Anzahlungs-Rg.: keine weitere Rückbuchung bei erneutem Buchen einer Schluss-Rg
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 26 Nov 2021 15:35:13 +0000 (16:35 +0100)
committerJan Büren <jan@kivitendo.de>
Mon, 14 Feb 2022 12:52:01 +0000 (13:52 +0100)
SL/IS.pm

index 3bcc0da..1340fcb 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -734,6 +734,8 @@ sub _post_invoice {
 
   my $all_units = AM->retrieve_units($myconfig, $form);
 
+  my $already_booked = !!$form->{id};
+
   if (!$payments_only) {
     if ($form->{storno}) {
       _delete_transfers($dbh, $form, $form->{storno_id});
@@ -1060,7 +1062,7 @@ SQL
   my $taxdate = $form->{tax_point} ||$form->{deliverydate} || $form->{invdate};
 
   # better type? maybe define Invoice->invoice_type
-  if ($form->{type} ne 'invoice_for_advance_payment') {
+  if (!$already_booked && $form->{type} ne 'invoice_for_advance_payment') {
     my $invoices_for_advance_payment = $self->_get_invoices_for_advance_payment($form->{convert_from_ar_ids} || $form->{id});
     if (scalar @$invoices_for_advance_payment > 0) {
       # reverse booking for invoices for advance payment
@@ -1070,9 +1072,6 @@ SQL
         # delete ?
         # --> is implemented below (bookings are marked in memo field)
         #
-        # post twice case ?
-        # ?
-        #
         # TODO: helper table acc_trans_advance_payment
         # trans_id for final invoice connects to acc_trans_id here
         # my $booking = SL::DB::AccTrans->new( ...)