Commit ddfd488b authored by Jérome Perrin's avatar Jérome Perrin

Fix source / debit confusion for total asset price.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5566 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a86f64a9
...@@ -250,7 +250,8 @@ class Movement(XMLObject, Amount): ...@@ -250,7 +250,8 @@ class Movement(XMLObject, Amount):
""" """
Get the Total Price in the context. Get the Total Price in the context.
""" """
return self._getTotalPrice(self.asContext(context=context, REQUEST=REQUEST, **kw)) return self._getTotalPrice(self.asContext(context=context,
REQUEST=REQUEST, **kw))
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getTotalQuantity') 'getTotalQuantity')
...@@ -299,7 +300,7 @@ class Movement(XMLObject, Amount): ...@@ -299,7 +300,7 @@ class Movement(XMLObject, Amount):
if quantity : if quantity :
source_asset_price = self.getSourceAssetPrice() source_asset_price = self.getSourceAssetPrice()
if source_asset_price : if source_asset_price :
return source_asset_price * quantity return source_asset_price * - quantity
return None return None
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
...@@ -642,7 +643,8 @@ class Movement(XMLObject, Amount): ...@@ -642,7 +643,8 @@ class Movement(XMLObject, Amount):
Return the debit part of the source total asset price. Return the debit part of the source total asset price.
This is the same as getSourceDebit where quantity is replaced This is the same as getSourceDebit where quantity is replaced
by source_total_asset_price by source_total_asset_price.
This method returns 0 if the total asset price is not set.
""" """
quantity = self.getSourceTotalAssetPrice() quantity = self.getSourceTotalAssetPrice()
try: try:
...@@ -650,9 +652,9 @@ class Movement(XMLObject, Amount): ...@@ -650,9 +652,9 @@ class Movement(XMLObject, Amount):
except TypeError: except TypeError:
quantity = 0.0 quantity = 0.0
if quantity < 0: if quantity < 0:
return - quantity
else:
return 0.0 return 0.0
else:
return quantity
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getSourceAssetCredit' ) 'getSourceAssetCredit' )
...@@ -661,7 +663,8 @@ class Movement(XMLObject, Amount): ...@@ -661,7 +663,8 @@ class Movement(XMLObject, Amount):
Return the credit part of the source total asset price. Return the credit part of the source total asset price.
This is the same as getSourceCredit where quantity is replaced This is the same as getSourceCredit where quantity is replaced
by source_total_asset_price by source_total_asset_price.
This method returns 0 if the total asset price is not set.
""" """
quantity = self.getSourceTotalAssetPrice() quantity = self.getSourceTotalAssetPrice()
try: try:
...@@ -669,9 +672,9 @@ class Movement(XMLObject, Amount): ...@@ -669,9 +672,9 @@ class Movement(XMLObject, Amount):
except TypeError: except TypeError:
quantity = 0.0 quantity = 0.0
if quantity < 0: if quantity < 0:
return 0.0 return - quantity
else: else:
return quantity return 0.0
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getDestinationAssetDebit' ) 'getDestinationAssetDebit' )
...@@ -680,7 +683,8 @@ class Movement(XMLObject, Amount): ...@@ -680,7 +683,8 @@ class Movement(XMLObject, Amount):
Return the debit part of the destination total asset price. Return the debit part of the destination total asset price.
This is the same as getDestinationDebit where quantity is replaced This is the same as getDestinationDebit where quantity is replaced
by destination_total_asset_price by destination_total_asset_price.
This method returns 0 if the total asset price is not set.
""" """
quantity = self.getDestinationTotalAssetPrice() quantity = self.getDestinationTotalAssetPrice()
try: try:
...@@ -688,9 +692,9 @@ class Movement(XMLObject, Amount): ...@@ -688,9 +692,9 @@ class Movement(XMLObject, Amount):
except TypeError: except TypeError:
quantity = 0.0 quantity = 0.0
if quantity < 0: if quantity < 0:
return - quantity
else:
return 0.0 return 0.0
else:
return quantity
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getDestinationAssetCredit' ) 'getDestinationAssetCredit' )
...@@ -699,7 +703,8 @@ class Movement(XMLObject, Amount): ...@@ -699,7 +703,8 @@ class Movement(XMLObject, Amount):
Return the credit part of the destination total asset price. Return the credit part of the destination total asset price.
This is the same as getDestinationCredit where quantity is replaced This is the same as getDestinationCredit where quantity is replaced
by destination_total_asset_price by destination_total_asset_price.
This method returns 0 if the total asset price is not set.
""" """
quantity = self.getDestinationTotalAssetPrice() quantity = self.getDestinationTotalAssetPrice()
try: try:
...@@ -707,46 +712,46 @@ class Movement(XMLObject, Amount): ...@@ -707,46 +712,46 @@ class Movement(XMLObject, Amount):
except TypeError: except TypeError:
quantity = 0.0 quantity = 0.0
if quantity < 0: if quantity < 0:
return 0.0 return -quantity
else: else:
return quantity return 0.0
security.declareProtected( Permissions.ModifyPortalContent, security.declareProtected( Permissions.ModifyPortalContent,
'setSourceAssetDebit' ) 'setSourceAssetDebit' )
def setSourceAssetDebit(self, source_debit): def setSourceAssetDebit(self, source_debit):
""" """
Set the quantity Set the source total asset price
""" """
if source_debit in (None, ''): if source_debit in (None, ''):
return 0.0 return
try: try:
source_debit = float(source_debit) source_debit = float(source_debit)
except TypeError: except TypeError:
source_debit = 0.0 source_debit = 0.0
self.setSourceTotalAssetPrice(- source_debit) self.setSourceTotalAssetPrice(source_debit)
security.declareProtected( Permissions.ModifyPortalContent, security.declareProtected( Permissions.ModifyPortalContent,
'setSourceAssetCredit' ) 'setSourceAssetCredit' )
def setSourceAssetCredit(self, source_credit): def setSourceAssetCredit(self, source_credit):
""" """
Set the quantity Set the source total asset price
""" """
if source_credit in (None, ''): if source_credit in (None, ''):
return 0.0 return
try: try:
source_credit = float(source_credit) source_credit = float(source_credit)
except TypeError: except TypeError:
source_credit = 0.0 source_credit = 0.0
self.setSourceTotalAssetPrice(source_credit) self.setSourceTotalAssetPrice( - source_credit)
security.declareProtected( Permissions.ModifyPortalContent, security.declareProtected( Permissions.ModifyPortalContent,
'setDestinationAssetDebit' ) 'setDestinationAssetDebit' )
def setDestinationAssetDebit(self, destination_debit): def setDestinationAssetDebit(self, destination_debit):
""" """
Set the quantity Set the destination total asset price
""" """
if destination_debit in (None, ''): if destination_debit in (None, ''):
return 0.0 return
try: try:
destination_debit = float(destination_debit) destination_debit = float(destination_debit)
except TypeError: except TypeError:
...@@ -757,18 +762,19 @@ class Movement(XMLObject, Amount): ...@@ -757,18 +762,19 @@ class Movement(XMLObject, Amount):
'setDestinationAssetCredit' ) 'setDestinationAssetCredit' )
def setDestinationAssetCredit(self, destination_credit): def setDestinationAssetCredit(self, destination_credit):
""" """
Set the quantity Set the destination total asset price
""" """
if destination_credit in (None, ''): if destination_credit in (None, ''):
return 0.0 return
try: try:
destination_credit = float(destination_credit) destination_credit = float(destination_credit)
except TypeError: except TypeError:
destination_credit = 0.0 destination_credit = 0.0
self.setDestinationTotalAssetPrice(- destination_credit) self.setDestinationTotalAssetPrice( - destination_credit)
# Item Access (tracking) # Item Access (tracking)
security.declareProtected(Permissions.AccessContentsInformation, 'getTrackedItemUidList') security.declareProtected(Permissions.AccessContentsInformation,
'getTrackedItemUidList')
def getTrackedItemUidList(self): def getTrackedItemUidList(self):
""" """
Return a list of uid for related items Return a list of uid for related items
......
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