Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Robert Mulder 79 posts 272 karma points c-trib
    Dec 04, 2014 @ 20:32
    Robert Mulder
    0

    Bug in CalculateOrderLinesUnitDiscountsTask?

    While figuring out how exactly discounts work I did discover something odd.

    In the CalculateOrderLinesUnitDiscountsTask the sum of all order lines that participate in a discount are taken by taking their price times their quantity. Then a few lines later this sum is used to calculate the percentage of the discount should be allocated to each line. At this point however the percentage is calculated by taking the plain Price of the order line (not times the quantity). The dotPeek software makes a mess of the code, so I may be reading it wrong, but to me it seems as though that could go wrong in some situations.

    For example, I have two order lines:

    • Product A - Price 100 - Quantity 2 - Total 200
    • Product B - Price 200 - Quantity 1 - Total 200

    And a discount with AmountOffTotal of 40 that spans both order lines.

    The calculation in CalculateOrderLinesUnitDiscountsTask as I see it does this:

    1. Take the sum of all participating lines: Price x Quantity = (100 x 2) + (200 x 1) = 400
    2. Loop through the lines in the discount
      • First line percentage 100 / 400 = 25% (Price / sum of all lines - this is what I think is a bug)
        • Discount granted to first line: 25% x 40 = 10
      • Second line percentage 200 / 400 = 50%
        • Discount granted to second line: 50% x 40 = 20

    The net result is that there's only a total of 30 applied in discounts.

    Again, I'm working off dotPeek code, so I may be reading it all wrong, but it seems to me like there's a bug in this code. The participation percentage of each line should also use the quantity in the calculation.

Please Sign in or register to post replies

Write your reply to:

Draft