pricing - simple pricing backward compatibility
MODIFY
src/integration/pricing/simple-pricing/BuiltInPricingIntegration.ts
src/integration/pricing/simple-pricing/BuiltInPricingIntegration.ts
@@ -55,9 +55,7 @@ export default class BuiltInPricingIntegration extends PricingIntegration<Simple
};
if (!FeatureToggles.isFeatureActive(Feature.PRICING_NEW_MODEL)) {
- // TODO - Old way of doing it - to be removed
- pricedConsumption.cumulatedAmount = transaction.currentCumulatedPrice ? Utils.createDecimal(transaction.currentCumulatedPrice).plus(amount).toNumber() : amount;
- pricedConsumption.cumulatedRoundedAmount = transaction.currentCumulatedRoundedPrice ? Utils.createDecimal(transaction.currentCumulatedRoundedPrice).plus(roundedAmount).toNumber() : amount;
+ throw new Error('Unexpected situation - this layer should not be called in that context');
} else {
// New logic - get the amount from the priced data to avoid rounding issues
const { cumulatedAmount, cumulatedRoundedAmount } = this.computeCumulatedAmount(pricingModel);

MODIFY
src/integration/pricing/simple-pricing/SimplePricingIntegration.ts
src/integration/pricing/simple-pricing/SimplePricingIntegration.ts
@@ -36,13 +36,15 @@ export default class SimplePricingIntegration extends PricingIntegration<SimpleP
amount = 0;
roundedAmount = 0;
}
+ const cumulatedAmount = Utils.createDecimal(transaction.currentCumulatedPrice).plus(amount).toNumber();
+ const cumulatedRoundedAmount = Utils.truncTo(cumulatedAmount, 2);
const pricedConsumption: PricedConsumption = {
pricingSource: PricingSource.SIMPLE,
- amount: amount,
- roundedAmount: roundedAmount,
currencyCode: this.settings.currency,
- cumulatedAmount: transaction.currentCumulatedPrice ? Utils.createDecimal(transaction.currentCumulatedPrice).plus(amount).toNumber() : amount,
- cumulatedRoundedAmount: transaction.currentCumulatedRoundedPrice ? Utils.createDecimal(transaction.currentCumulatedRoundedPrice).plus(roundedAmount).toNumber() : roundedAmount
+ amount,
+ roundedAmount,
+ cumulatedAmount,
+ cumulatedRoundedAmount
};
return pricedConsumption;
}

MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -351,6 +351,9 @@ class TestData {
assert(billingDataStop?.invoiceNumber === null, `Invoice Number should not yet been set - Invoice Number is: ${billingDataStop?.invoiceNumber}`);
}
if (expectedPrice) {
+ if (!FeatureToggles.isFeatureActive(Feature.PRICING_NEW_MODEL)) {
+ expectedPrice = 32.32; // Expected price when using the Simple Pricing logic!
+ }
// --------------------------------
// Check transaction rounded price
// --------------------------------

pricing - simple pricing backward compatibility