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'" };
35 $_[0]->record->is_sales
36 ? $_[0]->make_sellprice
37 : $_[0]->make_lastcost
45 return SL::PriceSource::Price->new(
46 price => $self->part->sellprice,
48 description => t8('Sellprice'),
49 price_source => $self,
56 return SL::PriceSource::Price->new(
57 price => $self->part->listprice,
59 description => t8('List Price'),
60 price_source => $self,
67 return SL::PriceSource::Price->new(
68 price => $self->part->lastcost,
70 description => t8('Lastcost'),
71 price_source => $self,