Commit 87ba4a2f authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: trigger the deposit's packing list creation in an alarm

parent a379f510
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_generateSlapOSDepositSalePackingList</string> </value>
</item>
<item>
<key> <string>automatic_solve</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_generate_deposit_sale_packing_list</string> </value>
</item>
<item>
<key> <string>periodicity_day_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>0.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>SlapOS Generate Deposit Sale Packing List</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
<type>Open Sale Order</type> <type>Open Sale Order</type>
<workflow>slapos_accounting_interaction_workflow, slapos_simulation_interaction_workflow</workflow> <workflow>slapos_accounting_interaction_workflow, slapos_simulation_interaction_workflow</workflow>
</chain> </chain>
<chain>
<type>Payment Transaction</type>
<workflow>slapos_accounting_interaction_workflow</workflow>
</chain>
<chain> <chain>
<type>Project</type> <type>Project</type>
<workflow>slapos_accounting_interaction_workflow</workflow> <workflow>slapos_accounting_interaction_workflow</workflow>
......
portal = context.getPortalObject()
activate_kw = {'tag': tag}
select_dict= {'causality__uid': None}
portal.portal_catalog.searchAndActivate(
portal_type='Payment Transaction',
simulation_state='stopped',
ledger__uid=portal.portal_categories.ledger.automated.getUid(),
# Only check standalone payment
left_join_list=select_dict.keys(),
causality__uid=None,
method_id='PaymentTransaction_acceptDepositPayment',
method_kw={'activate_kw': activate_kw},
activate_kw=activate_kw
)
context.activate(after_tag=tag).getId()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_generateSlapOSDepositSalePackingList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
from DateTime import DateTime from DateTime import DateTime
portal = context.getPortalObject() portal = context.getPortalObject()
payment_transaction = context payment_transaction = context
payment_transaction.stop() assert payment_transaction.getSimulationState() == 'stopped'
trade_condition = payment_transaction.getSpecialiseValue()
assert trade_condition is not None
assert trade_condition.getTradeConditionType() == 'deposit'
# Ensure the payment has no grouping reference
assert not [x for x in trade_condition.contentValues(portal_type='Accounting Transaction Line') if x.getGroupingReference(None) is not None]
start_date = DateTime() start_date = DateTime()
stop_date = None stop_date = None
...@@ -14,7 +23,12 @@ quantity_unit_value = resource_value.getQuantityUnitValue() ...@@ -14,7 +23,12 @@ quantity_unit_value = resource_value.getQuantityUnitValue()
order_portal_type = 'Sale Packing List' order_portal_type = 'Sale Packing List'
order_line_portal_type = 'Sale Packing List Line' order_line_portal_type = 'Sale Packing List Line'
activate_kw = None existing_packing_list = portal.portal_catalog.getResultValue(
portal_type=order_portal_type,
causality__uid=payment_transaction.getUid()
)
if existing_packing_list is not None:
return
####################################################### #######################################################
# Open Sale Order # Open Sale Order
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>activate_kw=None, REQUEST=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -35,7 +35,8 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -35,7 +35,8 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
with PinnedDateTime(self, DateTime('2021/04/04')): with PinnedDateTime(self, DateTime('2021/04/04')):
payment_transaction = owner_person.Person_addDepositPayment(99*10, currency.getRelativeUrl(), 1) payment_transaction = owner_person.Person_addDepositPayment(99*10, currency.getRelativeUrl(), 1)
payment_transaction.PaymentTransaction_acceptDepositPayment() # payzen interface will only stop the payment
payment_transaction.stop()
self.tic() self.tic()
self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=True)) self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=True))
...@@ -209,7 +210,8 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -209,7 +210,8 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
with PinnedDateTime(self, creation_date + 2): with PinnedDateTime(self, creation_date + 2):
for person in person_list: for person in person_list:
payment_transaction = person.Person_addDepositPayment(99*100, currency.getRelativeUrl(), 1) payment_transaction = person.Person_addDepositPayment(99*100, currency.getRelativeUrl(), 1)
payment_transaction.PaymentTransaction_acceptDepositPayment() # payzen interface will only stop the payment
payment_transaction.stop()
################################################## ##################################################
# Add first batch of service, and generate invoices # Add first batch of service, and generate invoices
...@@ -310,7 +312,8 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -310,7 +312,8 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
# Add deposit (0.1 to prevent discount generation) # Add deposit (0.1 to prevent discount generation)
with PinnedDateTime(self, creation_date + 0.1): with PinnedDateTime(self, creation_date + 0.1):
payment_transaction = owner_person.Person_addDepositPayment(99*100, currency.getRelativeUrl(), 1) payment_transaction = owner_person.Person_addDepositPayment(99*100, currency.getRelativeUrl(), 1)
payment_transaction.PaymentTransaction_acceptDepositPayment() # payzen interface will only stop the payment
payment_transaction.stop()
self.logout() self.logout()
self.login() self.login()
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>after_script/portal_workflow/slapos_accounting_interaction_workflow/script_Base_triggerGenerateDepositSalePackingListAlarm</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interaction_PaymentTransaction_stop</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<tuple>
<string>Payment Transaction</string>
</tuple>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>trigger_method_id</string> </key>
<value>
<tuple>
<string>stop</string>
</tuple>
</value>
</item>
<item>
<key> <string>trigger_once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Base_triggerGenerateDepositSalePackingListAlarm</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -19,6 +19,7 @@ currency_module/EUR ...@@ -19,6 +19,7 @@ currency_module/EUR
portal_alarms/slapos_accounting_generate_packing_list_from_tioxml portal_alarms/slapos_accounting_generate_packing_list_from_tioxml
portal_alarms/slapos_archive_open_sale_order_with_unused_item portal_alarms/slapos_archive_open_sale_order_with_unused_item
portal_alarms/slapos_cancel_sale_invoice_transaction_paied_payment_list portal_alarms/slapos_cancel_sale_invoice_transaction_paied_payment_list
portal_alarms/slapos_generate_deposit_sale_packing_list
portal_alarms/slapos_manage_building_calculating_delivery portal_alarms/slapos_manage_building_calculating_delivery
portal_alarms/slapos_remove_bogus_delivery_link portal_alarms/slapos_remove_bogus_delivery_link
portal_alarms/slapos_stop_confirmed_aggregated_sale_invoice_transaction portal_alarms/slapos_stop_confirmed_aggregated_sale_invoice_transaction
......
...@@ -10,6 +10,7 @@ Hosting Subscription | slapos_accounting_interaction_workflow ...@@ -10,6 +10,7 @@ Hosting Subscription | slapos_accounting_interaction_workflow
Instance Tree | slapos_accounting_interaction_workflow Instance Tree | slapos_accounting_interaction_workflow
Open Sale Order | slapos_accounting_interaction_workflow Open Sale Order | slapos_accounting_interaction_workflow
Open Sale Order | slapos_simulation_interaction_workflow Open Sale Order | slapos_simulation_interaction_workflow
Payment Transaction | slapos_accounting_interaction_workflow
Project | slapos_accounting_interaction_workflow Project | slapos_accounting_interaction_workflow
Sale Invoice Transaction | slapos_accounting_interaction_workflow Sale Invoice Transaction | slapos_accounting_interaction_workflow
Sale Invoice Transaction | slapos_simulation_interaction_workflow Sale Invoice Transaction | slapos_simulation_interaction_workflow
......
...@@ -57,7 +57,8 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -57,7 +57,8 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
# Add deposit # Add deposit
with PinnedDateTime(self, creation_date): with PinnedDateTime(self, creation_date):
payment_transaction = owner_person.Person_addDepositPayment(99*100, currency.getRelativeUrl(), 1) payment_transaction = owner_person.Person_addDepositPayment(99*100, currency.getRelativeUrl(), 1)
payment_transaction.PaymentTransaction_acceptDepositPayment() # payzen interface will only stop the payment
payment_transaction.stop()
################################################## ##################################################
# Add first batch of service, and generate invoices # Add first batch of service, and generate invoices
......
...@@ -166,6 +166,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -166,6 +166,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_accounting/Base_getAccountForUse', 'slapos_accounting/Base_getAccountForUse',
'slapos_accounting/Entity_createPaymentTransactionAction', 'slapos_accounting/Entity_createPaymentTransactionAction',
'slapos_accounting/Movement_getPriceCalculationOperandDict', 'slapos_accounting/Movement_getPriceCalculationOperandDict',
'slapos_accounting/PaymentTransaction_acceptDepositPayment',
'slapos_accounting/PaymentTransaction_getExternalPaymentId', 'slapos_accounting/PaymentTransaction_getExternalPaymentId',
'slapos_accounting/PaymentTransaction_postOrderBuild', 'slapos_accounting/PaymentTransaction_postOrderBuild',
'slapos_accounting/SaleInvoiceTransaction_init', 'slapos_accounting/SaleInvoiceTransaction_init',
......
...@@ -489,7 +489,8 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -489,7 +489,8 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
self.tic() self.tic()
self.logout() self.logout()
self.login() self.login()
payment_transaction.PaymentTransaction_acceptDepositPayment() # payzen interface will only stop the payment
payment_transaction.stop()
self.tic() self.tic()
assert payment_transaction.receivable.getGroupingReference(None) is not None assert payment_transaction.receivable.getGroupingReference(None) is not None
...@@ -561,7 +562,8 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -561,7 +562,8 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
project = self.portal.restrictedTraverse(project_relative_url) project = self.portal.restrictedTraverse(project_relative_url)
payment_transaction = customer_section_organisation.Person_addDepositPayment(99*10, currency.getRelativeUrl(), 1) payment_transaction = customer_section_organisation.Person_addDepositPayment(99*10, currency.getRelativeUrl(), 1)
payment_transaction.PaymentTransaction_acceptDepositPayment() # payzen interface will only stop the payment
payment_transaction.stop()
self.tic() self.tic()
self.portal.log('SubscriptionRequest_validateIfSubmitted %s' % payment_transaction.getSimulationState()) self.portal.log('SubscriptionRequest_validateIfSubmitted %s' % payment_transaction.getSimulationState())
...@@ -780,7 +782,8 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -780,7 +782,8 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
project = self.portal.restrictedTraverse(project_relative_url) project = self.portal.restrictedTraverse(project_relative_url)
payment_transaction = owner_person.Person_addDepositPayment(99*10, currency.getRelativeUrl(), 1) payment_transaction = owner_person.Person_addDepositPayment(99*10, currency.getRelativeUrl(), 1)
payment_transaction.PaymentTransaction_acceptDepositPayment() # payzen interface will only stop the payment
payment_transaction.stop()
preference = self.portal.portal_preferences.slapos_default_system_preference preference = self.portal.portal_preferences.slapos_default_system_preference
preference.edit( preference.edit(
...@@ -869,7 +872,8 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -869,7 +872,8 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
reference=public_reference).getParentValue() reference=public_reference).getParentValue()
payment_transaction = public_person.Person_addDepositPayment(99*10, currency.getRelativeUrl(), 1) payment_transaction = public_person.Person_addDepositPayment(99*10, currency.getRelativeUrl(), 1)
payment_transaction.PaymentTransaction_acceptDepositPayment() # payzen interface will only stop the payment
payment_transaction.stop()
with PinnedDateTime(self, DateTime('2024/02/17 01:01')): with PinnedDateTime(self, DateTime('2024/02/17 01:01')):
public_instance_title = 'Public title %s' % self.generateNewId() public_instance_title = 'Public title %s' % self.generateNewId()
......
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