Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
31 changes: 20 additions & 11 deletions src/variables/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Loading