Commit 3a23ba4b authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

minimise the configuratino of payment rule cell.

* one cell per predicate is enough
* no need to specify quantity


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33077 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent df47534f
...@@ -101,26 +101,28 @@ class PaymentSimulationRule(Rule, PredicateMatrix): ...@@ -101,26 +101,28 @@ class PaymentSimulationRule(Rule, PredicateMatrix):
input_movement.getStartDate() input_movement.getStartDate()
stop_date = payment_condition.getExpectedStopDate(input_movement) or \ stop_date = payment_condition.getExpectedStopDate(input_movement) or \
input_movement.getStopDate() input_movement.getStopDate()
kw.update({'start_date':start_date, 'stop_date':stop_date})
quantity = payment_condition.getExpectedQuantity(input_movement) quantity = payment_condition.getExpectedQuantity(input_movement)
for payment_rule_cell_line in cell.objectValues():
prevision_line = kw.copy() # one for payable
prevision_line.update( prevision_line = kw.copy()
source=payment_rule_cell_line.getSource() or \ prevision_line.update(
input_movement.getSource(), source=input_movement.getSource(),
destination=payment_rule_cell_line.getDestination() or \ destination=input_movement.getDestination(),
input_movement.getDestination(), quantity=-quantity
start_date=start_date, )
stop_date=stop_date, prevision_list.append(prevision_line)
quantity=quantity * payment_rule_cell_line.getQuantity() # one for cash, bank etc.
) payment_rule_cell_line_list = cell.objectValues()
# Generate Prevision Script is required for Payment Simulation Rule? assert len(payment_rule_cell_line_list) == 1
if payment_rule_cell_line.hasProperty( payment_rule_cell_line = payment_rule_cell_line_list[0]
'generate_prevision_script_id'): prevision_line = kw.copy()
generate_prevision_script_id = \ prevision_line.update(
payment_rule_cell_line.getGeneratePrevisionScriptId() source=payment_rule_cell_line.getSource(),
prevision_line.update(getattr(input_movement, destination=payment_rule_cell_line.getDestination(),
generate_prevision_script_id)(prevision_line)) quantity=quantity
prevision_list.append(prevision_line) )
prevision_list.append(prevision_line)
return prevision_list return prevision_list
security.declareProtected(Permissions.ModifyPortalContent, 'expand') security.declareProtected(Permissions.ModifyPortalContent, 'expand')
......
...@@ -88,8 +88,7 @@ class TestAccountingRulesMixin: ...@@ -88,8 +88,7 @@ class TestAccountingRulesMixin:
payment_transaction_portal_type = "Payment Transaction" payment_transaction_portal_type = "Payment Transaction"
payment_transaction_line_definition_list = ( payment_transaction_line_definition_list = (
('payable', None, None, -1.0), ('bank', 'account_module/bank', 'account_module/bank'),
('bank', 'account_module/bank', 'account_module/bank', 1.0)
) )
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
...@@ -538,10 +537,10 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase): ...@@ -538,10 +537,10 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
self.assertEqual(len(cell_list), 1) self.assertEqual(len(cell_list), 1)
cell = cell_list[0] cell = cell_list[0]
for line_id, line_source_id, line_destination_id, line_ratio in \ for line_id, line_source_id, line_destination_id in \
self.payment_transaction_line_definition_list: self.payment_transaction_line_definition_list:
line = cell.newContent(id=line_id, line = cell.newContent(id=line_id,
portal_type='Accounting Transaction Line', quantity=line_ratio, portal_type='Accounting Transaction Line',
source=line_source_id, source=line_source_id,
destination=line_destination_id) destination=line_destination_id)
payment_rule.validate() payment_rule.validate()
......
...@@ -78,8 +78,7 @@ class TestInvoiceMixin(TestPackingListMixin, ...@@ -78,8 +78,7 @@ class TestInvoiceMixin(TestPackingListMixin,
) )
payment_transaction_line_definition_list = ( payment_transaction_line_definition_list = (
('payable', None, None, -1.0), ('bank', 'account_module/bank', 'account_module/bank'),
('bank', 'account_module/bank', 'account_module/bank', 1.0)
) )
def getTitle(self): def getTitle(self):
...@@ -195,10 +194,10 @@ class TestInvoiceMixin(TestPackingListMixin, ...@@ -195,10 +194,10 @@ class TestInvoiceMixin(TestPackingListMixin,
self.assertEqual(len(cell_list), 1) self.assertEqual(len(cell_list), 1)
cell = cell_list[0] cell = cell_list[0]
for line_id, line_source_id, line_destination_id, line_ratio in \ for line_id, line_source_id, line_destination_id in \
self.payment_transaction_line_definition_list: self.payment_transaction_line_definition_list:
line = cell.newContent(id=line_id, line = cell.newContent(id=line_id,
portal_type='Accounting Transaction Line', quantity=line_ratio, portal_type='Accounting Transaction Line',
source=line_source_id, source=line_source_id,
destination=line_destination_id) destination=line_destination_id)
transaction.commit() transaction.commit()
......
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