X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FBankTransaction.pm;h=6ad0348c7ffe46bf38a6612616dd8f49a37fb02f;hb=b269674b6b0e99818c3643d4fc3271a8ce83b8c6;hp=e91651a98bcb5373f6c9fd9a593e132da70102bb;hpb=88d162cc5e8e8d3810059d918a1eef6a2b205984;p=kivitendo-erp.git diff --git a/SL/DB/BankTransaction.pm b/SL/DB/BankTransaction.pm index e91651a98..6ad0348c7 100644 --- a/SL/DB/BankTransaction.pm +++ b/SL/DB/BankTransaction.pm @@ -151,7 +151,7 @@ sub get_agreement_with_invoice { my $cvname; $cvname = $invoice->customer->name if $invoice->is_sales; $cvname = $invoice->vendor->name if ! $invoice->is_sales; - if ( $cvname && $self->purpose =~ /\b$cvname\b/i ) { + if ( $cvname && $self->purpose =~ /\b\Q$cvname\E\b/i ) { $agreement += $points{cust_vend_name_in_purpose}; $rule_matches .= 'cust_vend_name_in_purpose(' . $points{'cust_vend_name_in_purpose'} . ') '; }; @@ -209,27 +209,28 @@ sub get_agreement_with_invoice { }; }; -# # if there is exactly one non-executed sepa_export_item for the invoice -# if ( my $seis = $invoice->find_sepa_export_items({ executed => 0 }) ) { -# 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 -# my $arap = $invoice->is_sales ? 'ar' : 'ap'; -# 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 -# }; -# }; + # if there is exactly one non-executed sepa_export_item for the invoice + if ( my $seis = $invoice->find_sepa_export_items({ executed => 0 }) ) { + 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 + my $arap = $invoice->is_sales ? 'ar' : 'ap'; + + 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. + } + } return ($agreement,$rule_matches); };