- from_table => 'bank_transactions',
- from_id => $bt_id,
- to_table => $arap->is_sales ? 'ar' : 'ap',
- to_id => $arap->id,
- );
-
- my $existing = SL::DB::Manager::RecordLink->get_all(where => \@props, limit => 1)->[0];
-
- SL::DB::RecordLink->new(@props)->save if !$existing;
+ from_table => 'bank_transactions',
+ from_id => $bt_id,
+ to_table => $arap->is_sales ? 'ar' : 'ap',
+ to_id => $arap->id,
+ );
+
+ 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;
+ }
+ }