]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/BankTransaction.pm
Funktion "Erzeugnis fertigen" sucht Bestandteile im falschen Lager.(3)
[mfinanz.git] / SL / Controller / BankTransaction.pm
index 5821d3eb8aedcd0f0aee336a2056b5e65b43c33c..c07b799e60961b501797056e63723d68779085ff 100644 (file)
@@ -436,6 +436,18 @@ sub action_save_invoices {
           );
 
       SL::DB::RecordLink->new(@props)->save;
+
+      # "close" a sepa_export_item if it exists
+      # code duplicated in action_save_proposals!
+      # currently only works, if there is only exactly one open sepa_export_item
+      if ( my $seis = $invoice->find_sepa_export_items({ executed => 0 }) ) {
+        if ( scalar @$seis == 1 ) {
+          # moved the execution and the check for sepa_export into a method,
+          # this isn't part of a transaction, though
+          $seis->[0]->set_executed if $invoice->id == $seis->[0]->arap_id;
+        };
+      };
+
     }
     $bank_transaction->save;
   }
@@ -477,6 +489,17 @@ sub action_save_proposals {
         );
 
     SL::DB::RecordLink->new(@props)->save;
+
+    # code duplicated in action_save_invoices!
+    # "close" a sepa_export_item if it exists
+    # currently only works, if there is only exactly one open sepa_export_item
+    if ( my $seis = $arap->find_sepa_export_items({ executed => 0 }) ) {
+      if ( scalar @$seis == 1 ) {
+        # moved the execution and the check for sepa_export into a method,
+        # this isn't part of a transaction, though
+        $seis->[0]->set_executed if $arap->id == $seis->[0]->arap_id;
+      };
+    };
   }
 
   flash('ok', t8('#1 proposal(s) saved.', scalar @{ $::form->{proposal_ids} }));