Try our conversational search powered by Generative AI!

Attempted to divide by zero CalculateDiscountsActivity

Vote:
 

Hello!

After upgrading from Commerce 8.15 to 9.8.1

I do get "Attempted to divide by zero" error on CartPrepair and CartCheckOutWorkflow (ApplyItemDiscount in CalculateDiscountsActivity), The error is when i have a promo 100% of order value. 

This is suppose to be fixed in version 8.2 and it seems that i don't have this problem in version 8.15.

http://world.episerver.com/documentation/Release-Notes/ReleaseNote/?releaseNoteId=118529

Any work around or configuration that i'm missing?

Should i implement my own CalculateDiscountsActivity?

MetaInfo: Some product skus may not have any price at all

Regards

#144903
Feb 22, 2016 14:29
Vote:
 

Hi,

It's unsual to have SKUs without price. I think the problem comes from this (ApplyItemDiscount in CalculateDiscountsActivity):

// Calculate percentage off discount price
if (totalAmount > 0)
{
    percentageOffTotal = record.PromotionReward.AmountOff / totalAmount;
    // but since CostPerEntry is not an adjusted price, we need to take into account additional discounts already applied
    percentageOffTotal = percentageOffTotal * (totalAmount / record.AffectedEntriesSet.TotalCost);
}
else
{
    percentageOffTotal = 100m;
}
 
discountAmount = record.PromotionReward.AmountOff;

In your certain cases record.AffectedEntriesSet.TotalCost can be 0 and cause the problem.

You don't have to implement your own CalculateDiscountsActivity, just download the source code package, build it, debug and the fix it.

Regards,

/Q

#144915
Feb 22, 2016 16:18
Vote:
 

Allright, i integrated Mediachase.Commerce.Workflow into our solution and made some customization. I guess i need to be awaik if Episerver updates this package then...  

#145092
Feb 24, 2016 14:49
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.