@amboras-dev/money 0.1.0 → 0.2.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/README.md +14 -6
- package/dist/ai.cjs +4 -4
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.js +4 -4
- package/dist/{allocate-D7tm_t_o.cjs → allocate-CZRg4TOP.cjs} +2 -2
- package/dist/{allocate-CdnhvAda.js → allocate-X7_jAtOj.js} +2 -2
- package/dist/{amount-DHtvZSSm.cjs → amount-BV0O-aN8.cjs} +3 -3
- package/dist/{amount-D7dj76nH.js → amount-BoYBMgK9.js} +3 -3
- package/dist/{arithmetic-C-Q_aI49.js → arithmetic-BhNwisjb.js} +3 -3
- package/dist/{arithmetic-Bq-8mSal.cjs → arithmetic-DjT4Kzgt.cjs} +3 -3
- package/dist/billing.cjs +2 -2
- package/dist/billing.d.cts +1 -1
- package/dist/billing.d.ts +1 -1
- package/dist/billing.js +2 -2
- package/dist/commerce.cjs +7 -7
- package/dist/commerce.d.cts +2 -2
- package/dist/commerce.d.ts +2 -2
- package/dist/commerce.js +7 -7
- package/dist/{format-BdB7LEIp.js → format-BdPnijvn.js} +11 -2
- package/dist/{format-BnA1aLJk.cjs → format-DLhno7eX.cjs} +16 -1
- package/dist/fx.cjs +5 -5
- package/dist/fx.d.cts +5 -5
- package/dist/fx.d.ts +5 -5
- package/dist/fx.js +5 -5
- package/dist/index.cjs +10 -7
- package/dist/index.d.cts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +8 -8
- package/dist/input.cjs +4 -4
- package/dist/input.d.cts +2 -2
- package/dist/input.d.ts +2 -2
- package/dist/input.js +4 -4
- package/dist/{iso-minor-CtaiIifs.js → iso-minor-CqkWDxHS.js} +1 -1
- package/dist/{iso-minor--gQWI1f2.cjs → iso-minor-wSwJN57T.cjs} +1 -1
- package/dist/{medusa-DuQ3-KoD.d.cts → medusa-4K8N1pUc.d.cts} +11 -2
- package/dist/{medusa-RwqxaDGq.d.ts → medusa-DBXJXXvF.d.ts} +11 -2
- package/dist/{medusa-CmxCni-G.js → medusa-DqJY1qpj.js} +17 -2
- package/dist/{medusa-OJ2TJOxt.cjs → medusa-lRY9xlsf.cjs} +22 -1
- package/dist/{money-CbhsT0fB.d.cts → money-B-3aFjNJ.d.cts} +19 -3
- package/dist/{money-CbhsT0fB.d.ts → money-B-3aFjNJ.d.ts} +19 -3
- package/dist/{money-D5-vlv0h.cjs → money-B3wH_Z4S.cjs} +35 -5
- package/dist/{money-CIgELekG.js → money-WhnGiI00.js} +18 -6
- package/dist/{number-text-BpvN6NAo.cjs → number-text-BWu67jUq.cjs} +1 -1
- package/dist/{number-text-C82oh6JB.js → number-text-DE-q4jO5.js} +1 -1
- package/dist/{percent-Dt8vNIAW.cjs → percent-C0InC2t2.cjs} +1 -1
- package/dist/{percent-CKVI_c-m.js → percent-D1VB9xXG.js} +1 -1
- package/dist/{rate-DGPfB_jc.cjs → rate-CVeMii4a.cjs} +1 -1
- package/dist/{rate-CmeTGNex.d.ts → rate-DBPiYgT1.d.ts} +1 -1
- package/dist/{rate-lLPViBuM.js → rate-DicStBue.js} +1 -1
- package/dist/{rate-toyS3EMf.d.cts → rate-tqK8ijG0.d.cts} +1 -1
- package/dist/{reporting-DEM97DhQ.d.cts → reporting-CG-ai2sM.d.cts} +2 -2
- package/dist/{reporting-5xby-Zas.d.ts → reporting-tpGJbqYp.d.ts} +2 -2
- package/dist/{retail-BsvpNv1F.js → retail-1mu888J1.js} +3 -3
- package/dist/{retail-Mqd-sPMF.d.cts → retail-C_BPLvMj.d.cts} +1 -1
- package/dist/{retail-DTk2XAMM.cjs → retail-Cml8YSKg.cjs} +3 -3
- package/dist/{retail-BwcFJcVN.d.ts → retail-DRUTTQoJ.d.ts} +1 -1
- package/dist/{rounding-oZ832yTD.cjs → rounding-DHBtNCHG.cjs} +1 -1
- package/dist/{rounding-CVAPEfq_.js → rounding-g9rvye0k.js} +1 -1
- package/dist/sql.cjs +3 -3
- package/dist/sql.d.cts +2 -2
- package/dist/sql.d.ts +2 -2
- package/dist/sql.js +3 -3
- package/dist/testing.cjs +33481 -4
- package/dist/testing.d.cts +31 -3
- package/dist/testing.d.ts +31 -3
- package/dist/testing.js +33481 -5
- package/dist/{wire-DQZ6fA3c.cjs → wire-Bhuut8cW.cjs} +259 -34
- package/dist/{wire-Cd4Q1Jmm.d.ts → wire-CaUN9Vf_.d.ts} +61 -21
- package/dist/{wire-CI3Sm1iC.js → wire-sW0yzqth.js} +248 -35
- package/dist/{wire-hWuixv3w.d.cts → wire-xjYXv4go.d.cts} +61 -21
- package/dist/wire.cjs +3 -1
- package/dist/wire.d.cts +2 -2
- package/dist/wire.d.ts +2 -2
- package/dist/wire.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,8 +121,10 @@ corrupt one), `sameCurrency`, `medusaCurrencyCode` (the only sanctioned lower-ca
|
|
|
121
121
|
pinned to `@medusajs/utils` 2.13.4). `CurrencyInfo` also carries `symbolAliases`, `localeHint` and `commaDecimal` (TND: its decimal mark is a comma, so `'12,500'` is 12.5).
|
|
122
122
|
|
|
123
123
|
**Medusa shapes**: `readStored` reads `.value ?? .raw.value ?? .raw_.value`, then
|
|
124
|
-
`.numeric ?? .numeric_`, then the primitive
|
|
124
|
+
`.numeric ?? .numeric_`, then the primitive (`precision: 'round'` rounds a fractional amount
|
|
125
|
+
half-up to a whole storage unit instead of refusing it). `readStoredField` (`raw_<key>` first, no fallback
|
|
125
126
|
when it is unreadable), `readStoredDecimal` (keeps fractions, canonical text),
|
|
127
|
+
`readStoredLiteral` (the amount literal verbatim, for SQL and ledger columns),
|
|
126
128
|
`readCalculatedPrice`, `toMedusaRaw` (never an exponent), `toMedusaAmountInput` (`'0'` for zero),
|
|
127
129
|
`moneyByCurrency` / `moneyFor` (per-currency settings and price lists), `isPositiveAmount`.
|
|
128
130
|
|
|
@@ -144,12 +146,13 @@ unit apart).
|
|
|
144
146
|
|
|
145
147
|
**Decimal text**: `parseDecimalText`, `isDecimalLiteral` (the one storage-literal grammar),
|
|
146
148
|
`assertDecimalLiteral`, `trimDecimalZeros`, `decimalSum`, `decimalSubtract`, `decimalMultiply`,
|
|
147
|
-
`decimalDivide`, `decimalRound`, `decimalCompare`, `decimalClamp`, `decimalWithin
|
|
148
|
-
and exponents are refused.
|
|
149
|
+
`decimalDivide`, `decimalRound`, `decimalCompare`, `decimalClamp`, `decimalWithin`, `decimalEquals`
|
|
150
|
+
(never throws: a non-decimal is never equal). Exact; `''` and exponents are refused.
|
|
149
151
|
|
|
150
152
|
**Formatting** (for people, not byte-stable across ICU): `formatMoney` (display digits, or
|
|
151
153
|
`widen` / `trim-zero`; explicit locale, default `en-US`), `formatMoneyCompact`,
|
|
152
|
-
`formatMoneyRange`, `moneyAxisFormatter
|
|
154
|
+
`formatMoneyRange`, `moneyAxisFormatter`, `formatStored` (a possibly fractional stored amount,
|
|
155
|
+
rounded half-up to a storage unit, then `formatMoney`).
|
|
153
156
|
|
|
154
157
|
Internals other entry points build on (never exported), each the only implementation of its concept:
|
|
155
158
|
`internal/number-text.ts` `readNumberText` (the one separator engine), `internal/rational.ts`
|
|
@@ -166,12 +169,16 @@ import { ISO_MINOR_V2, conventionOf, decodeWire, encodeWire } from '@amboras-dev
|
|
|
166
169
|
|
|
167
170
|
encodeWire('stripe', money(120000, 'JPY'), { convention: ISO_MINOR_V2 }) // 1200
|
|
168
171
|
decodeWire('stripe', 1200, 'JPY', conventionOf(paymentIntent)) // { amount: 120000, currency: 'JPY' }
|
|
172
|
+
encodeWire('mollie', { amount: '107.8175', currency: 'USD' }) // '1.08': a fractional stored total
|
|
169
173
|
```
|
|
170
174
|
|
|
175
|
+
A Medusa session amount can be fractional at storage scale (107.8175). `encodeWire` and `sameWireAmount` take it as a `FractionalMoney` and round it by the PSP's own rule: Stripe and Adyen to a whole storage unit first, whole-unit PSPs (MoMo, Payoo, VNPay, Paystack XOF) refuse it, a pre-cutover Razorpay payment refuses it, every other PSP rounds once, half-up, at its wire unit.
|
|
176
|
+
|
|
171
177
|
- Codec: `encodeWire`, `decodeWire`, `tryDecodeWire` (never throws), `wireFactor`, `pspWireDigits`, `oneWireUnit`, `wireBreakdown` (line items that sum to the encoded total), `wireKeyPart`.
|
|
172
178
|
- Cutover marker: `WIRE_SCALE_KEY`, `WIRE_SCALE_ISO_MINOR_V2`, `WIRE_SCALE_MARKER`, `ISO_MINOR_V2`, `PRE_CUTOVER`, `conventionOf` (gated PSPs need the convention; there is no hidden default).
|
|
173
|
-
- Provider tables: `PSP_IDS`, `pspSupportsCurrency`, `assertPspCurrency`, `pspCurrencies
|
|
174
|
-
-
|
|
179
|
+
- Provider tables: `PSP_IDS`, `pspSupportsCurrency`, `assertPspCurrency`, `pspCurrencies` (what the codec scales), `pspDefaultCurrency`, `pspMinimumAmount`.
|
|
180
|
+
- Presentment (eligibility): `pspPresentmentCurrencies(psp, { accountCountry })` (what an account can charge buyers in) and `pspPresentment(psp)` (the rules as data: union, currencies needing an account country, account countries limited to a list).
|
|
181
|
+
- Comparison: `sameWireAmount` (a webhook amount against the expected Money or FractionalMoney, exactly at storage scale; `acceptLegacyIsoDigits`, `textOnly`).
|
|
175
182
|
- Provider quirks: `verificationCharge`, `RAZORPAY_AFA_FREE_CAP`, `iyzicoPrice`, `authorizeNetReversibleAmount`, `jsonDecimalLiteral`.
|
|
176
183
|
- Provider text: `parseProviderAmount` (carrier quotes, dispute amounts; `decimalSeparator: 'auto'` is the `/input` rule).
|
|
177
184
|
- Destinations: `destinationAmount` (pixels, ad platforms, email tools), `feedPrice`, `googleMicros`, `eventMoney` (ClickHouse `Int64` contract).
|
|
@@ -310,6 +317,7 @@ Framework-agnostic: no test runner or fast-check dependency.
|
|
|
310
317
|
`/wire`'s `encodeWire` must reproduce every vector (decision D2: wire bytes feed idempotency keys, Redis keys and HMAC strings).
|
|
311
318
|
A positive amount whose wire rounds to 0 (68 vectors: one storage unit of a zero-decimal currency at Stripe, Adyen, Razorpay, Airwallex, PayPal HUF/JPY/TWD, Mollie ISK/JPY) is a refusal vector by package policy: `encodeWire` refuses it with `wire_refused` (`... rounds to 0 at <Tag> ...`).
|
|
312
319
|
Medusa today puts 0 on the wire at initiate for Stripe and Adyen, and for Razorpay, PayPal and Airwallex everywhere; it refuses at refund and capture for Stripe and Adyen, and in Mollie, iyzico and Authorize.Net.
|
|
320
|
+
- `PSP_FRACTIONAL_GOLDEN_VECTORS`: the same codecs fed fractional storage amounts (0.4, 0.5, ties, 107.8175, a fraction of a dong); `policy` and `medusa` mark where `encodeWire` departs from them on purpose (the sub-unit refusal, exact half-up at ties float `toFixed` rounds down, the real amount in a refusal message).
|
|
313
321
|
- `DESTINATION_GOLDEN_VECTORS`: what `destinationAmount`, `feedPrice` and `googleMicros` must give per destination.
|
|
314
322
|
- `checkWireDigits(psp, documented)`: the capability-consistency probe; returns mismatch messages.
|
|
315
323
|
- `normalizeIntlSpaces(s)`, `sampleMoney(currency, major)`.
|
package/dist/ai.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_money = require("./money-
|
|
3
|
-
const require_format = require("./format-
|
|
4
|
-
const require_number_text = require("./number-text-
|
|
5
|
-
const require_amount = require("./amount-
|
|
2
|
+
const require_money = require("./money-B3wH_Z4S.cjs");
|
|
3
|
+
const require_format = require("./format-DLhno7eX.cjs");
|
|
4
|
+
const require_number_text = require("./number-text-BWu67jUq.cjs");
|
|
5
|
+
const require_amount = require("./amount-BV0O-aN8.cjs");
|
|
6
6
|
//#region src/ai/mentions.ts
|
|
7
7
|
const ACTIVE = require_money.CURRENCIES.filter((c) => c.status === "active");
|
|
8
8
|
const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
package/dist/ai.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as DecimalText, g as CurrencyCode, i as Money } from "./money-B-3aFjNJ.cjs";
|
|
2
2
|
//#region src/ai/mentions.d.ts
|
|
3
3
|
/** One price found in text. `code` is set when the mark names one currency; `amount` when the number reads (see the separator engine's 'auto' rule). */
|
|
4
4
|
interface MoneyMention {
|
package/dist/ai.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as DecimalText, g as CurrencyCode, i as Money } from "./money-B-3aFjNJ.js";
|
|
2
2
|
//#region src/ai/mentions.d.ts
|
|
3
3
|
/** One price found in text. `code` is set when the mark names one currency; `amount` when the number reads (see the separator engine's 'auto' rule). */
|
|
4
4
|
interface MoneyMention {
|
package/dist/ai.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as formatMoney } from "./format-
|
|
3
|
-
import { n as readNumberText, t as digitGroupingSource } from "./number-text-
|
|
4
|
-
import { s as parseAmountInput } from "./amount-
|
|
1
|
+
import { $ as describeValue, E as resolveCurrency, Q as MoneyError, l as toMajorNumber, m as currencyMarks, n as fromMajor, pt as toDecimalText, s as storedDecimal, u as CURRENCIES } from "./money-WhnGiI00.js";
|
|
2
|
+
import { t as formatMoney } from "./format-BdPnijvn.js";
|
|
3
|
+
import { n as readNumberText, t as digitGroupingSource } from "./number-text-DE-q4jO5.js";
|
|
4
|
+
import { s as parseAmountInput } from "./amount-BoYBMgK9.js";
|
|
5
5
|
//#region src/ai/mentions.ts
|
|
6
6
|
const ACTIVE = CURRENCIES.filter((c) => c.status === "active");
|
|
7
7
|
const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_money = require("./money-
|
|
2
|
-
const require_rounding = require("./rounding-
|
|
1
|
+
const require_money = require("./money-B3wH_Z4S.cjs");
|
|
2
|
+
const require_rounding = require("./rounding-DHBtNCHG.cjs");
|
|
3
3
|
//#region src/allocate.ts
|
|
4
4
|
const invalid = (message) => new require_money.MoneyError("amount_invalid", message);
|
|
5
5
|
const sumOf = (values) => values.reduce((a, b) => a + b, 0n);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as unitSize } from "./rounding-
|
|
1
|
+
import { $ as describeValue, B as decimalOf, Q as MoneyError, X as mulDiv, at as fractionDigitsOf, dt as roundToScale, pt as toDecimalText, rt as divRound, s as storedDecimal, t as boundedMoney } from "./money-WhnGiI00.js";
|
|
2
|
+
import { a as unitSize } from "./rounding-g9rvye0k.js";
|
|
3
3
|
//#region src/allocate.ts
|
|
4
4
|
const invalid = (message) => new MoneyError("amount_invalid", message);
|
|
5
5
|
const sumOf = (values) => values.reduce((a, b) => a + b, 0n);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_money = require("./money-
|
|
2
|
-
const require_arithmetic = require("./arithmetic-
|
|
3
|
-
const require_number_text = require("./number-text-
|
|
1
|
+
const require_money = require("./money-B3wH_Z4S.cjs");
|
|
2
|
+
const require_arithmetic = require("./arithmetic-DjT4Kzgt.cjs");
|
|
3
|
+
const require_number_text = require("./number-text-BWu67jUq.cjs");
|
|
4
4
|
//#region src/input/amount.ts
|
|
5
5
|
/** Internal: the exact signed decimal a successful separator-engine read holds. */
|
|
6
6
|
function decimalOfText(read) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E as resolveCurrency,
|
|
2
|
-
import { r as compare } from "./arithmetic-
|
|
3
|
-
import { n as readNumberText } from "./number-text-
|
|
1
|
+
import { E as resolveCurrency, M as resolveLocale, N as separatorsOf, Q as MoneyError, at as fractionDigitsOf, c as toMajorDecimal, it as formatDecimal, n as fromMajor, q as trimDecimalZeros, s as storedDecimal, tt as compareDecimal } from "./money-WhnGiI00.js";
|
|
2
|
+
import { r as compare } from "./arithmetic-BhNwisjb.js";
|
|
3
|
+
import { n as readNumberText } from "./number-text-DE-q4jO5.js";
|
|
4
4
|
//#region src/input/amount.ts
|
|
5
5
|
/** Internal: the exact signed decimal a successful separator-engine read holds. */
|
|
6
6
|
function decimalOfText(read) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as mulDivToUnit } from "./rounding-
|
|
3
|
-
import { n as hundredPercent } from "./percent-
|
|
1
|
+
import { $ as describeValue, B as decimalOf, E as resolveCurrency, Q as MoneyError, ot as isPositiveDecimal, s as storedDecimal, t as boundedMoney, ut as pow10 } from "./money-WhnGiI00.js";
|
|
2
|
+
import { t as mulDivToUnit } from "./rounding-g9rvye0k.js";
|
|
3
|
+
import { n as hundredPercent } from "./percent-D1VB9xXG.js";
|
|
4
4
|
//#region src/arithmetic.ts
|
|
5
5
|
/** Internal: the shared currency of `a` and `b` and their stored integers. Throws `currency_mismatch`. */
|
|
6
6
|
function pair(a, b, verb) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_money = require("./money-
|
|
2
|
-
const require_rounding = require("./rounding-
|
|
3
|
-
const require_percent = require("./percent-
|
|
1
|
+
const require_money = require("./money-B3wH_Z4S.cjs");
|
|
2
|
+
const require_rounding = require("./rounding-DHBtNCHG.cjs");
|
|
3
|
+
const require_percent = require("./percent-C0InC2t2.cjs");
|
|
4
4
|
//#region src/arithmetic.ts
|
|
5
5
|
/** Internal: the shared currency of `a` and `b` and their stored integers. Throws `currency_mismatch`. */
|
|
6
6
|
function pair(a, b, verb) {
|
package/dist/billing.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_money = require("./money-
|
|
3
|
-
const require_percent = require("./percent-
|
|
2
|
+
const require_money = require("./money-B3wH_Z4S.cjs");
|
|
3
|
+
const require_percent = require("./percent-C0InC2t2.cjs");
|
|
4
4
|
//#region src/billing/credits.ts
|
|
5
5
|
function wholeNumber(value, name, min) {
|
|
6
6
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < min) throw new require_money.MoneyError("amount_invalid", `${name} must be an integer >= ${min}, got ${require_money.describeValue(value)}`);
|
package/dist/billing.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as DecimalText, i as Money } from "./money-B-3aFjNJ.cjs";
|
|
2
2
|
//#region src/billing/usage.d.ts
|
|
3
3
|
/** USD with sub-cent precision, as canonical decimal text (`'0.001234'`). Never merchant money. */
|
|
4
4
|
type UsdAmount = DecimalText;
|
package/dist/billing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as DecimalText, i as Money } from "./money-B-3aFjNJ.js";
|
|
2
2
|
//#region src/billing/usage.d.ts
|
|
3
3
|
/** USD with sub-cent precision, as canonical decimal text (`'0.001234'`). Never merchant money. */
|
|
4
4
|
type UsdAmount = DecimalText;
|
package/dist/billing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { n as hundredPercent, r as percentOfUnits } from "./percent-
|
|
1
|
+
import { $ as describeValue, B as decimalOf, Q as MoneyError, dt as roundToScale, et as addDecimal, it as formatDecimal, n as fromMajor, pt as toDecimalText, rt as divRound, s as storedDecimal, st as multiplyDecimal, t as boundedMoney } from "./money-WhnGiI00.js";
|
|
2
|
+
import { n as hundredPercent, r as percentOfUnits } from "./percent-D1VB9xXG.js";
|
|
3
3
|
//#region src/billing/credits.ts
|
|
4
4
|
function wholeNumber(value, name, min) {
|
|
5
5
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < min) throw new MoneyError("amount_invalid", `${name} must be an integer >= ${min}, got ${describeValue(value)}`);
|
package/dist/commerce.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_money = require("./money-
|
|
3
|
-
const require_rounding = require("./rounding-
|
|
4
|
-
const require_allocate = require("./allocate-
|
|
5
|
-
const require_percent = require("./percent-
|
|
6
|
-
const require_format = require("./format-
|
|
7
|
-
const require_medusa = require("./medusa-
|
|
8
|
-
const require_retail = require("./retail-
|
|
2
|
+
const require_money = require("./money-B3wH_Z4S.cjs");
|
|
3
|
+
const require_rounding = require("./rounding-DHBtNCHG.cjs");
|
|
4
|
+
const require_allocate = require("./allocate-CZRg4TOP.cjs");
|
|
5
|
+
const require_percent = require("./percent-C0InC2t2.cjs");
|
|
6
|
+
const require_format = require("./format-DLhno7eX.cjs");
|
|
7
|
+
const require_medusa = require("./medusa-lRY9xlsf.cjs");
|
|
8
|
+
const require_retail = require("./retail-Cml8YSKg.cjs");
|
|
9
9
|
//#region src/commerce/convention.ts
|
|
10
10
|
/**
|
|
11
11
|
* Currencies with storage digits: step 1, `'x100'`. Zero-decimal currencies: step 100 when
|
package/dist/commerce.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as RetailRounding } from "./retail-
|
|
1
|
+
import { R as DecimalText, i as Money, z as RoundingMode } from "./money-B-3aFjNJ.cjs";
|
|
2
|
+
import { t as RetailRounding } from "./retail-C_BPLvMj.cjs";
|
|
3
3
|
//#region src/commerce/convention.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Currencies with storage digits: step 1, `'x100'`. Zero-decimal currencies: step 100 when
|
package/dist/commerce.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as RetailRounding } from "./retail-
|
|
1
|
+
import { R as DecimalText, i as Money, z as RoundingMode } from "./money-B-3aFjNJ.js";
|
|
2
|
+
import { t as RetailRounding } from "./retail-DRUTTQoJ.js";
|
|
3
3
|
//#region src/commerce/convention.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Currencies with storage digits: step 1, `'x100'`. Zero-decimal currencies: step 100 when
|
package/dist/commerce.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { a as unitSize, r as roundStoredDecimal, t as mulDivToUnit } from "./rounding-
|
|
3
|
-
import { n as allocateUnits, t as allocate } from "./allocate-
|
|
4
|
-
import { i as percentRatio, n as hundredPercent, t as basisPointsOf } from "./percent-
|
|
5
|
-
import { t as formatMoney } from "./format-
|
|
6
|
-
import { a as readStoredDecimal,
|
|
7
|
-
import { n as retailUnits } from "./retail-
|
|
1
|
+
import { $ as describeValue, B as decimalOf, E as resolveCurrency, Q as MoneyError, X as mulDiv, Z as ratioToDecimal, dt as roundToScale, et as addDecimal, i as medusaAmountDecimal, pt as toDecimalText, rt as divRound, s as storedDecimal, st as multiplyDecimal, t as boundedMoney, ut as pow10 } from "./money-WhnGiI00.js";
|
|
2
|
+
import { a as unitSize, r as roundStoredDecimal, t as mulDivToUnit } from "./rounding-g9rvye0k.js";
|
|
3
|
+
import { n as allocateUnits, t as allocate } from "./allocate-X7_jAtOj.js";
|
|
4
|
+
import { i as percentRatio, n as hundredPercent, t as basisPointsOf } from "./percent-D1VB9xXG.js";
|
|
5
|
+
import { t as formatMoney } from "./format-BdPnijvn.js";
|
|
6
|
+
import { a as readStoredDecimal, c as storedFieldValue } from "./medusa-DqJY1qpj.js";
|
|
7
|
+
import { n as retailUnits } from "./retail-1mu888J1.js";
|
|
8
8
|
//#region src/commerce/convention.ts
|
|
9
9
|
/**
|
|
10
10
|
* Currencies with storage digits: step 1, `'x100'`. Zero-decimal currencies: step 100 when
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { E as resolveCurrency, M as resolveLocale,
|
|
1
|
+
import { B as decimalOf, E as resolveCurrency, M as resolveLocale, Q as MoneyError, at as fractionDigitsOf, dt as roundToScale, it as formatDecimal, j as numberFormat, nt as decimalFromNumber, s as storedDecimal, tt as compareDecimal } from "./money-WhnGiI00.js";
|
|
2
|
+
import { i as roundToUnit } from "./rounding-g9rvye0k.js";
|
|
2
3
|
//#region src/format.ts
|
|
3
4
|
function intlDisplay(options) {
|
|
4
5
|
const display = options.currencyDisplay ?? "symbol";
|
|
@@ -32,6 +33,14 @@ function formatMoney(m, options = {}) {
|
|
|
32
33
|
return finish(`${info.code} ${text}`, info.code, options);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* A stored amount that may be fractional (a Medusa total, 107.8175; a percentage promotion) for
|
|
38
|
+
* people: rounded half-up to a whole storage unit (`roundToUnit`), then `formatMoney` with `options`.
|
|
39
|
+
* A number must be finite; text is plain decimal; an unknown currency throws `currency_invalid`.
|
|
40
|
+
*/
|
|
41
|
+
function formatStored(amount, currency, options = {}) {
|
|
42
|
+
return formatMoney(roundToUnit(amount, currency), options);
|
|
43
|
+
}
|
|
35
44
|
function compact(currency, major, options, significant) {
|
|
36
45
|
return numberFormat(resolveLocale(options.locale), {
|
|
37
46
|
style: "currency",
|
|
@@ -87,4 +96,4 @@ function moneyAxisFormatter(currency, options = {}) {
|
|
|
87
96
|
};
|
|
88
97
|
}
|
|
89
98
|
//#endregion
|
|
90
|
-
export { moneyAxisFormatter as i, formatMoneyCompact as n, formatMoneyRange as r, formatMoney as t };
|
|
99
|
+
export { moneyAxisFormatter as a, formatStored as i, formatMoneyCompact as n, formatMoneyRange as r, formatMoney as t };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const require_money = require("./money-
|
|
1
|
+
const require_money = require("./money-B3wH_Z4S.cjs");
|
|
2
|
+
const require_rounding = require("./rounding-DHBtNCHG.cjs");
|
|
2
3
|
//#region src/format.ts
|
|
3
4
|
function intlDisplay(options) {
|
|
4
5
|
const display = options.currencyDisplay ?? "symbol";
|
|
@@ -32,6 +33,14 @@ function formatMoney(m, options = {}) {
|
|
|
32
33
|
return finish(`${info.code} ${text}`, info.code, options);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* A stored amount that may be fractional (a Medusa total, 107.8175; a percentage promotion) for
|
|
38
|
+
* people: rounded half-up to a whole storage unit (`roundToUnit`), then `formatMoney` with `options`.
|
|
39
|
+
* A number must be finite; text is plain decimal; an unknown currency throws `currency_invalid`.
|
|
40
|
+
*/
|
|
41
|
+
function formatStored(amount, currency, options = {}) {
|
|
42
|
+
return formatMoney(require_rounding.roundToUnit(amount, currency), options);
|
|
43
|
+
}
|
|
35
44
|
function compact(currency, major, options, significant) {
|
|
36
45
|
return require_money.numberFormat(require_money.resolveLocale(options.locale), {
|
|
37
46
|
style: "currency",
|
|
@@ -105,6 +114,12 @@ Object.defineProperty(exports, "formatMoneyRange", {
|
|
|
105
114
|
return formatMoneyRange;
|
|
106
115
|
}
|
|
107
116
|
});
|
|
117
|
+
Object.defineProperty(exports, "formatStored", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function() {
|
|
120
|
+
return formatStored;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
108
123
|
Object.defineProperty(exports, "moneyAxisFormatter", {
|
|
109
124
|
enumerable: true,
|
|
110
125
|
get: function() {
|
package/dist/fx.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_money = require("./money-
|
|
3
|
-
const require_rounding = require("./rounding-
|
|
2
|
+
const require_money = require("./money-B3wH_Z4S.cjs");
|
|
3
|
+
const require_rounding = require("./rounding-DHBtNCHG.cjs");
|
|
4
4
|
const require_own = require("./own-oP9DXFWv.cjs");
|
|
5
|
-
const require_medusa = require("./medusa-
|
|
6
|
-
const require_rate = require("./rate-
|
|
7
|
-
const require_retail = require("./retail-
|
|
5
|
+
const require_medusa = require("./medusa-lRY9xlsf.cjs");
|
|
6
|
+
const require_rate = require("./rate-CVeMii4a.cjs");
|
|
7
|
+
const require_retail = require("./retail-Cml8YSKg.cjs");
|
|
8
8
|
//#region src/fx/convert.ts
|
|
9
9
|
const infoOf = (code) => require_money.resolveCurrency(code, { allowHistoric: true });
|
|
10
10
|
/**
|
package/dist/fx.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as priceRoundingParams, r as roundRetail, t as RetailRounding } from "./retail-
|
|
3
|
-
import { a as RateRow, c as rate, d as rateFromRow, f as rateToDecimal, i as RateFromDecimalOptions, l as rateEquals, n as RATE_REF, o as crossRate, p as rateToNumber, r as Rate, s as invertRate, t as RATE_BOUNDS, u as rateFromDecimal } from "./rate-
|
|
4
|
-
import { i as toReporting, n as ReportingTotal, r as storeFactors, t as FactorTable } from "./reporting-
|
|
5
|
-
import { n as MoneyByCurrency } from "./medusa-
|
|
1
|
+
import { R as DecimalText, i as Money, z as RoundingMode } from "./money-B-3aFjNJ.cjs";
|
|
2
|
+
import { n as priceRoundingParams, r as roundRetail, t as RetailRounding } from "./retail-C_BPLvMj.cjs";
|
|
3
|
+
import { a as RateRow, c as rate, d as rateFromRow, f as rateToDecimal, i as RateFromDecimalOptions, l as rateEquals, n as RATE_REF, o as crossRate, p as rateToNumber, r as Rate, s as invertRate, t as RATE_BOUNDS, u as rateFromDecimal } from "./rate-tqK8ijG0.cjs";
|
|
4
|
+
import { i as toReporting, n as ReportingTotal, r as storeFactors, t as FactorTable } from "./reporting-CG-ai2sM.cjs";
|
|
5
|
+
import { n as MoneyByCurrency } from "./medusa-4K8N1pUc.cjs";
|
|
6
6
|
//#region src/fx/convert.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* The factor taking a stored `from` amount to a stored `to` amount for the major rate `r`
|
package/dist/fx.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as priceRoundingParams, r as roundRetail, t as RetailRounding } from "./retail-
|
|
3
|
-
import { a as RateRow, c as rate, d as rateFromRow, f as rateToDecimal, i as RateFromDecimalOptions, l as rateEquals, n as RATE_REF, o as crossRate, p as rateToNumber, r as Rate, s as invertRate, t as RATE_BOUNDS, u as rateFromDecimal } from "./rate-
|
|
4
|
-
import { i as toReporting, n as ReportingTotal, r as storeFactors, t as FactorTable } from "./reporting-
|
|
5
|
-
import { n as MoneyByCurrency } from "./medusa-
|
|
1
|
+
import { R as DecimalText, i as Money, z as RoundingMode } from "./money-B-3aFjNJ.js";
|
|
2
|
+
import { n as priceRoundingParams, r as roundRetail, t as RetailRounding } from "./retail-DRUTTQoJ.js";
|
|
3
|
+
import { a as RateRow, c as rate, d as rateFromRow, f as rateToDecimal, i as RateFromDecimalOptions, l as rateEquals, n as RATE_REF, o as crossRate, p as rateToNumber, r as Rate, s as invertRate, t as RATE_BOUNDS, u as rateFromDecimal } from "./rate-DBPiYgT1.js";
|
|
4
|
+
import { i as toReporting, n as ReportingTotal, r as storeFactors, t as FactorTable } from "./reporting-tpGJbqYp.js";
|
|
5
|
+
import { n as MoneyByCurrency } from "./medusa-DBXJXXvF.js";
|
|
6
6
|
//#region src/fx/convert.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* The factor taking a stored `from` amount to a stored `to` amount for the major rate `r`
|
package/dist/fx.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as resolveCurrency, J as
|
|
2
|
-
import { t as mulDivToUnit } from "./rounding-
|
|
1
|
+
import { $ as describeValue, B as decimalOf, E as resolveCurrency, J as compareRatio, M as resolveLocale, Q as MoneyError, X as mulDiv, Y as gcd, Z as ratioToDecimal, it as formatDecimal, j as numberFormat, n as fromMajor, nt as decimalFromNumber, pt as toDecimalText, s as storedDecimal, t as boundedMoney, ut as pow10, y as findCurrency } from "./money-WhnGiI00.js";
|
|
2
|
+
import { t as mulDivToUnit } from "./rounding-g9rvye0k.js";
|
|
3
3
|
import { t as hasOwnKey } from "./own-D7544D3k.js";
|
|
4
|
-
import { r as moneyFor } from "./medusa-
|
|
5
|
-
import { a as invertRate, c as rateFromDecimal, d as rateToNumber, i as crossRate, l as rateFromRow, n as RATE_REF, o as rate, r as checkRate, s as rateEquals, t as RATE_BOUNDS, u as rateToDecimal } from "./rate-
|
|
6
|
-
import { n as retailUnits, r as roundRetail, t as priceRoundingParams } from "./retail-
|
|
4
|
+
import { r as moneyFor } from "./medusa-DqJY1qpj.js";
|
|
5
|
+
import { a as invertRate, c as rateFromDecimal, d as rateToNumber, i as crossRate, l as rateFromRow, n as RATE_REF, o as rate, r as checkRate, s as rateEquals, t as RATE_BOUNDS, u as rateToDecimal } from "./rate-DicStBue.js";
|
|
6
|
+
import { n as retailUnits, r as roundRetail, t as priceRoundingParams } from "./retail-1mu888J1.js";
|
|
7
7
|
//#region src/fx/convert.ts
|
|
8
8
|
const infoOf = (code) => resolveCurrency(code, { allowHistoric: true });
|
|
9
9
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_money = require("./money-
|
|
3
|
-
const require_rounding = require("./rounding-
|
|
4
|
-
const require_allocate = require("./allocate-
|
|
5
|
-
const require_arithmetic = require("./arithmetic-
|
|
2
|
+
const require_money = require("./money-B3wH_Z4S.cjs");
|
|
3
|
+
const require_rounding = require("./rounding-DHBtNCHG.cjs");
|
|
4
|
+
const require_allocate = require("./allocate-CZRg4TOP.cjs");
|
|
5
|
+
const require_arithmetic = require("./arithmetic-DjT4Kzgt.cjs");
|
|
6
6
|
const require_own = require("./own-oP9DXFWv.cjs");
|
|
7
|
-
const require_format = require("./format-
|
|
8
|
-
const require_iso_minor = require("./iso-minor
|
|
9
|
-
const require_medusa = require("./medusa-
|
|
7
|
+
const require_format = require("./format-DLhno7eX.cjs");
|
|
8
|
+
const require_iso_minor = require("./iso-minor-wSwJN57T.cjs");
|
|
9
|
+
const require_medusa = require("./medusa-lRY9xlsf.cjs");
|
|
10
10
|
//#region src/data/countries.ts
|
|
11
11
|
const COUNTRY_CURRENCY = {
|
|
12
12
|
AC: "SHP",
|
|
@@ -291,6 +291,7 @@ exports.currencySymbol = require_money.currencySymbol;
|
|
|
291
291
|
exports.decimalClamp = require_money.decimalClamp;
|
|
292
292
|
exports.decimalCompare = require_money.decimalCompare;
|
|
293
293
|
exports.decimalDivide = require_money.decimalDivide;
|
|
294
|
+
exports.decimalEquals = require_money.decimalEquals;
|
|
294
295
|
exports.decimalMultiply = require_money.decimalMultiply;
|
|
295
296
|
exports.decimalRound = require_money.decimalRound;
|
|
296
297
|
exports.decimalSubtract = require_money.decimalSubtract;
|
|
@@ -305,6 +306,7 @@ exports.firstCurrency = require_money.firstCurrency;
|
|
|
305
306
|
exports.formatMoney = require_format.formatMoney;
|
|
306
307
|
exports.formatMoneyCompact = require_format.formatMoneyCompact;
|
|
307
308
|
exports.formatMoneyRange = require_format.formatMoneyRange;
|
|
309
|
+
exports.formatStored = require_format.formatStored;
|
|
308
310
|
exports.fromIsoMinor = require_iso_minor.fromIsoMinor;
|
|
309
311
|
exports.fromMajor = require_money.fromMajor;
|
|
310
312
|
exports.isCurrencyCode = require_money.isCurrencyCode;
|
|
@@ -331,6 +333,7 @@ exports.readCalculatedPrice = require_medusa.readCalculatedPrice;
|
|
|
331
333
|
exports.readStored = require_money.readStored;
|
|
332
334
|
exports.readStoredDecimal = require_medusa.readStoredDecimal;
|
|
333
335
|
exports.readStoredField = require_medusa.readStoredField;
|
|
336
|
+
exports.readStoredLiteral = require_medusa.readStoredLiteral;
|
|
334
337
|
exports.remaining = require_arithmetic.remaining;
|
|
335
338
|
exports.roundMajor = require_rounding.roundMajor;
|
|
336
339
|
exports.roundToUnit = require_rounding.roundToUnit;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { a as isPositiveAmount, c as readCalculatedPrice, d as
|
|
1
|
+
import { A as isCurrencyCode, C as currencyInfo, D as currencySymbol, E as currencyOptions, F as sameCurrency, I as storageDigits, L as storageScale, M as medusaCurrencyCode, N as medusaEpsilon, O as displayDigits, P as parseCurrencyCode, R as DecimalText, S as currencyCode, T as currencyName, _ as CurrencyCodeOptions, a as ReadStoredOptions, b as FractionDigits, c as ToMajorDecimalOptions, d as money, f as readStored, g as CurrencyCode, h as CURRENCIES, i as Money, j as localeForCurrency, k as firstCurrency, l as fromMajor, m as toMajorNumber, n as FromMajorOptions, o as StoredAmount, p as toMajorDecimal, r as MajorDecimal, s as StoredAmountOptions, t as FractionalMoney, u as isStoredAmount, v as CurrencyInfo, w as currencyLabel, x as StorageScale, y as CurrencyStatus, z as RoundingMode } from "./money-B-3aFjNJ.cjs";
|
|
2
|
+
import { a as isPositiveAmount, c as readCalculatedPrice, d as readStoredLiteral, f as toMedusaAmountInput, i as ReadStoredDecimalOptions, l as readStoredDecimal, n as MoneyByCurrency, o as moneyByCurrency, p as toMedusaRaw, r as PriceLike, s as moneyFor, t as MedusaRaw, u as readStoredField } from "./medusa-4K8N1pUc.cjs";
|
|
3
3
|
//#region src/allocate.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Where the rounding remainder goes:
|
|
@@ -190,6 +190,12 @@ export declare function decimalRound(a: DecimalText | string | number, options:
|
|
|
190
190
|
}): DecimalText;
|
|
191
191
|
/** `-1`, `0` or `1` as `a` is below, equal to or above `b`. */
|
|
192
192
|
export declare function decimalCompare(a: DecimalText | string, b: DecimalText | string): -1 | 0 | 1;
|
|
193
|
+
/**
|
|
194
|
+
* Whether `a` and `b` are the same decimal, exactly (`'43.0'` equals `'43.00'` and `43`). Takes what
|
|
195
|
+
* `decimalCompare` takes, but never throws: anything that is not plain decimal text, a finite number
|
|
196
|
+
* or a bigint is never equal, not even to itself.
|
|
197
|
+
*/
|
|
198
|
+
export declare function decimalEquals(a: unknown, b: unknown): boolean;
|
|
193
199
|
/** `a` limited to `[min, max]` (either bound optional). `min` above `max` throws `amount_invalid`. */
|
|
194
200
|
export declare function decimalClamp(a: DecimalText | string, bounds: {
|
|
195
201
|
min?: DecimalText | string;
|
|
@@ -249,6 +255,12 @@ interface FormatMoneyOptions {
|
|
|
249
255
|
* pass. If Intl throws, `'<CODE> <decimal>'`.
|
|
250
256
|
*/
|
|
251
257
|
export declare function formatMoney(m: Money, options?: FormatMoneyOptions): string;
|
|
258
|
+
/**
|
|
259
|
+
* A stored amount that may be fractional (a Medusa total, 107.8175; a percentage promotion) for
|
|
260
|
+
* people: rounded half-up to a whole storage unit (`roundToUnit`), then `formatMoney` with `options`.
|
|
261
|
+
* A number must be finite; text is plain decimal; an unknown currency throws `currency_invalid`.
|
|
262
|
+
*/
|
|
263
|
+
export declare function formatStored(amount: number | DecimalText, currency: string, options?: FormatMoneyOptions): string;
|
|
252
264
|
/**
|
|
253
265
|
* Like `formatMoney` below `threshold` major units (default 10000, by magnitude); at or above
|
|
254
266
|
* it, compact short notation with `maximumSignificantDigits` (default 3): `'$12.3K'`.
|
|
@@ -285,4 +297,4 @@ export declare function fromIsoMinor(value: number | string, currency: string, o
|
|
|
285
297
|
digits?: FractionDigits;
|
|
286
298
|
}): Money;
|
|
287
299
|
//#endregion
|
|
288
|
-
export { type AllocateOptions, type AllocationStrategy, type AllocationWeight, type AmountUnit, CURRENCIES, type CurrencyCode, type CurrencyCodeOptions, type CurrencyInfo, type CurrencyStatus, type DecimalInput, type DecimalText, type FormatMoneyOptions, type FractionDigits, type FromMajorOptions, type MajorDecimal, type MedusaRaw, type Money, type MoneyByCurrency, type MoneyErrorCode, type MoneyErrorOptions, type PriceLike, type Ratio, type ReadStoredDecimalOptions, type ReadStoredOptions, type RoundToUnitOptions, type RoundingMode, type StorageScale, type StoredAmount, type StoredAmountOptions, type ToMajorDecimalOptions, type UnitPricePart, type WaterfallResult, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, displayDigits, firstCurrency, fromMajor, isCurrencyCode, isPositiveAmount, isStoredAmount, localeForCurrency, medusaCurrencyCode, medusaEpsilon, money, moneyByCurrency, moneyFor, parseCurrencyCode, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, sameCurrency, storageDigits, storageScale, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw };
|
|
300
|
+
export { type AllocateOptions, type AllocationStrategy, type AllocationWeight, type AmountUnit, CURRENCIES, type CurrencyCode, type CurrencyCodeOptions, type CurrencyInfo, type CurrencyStatus, type DecimalInput, type DecimalText, type FormatMoneyOptions, type FractionDigits, type FractionalMoney, type FromMajorOptions, type MajorDecimal, type MedusaRaw, type Money, type MoneyByCurrency, type MoneyErrorCode, type MoneyErrorOptions, type PriceLike, type Ratio, type ReadStoredDecimalOptions, type ReadStoredOptions, type RoundToUnitOptions, type RoundingMode, type StorageScale, type StoredAmount, type StoredAmountOptions, type ToMajorDecimalOptions, type UnitPricePart, type WaterfallResult, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, displayDigits, firstCurrency, fromMajor, isCurrencyCode, isPositiveAmount, isStoredAmount, localeForCurrency, medusaCurrencyCode, medusaEpsilon, money, moneyByCurrency, moneyFor, parseCurrencyCode, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, readStoredLiteral, sameCurrency, storageDigits, storageScale, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { a as isPositiveAmount, c as readCalculatedPrice, d as
|
|
1
|
+
import { A as isCurrencyCode, C as currencyInfo, D as currencySymbol, E as currencyOptions, F as sameCurrency, I as storageDigits, L as storageScale, M as medusaCurrencyCode, N as medusaEpsilon, O as displayDigits, P as parseCurrencyCode, R as DecimalText, S as currencyCode, T as currencyName, _ as CurrencyCodeOptions, a as ReadStoredOptions, b as FractionDigits, c as ToMajorDecimalOptions, d as money, f as readStored, g as CurrencyCode, h as CURRENCIES, i as Money, j as localeForCurrency, k as firstCurrency, l as fromMajor, m as toMajorNumber, n as FromMajorOptions, o as StoredAmount, p as toMajorDecimal, r as MajorDecimal, s as StoredAmountOptions, t as FractionalMoney, u as isStoredAmount, v as CurrencyInfo, w as currencyLabel, x as StorageScale, y as CurrencyStatus, z as RoundingMode } from "./money-B-3aFjNJ.js";
|
|
2
|
+
import { a as isPositiveAmount, c as readCalculatedPrice, d as readStoredLiteral, f as toMedusaAmountInput, i as ReadStoredDecimalOptions, l as readStoredDecimal, n as MoneyByCurrency, o as moneyByCurrency, p as toMedusaRaw, r as PriceLike, s as moneyFor, t as MedusaRaw, u as readStoredField } from "./medusa-DBXJXXvF.js";
|
|
3
3
|
//#region src/allocate.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Where the rounding remainder goes:
|
|
@@ -190,6 +190,12 @@ export declare function decimalRound(a: DecimalText | string | number, options:
|
|
|
190
190
|
}): DecimalText;
|
|
191
191
|
/** `-1`, `0` or `1` as `a` is below, equal to or above `b`. */
|
|
192
192
|
export declare function decimalCompare(a: DecimalText | string, b: DecimalText | string): -1 | 0 | 1;
|
|
193
|
+
/**
|
|
194
|
+
* Whether `a` and `b` are the same decimal, exactly (`'43.0'` equals `'43.00'` and `43`). Takes what
|
|
195
|
+
* `decimalCompare` takes, but never throws: anything that is not plain decimal text, a finite number
|
|
196
|
+
* or a bigint is never equal, not even to itself.
|
|
197
|
+
*/
|
|
198
|
+
export declare function decimalEquals(a: unknown, b: unknown): boolean;
|
|
193
199
|
/** `a` limited to `[min, max]` (either bound optional). `min` above `max` throws `amount_invalid`. */
|
|
194
200
|
export declare function decimalClamp(a: DecimalText | string, bounds: {
|
|
195
201
|
min?: DecimalText | string;
|
|
@@ -249,6 +255,12 @@ interface FormatMoneyOptions {
|
|
|
249
255
|
* pass. If Intl throws, `'<CODE> <decimal>'`.
|
|
250
256
|
*/
|
|
251
257
|
export declare function formatMoney(m: Money, options?: FormatMoneyOptions): string;
|
|
258
|
+
/**
|
|
259
|
+
* A stored amount that may be fractional (a Medusa total, 107.8175; a percentage promotion) for
|
|
260
|
+
* people: rounded half-up to a whole storage unit (`roundToUnit`), then `formatMoney` with `options`.
|
|
261
|
+
* A number must be finite; text is plain decimal; an unknown currency throws `currency_invalid`.
|
|
262
|
+
*/
|
|
263
|
+
export declare function formatStored(amount: number | DecimalText, currency: string, options?: FormatMoneyOptions): string;
|
|
252
264
|
/**
|
|
253
265
|
* Like `formatMoney` below `threshold` major units (default 10000, by magnitude); at or above
|
|
254
266
|
* it, compact short notation with `maximumSignificantDigits` (default 3): `'$12.3K'`.
|
|
@@ -285,4 +297,4 @@ export declare function fromIsoMinor(value: number | string, currency: string, o
|
|
|
285
297
|
digits?: FractionDigits;
|
|
286
298
|
}): Money;
|
|
287
299
|
//#endregion
|
|
288
|
-
export { type AllocateOptions, type AllocationStrategy, type AllocationWeight, type AmountUnit, CURRENCIES, type CurrencyCode, type CurrencyCodeOptions, type CurrencyInfo, type CurrencyStatus, type DecimalInput, type DecimalText, type FormatMoneyOptions, type FractionDigits, type FromMajorOptions, type MajorDecimal, type MedusaRaw, type Money, type MoneyByCurrency, type MoneyErrorCode, type MoneyErrorOptions, type PriceLike, type Ratio, type ReadStoredDecimalOptions, type ReadStoredOptions, type RoundToUnitOptions, type RoundingMode, type StorageScale, type StoredAmount, type StoredAmountOptions, type ToMajorDecimalOptions, type UnitPricePart, type WaterfallResult, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, displayDigits, firstCurrency, fromMajor, isCurrencyCode, isPositiveAmount, isStoredAmount, localeForCurrency, medusaCurrencyCode, medusaEpsilon, money, moneyByCurrency, moneyFor, parseCurrencyCode, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, sameCurrency, storageDigits, storageScale, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw };
|
|
300
|
+
export { type AllocateOptions, type AllocationStrategy, type AllocationWeight, type AmountUnit, CURRENCIES, type CurrencyCode, type CurrencyCodeOptions, type CurrencyInfo, type CurrencyStatus, type DecimalInput, type DecimalText, type FormatMoneyOptions, type FractionDigits, type FractionalMoney, type FromMajorOptions, type MajorDecimal, type MedusaRaw, type Money, type MoneyByCurrency, type MoneyErrorCode, type MoneyErrorOptions, type PriceLike, type Ratio, type ReadStoredDecimalOptions, type ReadStoredOptions, type RoundToUnitOptions, type RoundingMode, type StorageScale, type StoredAmount, type StoredAmountOptions, type ToMajorDecimalOptions, type UnitPricePart, type WaterfallResult, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, displayDigits, firstCurrency, fromMajor, isCurrencyCode, isPositiveAmount, isStoredAmount, localeForCurrency, medusaCurrencyCode, medusaEpsilon, money, moneyByCurrency, moneyFor, parseCurrencyCode, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, readStoredLiteral, sameCurrency, storageDigits, storageScale, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as storageScale,
|
|
2
|
-
import { i as roundToUnit, n as roundMajor } from "./rounding-
|
|
3
|
-
import { i as splitUnitPrice, r as allocateWaterfall, t as allocate } from "./allocate-
|
|
4
|
-
import { _ as within, a as equals, c as isPositive, d as min, f as multiply, g as sum, h as subtract, i as divide, l as isZero, m as remaining, n as clamp, o as excessOver, p as percentOf, r as compare, s as isNegative, t as add, u as max } from "./arithmetic-
|
|
1
|
+
import { A as storageScale, C as medusaCurrencyCode, D as sameCurrency, F as decimalClamp, G as isDecimalLiteral, H as decimalSubtract, I as decimalCompare, K as parseDecimalText, L as decimalDivide, O as storageDigits, P as assertDecimalLiteral, Q as MoneyError, R as decimalEquals, S as localeForCurrency, T as parseCurrencyCode, U as decimalSum, V as decimalRound, W as decimalWithin, _ as currencySymbol, a as money, b as firstCurrency, c as toMajorDecimal, d as currencyCode, f as currencyInfo, g as currencyOptions, h as currencyName, l as toMajorNumber, n as fromMajor, o as readStored, p as currencyLabel, q as trimDecimalZeros, r as isStoredAmount, u as CURRENCIES, v as displayDigits, w as medusaEpsilon, x as isCurrencyCode, z as decimalMultiply } from "./money-WhnGiI00.js";
|
|
2
|
+
import { i as roundToUnit, n as roundMajor } from "./rounding-g9rvye0k.js";
|
|
3
|
+
import { i as splitUnitPrice, r as allocateWaterfall, t as allocate } from "./allocate-X7_jAtOj.js";
|
|
4
|
+
import { _ as within, a as equals, c as isPositive, d as min, f as multiply, g as sum, h as subtract, i as divide, l as isZero, m as remaining, n as clamp, o as excessOver, p as percentOf, r as compare, s as isNegative, t as add, u as max } from "./arithmetic-BhNwisjb.js";
|
|
5
5
|
import { t as hasOwnKey } from "./own-D7544D3k.js";
|
|
6
|
-
import {
|
|
7
|
-
import { r as toIsoMinor, t as fromIsoMinor } from "./iso-minor-
|
|
8
|
-
import { a as readStoredDecimal,
|
|
6
|
+
import { a as moneyAxisFormatter, i as formatStored, n as formatMoneyCompact, r as formatMoneyRange, t as formatMoney } from "./format-BdPnijvn.js";
|
|
7
|
+
import { r as toIsoMinor, t as fromIsoMinor } from "./iso-minor-CqkWDxHS.js";
|
|
8
|
+
import { a as readStoredDecimal, i as readCalculatedPrice, l as toMedusaAmountInput, n as moneyByCurrency, o as readStoredField, r as moneyFor, s as readStoredLiteral, t as isPositiveAmount, u as toMedusaRaw } from "./medusa-DqJY1qpj.js";
|
|
9
9
|
//#region src/data/countries.ts
|
|
10
10
|
const COUNTRY_CURRENCY = {
|
|
11
11
|
AC: "SHP",
|
|
@@ -273,4 +273,4 @@ function defaultCurrencyForCountry(country) {
|
|
|
273
273
|
return hasOwnKey(COUNTRY_CURRENCY, key) ? COUNTRY_CURRENCY[key] : null;
|
|
274
274
|
}
|
|
275
275
|
//#endregion
|
|
276
|
-
export { CURRENCIES, MoneyError, add, allocate, allocateWaterfall, assertDecimalLiteral, clamp, compare, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, decimalClamp, decimalCompare, decimalDivide, decimalMultiply, decimalRound, decimalSubtract, decimalSum, decimalWithin, defaultCurrencyForCountry, displayDigits, divide, equals, excessOver, firstCurrency, formatMoney, formatMoneyCompact, formatMoneyRange, fromIsoMinor, fromMajor, isCurrencyCode, isDecimalLiteral, isNegative, isPositive, isPositiveAmount, isStoredAmount, isZero, localeForCurrency, max, medusaCurrencyCode, medusaEpsilon, min, money, moneyAxisFormatter, moneyByCurrency, moneyFor, multiply, parseCurrencyCode, parseDecimalText, percentOf, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, remaining, roundMajor, roundToUnit, sameCurrency, splitUnitPrice, storageDigits, storageScale, subtract, sum, toIsoMinor, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw, trimDecimalZeros, within };
|
|
276
|
+
export { CURRENCIES, MoneyError, add, allocate, allocateWaterfall, assertDecimalLiteral, clamp, compare, currencyCode, currencyInfo, currencyLabel, currencyName, currencyOptions, currencySymbol, decimalClamp, decimalCompare, decimalDivide, decimalEquals, decimalMultiply, decimalRound, decimalSubtract, decimalSum, decimalWithin, defaultCurrencyForCountry, displayDigits, divide, equals, excessOver, firstCurrency, formatMoney, formatMoneyCompact, formatMoneyRange, formatStored, fromIsoMinor, fromMajor, isCurrencyCode, isDecimalLiteral, isNegative, isPositive, isPositiveAmount, isStoredAmount, isZero, localeForCurrency, max, medusaCurrencyCode, medusaEpsilon, min, money, moneyAxisFormatter, moneyByCurrency, moneyFor, multiply, parseCurrencyCode, parseDecimalText, percentOf, readCalculatedPrice, readStored, readStoredDecimal, readStoredField, readStoredLiteral, remaining, roundMajor, roundToUnit, sameCurrency, splitUnitPrice, storageDigits, storageScale, subtract, sum, toIsoMinor, toMajorDecimal, toMajorNumber, toMedusaAmountInput, toMedusaRaw, trimDecimalZeros, within };
|
package/dist/input.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_money = require("./money-
|
|
3
|
-
const require_number_text = require("./number-text-
|
|
4
|
-
const require_rate = require("./rate-
|
|
5
|
-
const require_amount = require("./amount-
|
|
2
|
+
const require_money = require("./money-B3wH_Z4S.cjs");
|
|
3
|
+
const require_number_text = require("./number-text-BWu67jUq.cjs");
|
|
4
|
+
const require_rate = require("./rate-CVeMii4a.cjs");
|
|
5
|
+
const require_amount = require("./amount-BV0O-aN8.cjs");
|
|
6
6
|
//#region src/input/import.ts
|
|
7
7
|
/**
|
|
8
8
|
* Amount text from a file or a third party to canonical DecimalText (major units, exactly as
|
package/dist/input.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as Rate } from "./rate-
|
|
1
|
+
import { R as DecimalText, b as FractionDigits, i as Money } from "./money-B-3aFjNJ.cjs";
|
|
2
|
+
import { r as Rate } from "./rate-tqK8ijG0.cjs";
|
|
3
3
|
//#region src/input/amount.d.ts
|
|
4
4
|
/** Why typed text is not an acceptable amount. */
|
|
5
5
|
type ParseFailureReason = 'empty' | 'unparseable' | 'too_many_decimals' | 'negative' | 'zero' | 'below_min' | 'above_max';
|