I'm working on implementing the Promotions module on an old Commerce 12.17 site. This is going fine, except for one thing...
It was decided a long time ago that the site should not show any decimals on prices (except for tax values), and the decision was made to just cut off all decimals (i.e. round down).
This worked fine, because all prices was integers. BUT the problem now arises when something costs 299 SEK, and there is a 50% discount, the discounted price is 149,50 SEK, which gets rounded up to 150 SEK. I want it to be rounded down instead, to 149 SEK.
I tried creating my own implementations inheriting from DefaultLineItemCalculator and DefaultPlacedPriceProcessor, but the prices are already rounded up when they get to the various methods in them (which I've checked using breakpoints), except for one of the many, many calls to DefaultLineItemCalculator.CalculateDiscountedPrice() where it actually was 149,50, and I could truncate that down to 149 SEK.
Is there a better place to do this? Some interface I'm missing somewhere? Maybe create my own version of the PromotionEngine?
Create your own Promotion. Then can dictate what gets returned when CalculateDiscountedPrice is called.
Hey,I don't have a solution to this problem but we're facing the same difficulties. The client wants whole number discounted prices. Didn't think it was going to be that hard implementing but I couldn't either find any information regarding this. We've implemented custom LineItemCalculators and custom OrderGroupCalculator to be able to use the built in money rounding in .NET, but we're having to much custom logic in my opinon. Also seem to face some edge-case scenarios where tax calculation of rounded prices are giving incorrect taxes. Going to look into creating custom promotions like Surjit suggested. Either way I would vote for having some more information regarding rounding in the documentation :)