Le 03/05/2013 10:37, Florian Henry a écrit :
Hello all,
I'm currently bugs hunting and I try the margin module. I fix some
little thing, but my question is more about usage of "price" column
into llx_facturedet.
In margin module the column llx_facturedet.price is use to
calculated the margin per invoice line. But this column is always
empty, (NULL) since 3.2 as I see.
This column description into
htdocs/install/mysql/table/llx_facturedet.sql we have this comment
price double(24,8), -- P.U. HT apres remise % de ligne (Unit price
afer % discount per line)
I cannot see anywhere line of code that update this column (in 3.3
or in 3.4) Did I miss something ?
So if we have to change it, how do we do that ? put in this column
a relevant information or calculated the margin on total_ht or on
subprice ?
Regards
Yes, the field price is no more update since 3.2.
This is because value inside this field was always wrong due to rounding
rules (qty * price was sometimes not equal to total_ht) and was used
sometimes by some code, this was making calculation wrong.
Reliable field are: qty, total_ht, total_ttc, subprice
I think you should find or be able to make calculation of what margin
module need with this field.
I think (if you need a unit price with a percent discount) you can use:
price2num(total_ht / qty, 'MU') to get value you need. Storing this
value into database is not recommanded as it is a duplicate information
that lead to not coherent data (depending on rounding rule you want,
value will differs).
So it is better to calcucate it dynamically when you need a "Unit price
that include the % discount". But not that you must not multiplicate
this field with qty, result will be wrong, you must use total_xxx field
instead if you need total price on line that include the % discount.