From 79a715a681b5ef1cbe3b2856f7cde36de3377344 Mon Sep 17 00:00:00 2001 From: Julian Maurer Date: Fri, 7 Aug 2026 16:55:07 +0200 Subject: [PATCH] Use full precision for GetAg unit work prices --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- src/variables/utils.ts | 31 ++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3006303..09af76c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## 5.7.1 + +### Patch Changes + +- Use full precision for GET AG workprices + +## 5.7.0 + +### Features + +- Support TaxItem (an ad-hoc tax rate with no backing entity) alongside Tax wherever a tax object is accepted or returned, following the @epilot/pricing-client bump that introduced it. Ad-hoc/custom line items with no product or price reference can now be taxed without a full Tax entity. + ## 5.6.9 ### Patch Changes diff --git a/package.json b/package.json index 361f328..1456ade 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@epilot/pricing", - "version": "5.7.0", + "version": "5.7.1", "description": "Pricing Library", "main": "./dist/cjs/index.cjs", "module": "./dist/esm/index.mjs", diff --git a/src/variables/utils.ts b/src/variables/utils.ts index 533b8d9..2a25b9a 100644 --- a/src/variables/utils.ts +++ b/src/variables/utils.ts @@ -314,18 +314,27 @@ const getTieredUnitAmount = ( }; const getGetAgUnitAmount = (item: PriceItem, i18n: I18n, useUnitAmountNet: boolean) => { - const amount = useUnitAmountNet - ? item.unit_amount_net || 0 - : ((item.is_tax_inclusive ?? item._price?.is_tax_inclusive) ? item.unit_amount_gross : item.unit_amount_net) || 0; - - if (!item._price?.is_composite_price) { - return safeFormatAmount({ - amount, - currency: item.currency as any, - locale: i18n.language, - enableSubunitDisplay: true, - }); + if (item._price?.is_composite_price) return; + + let amount; + if (item._price?.get_ag?.type === 'work_price') { + amount = useUnitAmountNet + ? item.unit_amount_net_decimal || '0' + : ((item.is_tax_inclusive ?? item._price?.is_tax_inclusive) + ? item.unit_amount_gross_decimal + : item.unit_amount_net_decimal) || '0'; + } else { + amount = useUnitAmountNet + ? item.unit_amount_net || 0 + : ((item.is_tax_inclusive ?? item._price?.is_tax_inclusive) ? item.unit_amount_gross : item.unit_amount_net) || 0; } + + return safeFormatAmount({ + amount, + currency: item.currency as any, + locale: i18n.language, + enableSubunitDisplay: true, + }); }; export const getSafeAmount = (value: unknown) =>