Commit 77b6da1f authored by Nicolas Dumazet's avatar Nicolas Dumazet

use xors


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36790 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f91ad7f9
...@@ -385,9 +385,7 @@ class Movement(XMLObject, Amount, CompositionMixin): ...@@ -385,9 +385,7 @@ class Movement(XMLObject, Amount, CompositionMixin):
""" """
result = self.getSourceInventoriatedTotalAssetPrice() result = self.getSourceInventoriatedTotalAssetPrice()
if result is not None : if result is not None :
if result > 0 and not self.isCancellationAmount(): if (result > 0) ^ bool(self.isCancellationAmount()):
return result
if result < 0 and self.isCancellationAmount():
return result return result
return 0.0 return 0.0
...@@ -399,9 +397,7 @@ class Movement(XMLObject, Amount, CompositionMixin): ...@@ -399,9 +397,7 @@ class Movement(XMLObject, Amount, CompositionMixin):
""" """
result = self.getSourceInventoriatedTotalAssetPrice() result = self.getSourceInventoriatedTotalAssetPrice()
if result is not None : if result is not None :
if result < 0 and not self.isCancellationAmount(): if (result < 0) ^ bool(self.isCancellationAmount()):
return -result
if result > 0 and self.isCancellationAmount():
return -result return -result
return 0.0 return 0.0
...@@ -789,9 +785,7 @@ class Movement(XMLObject, Amount, CompositionMixin): ...@@ -789,9 +785,7 @@ class Movement(XMLObject, Amount, CompositionMixin):
quantity = float(quantity) quantity = float(quantity)
except TypeError: except TypeError:
quantity = 0.0 quantity = 0.0
if (quantity < 0 and not self.isCancellationAmount()): if (quantity < 0) ^ bool(self.isCancellationAmount()):
return - quantity
elif quantity > 0 and self.isCancellationAmount():
return - quantity return - quantity
return 0.0 return 0.0
...@@ -806,8 +800,7 @@ class Movement(XMLObject, Amount, CompositionMixin): ...@@ -806,8 +800,7 @@ class Movement(XMLObject, Amount, CompositionMixin):
quantity = float(quantity) quantity = float(quantity)
except TypeError: except TypeError:
quantity = 0.0 quantity = 0.0
if quantity < 0 and not self.isCancellationAmount() \ if (quantity < 0) ^ bool(self.isCancellationAmount()):
or quantity > 0 and self.isCancellationAmount():
return 0.0 return 0.0
return quantity return quantity
...@@ -889,8 +882,7 @@ class Movement(XMLObject, Amount, CompositionMixin): ...@@ -889,8 +882,7 @@ class Movement(XMLObject, Amount, CompositionMixin):
quantity = float(quantity) quantity = float(quantity)
except TypeError: except TypeError:
quantity = 0.0 quantity = 0.0
if quantity < 0 and not self.isCancellationAmount() \ if (quantity < 0) ^ bool(self.isCancellationAmount()):
or quantity > 0 and self.isCancellationAmount():
return 0.0 return 0.0
return quantity return quantity
...@@ -909,9 +901,7 @@ class Movement(XMLObject, Amount, CompositionMixin): ...@@ -909,9 +901,7 @@ class Movement(XMLObject, Amount, CompositionMixin):
quantity = float(quantity) quantity = float(quantity)
except TypeError: except TypeError:
quantity = 0.0 quantity = 0.0
if (quantity < 0 and not self.isCancellationAmount()): if (quantity < 0) ^ bool(self.isCancellationAmount()):
return - quantity
elif quantity > 0 and self.isCancellationAmount():
return - quantity return - quantity
return 0.0 return 0.0
...@@ -930,8 +920,7 @@ class Movement(XMLObject, Amount, CompositionMixin): ...@@ -930,8 +920,7 @@ class Movement(XMLObject, Amount, CompositionMixin):
quantity = float(quantity) quantity = float(quantity)
except TypeError: except TypeError:
quantity = 0.0 quantity = 0.0
if quantity < 0 and not self.isCancellationAmount() \ if (quantity < 0) ^ bool(self.isCancellationAmount()):
or quantity > 0 and self.isCancellationAmount():
return 0.0 return 0.0
return quantity return quantity
...@@ -950,9 +939,7 @@ class Movement(XMLObject, Amount, CompositionMixin): ...@@ -950,9 +939,7 @@ class Movement(XMLObject, Amount, CompositionMixin):
quantity = float(quantity) quantity = float(quantity)
except TypeError: except TypeError:
quantity = 0.0 quantity = 0.0
if (quantity < 0 and not self.isCancellationAmount()): if (quantity < 0) ^ bool(self.isCancellationAmount()):
return - quantity
elif quantity > 0 and self.isCancellationAmount():
return - quantity return - quantity
return 0.0 return 0.0
......
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