diff --git a/.changeset/heavy-dolls-run.md b/.changeset/heavy-dolls-run.md new file mode 100644 index 0000000..af96f8d --- /dev/null +++ b/.changeset/heavy-dolls-run.md @@ -0,0 +1,5 @@ +--- +'@epilot/pricing': patch +--- + +Include cashback name in cashback breakdown diff --git a/package.json b/package.json index 7c9c96c..f288c75 100644 --- a/package.json +++ b/package.json @@ -67,13 +67,13 @@ "dinero.js": "^1.9.1" }, "peerDependencies": { - "@epilot/pricing-client": "^3.51.0", + "@epilot/pricing-client": "^3.53.8", "i18next": "^25.1.2" }, "devDependencies": { "@changesets/cli": "^2.30.0", "@epilot/eslint-config": "^3.0.5", - "@epilot/pricing-client": "^3.53.5", + "@epilot/pricing-client": "^3.53.8", "@types/dinero.js": "^1.9.4", "@vitest/coverage-v8": "^1.6.1", "concurrently": "^9.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8c37810..a64fc2a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,8 +19,8 @@ importers: specifier: ^3.0.5 version: 3.0.5(eslint@9.28.0)(typescript@5.8.3) '@epilot/pricing-client': - specifier: ^3.53.5 - version: 3.53.5(axios@1.9.0)(js-yaml@4.1.1) + specifier: ^3.53.8 + version: 3.53.8(axios@1.9.0)(js-yaml@4.1.1) '@types/dinero.js': specifier: ^1.9.4 version: 1.9.4 @@ -163,8 +163,8 @@ packages: eslint: '>= 9.0.0' typescript: '>= 5.0.0' - '@epilot/pricing-client@3.53.5': - resolution: {integrity: sha512-1FGVYx0s5NdOAQOI7tIFYfHlWdxvZC6B6+QgPGQgbZ0sXez5mLR36dERzgXl8gy8Rr7THX7QTw4DuWh2Y3VDcg==} + '@epilot/pricing-client@3.53.8': + resolution: {integrity: sha512-jGJ9TEEi+GR82XGCf+KWcOLKJR6mqoTO53UAro8thPpixCfleFBIFT1MVTtbIJvQ+BcOY96Us8dvQhZHIRXE5A==} peerDependencies: axios: ^1.0.0 || >=0.25.0 <1.0.0 @@ -2743,7 +2743,7 @@ snapshots: - eslint-import-resolver-webpack - supports-color - '@epilot/pricing-client@3.53.5(axios@1.9.0)(js-yaml@4.1.1)': + '@epilot/pricing-client@3.53.8(axios@1.9.0)(js-yaml@4.1.1)': dependencies: '@dazn/lambda-powertools-correlation-ids': 1.28.1 axios: 1.9.0 diff --git a/src/__tests__/fixtures/pricing.results.ts b/src/__tests__/fixtures/pricing.results.ts index 44031f7..e219721 100644 --- a/src/__tests__/fixtures/pricing.results.ts +++ b/src/__tests__/fixtures/pricing.results.ts @@ -8103,6 +8103,7 @@ export const computedPriceWithFixedAmountCashbackCoupon = { { amount_total: 1000, cashback_period: '12', + cashback_name: 'Summer Cashback', }, ], }, @@ -8251,6 +8252,7 @@ export const computedPriceWithFixedAmountCashbackCouponAndPriceMappings = { { cashback_period: '12', amount_total: 2000, + cashback_name: 'Summer Cashback', }, ], }, @@ -8405,6 +8407,7 @@ export const computedPriceWithPercentageCashbackCoupon = { { amount_total: 1000, cashback_period: '12', + cashback_name: 'Summer Cashback', }, ], }, @@ -8553,6 +8556,7 @@ export const computedRecurringPriceWithFixedAmountCashbackCoupon = { { amount_total: 1000, cashback_period: '12', + cashback_name: 'Summer Cashback', }, ], }, @@ -9369,10 +9373,12 @@ export const computedCompositePriceWithComponentsWithCashbacks = { { cashback_period: '12', amount_total: 1000, + cashback_name: 'Summer Cashback', }, { cashback_period: '12', amount_total: 1000, + cashback_name: 'Summer Cashback', }, ], }, @@ -9776,10 +9782,12 @@ export const computedCompositePriceWithComponentsWithCashbacks = { { cashback_period: '12', amount_total: 1000, + cashback_name: 'Summer Cashback', }, { cashback_period: '12', amount_total: 1000, + cashback_name: 'Summer Cashback', }, ], }, diff --git a/src/computations/compute-composite-price-cashbacks.ts b/src/computations/compute-composite-price-cashbacks.ts index 11578fc..f75f16e 100644 --- a/src/computations/compute-composite-price-cashbacks.ts +++ b/src/computations/compute-composite-price-cashbacks.ts @@ -41,6 +41,7 @@ export const computeCompositePriceCashbacks = ( cashbacks.push({ cashback_period: cashbackPeriod, amount_total: cashback_amount, + ...(cashbackCoupon.name && { cashback_name: cashbackCoupon.name }), }); } diff --git a/src/computations/compute-totals.test.ts b/src/computations/compute-totals.test.ts index ebb3550..c70457a 100644 --- a/src/computations/compute-totals.test.ts +++ b/src/computations/compute-totals.test.ts @@ -575,6 +575,7 @@ describe('computeAggregatedAndPriceTotals', () => { { amount_total: 10000, cashback_period: '12', + cashback_name: 'Summer Cashback', }, ]); }); diff --git a/src/computations/compute-totals.ts b/src/computations/compute-totals.ts index 852e6e2..4e20b44 100644 --- a/src/computations/compute-totals.ts +++ b/src/computations/compute-totals.ts @@ -367,6 +367,7 @@ const recomputeDetailTotals = ( cashbacks.push({ cashback_period: cashbackPeriod, amount_total: priceCashBackAmount.getAmount(), + ...(coupon?.name && { cashback_name: coupon.name }), }); }