X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FBankTransaction.pm;h=e91651a98bcb5373f6c9fd9a593e132da70102bb;hb=728f5827cddfd7e7ca7bd7c36a3d40a9ba311d16;hp=051245682f99973aad1994b3975bf740a7eed688;hpb=5d02d52104d470736dc1ec73b6da8eeac4ad58c8;p=kivitendo-erp.git diff --git a/SL/DB/BankTransaction.pm b/SL/DB/BankTransaction.pm index 051245682..e91651a98 100644 --- a/SL/DB/BankTransaction.pm +++ b/SL/DB/BankTransaction.pm @@ -8,6 +8,7 @@ use strict; use SL::DB::MetaSetup::BankTransaction; use SL::DB::Manager::BankTransaction; use SL::DB::Helper::LinkedRecords; +use Carp; require SL::DB::Invoice; require SL::DB::PurchaseInvoice; @@ -49,7 +50,7 @@ sub linked_invoices { sub get_agreement_with_invoice { my ($self, $invoice) = @_; - die "first argument is not an invoice object" + carp "get_agreement_with_invoice needs an invoice object as its first argument" unless ref($invoice) eq 'SL::DB::Invoice' or ref($invoice) eq 'SL::DB::PurchaseInvoice'; my %points = ( @@ -71,6 +72,7 @@ sub get_agreement_with_invoice { remote_account_number => 3, skonto_exact_amount => 5, wrong_sign => -1, + sepa_export_item => 5, ); my ($agreement,$rule_matches); @@ -110,11 +112,12 @@ sub get_agreement_with_invoice { if ( $invoice->skonto_date && abs(abs($invoice->amount_less_skonto) - abs($self->amount)) < 0.01) { $agreement += $points{skonto_exact_amount}; $rule_matches .= 'skonto_exact_amount(' . $points{'skonto_exact_amount'} . ') '; + $invoice->{skonto_type} = 'with_skonto_pt'; }; #search invoice number in purpose my $invnumber = $invoice->invnumber; - # invnumbernhas to have at least 3 characters + # invnumber has to have at least 3 characters my $squashed_purpose = $self->purpose; $squashed_purpose =~ s/ //g; if (length($invnumber) > 4 && $squashed_purpose =~ /$invnumber/ && $invoice->is_sales){ @@ -206,6 +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 +# }; +# }; + return ($agreement,$rule_matches); };