X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FInvoice.pm;h=302179c807777fb9eafef980f8d70482c8bf6cfb;hb=73d810a4ac3395dc6d8012a52b6c787dedf932b1;hp=0d21ef8b29bd82fa2e245308f04bac09f8291e56;hpb=16c6be411e2eddf778e665b0da6c452c42b676af;p=kivitendo-erp.git diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 0d21ef8b2..302179c80 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -33,6 +33,12 @@ __PACKAGE__->meta->add_relationship( class => 'SL::DB::Invoice', column_map => { id => 'storno_id' }, }, + sepa_export_items => { + type => 'one to many', + class => 'SL::DB::SepaExportItem', + column_map => { id => 'ar_id' }, + manager_args => { with_objects => [ 'sepa_export' ] } + }, ); __PACKAGE__->meta->initialize; @@ -41,6 +47,12 @@ __PACKAGE__->meta->initialize; sub items { goto &invoiceitems; } +sub items_sorted { + my ($self) = @_; + + return [ sort {$a->id <=> $b->id } @{ $self->items } ]; +} + sub is_sales { # For compatibility with Order, DeliveryOrder croak 'not an accessor' if @_ > 1; @@ -92,9 +104,9 @@ sub new_from { my $terms = $source->can('payment_id') && $source->payment_id ? $source->payment_terms->terms_netto : 0; - my %args = ( map({ ( $_ => $source->$_ ) } qw(customer_id taxincluded shippingpoint shipvia notes intnotes curr salesman_id cusordnumber ordnumber quonumber + my %args = ( map({ ( $_ => $source->$_ ) } qw(customer_id taxincluded shippingpoint shipvia notes intnotes salesman_id cusordnumber ordnumber quonumber department_id cp_id language_id payment_id delivery_customer_id delivery_vendor_id taxzone_id shipto_id - globalproject_id transaction_description)), + globalproject_id transaction_description currency_id)), transdate => DateTime->today_local, gldate => DateTime->today_local, duedate => DateTime->today_local->add(days => $terms * 1), @@ -122,7 +134,7 @@ sub new_from { base_qty subtotal longdescription lastcost price_factor_id)), deliverydate => $source_item->reqdate, fxsellprice => $source_item->sellprice,); - } @{ $source->items }; + } @{ $source->items_sorted }; $invoice->invoiceitems(\@items);