mirror of
https://github.com/NaN-tic/trytond-sale_discount_visible.git
synced 2023-12-14 05:13:13 +01:00
Deal with variable discount digits
This commit is contained in:
parent
de63b7b9d4
commit
22f55a7388
|
@ -1,10 +1,7 @@
|
||||||
==========================================================
|
========================================================================
|
||||||
Ventas. Precio venta y el precio de tarifa en el descuento
|
Ventas. Descuento calculado a partir del precio venta y precio de tarifa
|
||||||
==========================================================
|
========================================================================
|
||||||
|
|
||||||
Permite mostrar el precio de venta (precio venta sin aplicar la tarifa) con un descuento.
|
Permite mostrar la diferencia entre el precio de venta del producto (precio de venta sin aplicar la tarifa) y el precio de venta calculado con la tarifa en forma de descuento.
|
||||||
El descuento es la diferencia entre el precio de venta y el precio con la tarifa de venta
|
El descuento es la diferencia porcentual entre el precio de venta del producto y el precio de venta calculado con la tarifa que se le aplica.
|
||||||
que se le aplica.
|
|
||||||
|
|
||||||
Visualmente el cliente verá el precio que debe pagar pero con el descuento quedará con el precio
|
|
||||||
que se le aplica con la tarifa tanto a pedidos de venta como facturas.
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
Sale Discount Visible Module
|
Sale Discount Visible Module
|
||||||
############################
|
############################
|
||||||
|
|
||||||
Tryton module that allows to show discounts in sale and invoice lines
|
Displays the difference between the sale price of the product (sale price without applying the pricelist) and the sale price calculated by the pricelist as the discount rate.
|
||||||
|
The discount is the percentage difference between the sale price of the product and the sale price calculated by the pricelist applied to it.
|
||||||
|
|
10
sale.py
10
sale.py
|
@ -19,11 +19,13 @@ class SaleLine:
|
||||||
gross_unit_price = Product.get_sale_price([self.product],
|
gross_unit_price = Product.get_sale_price([self.product],
|
||||||
self.quantity or 0)[self.product.id]
|
self.quantity or 0)[self.product.id]
|
||||||
if gross_unit_price:
|
if gross_unit_price:
|
||||||
|
unit_price_digits = self.__class__.gross_unit_price.digits[1]
|
||||||
|
discount_digits = self.__class__.discount.digits[1]
|
||||||
res['gross_unit_price'] = gross_unit_price.quantize(
|
res['gross_unit_price'] = gross_unit_price.quantize(
|
||||||
Decimal(1) / 10 ** self.__class__.unit_price.digits[1])
|
Decimal(str(10.0 ** -unit_price_digits)))
|
||||||
discount = 1 - (res['unit_price'] /
|
discount = 1 - (res['unit_price'] / res['gross_unit_price'])
|
||||||
res['gross_unit_price'])
|
res['discount'] = discount.quantize(
|
||||||
res['discount'] = Decimal("%0.4f" % discount)
|
Decimal(str(10.0 ** -discount_digits)))
|
||||||
else:
|
else:
|
||||||
res = super(SaleLine, self).update_prices()
|
res = super(SaleLine, self).update_prices()
|
||||||
return res
|
return res
|
||||||
|
|
Loading…
Reference in a new issue