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

payment_mean: consider all sections from the group

Follow the same rule that allow other organisations from the same group to
use bank account from the main section when selecting the payments and
displaying the payments from the group.
parent bd301f0b
...@@ -12,12 +12,14 @@ except KeyError: ...@@ -12,12 +12,14 @@ except KeyError:
row, = portal.portal_simulation.getInventoryList( row, = portal.portal_simulation.getInventoryList(
select_dict={'count': 'COUNT(*)'}, select_dict={'count': 'COUNT(*)'},
ignore_group_by=1, ignore_group_by=1,
section_uid=context.getSourceSectionUid(), section_uid=context.getSourceSection()
and portal.Base_getSectionUidListForSectionCategory(
context.getSourceSectionValue().getGroup(base=True)),
strict_aggregate_uid=context.getUid(), strict_aggregate_uid=context.getUid(),
node_uid=[x.uid for x in portal.portal_catalog( node_uid=[x.uid for x in portal.portal_catalog(
portal_type='Account', portal_type='Account',
strict_account_type_uid=portal.portal_categories.account_type.asset.cash.bank.getUid(), strict_account_type_uid=portal.portal_categories.account_type.asset.cash.bank.getUid(),
)], )] or -1,
**params **params
) )
cache[cache_key] = result = (row.count, row.total_quantity) cache[cache_key] = result = (row.count, row.total_quantity)
......
portal = context.getPortalObject() portal = context.getPortalObject()
kw['section_uid'] = context.getSourceSectionUid() kw['section_uid'] = -1
if context.getSourceSection():
kw['section_uid'] = portal.Base_getSectionUidListForSectionCategory(
context.getSourceSectionValue().getGroup(base=True))
kw['default_aggregate_uid'] = context.getUid() kw['default_aggregate_uid'] = context.getUid()
kw['parent_portal_type'] = ('Payment Transaction', 'Accounting Transaction') kw['parent_portal_type'] = ('Payment Transaction', 'Accounting Transaction')
......
...@@ -10,7 +10,9 @@ search_kw = dict( ...@@ -10,7 +10,9 @@ search_kw = dict(
parent_portal_type='Payment Transaction', parent_portal_type='Payment Transaction',
limit=None, limit=None,
simulation_state=simulation_state, simulation_state=simulation_state,
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(),
resource_uid=context.getPriceCurrencyUid(), resource_uid=context.getPriceCurrencyUid(),
node_category='account_type/asset/cash/bank', node_category='account_type/asset/cash/bank',
......
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from erp5.component.test.testAccounting import AccountingTestCase
class TestPaymentTransactionGroup(ERP5TypeTestCase): class TestPaymentTransactionGroupReferences(ERP5TypeTestCase):
def test_source_reference_generated(self): def test_source_reference_generated(self):
ptg = self.portal.payment_transaction_group_module.newContent( ptg = self.portal.payment_transaction_group_module.newContent(
portal_type='Payment Transaction Group') portal_type='Payment Transaction Group')
...@@ -141,3 +142,100 @@ class TestPaymentTransactionGroupConstraint(ERP5TypeTestCase): ...@@ -141,3 +142,100 @@ class TestPaymentTransactionGroupConstraint(ERP5TypeTestCase):
self.assertEqual( self.assertEqual(
sorted([str(m.getMessage()) for m in ptg.checkConsistency()]), sorted([str(m.getMessage()) for m in ptg.checkConsistency()]),
[]) [])
class TestPaymentTransactionGroupPaymentSelection(AccountingTestCase, ERP5TypeTestCase):
def afterSetUp(self):
AccountingTestCase.afterSetUp(self)
self.bank_account = self.main_section.newContent(
portal_type='Bank Account',
price_currency_value=self.portal.currency_module.euro)
self.bank_account.validate()
self.tic()
# TODO: more PaymentTransactionGroup_getGroupablePaymentTransactionLineList test
def test_PaymentTransactionGroup_getGroupablePaymentTransactionLineList_mapping_organisation(self):
account_module = self.account_module
payment_main_section = self._makeOne(
portal_type='Payment Transaction',
simulation_state='delivered',
title='main section',
reference='P1',
source_section_value=self.main_section,
source_payment_value=self.bank_account,
destination_section_value=self.organisation_module.client_1,
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)))
payment_section = self._makeOne(
portal_type='Payment Transaction',
simulation_state='delivered',
title='section',
reference='P2',
source_section_value=self.section,
source_payment_value=self.bank_account,
destination_section_value=self.organisation_module.client_2,
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)))
ptg = self.portal.payment_transaction_group_module.newContent(
portal_type='Payment Transaction Group',
source_section_value=self.main_section,
source_payment_value=self.bank_account,
stop_date=DateTime(2014, 1, 31),)
self.tic()
line_list = ptg.PaymentTransactionGroup_getGroupablePaymentTransactionLineList(
limit=None,
start_date_range_min=None,
start_date_range_max=None,
sign='incoming',
mode='stopped_or_delivered',
)
self.assertEqual(
sorted([line.getObject().getRelativeUrl() for line in line_list]),
sorted([payment_main_section.bank.getRelativeUrl(), payment_section.bank.getRelativeUrl()]))
# Add a payment to the group
payment_section.bank.setAggregateValue(ptg)
self.tic()
# Now the listbox only remaining transactions
line_list = ptg.PaymentTransactionGroup_getGroupablePaymentTransactionLineList(
limit=None,
start_date_range_min=None,
start_date_range_max=None,
sign='incoming',
mode='stopped_or_delivered',
)
self.assertEqual(
sorted([line.getObject().getRelativeUrl() for line in line_list]),
sorted([payment_main_section.bank.getRelativeUrl()]))
# Add the other payment to the group
payment_main_section.bank.setAggregateValue(ptg)
self.tic()
# the listbox of the payment transaction group correctly show both payments.
line_list = ptg.PaymentTransactionGroup_view.listbox.get_value(
'default',
render_format='list',)
self.assertEqual(
sorted([(line.is_stat_line, line['Movement_getMirrorSectionTitle'], line['total_quantity'])
for line in line_list if not line.is_title_line]),
[(0, 'Client 1', 100.0), (0, 'Client 2', 200.0), (1, None, 300.0)],
)
erp5_full_text_mroonga_catalog erp5_full_text_mroonga_catalog
erp5_accounting_ui_test
\ No newline at end of file
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