[Erp5-report] r10091 - in /erp5/trunk/products: ERP5/Document/ ERP5Type/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Sep 18 14:32:40 CEST 2006
Author: jp
Date: Mon Sep 18 14:32:39 2006
New Revision: 10091
URL: http://svn.erp5.org?rev=10091&view=rev
Log:
First generic implementation of precision handling
Modified:
erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py
erp5/trunk/products/ERP5Type/Base.py
Modified: erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py?rev=10091&r1=10090&r2=10091&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py (original)
+++ erp5/trunk/products/ERP5/Document/InvoiceTransactionRule.py Mon Sep 18 14:32:39 2006
@@ -263,6 +263,7 @@
# 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 @@
.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
Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=10091&r1=10090&r2=10091&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py (original)
+++ erp5/trunk/products/ERP5Type/Base.py Mon Sep 18 14:32:39 2006
@@ -2335,12 +2335,33 @@
# 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):
"""
More information about the Erp5-report
mailing list