Commit c73993a2 authored by Jérome Perrin's avatar Jérome Perrin Committed by Aurel

payment_mean: New mode to select payments

Instead of selecting already stopped payments, introduce a new "mode" field in
the dialog, where user can choose the previous behavior of selecting stopped
payments, or a new behavior where user would select planned or confirmed payments,
in that case the payments will be automatically stopped before being added to
the group.
parent 4b5ddb72
from Products.ERP5Type.Message import translateString
portal = context.getPortalObject()
payment_transaction_group = portal.restrictedTraverse(aggregate)
payment_transaction = context.getParentValue()
payment_transaction.setDefaultActivateParameterDict({"activate_kw": activate_kw})
if payment_transaction.getSimulationState() == 'planned':
payment_transaction.Base_workflowStatusModify(
workflow_action='confirm_action',
batch_mode=True,
)
if payment_transaction.getSimulationState() == 'confirmed':
payment_transaction.Base_workflowStatusModify(
workflow_action='start_action',
batch_mode=True,
)
payment_transaction.Base_workflowStatusModify(
workflow_action='stop_action',
comment=translateString(
"Posted automatically with payment transaction group ${payment_transaction_group_reference}",
mapping={'payment_transaction_group_reference': payment_transaction_group.getReference()}),
batch_mode=True,
)
if payment_transaction.getSimulationState() == 'stopped':
context.setAggregateValue(payment_transaction_group)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>aggregate, activate_kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionLine_stopAndSetAggregate</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
if mode == 'stopped_or_delivered':
simulation_state = ('delivered', 'stopped')
else:
assert mode == 'planned_or_confirmed', "Unknown mode, %r" % mode
simulation_state = ('planned', 'confirmed')
search_kw = dict(
parent_portal_type='Payment Transaction',
limit=None,
simulation_state=('delivered', 'stopped'),
simulation_state=simulation_state,
section_uid=context.getSourceSectionUid(),
payment_uid=context.getSourcePaymentUid(),
resource_uid=context.getPriceCurrencyUid(),
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>select_limit=None, start_date_range_min=None, start_date_range_max=None, sign=None, **kw</string> </value>
<value> <string>select_limit=None, start_date_range_min=None, start_date_range_max=None, sign=None, mode=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -12,6 +12,7 @@ context.activate(tag=tag).PaymentTransactionGroup_selectPaymentTransactionLineLi
start_date_range_min=start_date_range_min,
start_date_range_max=start_date_range_max,
sign=sign,
mode=mode,
tag=tag)
return context.Base_redirect(form_id,
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'view\', select_limit=None, start_date_range_min=None, start_date_range_max=None, sign=None, **kw</string> </value>
<value> <string>form_id=\'view\', select_limit=None, start_date_range_min=None, start_date_range_max=None, sign=None, mode=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -10,7 +10,15 @@ payment_relative_url_list = [brain.relative_url for brain
select_limit=select_limit,
start_date_range_min=start_date_range_min,
start_date_range_max=start_date_range_max,
sign=sign,)]
sign=sign,
mode=mode,)]
if mode == 'stopped_or_delivered':
method_id = 'AccountingTransactionLine_setAggregate'
else:
assert mode == 'planned_or_confirmed', "Unknown mode, %r" % mode
method_id = 'AccountingTransactionLine_stopAndSetAggregate'
object_list_len = len(payment_relative_url_list)
activate = context.getPortalObject().portal_activities.activate
......@@ -18,6 +26,6 @@ for i in xrange(0, object_list_len, batch_size):
current_path_list = payment_relative_url_list[i:i+batch_size]
activate(activity='SQLQueue', activate_kw=activate_kw,).callMethodOnObjectList(
current_path_list,
'AccountingTransactionLine_setAggregate',
method_id,
aggregate=aggregate,
activate_kw=activate_kw)
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>select_limit=None, start_date_range_min=None, start_date_range_max=None, sign=None, tag=\'\'</string> </value>
<value> <string>select_limit=None, start_date_range_min=None, start_date_range_max=None, sign=None, mode=None, tag=\'\'</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
......@@ -102,6 +102,7 @@
<string>your_start_date_range_min</string>
<string>your_start_date_range_max</string>
<string>your_sign</string>
<string>your_mode</string>
</list>
</value>
</item>
......
2021-04-23
* New "Select Planned or Confirmed Payments and Post them to General Ledger" mode to select payments.
2011-07-13 Gabriel:
* Add field on PaymentTransactionGroup_view to display the source_administration property
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testPaymentTransactionGroupSelectPlannedOrConfirmedPaymentsFastInput</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title tal:content="template/title_or_id"></title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3" tal:content="template/title_or_id"></td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_viewCommonTemplatePaymentMeanRenderJsUiTest/macros/init" />
<tal:block metal:use-macro="here/Zuite_viewCommonTemplatePaymentMeanRenderJsUiTest/macros/prepare_data" />
<tal:block metal:use-macro="here/Zuite_viewCommonTemplatePaymentMeanRenderJsUiTest/macros/view_fast_input" />
<tr>
<td>assertSelected</td>
<td>field_your_mode</td>
<td>Select already Posted to General Ledger or Closed Payments</td>
</tr>
<!-- update dialog -->
<tr>
<td>select</td>
<td>field_your_mode</td>
<td>Select Planned or Confirmed Payments and Post them to General Ledger</td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/update_dialog" />
<!-- out of the 3, one is not consistent -->
<tal:block tal:define="pagination_configuration python: {'header': '(3)', 'footer': '3 Records'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<!-- select -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block tal:define="notification_configuration python: {'class': 'success',
'text': 'Payment selection in progress.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<tr>
<td>open</td>
<td>${renderjs_url}/payment_transaction_group_module/erp5_payment_mean_ui_test_payment_transaction_group</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<!-- the not consistent transaction was not selected, we selected and validated the two consistent ones -->
<tal:block tal:define="pagination_configuration python: {'header': '(2)', 'footer': '2 Records'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<tr>
<td>assertTextPresent</td>
<td>Posted to General Ledger</td>
<td></td>
</tr>
<!-- XXX we don't really need to wait for activities here, but we need to `open` a different page so that we can
open erp5_payment_mean_ui_test_confirmed_not_consistent_outgoing_payment later.
selenium open command expect that a new page is loaded, without this we would just re-open the same page with
a different fragment and selenium would never notice with open is executed.
-->
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<!-- the not consistent transaction is left separately, there's a note in history explaining why it could not be selected -->
<tr>
<td>open</td>
<td>${renderjs_url}/accounting_module/erp5_payment_mean_ui_test_confirmed_not_consistent_outgoing_payment</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'Views'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_header_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'History'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_page_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tr>
<td>assertTextPresent</td>
<td>Transaction is not balanced for erp5_payment_mean_ui_test_organisation</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -2,12 +2,12 @@
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title tal:replace="template/title_or_id"></title>
<title tal:content="template/title_or_id"></title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3" tal:replace="template/title_or_id"></td></tr>
<tr><td rowspan="1" colspan="3" tal:content="template/title_or_id"></td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_viewCommonTemplatePaymentMeanUiTest/macros/init" />
......@@ -16,50 +16,17 @@
<tr>
<td>assertSelected</td>
<td>field_your_sign</td>
<td>Outgoing</td>
<td>field_your_mode</td>
<td>Select already Posted to General Ledger or Closed Payments</td>
</tr>
<!-- update dialog -->
<tr>
<td>clickAndWait</td>
<td>dialog_update_button</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>2 records</td>
</tr>
<!-- choose sign -->
<tr>
<td>select</td>
<td>field_your_sign</td>
<td>Incoming</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>dialog_update_button</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>1 records</td>
<td>field_your_mode</td>
<td>Select Planned or Confirmed Payments and Post them to General Ledger</td>
</tr>
<!-- choose limit -->
<tr>
<td>select</td>
<td>field_your_sign</td>
<td>Incoming</td>
</tr>
<tr>
<td>type</td>
<td>//input[@name='field_your_limit']</td>
<td>1</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>dialog_update_button</td>
......@@ -68,40 +35,8 @@
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<!-- XXX this is not cool to have "sample of " here, but since we pass a limit, listbox detects that the limit was reached -->
<td>sample of 1 records</td>
</tr>
<!-- choose dates -->
<tr>
<td>type</td>
<td>//input[@name='field_your_limit']</td>
<td>10</td>
</tr>
<tr>
<td>type</td>
<td>//input[@name='subfield_field_your_start_date_range_max_year']</td>
<td>2019</td>
</tr>
<tr>
<td>type</td>
<td>//input[@name='subfield_field_your_start_date_range_max_month']</td>
<td>10</td>
</tr>
<tr>
<td>type</td>
<td>//input[@name='subfield_field_your_start_date_range_max_day']</td>
<td>20</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>dialog_update_button</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>1 records</td>
<!-- out of the 3, one is not consistent -->
<td>3 records</td>
</tr>
<!-- select -->
......@@ -122,12 +57,28 @@
<td>${base_url}/payment_transaction_group_module/erp5_payment_mean_ui_test_payment_transaction_group</td>
<td></td>
</tr>
<!-- the not consistent transaction was not selected, we selected and validated the two consistent ones -->
<tr>
<td>assertText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>1 records</td>
<td>2 records</td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Posted to General Ledger</td>
<td></td>
</tr>
<!-- the not consistent transaction is left separately, there's a note in history explaining why it could not be selected -->
<tr>
<td>open</td>
<td>${base_url}/accounting_module/erp5_payment_mean_ui_test_confirmed_not_consistent_outgoing_payment/Base_viewHistory</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Transaction is not balanced for erp5_payment_mean_ui_test_organisation</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -7,6 +7,14 @@ for rule in portal.portal_rules.contentValues():
if rule.getValidationState() != 'validated':
rule.validate()
# validate other documents used in this test
for document in (
portal.account_module.equity,
portal.account_module.bank,
portal.currency_module.euro, ):
if document.getValidationState() != 'validated':
document.validate()
organisation_id = "erp5_payment_mean_ui_test_organisation"
organisation = portal.organisation_module.newContent(
portal_type='Organisation',
......@@ -35,94 +43,40 @@ payment_mean = portal.payment_transaction_group_module.newContent(
)
payment_mean.open()
incoming_payment = portal.accounting_module.newContent(
portal_type='Payment Transaction',
id="erp5_payment_mean_ui_test_incoming_payment",
title="Incoming payment",
source_section_value=organisation,
destination_section_value=organisation,
source_payment_value=bank_account,
start_date=DateTime('2019/10/20'),
resource_value=portal.currency_module.euro,
payment_mode_value=portal.portal_categories.payment_mode.cash,
specialise_value=portal.business_process_module.erp5_default_business_process,
)
incoming_payment.bank.edit(
source_value=portal.account_module.bank,
source_debit=100,
)
incoming_payment.stop()
outgoing_payment = portal.accounting_module.newContent(
portal_type='Payment Transaction',
id="erp5_payment_mean_ui_test_outgoing_payment",
title="Outgoing payment",
source_section_value=organisation,
destination_section_value=organisation,
source_payment_value=bank_account,
start_date=DateTime('2019/10/20'),
resource_value=portal.currency_module.euro,
payment_mode_value=portal.portal_categories.payment_mode.cash,
specialise_value=portal.business_process_module.erp5_default_business_process,
)
outgoing_payment.bank.edit(
source_value=portal.account_module.bank,
source_credit=100,
)
outgoing_payment.stop()
second_outgoing_payment = portal.accounting_module.newContent(
portal_type='Payment Transaction',
id="erp5_payment_mean_ui_test_second_outgoing_payment",
title="Second outgoing payment",
source_section_value=organisation,
destination_section_value=organisation,
source_payment_value=bank_account,
start_date=DateTime('2019/10/21'),
resource_value=portal.currency_module.euro,
payment_mode_value=portal.portal_categories.payment_mode.cash,
specialise_value=portal.business_process_module.erp5_default_business_process,
)
second_outgoing_payment.bank.edit(
source_value=portal.account_module.bank,
source_credit=100,
)
second_outgoing_payment.stop()
wrong_payment_mode_outgoing_payment = portal.accounting_module.newContent(
portal_type='Payment Transaction',
id="erp5_payment_mean_ui_test_wrong_payment_mode_outgoing_payment",
title="Wrong Payment Mode outgoing payment",
source_section_value=organisation,
destination_section_value=organisation,
source_payment_value=bank_account,
start_date=DateTime('2019/10/22'),
resource_value=portal.currency_module.euro,
payment_mode_value=portal.portal_categories.payment_mode.check,
specialise_value=portal.business_process_module.erp5_default_business_process,
)
wrong_payment_mode_outgoing_payment.bank.edit(
source_value=portal.account_module.bank,
source_credit=100,
)
wrong_payment_mode_outgoing_payment.stop()
wrong_currency_outgoing_payment = portal.accounting_module.newContent(
portal_type='Payment Transaction',
id="erp5_payment_mean_ui_test_wrong_currency_outgoing_payment",
title="Wrong Currency outgoing payment",
source_section_value=organisation,
destination_section_value=organisation,
source_payment_value=bank_account,
start_date=DateTime('2019/10/23'),
resource_value=portal.currency_module.yen,
payment_mode_value=portal.portal_categories.payment_mode.cash,
specialise_value=portal.business_process_module.erp5_default_business_process,
)
wrong_currency_outgoing_payment.bank.edit(
source_value=portal.account_module.bank,
source_credit=100,
)
wrong_currency_outgoing_payment.stop()
for id_, date, resource_value, payment_mode_value, quantity, state, consistent in (
('erp5_payment_mean_ui_test_incoming_payment', DateTime('2019/10/20'), portal.currency_module.euro, portal.portal_categories.payment_mode.cash, -100, 'stopped', True),
('erp5_payment_mean_ui_test_outgoing_payment', DateTime('2019/10/20'), portal.currency_module.euro, portal.portal_categories.payment_mode.cash, 100, 'stopped', True),
('erp5_payment_mean_ui_test_second_outgoing_payment', DateTime('2019/10/21'), portal.currency_module.euro, portal.portal_categories.payment_mode.cash, 100, 'stopped', True),
('erp5_payment_mean_ui_test_planned_outgoing_payment', DateTime('2019/10/20'), portal.currency_module.euro, portal.portal_categories.payment_mode.cash, 100, 'planned', True),
('erp5_payment_mean_ui_test_confirmed_outgoing_payment', DateTime('2019/10/20'), portal.currency_module.euro, portal.portal_categories.payment_mode.cash, 100, 'confirmed', True),
('erp5_payment_mean_ui_test_confirmed_not_consistent_outgoing_payment', DateTime('2019/10/20'), portal.currency_module.euro, portal.portal_categories.payment_mode.cash, 100, 'confirmed', False),
('erp5_payment_mean_ui_test_wrong_payment_mode_outgoing_payment', DateTime('2019/10/20'), portal.currency_module.euro, portal.portal_categories.payment_mode.check, 100, 'stopped', True),
('erp5_payment_mean_ui_test_wrong_currency_outgoing_payment', DateTime('2019/10/20'), portal.currency_module.yen, portal.portal_categories.payment_mode.cash, 100, 'stopped', True),
):
payment = portal.accounting_module.newContent(
portal_type='Payment Transaction',
id=id_,
source_section_value=organisation,
source_payment_value=bank_account,
start_date=date,
resource_value=resource_value,
payment_mode_value=payment_mode_value,
specialise_value=portal.business_process_module.erp5_default_business_process,
)
payment.bank.edit(
source_value=portal.account_module.bank,
quantity=quantity
)
payment.receivable.edit(
source_value=portal.account_module.equity if consistent else None,
quantity=-quantity
)
if state == 'planned':
payment.plan()
elif state == 'confirmed':
payment.confirm()
elif state == 'stopped':
payment.stop()
else:
raise ValueError("unknown state", state)
return "Test Data Created."
......@@ -6,6 +6,9 @@ for portal_type, document_id_list in (
('Payment Transaction', (
'erp5_payment_mean_ui_test_incoming_payment',
'erp5_payment_mean_ui_test_outgoing_payment',
'erp5_payment_mean_ui_test_planned_outgoing_payment',
'erp5_payment_mean_ui_test_confirmed_outgoing_payment',
'erp5_payment_mean_ui_test_confirmed_not_consistent_outgoing_payment',
'erp5_payment_mean_ui_test_second_outgoing_payment',
'erp5_payment_mean_ui_test_wrong_payment_mode_outgoing_payment',
'erp5_payment_mean_ui_test_wrong_currency_outgoing_payment',
......
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