X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=SL%2FIR.pm;h=a87fca31be57fb240dd3d784d7fca1d59ce51429;hb=b8125c17c8add08c9b84fb054f797547a853dd3a;hp=33f3ec4dfa7cc83d7d58513f67fefb673798f228;hpb=be42a45043cab936e86e91aa895c6fc25bab079f;p=kivitendo-erp.git diff --git a/SL/IR.pm b/SL/IR.pm index 33f3ec4df..a87fca31b 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -373,7 +373,7 @@ sub post_invoice { dbh => $dbh, row => $i, sub_module => 'invoice', - may_converted_from => ['delivery_order_items', 'orderitems']); + 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 @@ -416,9 +416,10 @@ SQL name_prefix => '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' => $_, @@ -426,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"}; } }