Allow discount digits be defined in config file
This commit is contained in:
parent
ea63da6c07
commit
85d29c0d65
|
@ -2,15 +2,14 @@
|
|||
Facturación. Descuentos en las líneas de las facturas
|
||||
=====================================================
|
||||
|
||||
En las líneas de la factura podemos añadir un valor fijo para aplicar un descuento.
|
||||
Permite realizar descuentos en las líneas de la factura.
|
||||
|
||||
El descuento se aplica en el campo "Precio unidad" a partir del descuento y el
|
||||
campo "Precio bruto".
|
||||
A partir del "Descuento" y el "Precio unidad bruto" se calcula el campo "Precio unidad" como:
|
||||
|
||||
Precio = Precio bruto - descuento
|
||||
Precio unidad = Precio unidad bruto * (1 - Descuento)
|
||||
|
||||
Por defecto el número de dígitos del descuento son 4 dígitos. Si desea usar más
|
||||
número de dígitos en el descuento, en el fichero de configuración de trytond,
|
||||
puede definir la variable "unit_price_digits" y el número de dígitos. Por ejemplo:
|
||||
Por defecto el número de decimales del "Precio unidad bruto" y el "Descuento" es 4. El número de decimales del "Precio unidad" es la suma de ambos, por defecto 8.
|
||||
Si desea cambiar el número de decimales del "Precio unidad bruto" y/o el "Descuento", por ejemplo 3 y 2 respectivamente, puede definir las siguientes variables en el fichero de configuración de trytond:
|
||||
|
||||
unit_price_digits = 8
|
||||
unit_price_digits = 3
|
||||
discount_digits = 2
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
Account Invoice Discount Module
|
||||
###############################
|
||||
|
||||
Tryton module to add discounts in lines invoice
|
||||
Tryton module to add discounts on invoice lines.
|
||||
|
||||
Default discount digits is 4 digits. If you like increase number digits,
|
||||
in trytond configuration file you could add new variable "unit_price_digits"
|
||||
and add digits value. For example:
|
||||
From the "Discount" and the "Gross unit price", the "Unit price" field is calculated as:
|
||||
|
||||
unit_price_digits = 8
|
||||
Unit price = Gross unit price * (1 - Discount)
|
||||
|
||||
By default the number of decimal places of "Gross unit price" and "Discount" is 4. The number of decimal places of "Unit Price" is the sum of both, by default 8.
|
||||
To change the number of decimal places of "Gross unit price" and / or "Discount", for example 3 and 2 respectively, you can define the following variables in trytond configuration file:
|
||||
|
||||
unit_price_digits = 3
|
||||
discount_digits = 2
|
||||
|
|
|
@ -4,6 +4,7 @@ from trytond.pool import PoolMeta
|
|||
from trytond.pyson import Eval
|
||||
from trytond.config import CONFIG
|
||||
DIGITS = int(CONFIG.get('unit_price_digits', 4))
|
||||
DISCOUNT_DIGITS = int(CONFIG.get('discount_digits', 4))
|
||||
|
||||
__all__ = ['InvoiceLine']
|
||||
__metaclass__ = PoolMeta
|
||||
|
@ -19,13 +20,14 @@ class InvoiceLine:
|
|||
|
||||
gross_unit_price = fields.Numeric('Gross Price', digits=(16, DIGITS),
|
||||
states=STATES)
|
||||
discount = fields.Numeric('Discount', digits=(16, 4), states=STATES)
|
||||
discount = fields.Numeric('Discount', digits=(16, DISCOUNT_DIGITS),
|
||||
states=STATES)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(InvoiceLine, cls).__setup__()
|
||||
cls.unit_price.states['readonly'] = True
|
||||
cls.unit_price.digits = (20, DIGITS + 4)
|
||||
cls.unit_price.digits = (20, DIGITS + DISCOUNT_DIGITS)
|
||||
if 'discount' not in cls.amount.on_change_with:
|
||||
cls.amount.on_change_with.add('discount')
|
||||
if 'gross_unit_price' not in cls.amount.on_change_with:
|
||||
|
|
Loading…
Reference in New Issue