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