Commit c61340e1 authored by Jérome Perrin's avatar Jérome Perrin

bank_reconciliation: properly support payment at previous bank statement date

See merge request nexedi/erp5!1264
parents 3453958d 9da2d2d2
Pipeline #11515 failed with stage
in 0 seconds
......@@ -6,9 +6,7 @@ if context.getSourcePayment():
precision = context.getQuantityPrecisionFromResource(
context.getSourcePaymentValue().getPriceCurrency())
at_date = context.getStartDate()
assert at_date
return round(context.getQuantityRangeMin(), precision) \
== round(context.BankReconciliation_getReconciledAccountBalance(
at_date=at_date), precision)
at_date=context.getStartDate().latestTime()), precision)
......@@ -333,7 +333,7 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
stop_date=DateTime(2014, 1, 31))
previous_bank_reconciliation.open()
self._makeOne(
reconcilied_payment = self._makeOne(
portal_type='Payment Transaction',
simulation_state='delivered',
source_payment_value=self.bank_account,
......@@ -368,30 +368,50 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
# reconciled balance must match
bank_reconciliation.setQuantityRangeMax(10)
self.assertEqual(1, len(bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()],
["Bank statement balance does not match reconciled balance"])
bank_reconciliation.setQuantityRangeMax(100)
self.assertEqual(0, len(bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()], [])
self.assertEqual(0, len(previous_bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in previous_bank_reconciliation.checkConsistency()], [])
previous_bank_reconciliation.setQuantityRangeMax(10)
self.assertEqual(1, len(previous_bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in previous_bank_reconciliation.checkConsistency()],
['Bank statement balance does not match reconciled balance'])
previous_bank_reconciliation.setQuantityRangeMax(100)
# Previous reconciled balance must match as well
bank_reconciliation.setStartDate(DateTime(2014, 1, 31))
bank_reconciliation.setQuantityRangeMin(10)
self.assertEqual(1, len(bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()],
['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.
# (that is why the bank reconciliation have been openned for the
# assertions above)
with self.assertRaises(ValidationFailed):
with self.assertRaisesRegexp(
ValidationFailed,
"Previous bank statement balance does not match reconciled balance at previous bank statement date"):
self.portal.portal_workflow.doActionFor(
bank_reconciliation,
'close_action')
bank_reconciliation.setQuantityRangeMin(100)
self.assertEqual(0, len(bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()], [])
self.portal.portal_workflow.doActionFor(
bank_reconciliation,
'close_action')
......
......@@ -6,6 +6,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testBankReconciliation</string> </value>
......@@ -53,13 +59,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -72,7 +93,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -81,7 +102,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
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