@ducatjs/money 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE +51 -0
- package/README.md +617 -3
- package/assets/CREDITS.md +12 -0
- package/data/adyen-fx.json +19 -0
- package/data/adyen.json +171 -0
- package/data/braintree.json +223 -0
- package/data/cash-rounding.json +399 -0
- package/data/checkout.json +230 -0
- package/data/iso4217-list-one.xml +1956 -0
- package/data/klarna.json +95 -0
- package/data/paypal.json +65 -0
- package/data/stripe-fx.json +17 -0
- package/data/stripe.json +285 -0
- package/dist/adyen-fx.d.ts +25 -0
- package/dist/adyen-fx.d.ts.map +1 -0
- package/dist/adyen-fx.js +122 -0
- package/dist/adyen-fx.js.map +1 -0
- package/dist/adyen.d.ts +25 -0
- package/dist/adyen.d.ts.map +1 -0
- package/dist/adyen.js +34 -0
- package/dist/adyen.js.map +1 -0
- package/dist/allocate.d.ts +72 -0
- package/dist/allocate.d.ts.map +1 -0
- package/dist/allocate.js +314 -0
- package/dist/allocate.js.map +1 -0
- package/dist/bag.d.ts +58 -0
- package/dist/bag.d.ts.map +1 -0
- package/dist/bag.js +122 -0
- package/dist/bag.js.map +1 -0
- package/dist/braintree.d.ts +34 -0
- package/dist/braintree.d.ts.map +1 -0
- package/dist/braintree.js +45 -0
- package/dist/braintree.js.map +1 -0
- package/dist/cash.d.ts +35 -0
- package/dist/cash.d.ts.map +1 -0
- package/dist/cash.js +86 -0
- package/dist/cash.js.map +1 -0
- package/dist/checkout.d.ts +42 -0
- package/dist/checkout.d.ts.map +1 -0
- package/dist/checkout.js +52 -0
- package/dist/checkout.js.map +1 -0
- package/dist/convert.d.ts +51 -0
- package/dist/convert.d.ts.map +1 -0
- package/dist/convert.js +55 -0
- package/dist/convert.js.map +1 -0
- package/dist/currency.d.ts +22 -0
- package/dist/currency.d.ts.map +1 -0
- package/dist/currency.js +38 -0
- package/dist/currency.js.map +1 -0
- package/dist/decimal.d.ts +52 -0
- package/dist/decimal.d.ts.map +1 -0
- package/dist/decimal.js +251 -0
- package/dist/decimal.js.map +1 -0
- package/dist/ecb.d.ts +17 -0
- package/dist/ecb.d.ts.map +1 -0
- package/dist/ecb.js +147 -0
- package/dist/ecb.js.map +1 -0
- package/dist/exact.d.ts +62 -0
- package/dist/exact.d.ts.map +1 -0
- package/dist/exact.js +147 -0
- package/dist/exact.js.map +1 -0
- package/dist/fetch.d.ts +58 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +79 -0
- package/dist/fetch.js.map +1 -0
- package/dist/fixed.d.ts +121 -0
- package/dist/fixed.d.ts.map +1 -0
- package/dist/fixed.js +420 -0
- package/dist/fixed.js.map +1 -0
- package/dist/fn.d.ts +27 -0
- package/dist/fn.d.ts.map +1 -0
- package/dist/fn.js +30 -0
- package/dist/fn.js.map +1 -0
- package/dist/format.d.ts +13 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +90 -0
- package/dist/format.js.map +1 -0
- package/dist/generated/adyen.d.ts +3 -0
- package/dist/generated/adyen.d.ts.map +1 -0
- package/dist/generated/adyen.js +144 -0
- package/dist/generated/adyen.js.map +1 -0
- package/dist/generated/braintree.d.ts +3 -0
- package/dist/generated/braintree.d.ts.map +1 -0
- package/dist/generated/braintree.js +140 -0
- package/dist/generated/braintree.js.map +1 -0
- package/dist/generated/cash.d.ts +12 -0
- package/dist/generated/cash.d.ts.map +1 -0
- package/dist/generated/cash.js +364 -0
- package/dist/generated/cash.js.map +1 -0
- package/dist/generated/checkout.d.ts +3 -0
- package/dist/generated/checkout.d.ts.map +1 -0
- package/dist/generated/checkout.js +151 -0
- package/dist/generated/checkout.js.map +1 -0
- package/dist/generated/iso4217.d.ts +174 -0
- package/dist/generated/iso4217.d.ts.map +1 -0
- package/dist/generated/iso4217.js +175 -0
- package/dist/generated/iso4217.js.map +1 -0
- package/dist/generated/kernel.d.ts +17 -0
- package/dist/generated/kernel.d.ts.map +1 -0
- package/dist/generated/kernel.js +208 -0
- package/dist/generated/kernel.js.map +1 -0
- package/dist/generated/klarna.d.ts +3 -0
- package/dist/generated/klarna.d.ts.map +1 -0
- package/dist/generated/klarna.js +21 -0
- package/dist/generated/klarna.js.map +1 -0
- package/dist/generated/paypal.d.ts +3 -0
- package/dist/generated/paypal.d.ts.map +1 -0
- package/dist/generated/paypal.js +31 -0
- package/dist/generated/paypal.js.map +1 -0
- package/dist/generated/stripe.d.ts +8 -0
- package/dist/generated/stripe.d.ts.map +1 -0
- package/dist/generated/stripe.js +150 -0
- package/dist/generated/stripe.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/klarna.d.ts +31 -0
- package/dist/klarna.d.ts.map +1 -0
- package/dist/klarna.js +38 -0
- package/dist/klarna.js.map +1 -0
- package/dist/money.d.ts +218 -0
- package/dist/money.d.ts.map +1 -0
- package/dist/money.js +577 -0
- package/dist/money.js.map +1 -0
- package/dist/parse.d.ts +11 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +132 -0
- package/dist/parse.js.map +1 -0
- package/dist/paypal.d.ts +41 -0
- package/dist/paypal.d.ts.map +1 -0
- package/dist/paypal.js +58 -0
- package/dist/paypal.js.map +1 -0
- package/dist/plugins/adyen.d.ts +15 -0
- package/dist/plugins/adyen.d.ts.map +1 -0
- package/dist/plugins/adyen.js +10 -0
- package/dist/plugins/adyen.js.map +1 -0
- package/dist/plugins/all.d.ts +22 -0
- package/dist/plugins/all.d.ts.map +1 -0
- package/dist/plugins/all.js +23 -0
- package/dist/plugins/all.js.map +1 -0
- package/dist/plugins/allocate.d.ts +20 -0
- package/dist/plugins/allocate.d.ts.map +1 -0
- package/dist/plugins/allocate.js +26 -0
- package/dist/plugins/allocate.js.map +1 -0
- package/dist/plugins/braintree.d.ts +12 -0
- package/dist/plugins/braintree.d.ts.map +1 -0
- package/dist/plugins/braintree.js +12 -0
- package/dist/plugins/braintree.js.map +1 -0
- package/dist/plugins/cash.d.ts +19 -0
- package/dist/plugins/cash.d.ts.map +1 -0
- package/dist/plugins/cash.js +16 -0
- package/dist/plugins/cash.js.map +1 -0
- package/dist/plugins/checkout.d.ts +21 -0
- package/dist/plugins/checkout.d.ts.map +1 -0
- package/dist/plugins/checkout.js +16 -0
- package/dist/plugins/checkout.js.map +1 -0
- package/dist/plugins/convert.d.ts +20 -0
- package/dist/plugins/convert.d.ts.map +1 -0
- package/dist/plugins/convert.js +13 -0
- package/dist/plugins/convert.js.map +1 -0
- package/dist/plugins/exact.d.ts +15 -0
- package/dist/plugins/exact.d.ts.map +1 -0
- package/dist/plugins/exact.js +13 -0
- package/dist/plugins/exact.js.map +1 -0
- package/dist/plugins/fixed.d.ts +17 -0
- package/dist/plugins/fixed.d.ts.map +1 -0
- package/dist/plugins/fixed.js +13 -0
- package/dist/plugins/fixed.js.map +1 -0
- package/dist/plugins/format.d.ts +9 -0
- package/dist/plugins/format.d.ts.map +1 -0
- package/dist/plugins/format.js +16 -0
- package/dist/plugins/format.js.map +1 -0
- package/dist/plugins/klarna.d.ts +10 -0
- package/dist/plugins/klarna.d.ts.map +1 -0
- package/dist/plugins/klarna.js +10 -0
- package/dist/plugins/klarna.js.map +1 -0
- package/dist/plugins/paypal.d.ts +14 -0
- package/dist/plugins/paypal.d.ts.map +1 -0
- package/dist/plugins/paypal.js +16 -0
- package/dist/plugins/paypal.js.map +1 -0
- package/dist/plugins/prisma.d.ts +8 -0
- package/dist/plugins/prisma.d.ts.map +1 -0
- package/dist/plugins/prisma.js +13 -0
- package/dist/plugins/prisma.js.map +1 -0
- package/dist/plugins/stripe.d.ts +14 -0
- package/dist/plugins/stripe.d.ts.map +1 -0
- package/dist/plugins/stripe.js +16 -0
- package/dist/plugins/stripe.js.map +1 -0
- package/dist/plugins/tax.d.ts +21 -0
- package/dist/plugins/tax.d.ts.map +1 -0
- package/dist/plugins/tax.js +18 -0
- package/dist/plugins/tax.js.map +1 -0
- package/dist/prisma.d.ts +66 -0
- package/dist/prisma.d.ts.map +1 -0
- package/dist/prisma.js +66 -0
- package/dist/prisma.js.map +1 -0
- package/dist/processor.d.ts +28 -0
- package/dist/processor.d.ts.map +1 -0
- package/dist/processor.js +118 -0
- package/dist/processor.js.map +1 -0
- package/dist/provider.d.ts +89 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +240 -0
- package/dist/provider.js.map +1 -0
- package/dist/rate.d.ts +119 -0
- package/dist/rate.d.ts.map +1 -0
- package/dist/rate.js +271 -0
- package/dist/rate.js.map +1 -0
- package/dist/rounding-error.d.ts +9 -0
- package/dist/rounding-error.d.ts.map +1 -0
- package/dist/rounding-error.js +9 -0
- package/dist/rounding-error.js.map +1 -0
- package/dist/rounding.d.ts +50 -0
- package/dist/rounding.d.ts.map +1 -0
- package/dist/rounding.js +87 -0
- package/dist/rounding.js.map +1 -0
- package/dist/stripe-fx.d.ts +22 -0
- package/dist/stripe-fx.d.ts.map +1 -0
- package/dist/stripe-fx.js +30 -0
- package/dist/stripe-fx.js.map +1 -0
- package/dist/stripe.d.ts +36 -0
- package/dist/stripe.d.ts.map +1 -0
- package/dist/stripe.js +39 -0
- package/dist/stripe.js.map +1 -0
- package/dist/tax.d.ts +29 -0
- package/dist/tax.d.ts.map +1 -0
- package/dist/tax.js +39 -0
- package/dist/tax.js.map +1 -0
- package/package.json +169 -5
- package/src/adyen-fx.ts +154 -0
- package/src/adyen.ts +46 -0
- package/src/allocate.ts +393 -0
- package/src/bag.ts +170 -0
- package/src/braintree.ts +71 -0
- package/src/cash.ts +115 -0
- package/src/checkout.ts +77 -0
- package/src/convert.ts +159 -0
- package/src/currency.ts +61 -0
- package/src/decimal.ts +283 -0
- package/src/ecb.ts +162 -0
- package/src/exact.ts +182 -0
- package/src/fetch.ts +127 -0
- package/src/fixed.ts +558 -0
- package/src/fn.ts +80 -0
- package/src/format.ts +106 -0
- package/src/generated/adyen.ts +144 -0
- package/src/generated/braintree.ts +140 -0
- package/src/generated/cash.ts +375 -0
- package/src/generated/checkout.ts +151 -0
- package/src/generated/iso4217.ts +179 -0
- package/src/generated/kernel.ts +230 -0
- package/src/generated/klarna.ts +21 -0
- package/src/generated/paypal.ts +31 -0
- package/src/generated/stripe.ts +150 -0
- package/src/index.ts +37 -0
- package/src/klarna.ts +54 -0
- package/src/money.ts +781 -0
- package/src/parse.ts +144 -0
- package/src/paypal.ts +93 -0
- package/src/plugins/adyen.ts +25 -0
- package/src/plugins/all.ts +47 -0
- package/src/plugins/allocate.ts +53 -0
- package/src/plugins/braintree.ts +23 -0
- package/src/plugins/cash.ts +33 -0
- package/src/plugins/checkout.ts +32 -0
- package/src/plugins/convert.ts +50 -0
- package/src/plugins/exact.ts +23 -0
- package/src/plugins/fixed.ts +28 -0
- package/src/plugins/format.ts +28 -0
- package/src/plugins/klarna.ts +21 -0
- package/src/plugins/paypal.ts +29 -0
- package/src/plugins/prisma.ts +24 -0
- package/src/plugins/stripe.ts +29 -0
- package/src/plugins/tax.ts +41 -0
- package/src/prisma.ts +118 -0
- package/src/processor.ts +181 -0
- package/src/provider.ts +324 -0
- package/src/rate.ts +377 -0
- package/src/rounding-error.ts +8 -0
- package/src/rounding.ts +122 -0
- package/src/stripe-fx.ts +49 -0
- package/src/stripe.ts +69 -0
- package/src/tax.ts +71 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ducatjs/money/fixed`: exact fixed-point decimals without a currency, on the same engine as
|
|
3
|
+
* Money. Importing this module adds `Money#toFixedPoint()`.
|
|
4
|
+
*/
|
|
5
|
+
import { type Fixed } from '../fixed.js';
|
|
6
|
+
export * from '../fixed.js';
|
|
7
|
+
declare module '../money.js' {
|
|
8
|
+
interface Money<C extends string> {
|
|
9
|
+
/**
|
|
10
|
+
* The exact Fixed of this amount, at its scale: `money('12.34', 'EUR').toFixedPoint()` is
|
|
11
|
+
* 12.34. Not `toFixed`, which Number, decimal.js and big.js all use for `toFixed(places):
|
|
12
|
+
* string`.
|
|
13
|
+
*/
|
|
14
|
+
toFixedPoint(): Fixed;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=fixed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixed.d.ts","sourceRoot":"","sources":["../../src/plugins/fixed.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAGvD,cAAc,aAAa,CAAC;AAE5B,OAAO,QAAQ,aAAa,CAAC;IAC3B,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;QAC9B;;;;WAIG;QACH,YAAY,IAAI,KAAK,CAAC;KACvB;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ducatjs/money/fixed`: exact fixed-point decimals without a currency, on the same engine as
|
|
3
|
+
* Money. Importing this module adds `Money#toFixedPoint()`.
|
|
4
|
+
*/
|
|
5
|
+
import { moneyToFixed } from '../fixed.js';
|
|
6
|
+
import { extendMoney } from '../money.js';
|
|
7
|
+
export * from '../fixed.js';
|
|
8
|
+
extendMoney({
|
|
9
|
+
toFixedPoint() {
|
|
10
|
+
return moneyToFixed(this);
|
|
11
|
+
},
|
|
12
|
+
}, { owner: '@ducatjs/money/fixed' });
|
|
13
|
+
//# sourceMappingURL=fixed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixed.js","sourceRoot":"","sources":["../../src/plugins/fixed.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAc,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AAEtD,cAAc,aAAa,CAAC;AAa5B,WAAW,CACT;IACE,YAAY;QACV,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,EACD,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAClC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from '../format.js';
|
|
2
|
+
declare module '../money.js' {
|
|
3
|
+
interface Money<C extends string> {
|
|
4
|
+
/** Locale formatting via Intl: `price.format('de-DE')` gives "19,99 €" */
|
|
5
|
+
format(locale?: string, options?: Intl.NumberFormatOptions): string;
|
|
6
|
+
formatToParts(locale?: string, options?: Intl.NumberFormatOptions): Intl.NumberFormatPart[];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/plugins/format.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAE7B,OAAO,QAAQ,aAAa,CAAC;IAC3B,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;QAC9B,0EAA0E;QAC1E,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;QACpE,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;KAC7F;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ducatjs/money/format`: locale formatting through Intl. Importing this module adds the methods
|
|
3
|
+
* below.
|
|
4
|
+
*/
|
|
5
|
+
import { format, formatToParts } from '../format.js';
|
|
6
|
+
import { extendMoney } from '../money.js';
|
|
7
|
+
export * from '../format.js';
|
|
8
|
+
extendMoney({
|
|
9
|
+
format(locale, options) {
|
|
10
|
+
return format(this, locale, options);
|
|
11
|
+
},
|
|
12
|
+
formatToParts(locale, options) {
|
|
13
|
+
return formatToParts(this, locale, options);
|
|
14
|
+
},
|
|
15
|
+
}, { owner: '@ducatjs/money/format' });
|
|
16
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/plugins/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AAEtD,cAAc,cAAc,CAAC;AAU7B,WAAW,CACT;IACE,MAAM,CAAc,MAAe,EAAE,OAAkC;QACrE,OAAO,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IACD,aAAa,CAAc,MAAe,EAAE,OAAkC;QAC5E,OAAO,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF,EACD,EAAE,KAAK,EAAE,uBAAuB,EAAE,CACnC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** `@ducatjs/money/klarna`: Klarna's amount view. Importing this module adds `toKlarna`. */
|
|
2
|
+
import { type KlarnaAmountOptions } from '../klarna.js';
|
|
3
|
+
export * from '../klarna.js';
|
|
4
|
+
declare module '../money.js' {
|
|
5
|
+
interface Money<C extends string> {
|
|
6
|
+
/** The integer for any Klarna amount field: `money('25', 'EUR').toKlarna()` is 2500. */
|
|
7
|
+
toKlarna(options?: KlarnaAmountOptions): number;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=klarna.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"klarna.d.ts","sourceRoot":"","sources":["../../src/plugins/klarna.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGlE,cAAc,cAAc,CAAC;AAE7B,OAAO,QAAQ,aAAa,CAAC;IAC3B,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;QAC9B,wFAAwF;QACxF,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;KACjD;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** `@ducatjs/money/klarna`: Klarna's amount view. Importing this module adds `toKlarna`. */
|
|
2
|
+
import { toKlarna } from '../klarna.js';
|
|
3
|
+
import { extendMoney } from '../money.js';
|
|
4
|
+
export * from '../klarna.js';
|
|
5
|
+
extendMoney({
|
|
6
|
+
toKlarna(options) {
|
|
7
|
+
return toKlarna(this, options);
|
|
8
|
+
},
|
|
9
|
+
}, { owner: '@ducatjs/money/klarna' });
|
|
10
|
+
//# sourceMappingURL=klarna.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"klarna.js","sourceRoot":"","sources":["../../src/plugins/klarna.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,OAAO,EAAE,QAAQ,EAA4B,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AAEtD,cAAc,cAAc,CAAC;AAS7B,WAAW,CACT;IACE,QAAQ,CAAc,OAA6B;QACjD,OAAO,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;CACF,EACD,EAAE,KAAK,EAAE,uBAAuB,EAAE,CACnC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PayPalAmountOptions } from '../paypal.js';
|
|
2
|
+
export * from '../paypal.js';
|
|
3
|
+
declare module '../money.js' {
|
|
4
|
+
interface Money<C extends string> {
|
|
5
|
+
/** The exact `value` string for PayPal: `money('1000', 'HUF').toPayPalValue()` is '1000'. */
|
|
6
|
+
toPayPalValue(options?: PayPalAmountOptions): string;
|
|
7
|
+
/** A PayPal `money` object: `{ currency_code, value }`. */
|
|
8
|
+
toPayPal(options?: PayPalAmountOptions): {
|
|
9
|
+
currency_code: string;
|
|
10
|
+
value: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=paypal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paypal.d.ts","sourceRoot":"","sources":["../../src/plugins/paypal.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2B,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEjF,cAAc,cAAc,CAAC;AAE7B,OAAO,QAAQ,aAAa,CAAC;IAC3B,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;QAC9B,6FAA6F;QAC7F,aAAa,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;QACrD,2DAA2D;QAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG;YAAE,aAAa,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;KACnF;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ducatjs/money/paypal`: PayPal's amount view. Importing this module adds `toPayPal` and
|
|
3
|
+
* `toPayPalValue`.
|
|
4
|
+
*/
|
|
5
|
+
import { extendMoney } from '../money.js';
|
|
6
|
+
import { toPayPal, toPayPalValue } from '../paypal.js';
|
|
7
|
+
export * from '../paypal.js';
|
|
8
|
+
extendMoney({
|
|
9
|
+
toPayPalValue(options) {
|
|
10
|
+
return toPayPalValue(this, options);
|
|
11
|
+
},
|
|
12
|
+
toPayPal(options) {
|
|
13
|
+
return toPayPal(this, options);
|
|
14
|
+
},
|
|
15
|
+
}, { owner: '@ducatjs/money/paypal' });
|
|
16
|
+
//# sourceMappingURL=paypal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paypal.js","sourceRoot":"","sources":["../../src/plugins/paypal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAA4B,MAAM,cAAc,CAAC;AAEjF,cAAc,cAAc,CAAC;AAW7B,WAAW,CACT;IACE,aAAa,CAAc,OAA6B;QACtD,OAAO,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IACD,QAAQ,CAAc,OAA6B;QACjD,OAAO,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;CACF,EACD,EAAE,KAAK,EAAE,uBAAuB,EAAE,CACnC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from '../prisma.js';
|
|
2
|
+
declare module '../money.js' {
|
|
3
|
+
interface Money<C extends string> {
|
|
4
|
+
/** A Decimal for a NUMERIC column: `m.toDecimalValue(Prisma.Decimal)`. */
|
|
5
|
+
toDecimalValue<D>(Decimal: new (value: string) => D): D;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=prisma.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/plugins/prisma.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAE7B,OAAO,QAAQ,aAAa,CAAC;IAC3B,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;QAC9B,0EAA0E;QAC1E,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;KACzD;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ducatjs/money/prisma`: Prisma and SQL column helpers. Importing this module adds
|
|
3
|
+
* `toDecimalValue`.
|
|
4
|
+
*/
|
|
5
|
+
import { extendMoney } from '../money.js';
|
|
6
|
+
import { toDecimalValue } from '../prisma.js';
|
|
7
|
+
export * from '../prisma.js';
|
|
8
|
+
extendMoney({
|
|
9
|
+
toDecimalValue(Decimal) {
|
|
10
|
+
return toDecimalValue(this, Decimal);
|
|
11
|
+
},
|
|
12
|
+
}, { owner: '@ducatjs/money/prisma' });
|
|
13
|
+
//# sourceMappingURL=prisma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.js","sourceRoot":"","sources":["../../src/plugins/prisma.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,cAAc,cAAc,CAAC;AAS7B,WAAW,CACT;IACE,cAAc,CAAc,OAAuC;QACjE,OAAO,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;CACF,EACD,EAAE,KAAK,EAAE,uBAAuB,EAAE,CACnC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type StripeAmountOptions } from '../stripe.js';
|
|
2
|
+
export * from '../stripe.js';
|
|
3
|
+
declare module '../money.js' {
|
|
4
|
+
interface Money<C extends string> {
|
|
5
|
+
/** The integer `amount` to send to Stripe: `money('5', 'ISK').toStripeAmount()` is 500. */
|
|
6
|
+
toStripeAmount(options?: StripeAmountOptions): number;
|
|
7
|
+
/** `{ amount, currency }` with Stripe's lowercase currency code, ready for a PaymentIntent. */
|
|
8
|
+
toStripe(options?: StripeAmountOptions): {
|
|
9
|
+
amount: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=stripe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.d.ts","sourceRoot":"","sources":["../../src/plugins/stripe.ts"],"names":[],"mappings":"AAKA,OAAO,EAA4B,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAElF,cAAc,cAAc,CAAC;AAE7B,OAAO,QAAQ,aAAa,CAAC;IAC3B,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;QAC9B,2FAA2F;QAC3F,cAAc,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;QACtD,+FAA+F;QAC/F,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/E;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ducatjs/money/stripe`: Stripe's minor-unit view. Importing this module adds `toStripe` and
|
|
3
|
+
* `toStripeAmount`.
|
|
4
|
+
*/
|
|
5
|
+
import { extendMoney } from '../money.js';
|
|
6
|
+
import { toStripe, toStripeAmount } from '../stripe.js';
|
|
7
|
+
export * from '../stripe.js';
|
|
8
|
+
extendMoney({
|
|
9
|
+
toStripeAmount(options) {
|
|
10
|
+
return toStripeAmount(this, options);
|
|
11
|
+
},
|
|
12
|
+
toStripe(options) {
|
|
13
|
+
return toStripe(this, options);
|
|
14
|
+
},
|
|
15
|
+
}, { owner: '@ducatjs/money/stripe' });
|
|
16
|
+
//# sourceMappingURL=stripe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.js","sourceRoot":"","sources":["../../src/plugins/stripe.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAA4B,MAAM,cAAc,CAAC;AAElF,cAAc,cAAc,CAAC;AAW7B,WAAW,CACT;IACE,cAAc,CAAc,OAA6B;QACvD,OAAO,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IACD,QAAQ,CAAc,OAA6B;QACjD,OAAO,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;CACF,EACD,EAAE,KAAK,EAAE,uBAAuB,EAAE,CACnC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ducatjs/money/tax`: percentages, discounts and tax breakdowns. Importing this module adds the
|
|
3
|
+
* methods below.
|
|
4
|
+
*/
|
|
5
|
+
import type { Factor } from '../decimal.js';
|
|
6
|
+
import type { RoundingMode } from '../rounding.js';
|
|
7
|
+
import { type TaxBreakdown } from '../tax.js';
|
|
8
|
+
export * from '../tax.js';
|
|
9
|
+
declare module '../money.js' {
|
|
10
|
+
interface Money<C extends string> {
|
|
11
|
+
/** `percent`% of this, e.g. `price.percentage(15, 'halfEven')` */
|
|
12
|
+
percentage(percent: Factor, rounding?: RoundingMode): Money<C>;
|
|
13
|
+
/** this minus `percent`% */
|
|
14
|
+
discount(percent: Factor, rounding?: RoundingMode): Money<C>;
|
|
15
|
+
/** Treats this as net: `{ net, tax, gross }`, net + tax = gross exactly. */
|
|
16
|
+
addTax(percent: Factor, rounding?: RoundingMode): TaxBreakdown<C>;
|
|
17
|
+
/** Treats this as gross: `{ net, tax, gross }`, net + tax = gross exactly. */
|
|
18
|
+
extractTax(percent: Factor, rounding?: RoundingMode): TaxBreakdown<C>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=tax.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tax.d.ts","sourceRoot":"","sources":["../../src/plugins/tax.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAA4C,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAExF,cAAc,WAAW,CAAC;AAE1B,OAAO,QAAQ,aAAa,CAAC;IAC3B,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;QAC9B,kEAAkE;QAClE,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/D,4BAA4B;QAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7D,4EAA4E;QAC5E,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAClE,8EAA8E;QAC9E,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;KACvE;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { extendMoney } from '../money.js';
|
|
2
|
+
import { addTax, discount, extractTax, percentage } from '../tax.js';
|
|
3
|
+
export * from '../tax.js';
|
|
4
|
+
extendMoney({
|
|
5
|
+
percentage(percent, rounding) {
|
|
6
|
+
return percentage(this, percent, rounding);
|
|
7
|
+
},
|
|
8
|
+
discount(percent, rounding) {
|
|
9
|
+
return discount(this, percent, rounding);
|
|
10
|
+
},
|
|
11
|
+
addTax(percent, rounding) {
|
|
12
|
+
return addTax(this, percent, rounding);
|
|
13
|
+
},
|
|
14
|
+
extractTax(percent, rounding) {
|
|
15
|
+
return extractTax(this, percent, rounding);
|
|
16
|
+
},
|
|
17
|
+
}, { owner: '@ducatjs/money/tax' });
|
|
18
|
+
//# sourceMappingURL=tax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tax.js","sourceRoot":"","sources":["../../src/plugins/tax.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAc,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAqB,MAAM,WAAW,CAAC;AAExF,cAAc,WAAW,CAAC;AAe1B,WAAW,CACT;IACE,UAAU,CAAc,OAAe,EAAE,QAAuB;QAC9D,OAAO,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,QAAQ,CAAc,OAAe,EAAE,QAAuB;QAC5D,OAAO,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,CAAc,OAAe,EAAE,QAAuB;QAC1D,OAAO,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;IACD,UAAU,CAAc,OAAe,EAAE,QAAuB;QAC9D,OAAO,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;CACF,EACD,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAChC,CAAC"}
|
package/dist/prisma.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prisma / SQL interop with no dependency on @prisma/client (works with any Decimal class that has
|
|
3
|
+
* toFixed(): Prisma.Decimal, decimal.js, big.js).
|
|
4
|
+
*
|
|
5
|
+
* Storage options (see README "Databases"):
|
|
6
|
+
* 1. two columns: amount_minor BIGINT + currency CHAR(3)
|
|
7
|
+
* -> minorMoneyField / toMinorColumns
|
|
8
|
+
* 2. a DECIMAL/NUMERIC column (+ a currency column or constant)
|
|
9
|
+
* -> decimalMoneyField / toDecimalValue
|
|
10
|
+
*/
|
|
11
|
+
import { type CurrencyInput, type Money, type MoneyOptions } from './money.js';
|
|
12
|
+
/** Structural type of Prisma.Decimal / decimal.js / big.js values. */
|
|
13
|
+
export interface DecimalLike {
|
|
14
|
+
toFixed(): string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Money from a Decimal (or decimal string) column. Exact; throws if it has more decimals than the
|
|
18
|
+
* currency.
|
|
19
|
+
*/
|
|
20
|
+
export declare function fromDecimal<C extends CurrencyInput>(value: DecimalLike | string, currency: C, options?: MoneyOptions): Money<C>;
|
|
21
|
+
/** A Decimal for a NUMERIC column: toDecimalValue(m, Prisma.Decimal). */
|
|
22
|
+
export declare function toDecimalValue<D>(money: Money, Decimal: new (value: string) => D): D;
|
|
23
|
+
type Row<A extends string, V> = {
|
|
24
|
+
[P in A]: V;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A Prisma result-extension field that exposes a Money built from `amount_minor` + `currency`
|
|
28
|
+
* columns:
|
|
29
|
+
*
|
|
30
|
+
* const db = new PrismaClient().$extends({
|
|
31
|
+
* result: { order: { total: minorMoneyField('totalMinor', 'currency') } },
|
|
32
|
+
* });
|
|
33
|
+
* (await db.order.findFirstOrThrow()).total // Money
|
|
34
|
+
*/
|
|
35
|
+
export declare function minorMoneyField<const A extends string, const K extends string>(amount: A, currency: K): {
|
|
36
|
+
needs: { [P in A | K]: true; };
|
|
37
|
+
compute: (row: Row<A, bigint | number> & Row<K, string>) => Money;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* A Prisma result-extension field for a Decimal column, with the currency taken from another column
|
|
41
|
+
* (`{ currencyField: 'currency' }`) or fixed (`{ currency: 'EUR' }`).
|
|
42
|
+
*/
|
|
43
|
+
export declare function decimalMoneyField<const A extends string, const K extends string>(amount: A, currency: {
|
|
44
|
+
currencyField: K;
|
|
45
|
+
}): {
|
|
46
|
+
needs: {
|
|
47
|
+
[P in A | K]: true;
|
|
48
|
+
};
|
|
49
|
+
compute: (row: Row<A, DecimalLike> & Row<K, string>) => Money;
|
|
50
|
+
};
|
|
51
|
+
export declare function decimalMoneyField<const A extends string, const C extends CurrencyInput>(amount: A, currency: {
|
|
52
|
+
currency: C;
|
|
53
|
+
}): {
|
|
54
|
+
needs: {
|
|
55
|
+
[P in A]: true;
|
|
56
|
+
};
|
|
57
|
+
compute: (row: Row<A, DecimalLike>) => Money<C>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Column values for writes: `data: { ...toMinorColumns(total, 'totalMinor', 'currency') }`.
|
|
61
|
+
* Minor units are a bigint (Prisma BigInt). Throws if the value has a non-standard scale, because
|
|
62
|
+
* the column cannot record it.
|
|
63
|
+
*/
|
|
64
|
+
export declare function toMinorColumns<const A extends string, const K extends string>(money: Money, amount: A, currency: K): Row<A, bigint> & Row<K, string>;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=prisma.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../src/prisma.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAEpB,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC1B,OAAO,IAAI,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,aAAa,EACjD,KAAK,EAAE,WAAW,GAAG,MAAM,EAC3B,QAAQ,EAAE,CAAC,EACX,OAAO,CAAC,EAAE,YAAY,GACrB,KAAK,CAAC,CAAC,CAAC,CAEV;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,CAEpF;AAED,KAAK,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI;KAAG,CAAC,IAAI,CAAC,GAAG,CAAC;CAAE,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,MAAM,EAC5E,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC;WAGsC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,GAAE;mBACtD,GAAG,CAAC,CAAC,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QL interop with no dependency on @prisma/client (works with any Decimal class that has
|
|
3
|
+
* toFixed(): Prisma.Decimal, decimal.js, big.js).
|
|
4
|
+
*
|
|
5
|
+
* Storage options (see README "Databases"):
|
|
6
|
+
* 1. two columns: amount_minor BIGINT + currency CHAR(3)
|
|
7
|
+
* -> minorMoneyField / toMinorColumns
|
|
8
|
+
* 2. a DECIMAL/NUMERIC column (+ a currency column or constant)
|
|
9
|
+
* -> decimalMoneyField / toDecimalValue
|
|
10
|
+
*/
|
|
11
|
+
import { fromMinor, money, toDecimal, toMinor, } from './money.js';
|
|
12
|
+
/**
|
|
13
|
+
* Money from a Decimal (or decimal string) column. Exact; throws if it has more decimals than the
|
|
14
|
+
* currency.
|
|
15
|
+
*/
|
|
16
|
+
export function fromDecimal(value, currency, options) {
|
|
17
|
+
return money(typeof value === 'string' ? value : value.toFixed(), currency, options);
|
|
18
|
+
}
|
|
19
|
+
/** A Decimal for a NUMERIC column: toDecimalValue(m, Prisma.Decimal). */
|
|
20
|
+
export function toDecimalValue(money, Decimal) {
|
|
21
|
+
return new Decimal(toDecimal(money));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A Prisma result-extension field that exposes a Money built from `amount_minor` + `currency`
|
|
25
|
+
* columns:
|
|
26
|
+
*
|
|
27
|
+
* const db = new PrismaClient().$extends({
|
|
28
|
+
* result: { order: { total: minorMoneyField('totalMinor', 'currency') } },
|
|
29
|
+
* });
|
|
30
|
+
* (await db.order.findFirstOrThrow()).total // Money
|
|
31
|
+
*/
|
|
32
|
+
export function minorMoneyField(amount, currency) {
|
|
33
|
+
return {
|
|
34
|
+
needs: { [amount]: true, [currency]: true },
|
|
35
|
+
compute: (row) => fromMinor(row[amount], row[currency]),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
export function decimalMoneyField(amount, currencySource) {
|
|
40
|
+
if ('currencyField' in currencySource) {
|
|
41
|
+
return {
|
|
42
|
+
needs: { [amount]: true, [currencySource.currencyField]: true },
|
|
43
|
+
compute: (row) => fromDecimal(row[amount], row[currencySource.currencyField]),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
needs: { [amount]: true },
|
|
48
|
+
compute: (row) => fromDecimal(row[amount], currencySource.currency),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Column values for writes: `data: { ...toMinorColumns(total, 'totalMinor', 'currency') }`.
|
|
53
|
+
* Minor units are a bigint (Prisma BigInt). Throws if the value has a non-standard scale, because
|
|
54
|
+
* the column cannot record it.
|
|
55
|
+
*/
|
|
56
|
+
export function toMinorColumns(money, amount, currency) {
|
|
57
|
+
return { [amount]: toMinorAtIsoScale(money), [currency]: money.currency };
|
|
58
|
+
}
|
|
59
|
+
function toMinorAtIsoScale(money) {
|
|
60
|
+
const iso = fromMinor(0, money.currency).scale;
|
|
61
|
+
if (money.scale !== iso) {
|
|
62
|
+
throw new RangeError(`${money} has scale ${money.scale}; round() it to ${iso} decimals before storing minor units`);
|
|
63
|
+
}
|
|
64
|
+
return toMinor(money);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=prisma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.js","sourceRoot":"","sources":["../src/prisma.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,OAAO,GAIR,MAAM,YAAY,CAAC;AAOpB;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,KAA2B,EAC3B,QAAW,EACX,OAAsB;IAEtB,OAAO,KAAK,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACvF,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,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,CAAC;AACnB,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAY;IACrC,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;IAC/C,IAAI,KAAK,CAAC,KAAK,KAAK,GAAG,EAAE,CAAC;QACxB,MAAM,IAAI,UAAU,CAClB,GAAG,KAAK,cAAc,KAAK,CAAC,KAAK,mBAAmB,GAAG,sCAAsC,CAC9F,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type CurrencyInput, type Money } from './money.js';
|
|
2
|
+
import { type RoundingMode } from './rounding.js';
|
|
3
|
+
/**
|
|
4
|
+
* Which signs a processor field accepts, checked after rounding:
|
|
5
|
+
* - 'any': negative amounts are documented (Klarna's discount order lines);
|
|
6
|
+
* - 'nonNegative': zero is documented but negatives aren't (refunds are sent as positive amounts);
|
|
7
|
+
* - 'positive': the processor rejects zero too (Braintree's transaction amount).
|
|
8
|
+
*/
|
|
9
|
+
export type SignRule = 'any' | 'nonNegative' | 'positive';
|
|
10
|
+
/**
|
|
11
|
+
* @internal Money -> a processor's integer amount at the processor's exponent.
|
|
12
|
+
* Throws a RangeError when the amount doesn't fit in a safe integer or has a sign `sign` rules out.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toProcessorAmount(processor: string, money: Money, exponent: number, multiple: number, rounding: RoundingMode, sign?: SignRule): number;
|
|
15
|
+
/**
|
|
16
|
+
* @internal Money -> a processor's decimal string with exactly `exponent` decimals
|
|
17
|
+
* ("10.00", or "1000" for JPY), built from the integer so it never goes through a float.
|
|
18
|
+
*/
|
|
19
|
+
export declare function toProcessorDecimal(processor: string, money: Money, exponent: number, rounding: RoundingMode, sign?: SignRule): string;
|
|
20
|
+
/** @internal A processor's integer amount -> Money (see `toIsoScaleWhenExact` for the scale). */
|
|
21
|
+
export declare function fromProcessorAmount<C extends CurrencyInput>(processor: string, amount: number | bigint, currency: C, exponent: number): Money<C>;
|
|
22
|
+
/**
|
|
23
|
+
* @internal A processor's decimal string -> Money, exactly (never via a float). `pattern` is the
|
|
24
|
+
* processor's documented format and `maxLength` its length limit, if any. The scale follows
|
|
25
|
+
* `toIsoScaleWhenExact`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fromProcessorDecimal<C extends CurrencyInput>(processor: string, value: string, currency: C, pattern: RegExp, maxLength?: number): Money<C>;
|
|
28
|
+
//# sourceMappingURL=processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../src/processor.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0C,KAAK,aAAa,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AACpG,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,aAAa,GAAG,UAAU,CAAC;AAuE1D;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,YAAY,EACtB,IAAI,GAAE,QAAgB,GACrB,MAAM,CASR;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,YAAY,EACtB,IAAI,GAAE,QAAgB,GACrB,MAAM,CAMR;AAmBD,iGAAiG;AACjG,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,aAAa,EACzD,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,QAAQ,EAAE,CAAC,EACX,QAAQ,EAAE,MAAM,GACf,KAAK,CAAC,CAAC,CAAC,CAMV;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,aAAa,EAC1D,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,MAAM,EACf,SAAS,SAAW,GACnB,KAAK,CAAC,CAAC,CAAC,CAWV"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { currencyExponent } from './currency.js';
|
|
2
|
+
import { formatScaled, parseDecimal, parsePlainDecimal, normalizeMinor } from './decimal.js';
|
|
3
|
+
import { fromMinor, scaleDown, scaleUp, toScale } from './money.js';
|
|
4
|
+
import { divideAndRound, divideAndRoundBigint, RoundingError, } from './rounding.js';
|
|
5
|
+
/**
|
|
6
|
+
* Rescales Money's minor units to a processor's exponent, then to a multiple of `multiple` minor
|
|
7
|
+
* units (Checkout.com's CLP, Stripe's ISK). Throws a RoundingError naming the processor when
|
|
8
|
+
* precision would be lost and `rounding` is 'unnecessary'.
|
|
9
|
+
*/
|
|
10
|
+
function rescaleForProcessor(processor, money, exponent, multiple, rounding) {
|
|
11
|
+
// Going up in scale is always exact; going down (e.g. IDR on Adyen) may need rounding.
|
|
12
|
+
let minor;
|
|
13
|
+
try {
|
|
14
|
+
if (exponent >= money.scale) {
|
|
15
|
+
minor = scaleUp(money.minor, exponent - money.scale);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
minor = scaleDown(money.minor, money.scale - exponent, rounding);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error instanceof RoundingError) {
|
|
23
|
+
throw new RoundingError(`${money} has more precision than ${processor} accepts for ${money.currency} ` +
|
|
24
|
+
`(${exponent} decimals); pass a rounding mode`);
|
|
25
|
+
}
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
if (multiple === 1) {
|
|
29
|
+
return minor;
|
|
30
|
+
}
|
|
31
|
+
const isMultiple = typeof minor === 'number' ? minor % multiple === 0 : minor % BigInt(multiple) === 0n;
|
|
32
|
+
if (isMultiple) {
|
|
33
|
+
return minor;
|
|
34
|
+
}
|
|
35
|
+
if (rounding === 'unnecessary') {
|
|
36
|
+
throw new RoundingError(`${processor} requires ${money.currency} amounts to be a multiple of ${multiple} minor units; ` +
|
|
37
|
+
`${money} is not (pass a rounding mode)`);
|
|
38
|
+
}
|
|
39
|
+
if (typeof minor === 'number') {
|
|
40
|
+
return divideAndRound(minor, multiple, rounding) * multiple;
|
|
41
|
+
}
|
|
42
|
+
const bigMultiple = BigInt(multiple);
|
|
43
|
+
return normalizeMinor(divideAndRoundBigint(minor, bigMultiple, rounding) * bigMultiple);
|
|
44
|
+
}
|
|
45
|
+
/** Throws a RangeError when the rounded amount has a sign the processor doesn't accept. */
|
|
46
|
+
function checkSign(processor, money, minor, sign) {
|
|
47
|
+
// Checked on the rounded amount, so -0.004 USD rounded to 0 counts as zero, not as negative.
|
|
48
|
+
if (sign === 'any') {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (minor < 0) {
|
|
52
|
+
throw new RangeError(`${processor} amounts can't be negative (${money}); send refunds as positive amounts`);
|
|
53
|
+
}
|
|
54
|
+
if (sign === 'positive' && (minor === 0 || minor === 0n)) {
|
|
55
|
+
throw new RangeError(`${processor} amounts must be greater than zero (${money})`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @internal Money -> a processor's integer amount at the processor's exponent.
|
|
60
|
+
* Throws a RangeError when the amount doesn't fit in a safe integer or has a sign `sign` rules out.
|
|
61
|
+
*/
|
|
62
|
+
export function toProcessorAmount(processor, money, exponent, multiple, rounding, sign = 'any') {
|
|
63
|
+
const minor = rescaleForProcessor(processor, money, exponent, multiple, rounding);
|
|
64
|
+
if (typeof minor !== 'number') {
|
|
65
|
+
throw new RangeError(`${money} is too large for ${processor}`);
|
|
66
|
+
}
|
|
67
|
+
checkSign(processor, money, minor, sign);
|
|
68
|
+
// `+ 0` turns -0 into 0, so a zero amount never serialises as "-0".
|
|
69
|
+
return minor + 0;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @internal Money -> a processor's decimal string with exactly `exponent` decimals
|
|
73
|
+
* ("10.00", or "1000" for JPY), built from the integer so it never goes through a float.
|
|
74
|
+
*/
|
|
75
|
+
export function toProcessorDecimal(processor, money, exponent, rounding, sign = 'any') {
|
|
76
|
+
const minor = rescaleForProcessor(processor, money, exponent, 1, rounding);
|
|
77
|
+
checkSign(processor, money, minor, sign);
|
|
78
|
+
// `+ 0` turns -0 into 0, so a zero amount never serialises as "-0".
|
|
79
|
+
return formatScaled(typeof minor === 'number' ? minor + 0 : minor, exponent);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Returns Money at the currency's ISO scale when that is exact, and otherwise at the scale it
|
|
83
|
+
* came with, so a processor's extra precision (Stripe's ISK 12.34) is kept rather than lost.
|
|
84
|
+
*/
|
|
85
|
+
function toIsoScaleWhenExact(money, currency) {
|
|
86
|
+
const isoExponent = currencyExponent(currency);
|
|
87
|
+
if (isoExponent >= money.scale) {
|
|
88
|
+
return toScale(money, isoExponent);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
return toScale(money, isoExponent, 'unnecessary');
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return money;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** @internal A processor's integer amount -> Money (see `toIsoScaleWhenExact` for the scale). */
|
|
98
|
+
export function fromProcessorAmount(processor, amount, currency, exponent) {
|
|
99
|
+
if (typeof amount === 'number' && !Number.isSafeInteger(amount)) {
|
|
100
|
+
throw new RangeError(`${processor} amount must be an integer, got ${amount}`);
|
|
101
|
+
}
|
|
102
|
+
return toIsoScaleWhenExact(fromMinor(amount, currency, exponent), currency);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @internal A processor's decimal string -> Money, exactly (never via a float). `pattern` is the
|
|
106
|
+
* processor's documented format and `maxLength` its length limit, if any. The scale follows
|
|
107
|
+
* `toIsoScaleWhenExact`.
|
|
108
|
+
*/
|
|
109
|
+
export function fromProcessorDecimal(processor, value, currency, pattern, maxLength = Infinity) {
|
|
110
|
+
if (typeof value !== 'string' || value.length > maxLength || !pattern.test(value)) {
|
|
111
|
+
throw new SyntaxError(`${processor} amount must be a decimal string, got ${JSON.stringify(value)}`);
|
|
112
|
+
}
|
|
113
|
+
// PayPal's pattern allows a bare fraction (".5"), which the decimal parsers don't.
|
|
114
|
+
const withLeadingZero = value.replace(/^(-?)\./, '$10.');
|
|
115
|
+
const parsed = parsePlainDecimal(withLeadingZero) ?? parseDecimal(withLeadingZero);
|
|
116
|
+
return toIsoScaleWhenExact(fromMinor(parsed.digits, currency, parsed.scale), currency);
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.js","sourceRoot":"","sources":["../src/processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAkC,MAAM,YAAY,CAAC;AACpG,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,aAAa,GAEd,MAAM,eAAe,CAAC;AAUvB;;;;GAIG;AACH,SAAS,mBAAmB,CAC1B,SAAiB,EACjB,KAAY,EACZ,QAAgB,EAChB,QAAgB,EAChB,QAAsB;IAEtB,uFAAuF;IACvF,IAAI,KAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,IAAI,QAAQ,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAC5B,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,CA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