1 package SL::PriceSource::MasterData;
4 use parent qw(SL::PriceSource::Base);
6 use SL::PriceSource::Price;
7 use SL::Locale::String;
9 sub name { 'master_data' }
11 sub description { t8('Master Data') }
13 sub available_prices {
14 my ($self, %params) = @_;
16 return () unless $self->part;
18 grep { $_->price > 0 } $self->record->is_sales
19 ? ($self->make_sellprice, $self->make_listprice)
20 : ($self->make_lastcost, $self->make_listprice);
23 sub available_discounts { }
25 sub price_from_source {
26 my ($self, $source, $spec) = @_;
28 $spec eq 'sellprice' ? $self->make_sellprice
29 : $spec eq 'lastcost' ? $self->make_lastcost
30 : $spec eq 'listprice' ? $self->make_listprice
31 : do { die "unknown spec '$spec'" };
34 sub discount_from_source { }
37 $_[0]->record->is_sales
38 ? $_[0]->make_sellprice
39 : $_[0]->make_lastcost
45 $_[0]->record_item ? $_[0]->record_item->unit_multiplier : 1
51 return SL::PriceSource::Price->new(
52 price => $self->part->sellprice * $self->unit_mul,
54 description => t8('Sellprice'),
55 price_source => $self,
62 return SL::PriceSource::Price->new(
63 price => $self->part->listprice * $self->unit_mul,
65 description => t8('List Price'),
66 price_source => $self,
73 return SL::PriceSource::Price->new(
74 price => $self->part->lastcost * $self->unit_mul,
76 description => t8('Lastcost'),
77 price_source => $self,