Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marek 3 posts 72 karma points
    Mar 03, 2016 @ 17:06
    Marek
    0

    uCommerece: DivideByZeroException when price is equal to 0

    Hi,

    I would like to report bug in CalculateOrderLineTaxRateTask.

    When price is equal to 0, this task throws DivideByZeroException.

    I have fixed this issue by overriding this task as below, but I hope this will be fixed in following versions.

    public class newCalculateOrderLineTaxRateTask : UCommerce.Pipelines.IPipelineTask<PurchaseOrder>
    {
        public PipelineExecutionResult Execute(PurchaseOrder subject)
        {
            foreach (OrderLine orderLine in (IEnumerable<OrderLine>)subject.OrderLines)
            {
                if (orderLine.Price == 0)
                {
                    orderLine.VATRate = 0;
                }
                else
                {
                    Decimal num = Decimal.Round(orderLine.VAT/orderLine.Price, 4);
                    if (Math.Abs(orderLine.VATRate - num) > new Decimal(5, 0, 0, false, (byte) 3))
                        orderLine.VATRate = num;
                }
            }
            return PipelineExecutionResult.Success;
        }
    }
    

    I'm using uCommere 7.0.0.16029

Please Sign in or register to post replies

Write your reply to:

Draft