@hisaabo/cli 0.7.5 → 0.8.4

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 (210) hide show
  1. package/LICENSE +31 -0
  2. package/README.md +9 -0
  3. package/dist/bin/{audit-trail-DLSSSM4T.js → audit-trail-IJ6SKACR.js} +2 -2
  4. package/dist/bin/{categories-63QR6WCV.js → categories-O6TODPAH.js} +2 -2
  5. package/dist/bin/{check-slug-NXO55WKH.js → check-slug-P7RFU6OP.js} +2 -2
  6. package/dist/bin/chunk-NO4FIFMS.js +0 -0
  7. package/dist/bin/{chunk-7MJDOL6B.js → chunk-QUITS2FE.js} +28 -0
  8. package/dist/bin/{chunk-M42SETRZ.js → chunk-WDN7RIE3.js} +23 -2
  9. package/dist/bin/chunk-ZPYC767N.js +0 -0
  10. package/dist/bin/{client-T32CIZA3.js → client-36JX5MR3.js} +1 -1
  11. package/dist/bin/{collection-efficiency-T6PWNTZO.js → collection-efficiency-DA5RWG3V.js} +2 -2
  12. package/dist/bin/{config-V4QFCONN.js → config-4LLNT4SH.js} +3 -1
  13. package/dist/bin/{create-NUKHDWLK.js → create-C5INBPQO.js} +2 -2
  14. package/dist/bin/{default-account-JWFPHMRF.js → default-account-2GMQ7ZA4.js} +2 -2
  15. package/dist/bin/{expenses-2UWUZVLI.js → expenses-S2YVA5UT.js} +2 -2
  16. package/dist/bin/{export-XSX7WQH7.js → export-YOOODNVX.js} +2 -2
  17. package/dist/bin/export-ZA43MLWO.js +191 -0
  18. package/dist/bin/{factory-BWOKRIP4.js → factory-6MUCSXTL.js} +2 -2
  19. package/dist/bin/{get-CHNTG3IM.js → get-GMQRROK2.js} +2 -2
  20. package/dist/bin/{get-ZSZ6SL3N.js → get-ZV3SC2VY.js} +2 -2
  21. package/dist/bin/hisaabo.js +100 -57
  22. package/dist/bin/import-UUHMLCKX.js +267 -0
  23. package/dist/bin/{invitations-H2SL3XAD.js → invitations-OVORTTMF.js} +2 -2
  24. package/dist/bin/{invite-EW73UIBE.js → invite-GGHBZY4U.js} +2 -2
  25. package/dist/bin/{invoice-breakdown-XP4QATCF.js → invoice-breakdown-32XXAZDP.js} +2 -2
  26. package/dist/bin/{items-DPD6EFTP.js → items-6NOIMH6B.js} +2 -2
  27. package/dist/bin/{items-toggle-R4OPSE4W.js → items-toggle-L6W6QKQD.js} +2 -2
  28. package/dist/bin/{list-PKHBE475.js → list-FC5JHKHD.js} +2 -2
  29. package/dist/bin/{list-KLEHBMQ2.js → list-OXAVDXH7.js} +2 -2
  30. package/dist/bin/{list-UR7OOJVF.js → list-RAR56EMQ.js} +2 -2
  31. package/dist/bin/{members-XA3TF4IQ.js → members-Y6XJVHHR.js} +2 -2
  32. package/dist/bin/{monthly-comparison-OLVS5HEY.js → monthly-comparison-IAUZ6SBJ.js} +2 -2
  33. package/dist/bin/{order-cancel-MXMJFFRR.js → order-cancel-QRTCNART.js} +2 -2
  34. package/dist/bin/{order-confirm-IXU45Q4L.js → order-confirm-LGQOMC4O.js} +2 -2
  35. package/dist/bin/{order-get-RDXMHLJ7.js → order-get-4XAQCRYV.js} +2 -2
  36. package/dist/bin/{order-update-KGIPBEJX.js → order-update-KZY4H2UR.js} +2 -2
  37. package/dist/bin/output-NUOL7KJW.js +0 -0
  38. package/dist/bin/{payment-modes-CZL35SVS.js → payment-modes-DY2ZEMK7.js} +2 -2
  39. package/dist/bin/{profit-loss-M332OSC5.js → profit-loss-5GJBG3PL.js} +2 -2
  40. package/dist/bin/{receivables-aging-OXRHGMBF.js → receivables-aging-6A7XJKDT.js} +2 -2
  41. package/dist/bin/{remove-I5HD2Y4K.js → remove-ZBX34TIQ.js} +2 -2
  42. package/dist/bin/{revoke-OC6AOMIZ.js → revoke-XDNOA2GJ.js} +2 -2
  43. package/dist/bin/{revoke-MFLWGCMP.js → revoke-ZTAMW2Q2.js} +2 -2
  44. package/dist/bin/{revoke-all-FSAPBB3P.js → revoke-all-365NRBOA.js} +2 -2
  45. package/dist/bin/{revoke-invitation-JXDPXTOW.js → revoke-invitation-PQH7XNYA.js} +2 -2
  46. package/dist/bin/{sales-trend-KK63WNDL.js → sales-trend-D6PQ7MHY.js} +2 -2
  47. package/dist/bin/{sequence-IQ4HUJ3W.js → sequence-KZWADVD7.js} +2 -2
  48. package/dist/bin/{store-6QT6HKG2.js → store-SVRZBUFO.js} +2 -2
  49. package/dist/bin/{summary-3FTF5B4A.js → summary-H6U7O5GJ.js} +2 -2
  50. package/dist/bin/{top-customers-HNYGXBQZ.js → top-customers-ATBN6RDI.js} +2 -2
  51. package/dist/bin/{top-items-JUDG3BVW.js → top-items-XXU6KYTC.js} +2 -2
  52. package/dist/bin/{top-outstanding-WK26ZNE5.js → top-outstanding-JTQNGGW4.js} +2 -2
  53. package/dist/bin/{unpaid-invoices-RYFIIIK7.js → unpaid-invoices-BTNQFWCH.js} +2 -2
  54. package/dist/bin/{untracked-FAFS3KCK.js → untracked-PAMEDJ6Y.js} +2 -2
  55. package/dist/bin/{update-5YSPXIWO.js → update-6ZMX2OYX.js} +2 -2
  56. package/dist/bin/{update-I46XLU77.js → update-EGHPFXLK.js} +2 -2
  57. package/dist/bin/{update-NAW2JWZS.js → update-EK4NJWU4.js} +2 -2
  58. package/dist/bin/{update-role-5GV42MSN.js → update-role-24PDTNFK.js} +2 -2
  59. package/dist/bin/{update-settings-KYSQDIEO.js → update-settings-AASI6WZX.js} +2 -2
  60. package/package.json +35 -9
  61. package/.turbo/turbo-build.log +0 -13
  62. package/.turbo/turbo-typecheck.log +0 -4
  63. package/CLI-UX-ARCHITECTURE.md +0 -1269
  64. package/src/auth.ts +0 -221
  65. package/src/bin/hisaabo.ts +0 -74
  66. package/src/bin/registrars/api-key.ts +0 -44
  67. package/src/bin/registrars/auth.ts +0 -222
  68. package/src/bin/registrars/automated-invoice.ts +0 -167
  69. package/src/bin/registrars/bank-recon.ts +0 -34
  70. package/src/bin/registrars/bank.ts +0 -124
  71. package/src/bin/registrars/business.ts +0 -120
  72. package/src/bin/registrars/dashboard.ts +0 -225
  73. package/src/bin/registrars/document.ts +0 -184
  74. package/src/bin/registrars/einvoice.ts +0 -46
  75. package/src/bin/registrars/ewb.ts +0 -37
  76. package/src/bin/registrars/expense.ts +0 -87
  77. package/src/bin/registrars/gst.ts +0 -57
  78. package/src/bin/registrars/import.ts +0 -49
  79. package/src/bin/registrars/invoice.ts +0 -117
  80. package/src/bin/registrars/itc.ts +0 -56
  81. package/src/bin/registrars/item.ts +0 -112
  82. package/src/bin/registrars/journal.ts +0 -47
  83. package/src/bin/registrars/party.ts +0 -81
  84. package/src/bin/registrars/payment.ts +0 -128
  85. package/src/bin/registrars/report.ts +0 -186
  86. package/src/bin/registrars/session.ts +0 -32
  87. package/src/bin/registrars/shipment.ts +0 -74
  88. package/src/bin/registrars/store.ts +0 -128
  89. package/src/bin/registrars/target.ts +0 -46
  90. package/src/bin/registrars/tenant.ts +0 -73
  91. package/src/client.ts +0 -2071
  92. package/src/commands/api-key/create.ts +0 -72
  93. package/src/commands/api-key/list.ts +0 -71
  94. package/src/commands/api-key/revoke.ts +0 -46
  95. package/src/commands/automated-invoice/create.ts +0 -85
  96. package/src/commands/automated-invoice/delete.ts +0 -42
  97. package/src/commands/automated-invoice/get.ts +0 -113
  98. package/src/commands/automated-invoice/history.ts +0 -65
  99. package/src/commands/automated-invoice/index.ts +0 -11
  100. package/src/commands/automated-invoice/list.ts +0 -91
  101. package/src/commands/automated-invoice/pause.ts +0 -29
  102. package/src/commands/automated-invoice/resume.ts +0 -29
  103. package/src/commands/automated-invoice/run-now.ts +0 -29
  104. package/src/commands/automated-invoice/suggestions.ts +0 -68
  105. package/src/commands/automated-invoice/update.ts +0 -54
  106. package/src/commands/automated-invoice/usage.ts +0 -68
  107. package/src/commands/bank/gateway-config.ts +0 -61
  108. package/src/commands/bank/index.ts +0 -244
  109. package/src/commands/bank/update-gateway.ts +0 -84
  110. package/src/commands/bank-recon/index.ts +0 -127
  111. package/src/commands/business/audit-trail.ts +0 -79
  112. package/src/commands/business/export.ts +0 -52
  113. package/src/commands/business/get.ts +0 -55
  114. package/src/commands/business/sequence.ts +0 -65
  115. package/src/commands/business/update.ts +0 -64
  116. package/src/commands/dashboard/collection-efficiency.ts +0 -164
  117. package/src/commands/dashboard/expenses.ts +0 -76
  118. package/src/commands/dashboard/invoice-breakdown.ts +0 -89
  119. package/src/commands/dashboard/monthly-comparison.ts +0 -193
  120. package/src/commands/dashboard/payment-modes.ts +0 -121
  121. package/src/commands/dashboard/profit-loss.ts +0 -146
  122. package/src/commands/dashboard/receivables-aging.ts +0 -169
  123. package/src/commands/dashboard/sales-trend.ts +0 -68
  124. package/src/commands/dashboard/summary.ts +0 -105
  125. package/src/commands/dashboard/top-customers.ts +0 -70
  126. package/src/commands/dashboard/top-items.ts +0 -74
  127. package/src/commands/dashboard/top-outstanding.ts +0 -61
  128. package/src/commands/dashboard.ts +0 -105
  129. package/src/commands/document/factory.ts +0 -590
  130. package/src/commands/einvoice/index.ts +0 -109
  131. package/src/commands/ewb/index.ts +0 -108
  132. package/src/commands/expense/categories.ts +0 -40
  133. package/src/commands/expense/create.ts +0 -51
  134. package/src/commands/expense/delete.ts +0 -45
  135. package/src/commands/expense/list.ts +0 -65
  136. package/src/commands/expense/update.ts +0 -58
  137. package/src/commands/gst/index.ts +0 -194
  138. package/src/commands/import/index.ts +0 -168
  139. package/src/commands/invoice/create.ts +0 -262
  140. package/src/commands/invoice/delete.ts +0 -44
  141. package/src/commands/invoice/get.ts +0 -113
  142. package/src/commands/invoice/list.ts +0 -126
  143. package/src/commands/invoice/pdf.ts +0 -75
  144. package/src/commands/invoice/status.ts +0 -41
  145. package/src/commands/itc/index.ts +0 -163
  146. package/src/commands/item/categories.ts +0 -40
  147. package/src/commands/item/create.ts +0 -98
  148. package/src/commands/item/delete.ts +0 -44
  149. package/src/commands/item/list.ts +0 -81
  150. package/src/commands/item/low-stock-count.ts +0 -32
  151. package/src/commands/item/merge.ts +0 -53
  152. package/src/commands/item/price-history.ts +0 -59
  153. package/src/commands/item/rename-unit.ts +0 -39
  154. package/src/commands/item/sales-stats.ts +0 -44
  155. package/src/commands/item/stock-history.ts +0 -70
  156. package/src/commands/item/stock.ts +0 -46
  157. package/src/commands/item/switch-base-unit.ts +0 -42
  158. package/src/commands/item/update.ts +0 -59
  159. package/src/commands/item/variants-create.ts +0 -58
  160. package/src/commands/item/variants-delete.ts +0 -47
  161. package/src/commands/item/variants-list.ts +0 -63
  162. package/src/commands/item/variants-update.ts +0 -61
  163. package/src/commands/journal/index.ts +0 -156
  164. package/src/commands/party/create.ts +0 -88
  165. package/src/commands/party/delete.ts +0 -44
  166. package/src/commands/party/get.ts +0 -42
  167. package/src/commands/party/ledger-report.ts +0 -81
  168. package/src/commands/party/ledger.ts +0 -63
  169. package/src/commands/party/list.ts +0 -69
  170. package/src/commands/party/merge.ts +0 -50
  171. package/src/commands/party/stats.ts +0 -40
  172. package/src/commands/party/top-items.ts +0 -57
  173. package/src/commands/party/update.ts +0 -65
  174. package/src/commands/payment/create.ts +0 -131
  175. package/src/commands/payment/default-account.ts +0 -56
  176. package/src/commands/payment/delete.ts +0 -46
  177. package/src/commands/payment/get.ts +0 -59
  178. package/src/commands/payment/list.ts +0 -66
  179. package/src/commands/payment/unpaid-invoices.ts +0 -69
  180. package/src/commands/payment/untracked.ts +0 -70
  181. package/src/commands/payment/update.ts +0 -54
  182. package/src/commands/report/index.ts +0 -736
  183. package/src/commands/session/list.ts +0 -91
  184. package/src/commands/session/revoke-all.ts +0 -20
  185. package/src/commands/session/revoke.ts +0 -32
  186. package/src/commands/shipment/index.ts +0 -170
  187. package/src/commands/store/check-slug.ts +0 -48
  188. package/src/commands/store/index.ts +0 -77
  189. package/src/commands/store/items-toggle.ts +0 -41
  190. package/src/commands/store/items.ts +0 -61
  191. package/src/commands/store/order-cancel.ts +0 -48
  192. package/src/commands/store/order-confirm.ts +0 -45
  193. package/src/commands/store/order-get.ts +0 -66
  194. package/src/commands/store/order-update.ts +0 -52
  195. package/src/commands/store/update-settings.ts +0 -52
  196. package/src/commands/target/index.ts +0 -118
  197. package/src/commands/tenant/invitations.ts +0 -62
  198. package/src/commands/tenant/invite.ts +0 -57
  199. package/src/commands/tenant/list.ts +0 -46
  200. package/src/commands/tenant/members.ts +0 -55
  201. package/src/commands/tenant/remove.ts +0 -47
  202. package/src/commands/tenant/revoke-invitation.ts +0 -32
  203. package/src/commands/tenant/update-role.ts +0 -41
  204. package/src/config.ts +0 -120
  205. package/src/error-handler.ts +0 -53
  206. package/src/format.ts +0 -181
  207. package/src/output.ts +0 -228
  208. package/src/spinner.ts +0 -39
  209. package/tsconfig.json +0 -22
  210. package/tsup.config.ts +0 -18
@@ -1,736 +0,0 @@
1
- import { HisaaboClient, HisaaboApiError, type DaybookEntry } from "../../client.js";
2
- import { requireAuth } from "../../config.js";
3
- import {
4
- fatalError, outputJSON, outputTable, outputTSV, outputCSV, EXIT, type ColumnDef,
5
- } from "../../output.js";
6
- import { formatAmount, formatDate, formatStatus, todayISO, fyStart, monthStart, monthEnd } from "../../format.js";
7
-
8
- interface ReportOpts {
9
- json?: boolean;
10
- format?: string;
11
- from?: string;
12
- to?: string;
13
- thisMonth?: boolean;
14
- thisFy?: boolean;
15
- }
16
-
17
- function resolveRange(opts: ReportOpts): { from: string; to: string } {
18
- if (opts.thisFy) return { from: fyStart(), to: todayISO() };
19
- if (opts.thisMonth) return { from: monthStart(), to: monthEnd() };
20
- return { from: opts.from ?? fyStart(), to: opts.to ?? todayISO() };
21
- }
22
-
23
- export async function reportDaybookCommand(opts: ReportOpts): Promise<void> {
24
- const cfg = requireAuth();
25
- const client = new HisaaboClient(cfg);
26
- const { from, to } = resolveRange(opts);
27
-
28
- try {
29
- const result = await client.reports.daybook({ fromDate: from, toDate: to });
30
-
31
- if (opts.json) {
32
- outputJSON(result);
33
- return;
34
- }
35
-
36
- console.log(`\n Daybook Report ${from} → ${to}\n`);
37
- console.log(` ${"═".repeat(70)}\n`);
38
-
39
- const cols: ColumnDef<DaybookEntry>[] = [
40
- { key: "time", header: "Time", width: 20, format: (v) => formatDate(String(v ?? "")) },
41
- { key: "entryType", header: "Type", width: 10 },
42
- { key: "number", header: "#", width: 12, format: (v) => String(v ?? "-") },
43
- { key: "partyOrCategory", header: "Party / Category", width: 22 },
44
- { key: "debit", header: "Debit (₹)", align: "right", width: 13, format: (v) => parseFloat(String(v ?? "0")) !== 0 ? formatAmount(String(v)) : "-" },
45
- { key: "credit", header: "Credit (₹)", align: "right", width: 13, format: (v) => parseFloat(String(v ?? "0")) !== 0 ? formatAmount(String(v)) : "-" },
46
- ];
47
-
48
- if (opts.format === "tsv") outputTSV(result.entries, cols);
49
- else if (opts.format === "csv") outputCSV(result.entries, cols);
50
- else {
51
- outputTable(result.entries, cols);
52
-
53
- const s = result.summary;
54
- console.log(`\n Sales Invoiced: ${formatAmount(s.totalSalesInvoiced).padStart(14)}`);
55
- console.log(` Purchases Invoiced: ${formatAmount(s.totalPurchaseInvoiced).padStart(14)}`);
56
- console.log(` Payments Received: ${formatAmount(s.totalPaymentsReceived).padStart(14)}`);
57
- console.log(` Payments Made: ${formatAmount(s.totalPaymentsMade).padStart(14)}`);
58
- console.log(` Expenses: ${formatAmount(s.totalExpenses).padStart(14)}`);
59
- console.log(` Net Cash Movement: ${formatAmount(s.netCashMovement).padStart(14)}\n`);
60
- }
61
-
62
- } catch (e) {
63
- if (e instanceof HisaaboApiError) {
64
- const err = e.hisaaboError;
65
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
66
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
67
- }
68
- fatalError(String(e instanceof Error ? e.message : e));
69
- }
70
- }
71
-
72
- export async function reportOutstandingCommand(opts: ReportOpts & { type?: string }): Promise<void> {
73
- const cfg = requireAuth();
74
- const client = new HisaaboClient(cfg);
75
-
76
- try {
77
- const result = await client.reports.outstanding({
78
- type: opts.type as "receivable" | "payable" | "both" | undefined ?? "both",
79
- });
80
-
81
- if (opts.json) {
82
- outputJSON(result);
83
- return;
84
- }
85
-
86
- console.log("\n Outstanding Report\n");
87
- console.log(" " + "═".repeat(60) + "\n");
88
-
89
- if (result.receivables && Array.isArray(result.receivables)) {
90
- console.log(" Receivables:");
91
- (result.receivables as Array<Record<string, unknown>>).forEach((row) => {
92
- console.log(` ${String(row["partyName"] ?? "").padEnd(25)} ${formatAmount(String(row["balance"] ?? "0")).padStart(14)}`);
93
- });
94
- }
95
- if (result.payables && Array.isArray(result.payables)) {
96
- console.log("\n Payables:");
97
- (result.payables as Array<Record<string, unknown>>).forEach((row) => {
98
- console.log(` ${String(row["partyName"] ?? "").padEnd(25)} ${formatAmount(String(row["balance"] ?? "0")).padStart(14)}`);
99
- });
100
- }
101
- console.log();
102
-
103
- } catch (e) {
104
- if (e instanceof HisaaboApiError) {
105
- const err = e.hisaaboError;
106
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
107
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
108
- }
109
- fatalError(String(e instanceof Error ? e.message : e));
110
- }
111
- }
112
-
113
- export async function reportTaxSummaryCommand(opts: ReportOpts): Promise<void> {
114
- const cfg = requireAuth();
115
- const client = new HisaaboClient(cfg);
116
- const { from, to } = resolveRange(opts);
117
-
118
- try {
119
- const result = await client.reports.taxSummary({ fromDate: from, toDate: to });
120
-
121
- if (opts.json) {
122
- outputJSON(result);
123
- return;
124
- }
125
-
126
- console.log(`\n Tax Summary ${from} → ${to}\n`);
127
- console.log(" " + "═".repeat(60) + "\n");
128
-
129
- if (Array.isArray(result.rows)) {
130
- (result.rows as Array<Record<string, unknown>>).forEach((row) => {
131
- const rate = String(row["taxPercent"] ?? row["rate"] ?? "-");
132
- const taxable = formatAmount(String(row["taxableAmount"] ?? "0"));
133
- const tax = formatAmount(String(row["taxAmount"] ?? "0"));
134
- console.log(` ${rate.padEnd(6)}% Taxable: ${taxable.padStart(14)} Tax: ${tax.padStart(12)}`);
135
- });
136
- }
137
- console.log();
138
-
139
- } catch (e) {
140
- if (e instanceof HisaaboApiError) {
141
- const err = e.hisaaboError;
142
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
143
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
144
- }
145
- fatalError(String(e instanceof Error ? e.message : e));
146
- }
147
- }
148
-
149
- export async function reportItemSalesCommand(opts: ReportOpts): Promise<void> {
150
- const cfg = requireAuth();
151
- const client = new HisaaboClient(cfg);
152
- const { from, to } = resolveRange(opts);
153
-
154
- try {
155
- const result = await client.reports.itemSales({ fromDate: from, toDate: to });
156
-
157
- if (opts.json) {
158
- outputJSON(result);
159
- return;
160
- }
161
-
162
- console.log(`\n Item Sales ${from} → ${to}\n`);
163
- console.log(" " + "═".repeat(70) + "\n");
164
-
165
- if (Array.isArray(result.rows)) {
166
- (result.rows as Array<Record<string, unknown>>).slice(0, 50).forEach((row) => {
167
- const name = String(row["itemName"] ?? row["name"] ?? "-").padEnd(25);
168
- const qty = String(row["totalQuantity"] ?? row["qty"] ?? "-").padStart(8);
169
- const rev = formatAmount(String(row["totalRevenue"] ?? row["revenue"] ?? "0")).padStart(14);
170
- console.log(` ${name} ${qty} ${rev}`);
171
- });
172
- }
173
- console.log();
174
-
175
- } catch (e) {
176
- if (e instanceof HisaaboApiError) {
177
- const err = e.hisaaboError;
178
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
179
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
180
- }
181
- fatalError(String(e instanceof Error ? e.message : e));
182
- }
183
- }
184
-
185
- export async function reportStockSummaryCommand(opts: { json?: boolean; category?: string }): Promise<void> {
186
- const cfg = requireAuth();
187
- const client = new HisaaboClient(cfg);
188
-
189
- try {
190
- const result = await client.reports.stockSummary({ category: opts.category });
191
-
192
- if (opts.json) {
193
- outputJSON(result);
194
- return;
195
- }
196
-
197
- console.log("\n Stock Summary\n");
198
- console.log(" " + "═".repeat(60) + "\n");
199
-
200
- if (Array.isArray(result.rows)) {
201
- (result.rows as Array<Record<string, unknown>>).forEach((row) => {
202
- const name = String(row["itemName"] ?? row["name"] ?? "-").padEnd(25);
203
- const stock = String(row["stockQuantity"] ?? row["stock"] ?? "-").padStart(10);
204
- const val = formatAmount(String(row["stockValue"] ?? row["value"] ?? "0")).padStart(14);
205
- console.log(` ${name} ${stock} ${val}`);
206
- });
207
- }
208
- console.log();
209
-
210
- } catch (e) {
211
- if (e instanceof HisaaboApiError) {
212
- const err = e.hisaaboError;
213
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
214
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
215
- }
216
- fatalError(String(e instanceof Error ? e.message : e));
217
- }
218
- }
219
-
220
- // ── Sales Register ─────────────────────────────────────────────────────────
221
-
222
- interface RegisterRow {
223
- date?: string;
224
- invoiceDate?: string;
225
- invoiceNumber?: string;
226
- number?: string;
227
- partyName?: string;
228
- party?: string;
229
- subtotal?: string;
230
- taxAmount?: string;
231
- tax?: string;
232
- total?: string;
233
- totalAmount?: string;
234
- status?: string;
235
- [key: string]: unknown;
236
- }
237
-
238
- export async function reportSalesRegisterCommand(
239
- opts: ReportOpts & { partyId?: string },
240
- ): Promise<void> {
241
- const cfg = requireAuth();
242
- const client = new HisaaboClient(cfg);
243
- const { from, to } = resolveRange(opts);
244
-
245
- try {
246
- const result = await client.reports.salesRegister({ fromDate: from, toDate: to, partyId: opts.partyId });
247
-
248
- if (opts.json) {
249
- outputJSON(result);
250
- return;
251
- }
252
-
253
- console.log(`\n Sales Register ${from} → ${to}\n`);
254
- console.log(` ${"═".repeat(80)}\n`);
255
-
256
- const rows: RegisterRow[] = Array.isArray(result) ? result
257
- : Array.isArray(result.rows) ? result.rows
258
- : Array.isArray(result.invoices) ? result.invoices
259
- : [];
260
-
261
- const cols: ColumnDef<RegisterRow>[] = [
262
- { key: "date", header: "Date", width: 13, format: (v, r) => formatDate(String(r.date ?? r.invoiceDate ?? v ?? "")) },
263
- { key: "invoiceNumber", header: "Invoice #", width: 14, format: (v, r) => String(r.invoiceNumber ?? r.number ?? v ?? "-") },
264
- { key: "partyName", header: "Party", width: 22, format: (v, r) => String(r.partyName ?? r.party ?? v ?? "-") },
265
- { key: "subtotal", header: "Subtotal (₹)", align: "right", width: 14, format: (v, r) => formatAmount(String(r.subtotal ?? v ?? "0")) },
266
- { key: "taxAmount", header: "Tax (₹)", align: "right", width: 12, format: (v, r) => formatAmount(String(r.taxAmount ?? r.tax ?? v ?? "0")) },
267
- { key: "total", header: "Total (₹)", align: "right", width: 14, format: (v, r) => formatAmount(String(r.total ?? r.totalAmount ?? v ?? "0")) },
268
- { key: "status", header: "Status", width: 10, format: (v, r) => formatStatus(String(r.status ?? v ?? "")) },
269
- ];
270
-
271
- if (opts.format === "tsv") outputTSV(rows, cols);
272
- else if (opts.format === "csv") outputCSV(rows, cols);
273
- else outputTable(rows, cols);
274
-
275
- if (rows.length > 0 && opts.format !== "tsv" && opts.format !== "csv") {
276
- const total = rows.reduce((sum, r) => sum + parseFloat(String(r.total ?? r.totalAmount ?? "0")), 0);
277
- console.log(`\n Total: ${formatAmount(String(total)).padStart(14)}\n`);
278
- }
279
-
280
- } catch (e) {
281
- if (e instanceof HisaaboApiError) {
282
- const err = e.hisaaboError;
283
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
284
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
285
- }
286
- fatalError(String(e instanceof Error ? e.message : e));
287
- }
288
- }
289
-
290
- // ── Purchase Register ──────────────────────────────────────────────────────
291
-
292
- export async function reportPurchaseRegisterCommand(
293
- opts: ReportOpts & { partyId?: string },
294
- ): Promise<void> {
295
- const cfg = requireAuth();
296
- const client = new HisaaboClient(cfg);
297
- const { from, to } = resolveRange(opts);
298
-
299
- try {
300
- const result = await client.reports.purchaseRegister({ fromDate: from, toDate: to, partyId: opts.partyId });
301
-
302
- if (opts.json) {
303
- outputJSON(result);
304
- return;
305
- }
306
-
307
- console.log(`\n Purchase Register ${from} → ${to}\n`);
308
- console.log(` ${"═".repeat(80)}\n`);
309
-
310
- const rows: RegisterRow[] = Array.isArray(result) ? result
311
- : Array.isArray(result.rows) ? result.rows
312
- : Array.isArray(result.invoices) ? result.invoices
313
- : [];
314
-
315
- const cols: ColumnDef<RegisterRow>[] = [
316
- { key: "date", header: "Date", width: 13, format: (v, r) => formatDate(String(r.date ?? r.invoiceDate ?? v ?? "")) },
317
- { key: "invoiceNumber", header: "Invoice #", width: 14, format: (v, r) => String(r.invoiceNumber ?? r.number ?? v ?? "-") },
318
- { key: "partyName", header: "Party", width: 22, format: (v, r) => String(r.partyName ?? r.party ?? v ?? "-") },
319
- { key: "subtotal", header: "Subtotal (₹)", align: "right", width: 14, format: (v, r) => formatAmount(String(r.subtotal ?? v ?? "0")) },
320
- { key: "taxAmount", header: "Tax (₹)", align: "right", width: 12, format: (v, r) => formatAmount(String(r.taxAmount ?? r.tax ?? v ?? "0")) },
321
- { key: "total", header: "Total (₹)", align: "right", width: 14, format: (v, r) => formatAmount(String(r.total ?? r.totalAmount ?? v ?? "0")) },
322
- { key: "status", header: "Status", width: 10, format: (v, r) => formatStatus(String(r.status ?? v ?? "")) },
323
- ];
324
-
325
- if (opts.format === "tsv") outputTSV(rows, cols);
326
- else if (opts.format === "csv") outputCSV(rows, cols);
327
- else outputTable(rows, cols);
328
-
329
- if (rows.length > 0 && opts.format !== "tsv" && opts.format !== "csv") {
330
- const total = rows.reduce((sum, r) => sum + parseFloat(String(r.total ?? r.totalAmount ?? "0")), 0);
331
- console.log(`\n Total: ${formatAmount(String(total)).padStart(14)}\n`);
332
- }
333
-
334
- } catch (e) {
335
- if (e instanceof HisaaboApiError) {
336
- const err = e.hisaaboError;
337
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
338
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
339
- }
340
- fatalError(String(e instanceof Error ? e.message : e));
341
- }
342
- }
343
-
344
- // ── Party Statement ────────────────────────────────────────────────────────
345
-
346
- interface StatementRow {
347
- date?: string;
348
- type?: string;
349
- entryType?: string;
350
- number?: string;
351
- invoiceNumber?: string;
352
- debit?: string;
353
- credit?: string;
354
- balance?: string;
355
- runningBalance?: string;
356
- [key: string]: unknown;
357
- }
358
-
359
- export async function reportPartyStatementCommand(
360
- partyId: string,
361
- opts: ReportOpts,
362
- ): Promise<void> {
363
- const cfg = requireAuth();
364
- const client = new HisaaboClient(cfg);
365
- const { from, to } = resolveRange(opts);
366
-
367
- try {
368
- const result = await client.reports.partyStatement({ partyId, fromDate: from, toDate: to });
369
-
370
- if (opts.json) {
371
- outputJSON(result);
372
- return;
373
- }
374
-
375
- const res = result as Record<string, unknown>;
376
- const partyName = String(res["partyName"] ?? res["party"] ?? partyId);
377
- console.log(`\n Party Statement — ${partyName} ${from} → ${to}\n`);
378
- console.log(` ${"═".repeat(75)}\n`);
379
-
380
- const openingBalance = String(res["openingBalance"] ?? "0");
381
- console.log(` Opening Balance: ${formatAmount(openingBalance).padStart(14)}\n`);
382
-
383
- const rows: StatementRow[] = Array.isArray(res["entries"]) ? res["entries"] as StatementRow[]
384
- : Array.isArray(res["rows"]) ? res["rows"] as StatementRow[]
385
- : [];
386
-
387
- const cols: ColumnDef<StatementRow>[] = [
388
- { key: "date", header: "Date", width: 13, format: (v, r) => formatDate(String(r.date ?? v ?? "")) },
389
- { key: "type", header: "Type", width: 12, format: (v, r) => String(r.type ?? r.entryType ?? v ?? "-") },
390
- { key: "number", header: "Number", width: 14, format: (v, r) => String(r.number ?? r.invoiceNumber ?? v ?? "-") },
391
- { key: "debit", header: "Debit (₹)", align: "right", width: 13, format: (v, r) => parseFloat(String(r.debit ?? v ?? "0")) !== 0 ? formatAmount(String(r.debit ?? v)) : "-" },
392
- { key: "credit", header: "Credit (₹)", align: "right", width: 13, format: (v, r) => parseFloat(String(r.credit ?? v ?? "0")) !== 0 ? formatAmount(String(r.credit ?? v)) : "-" },
393
- { key: "balance", header: "Balance (₹)", align: "right", width: 14, format: (v, r) => formatAmount(String(r.balance ?? r.runningBalance ?? v ?? "0")) },
394
- ];
395
-
396
- if (opts.format === "tsv") outputTSV(rows, cols);
397
- else if (opts.format === "csv") outputCSV(rows, cols);
398
- else outputTable(rows, cols);
399
-
400
- if (opts.format !== "tsv" && opts.format !== "csv") {
401
- const closingBalance = String(res["closingBalance"] ?? res["balance"] ?? "0");
402
- console.log(`\n Closing Balance: ${formatAmount(closingBalance).padStart(14)}\n`);
403
- }
404
-
405
- } catch (e) {
406
- if (e instanceof HisaaboApiError) {
407
- const err = e.hisaaboError;
408
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
409
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
410
- }
411
- fatalError(String(e instanceof Error ? e.message : e));
412
- }
413
- }
414
-
415
- // ── Payment Summary ────────────────────────────────────────────────────────
416
-
417
- export async function reportPaymentSummaryCommand(
418
- opts: ReportOpts & { type?: string },
419
- ): Promise<void> {
420
- const cfg = requireAuth();
421
- const client = new HisaaboClient(cfg);
422
- const { from, to } = resolveRange(opts);
423
-
424
- try {
425
- const result = await client.reports.paymentSummary({
426
- fromDate: from,
427
- toDate: to,
428
- type: opts.type as "received" | "made" | "both" | undefined ?? "both",
429
- });
430
-
431
- if (opts.json) {
432
- outputJSON(result);
433
- return;
434
- }
435
-
436
- const res = result as Record<string, unknown>;
437
- console.log(`\n Payment Summary ${from} → ${to}\n`);
438
- console.log(" " + "═".repeat(60) + "\n");
439
-
440
- const received = String(res["totalReceived"] ?? res["received"] ?? "0");
441
- const made = String(res["totalMade"] ?? res["made"] ?? "0");
442
- const net = String(res["net"] ?? res["netCash"] ?? "0");
443
-
444
- console.log(` Total Received: ${formatAmount(received).padStart(14)}`);
445
- console.log(` Total Made: ${formatAmount(made).padStart(14)}`);
446
- console.log(` Net: ${formatAmount(net).padStart(14)}`);
447
-
448
- const breakdown = res["breakdown"] ?? res["byMode"] ?? res["modes"];
449
- if (breakdown && Array.isArray(breakdown)) {
450
- console.log(`\n By Payment Mode:\n`);
451
- (breakdown as Array<Record<string, unknown>>).forEach((row) => {
452
- const mode = String(row["mode"] ?? row["paymentMode"] ?? "-").padEnd(18);
453
- const amount = formatAmount(String(row["amount"] ?? row["total"] ?? "0")).padStart(14);
454
- console.log(` ${mode} ${amount}`);
455
- });
456
- }
457
- console.log();
458
-
459
- } catch (e) {
460
- if (e instanceof HisaaboApiError) {
461
- const err = e.hisaaboError;
462
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
463
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
464
- }
465
- fatalError(String(e instanceof Error ? e.message : e));
466
- }
467
- }
468
-
469
- // ── Cash Flow Forecast ─────────────────────────────────────────────────────
470
-
471
- export async function reportCashFlowCommand(opts: { json?: boolean }): Promise<void> {
472
- const cfg = requireAuth();
473
- const client = new HisaaboClient(cfg);
474
-
475
- try {
476
- const result = await client.reports.cashFlowForecast();
477
-
478
- if (opts.json) {
479
- outputJSON(result);
480
- return;
481
- }
482
-
483
- const res = result as Record<string, unknown>;
484
- console.log("\n Cash Flow Forecast\n");
485
- console.log(" " + "═".repeat(60) + "\n");
486
-
487
- const currentBalance = String(res["currentBalance"] ?? res["balance"] ?? "0");
488
- const avgDailyExpenses = String(res["avgDailyExpenses"] ?? res["dailyBurn"] ?? "0");
489
-
490
- console.log(` Current Balance: ${formatAmount(currentBalance).padStart(14)}`);
491
- console.log(` Avg Daily Expenses: ${formatAmount(avgDailyExpenses).padStart(14)}`);
492
-
493
- const forecasts = res["forecasts"] ?? res["forecast"];
494
- if (forecasts && Array.isArray(forecasts)) {
495
- console.log(`\n Forecast:\n`);
496
- (forecasts as Array<Record<string, unknown>>).forEach((f) => {
497
- const days = String(f["days"] ?? f["day"] ?? "-");
498
- const balance = formatAmount(String(f["balance"] ?? f["amount"] ?? "0")).padStart(14);
499
- console.log(` ${`${days}d`.padEnd(6)} ${balance}`);
500
- });
501
- } else {
502
- // Fall back to computing from balance and daily burn if no forecasts array
503
- const current = parseFloat(currentBalance);
504
- const daily = parseFloat(avgDailyExpenses);
505
- if (!isNaN(current) && !isNaN(daily)) {
506
- console.log(`\n Forecast:\n`);
507
- for (const days of [7, 14, 30]) {
508
- const projected = current - daily * days;
509
- console.log(` ${`${days}d`.padEnd(6)} ${formatAmount(String(projected)).padStart(14)}`);
510
- }
511
- }
512
- }
513
- console.log();
514
-
515
- } catch (e) {
516
- if (e instanceof HisaaboApiError) {
517
- const err = e.hisaaboError;
518
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
519
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
520
- }
521
- fatalError(String(e instanceof Error ? e.message : e));
522
- }
523
- }
524
-
525
- // ── Trial Balance ──────────────────────────────────────────────────────────
526
-
527
- export async function reportTrialBalanceCommand(opts: ReportOpts): Promise<void> {
528
- const cfg = requireAuth();
529
- const client = new HisaaboClient(cfg);
530
- const { from: _from, to } = resolveRange(opts);
531
-
532
- try {
533
- const result = await client.reports.trialBalance({ asOfDate: to });
534
-
535
- if (opts.json) {
536
- outputJSON(result);
537
- return;
538
- }
539
-
540
- console.log(`\n Trial Balance as of ${to}\n`);
541
- console.log(` ${"═".repeat(70)}\n`);
542
-
543
- const rows = Array.isArray(result?.accounts) ? result.accounts
544
- : Array.isArray(result?.rows) ? result.rows
545
- : Array.isArray(result) ? result
546
- : [];
547
-
548
- for (const row of rows as Array<Record<string, unknown>>) {
549
- const name = String(row["accountName"] ?? row["name"] ?? "-").padEnd(30);
550
- const debit = String(row["debit"] ?? "0");
551
- const credit = String(row["credit"] ?? "0");
552
- const dr = parseFloat(debit) !== 0 ? formatAmount(debit) : "-";
553
- const cr = parseFloat(credit) !== 0 ? formatAmount(credit) : "-";
554
- console.log(` ${name} ${dr.padStart(14)} ${cr.padStart(14)}`);
555
- }
556
- console.log();
557
-
558
- } catch (e) {
559
- if (e instanceof HisaaboApiError) {
560
- const err = e.hisaaboError;
561
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
562
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
563
- }
564
- fatalError(String(e instanceof Error ? e.message : e));
565
- }
566
- }
567
-
568
- // ── Balance Sheet ──────────────────────────────────────────────────────────
569
-
570
- export async function reportBalanceSheetCommand(opts: ReportOpts): Promise<void> {
571
- const cfg = requireAuth();
572
- const client = new HisaaboClient(cfg);
573
- const { to } = resolveRange(opts);
574
-
575
- try {
576
- const result = await client.reports.balanceSheet({ asOfDate: to });
577
-
578
- if (opts.json) {
579
- outputJSON(result);
580
- return;
581
- }
582
-
583
- const r = result as Record<string, unknown>;
584
- console.log(`\n Balance Sheet as of ${to}\n`);
585
- console.log(` ${"═".repeat(60)}\n`);
586
-
587
- const assets = String(r["totalAssets"] ?? r["assets"] ?? "0");
588
- const liabilities = String(r["totalLiabilities"] ?? r["liabilities"] ?? "0");
589
- const equity = String(r["totalEquity"] ?? r["equity"] ?? "0");
590
-
591
- console.log(` Total Assets: ${formatAmount(assets).padStart(14)}`);
592
- console.log(` Total Liabilities: ${formatAmount(liabilities).padStart(14)}`);
593
- console.log(` Total Equity: ${formatAmount(equity).padStart(14)}`);
594
- console.log();
595
- console.log(" Use --json for full balance sheet breakdown.\n");
596
-
597
- } catch (e) {
598
- if (e instanceof HisaaboApiError) {
599
- const err = e.hisaaboError;
600
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
601
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
602
- }
603
- fatalError(String(e instanceof Error ? e.message : e));
604
- }
605
- }
606
-
607
- // ── Cash Flow Statement ────────────────────────────────────────────────────
608
-
609
- export async function reportCashFlowStatementCommand(opts: ReportOpts): Promise<void> {
610
- const cfg = requireAuth();
611
- const client = new HisaaboClient(cfg);
612
- const { from, to } = resolveRange(opts);
613
-
614
- try {
615
- const result = await client.reports.cashFlowStatement({ fromDate: from, toDate: to });
616
-
617
- if (opts.json) {
618
- outputJSON(result);
619
- return;
620
- }
621
-
622
- const r = result as Record<string, unknown>;
623
- console.log(`\n Cash Flow Statement ${from} → ${to}\n`);
624
- console.log(` ${"═".repeat(60)}\n`);
625
-
626
- const operating = String(r["operatingActivities"] ?? r["operations"] ?? "0");
627
- const investing = String(r["investingActivities"] ?? r["investing"] ?? "0");
628
- const financing = String(r["financingActivities"] ?? r["financing"] ?? "0");
629
- const net = String(r["netCashFlow"] ?? r["net"] ?? "0");
630
-
631
- console.log(` Operating Activities: ${formatAmount(operating).padStart(14)}`);
632
- console.log(` Investing Activities: ${formatAmount(investing).padStart(14)}`);
633
- console.log(` Financing Activities: ${formatAmount(financing).padStart(14)}`);
634
- console.log(` Net Cash Flow: ${formatAmount(net).padStart(14)}`);
635
- console.log();
636
-
637
- } catch (e) {
638
- if (e instanceof HisaaboApiError) {
639
- const err = e.hisaaboError;
640
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
641
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
642
- }
643
- fatalError(String(e instanceof Error ? e.message : e));
644
- }
645
- }
646
-
647
- // ── General Ledger ─────────────────────────────────────────────────────────
648
-
649
- export async function reportGeneralLedgerCommand(accountId: string, opts: ReportOpts): Promise<void> {
650
- const cfg = requireAuth();
651
- const client = new HisaaboClient(cfg);
652
- const { from, to } = resolveRange(opts);
653
-
654
- try {
655
- const result = await client.reports.generalLedger({ accountId, fromDate: from, toDate: to });
656
-
657
- if (opts.json) {
658
- outputJSON(result);
659
- return;
660
- }
661
-
662
- const r = result as Record<string, unknown>;
663
- const accountName = String(r["accountName"] ?? r["account"] ?? accountId);
664
- console.log(`\n General Ledger — ${accountName} ${from} → ${to}\n`);
665
- console.log(` ${"═".repeat(75)}\n`);
666
-
667
- const opening = String(r["openingBalance"] ?? "0");
668
- console.log(` Opening Balance: ${formatAmount(opening).padStart(14)}\n`);
669
-
670
- const entries = Array.isArray(r["entries"]) ? r["entries"]
671
- : Array.isArray(r["rows"]) ? r["rows"]
672
- : [];
673
-
674
- for (const entry of entries as Array<Record<string, unknown>>) {
675
- const date = formatDate(String(entry["date"] ?? "")).padEnd(13);
676
- const narration = String(entry["narration"] ?? entry["description"] ?? "-").slice(0, 25).padEnd(25);
677
- const debit = parseFloat(String(entry["debit"] ?? "0")) !== 0 ? formatAmount(String(entry["debit"])) : "-";
678
- const credit = parseFloat(String(entry["credit"] ?? "0")) !== 0 ? formatAmount(String(entry["credit"])) : "-";
679
- const balance = formatAmount(String(entry["balance"] ?? "0"));
680
- console.log(` ${date} ${narration} ${debit.padStart(12)} ${credit.padStart(12)} ${balance.padStart(14)}`);
681
- }
682
-
683
- const closing = String(r["closingBalance"] ?? r["balance"] ?? "0");
684
- console.log(`\n Closing Balance: ${formatAmount(closing).padStart(14)}\n`);
685
-
686
- } catch (e) {
687
- if (e instanceof HisaaboApiError) {
688
- const err = e.hisaaboError;
689
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
690
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
691
- }
692
- fatalError(String(e instanceof Error ? e.message : e));
693
- }
694
- }
695
-
696
- // ── Collection Efficiency ──────────────────────────────────────────────────
697
-
698
- export async function reportCollectionEfficiencyCommand(opts: ReportOpts): Promise<void> {
699
- const cfg = requireAuth();
700
- const client = new HisaaboClient(cfg);
701
- const { from, to } = resolveRange(opts);
702
-
703
- try {
704
- const result = await client.reports.collectionEfficiency({ fromDate: from, toDate: to });
705
-
706
- if (opts.json) {
707
- outputJSON(result);
708
- return;
709
- }
710
-
711
- const res = result as Record<string, unknown>;
712
- console.log(`\n Collection Efficiency ${from} → ${to}\n`);
713
- console.log(" " + "═".repeat(60) + "\n");
714
-
715
- const rate = String(res["collectionRate"] ?? res["rate"] ?? "0");
716
- const dso = String(res["dso"] ?? res["daysSalesOutstanding"] ?? "-");
717
- const paidOnTime = String(res["paidOnTime"] ?? res["onTimeCount"] ?? "-");
718
- const totalInvoiced = String(res["totalInvoiced"] ?? res["invoiced"] ?? "-");
719
-
720
- console.log(` Collection Rate: ${(parseFloat(rate)).toFixed(1).padStart(8)}%`);
721
- console.log(` DSO (Days): ${dso.padStart(8)}`);
722
- console.log(` Paid On Time: ${paidOnTime.padStart(8)}`);
723
- if (totalInvoiced !== "-") {
724
- console.log(` Total Invoiced: ${formatAmount(totalInvoiced).padStart(14)}`);
725
- }
726
- console.log();
727
-
728
- } catch (e) {
729
- if (e instanceof HisaaboApiError) {
730
- const err = e.hisaaboError;
731
- if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
732
- if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
733
- }
734
- fatalError(String(e instanceof Error ? e.message : e));
735
- }
736
- }