Commit 4c697375 authored by Romain Courteaud's avatar Romain Courteaud

slapos_wechat:

* drop not needed wechat_sale_trade_condition
* new id generator per node is used
* payment transaction ID is used as mapping
parent 4e02205e
...@@ -81,9 +81,7 @@ ...@@ -81,9 +81,7 @@
<item> <item>
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple/>
<string>source_trade/sale_trade_condition_module/wechat_sale_trade_condition</string>
</tuple>
</value> </value>
</item> </item>
<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 ...@@ -7,7 +7,10 @@ integration_site = portal.restrictedTraverse(portal.portal_preferences.getPrefer
wechat_id = integration_site.getCategoryFromMapping('Causality/%s' % context.getId().replace('-', '_')) wechat_id = integration_site.getCategoryFromMapping('Causality/%s' % context.getId().replace('-', '_'))
if wechat_id != '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 return DateTime(date).toZone('UTC'), wechat_id
else: else:
return None, None return None, None
...@@ -122,8 +122,13 @@ class TestSlapOSPaymentTransaction_generateWechatId(SlapOSTestCaseMixinWithAbort ...@@ -122,8 +122,13 @@ class TestSlapOSPaymentTransaction_generateWechatId(SlapOSTestCaseMixinWithAbort
mapping = integration_site.getCategoryFromMapping( mapping = integration_site.getCategoryFromMapping(
'Causality/%s' % transaction_url) 'Causality/%s' % transaction_url)
self.assertEqual(mapping, "%s-%s" % ( self.assertEqual(mapping, payment_transaction.getId())
transaction_date.asdatetime().strftime('%Y%m%d'), wechat_id.split('-')[1])) 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) category = integration_site.getMappingFromCategory('causality/%s' % mapping)
# XXX Not indexed yet # XXX Not indexed yet
# self.assertEqual(category, 'Causality/%s' % transaction_url) # self.assertEqual(category, 'Causality/%s' % transaction_url)
...@@ -589,17 +594,23 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -589,17 +594,23 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualWechatPayment_redirect(self): def test_PaymentTransaction_redirectToManualWechatPayment_redirect(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test") 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( invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat", payment_mode="wechat",
destination_section=person.getRelativeUrl()) destination_section_value=person,
destination_project_value=project
)
self.tic() self.tic()
payment = self.portal.accounting_module.newContent( payment = self.portal.accounting_module.newContent(
portal_type="Payment Transaction", portal_type="Payment Transaction",
payment_mode='wechat', payment_mode='wechat',
causality_value=invoice, causality_value=invoice,
destination=invoice.getDestination(),
destination_section=invoice.getDestinationSection(), destination_section=invoice.getDestinationSection(),
destination_project_value=project,
resource_value=self.portal.currency_module.CNY, resource_value=self.portal.currency_module.CNY,
ledger="automated",
created_by_builder=1 # to prevent init script to create lines created_by_builder=1 # to prevent init script to create lines
) )
self.portal.portal_workflow._jumpToStateFor(payment, 'started') self.portal.portal_workflow._jumpToStateFor(payment, 'started')
...@@ -634,17 +645,23 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -634,17 +645,23 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualWechatPayment_redirect_with_website(self): def test_PaymentTransaction_redirectToManualWechatPayment_redirect_with_website(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test") 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( invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat", payment_mode="wechat",
destination_section=person.getRelativeUrl()) destination_section_value=person,
destination_project_value=project
)
self.tic() self.tic()
payment = self.portal.accounting_module.newContent( payment = self.portal.accounting_module.newContent(
portal_type="Payment Transaction", portal_type="Payment Transaction",
payment_mode='wechat', payment_mode='wechat',
causality_value=invoice, causality_value=invoice,
destination=invoice.getDestination(),
destination_section=invoice.getDestinationSection(), destination_section=invoice.getDestinationSection(),
destination_project_value=project,
resource_value=self.portal.currency_module.CNY, resource_value=self.portal.currency_module.CNY,
ledger="automated",
created_by_builder=1 # to prevent init script to create lines created_by_builder=1 # to prevent init script to create lines
) )
self.portal.portal_workflow._jumpToStateFor(payment, 'started') self.portal.portal_workflow._jumpToStateFor(payment, 'started')
...@@ -674,17 +691,23 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -674,17 +691,23 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualWechatPayment_already_registered(self): def test_PaymentTransaction_redirectToManualWechatPayment_already_registered(self):
person = self.makePerson() project = self.addProject()
person = self.makePerson(project)
invoice = self.createStoppedSaleInvoiceTransaction( invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat", payment_mode="wechat",
destination_section=person.getRelativeUrl()) destination_section_value=person,
destination_project_value=project
)
self.tic() self.tic()
payment = self.portal.accounting_module.newContent( payment = self.portal.accounting_module.newContent(
portal_type="Payment Transaction", portal_type="Payment Transaction",
payment_mode='wechat', payment_mode='wechat',
causality_value=invoice, causality_value=invoice,
destination=invoice.getDestination(),
destination_section=invoice.getDestinationSection(), destination_section=invoice.getDestinationSection(),
destination_project_value=project,
resource_value=self.portal.currency_module.CNY, resource_value=self.portal.currency_module.CNY,
ledger="automated",
created_by_builder=1 # to prevent init script to create lines created_by_builder=1 # to prevent init script to create lines
) )
self.portal.portal_workflow._jumpToStateFor(payment, 'started') self.portal.portal_workflow._jumpToStateFor(payment, 'started')
......
image_module/wechat** image_module/wechat**
sale_trade_condition_module/wechat_sale_trade_condition \ No newline at end of file
\ No newline at end of file
portal_secure_payments/slapos_wechat_test portal_secure_payments/slapos_wechat_test
portal_secure_payments/slapos_wechat_test/** portal_secure_payments/slapos_wechat_test/**
\ No newline at end of file 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 ...@@ -6,5 +6,4 @@ portal_integrations/slapos_wechat_test_integration/Resource
portal_integrations/slapos_wechat_test_integration/Resource/** portal_integrations/slapos_wechat_test_integration/Resource/**
portal_integrations/slapos_wechat_test_integration/SourceProject portal_integrations/slapos_wechat_test_integration/SourceProject
portal_secure_payments/slapos_wechat_test portal_secure_payments/slapos_wechat_test
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
\ 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