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::DB::Helper::Payment qw(:ALL);
12 use SL::Locale::String qw(t8);
14 # The calculator hasn't been adjusted for purchase invoices yet.
15 # use SL::DB::Helper::PriceTaxCalculator;
17 __PACKAGE__->meta->add_relationship(
19 type => 'one to many',
20 class => 'SL::DB::InvoiceItem',
21 column_map => { id => 'trans_id' },
22 manager_args => { with_objects => [ 'part' ] }
24 sepa_export_items => {
25 type => 'one to many',
26 class => 'SL::DB::SepaExportItem',
27 column_map => { id => 'ap_id' },
28 manager_args => { with_objects => [ 'sepa_export' ] }
32 class => 'SL::DB::Shipto',
33 column_map => { id => 'trans_id' },
34 query_args => [ module => 'AP' ],
37 type => 'one to many',
38 class => 'SL::DB::AccTransaction',
39 column_map => { id => 'trans_id' },
40 manager_args => { with_objects => [ 'chart' ],
41 sort_by => 'acc_trans_id ASC' }
45 __PACKAGE__->meta->initialize;
47 __PACKAGE__->attr_html('notes');
49 sub items { goto &invoiceitems; }
50 sub add_items { goto &add_invoiceitems; }
55 return [ sort {$a->position <=> $b->position } @{ $self->items } ];
59 # For compatibility with Order, DeliveryOrder
60 croak 'not an accessor' if @_ > 1;
79 return t8('AP Transaction (abbreviation)') if !$self->invoice && !$self->storno;
80 return t8('AP Transaction (abbreviation)') . '(' . t8('Storno (one letter abbreviation)') . ')' if !$self->invoice && $self->storno;
81 return t8('Invoice (one letter abbreviation)'). '(' . t8('Storno (one letter abbreviation)') . ')' if $self->storno;
82 return t8('Invoice (one letter abbreviation)');
90 $html = SL::Presenter->get->purchase_invoice($self, display => 'inline') if $self->invoice;
91 $html = SL::Presenter->get->ap_transaction($self, display => 'inline') if !$self->invoice;