pricing/billing - backward compatibility with old sessions
MODIFY
src/integration/pricing/PricingHelper.ts
src/integration/pricing/PricingHelper.ts
@@ -57,10 +57,17 @@ export default class PricingHelper {
};
accumulatedData[dimensionType] = emptyDimensionData;
}
+ let persistedAmount: Decimal;
+ if (Utils.isNullOrUndefined(pricedData[dimensionType].amountAsDecimal)) {
+ // amountAsDecimal is NOT set - let's use the amount instead
+ persistedAmount = Utils.createDecimal(pricedData[dimensionType].amount);
+ } else {
+ // Normal situation - amountAsDecimal is set
+ persistedAmount = Utils.createDecimal(pricedData[dimensionType].amountAsDecimal);
+ }
accumulatedData[dimensionType].quantity = Utils.createDecimal(accumulatedData[dimensionType].quantity).plus(pricedData[dimensionType].quantity).toNumber();
- accumulatedData[dimensionType].amountAsDecimal = Utils.createDecimal(accumulatedData[dimensionType].amountAsDecimal).plus(pricedData[dimensionType].amountAsDecimal);
+ accumulatedData[dimensionType].amountAsDecimal = Utils.createDecimal(accumulatedData[dimensionType].amountAsDecimal).plus(persistedAmount);
accumulatedData[dimensionType].amount = Utils.createDecimal(accumulatedData[dimensionType].amountAsDecimal).toNumber();
- // accumulatedData[dimensionType].roundedAmount = Utils.createDecimal(accumulatedData[dimensionType].roundedAmount).plus(pricedData[dimensionType].roundedAmount).toNumber();
accumulatedData[dimensionType].roundedAmount = Utils.truncTo(accumulatedData[dimensionType].amount, 2);
}
}

pricing/billing - backward compatibility with old sessions