Commit 69848c75 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: Use isLettered rather them isGrouped

   isLettered is more accurated to accounting terms and easy to understand.
parent 54d861d4
......@@ -12,7 +12,7 @@ portal.portal_catalog.searchAndActivate(
payment_mode_uid=[
portal.portal_categories.payment_mode.payzen.getUid(),
portal.portal_categories.payment_mode.wechat.getUid()],
method_id='PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped',
method_id='PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered',
packet_size=1, # just one to minimise errors
activate_kw={'tag': tag},
**kw
......
......@@ -4,35 +4,13 @@ if simulation_state != "started":
# The payment isn't started, so ignore it
return "Not Started"
portal = context.getPortalObject()
paid = False
def isNodeFromLineReceivable(line):
node_value = line.getSourceValue(portal_type='Account')
return node_value.getAccountType() == 'asset/receivable'
invoice = context.getCausalityValue()
if invoice is None:
# No invoice Related, so skip and ignore
return
line_found = False
line_list = invoice.getMovementList(portal.getPortalAccountingMovementTypeList())
if not len(line_list):
# Ignore since lines to group don't exist yet
return
for line in line_list:
if isNodeFromLineReceivable(line):
line_found = True
if line.hasGroupingReference():
paid = True
letter = line.getGroupingReference()
break
if line_found and paid:
letter = invoice.SaleInvoiceTransaction_isLettered()
if letter:
# 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,\
......@@ -40,7 +18,6 @@ if line_found and paid:
# Should be safe now to fix everything XXXXXXX
invoice.SaleInvoiceTransaction_resetPaymentMode()
return "Payment Cancelled"
return "Skipped"
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped</string> </value>
<value> <string>PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered</string> </value>
</item>
</dictionary>
</pickle>
......
portal = context.getObject()
line_list = context.getMovementList(
portal_type=portal.getPortalAccountingMovementTypeList())
if not len(line_list):
# Ignore since lines to group don't exist yet
return False
source_list = [i.getRelativeUrl() for i in context.Base_getReceivableAccountList()]
for line in line_list:
if line.gerSource() in source_list:
if line.hasGroupingReference():
return line.getGroupingReference()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleInvoiceTransaction_isLettered</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
# -*- coding:utf-8 -*-
##############################################################################
#
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
# Copyright (c) 2002-2018 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
......@@ -1411,14 +1432,14 @@ class TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm(SlapOSTestCase
self.tic()
self.assertNotEqual(
'Not visited by PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped',
'Not visited by PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered',
payment_transaction.getTitle())
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped')
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered')
def test_payment_is_draft_payzen(self):
self._test_payment_is_draft(payment_mode="payzen")
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped')
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionIsLettered')
def test_payment_is_draft_wechat(self):
self._test_payment_is_draft(payment_mode="wechat")
......@@ -1440,14 +1461,14 @@ class TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm(SlapOSTestCase
self.tic()
self.assertNotEqual(
'Not visited by PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped',
'Not visited by PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered',
payment_transaction.getTitle())
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped')
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered')
def test_payment_is_stopped_payzen(self):
self._test_payment_is_stopped(payment_mode="payzen")
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped')
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered')
def test_payment_is_stopped_wechat(self):
self._test_payment_is_stopped(payment_mode="wechat")
......@@ -1469,14 +1490,13 @@ class TestSlapOSCancelSaleTnvoiceTransactionPaiedPaymentListAlarm(SlapOSTestCase
self.tic()
self.assertNotEqual(
'Visited by PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped',
'Visited by PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered',
payment_transaction.getTitle())
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped')
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered')
def test_payment_is_started_payzen(self):
self._test_payment_is_started(payment_mode="payzen")
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionIsGrouped')
@simulateByTitlewMark('PaymentTransaction_cancelIfSaleInvoiceTransactionisLettered')
def test_payment_is_started_wechat(self):
self._test_payment_is_started(payment_mode="wechat")
self._test_payment_is_started(payment_mode="wechat")
\ No newline at end of file
......@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSAccountingAlarm</string> </value>
......@@ -55,28 +49,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</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>
......@@ -89,7 +68,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
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