diff --git a/bt5/erp5_simulation_legacy/DocumentTemplateItem/PaymentSimulationRule.py b/bt5/erp5_simulation_legacy/DocumentTemplateItem/PaymentSimulationRule.py index 975ffe0ffd73486eba1aed49fa7c7965cde4d50b..2c11f90fd5f005198bc29a00f1924057a631f8b6 100644 --- a/bt5/erp5_simulation_legacy/DocumentTemplateItem/PaymentSimulationRule.py +++ b/bt5/erp5_simulation_legacy/DocumentTemplateItem/PaymentSimulationRule.py @@ -97,13 +97,17 @@ class PaymentSimulationRule(Rule, PredicateMatrix): if cell is not None : # else, we do nothing for payment_condition in payment_condition_list: - aggregated_ammount_list = payment_condition.getAggregatedAmountList( - input_movement, movement_list=[input_movement]) - assert len(aggregated_ammount_list) == 1 - aggregated_ammount = aggregated_ammount_list[0] - start_date = aggregated_ammount.getStartDate() - stop_date = aggregated_ammount.getStopDate() - quantity = aggregated_ammount.getQuantity() + # XXX + if (payment_condition.getCalculationScript(input_movement) is not None + or payment_condition.getEfficiency() != 1): + raise NotImplementedError + #amount, = payment_condition.getAggregatedAmountList((input_movement,)) + #start_date = amount.getStartDate() # does it depend on any property + #stop_date = amount.getStopDate() # of payment_condition ? + #quantity = amount.getQuantity() + start_date = input_movement.getStartDate() + stop_date = input_movement.getStopDate() + quantity = input_movement.getTotalPrice() * payment_condition.getQuantity(1) payment_mode = payment_condition.getPaymentMode() # one for payable diff --git a/bt5/erp5_simulation_legacy/bt/revision b/bt5/erp5_simulation_legacy/bt/revision index d8263ee9860594d2806b0dfd1bfd17528b0ba2a4..e440e5c842586965a7fb77deda2eca68612b1f53 100644 --- a/bt5/erp5_simulation_legacy/bt/revision +++ b/bt5/erp5_simulation_legacy/bt/revision @@ -1 +1 @@ -2 \ No newline at end of file +3 \ No newline at end of file diff --git a/product/ERP5/tests/testAccountingRules.py b/product/ERP5/tests/testAccountingRules.py index d6b5bed39edaf056e5239d4c2c676f501fa1168f..c0ec6765701722af01e82114a24cb3ed837ebb34 100644 --- a/product/ERP5/tests/testAccountingRules.py +++ b/product/ERP5/tests/testAccountingRules.py @@ -47,6 +47,7 @@ import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.Sequence import SequenceList +from Products.ERP5.tests.utils import newSimulationExpectedFailure from Products.ERP5.Document.MirrorMovementGroup import _isMirrored from Testing import ZopeTestCase @@ -1662,6 +1663,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): self.failUnless(self.getProductModule() != None) self.failUnless(self.getCurrencyModule() != None) + @newSimulationExpectedFailure def test_02_UpdateInvoiceTransactionRuleMatrix(self, quiet=QUIET, run=RUN_ALL_TESTS): """ test edition of matrix and rule. @@ -1689,6 +1691,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): stepCheckRestoreOriginalPredicates """, quiet=quiet) + @newSimulationExpectedFailure def test_03_invoiceTransactionRule_getMatchingCell(self, quiet=QUIET, run=RUN_ALL_TESTS): """ test predicates for the cells of invoice transaction rule @@ -1719,6 +1722,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): stepCheckNotMatchableInvoiceMovements """, quiet=quiet) + @newSimulationExpectedFailure def test_04_SimpleInvoice(self, quiet=QUIET, run=RUN_ALL_TESTS): """ Simple Invoice. Try to expand an invoice containing only one simple Invoice Line. @@ -1760,6 +1764,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): stepCheckPaymentLinesCreatedForSimpleInvoice """, quiet=quiet ) + @newSimulationExpectedFailure def test_04b_SimpleInvoiceConfirm(self, quiet=QUIET, run=RUN_ALL_TESTS): """ Same test as SimpleInvoice but directly confirm the invoice without planning it """ @@ -1795,6 +1800,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): stepRebuildAndCheckNothingIsCreated """, quiet=quiet ) + @newSimulationExpectedFailure def test_04c_SimpleInvoiceTwoLines(self, quiet=QUIET, run=RUN_ALL_TESTS): """ Simple Invoice, 2 lines. Same test as SimpleInvoice but use 2 lines of quantity 5 instead of @@ -1832,6 +1838,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): stepRebuildAndCheckNothingIsCreated """, quiet=quiet ) + @newSimulationExpectedFailure def test_04d_SimpleInvoiceTwoCells(self, quiet=QUIET, run=RUN_ALL_TESTS): """ Simple Invoice, 2 cells. Same test as SimpleInvoice but use 2 cells of quantity 5 instead of @@ -1870,6 +1877,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): """, quiet=quiet ) # next 5 tests will check update of applied rules. + @newSimulationExpectedFailure def test_05a_SimpleInvoiceReExpandAddLine(self, quiet=QUIET, run=RUN_ALL_TESTS): """ Add a new line then updateAppliedRule. @@ -1912,6 +1920,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): stepRebuildAndCheckNothingIsCreated """, quiet=quiet ) + @newSimulationExpectedFailure def test_05b_SimpleInvoiceReExpandEditLine(self, quiet=QUIET, run = RUN_ALL_TESTS): """ Tests that editing a line updates simulation correctly """ @@ -1950,6 +1959,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): stepRebuildAndCheckNothingIsCreated """, quiet=quiet ) + @newSimulationExpectedFailure def test_05c_SimpleInvoiceReExpandDeleteLine( self, quiet=QUIET, run=RUN_ALL_TESTS): """ Tests that removing a line updates simulation correctly """ @@ -1990,6 +2000,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): stepRebuildAndCheckNothingIsCreated """, quiet=quiet ) + @newSimulationExpectedFailure def test_05d_SimpleInvoiceReExpandCreateCell(self, quiet=QUIET, run=RUN_ALL_TESTS): """ Tests that replacing a line by cells updates simulation correctly """ @@ -2028,6 +2039,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): stepRebuildAndCheckNothingIsCreated """, quiet=quiet) + @newSimulationExpectedFailure def test_05e_SimpleInvoiceExpandManyTimes( self, quiet=QUIET, run=RUN_ALL_TESTS): """ Tests that updating an applied rule many times doesn't break the @@ -2071,6 +2083,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): stepRebuildAndCheckNothingIsCreated """, quiet=quiet ) + @newSimulationExpectedFailure def test_06_MultiLineInvoice(self, quiet=QUIET, run=RUN_ALL_TESTS): """ Multiple lines invoice. Try to expand an invoice containing multiples Invoice Line. @@ -2120,6 +2133,7 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): # quantity from sum of receivable movement # link to sale invoice + @newSimulationExpectedFailure def test_planning_invoice_creates_simulation(self, quiet=QUIET): # http://mail.nexedi.com/pipermail/erp5-dev/2008-June/001969.html self.playSequence(""" diff --git a/product/ERP5/tests/testRule.py b/product/ERP5/tests/testRule.py index 2934a88727d0e7373e0343464e8fec95590b1e6f..ff750d2667a24220b955b59bad0bdce1c086f7bb 100644 --- a/product/ERP5/tests/testRule.py +++ b/product/ERP5/tests/testRule.py @@ -31,7 +31,8 @@ import transaction from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.utils import createZODBPythonScript -from testOrder import TestOrderMixin +from Products.ERP5.tests.testOrder import TestOrderMixin +from Products.ERP5.tests.utils import newSimulationExpectedFailure class TestRuleMixin(TestOrderMixin): """ @@ -108,6 +109,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : run_all_test = 1 quiet = 0 + @newSimulationExpectedFailure def test_01_ValidatedRuleWithNoScript(self, quiet=quiet, run=run_all_test): """ test that when a rule is validated, but has no script it will not apply @@ -124,6 +126,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : validation_state="validated")[0][0], 1) self.assertEquals(len(self.getRuleTool().searchRuleList(self.pl)), 0) + @newSimulationExpectedFailure def test_02_WrongTestMethod(self, quiet=quiet, run=run_all_test): """ test that when a rule's test method returns False, it will not apply @@ -144,6 +147,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : validation_state="validated")[0][0], 1) self.assertEquals(len(self.getRuleTool().searchRuleList(self.pl)), 0) + @newSimulationExpectedFailure def test_03_GoodTestMethod(self, quiet=quiet, run=run_all_test): """ test that when a rule's test method returns True, it will apply @@ -164,6 +168,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : validation_state="validated")[0][0], 1) self.assertEquals(len(self.getRuleTool().searchRuleList(self.pl)), 1) + @newSimulationExpectedFailure def test_04_NotValidatedRule(self, quiet=quiet, run=run_all_test): """ test that when a rule is not validated, it will not apply, even if it has @@ -186,6 +191,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : validation_state="validated")[0][0], 0) self.assertEquals(len(self.getRuleTool().searchRuleList(self.pl)), 0) + @newSimulationExpectedFailure def test_06_WrongDateRange(self, quiet=quiet, run=run_all_test): """ test that when a rule is validated but does not have correct date range, @@ -209,6 +215,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : validation_state="validated")[0][0], 1) self.assertEquals(len(self.getRuleTool().searchRuleList(self.pl)), 0) + @newSimulationExpectedFailure def test_07_GoodDateRange(self, quiet=quiet, run=run_all_test): """ test that when a rule is validated and has a correct date range, it will @@ -232,6 +239,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : validation_state="validated")[0][0], 1) self.assertEquals(len(self.getRuleTool().searchRuleList(self.pl)), 1) + @newSimulationExpectedFailure def test_08_updateAppliedRule(self, quiet=quiet, run=run_all_test): """ test that when updateAppliedRule is called, the rule with the correct @@ -286,6 +294,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : self.assertEquals(self.pl.getCausalityRelatedValue().getSpecialise(), delivery_rule_1.getRelativeUrl()) + @newSimulationExpectedFailure def test_09_expandTwoRules(self, quiet=quiet, run=run_all_test): """ test that when expand is called on a simulation movement, if two rules @@ -365,6 +374,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : self.assertEquals(applied_rule.getSpecialise(), invoicing_rule_1.getRelativeUrl()) + @newSimulationExpectedFailure def test_10_expandAddsRule(self, quiet=quiet, run=run_all_test): """ test that if a rule didn't match previously, and does now, it should apply @@ -467,6 +477,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : invoicing_rule_2.getRelativeUrl()) + @newSimulationExpectedFailure def test_11_expandRemovesRule(self, quiet=quiet, run=run_all_test): """ test that if a rule matched previously and does not anymore, it should be @@ -597,6 +608,7 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) : sub_movement = applied_rule.objectValues()[0] self.assertEquals(sub_movement.getDelivery(), self.pl.line.getRelativeUrl()) + @newSimulationExpectedFailure def test_12_expandReplacesRule(self, quiet=quiet, run=run_all_test): """ test that if a rule matched previously and does not anymore, and another diff --git a/product/ERP5Legacy/tests/testLegacySimulationRule.py b/product/ERP5Legacy/tests/testLegacySimulationRule.py new file mode 100644 index 0000000000000000000000000000000000000000..76982d8f7b39639885706ef28c9daf1755252898 --- /dev/null +++ b/product/ERP5Legacy/tests/testLegacySimulationRule.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +############################################################################## +# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved. +# Julien Muchembled <jm@nexedi.com> +# +# 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 advised 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. +# +############################################################################## + +import sys +from Products.ERP5Legacy.tests import testLegacyRuleOrder +sys.modules['Products.ERP5.tests.testOrder'] = testLegacyRuleOrder + +from Products.ERP5Legacy.tests import Legacy_getBusinessTemplateList +from Products.ERP5.tests.testRule import * +Legacy_getBusinessTemplateList(TestRuleMixin)