From 96ab68a31bb2e33769aeccea9b7e51b23b65f59a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Thu, 9 Jun 2016 17:13:46 +0200 Subject: [PATCH] =?utf8?q?Einkaufsstornos=20auch=20verkn=C3=BCpfen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Analog zur Verkaufs-Ansicht auch die Einkaufsrechnungen bei Stornos verknüpfn --- SL/IR.pm | 22 ++++++++++++---------- bin/mozilla/ir.pl | 7 +++++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/SL/IR.pm b/SL/IR.pm index aa2ed316e..620fa1847 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -418,7 +418,7 @@ SQL dbh => $dbh); # link previous items with invoice items See IS.pm (no credit note -> no invoice item) - foreach (qw(delivery_order_items orderitems)) { + foreach (qw(delivery_order_items orderitems invoice)) { if (!$form->{useasnew} && $form->{"converted_from_${_}_id_$i"}) { RecordLinks->create_links('dbh' => $dbh, 'mode' => 'ids', @@ -758,16 +758,18 @@ SQL Common::webdav_folder($form); - # Link this record to the records it was created from. - if ($form->{convert_from_oe_ids}) { - RecordLinks->create_links('dbh' => $dbh, - 'mode' => 'ids', - 'from_table' => 'oe', - 'from_ids' => $form->{convert_from_oe_ids}, - 'to_table' => 'ap', - 'to_id' => $form->{id}, + # Link this record to the records it was created from order or invoice (storno) + foreach (qw(oe ap)) { + if ($form->{"convert_from_${_}_ids"}) { + RecordLinks->create_links('dbh' => $dbh, + 'mode' => 'ids', + 'from_table' => $_, + 'from_ids' => $form->{"convert_from_${_}_ids"}, + 'to_table' => 'ap', + 'to_id' => $form->{id}, ); - delete $form->{convert_from_oe_ids}; + delete $form->{"convert_from_${_}_ids"}; + } } my @convert_from_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{convert_from_do_ids}; diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index e08c4355d..5ec505a9e 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -334,7 +334,7 @@ sub form_header { max_dunning_level dunning_amount shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptogln shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts cursor_fokus - convert_from_do_ids convert_from_oe_ids show_details gldate useasnew + convert_from_do_ids convert_from_oe_ids convert_from_ap_ids show_details gldate useasnew ), @custom_hiddens, map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}]; @@ -626,7 +626,8 @@ sub storno { $form->{paidaccounts} = 0; map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ gldate_ acc_trans_id_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form }; # set new ids for storno invoice - delete $form->{"invoice_id_$_"} for 1 .. $form->{"rowcount"}; + # set new persistent ids for storno invoice items + $form->{"converted_from_invoice_id_$_"} = delete $form->{"invoice_id_$_"} for 1 .. $form->{"rowcount"}; # saving the history if(!exists $form->{addition} && $form->{id} ne "") { @@ -637,6 +638,8 @@ sub storno { } # /saving the history + # record link invoice to storno + $form->{convert_from_ap_ids} = $form->{id}; $form->{storno_id} = $form->{id}; $form->{storno} = 1; $form->{id} = ""; -- 2.20.1