Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 89b26688

Von Sven Schöling vor mehr als 9 Jahren hinzugefügt

  • ID 89b2668811eac6023ad58322e2f9970ddb6a27c9
  • Vorgänger c653b98f
  • Nachfolger 766ed2a6

PriceSource: Rabattbehandlung

Unterschiede anzeigen:

SL/PriceSource/Price.pm
7 7
  scalar => [ qw(price description spec price_source invalid missing) ],
8 8
);
9 9

  
10
use SL::DB::Helper::Attr;
10
require SL::DB::Helper::Attr;
11 11
SL::DB::Helper::Attr::make(__PACKAGE__,
12 12
  price => 'numeric(15,5)',
13 13
);
14 14

  
15 15
sub source {
16 16
  $_[0]->price_source
17
  ?  $_[0]->price_source->name . '/' . $_[0]->spec
17
  ? $_[0]->price_source->name . '/' . $_[0]->spec
18 18
  : '';
19 19
}
20 20

  
......
31 31

  
32 32
  $self->price_source
33 33
    ? $self->price_source->description
34
    : $self->description 
34
    : $self->description
35 35
}
36 36

  
37 37
sub to_str {
38
  "source: @{[ $_[0]->source ]}, price: @{[ $_[0]->price]}, description: @{[ $_[0]->description ]}"
38
  "source: @{[ $_[0]->source ]}, price: @{[ $_[0]->price ]}, description: @{[ $_[0]->description ]}"
39 39
}
40 40

  
41 41
1;
......
53 53
  # in PriceSource::Base implementation
54 54
  $price = SL::PriceSource::Price->new(
55 55
    price        => 10.3,
56
    spec         => '10.3', # something you can easily parse later
57
    description  => t8('Fix price 10.3'),
56
    spec         => '3', # something you can easily parse later
57
    description  => t8('Fix price 10.3 for customer 3'),
58 58
    price_source => $self,
59 59
  )
60 60

  
61
  # special empty price in SL::PriceSource
61
  # special empty price in SL::PriceSource, for internal use.
62 62
  SL::PriceSource::Price->new(
63 63
    description => t8('None (PriceSource)'),
64 64
  );
65 65

  
66
  # invalid price
66
  # price can't be restored
67 67
  SL::PriceSource::Price->new(
68
    price        => $original_price,
69
    spec         => $original_spec,
70
    description  => $original_description,
71
    invalid      => t8('Offer expired #1 weeks ago', $dt->delta_weeks),
68
    missing      => t8('Um, sorry, cannot find that one'),
72 69
    price_source => $self,
73 70
  );
74 71

  
75
  # missing price
72
  # invalid price
76 73
  SL::PriceSource::Price->new(
77
    price        => $original_price,              # will keep last entered price
74
    price        => $original_price,
78 75
    spec         => $original_spec,
79
    description  => '',
80
    missing      => t8('Um, sorry, cannot find that one'),
76
    description  => $original_description,
77
    invalid      => t8('Offer expired #1 weeks ago', $dt->delta_weeks),
81 78
    price_source => $self,
82 79
  );
83 80

  
84

  
85 81
=head1 DESCRIPTION
86 82

  
87 83
See L<SL::PriceSource> for information about the mechanism.
......
97 93

  
98 94
The price. A price of 0 is special and is considered undesirable. If passed as
99 95
part of C<available_prices> it will be filtered out. If returned as
100
C<best_price> or C<price_from_source> it will be warned about.
96
C<best_price> or C<price_from_source> it will trigger a warning.
101 97

  
102 98
=item C<spec>
103 99

  
......
118 114
OPTIONAL. Both indicator and localized message that the price with this spec
119 115
could not be reproduced and should be changed.
120 116

  
117
If price is missing, you do not need to supply anything except C<source>.
118

  
121 119
=item C<invalid>
122 120

  
123 121
OPTIONAL. Both indicator and localized message that the conditions for this
124 122
price are no longer valid, and that the price should be changed.
125 123

  
124
If price is missing, you do not need to supply anything except C<source>.
125

  
126 126
=back
127 127

  
128 128
=head1 SEE ALSO

Auch abrufbar als: Unified diff