Get margin: amount from amount line
This commit is contained in:
parent
0d8eb26e61
commit
0b86ed0ec3
9
sale.py
9
sale.py
|
@ -76,9 +76,7 @@ class SaleLine:
|
||||||
def on_change_with_margin(self):
|
def on_change_with_margin(self):
|
||||||
cost = Decimal(str(self.quantity or '0.0')) * \
|
cost = Decimal(str(self.quantity or '0.0')) * \
|
||||||
(self.cost_price or Decimal('0.0'))
|
(self.cost_price or Decimal('0.0'))
|
||||||
amount = Decimal(str(self.quantity or '0.0')) * \
|
res = Decimal(self.amount-cost)
|
||||||
(self.unit_price or Decimal('0.0'))
|
|
||||||
res = Decimal(amount-cost)
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_margin(self, name):
|
def get_margin(self, name):
|
||||||
|
@ -87,8 +85,7 @@ class SaleLine:
|
||||||
'''
|
'''
|
||||||
Currency = Pool().get('currency.currency')
|
Currency = Pool().get('currency.currency')
|
||||||
if self.type == 'line':
|
if self.type == 'line':
|
||||||
cost = Decimal(str(self.quantity)) * (self.cost_price or Decimal('0.0'))
|
cost = Decimal(str(self.quantity)) * (self.cost_price or Decimal('0.0'))
|
||||||
amount = Decimal(str(self.quantity)) * (self.unit_price)
|
return Currency.round(self.sale.currency, self.amount - cost)
|
||||||
return Currency.round(self.sale.currency, amount - cost)
|
|
||||||
else:
|
else:
|
||||||
return Decimal('0.0')
|
return Decimal('0.0')
|
||||||
|
|
Loading…
Reference in New Issue