2025 Feb 07 5:42 AM - edited 2025 Feb 07 7:31 AM
hello All,
In context to handling the post order cancellation , returns and refunds on computing the apportion of the promotion amount at line item level , please suggest best practices followed in CCV2 , should it be custom logic completely or any other approach , deinfing refund rules in promotion engine to generate pro-rated discounts ?
Regards,
Nivedita
Request clarification before answering.
Promotion apportioning is not implemented by default in SAP Commerce. If you need to determine the apportioned amount per order entry, you must implement custom logic. Where you place this method execution depends on what you aim to achieve with the implementation.
For example, if you want to display the apportioned amounts in the cart, you can implement CommerceCartCalculationMethodHook. In the beforeCalculate method, you can delete existing promotion-apportioned amount records and then recreate them in the afterCalculate method, ensuring that all promotions are evaluated and calculated.
If you need the apportioned amounts after the order is placed (e.g., to send the information to an ERP or invoicing system for refund amount calculations), you can use CommercePlaceOrderMethodHook. In the afterPlaceOrder method, you can calculate the apportioned amounts accordingly.
Additionally, in calculation of RefundEntry's amount value, the following method is used in DefaultOmsReturnFacade:
protected BigDecimal calculateRefundEntryAmount(final AbstractOrderEntryModel orderEntryModel, final Long expectedQuantity,
final boolean completeReturn)
{
final BigDecimal entryAmount;
if (completeReturn)
{
entryAmount = BigDecimal.valueOf(orderEntryModel.getTotalPrice());
}
else if (CollectionUtils.isEmpty(orderEntryModel.getDiscountValues()))
{
entryAmount = BigDecimal.valueOf(orderEntryModel.getBasePrice() * expectedQuantity);
}
else
{
entryAmount = BigDecimal.ZERO;
}
return entryAmount;
}
So, you need to overwrite this calculation logic for entries with discount (promotion or regular discount). And in the case of order-level discounts refund amount would be calculated wrongly since this code does not take into account a discount applied on order-level.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
16 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.