It may be a bug or it's another conception of things.
I can today buy a:
A month after, I can buy this same product x with the same ref y and the same supplier z but with annother price.
Currently it updates the first record and doesn't create another record in product_fournisseur_price
But to have an evolution curve of the purchase price is important to have all the prices in a time interval.
I could be wrong or something else is beyond me!
Good point, I do agree. The history of the purchase price is very important especially if you buy let鈥檚 say 2000 units for 拢10 and sold 1800 then buy another 2000 but this time for 拢6. So now we have 2200 units but 2000 for 拢6 (which gives 拢12000) and 200 for 拢10 (拢2000) so 拢14000 in total (purchase price). At the moment we can see only one price from one supplier of the same product with the same reference. So we can see 2200 units for 拢6 (the total is 拢13200 so 拢800 loss). The history of purchase price would help companies to make sure they are making profit.
There is a PR already to correct this problem. Search supplier history in the repo
@BebZ
Thank you.
I don't understand why it is necessary to go through a second table (log) it may be for compatibility with older versions?
In this case, we will have to add the log records below each Supplier to the purchase price sheet?
or there is another place to consult them?
I dont know. @fappels sould know :) ?!
There are multiple reasons why I did this.
1) log table is already available on older dolibarr version, so with a cherry pick it's easy to implement on older versions.
2) Should need to modify uk_product_fournisseur_price_ref, could lead to regression and needs some deep testing on impact.
3) Not in favor of current sell price system with one table, actual price is defined by date of price.
My PR is still missing a price log table on price card (see FR #10394), for the moment I'm quite busy, maybe other volunteer?
@fappels
Thank u
Hello @wdammak, thanks for trying to improve, but you can not remove composite key (like @eldy confirms). The composite key is the supplier price, if you remove it you have only list of prices. You refer to product sell price, but there the composite key is replaced by some sql which sort prices on date of price. It's not always good practice use other older code as an example for new developments.
By definition a supplier reference is a reference unique for one price at a time.
If at the same time, the product P for supplier S and quantity Q is 10 euros and has also a reference price of 12 euros for same P, same S and same Q, it means it is 2 different references.
Even if the supplier itself does not make difference and call them both P-S-Q, you can call them P-S-Q-10 and P-S-Q-12.
The supplier reference is the reference of the supplier price (it does not means price can't differs for some sells of volume), it just means it is the reference price. So, if there is 2 different "reference price", it is 2 different references. So i close the ticket and recommand to suffix the supplier reference price if you need to store 2 different prices for same P, S and Q at the same time.
Most helpful comment
There is a PR already to correct this problem. Search supplier history in the repo
10395