Commit 9da2d2d2 authored by Jérome Perrin's avatar Jérome Perrin

bank_reconciliation: properly support payment at previous bank statement date

Payments made on the date of previous bank statement but not at 00:00 were
not taken into account in this constraint, which leaded to false positive preventing
to open the next bank reconciliation when previous one had a payment with an
accounting date on the day of the bank statement but not at 00:00
parent 6a70229e
...@@ -6,9 +6,7 @@ if context.getSourcePayment(): ...@@ -6,9 +6,7 @@ if context.getSourcePayment():
precision = context.getQuantityPrecisionFromResource( precision = context.getQuantityPrecisionFromResource(
context.getSourcePaymentValue().getPriceCurrency()) context.getSourcePaymentValue().getPriceCurrency())
at_date = context.getStartDate()
assert at_date
return round(context.getQuantityRangeMin(), precision) \ return round(context.getQuantityRangeMin(), precision) \
== round(context.BankReconciliation_getReconciledAccountBalance( == round(context.BankReconciliation_getReconciledAccountBalance(
at_date=at_date), precision) at_date=context.getStartDate().latestTime()), precision)
...@@ -333,7 +333,7 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase): ...@@ -333,7 +333,7 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
stop_date=DateTime(2014, 1, 31)) stop_date=DateTime(2014, 1, 31))
previous_bank_reconciliation.open() previous_bank_reconciliation.open()
self._makeOne( reconcilied_payment = self._makeOne(
portal_type='Payment Transaction', portal_type='Payment Transaction',
simulation_state='delivered', simulation_state='delivered',
source_payment_value=self.bank_account, source_payment_value=self.bank_account,
...@@ -390,6 +390,15 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase): ...@@ -390,6 +390,15 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
[str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()], [str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()],
['Previous bank statement balance does not match reconciled balance at previous bank statement date']) ['Previous bank statement balance does not match reconciled balance at previous bank statement date'])
# edge case, payments on the day of previous statement date, but after 00:00 are reconciled at the
# previous bank statement date.
reconcilied_payment.setStartDate(DateTime(2014, 1, 31, 12, 34))
bank_reconciliation.setQuantityRangeMin(100)
self.tic()
self.assertEqual(
[str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()], [])
bank_reconciliation.setQuantityRangeMin(10)
# These constraints are only verified when we go from open to close state. # These constraints are only verified when we go from open to close state.
# (that is why the bank reconciliation have been openned for the # (that is why the bank reconciliation have been openned for the
# assertions above) # assertions above)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment