Skip to content

CalculateDiffFromOrderService miscalculates with multiple rate plans

Problem

When an order contains an add product and update product action at the same time the calculation is incorrect because the update product action is misclassified as an add product.

This is because the new_rate_plan? method is based on a list of new rate plan ids. As a result the quantity calculation is wrong because the updated rate plans are not correctly identified and calculated.

In the following example both the add and update product would be considered new rate plans because they share the same rate plan id. image

Link to the MR where this was discovered.

Proposal

Consider the charge_id when determining if a charge is from a new_rate_plan instead of just the rate_plan_id.

Result

When new and updated rate plans are in the same order we calculate the correct quantity change for both.

How will we measure success?

The fix is verified and all previous scenarios continue to work.

OSZAR »