1 package SL::DB::PurchaseInvoice;
 
   7 use SL::DB::MetaSetup::PurchaseInvoice;
 
   8 use SL::DB::Manager::PurchaseInvoice;
 
   9 use SL::DB::Helper::LinkedRecords;
 
  10 use SL::Locale::String qw(t8);
 
  12 # The calculator hasn't been adjusted for purchase invoices yet.
 
  13 # use SL::DB::Helper::PriceTaxCalculator;
 
  15 __PACKAGE__->meta->add_relationship(
 
  17     type         => 'one to many',
 
  18     class        => 'SL::DB::InvoiceItem',
 
  19     column_map   => { id => 'trans_id' },
 
  20     manager_args => { with_objects => [ 'part' ] }
 
  22   sepa_export_items => {
 
  23     type            => 'one to many',
 
  24     class           => 'SL::DB::SepaExportItem',
 
  25     column_map      => { id => 'ap_id' },
 
  26     manager_args    => { with_objects => [ 'sepa_export' ] }
 
  30     class           => 'SL::DB::Shipto',
 
  31     column_map      => { id => 'trans_id' },
 
  32     query_args      => [ module => 'AP' ],
 
  35     type         => 'one to many',
 
  36     class        => 'SL::DB::AccTransaction',
 
  37     column_map   => { id => 'trans_id' },
 
  38     manager_args => { with_objects => [ 'chart' ],
 
  39                       sort_by      => 'acc_trans_id ASC' }
 
  43 __PACKAGE__->meta->initialize;
 
  45 sub items { goto &invoiceitems; }
 
  46 sub add_items { goto &add_invoiceitems; }
 
  51   return [ sort {$a->position <=> $b->position } @{ $self->items } ];
 
  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)');