Commit 7246420a authored by Romain Courteaud's avatar Romain Courteaud

slapos_payzen: support new ID generator

Modules switched to per day/node ID generator.

Also in this commit:
* drop templates
* drop not needed trade conditions
parent 2a5fb9ab
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Sale Invoice Transaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source/organisation_module/slapos</string>
<string>source_section/organisation_module/slapos</string>
<string>price_currency/currency_module/EUR</string>
<string>resource/currency_module/EUR</string>
<string>payment_mode/payzen</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_destination_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>template_sale_invoice_transaction</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Sale Invoice Transaction</string> </value>
</item>
<item>
<key> <string>start_date</string> </key>
<value>
<object>
<klass>
<global id="1.1" name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global id="1.2" name="DateTime" module="DateTime.DateTime"/>
<global id="1.3" name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>1325372400.0</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>stop_date</string> </key>
<value>
<object>
<klass> <reference id="1.1"/> </klass>
<tuple>
<reference id="1.2"/>
<reference id="1.3"/>
<none/>
</tuple>
<state>
<tuple>
<float>1326582000.0</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Sale Invoice Transaction Line" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>resource/currency_module/EUR</string>
<string>destination/account_module/payable</string>
<string>source/account_module/receivable</string>
</tuple>
</value>
</item>
<item>
<key> <string>destination_total_asset_price</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>grouping_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>2</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Sale Invoice Transaction Line</string> </value>
</item>
<item>
<key> <string>price</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>quantity</string> </key>
<value> <float>-1.0</float> </value>
</item>
<item>
<key> <string>source_total_asset_price</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Sale Invoice Transaction Line" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>resource/currency_module/EUR</string>
<string>destination/account_module/purchase</string>
<string>source/account_module/sales</string>
</tuple>
</value>
</item>
<item>
<key> <string>destination_total_asset_price</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>grouping_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>3</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Sale Invoice Transaction Line</string> </value>
</item>
<item>
<key> <string>price</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>quantity</string> </key>
<value> <float>0.84</float> </value>
</item>
<item>
<key> <string>source_total_asset_price</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Sale Invoice Transaction Line" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>resource/currency_module/EUR</string>
<string>destination/account_module/refundable_vat</string>
<string>source/account_module/coll_vat</string>
</tuple>
</value>
</item>
<item>
<key> <string>destination_total_asset_price</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>grouping_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>5</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Sale Invoice Transaction Line</string> </value>
</item>
<item>
<key> <string>price</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>quantity</string> </key>
<value> <float>0.16</float> </value>
</item>
<item>
<key> <string>source_total_asset_price</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -28,6 +28,10 @@
<key> <string>id</string> </key>
<value> <string>slapos_payzen_update_started_payment</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>
......@@ -48,7 +52,9 @@
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value> <int>2</int> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
......
......@@ -81,15 +81,19 @@
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source_trade/sale_trade_condition_module/payzen_sale_trade_condition</string>
</tuple>
<tuple/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>payzen</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_payzen_test_integration</string> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Sale Trade Condition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>payzen_sale_trade_condition</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Sale Trade Condition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>PayZen Sale Trade Condition</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</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>1702404222.37</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -85,9 +85,7 @@
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>price_currency/currency_module/EUR</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......@@ -205,16 +203,10 @@
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAg=</string> </persistent>
</value>
</item>
<item>
<key> <string>validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAk=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAg=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -224,71 +216,6 @@
</pickle>
</record>
<record id="8" aka="AAAAAAAAAAg=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1013.8578.12822.45056</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</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>1702404310.04</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="9" aka="AAAAAAAAAAk=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......@@ -329,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1702400771.68</float>
<float>1647423852.79</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -11,7 +11,7 @@ if not params.get('full', False) and last_active_process is not None:
last_active_process_start_date = last_active_process.getStartDate()
if (last_active_process_start_date + 0.02083) > now:
kw['creation_date'] = '>= %s' % last_active_process_start_date.ISO()
kw['indexation_timestamp'] = '>= %s' % last_active_process_start_date.ISO()
else:
context.newActiveProcess().getRelativeUrl()
else:
......
......@@ -3,10 +3,10 @@ relative_url = context.getRelativeUrl()
if relative_url == 'currency_module/CNY':
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredWechatIntegrationSite())
else:
elif relative_url == 'currency_module/EUR':
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())
else:
# Only EUR is supported for now
assert relative_url in ('currency_module/EUR', 'currency_module/CNY')
# Only EUR is supported for now
assert relative_url in ('currency_module/EUR', 'currency_module/CNY')
return integration_site.getMappingFromCategory('resource/%s' % relative_url).split('/', 1)[-1]
......@@ -7,7 +7,10 @@ integration_site = portal.restrictedTraverse(portal.portal_preferences.getPrefer
payzen_id = integration_site.getCategoryFromMapping('Causality/%s' % context.getId().replace('-', '_'))
if payzen_id != 'causality/%s' % context.getId().replace('-', '_'):
# ok when using per day generator
date, payzen_id = payzen_id.split('_', 1)
# and then switched to per day / per node generator
date = date.split('.', 1)[0]
return DateTime(date).toZone('UTC'), payzen_id
else:
return None, None
......@@ -72,7 +72,8 @@ elif transaction_status in continue_transaction_id_list:
# Check authAmount and authDevise and if match, stop transaction
auth_amount = int(transaction_kw['transactionDetails']['cardDetails']['authorizationResponse']['amount'])
auth_devise = transaction_kw['transactionDetails']['cardDetails']['authorizationResponse']['currency']
transaction_amount = int((round(transaction.PaymentTransaction_getTotalPayablePrice(), 2) * -100))
# XXX use currency base_unit_quantity instead
transaction_amount = int((round(transaction.PaymentTransaction_getTotalPayablePrice() * -100, 0)))
if transaction_amount != auth_amount:
payzen_event.confirm(comment='Received amount (%r) does not match stored on transaction (%r)'% (auth_amount, transaction_amount))
......
......@@ -25,6 +25,7 @@ from DateTime import DateTime
from zExceptions import Unauthorized
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSCurrency_getIntegrationMapping(SlapOSTestCaseMixinWithAbort):
def test_integratedCurrency(self):
......@@ -727,16 +728,22 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualPayzenPayment_redirect(self):
self.portal.portal_secure_payments.slapos_payzen_test.setReference("PSERV-Payzen-Test")
self.tic()
person = self.makePerson()
project = self.addProject()
person = self.makePerson(project)
invoice = self.createStoppedSaleInvoiceTransaction(
destination_section=person.getRelativeUrl())
destination_section_value=person,
destination_project_value=project
)
self.tic()
payment = self.portal.accounting_module.newContent(
portal_type="Payment Transaction",
payment_mode='payzen',
causality_value=invoice,
destination_section=invoice.getDestinationSection(),
destination_value=invoice.getDestinationValue(),
destination_section_value=invoice.getDestinationSectionValue(),
destination_project_value=invoice.getDestinationProjectValue(),
resource_value=self.portal.currency_module.EUR,
ledger="automated",
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
......@@ -778,16 +785,22 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
len(system_event_list[0].contentValues(portal_type="Payzen Event Message")), 1)
def test_PaymentTransaction_redirectToManualPayzenPayment_already_registered(self):
person = self.makePerson()
project = self.addProject()
person = self.makePerson(project)
invoice = self.createStoppedSaleInvoiceTransaction(
destination_section=person.getRelativeUrl())
destination_section_value=person,
destination_project_value=project
)
self.tic()
payment = self.portal.accounting_module.newContent(
portal_type="Payment Transaction",
payment_mode='payzen',
causality_value=invoice,
destination_section=invoice.getDestinationSection(),
destination_value=invoice.getDestinationValue(),
destination_section_value=invoice.getDestinationSectionValue(),
destination_project_value=invoice.getDestinationProjectValue(),
resource_value=self.portal.currency_module.EUR,
ledger="automated",
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
......
......@@ -4,6 +4,7 @@ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
import lxml.html
from DateTime import DateTime
from Products.ERP5Type.tests.utils import createZODBPythonScript
import difflib
HARDCODED_PRICE = -99.6
......@@ -289,7 +290,11 @@ class TestSlapOSPayzenInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
message_text_content = lxml.html.tostring(
lxml.html.fromstring(message.getTextContent()), method='c14n')
self.assertEqual(message_text_content, expected_html_page)
self.assertEqual(message_text_content, expected_html_page,
'\n'.join([q for q in difflib.unified_diff(
message_text_content.split('\n'),
expected_html_page.split('\n')
)]))
def test_updateStatus_noAccountingTransaction(self):
event = self.createPayzenEvent()
......
sale_trade_condition_module/payzen_sale_trade_condition
sale_trade_condition_module/slapos_manual_accounting_trade_condition
\ No newline at end of file
sale_trade_condition_module/payzen_sale_trade_condition
\ No newline at end of file
accounting_module/template_sale_invoice_transaction
accounting_module/template_sale_invoice_transaction/**
portal_alarms/slapos_payzen_update_started_payment
portal_integrations/slapos_payzen_test_integration
portal_integrations/slapos_payzen_test_integration/Causality
......@@ -8,5 +6,4 @@ portal_integrations/slapos_payzen_test_integration/Resource/**
portal_integrations/slapos_payzen_test_integration/SourceProject
portal_secure_payments/slapos_payzen_test
portal_secure_payments/slapos_payzen_test/**
sale_trade_condition_module/payzen_sale_trade_condition
sale_trade_condition_module/slapos_manual_accounting_trade_condition
\ 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