Because the standard rounding rule set up under the currencies isn't applied to the salesPrice, only to the LineAmount (It's by design according to Microsoft), I need to force a rounding on the salesPrice via custom.
Microsoft told me to add a priceEvent before the call to the pricing engine on the Retail side:
****
For the POS.
1) Create custom handler with code copied from the out of box pricingservice.
CalculatePricesServiceRequest,
CalculateDiscountsServiceRequest,
2) In the request handler, add line before the call to PricingEngine:
var priceEvents = PE.PricingEngineExtensionRepository.GetPriceEvents();
priceEvents.PrePriceRoundingAdjustments = <a method which has SkipStandardRounding = false>.
****
I cannot see how to accomplish the above.
I decrypted the pricing engine DLL and search for the PrePriceRoundingAdjustment Microsoft suggested I add.
Looking at its signature in the PriceEvents class, I see the following: public event EventHandler<PrePriceRoundingEventArgs> PrePriceRoundingAdjustments;
Looking at the signature of PrePriceRoundingEventArgs, I see the following:
public PrePriceRoundingEventArgs(PriceContext priceContext, SalesLine salesLine)
: base(priceContext, salesLine)
{
this.SkipStandardRounding = true;
}
I'm supposed to set the SkipStandardRounding to FALSE.
Now here my problem starts.
The pricing engine receives a SalesTransaction. This object has a collection of SalesLines. Looking at the signature of the PrePriceRoundingEventArgs, it wants a salesLine and it wants the pricecontext of the pricing engine. How do I give to this priceEvent the arguments it wants when I must add it before the call to the pricing engine. There is something I clearly don't understand regarding the priceEvents.
So, has anybody added a priceEvent and can help me out here please?
I have asked Microsoft for an example because there is nothing in the "RetailSDK\SampleExtensions\CommerceRuntime". But I don't know when I will hear back or if they even have an example. So I thought to ask here as well , because it is a serious problem for our company that the salesPrice is not rounded to 2 decimals.