Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e1c3b6b7

Von Bernd Bleßmann vor mehr als 9 Jahren hinzugefügt

  • ID e1c3b6b77d4407069cb09897a9e79cd8686e41bf
  • Vorgänger 9596d4a4
  • Nachfolger a4415997

PriceSources: discount_from_source analog zu price_from_source implemeniert.

Wenn keine zur Rabatt-Quelle passende Klasse gefunden werden kann, wird auch
hier ein spezieller leerer Rabatt zurückgeliefert.

Unterschiede anzeigen:

SL/PriceSource.pm
31 31
    : empty_price();
32 32
}
33 33

  
34
sub discount_from_source {
35
  my ($self, $source) = @_;
36
  my ($source_name, $spec) = split m{/}, $source, 2;
37

  
38
  my $class = SL::PriceSource::ALL->price_source_class_by_name($source_name);
39

  
40
  return $class
41
    ? $class->new(record_item => $self->record_item, record => $self->record)->discount_from_source($source, $spec)
42
    : empty_discount();
43
}
44

  
34 45
sub available_prices {
35 46
  map { $_->available_prices } $_[0]->all_price_sources;
36 47
}
......
54 65
  );
55 66
}
56 67

  
68
sub empty_discount {
69
  SL::PriceSource::Discount->new(
70
    description => t8('None (PriceSource Discount)'),
71
  );
72
}
73

  
57 74
1;
58 75

  
59 76
__END__
......
136 153

  
137 154
Attempts to retrieve a formerly calculated price with the same conditions
138 155

  
156
=item C<discount_from_source>
157

  
158
Attempts to retrieve a formerly calculated discount with the same conditions
159

  
139 160
=item C<available_prices>
140 161

  
141 162
Returns all available prices.
142 163

  
164
=item C<available_discounts>
165

  
166
Returns all available discounts.
167

  
143 168
=item C<best_price>
144 169

  
145 170
Attempts to get the best available price. returns L<empty_price> if no price is found.
146 171

  
172
=item C<best_discount>
173

  
174
Attempts to get the best available discount. returns L<empty_discount> if no discount is found.
175

  
147 176
=item C<empty_price>
148 177

  
149 178
A special empty price, that does not change the previously entered price, and
150 179
opens the price field to manual changes.
151 180

  
181
=item C<empty_discount>
182

  
183
A special empty discount, that does not change the previously entered discount, and
184
opens the discount field to manual changes.
185

  
152 186
=back
153 187

  
154 188
=head1 SEE ALSO
155 189

  
156 190
L<SL::PriceSource::Base>,
157 191
L<SL::PriceSource::Price>,
192
L<SL::PriceSource::Discount>,
158 193
L<SL::PriceSource::ALL>
159 194

  
160 195
=head1 BUGS AND CAVEATS
SL/PriceSource/Base.pm
21 21

  
22 22
sub price_from_source { die 'price_from_source needs to be implemented:' . "@_" }
23 23

  
24
sub discount_from_source { die 'discount_from_source needs to be implemented:' . "@_" }
25

  
24 26
sub part {
25 27
  $_[0]->record_item->part;
26 28
}
SL/PriceSource/Business.pm
28 28
  );
29 29
}
30 30

  
31
sub price_from_source {
31
sub price_from_source { }
32

  
33
sub discount_from_source {
32 34
  my ($self, $source, $spec) = @_;
33 35

  
34 36
  my $business = SL::DB::Business->load_cached($spec);
SL/PriceSource/Customer.pm
29 29
  );
30 30
}
31 31

  
32
sub price_from_source {
32
sub price_from_source { }
33

  
34
sub discount_from_source {
33 35
  my ($self, $source, $spec) = @_;
34 36

  
35 37
  my $customer = SL::DB::Customer->load_cached($spec);
SL/PriceSource/Makemodel.pm
39 39

  
40 40
}
41 41

  
42
sub discount_from_source { }
43

  
42 44
sub best_price {
43 45
  my ($self, %params) = @_;
44 46

  
SL/PriceSource/MasterData.pm
31 31
  : do { die "unknown spec '$spec'" };
32 32
}
33 33

  
34
sub discount_from_source { }
35

  
34 36
sub best_price {
35 37
  $_[0]->record->is_sales
36 38
  ? $_[0]->make_sellprice
SL/PriceSource/PriceRules.pm
44 44
sub price_from_source {
45 45
  my ($self, $source, $spec) = @_;
46 46

  
47
  my $rule = SL::DB::Manager::PriceRule->find_by(id => $spec);
48
  if ($rule->price_type != SL::DB::Manager::PriceRule::PRICE_DISCOUNT()) {
49
    return $self->make_price_from_rule($rule);
50
  }
51

  
52
  return;
53
}
54

  
55
sub discount_from_source {
56
  my ($self, $source, $spec) = @_;
57

  
47 58
  my $rule = SL::DB::Manager::PriceRule->find_by(id => $spec);
48 59
  if ($rule->price_type == SL::DB::Manager::PriceRule::PRICE_DISCOUNT()) {
49 60
    return $self->make_discount_from_rule($rule);
50
  } else {
51
    return $self->make_price_from_rule($rule);
52 61
  }
62

  
63
  return;
53 64
}
54 65

  
55 66
sub best_price {
SL/PriceSource/Pricegroup.pm
44 44
  return $self->make_price($price);
45 45
}
46 46

  
47
sub discount_from_source { }
48

  
47 49
sub best_price {
48 50
  my ($self, %params) = @_;
49 51

  
SL/PriceSource/Vendor.pm
28 28
  );
29 29
}
30 30

  
31
sub price_from_source {
31
sub price_from_source { }
32

  
33
sub discount_from_source {
32 34
  my ($self, $source, $spec) = @_;
33 35

  
34 36
  my $vendor = SL::DB::Vendor->load_cached($spec);
bin/mozilla/io.pl
345 345
    if ($form->{"id_${i}"} && !$is_delivery_order) {
346 346
      my $price_source  = SL::PriceSource->new(record_item => $record_item, record => $record);
347 347
      my $price         = $price_source->price_from_source($::form->{"active_price_source_$i"});
348
      my $discount      = $price_source->price_from_source($::form->{"active_discount_source_$i"});
348
      my $discount      = $price_source->discount_from_source($::form->{"active_discount_source_$i"});
349 349
      my $best_price    = $price_source->best_price;
350 350
      my $best_discount = $price_source->best_discount;
351 351
      $column_data{price_source} .= $cgi->button(-value => $price->source_description, -onClick => "kivi.io.price_chooser($i)");

Auch abrufbar als: Unified diff