Commit 380229bf authored by Jérome Perrin's avatar Jérome Perrin

payment_mean: refactor scripts and keep existing aggregates

Instead of using only setAggregate(), specify a portal type
to consider only payment transaction groups.
parent b00e420e
"""Adds the payment transaction group to the already aggregated items on this line.
This script has a proxy role to be able to modify delivered lines
"""
portal = context.getPortalObject()
assert context.getPortalType() in portal.getPortalAccountingMovementTypeList()
context.setDefaultActivateParameterDict({"activate_kw": activate_kw})
context.setAggregate(aggregate, portal_type='Payment Transaction Group')
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>AccountingTransactionLine_setAggregate</string> </value> <value> <string>AccountingTransactionLine_addPaymentTransactionGroup</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
context.setDefaultActivateParameterDict({"activate_kw": activate_kw})
context.setAggregate(aggregate)
...@@ -23,4 +23,7 @@ if payment_transaction.getSimulationState() == 'confirmed': ...@@ -23,4 +23,7 @@ if payment_transaction.getSimulationState() == 'confirmed':
batch_mode=True, batch_mode=True,
) )
if payment_transaction.getSimulationState() == 'stopped': if payment_transaction.getSimulationState() == 'stopped':
context.setAggregateValue(payment_transaction_group) context.AccountingTransactionLine_addPaymentTransactionGroup(
aggregate=aggregate,
activate_kw=activate_kw,
)
...@@ -52,17 +52,9 @@ ...@@ -52,17 +52,9 @@
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>aggregate, activate_kw</string> </value> <value> <string>aggregate, activate_kw</string> </value>
</item> </item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>AccountingTransactionLine_stopAndSetAggregate</string> </value> <value> <string>AccountingTransactionLine_stopAndAddPaymentTransactionGroup</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -3,4 +3,4 @@ if REQUEST is not None: ...@@ -3,4 +3,4 @@ if REQUEST is not None:
for payment_transaction_line in context.getAggregateRelatedValueList(): for payment_transaction_line in context.getAggregateRelatedValueList():
payment_transaction_line.setDefaultActivateParameterDict({"tag": tag}) payment_transaction_line.setDefaultActivateParameterDict({"tag": tag})
payment_transaction_line.setAggregate(None) payment_transaction_line.setAggregate(None, portal_type=context.getPortalType())
...@@ -14,10 +14,10 @@ payment_relative_url_list = [brain.relative_url for brain ...@@ -14,10 +14,10 @@ payment_relative_url_list = [brain.relative_url for brain
mode=mode,)] mode=mode,)]
if mode == 'stopped_or_delivered': if mode == 'stopped_or_delivered':
method_id = 'AccountingTransactionLine_setAggregate' method_id = 'AccountingTransactionLine_addPaymentTransactionGroup'
else: else:
assert mode == 'planned_or_confirmed', "Unknown mode, %r" % mode assert mode == 'planned_or_confirmed', "Unknown mode, %r" % mode
method_id = 'AccountingTransactionLine_stopAndSetAggregate' method_id = 'AccountingTransactionLine_stopAndAddPaymentTransactionGroup'
object_list_len = len(payment_relative_url_list) object_list_len = len(payment_relative_url_list)
......
...@@ -8,7 +8,7 @@ for line in context.getMovementList( ...@@ -8,7 +8,7 @@ for line in context.getMovementList(
payment_transaction_group = line.getAggregateValue(portal_type=portal_type) payment_transaction_group = line.getAggregateValue(portal_type=portal_type)
if payment_transaction_group is not None and \ if payment_transaction_group is not None and \
payment_transaction_group.getValidationState() not in ('delivered',): payment_transaction_group.getValidationState() not in ('delivered',):
line.setAggregateValue(None) line.setAggregateValue(None, portal_type=portal_type)
removed = True removed = True
message = translateString('No valid payment transaction group found') message = translateString('No valid payment transaction group found')
......
...@@ -144,7 +144,51 @@ class TestPaymentTransactionGroupConstraint(ERP5TypeTestCase): ...@@ -144,7 +144,51 @@ class TestPaymentTransactionGroupConstraint(ERP5TypeTestCase):
[]) [])
class TestPaymentTransactionGroupPaymentSelection(AccountingTestCase, ERP5TypeTestCase): class TestRemoveFromPaymentTransactionGroup(AccountingTestCase):
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()
def test_other_item_types(self):
account_module = self.account_module
payment = self._makeOne(
portal_type='Payment Transaction',
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)))
self.tic()
self.assertFalse(payment.getReference())
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()
item = self.portal.item_module.newContent(portal_type='Item')
payment.bank.setAggregateValueList([ptg, item])
self.tic()
payment.PaymentTransaction_removeFromPaymentTransactionGroup()
self.tic()
self.assertEqual(
payment.bank.getAggregateValueList(),
[item])
class TestPaymentTransactionGroupPaymentSelection(AccountingTestCase):
def afterSetUp(self): def afterSetUp(self):
AccountingTestCase.afterSetUp(self) AccountingTestCase.afterSetUp(self)
......
erp5_full_text_mroonga_catalog erp5_full_text_mroonga_catalog
erp5_accounting_ui_test erp5_accounting_ui_test
erp5_item
\ 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