X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FInvoice.pm;h=82cf66b5e2ce00de33ef6422443ec79016b4820b;hb=8e7908eb9db56a7661a69cf91561ee067760ab5b;hp=065d2b3cd27f315425e3f990a6fc965b8925b06b;hpb=a87694dc525b4eabff11029f1e5401621e2bd3bc;p=kivitendo-erp.git diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 065d2b3cd..82cf66b5e 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -138,14 +138,10 @@ sub new_from { require SL::DB::Employee; - 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') { - @columns = qw(quonumber payment_id delivery_customer_id delivery_vendor_id); + @columns = qw(quonumber delivery_customer_id delivery_vendor_id); @item_columns = qw(subtotal); $item_parent_id_column = 'trans_id'; @@ -158,12 +154,13 @@ sub new_from { $item_parent_column = 'delivery_order'; } + my $terms = $source->can('payment_id') ? $source->payment_terms : undef; + my %args = ( map({ ( $_ => $source->$_ ) } qw(customer_id taxincluded shippingpoint shipvia notes intnotes salesman_id cusordnumber ordnumber department_id - cp_id language_id taxzone_id shipto_id globalproject_id transaction_description currency_id delivery_term_id), @columns), + cp_id language_id taxzone_id shipto_id globalproject_id transaction_description currency_id delivery_term_id payment_id), @columns), transdate => DateTime->today_local, gldate => DateTime->today_local, - duedate => DateTime->today_local->add(days => ($terms ? $terms->terms_netto * 1 : 1)), - payment_id => $terms ? $terms->id : undef, + duedate => $terms ? $terms->calc_date(reference_date => DateTime->today_local) : DateTime->today_local, invoice => 1, type => 'invoice', storno => 0,