[FIX] account: return of product with unit price = 0 and fixed tax
Use copysign to take into account the sign of the base amount which includes the sign of the quantity and the sign of the price_unit Amount is the fixed price for the tax, it can be negative Base amount included the sign of the quantity and the sign of the unit price and when a product is returned, it can be done either by changing the sign of quantity or by changing the sign of the price unit. When the price unit is equal to 0, the sign of the quantity is absorbed in base_amount then a "else" case is needed. opw:684459
This commit is contained in:
@@ -615,7 +615,16 @@ class AccountTax(models.Model):
|
||||
if self.amount_type == 'fixed':
|
||||
# Use copysign to take into account the sign of the base amount which includes the sign
|
||||
# of the quantity and the sign of the price_unit
|
||||
return math.copysign(quantity, base_amount) * self.amount
|
||||
# Amount is the fixed price for the tax, it can be negative
|
||||
# Base amount included the sign of the quantity and the sign of the unit price and when
|
||||
# a product is returned, it can be done either by changing the sign of quantity or by changing the
|
||||
# sign of the price unit.
|
||||
# When the price unit is equal to 0, the sign of the quantity is absorbed in base_amount then
|
||||
# a "else" case is needed.
|
||||
if base_amount:
|
||||
return math.copysign(quantity, base_amount) * self.amount
|
||||
else:
|
||||
return quantity * self.amount
|
||||
if (self.amount_type == 'percent' and not self.price_include) or (self.amount_type == 'division' and self.price_include):
|
||||
return base_amount * self.amount / 100
|
||||
if self.amount_type == 'percent' and self.price_include:
|
||||
|
||||
Reference in New Issue
Block a user