From 39d73d3f22ea38ddf6218f140b85bb99620c1bf3 Mon Sep 17 00:00:00 2001 From: Paulo Henriques Date: Thu, 18 Jun 2026 10:45:13 +0100 Subject: [PATCH 1/2] fix: retain raw numeric value for line item unit_amount_net Updated the processOrderTableData function to ensure that the line item unit_amount_net remains a raw numeric value, while the formatted value is still accessible under price.unit_amount_net. Added a corresponding test to verify this behavior. --- src/variables/index.test.ts | 13 +++++++++++++ src/variables/process-order-table-data.ts | 3 +-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/variables/index.test.ts b/src/variables/index.test.ts index 691e1b2..9f32ca3 100644 --- a/src/variables/index.test.ts +++ b/src/variables/index.test.ts @@ -98,6 +98,19 @@ describe('processOrderTableData', () => { expect(result.total_details.recurrences).toEqual(orderWithCompositeItemResults.total_details.recurrences); }); + it('leaves the line item unit_amount_net as a raw numeric value (mirroring unit_amount_gross)', async () => { + const result = await processOrderTableData(orderWithCompositeItem as any, mockI18n); + + const item = result.products[7]; + + // The line item keeps the raw numeric net amount, it is NOT overwritten with a formatted string. + expect(item.unit_amount_net).toBe(65000); + expect(typeof item.unit_amount_net).toBe('number'); + + // The formatted value is still exposed under price.unit_amount_net for templates that render it. + expect(item.price.unit_amount_net).toBe('650,00\xa0€'); + }); + it('returns correctly the tax details', async () => { const result = await processOrderTableData(orderWithMultiplePrices as any, mockI18n); expect(result.total_details.recurrences).toEqual(orderWithMultiplePricesResults.total_details.recurrences); diff --git a/src/variables/process-order-table-data.ts b/src/variables/process-order-table-data.ts index f442937..ffa5897 100644 --- a/src/variables/process-order-table-data.ts +++ b/src/variables/process-order-table-data.ts @@ -406,7 +406,6 @@ export const processOrderTableData = (data: any, i18n: I18n) => { item.total_details.breakdown.recurrences = recurrences; } - item.unit_amount_net = unitAmountNetFormatted; item.unit_amount = unitAmountFormatted; item.amount_subtotal = unitAmountSubtotalFormatted; item.amount_tax = amountTaxFormatted; @@ -450,7 +449,7 @@ export const processOrderTableData = (data: any, i18n: I18n) => { const quantityDisplayValue = !isCoupon ? getQuantity(item, item.parent_item) : undefined; const unitAmountDisplayValue = isUnitAmountApproved ? originalUnitAmountFormatted : item.unit_amount; - const unitAmountNetDisplayValue = isUnitAmountApproved ? originalUnitAmountNetFormatted : item.unit_amount_net; + const unitAmountNetDisplayValue = isUnitAmountApproved ? originalUnitAmountNetFormatted : unitAmountNetFormatted; delete item.parent_item; // build custom variable From 1d27ed49b3b120a6ff25e6c0f4cac5799f13371a Mon Sep 17 00:00:00 2001 From: Paulo Henriques Date: Thu, 18 Jun 2026 10:48:35 +0100 Subject: [PATCH 2/2] Add changeset --- .changeset/thirty-jokes-notice.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/thirty-jokes-notice.md diff --git a/.changeset/thirty-jokes-notice.md b/.changeset/thirty-jokes-notice.md new file mode 100644 index 0000000..312b2ec --- /dev/null +++ b/.changeset/thirty-jokes-notice.md @@ -0,0 +1,5 @@ +--- +'@epilot/pricing': patch +--- + +Updated the processOrderTableData function to ensure that the line item unit_amount_net remains a raw numeric value, while the formatted value is still accessible under price.unit_amount_net.