diff --git a/package-lock.json b/package-lock.json index f2a043f..df70365 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@epilot/pricing", - "version": "4.20.1", + "version": "4.21.0-0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@epilot/pricing", - "version": "4.20.1", + "version": "4.21.0-0", "license": "UNLICENSED", "dependencies": { - "@epilot/pricing-client": "^3.15.1", + "@epilot/pricing-client": "^3.15.3", "@types/dinero.js": "^1.9.0", "dinero.js": "^1.9.1" }, @@ -64,36 +64,6 @@ "node": ">= 6" } }, - "node_modules/@anttiviljami/json-schema-ref-parser": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/@anttiviljami/json-schema-ref-parser/-/json-schema-ref-parser-9.2.2.tgz", - "integrity": "sha512-YmukqZd3JbZtlna0sS/+YO+17p/AkzLSxuvpQYbBV2f33upbksbKDct6ENmLcV7ZCayTNj+UASGXUJJyrlnaSQ==", - "dependencies": { - "@jsdevtools/ono": "^7.1.3", - "@types/json-schema": "^7.0.6", - "call-me-maybe": "^1.0.1", - "js-yaml": "^4.1.0" - }, - "funding": { - "url": "https://github.com/sponsors/philsturgeon" - } - }, - "node_modules/@anttiviljami/json-schema-ref-parser/node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "node_modules/@anttiviljami/json-schema-ref-parser/node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/@apidevtools/json-schema-ref-parser": { "version": "9.0.9", "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", @@ -825,14 +795,14 @@ } }, "node_modules/@epilot/pricing-client": { - "version": "3.15.1", - "resolved": "https://registry.npmjs.org/@epilot/pricing-client/-/pricing-client-3.15.1.tgz", - "integrity": "sha512-gQUn2dIQZr30s8qo+r/XYBdZP37lJcJavlQ3d5Q6G7M3K5hFAWRhx55VdBYaIjdNoTnxOerwkMQ4NyjoA+BRIQ==", + "version": "3.16.2", + "resolved": "https://registry.npmjs.org/@epilot/pricing-client/-/pricing-client-3.16.2.tgz", + "integrity": "sha512-dL76KUtx5e3GqnfAlykNumn2XXkgkSW6E2ap0uKPNETzg70AW0HN8lTJ/J6eIE/tzyGtCogwfbmWTy+XwKmV6g==", "dependencies": { "@dazn/lambda-powertools-correlation-ids": "^1.28.1", "buffer": "^6.0.3", "https-browserify": "^1.0.0", - "openapi-client-axios": "^6.0.0", + "openapi-client-axios": "^7.1.3", "stream-http": "^3.1.1", "url": "^0.11.0", "util": "^0.12.3" @@ -860,20 +830,19 @@ } }, "node_modules/@epilot/pricing-client/node_modules/openapi-client-axios": { - "version": "6.1.5", - "resolved": "https://registry.npmjs.org/openapi-client-axios/-/openapi-client-axios-6.1.5.tgz", - "integrity": "sha512-QNwB6czTFZZ/DdWmU+Ids64kwjFVN0TAzZFNvs2qlAAnCtGvkUje8rjbvwUv+64eo12QYNuKbtdEPg/hao1yQQ==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/openapi-client-axios/-/openapi-client-axios-7.4.0.tgz", + "integrity": "sha512-qD7LjzKWfs/Rp+9NfFrtzpxVzlJHqau3O0W/wQ8oEzyvhokdJKkq08rzINcElBVuz+KZO+jUOC0zJz8r+IRPyQ==", "dependencies": { - "@anttiviljami/json-schema-ref-parser": "^9.2.2", "bath-es5": "^3.0.3", - "copy-anything": "^3.0.2", - "openapi-types": "^12.0.2" + "dereference-json-schema": "^0.2.1", + "openapi-types": "^12.1.3" }, "funding": { "url": "https://github.com/sponsors/anttiviljami" }, "peerDependencies": { - "axios": "^0.25.0 || ^1.1.3", + "axios": ">=0.25.0", "js-yaml": "^4.1.0" } }, @@ -1249,7 +1218,8 @@ "node_modules/@jsdevtools/ono": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", - "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==", + "dev": true }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", @@ -1455,7 +1425,8 @@ "node_modules/@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", - "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==" + "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", + "dev": true }, "node_modules/@types/json5": { "version": "0.0.29", @@ -2702,7 +2673,8 @@ "node_modules/call-me-maybe": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz", - "integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=" + "integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=", + "dev": true }, "node_modules/callsites": { "version": "3.1.0", @@ -3147,20 +3119,6 @@ "safe-buffer": "~5.1.1" } }, - "node_modules/copy-anything": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-3.0.5.tgz", - "integrity": "sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==", - "dependencies": { - "is-what": "^4.1.8" - }, - "engines": { - "node": ">=12.13" - }, - "funding": { - "url": "https://github.com/sponsors/mesqueeb" - } - }, "node_modules/copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", @@ -3383,8 +3341,7 @@ "node_modules/dereference-json-schema": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/dereference-json-schema/-/dereference-json-schema-0.2.1.tgz", - "integrity": "sha512-uzJsrg225owJyRQ8FNTPHIuBOdSzIZlHhss9u6W8mp7jJldHqGuLv9cULagP/E26QVJDnjtG8U7Dw139mM1ydA==", - "dev": true + "integrity": "sha512-uzJsrg225owJyRQ8FNTPHIuBOdSzIZlHhss9u6W8mp7jJldHqGuLv9cULagP/E26QVJDnjtG8U7Dw139mM1ydA==" }, "node_modules/detect-newline": { "version": "3.1.0", @@ -5877,17 +5834,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-what": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/is-what/-/is-what-4.1.15.tgz", - "integrity": "sha512-uKua1wfy3Yt+YqsD6mTUEa2zSi3G1oPlqTflgaPJ7z63vUGN5pxFpnQfeSLMFnJDEsdvOtkp1rUWkYjB4YfhgA==", - "engines": { - "node": ">=12.13" - }, - "funding": { - "url": "https://github.com/sponsors/mesqueeb" - } - }, "node_modules/is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -11029,32 +10975,6 @@ } } }, - "@anttiviljami/json-schema-ref-parser": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/@anttiviljami/json-schema-ref-parser/-/json-schema-ref-parser-9.2.2.tgz", - "integrity": "sha512-YmukqZd3JbZtlna0sS/+YO+17p/AkzLSxuvpQYbBV2f33upbksbKDct6ENmLcV7ZCayTNj+UASGXUJJyrlnaSQ==", - "requires": { - "@jsdevtools/ono": "^7.1.3", - "@types/json-schema": "^7.0.6", - "call-me-maybe": "^1.0.1", - "js-yaml": "^4.1.0" - }, - "dependencies": { - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "requires": { - "argparse": "^2.0.1" - } - } - } - }, "@apidevtools/json-schema-ref-parser": { "version": "9.0.9", "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", @@ -11611,14 +11531,14 @@ } }, "@epilot/pricing-client": { - "version": "3.15.1", - "resolved": "https://registry.npmjs.org/@epilot/pricing-client/-/pricing-client-3.15.1.tgz", - "integrity": "sha512-gQUn2dIQZr30s8qo+r/XYBdZP37lJcJavlQ3d5Q6G7M3K5hFAWRhx55VdBYaIjdNoTnxOerwkMQ4NyjoA+BRIQ==", + "version": "3.16.2", + "resolved": "https://registry.npmjs.org/@epilot/pricing-client/-/pricing-client-3.16.2.tgz", + "integrity": "sha512-dL76KUtx5e3GqnfAlykNumn2XXkgkSW6E2ap0uKPNETzg70AW0HN8lTJ/J6eIE/tzyGtCogwfbmWTy+XwKmV6g==", "requires": { "@dazn/lambda-powertools-correlation-ids": "^1.28.1", "buffer": "^6.0.3", "https-browserify": "^1.0.0", - "openapi-client-axios": "^6.0.0", + "openapi-client-axios": "^7.1.3", "stream-http": "^3.1.1", "url": "^0.11.0", "util": "^0.12.3" @@ -11640,14 +11560,13 @@ } }, "openapi-client-axios": { - "version": "6.1.5", - "resolved": "https://registry.npmjs.org/openapi-client-axios/-/openapi-client-axios-6.1.5.tgz", - "integrity": "sha512-QNwB6czTFZZ/DdWmU+Ids64kwjFVN0TAzZFNvs2qlAAnCtGvkUje8rjbvwUv+64eo12QYNuKbtdEPg/hao1yQQ==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/openapi-client-axios/-/openapi-client-axios-7.4.0.tgz", + "integrity": "sha512-qD7LjzKWfs/Rp+9NfFrtzpxVzlJHqau3O0W/wQ8oEzyvhokdJKkq08rzINcElBVuz+KZO+jUOC0zJz8r+IRPyQ==", "requires": { - "@anttiviljami/json-schema-ref-parser": "^9.2.2", "bath-es5": "^3.0.3", - "copy-anything": "^3.0.2", - "openapi-types": "^12.0.2" + "dereference-json-schema": "^0.2.1", + "openapi-types": "^12.1.3" } } } @@ -11955,7 +11874,8 @@ "@jsdevtools/ono": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", - "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==", + "dev": true }, "@nodelib/fs.scandir": { "version": "2.1.5", @@ -12149,7 +12069,8 @@ "@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", - "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==" + "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", + "dev": true }, "@types/json5": { "version": "0.0.29", @@ -13067,7 +12988,8 @@ "call-me-maybe": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz", - "integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=" + "integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=", + "dev": true }, "callsites": { "version": "3.1.0", @@ -13410,14 +13332,6 @@ "safe-buffer": "~5.1.1" } }, - "copy-anything": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-3.0.5.tgz", - "integrity": "sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==", - "requires": { - "is-what": "^4.1.8" - } - }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", @@ -13586,8 +13500,7 @@ "dereference-json-schema": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/dereference-json-schema/-/dereference-json-schema-0.2.1.tgz", - "integrity": "sha512-uzJsrg225owJyRQ8FNTPHIuBOdSzIZlHhss9u6W8mp7jJldHqGuLv9cULagP/E26QVJDnjtG8U7Dw139mM1ydA==", - "dev": true + "integrity": "sha512-uzJsrg225owJyRQ8FNTPHIuBOdSzIZlHhss9u6W8mp7jJldHqGuLv9cULagP/E26QVJDnjtG8U7Dw139mM1ydA==" }, "detect-newline": { "version": "3.1.0", @@ -15410,11 +15323,6 @@ "call-bind": "^1.0.2" } }, - "is-what": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/is-what/-/is-what-4.1.15.tgz", - "integrity": "sha512-uKua1wfy3Yt+YqsD6mTUEa2zSi3G1oPlqTflgaPJ7z63vUGN5pxFpnQfeSLMFnJDEsdvOtkp1rUWkYjB4YfhgA==" - }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", diff --git a/package.json b/package.json index aaecd67..1809956 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "author": "epilot GmbH", "license": "UNLICENSED", "dependencies": { - "@epilot/pricing-client": "^3.15.1", + "@epilot/pricing-client": "^3.15.3", "@types/dinero.js": "^1.9.0", "dinero.js": "^1.9.1" }, diff --git a/src/__tests__/fixtures/pricing.results.ts b/src/__tests__/fixtures/pricing.results.ts index b50cf83..11599b5 100644 --- a/src/__tests__/fixtures/pricing.results.ts +++ b/src/__tests__/fixtures/pricing.results.ts @@ -381,6 +381,8 @@ export const resultsWhenNoPricesProvided = { amount_tax: 0, amount_total: 0, unit_amount_gross: 0, + amount_subtotal_decimal: '0', + amount_total_decimal: '0', type: 'one_time', }, ], @@ -755,6 +757,8 @@ export const severalItemsPerRecurrenceTotals = { amount_total: 1114, amount_tax: 100, unit_amount_gross: 1114, + amount_total_decimal: '11.14', + amount_subtotal_decimal: '10.142710120069', }, { type: 'one_time', @@ -762,6 +766,8 @@ export const severalItemsPerRecurrenceTotals = { amount_total: 50000, amount_tax: 7983, unit_amount_gross: 50000, + amount_total_decimal: '500', + amount_subtotal_decimal: '420.168067226891', }, ], }, @@ -1126,6 +1132,8 @@ export const severalItemsPerRecurrenceTotals = { amount_total: 839456, amount_tax: 134031, unit_amount_gross: 207891, + amount_subtotal_decimal: '7054.253987030911', + amount_total_decimal: '8394.56224456678', }, { type: 'recurring', @@ -1134,11 +1142,15 @@ export const severalItemsPerRecurrenceTotals = { amount_total: 4560, amount_tax: 650, unit_amount_gross: 4560, + amount_subtotal_decimal: '39.097520587866', + amount_total_decimal: '45.596224456678', }, { type: 'recurring', billing_period: 'yearly', amount_subtotal: 27274, + amount_subtotal_decimal: '272.737346740068', + amount_total_decimal: '289.101587544474', amount_total: 28910, amount_tax: 1636, unit_amount_gross: 9637, @@ -1408,6 +1420,8 @@ export const compositePricesUnitAmountZeroResult = { unit_amount_gross: 1069, billing_period: 'monthly', type: 'recurring', + amount_total_decimal: '10.69', + amount_subtotal_decimal: '9.718181818182', }, ], taxes: [ @@ -1429,6 +1443,8 @@ export const compositePricesUnitAmountZeroResult = { unit_amount_gross: 1069, billing_period: 'monthly', type: 'recurring', + amount_total_decimal: '10.69', + amount_subtotal_decimal: '9.718181818182', }, ], taxes: [ @@ -1649,6 +1665,8 @@ export const priceWithDisplayOnRequestAndSimplePrices = { amount_tax: 63024, unit_amount_gross: 78946, type: 'one_time', + amount_total_decimal: '3947.28112228339', + amount_subtotal_decimal: '3317.04295990201', }, { amount_subtotal: 2895, @@ -1657,6 +1675,8 @@ export const priceWithDisplayOnRequestAndSimplePrices = { amount_tax: 550, type: 'recurring', unit_amount_gross: 3446, + amount_total_decimal: '34.456224456678', + amount_subtotal_decimal: '28.954810467797', }, { amount_subtotal: 27274, @@ -1665,6 +1685,8 @@ export const priceWithDisplayOnRequestAndSimplePrices = { billing_period: 'yearly', type: 'recurring', unit_amount_gross: 9819, + amount_total_decimal: '294.556334479275', + amount_subtotal_decimal: '272.737346740068', }, ], }, @@ -2251,6 +2273,8 @@ export const compositePriceWithDisplayOnRequestAndOthers = { amount_total: 1114, unit_amount_gross: 1114, amount_tax: 100, + amount_subtotal_decimal: '10.142710120069', + amount_total_decimal: '11.14', }, { type: 'one_time', @@ -2258,6 +2282,8 @@ export const compositePriceWithDisplayOnRequestAndOthers = { amount_total: 50000, unit_amount_gross: 50000, amount_tax: 7983, + amount_subtotal_decimal: '420.168067226891', + amount_total_decimal: '500', }, ], }, @@ -2833,6 +2859,8 @@ export const compositePriceWithDisplayOnRequestAndOthers = { amount_total: 839456, unit_amount_gross: 207891, amount_tax: 134031, + amount_total_decimal: '8394.56224456678', + amount_subtotal_decimal: '7054.253987030911', }, { type: 'recurring', @@ -2841,6 +2869,8 @@ export const compositePriceWithDisplayOnRequestAndOthers = { amount_total: 4560, unit_amount_gross: 4560, amount_tax: 650, + amount_total_decimal: '45.596224456678', + amount_subtotal_decimal: '39.097520587866', }, { type: 'recurring', @@ -2849,6 +2879,8 @@ export const compositePriceWithDisplayOnRequestAndOthers = { amount_total: 28910, unit_amount_gross: 9637, amount_tax: 1636, + amount_total_decimal: '289.101587544474', + amount_subtotal_decimal: '272.737346740068', }, ], }, @@ -3216,6 +3248,8 @@ export const resultCompositePriceQuantity2 = { unit_amount_gross: 1114, billing_period: 'monthly', type: 'recurring', + amount_total_decimal: '22.28', + amount_subtotal_decimal: '20.285420240138', }, { amount_subtotal: 84034, @@ -3223,6 +3257,8 @@ export const resultCompositePriceQuantity2 = { amount_total: 100000, unit_amount_gross: 50000, type: 'one_time', + amount_total_decimal: '1000', + amount_subtotal_decimal: '840.336134453782', }, ], taxes: [ @@ -3245,8 +3281,18 @@ export const resultCompositePriceQuantity2 = { unit_amount_gross: 1114, billing_period: 'monthly', type: 'recurring', + amount_total_decimal: '22.28', + amount_subtotal_decimal: '20.285420240138', + }, + { + amount_subtotal: 84034, + amount_tax: 15966, + amount_total: 100000, + unit_amount_gross: 50000, + type: 'one_time', + amount_total_decimal: '1000', + amount_subtotal_decimal: '840.336134453782', }, - { amount_subtotal: 84034, amount_tax: 15966, amount_total: 100000, unit_amount_gross: 50000, type: 'one_time' }, ], taxes: [ { amount: 194, tax: { _id: '10', rate: 10, type: 'VAT' } }, @@ -3334,6 +3380,8 @@ export const priceDetailsForOnePrice = { amount_total: 394728, unit_amount_gross: 78946, type: 'one_time', + amount_subtotal_decimal: '3317.04295990201', + amount_total_decimal: '3947.28112228339', }, ], taxes: [{ amount: 63024, tax: { _id: '19', rate: 19, type: 'VAT' } }], @@ -3362,8 +3410,18 @@ export const priceDetailsForCompositePrice = { amount_total: 1114, unit_amount_gross: 1114, amount_tax: 100, + amount_subtotal_decimal: '10.142710120069', + amount_total_decimal: '11.14', + }, + { + type: 'one_time', + amount_subtotal: 42017, + amount_total: 50000, + unit_amount_gross: 50000, + amount_tax: 7983, + amount_subtotal_decimal: '420.168067226891', + amount_total_decimal: '500', }, - { type: 'one_time', amount_subtotal: 42017, amount_total: 50000, unit_amount_gross: 50000, amount_tax: 7983 }, ], }, }, @@ -3706,6 +3764,8 @@ export const priceDetailsForCompositePrice = { billing_period: 'monthly', amount_subtotal: 1014, amount_total: 1114, + amount_subtotal_decimal: '10.142710120069', + amount_total_decimal: '11.14', unit_amount_gross: 1114, amount_tax: 100, }, @@ -3715,6 +3775,8 @@ export const priceDetailsForCompositePrice = { amount_total: 50000, unit_amount_gross: 50000, amount_tax: 7983, + amount_total_decimal: '500', + amount_subtotal_decimal: '420.168067226891', }, ], }, @@ -3736,7 +3798,15 @@ export const priceDetailsForCompositePriceWithTaxChanges = { { tax: { _id: '79cac814-18c8-4047-ae45-1d0828598a18', type: 'Custom', rate: 19 }, amount: 3 }, ], recurrences: [ - { type: 'one_time', amount_subtotal: 10, amount_total: 10, unit_amount_gross: 10, amount_tax: 0 }, + { + type: 'one_time', + amount_subtotal: 10, + amount_total: 10, + unit_amount_gross: 10, + amount_tax: 0, + amount_total_decimal: '0.1', + amount_subtotal_decimal: '0.1', + }, { type: 'recurring', billing_period: 'monthly', @@ -3744,6 +3814,8 @@ export const priceDetailsForCompositePriceWithTaxChanges = { amount_total: 20, unit_amount_gross: 20, amount_tax: 3, + amount_subtotal_decimal: '0.168067226891', + amount_total_decimal: '0.2', }, ], }, @@ -3995,7 +4067,15 @@ export const priceDetailsForCompositePriceWithTaxChanges = { { tax: { _id: '79cac814-18c8-4047-ae45-1d0828598a18', type: 'Custom', rate: 19 }, amount: 3 }, ], recurrences: [ - { type: 'one_time', amount_subtotal: 10, amount_total: 10, unit_amount_gross: 10, amount_tax: 0 }, + { + type: 'one_time', + amount_subtotal: 10, + amount_total: 10, + unit_amount_gross: 10, + amount_tax: 0, + amount_total_decimal: '0.1', + amount_subtotal_decimal: '0.1', + }, { type: 'recurring', billing_period: 'monthly', @@ -4003,6 +4083,8 @@ export const priceDetailsForCompositePriceWithTaxChanges = { amount_total: 20, unit_amount_gross: 20, amount_tax: 3, + amount_subtotal_decimal: '0.168067226891', + amount_total_decimal: '0.2', }, ], }, @@ -4351,9 +4433,13 @@ export const resultsWithCompositePrices = { unit_amount_gross: 1114, billing_period: 'monthly', type: 'recurring', + amount_subtotal_decimal: '10.142710120069', + amount_total_decimal: '11.14', }, { amount_subtotal: 42017, + amount_subtotal_decimal: '420.168067226891', + amount_total_decimal: '500', amount_tax: 7983, amount_total: 50000, unit_amount_gross: 50000, @@ -4401,8 +4487,18 @@ export const resultsWithCompositePrices = { unit_amount_gross: 1114, billing_period: 'monthly', type: 'recurring', + amount_subtotal_decimal: '10.142710120069', + amount_total_decimal: '11.14', + }, + { + amount_subtotal: 42017, + amount_tax: 7983, + amount_total: 50000, + unit_amount_gross: 50000, + type: 'one_time', + amount_subtotal_decimal: '420.168067226891', + amount_total_decimal: '500', }, - { amount_subtotal: 42017, amount_tax: 7983, amount_total: 50000, unit_amount_gross: 50000, type: 'one_time' }, ], taxes: [ { amount: 97, tax: { _id: '10', rate: 10, type: 'VAT' } }, @@ -4479,7 +4575,15 @@ export const resultsForSimplePrice = { amount_tax: 12605, breakdown: { recurrences: [ - { amount_subtotal: 66341, amount_tax: 12605, amount_total: 78946, unit_amount_gross: 78946, type: 'one_time' }, + { + amount_subtotal: 66341, + amount_tax: 12605, + amount_total: 78946, + unit_amount_gross: 78946, + type: 'one_time', + amount_subtotal_decimal: '663.408591980402', + amount_total_decimal: '789.456224456678', + }, ], taxes: [{ amount: 12605, tax: { _id: '19', rate: 19, type: 'VAT' } }], }, @@ -4635,10 +4739,12 @@ export const oneItemPerRecurrenceTotals = { recurrences: [ { amount_subtotal: 331704, + amount_subtotal_decimal: '3317.04295990201', amount_total: 394728, amount_tax: 63024, type: 'one_time', unit_amount_gross: 78946, + amount_total_decimal: '3947.28112228339', }, { amount_subtotal: 2895, @@ -4647,6 +4753,8 @@ export const oneItemPerRecurrenceTotals = { amount_tax: 550, type: 'recurring', unit_amount_gross: 3446, + amount_total_decimal: '34.456224456678', + amount_subtotal_decimal: '28.954810467797', }, { amount_subtotal: 27274, @@ -4655,6 +4763,8 @@ export const oneItemPerRecurrenceTotals = { billing_period: 'yearly', type: 'recurring', unit_amount_gross: 9819, + amount_subtotal_decimal: '272.737346740068', + amount_total_decimal: '294.556334479275', }, ], }, @@ -5009,6 +5119,8 @@ export const resultCompositePriceWithTotalDetails = { recurrences: [ { amount_subtotal: 2029, + amount_subtotal_decimal: '20.285420240138', + amount_total_decimal: '22.28', amount_tax: 199, amount_total: 2228, unit_amount_gross: 1114, @@ -5017,6 +5129,8 @@ export const resultCompositePriceWithTotalDetails = { }, { amount_subtotal: 84034, + amount_subtotal_decimal: '840.336134453782', + amount_total_decimal: '1000', amount_tax: 15966, amount_total: 100000, unit_amount_gross: 50000, @@ -5038,13 +5152,23 @@ export const resultCompositePriceWithTotalDetails = { recurrences: [ { amount_subtotal: 2029, + amount_subtotal_decimal: '20.285420240138', + amount_total_decimal: '22.28', amount_tax: 199, amount_total: 2228, unit_amount_gross: 1114, billing_period: 'monthly', type: 'recurring', }, - { amount_subtotal: 84034, amount_tax: 15966, amount_total: 100000, unit_amount_gross: 50000, type: 'one_time' }, + { + amount_subtotal: 84034, + amount_tax: 15966, + amount_total: 100000, + unit_amount_gross: 50000, + type: 'one_time', + amount_subtotal_decimal: '840.336134453782', + amount_total_decimal: '1000', + }, ], taxes: [ { amount: 194, tax: { _id: '10', rate: 10, type: 'VAT' } }, diff --git a/src/pricing.test.ts b/src/pricing.test.ts index 6090cba..2dbeba1 100644 --- a/src/pricing.test.ts +++ b/src/pricing.test.ts @@ -159,6 +159,8 @@ describe('computeAggregatedAndPriceTotals', () => { unit_amount_gross: 5000, type: 'recurring', billing_period: 'yearly', + amount_subtotal_decimal: '45.456224456678', + amount_total_decimal: '50.001846902346', }, ], }), @@ -1359,6 +1361,8 @@ describe('computeAggregatedAndPriceTotals', () => { amount_subtotal: 1800, amount_tax: 0, amount_total: 1800, + amount_total_decimal: '18', + amount_subtotal_decimal: '18', unit_amount_gross: 1800, type: 'one_time', }, diff --git a/src/pricing.ts b/src/pricing.ts index b48a45b..ebe30c0 100644 --- a/src/pricing.ts +++ b/src/pricing.ts @@ -416,6 +416,8 @@ const recomputeDetailTotals = (details: PricingDetails, price: Price, priceItemT unit_amount_gross: priceUnitAmountGross.getAmount(), amount_subtotal: priceSubtotal.getAmount(), amount_total: priceTotal.getAmount(), + amount_subtotal_decimal: priceSubtotal.toUnit().toString(), + amount_total_decimal: priceTotal.toUnit().toString(), amount_tax: priceTax.getAmount(), }); } else { @@ -426,6 +428,8 @@ const recomputeDetailTotals = (details: PricingDetails, price: Price, priceItemT recurrence.unit_amount_gross = unitAmountGrossAmount.add(priceUnitAmountGross).getAmount(); recurrence.amount_subtotal = subTotalAmount.add(priceSubtotal).getAmount(); recurrence.amount_total = totalAmount.add(priceTotal).getAmount(); + recurrence.amount_subtotal_decimal = subTotalAmount.add(priceSubtotal).toUnit().toString(); + recurrence.amount_total_decimal = totalAmount.add(priceTotal).toUnit().toString(); recurrence.amount_tax = taxAmount.add(priceTax).getAmount(); }