X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIR.pm;h=a87fca31be57fb240dd3d784d7fca1d59ce51429;hb=f143a10a13313bca78b97e107bd3b870e5db7d98;hp=dd042488bd6299675580cf7c26003ebe6dc493d0;hpb=d557935a1484e5ebbb15f0eabe107d74e192ff0b;p=kivitendo-erp.git diff --git a/SL/IR.pm b/SL/IR.pm index dd042488b..a87fca31b 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -369,7 +369,12 @@ sub post_invoice { next if $payments_only; - my $cvars; + CVar->get_non_editable_ic_cvars(form => $form, + dbh => $dbh, + row => $i, + sub_module => 'invoice', + may_converted_from => ['delivery_order_items', 'orderitems', 'invoice']); + if (!$form->{"invoice_id_$i"}) { # there is no persistent id, therefore create one with all necessary constraints my $q_invoice_id = qq|SELECT nextval('invoiceid')|; @@ -380,22 +385,7 @@ sub post_invoice { do_query($form, $dbh, $q_create_invoice_id, conv_i($form->{"invoice_id_$i"}), conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"})); $h_invoice_id->finish(); - - # get values for CVars from master data for new items - $cvars = CVar->get_custom_variables(dbh => $dbh, - module => 'IC', - trans_id => $form->{"id_$i"}, - ); - } else { - # get values for CVars from custom_variables for existing items - $cvars = CVar->get_custom_variables(dbh => $dbh, - module => 'IC', - sub_module => 'invoice', - trans_id => $form->{"invoice_id_$i"}, - ); } - # map only non-editable CVars to form (editable ones are already there) - map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars }; # save detail record in invoice table $query = < 'ic_', name_postfix => "_$i", dbh => $dbh); + # link previous items with invoice items See IS.pm (no credit note -> no invoice item) foreach (qw(delivery_order_items orderitems)) { - if ($form->{"converted_from_${_}_id_$i"}) { + if (!$form->{useasnew} && $form->{"converted_from_${_}_id_$i"}) { RecordLinks->create_links('dbh' => $dbh, 'mode' => 'ids', 'from_table' => $_, @@ -436,8 +427,8 @@ SQL 'to_table' => 'invoice', 'to_id' => $form->{"invoice_id_$i"}, ); - delete $form->{"converted_from_${_}_id_$i"}; } + delete $form->{"converted_from_${_}_id_$i"}; } } @@ -1656,5 +1647,4 @@ sub get_duedate { return $duedate; } - 1;