From 0560b39eef592a150913baf51cd198a407b31a7a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 27 Feb 2015 01:54:22 +0100 Subject: [PATCH] =?utf8?q?Auslagern=20in=20VK-Rechnung:=20L=C3=B6schen=20d?= =?utf8?q?er=20Lagerbewegung=20beim=20L=C3=B6schen/Storno=20der=20Rechnung?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/IS.pm | 18 ++++++++++++++++++ bin/mozilla/is.pl | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/SL/IS.pm b/SL/IS.pm index 6a8ef4635..9ae430761 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -587,8 +587,12 @@ sub post_invoice { my $all_units = AM->retrieve_units($myconfig, $form); if (!$payments_only) { + if ($form->{storno}) { + _delete_transfers($dbh, $form, $form->{storno_id}); + } if ($form->{id}) { &reverse_invoice($dbh, $form); + _delete_transfers($dbh, $form, $form->{id}); } else { my $trans_number = SL::TransNumber->new(type => $form->{type}, dbh => $dbh, number => $form->{invnumber}, save => 1); @@ -1348,6 +1352,19 @@ sub _determine_wh_and_bin { return ($wh_id, $bin_id); } +sub _delete_transfers { + $::lxdebug->enter_sub; + + my ($dbh, $form, $id) = @_; + + my $query = qq|DELETE FROM inventory WHERE invoice_id + IN (SELECT id FROM invoice WHERE trans_id = ?)|; + + do_query($form, $dbh, $query, $id); + + $::lxdebug->leave_sub; +} + sub _delete_payments { $main::lxdebug->enter_sub(); @@ -1654,6 +1671,7 @@ sub delete_invoice { my $dbh = $form->get_standard_dbh; &reverse_invoice($dbh, $form); + _delete_transfers($dbh, $form, $form->{id}); my @values = (conv_i($form->{id})); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 0bcd3c360..7e14454df 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -782,7 +782,7 @@ sub post { # If transfer_out is requested, get rose db handle and do post and # transfer out in one transaction. Otherwise just post the invoice. - if ($::instance_conf->get_is_transfer_out) { + if ($::instance_conf->get_is_transfer_out && $form->{type} ne 'credit_note' && !$form->{storno}) { require SL::DB::Inventory; my $rose_db = SL::DB::Inventory->new->db; my $error; -- 2.20.1