From: Bernd Bleßmann Date: Fri, 27 Feb 2015 00:54:22 +0000 (+0100) Subject: Auslagern in VK-Rechnung: Löschen der Lagerbewegung beim Löschen/Storno der Rechnung X-Git-Tag: release-3.2.1~44 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0560b39eef592a150913baf51cd198a407b31a7a;p=kivitendo-erp.git Auslagern in VK-Rechnung: Löschen der Lagerbewegung beim Löschen/Storno der Rechnung --- 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;