1 package SL::DB::PurchaseInvoice;
7 use SL::DB::MetaSetup::PurchaseInvoice;
8 use SL::DB::Manager::PurchaseInvoice;
9 use SL::DB::Helper::AttrHTML;
10 use SL::DB::Helper::LinkedRecords;
11 use SL::Locale::String qw(t8);
13 # The calculator hasn't been adjusted for purchase invoices yet.
14 # use SL::DB::Helper::PriceTaxCalculator;
16 __PACKAGE__->meta->add_relationship(
18 type => 'one to many',
19 class => 'SL::DB::InvoiceItem',
20 column_map => { id => 'trans_id' },
21 manager_args => { with_objects => [ 'part' ] }
23 sepa_export_items => {
24 type => 'one to many',
25 class => 'SL::DB::SepaExportItem',
26 column_map => { id => 'ap_id' },
27 manager_args => { with_objects => [ 'sepa_export' ] }
31 class => 'SL::DB::Shipto',
32 column_map => { id => 'trans_id' },
33 query_args => [ module => 'AP' ],
36 type => 'one to many',
37 class => 'SL::DB::AccTransaction',
38 column_map => { id => 'trans_id' },
39 manager_args => { with_objects => [ 'chart' ],
40 sort_by => 'acc_trans_id ASC' }
44 __PACKAGE__->meta->initialize;
46 __PACKAGE__->attr_html('notes');
48 sub items { goto &invoiceitems; }
49 sub add_items { goto &add_invoiceitems; }
54 return [ sort {$a->position <=> $b->position } @{ $self->items } ];
58 # For compatibility with Order, DeliveryOrder
59 croak 'not an accessor' if @_ > 1;
78 return t8('AP Transaction (abbreviation)') if !$self->invoice && !$self->storno;
79 return t8('AP Transaction (abbreviation)') . '(' . t8('Storno (one letter abbreviation)') . ')' if !$self->invoice && $self->storno;
80 return t8('Invoice (one letter abbreviation)'). '(' . t8('Storno (one letter abbreviation)') . ')' if $self->storno;
81 return t8('Invoice (one letter abbreviation)');