diff --git a/doc/es/index.rst b/doc/es/index.rst index 29b2f23..cd72c53 100644 --- a/doc/es/index.rst +++ b/doc/es/index.rst @@ -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. -El descuento es la diferencia entre el precio de venta y el precio con la tarifa de venta -que se le aplica. +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 porcentual entre el precio de venta del producto y el precio de venta calculado con la tarifa 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. diff --git a/doc/index.rst b/doc/index.rst index 67e20e7..e9dbbef 100755 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,4 +1,5 @@ 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. diff --git a/sale.py b/sale.py index 8efa20e..4043b97 100644 --- a/sale.py +++ b/sale.py @@ -19,11 +19,13 @@ class SaleLine: gross_unit_price = Product.get_sale_price([self.product], self.quantity or 0)[self.product.id] 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( - Decimal(1) / 10 ** self.__class__.unit_price.digits[1]) - discount = 1 - (res['unit_price'] / - res['gross_unit_price']) - res['discount'] = Decimal("%0.4f" % discount) + Decimal(str(10.0 ** -unit_price_digits))) + discount = 1 - (res['unit_price'] / res['gross_unit_price']) + res['discount'] = discount.quantize( + Decimal(str(10.0 ** -discount_digits))) else: res = super(SaleLine, self).update_prices() return res