]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/BankTransaction.pm
BankTransaction: Treffer für Kreditorengutschriften erhöhen
[mfinanz.git] / SL / DB / BankTransaction.pm
index 9c5b56056585ee0195d482eae657fdbd89316577..0d6895b2343b3edc1421b14e9679bf807b574150 100644 (file)
@@ -162,11 +162,12 @@ sub get_agreement_with_invoice {
   }
 
   #check sign
-  if ( $invoice->is_sales && $self->amount < 0 ) {
+  if ( $invoice->is_sales && $self->amount < 0 ) { # TODO debit note
     $agreement += $points{wrong_sign};
     $rule_matches .= 'wrong_sign(' . $points{'wrong_sign'} . ') ';
   }
-  if ( ! $invoice->is_sales && $self->amount > 0 ) {
+  if (( !$invoice->is_sales && $invoice->amount > 0 && $self->amount > 0)  ||
+      ( !$invoice->is_sales && $invoice->amount < 0 && $self->amount < 0)     ) { # credit note
     $agreement += $points{wrong_sign};
     $rule_matches .= 'wrong_sign(' . $points{'wrong_sign'} . ') ';
   }
@@ -297,6 +298,20 @@ sub not_assigned_amount {
   return $not_assigned_amount;
 
 }
+sub closed_period {
+  my ($self) = @_;
+
+  # check for closed period
+  croak t8('Illegal date') unless ref $self->valutadate eq 'DateTime';
+
+
+  my $closedto = $::locale->parse_date_to_object($::instance_conf->get_closedto);
+  if ( ref $closedto && $self->valutadate < $closedto ) {
+    return 1;
+  } else {
+    return 0;
+  }
+}
 1;
 
 __END__
@@ -354,6 +369,11 @@ Usage:
 Returns the not open amount of this bank transaction.
 Dies if the return amount is higher than the original amount.
 
+=item C<closed_period>
+
+Returns 1 if the bank transaction valutadate is in a closed period, 0 if the
+valutadate of the bank transaction is not in a closed period.
+
 =back
 
 =head1 AUTHOR