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,65 @@
1
+ import { Money } from "../money/Money";
2
+ import { Currency } from "../currency/Currency";
3
+ import { Entry, TransactionMetadata, LedgerSnapshot, TransactionType } from "./types";
4
+ export declare class Ledger {
5
+ private entries;
6
+ private currency;
7
+ constructor(currency: string | Currency);
8
+ /**
9
+ * Records a transaction in the ledger.
10
+ * Returns the created entry for reference.
11
+ * Note: This is the synchronous version for Node.js. Use recordAsync for browser support.
12
+ */
13
+ record(money: Money, metadata: TransactionMetadata): Entry;
14
+ /**
15
+ * Records a transaction in the ledger (async version for browser support).
16
+ * Returns the created entry for reference.
17
+ */
18
+ recordAsync(money: Money, metadata: TransactionMetadata): Promise<Entry>;
19
+ /**
20
+ * Gets the current balance.
21
+ */
22
+ getBalance(): Money;
23
+ /**
24
+ * Returns the complete transaction history.
25
+ */
26
+ getHistory(): ReadonlyArray<Entry>;
27
+ /**
28
+ * Filters entries by criteria.
29
+ */
30
+ query(filter: {
31
+ type?: TransactionType | TransactionType[];
32
+ from?: Date;
33
+ to?: Date;
34
+ reference?: string;
35
+ minAmount?: Money;
36
+ maxAmount?: Money;
37
+ tags?: string[];
38
+ }): Entry[];
39
+ /**
40
+ * Verifies the integrity of the ledger using hash chain (sync version).
41
+ * @returns true if all hashes are valid and chain is unbroken.
42
+ */
43
+ verify(): boolean;
44
+ /**
45
+ * Verifies the integrity of the ledger using hash chain (async version for browsers).
46
+ * @returns Promise resolving to true if all hashes are valid and chain is unbroken.
47
+ */
48
+ verifyAsync(): Promise<boolean>;
49
+ /**
50
+ * Exports a snapshot for backup/audit purposes (sync version).
51
+ */
52
+ snapshot(): LedgerSnapshot;
53
+ /**
54
+ * Exports a snapshot for backup/audit purposes (async version for browsers).
55
+ */
56
+ snapshotAsync(): Promise<LedgerSnapshot>;
57
+ /**
58
+ * Restores from a snapshot (sync version).
59
+ */
60
+ static fromSnapshot(snapshot: LedgerSnapshot): Ledger;
61
+ /**
62
+ * Restores from a snapshot (async version for browsers).
63
+ */
64
+ static fromSnapshotAsync(snapshot: LedgerSnapshot): Promise<Ledger>;
65
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./Ledger";
2
+ export * from "./types";
3
+ export * from "./verification";