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;
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 = (
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
};
};
- # 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
+# };
+# };
return ($agreement,$rule_matches);
};