[TYPO3-commerce] BUGFIX: priceFromNet feature buggy!

Franz Koch typo.removeformessage at fx-graefix.de
Wed Sep 5 14:05:16 CEST 2007


Hi again,

> I'd like to use only net prices (Netto Preise) as it is a shop for other 
> companies and not for endusers. But it seems that the option 
> 'priceFromNet' is somehow buggy, or the calculation is called in a wrong 
> way, because the total net sum of a article is always calculated back 
> from gross, which leads to a rounding error.
> 
> I tried to debug this - but didn't succeed so far. Maybe one of you 
> noticed the same and already has a solution?

wow - that was a tricky one. The order of the calls was correct and 
sufficient, but the main problem was, that the flag was handled over to 
the basket items in a loop that used copies of the basket items and not 
references. So the copy had the correct settings, but the basket item 
itself didn't know about that.

After fixing this bug, I noticed that the total basket sum was somehow 
calculated wrong (the tax was subtracted from the total sum net instead 
of added). So I went for a little search and found out, that the flag 
'priceFromNet' was used redundant with some overhead:

First calculation for 'priceFromNet' was done in the basket-items.
The second calculation was done in the basket itself, but with items 
that already take the setting into account. So the second calculation 
could be simplified by just calling the appropriate function of the 
basket-item.


Long story short - there are some serious bugs with price-handling and 
the setting 'priceFromNet' which I solved as it seems. But I was not 
able to test it with a more complex shop setup.

The bugs are only in file class.tx_commerce_basic_basket.php which I 
uploaded here [1]. Could somebody please test it and tell me if this is 
working as expected.

[1] http://projects.elements-net.de/typo3/class.tx_commerce_basic_basket.zip

--
Kind regards,
Franz Koch


More information about the TYPO3-project-commerce mailing list