Commit 3b9c0f3e authored by Jérome Perrin's avatar Jérome Perrin

update rules for use with the DeliveryBuilder API


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3401 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5ce62250
...@@ -121,19 +121,22 @@ class InvoiceRule(Rule): ...@@ -121,19 +121,22 @@ class InvoiceRule(Rule):
new_id = invoice_line_object.getId() + '_' + c.getId() new_id = invoice_line_object.getId() + '_' + c.getId()
#LOG('Create Cell', 0, str(new_id)) #LOG('Create Cell', 0, str(new_id))
applied_rule.newContent(id=new_id applied_rule.newContent(id=new_id
, portal_type=invoice_line_type , portal_type = invoice_line_type
, delivery_value=c , resource = c.price_currency
, deliverable=1 , delivery_value = c
, deliverable = 1
) )
#LOG('After Create Cell', 0, str(new_id)) #LOG('After Create Cell', 0, str(new_id))
else: else:
if invoice_line_object.getUid() not in existing_uid_list: if invoice_line_object.getUid() not in existing_uid_list:
new_id = invoice_line_object.getId() new_id = invoice_line_object.getId()
#LOG('Create Line', 0, str(new_id)) #LOG('Create Line', 0, str(new_id))
applied_rule.newContent(id=new_id applied_rule.newContent(
, portal_type=invoice_line_type id = new_id
, delivery_value=invoice_line_object , portal_type = invoice_line_type
, deliverable=1 , delivery_value = invoice_line_object
, resource = c.price_currency
, deliverable = 1
) )
#LOG('After Create Line', 0, str(new_id)) #LOG('After Create Line', 0, str(new_id))
# Source, Destination, Quantity, Date, etc. are # Source, Destination, Quantity, Date, etc. are
......
...@@ -73,7 +73,7 @@ class InvoiceTransactionRule(Rule, XMLMatrix): ...@@ -73,7 +73,7 @@ class InvoiceTransactionRule(Rule, XMLMatrix):
return cell return cell
return None return None
def _getMatchingCell1(self, movement): def _getMatchingCell_AlternateImpl(self, movement):
""" """
Browse all predicates and make sur all dimensions match Browse all predicates and make sur all dimensions match
An alternate implementation left as example An alternate implementation left as example
...@@ -157,11 +157,12 @@ class InvoiceTransactionRule(Rule, XMLMatrix): ...@@ -157,11 +157,12 @@ class InvoiceTransactionRule(Rule, XMLMatrix):
else : else :
simulation_movement = applied_rule.newContent(id=transaction_line.getId() simulation_movement = applied_rule.newContent(id=transaction_line.getId()
, portal_type=invoice_transaction_line_type) , portal_type=invoice_transaction_line_type)
#LOG('InvoiceTransactionRule.expand :', 0, repr(( 'movement', simulation_movement, transaction_line.getSource(), transaction_line.getDestination(), (my_invoice_line_simulation.getQuantity() * my_invoice_line_simulation.getPrice()) * transaction_line.getQuantity() ))) simulation_movement._edit(
simulation_movement._edit(source = transaction_line.getSource() source = transaction_line.getSource()
, destination = transaction_line.getDestination() , destination = transaction_line.getDestination()
, source_section = my_invoice_line_simulation.getSourceSection() , source_section = my_invoice_line_simulation.getSourceSection()
, destination_section = my_invoice_line_simulation.getDestinationSection() , destination_section = my_invoice_line_simulation.getDestinationSection()
, resource = my_invoice_line_simulation.getResource()
, quantity = (my_invoice_line_simulation.getQuantity() * my_invoice_line_simulation.getPrice()) , quantity = (my_invoice_line_simulation.getQuantity() * my_invoice_line_simulation.getPrice())
* transaction_line.getQuantity() * transaction_line.getQuantity()
# calculate (quantity * price) * cell_quantity # calculate (quantity * price) * cell_quantity
......
...@@ -66,9 +66,10 @@ class PaymentRule(Rule): ...@@ -66,9 +66,10 @@ class PaymentRule(Rule):
""" """
Tests if the rule (still) applies Tests if the rule (still) applies
""" """
if 'receivable' in movement.getId() : if 'receivable' in movement.getId() : ### TODO: expand 'payable' too
parent = movement.getParent() parent = movement.getParent()
if parent.getPortalType()=='Applied Rule' and parent.getSpecialiseId()=='default_invoice_transaction_rule': if parent.getPortalType()=='Applied Rule' \
and parent.getSpecialiseId()=='default_invoice_transaction_rule':
#LOG('PaymentRule.test :', 0, repr(( 'applies with', movement, parent ))) #LOG('PaymentRule.test :', 0, repr(( 'applies with', movement, parent )))
return 1 return 1
return 0 return 0
...@@ -103,7 +104,10 @@ class PaymentRule(Rule): ...@@ -103,7 +104,10 @@ class PaymentRule(Rule):
type_name = payment_line_type, type_name = payment_line_type,
id = receivable_id) id = receivable_id)
# TODO: specify this using a rule in portal_rules
# TODO: generate many movement according to different trade conditions
bank_movement.edit( bank_movement.edit(
resource = my_parent_movement.getResource(),
quantity = my_parent_movement.getQuantity(), quantity = my_parent_movement.getQuantity(),
source = 'account/banques_etablissements_financiers', # XXX Not Generic source = 'account/banques_etablissements_financiers', # XXX Not Generic
destination = 'account/banques_etablissements_financiers', # XXX Not Generic destination = 'account/banques_etablissements_financiers', # XXX Not Generic
...@@ -111,6 +115,7 @@ class PaymentRule(Rule): ...@@ -111,6 +115,7 @@ class PaymentRule(Rule):
destination_section = my_parent_movement.getDestinationSection(), destination_section = my_parent_movement.getDestinationSection(),
) )
receivable_movement.edit( receivable_movement.edit(
resource = my_parent_movement.getResource(),
quantity = - my_parent_movement.getQuantity(), quantity = - my_parent_movement.getQuantity(),
source = 'account/creance_client', # XXX Not Generic source = 'account/creance_client', # XXX Not Generic
destination = 'account/dette_fournisseur', # XXX Not Generic destination = 'account/dette_fournisseur', # XXX Not Generic
......
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