Commit 7b63cf51 authored by Jérome Perrin's avatar Jérome Perrin

Support a generate prevision script in the accounting rule cell line (other

changes in erp5_accounting in r21584 are required for this)



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21585 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 688a083d
...@@ -78,7 +78,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -78,7 +78,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
cell = self._getMatchingCell(context_movement) cell = self._getMatchingCell(context_movement)
if cell is not None : # else, we do nothing if cell is not None : # else, we do nothing
for transaction_line in cell.objectValues() : for accounting_rule_cell_line in cell.objectValues() :
# get the resource (in that order): # get the resource (in that order):
# * resource from the invoice (using deliveryValue) # * resource from the invoice (using deliveryValue)
# * price_currency from the invoice # * price_currency from the invoice
...@@ -113,7 +113,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -113,7 +113,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
.getParentValue().getParentValue() .getParentValue().getParentValue()
if resource is None : if resource is None :
# last resort : get the resource from the rule # last resort : get the resource from the rule
resource = transaction_line.getResource() or cell.getResource() resource = accounting_rule_cell_line.getResource() or cell.getResource()
if resource in (None, '') : if resource in (None, '') :
# XXX this happen in many order, so this log is probably useless # XXX this happen in many order, so this log is probably useless
LOG("InvoiceTransactionRule", PROBLEM, LOG("InvoiceTransactionRule", PROBLEM,
...@@ -121,15 +121,15 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -121,15 +121,15 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
# XXX Harcoded list # XXX Harcoded list
prevision_line = { prevision_line = {
'id': transaction_line.getId(), 'id': accounting_rule_cell_line.getId(),
'source': transaction_line.getSource(), 'source': accounting_rule_cell_line.getSource(),
'source_section': context_movement.getSourceSection(), 'source_section': context_movement.getSourceSection(),
'source_decision': context_movement.getSourceDecision(), 'source_decision': context_movement.getSourceDecision(),
'source_administration': context_movement.getSourceAdministration(), 'source_administration': context_movement.getSourceAdministration(),
'source_project': context_movement.getSourceProject(), 'source_project': context_movement.getSourceProject(),
'source_function': context_movement.getSourceFunction(), 'source_function': context_movement.getSourceFunction(),
'source_payment': context_movement.getSourcePayment(), 'source_payment': context_movement.getSourcePayment(),
'destination': transaction_line.getDestination(), 'destination': accounting_rule_cell_line.getDestination(),
'destination_section': context_movement.getDestinationSection(), 'destination_section': context_movement.getDestinationSection(),
'destination_section': context_movement.getDestinationSection(), 'destination_section': context_movement.getDestinationSection(),
'destination_decision': context_movement.getDestinationDecision(), 'destination_decision': context_movement.getDestinationDecision(),
...@@ -141,18 +141,24 @@ class InvoiceTransactionRule(Rule, PredicateMatrix): ...@@ -141,18 +141,24 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
'stop_date': context_movement.getStopDate(), 'stop_date': context_movement.getStopDate(),
'resource': resource, 'resource': resource,
# 'variation_category_list': \ # 'variation_category_list': \
# transaction_line.getVariationCategoryList(), # accounting_rule_cell_line.getVariationCategoryList(),
# 'variation_property_dict': \ # 'variation_property_dict': \
# transaction_line.getVariationPropertyDict(), # accounting_rule_cell_line.getVariationPropertyDict(),
# 'aggregate_list': transaction_line.getAggregateList(), # 'aggregate_list': accounting_rule_cell_line.getAggregateList(),
# 'price': transaction_line.getPrice(), # 'price': accounting_rule_cell_line.getPrice(),
# 'price_currency': transaction_line.getPriceCurrency(), # 'price_currency': accounting_rule_cell_line.getPriceCurrency(),
# calculate (quantity * price) * cell_quantity # calculate (quantity * price) * cell_quantity
'quantity': (context_movement.getCorrectedQuantity() * 'quantity': (context_movement.getCorrectedQuantity() *
context_movement.getPrice(0.0)) * transaction_line.getQuantity(), context_movement.getPrice(0.0)) * accounting_rule_cell_line.getQuantity(),
# 'quantity_unit': transaction_line.getQuantityUnit(), # 'quantity_unit': accounting_rule_cell_line.getQuantityUnit(),
'force_update': 1, 'force_update': 1,
} }
if accounting_rule_cell_line.hasProperty('generate_prevision_script_id'):
generate_prevision_script_id = \
accounting_rule_cell_line.getGeneratePrevisionScriptId()
prevision_line.update(getattr(context_movement,
generate_prevision_script_id)(prevision_line))
prevision_list.append(prevision_line) prevision_list.append(prevision_line)
return prevision_list return prevision_list
......
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
# Jerome Perrin <jerome@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability 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
# garantees 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class AccountingRuleCellLine:
"""Properties for Accounting Rule Cell Lines
"""
_properties = (
{ 'id': 'generate_prevision_script_id',
'description': 'ID of a script used to generate prevision',
'type': 'string',
'mode': 'w',
},
)
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