- if ( $bt->{remote_account_number} eq $_->vc_iban && $_->amount eq ($bt->amount * $factor)) {
- push ($bt->{proposals},$open_invoice );
- $bt->{agreement} = 20;
- $bt->{rule_matches} = 'sepa_export_item(20)';
- #$main::lxdebug->message(LXDebug->DEBUG2(),"found invoice");
- @all_sepa_invoices = grep { $_ != $open_invoice } @all_sepa_invoices;
- last;
+ if ( $bt->{remote_account_number} eq $_->vc_iban && abs(( $_->amount *1 ) - ($bt->amount * $factor)) < 0.01 ) {
+ ($open_invoice->{agreement}, $open_invoice->{rule_matches}) = $bt->get_agreement_with_invoice($open_invoice);
+ $open_invoice->{agreement} += 5;
+ $open_invoice->{rule_matches} .= 'sepa_export_item(5) ';
+ $main::lxdebug->message(LXDebug->DEBUG2(),"sepa invoice_id=".$open_invoice->id." agreement=".$open_invoice->{agreement}." rules matches=".$open_invoice->{rule_matches});
+ $open_invoice->{realamount} = $::form->format_amount(\%::myconfig,$open_invoice->amount*$factor,2);