Commit 513b180a authored by Jean-Paul Smets's avatar Jean-Paul Smets

First generic implementation of precision handling

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10091 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8f03a7a6
......@@ -263,6 +263,7 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
# XXX this happen in many order, so this log is probably useless
LOG("InvoiceTransactionRule", PROBLEM,
"expanding %s: without resource" % applied_rule.getPath())
quantity_precision = self.getQuantityPrecisionFromResource(resource)
my_simulation_movement._edit(
source = transaction_line.getSource()
, destination = transaction_line.getDestination()
......@@ -271,9 +272,9 @@ class InvoiceTransactionRule(Rule, PredicateMatrix):
.getDestinationSection()
, resource = resource
# calculate (quantity * price) * cell_quantity
, quantity = (my_invoice_line_simulation.getQuantity()
, quantity = round((my_invoice_line_simulation.getQuantity()
* my_invoice_line_simulation.getPrice())
* transaction_line.getQuantity()
* transaction_line.getQuantity(), quantity_precision)
, start_date = my_invoice_line_simulation.getStartDate()
, stop_date = my_invoice_line_simulation.getStopDate()
, force_update = 1
......
......@@ -2335,12 +2335,33 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property
# Add to catalog
self.reindexObject()
# ZODB Transaction Management
security.declarePublic('serialize')
def serialize(self):
"""Make the transaction accessing to this object atomic
"""
self.id = self.id
# Helpers
def getQuantityPrecisionFromResource(self, resource):
"""
Provides a quick access to precision without accessing the resource
value in ZODB
"""
def cashed_getQuantityPrecisionFromResource(resource):
resource_value = self.portal_categories.resolveCategory(resource)
if resource_value is not None:
return resource_value.getQuantityPrecision()
else:
return 0
cashed_getQuantityPrecisionFromResource = CachingMethod(cashed_getQuantityPrecisionFromResource,
id='Base_getQuantityPrecisionFromResource')
return cashed_getResourceQuantityPrecision(resource)
# Documentation Helpers
security.declareProtected( Permissions.ManagePortal, 'asDocumentationHelper' )
def asDocumentationHelper(self, item_id=None):
"""
......
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