+ # e.g. datediff > 120
+ }
+ }
+
+ # if there is exactly one non-executed sepa_export_item for the invoice
+ my $seis = $params{sepa_export_items}
+ ? [ grep { $invoice->id == ($invoice->is_sales ? $_->ar_id : $_->ap_id) } @{ $params{sepa_export_items} } ]
+ : $invoice->find_sepa_export_items({ executed => 0 });
+ if ($seis) {
+ if (scalar @$seis == 1) {
+ my $sei = $seis->[0];
+
+ # test for amount and id matching only, sepa transfer date and bank
+ # transaction date needn't match
+ if (abs($self->amount) == ($sei->amount) && $invoice->id == $sei->arap_id) {
+ $agreement += $points{sepa_export_item};
+ $rule_matches .= 'sepa_export_item(' . $points{'sepa_export_item'} . ') ';
+ }
+ } else {
+ # zero or more than one sepa_export_item, do nothing for this invoice
+ # zero: do nothing, no sepa_export_item exists, no match
+ # more than one: does this ever apply? Currently you can't create sepa
+ # exports for invoices that already have a non-executed sepa_export
+ # TODO: Catch the more than one case. User is allowed to split
+ # payments for one invoice item in one sepa export.
+ }
+ }