Commit 7021dfe1 authored by Romain Courteaud's avatar Romain Courteaud

slapos_wechat: support new ID generator

Modules switched to per day/node ID generator.

Also in this commit:
* drop not needed trade conditions
parent 7246420a
......@@ -81,9 +81,7 @@
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source_trade/sale_trade_condition_module/wechat_sale_trade_condition</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......
<?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>Author</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>Author</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>Author</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>Author</string>
<string>Manager</string>
<string>Owner</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>wechat_sale_trade_condition</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</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>WeChat Sale Trade Condition</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value>
<none/>
</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>
</ZopeData>
......@@ -7,7 +7,10 @@ integration_site = portal.restrictedTraverse(portal.portal_preferences.getPrefer
wechat_id = integration_site.getCategoryFromMapping('Causality/%s' % context.getId().replace('-', '_'))
if wechat_id != 'causality/%s' % context.getId().replace('-', '_'):
date, _ = wechat_id.split('-', 1)
# ok when using per day generator
date = wechat_id.split('-', 1)[0]
# and then switched to per day / per node generator
date = date.split('.', 1)[0]
return DateTime(date).toZone('UTC'), wechat_id
else:
return None, None
......@@ -122,8 +122,13 @@ class TestSlapOSPaymentTransaction_generateWechatId(SlapOSTestCaseMixinWithAbort
mapping = integration_site.getCategoryFromMapping(
'Causality/%s' % transaction_url)
self.assertEqual(mapping, "%s-%s" % (
transaction_date.asdatetime().strftime('%Y%m%d'), wechat_id.split('-')[1]))
self.assertEqual(mapping, payment_transaction.getId())
self.assertTrue(mapping.startswith(
'%s.' % transaction_date.asdatetime().strftime('%Y%m%d')
))
self.assertTrue(mapping.endswith(
'-%s' % wechat_id.split('-')[1]
))
category = integration_site.getMappingFromCategory('causality/%s' % mapping)
# XXX Not indexed yet
# self.assertEqual(category, 'Causality/%s' % transaction_url)
......@@ -589,17 +594,23 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualWechatPayment_redirect(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
person = self.makePerson()
project = self.addProject()
person = self.makePerson(project)
invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat",
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='wechat',
causality_value=invoice,
destination=invoice.getDestination(),
destination_section=invoice.getDestinationSection(),
destination_project_value=project,
resource_value=self.portal.currency_module.CNY,
ledger="automated",
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
......@@ -634,17 +645,23 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualWechatPayment_redirect_with_website(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
person = self.makePerson()
project = self.addProject()
person = self.makePerson(project)
invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat",
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='wechat',
causality_value=invoice,
destination=invoice.getDestination(),
destination_section=invoice.getDestinationSection(),
destination_project_value=project,
resource_value=self.portal.currency_module.CNY,
ledger="automated",
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
......@@ -674,17 +691,23 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualWechatPayment_already_registered(self):
person = self.makePerson()
project = self.addProject()
person = self.makePerson(project)
invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat",
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='wechat',
causality_value=invoice,
destination=invoice.getDestination(),
destination_section=invoice.getDestinationSection(),
destination_project_value=project,
resource_value=self.portal.currency_module.CNY,
ledger="automated",
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
......
image_module/wechat**
sale_trade_condition_module/wechat_sale_trade_condition
\ No newline at end of file
image_module/wechat**
\ No newline at end of file
portal_secure_payments/slapos_wechat_test
portal_secure_payments/slapos_wechat_test/**
\ No newline at end of file
portal_secure_payments/slapos_wechat_test/**
sale_trade_condition_module/wechat_sale_trade_condition
\ No newline at end of file
......@@ -6,5 +6,4 @@ portal_integrations/slapos_wechat_test_integration/Resource
portal_integrations/slapos_wechat_test_integration/Resource/**
portal_integrations/slapos_wechat_test_integration/SourceProject
portal_secure_payments/slapos_wechat_test
portal_secure_payments/slapos_wechat_test/**
sale_trade_condition_module/wechat_sale_trade_condition
\ No newline at end of file
portal_secure_payments/slapos_wechat_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