X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/38b898b0cfebd96c3764d1506ad0a1358cf351f0..6f063101b0d1c37da024f46b9481267b869a945e:/SL/DB/Invoice.pm diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 3f94795ee..0e9616651 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -130,7 +130,10 @@ sub new_from { require SL::DB::Employee; - my $terms = $source->can('payment_id') && $source->payment_id ? $source->payment_terms->terms_netto : 0; + my $terms = $source->can('payment_id') && $source->payment_id ? $source->payment_terms + : $source->customer_id ? $source ->customer->payment_terms + : undef; + my (@columns, @item_columns, $item_parent_id_column, $item_parent_column); if (ref($source) eq 'SL::DB::Order') { @@ -151,7 +154,8 @@ sub new_from { cp_id language_id taxzone_id shipto_id globalproject_id transaction_description currency_id delivery_term_id), @columns), transdate => DateTime->today_local, gldate => DateTime->today_local, - duedate => DateTime->today_local->add(days => $terms * 1), + duedate => DateTime->today_local->add(days => ($terms ? $terms->terms_netto * 1 : 1)), + payment_id => $terms ? $terms->id : undef, invoice => 1, type => 'invoice', storno => 0,