Commit 5f6d212b authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: drop not needed SaleInvoiceTransaction_resetPaymentMode

parent 2e8399c8
...@@ -12,12 +12,8 @@ if invoice is None: ...@@ -12,12 +12,8 @@ if invoice is None:
letter = invoice.SaleInvoiceTransaction_isLettered() letter = invoice.SaleInvoiceTransaction_isLettered()
if letter: if letter:
# We should ensure that the order builder won't create another document. # We should ensure that the order builder won't create another document.
context.edit(payment_mode=None)
context.cancel(comment="Payment is cancelled since the invoice is payed by other document,\ context.cancel(comment="Payment is cancelled since the invoice is payed by other document,\
with grouping reference %s" % letter) with grouping reference %s" % letter)
# Should be safe now to fix everything XXXXXXX
invoice.SaleInvoiceTransaction_resetPaymentMode()
return "Payment Cancelled" return "Payment Cancelled"
return "Skipped" return "Skipped"
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
assert "Sale Invoice Transaction" == context.getPortalType()
assert "stopped" == context.getSimulationState()
# Edit as Manager to workarround security when cancel Sale Invoice Transaction
if context.getPaymentMode() in ["payzen", "wechat"]:
context.edit(payment_mode=None)
<?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>REQUEST=None</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>SaleInvoiceTransaction_resetPaymentMode</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, withAbort from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, withAbort
from zExceptions import Unauthorized
from DateTime import DateTime from DateTime import DateTime
class TestSlapOSAccounting(SlapOSTestCaseMixin): class TestSlapOSAccounting(SlapOSTestCaseMixin):
...@@ -124,34 +123,6 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin): ...@@ -124,34 +123,6 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
"%s doesn't end with %s?portal_status_message=The%%20payment%%20mode%%20is%%20unsupported." % ( "%s doesn't end with %s?portal_status_message=The%%20payment%%20mode%%20is%%20unsupported." % (
redirect, sale_invoice_transaction.getRelativeUrl())) redirect, sale_invoice_transaction.getRelativeUrl()))
#################################################################
# SaleInvoiceTransaction_resetPaymentMode
#################################################################
def test_SaleInvoiceTransaction_resetPaymentMode(self):
sale_invoice_transaction = self.portal.accounting_module.newContent(portal_type="Sale Invoice Transaction")
sale_invoice_transaction.edit(payment_mode="unknown",
start_date=DateTime(),
stop_date=DateTime())
sale_invoice_transaction.confirm()
sale_invoice_transaction.start( )
sale_invoice_transaction.stop()
sale_invoice_transaction.SaleInvoiceTransaction_resetPaymentMode()
self.assertEqual(sale_invoice_transaction.getPaymentMode(), "unknown")
sale_invoice_transaction.edit(payment_mode="payzen")
sale_invoice_transaction.SaleInvoiceTransaction_resetPaymentMode()
self.assertEqual(sale_invoice_transaction.getPaymentMode(), None)
sale_invoice_transaction.edit(payment_mode="wechat")
sale_invoice_transaction.SaleInvoiceTransaction_resetPaymentMode()
self.assertEqual(sale_invoice_transaction.getPaymentMode(), None)
self.assertRaises(
Unauthorized,
sale_invoice_transaction.SaleInvoiceTransaction_resetPaymentMode,
REQUEST={})
################################################################# #################################################################
# SaleInvoiceTransaction_createReversalSaleInvoiceTransaction # SaleInvoiceTransaction_createReversalSaleInvoiceTransaction
################################################################# #################################################################
...@@ -457,6 +428,8 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin): ...@@ -457,6 +428,8 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
self.tic() self.tic()
self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState()) self.assertEqual("Cancelled", invoice.AccountingTransaction_getPaymentState())
self.assertEqual(0, invoice.getTotalPrice() + reversal.getTotalPrice()) self.assertEqual(0, invoice.getTotalPrice() + reversal.getTotalPrice())
self.assertTrue(invoice.SaleInvoiceTransaction_isLettered())
self.assertTrue(reversal.SaleInvoiceTransaction_isLettered())
@withAbort @withAbort
def test_AccountingTransaction_getPaymentState_wechat_reversed_payment(self): def test_AccountingTransaction_getPaymentState_wechat_reversed_payment(self):
......
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