From 0d8e5a60b6f20bb2d32b5ff1d0976079b6ab6626 Mon Sep 17 00:00:00 2001
From: Jean-Paul Smets <jp@nexedi.com>
Date: Fri, 23 Jan 2004 18:58:14 +0000
Subject: [PATCH] Initial definition of profit and lost quantity

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@307 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/Amount.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/product/ERP5/Document/Amount.py b/product/ERP5/Document/Amount.py
index aceec30fbf..2292f1f09c 100755
--- a/product/ERP5/Document/Amount.py
+++ b/product/ERP5/Document/Amount.py
@@ -119,14 +119,14 @@ class Amount(Base, Variated):
   security.declareProtected(Permissions.AccessContentsInformation,
                                               'getVariationRangeCategoryItemList')
   def getVariationRangeCategoryItemList(self, base_category_list = (),
-                              method_id='getTitle', base=1,  start_with_item=None):
+                              method_id='getTitle', base=1,  current_category=None):
     """
       Returns possible category items for this amount ie.
       the variation of the resource (not the variation range)
     """
     try:
       return self.getDefaultResourceValue().getVariationCategoryItemList(
-             base_category_list, method_id=method_id, base=base, start_with_item=start_with_item)
+             base_category_list, method_id=method_id, base=base, current_category=current_category)
     except:
       # FIXME: method_name vs. method_id, start_with_item vs. start_with_empty, etc. -yo
       return self.portal_categories.getCategoryChildItemList()
@@ -211,12 +211,14 @@ class Amount(Base, Variated):
       Converts target_quantity to default unit
     """
     try:
+    #if 1:
       resource = self.getResourceValue()
       resource_quantity_unit = resource.getDefaultQuantityUnit()
       quantity_unit = self.getQuantityUnit()
       quantity = self.getTargetQuantity()
       converted_quantity = resource.convertQuantity(quantity, quantity_unit, resource_quantity_unit)
     except:
+    #else:
       LOG("ERP5 WARNING:", 100, 'could not convert target_quantity for %s' % self.getRelativeUrl())
       converted_quantity = None
     return converted_quantity
@@ -417,3 +419,14 @@ class Amount(Base, Variated):
       else:
         return 0.0
 
+  # Profit and Loss
+  security.declareProtected(Permissions.ModifyPortalContent, 'getLostQuantity')
+  def getLostQuantity(self):
+    return - self.getProfitQuantity()
+
+  security.declareProtected(Permissions.AccessContentsInformation, 'setLostQuantity')
+  def setLostQuantity(self, value):
+    return self.setProfitQuantity(- value)
+
+  def _setLostQuantity(self, value):
+    return self._setProfitQuantity(- value)
-- 
2.30.9