monetra 2.0.0 → 2.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.
Files changed (59) hide show
  1. package/README.md +177 -160
  2. package/dist/currency/Currency.d.ts +27 -0
  3. package/dist/currency/index.d.ts +4 -0
  4. package/dist/currency/iso4217.d.ts +245 -0
  5. package/dist/currency/precision.d.ts +2 -0
  6. package/dist/currency/registry.d.ts +22 -0
  7. package/dist/errors/BaseError.d.ts +22 -0
  8. package/dist/errors/CurrencyMismatchError.d.ts +12 -0
  9. package/dist/errors/InsufficientFundsError.d.ts +4 -0
  10. package/dist/errors/InvalidArgumentError.d.ts +4 -0
  11. package/dist/errors/InvalidPrecisionError.d.ts +4 -0
  12. package/dist/errors/OverflowError.d.ts +4 -0
  13. package/dist/errors/RoundingRequiredError.d.ts +4 -0
  14. package/dist/errors/index.d.ts +7 -0
  15. package/dist/financial/compound.d.ts +20 -0
  16. package/dist/financial/depreciation.d.ts +30 -0
  17. package/dist/financial/index.d.ts +7 -0
  18. package/dist/financial/index.js +1323 -0
  19. package/dist/financial/index.js.map +1 -0
  20. package/dist/financial/index.mjs +1275 -0
  21. package/dist/financial/index.mjs.map +1 -0
  22. package/dist/financial/investment.d.ts +31 -0
  23. package/dist/financial/leverage.d.ts +66 -0
  24. package/dist/financial/loan.d.ts +67 -0
  25. package/dist/financial/rate.d.ts +169 -0
  26. package/dist/financial/simple.d.ts +60 -0
  27. package/dist/format/formatter.d.ts +42 -0
  28. package/dist/format/parser.d.ts +53 -0
  29. package/dist/index.d.ts +11 -1202
  30. package/dist/index.js +263 -41
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +248 -41
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/ledger/Ledger.d.ts +65 -0
  35. package/dist/ledger/index.d.ts +3 -0
  36. package/dist/ledger/index.js +1054 -0
  37. package/dist/ledger/index.js.map +1 -0
  38. package/dist/ledger/index.mjs +1029 -0
  39. package/dist/ledger/index.mjs.map +1 -0
  40. package/dist/ledger/types.d.ts +30 -0
  41. package/dist/ledger/verification.d.ts +36 -0
  42. package/dist/money/Converter.d.ts +26 -0
  43. package/dist/money/Money.d.ts +299 -0
  44. package/dist/money/MoneyBag.d.ts +46 -0
  45. package/dist/money/allocation.d.ts +13 -0
  46. package/dist/money/arithmetic.d.ts +32 -0
  47. package/dist/money/guards.d.ts +3 -0
  48. package/dist/money/index.d.ts +4 -0
  49. package/dist/rounding/index.d.ts +3 -0
  50. package/dist/rounding/strategies.d.ts +36 -0
  51. package/dist/tokens/defineToken.d.ts +30 -0
  52. package/dist/tokens/index.d.ts +2 -0
  53. package/dist/tokens/index.js +100 -0
  54. package/dist/tokens/index.js.map +1 -0
  55. package/dist/tokens/index.mjs +69 -0
  56. package/dist/tokens/index.mjs.map +1 -0
  57. package/dist/tokens/types.d.ts +13 -0
  58. package/package.json +34 -14
  59. package/dist/index.d.mts +0 -1211
@@ -0,0 +1,53 @@
1
+ import { Currency } from "../currency/Currency";
2
+ /**
3
+ * Options for locale-aware parsing.
4
+ */
5
+ export interface LocaleParseOptions {
6
+ /**
7
+ * The locale to use for parsing (e.g., "en-US", "de-DE").
8
+ * Used to detect decimal and grouping separators.
9
+ */
10
+ locale: string;
11
+ }
12
+ /**
13
+ * Parses a locale-formatted string into a normalized decimal string.
14
+ *
15
+ * Handles locale-specific decimal separators (e.g., comma in German "1.234,56")
16
+ * and grouping separators (e.g., period in German "1.234").
17
+ *
18
+ * @param amount - The locale-formatted amount string (e.g., "1,234.56" or "1.234,56").
19
+ * @param options - The locale options.
20
+ * @returns A normalized decimal string (e.g., "1234.56").
21
+ * @example
22
+ * parseLocaleString("1.234,56", { locale: "de-DE" }); // "1234.56"
23
+ * parseLocaleString("1,234.56", { locale: "en-US" }); // "1234.56"
24
+ */
25
+ export declare function parseLocaleString(amount: string, options: LocaleParseOptions): string;
26
+ /**
27
+ * Parses a locale-formatted amount string and converts it to Money minor units.
28
+ *
29
+ * This is a convenience function that combines locale parsing with currency validation.
30
+ *
31
+ * @param amount - The locale-formatted amount string.
32
+ * @param currency - The currency to validate against.
33
+ * @param options - The locale options.
34
+ * @returns The amount in minor units as a BigInt.
35
+ * @throws {InvalidPrecisionError} If the precision exceeds the currency's decimals.
36
+ * @example
37
+ * parseLocaleToMinor("1.234,56", EUR, { locale: "de-DE" }); // 123456n
38
+ */
39
+ export declare function parseLocaleToMinor(amount: string, currency: Currency, options: LocaleParseOptions): bigint;
40
+ /**
41
+ * Parses a string representation of a major unit amount into minor units.
42
+ *
43
+ * Validates the input format to ensure it is a valid decimal number without
44
+ * scientific notation or ambiguous characters. Checks that the precision
45
+ * does not exceed the currency's allowed decimals.
46
+ *
47
+ * @param amount - The amount string (e.g., "10.50").
48
+ * @param currency - The currency to validate against.
49
+ * @returns The amount in minor units as a BigInt.
50
+ * @throws {Error} If the format is invalid (scientific notation, non-numeric chars).
51
+ * @throws {InvalidPrecisionError} If the precision exceeds the currency's decimals.
52
+ */
53
+ export declare function parseToMinor(amount: string, currency: Currency): bigint;