From e87e3ec21ec94c3b5132426a4dac4a1a50049c2f Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Thu, 29 Dec 2005 11:40:15 +0000 Subject: [PATCH] Extended API for debit and credit asset price git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4914 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/Movement.py | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/product/ERP5/Document/Movement.py b/product/ERP5/Document/Movement.py index 66242ab02e..3ddd39f8bf 100755 --- a/product/ERP5/Document/Movement.py +++ b/product/ERP5/Document/Movement.py @@ -581,6 +581,60 @@ class Movement(XMLObject, Amount): """ return + # Debit and credit methods for asset + security.declareProtected(Permissions.AccessContentsInformation, 'getSourceAssetDebit') + def getSourceAssetDebit(self): + """ + Return the debit part of the source total asset price. + + This is the same as getSourceDebit where quantity is replaced + by source_total_asset_price + """ + quantity = self.getSourceTotalAssetPrice() + try: + quantity = float(quantity) + except TypeError: + quantity = 0.0 + if quantity < 0: + return - quantity + else: + return 0.0 + + security.declareProtected(Permissions.AccessContentsInformation, 'getSourceAssetCredit') + def getSourceAssetCredit(self): + """ + Return + """ + quantity = self.getSourceTotalAssetPrice() + try: + quantity = float(quantity) + except TypeError: + quantity = 0.0 + if quantity < 0: + return 0.0 + else: + return quantity + + # MISSING + # getDestinationAssetDebit getDestinationAssetCredit + + security.declareProtected(Permissions.ModifyPortalContent, 'setSourceAssetDebit') + def setSourceAssetDebit(self, source_debit): + """ + Set the quantity + """ + if source_debit in (None, ''): + return 0.0 + try: + source_debit = float(source_debit) + except TypeError: + source_debit = 0.0 + self.setSourceTotalAssetPrice(- source_debit) + + # MISSING + # setSourceAssetDebit setSourceAssetCredit + # setDestinationAssetDebit setDestinationAssetCredit + # Item Access (tracking) security.declareProtected(Permissions.AccessContentsInformation, 'getTrackedItemUidList') def getTrackedItemUidList(self): -- 2.30.9