Commit 29b72bb5 authored by Jérome Perrin's avatar Jérome Perrin

Fix bank reconciliation with multiple sections using the same bank account

This is fix for #20170614-26135D "Bank Reconciliation only show transactions for the selected organisation"

At the same time, we stop using `portal_catalog.getObject` in `erp5_bank_reconciliation`.

/reviewed-on nexedi/erp5!297
parents 849831c8 0744ca5b
portal = context.getPortalObject()
kw = { kw = {
'section_uid': context.getSourceSectionUid(), 'section_uid': context.getSourceSection()
and portal.Base_getSectionUidListForSectionCategory(
context.getSourceSectionValue().getGroup(base=True)),
'payment_uid': context.getSourcePaymentUid(), 'payment_uid': context.getSourcePaymentUid(),
'node_category': 'account_type/asset/cash/bank', 'node_category': 'account_type/asset/cash/bank',
'simulation_state': ('stopped', 'delivered', ), 'simulation_state': ('stopped', 'delivered', ),
......
...@@ -2,7 +2,9 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery ...@@ -2,7 +2,9 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery
portal = context.getPortalObject() portal = context.getPortalObject()
kw = { kw = {
'section_uid': context.getSourceSectionUid(), 'section_uid': context.getSourceSection()
and portal.Base_getSectionUidListForSectionCategory(
context.getSourceSectionValue().getGroup(base=True)),
'payment_uid': context.getSourcePaymentUid(), 'payment_uid': context.getSourcePaymentUid(),
'node_category': 'account_type/asset/cash/bank', 'node_category': 'account_type/asset/cash/bank',
'simulation_state': ('stopped', 'delivered', ), 'simulation_state': ('stopped', 'delivered', ),
......
...@@ -2,7 +2,9 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery ...@@ -2,7 +2,9 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, NegatedQuery
portal = context.getPortalObject() portal = context.getPortalObject()
kw = { kw = {
'section_uid': context.getSourceSectionUid(), 'section_uid': context.getSourceSection()
and portal.Base_getSectionUidListForSectionCategory(
context.getSourceSectionValue().getGroup(base=True)),
'payment_uid': context.getSourcePaymentUid(), 'payment_uid': context.getSourcePaymentUid(),
'node_category': 'account_type/asset/cash/bank', 'node_category': 'account_type/asset/cash/bank',
'simulation_state': ('stopped', 'delivered', ), 'simulation_state': ('stopped', 'delivered', ),
......
...@@ -6,8 +6,8 @@ portal.portal_selections.updateSelectionCheckedUidList(list_selection_name, list ...@@ -6,8 +6,8 @@ portal.portal_selections.updateSelectionCheckedUidList(list_selection_name, list
selection_uid_list = portal.portal_selections.getSelectionCheckedUidsFor(list_selection_name) selection_uid_list = portal.portal_selections.getSelectionCheckedUidsFor(list_selection_name)
if mode == 'reconcile': if mode == 'reconcile':
for uid in selection_uid_list: for line in portal.portal_catalog(uid=selection_uid_list or -1):
line = portal.portal_catalog.getObject(uid) line = line.getObject()
if line.getAggregate(portal_type='Bank Reconciliation'): if line.getAggregate(portal_type='Bank Reconciliation'):
return context.Base_redirect(dialog_id, return context.Base_redirect(dialog_id,
abort_transaction=True, abort_transaction=True,
...@@ -27,8 +27,8 @@ if mode == 'reconcile': ...@@ -27,8 +27,8 @@ if mode == 'reconcile':
'reconciled_uid_list': selection_uid_list}) 'reconciled_uid_list': selection_uid_list})
assert mode == 'unreconcile' assert mode == 'unreconcile'
for uid in selection_uid_list: for line in portal.portal_catalog(uid=selection_uid_list or -1):
line = portal.portal_catalog.getObject(uid) line = line.getObject()
line.AccountingTransactionLine_setBankReconciliation(None, line.AccountingTransactionLine_setBankReconciliation(None,
message=translateString("Reconciling Bank Line")) message=translateString("Reconciling Bank Line"))
......
...@@ -503,8 +503,61 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase): ...@@ -503,8 +503,61 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
self.assertEqual(bank_reconciliation, payment1.bank.getAggregateValue()) self.assertEqual(bank_reconciliation, payment1.bank.getAggregateValue())
self.assertEqual(None, payment2.bank.getAggregateValue()) self.assertEqual(None, payment2.bank.getAggregateValue())
def test_BankReconciliation_multiple_section_using_same_bank_account(self):
account_module = self.account_module
self.bank_account.invalidate()
main_section_bank_account = self.main_section.newContent(
portal_type='Bank Account',
price_currency_value=self.portal.currency_module.euro)
main_section_bank_account.validate()
payment1 = self._makeOne(
portal_type='Payment Transaction',
simulation_state='delivered',
source_payment_value=main_section_bank_account,
start_date=DateTime(2014, 1, 1),
lines=(dict(source_value=account_module.bank,
source_debit=100,
id='bank'),
dict(source_value=account_module.receivable,
source_credit=100)))
payment2 = self._makeOne(
portal_type='Payment Transaction',
simulation_state='delivered',
source_section_value=self.main_section,
source_payment_value=main_section_bank_account,
start_date=DateTime(2014, 1, 2),
lines=(dict(source_value=account_module.bank,
source_debit=200,
id='bank'),
dict(source_value=account_module.receivable,
source_credit=200)))
bank_reconciliation = self.portal.bank_reconciliation_module.newContent(
portal_type='Bank Reconciliation',
source_section_value=self.main_section,
source_payment_value=main_section_bank_account,
stop_date=DateTime(2014, 1, 31))
self.tic()
self.assertEqual(300, bank_reconciliation.BankReconciliation_getAccountBalance())
self.assertEqual(
[payment1.bank, payment2.bank],
[x.getObject() for x in bank_reconciliation.BankReconciliation_getAccountingTransactionLineList()])
list_selection_name = bank_reconciliation\
.BankReconciliation_viewBankReconciliationFastInputDialog.listbox.get_value(
'selection_name')
bank_reconciliation.BankReconciliation_reconcileTransactionList(
list_selection_name=list_selection_name,
uids=(payment1.bank.getUid(), ),
mode='reconcile')
self.tic()
self.assertEqual(100, bank_reconciliation.BankReconciliation_getReconciledAccountBalance())
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestBankReconciliation)) suite.addTest(unittest.makeSuite(TestBankReconciliation))
return suite return suite
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