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::AttrSorted;
 
  11 use SL::DB::Helper::LinkedRecords;
 
  12 use SL::DB::Helper::Payment qw(:ALL);
 
  13 use SL::Locale::String qw(t8);
 
  15 # The calculator hasn't been adjusted for purchase invoices yet.
 
  16 # use SL::DB::Helper::PriceTaxCalculator;
 
  18 __PACKAGE__->meta->add_relationship(
 
  20     type         => 'one to many',
 
  21     class        => 'SL::DB::InvoiceItem',
 
  22     column_map   => { id => 'trans_id' },
 
  23     manager_args => { with_objects => [ 'part' ] }
 
  25   sepa_export_items => {
 
  26     type            => 'one to many',
 
  27     class           => 'SL::DB::SepaExportItem',
 
  28     column_map      => { id => 'ap_id' },
 
  29     manager_args    => { with_objects => [ 'sepa_export' ] }
 
  33     class           => 'SL::DB::Shipto',
 
  34     column_map      => { id => 'trans_id' },
 
  35     query_args      => [ module => 'AP' ],
 
  38     type         => 'one to many',
 
  39     class        => 'SL::DB::AccTransaction',
 
  40     column_map   => { id => 'trans_id' },
 
  41     manager_args => { with_objects => [ 'chart' ],
 
  42                       sort_by      => 'acc_trans_id ASC' }
 
  46 __PACKAGE__->meta->initialize;
 
  48 __PACKAGE__->attr_html('notes');
 
  49 __PACKAGE__->attr_sorted('items');
 
  51 sub items { goto &invoiceitems; }
 
  52 sub add_items { goto &add_invoiceitems; }
 
  55   # For compatibility with Order, DeliveryOrder
 
  56   croak 'not an accessor' if @_ > 1;
 
  75   return t8('AP Transaction (abbreviation)') if !$self->invoice && !$self->storno;
 
  76   return t8('AP Transaction (abbreviation)') . '(' . t8('Storno (one letter abbreviation)') . ')' if !$self->invoice && $self->storno;
 
  77   return t8('Invoice (one letter abbreviation)'). '(' . t8('Storno (one letter abbreviation)') . ')' if $self->storno;
 
  78   return t8('Invoice (one letter abbreviation)');
 
  86   $html   = SL::Presenter->get->purchase_invoice($self, display => 'inline') if $self->invoice;
 
  87   $html   = SL::Presenter->get->ap_transaction($self, display => 'inline') if !$self->invoice;