@hisaabo/cli 0.5.0 → 0.6.1

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 (67) hide show
  1. package/dist/bin/{audit-trail-5LOCJ7XZ.js → audit-trail-4AMEFQGB.js} +1 -1
  2. package/dist/bin/{categories-64WWZTND.js → categories-CLCBRNWC.js} +1 -1
  3. package/dist/bin/{check-slug-FLHHUDYS.js → check-slug-OKW7KDYG.js} +1 -1
  4. package/dist/bin/{chunk-4MEL44QX.js → chunk-GXRLFDZW.js} +234 -0
  5. package/dist/bin/{client-5NZ23GML.js → client-2ZKMLWI6.js} +1 -1
  6. package/dist/bin/{collection-efficiency-U56XNVEE.js → collection-efficiency-TECE6PVQ.js} +1 -1
  7. package/dist/bin/{create-RPDEORDD.js → create-AS2YVGRA.js} +1 -1
  8. package/dist/bin/{default-account-AE6EXZZR.js → default-account-3RVSU7RF.js} +1 -1
  9. package/dist/bin/{expenses-5N2QSG54.js → expenses-KXFQJKD6.js} +1 -1
  10. package/dist/bin/{export-QICOQK34.js → export-UHZISG7H.js} +1 -1
  11. package/dist/bin/{factory-KOCW2AQM.js → factory-OBESY2LG.js} +1 -1
  12. package/dist/bin/{get-GWH6S5SJ.js → get-GTL556HL.js} +1 -1
  13. package/dist/bin/{get-A43QCI2S.js → get-WUSYEMG4.js} +1 -1
  14. package/dist/bin/hisaabo.js +892 -55
  15. package/dist/bin/{invitations-P3EEN5WI.js → invitations-U4ZNYWY7.js} +1 -1
  16. package/dist/bin/{invite-T3CKX53E.js → invite-5S4GJKRF.js} +1 -1
  17. package/dist/bin/{invoice-breakdown-FN5BEFJD.js → invoice-breakdown-PP3BZQLG.js} +1 -1
  18. package/dist/bin/{items-2OOCQKVF.js → items-CHEFLI7C.js} +1 -1
  19. package/dist/bin/{items-toggle-SKZWCGJH.js → items-toggle-ETVCDCU6.js} +1 -1
  20. package/dist/bin/{list-A2RKI3ZG.js → list-3FO4UJKC.js} +1 -1
  21. package/dist/bin/{list-NRMBMKMI.js → list-LQJGTZB4.js} +1 -1
  22. package/dist/bin/{list-T74SN6IR.js → list-RJ34MFPR.js} +1 -1
  23. package/dist/bin/{members-W2GW3ODT.js → members-TE5K5NQC.js} +1 -1
  24. package/dist/bin/{monthly-comparison-T34ZFOHL.js → monthly-comparison-Q6KPMTPS.js} +1 -1
  25. package/dist/bin/{order-cancel-TI27JYYD.js → order-cancel-NOQDBL2N.js} +1 -1
  26. package/dist/bin/{order-confirm-VMRAMNTD.js → order-confirm-6WMKTGPV.js} +1 -1
  27. package/dist/bin/{order-get-C2RBUR4O.js → order-get-ONWR4GTW.js} +1 -1
  28. package/dist/bin/{order-update-RE3HATNF.js → order-update-IVO4AFGV.js} +1 -1
  29. package/dist/bin/{payment-modes-WOOT22I7.js → payment-modes-FXB2G6WP.js} +1 -1
  30. package/dist/bin/{profit-loss-T4RESJ32.js → profit-loss-XPYELDTH.js} +1 -1
  31. package/dist/bin/{receivables-aging-6XMENEWS.js → receivables-aging-MU6Q3DZ4.js} +1 -1
  32. package/dist/bin/{remove-6QZI4JCY.js → remove-DJBOOOR4.js} +1 -1
  33. package/dist/bin/{revoke-AVEMPAC7.js → revoke-5L5GZ4ZZ.js} +1 -1
  34. package/dist/bin/{revoke-YUCFZFNR.js → revoke-WRIK7HLY.js} +1 -1
  35. package/dist/bin/{revoke-all-LFW5WBHO.js → revoke-all-QARW2G6R.js} +1 -1
  36. package/dist/bin/{revoke-invitation-DTGQRJR4.js → revoke-invitation-ZGLJHYNB.js} +1 -1
  37. package/dist/bin/{sales-trend-ZYBRUDUU.js → sales-trend-P5HOZJSX.js} +1 -1
  38. package/dist/bin/{sequence-FPOJTI2P.js → sequence-LK6QLSI5.js} +1 -1
  39. package/dist/bin/{store-IOB4Y67C.js → store-FU7CEILC.js} +1 -1
  40. package/dist/bin/{summary-5KYBA4ZO.js → summary-XONLN72I.js} +1 -1
  41. package/dist/bin/{top-customers-WSQ2UEJL.js → top-customers-U6HQW2GH.js} +1 -1
  42. package/dist/bin/{top-items-RWQPDGLN.js → top-items-EAOIVZ4P.js} +1 -1
  43. package/dist/bin/{top-outstanding-QAMO2E7Y.js → top-outstanding-4546FJDH.js} +1 -1
  44. package/dist/bin/{unpaid-invoices-WB3TK5B4.js → unpaid-invoices-AED55PLC.js} +1 -1
  45. package/dist/bin/{untracked-H733MYJL.js → untracked-ZEM2CDHC.js} +1 -1
  46. package/dist/bin/{update-TLBUIC5J.js → update-FO7AAXF5.js} +1 -1
  47. package/dist/bin/{update-H6LPO2Z4.js → update-OZPBIBME.js} +1 -1
  48. package/dist/bin/{update-JU2X3XU5.js → update-QCK32XAG.js} +1 -1
  49. package/dist/bin/{update-role-QST7BVFX.js → update-role-RB35QIA5.js} +1 -1
  50. package/dist/bin/{update-settings-Q2EGRLKZ.js → update-settings-EUC2FJQJ.js} +1 -1
  51. package/package.json +1 -1
  52. package/src/bin/hisaabo.ts +10 -0
  53. package/src/bin/registrars/bank-recon.ts +34 -0
  54. package/src/bin/registrars/einvoice.ts +46 -0
  55. package/src/bin/registrars/ewb.ts +37 -0
  56. package/src/bin/registrars/gst.ts +17 -1
  57. package/src/bin/registrars/itc.ts +56 -0
  58. package/src/bin/registrars/journal.ts +47 -0
  59. package/src/bin/registrars/report.ts +44 -0
  60. package/src/client.ts +248 -0
  61. package/src/commands/bank-recon/index.ts +127 -0
  62. package/src/commands/einvoice/index.ts +109 -0
  63. package/src/commands/ewb/index.ts +108 -0
  64. package/src/commands/gst/index.ts +79 -1
  65. package/src/commands/itc/index.ts +163 -0
  66. package/src/commands/journal/index.ts +156 -0
  67. package/src/commands/report/index.ts +171 -0
@@ -5,6 +5,8 @@ import {
5
5
  reportSalesRegisterCommand, reportPurchaseRegisterCommand,
6
6
  reportPartyStatementCommand, reportPaymentSummaryCommand,
7
7
  reportCashFlowCommand, reportCollectionEfficiencyCommand,
8
+ reportTrialBalanceCommand, reportBalanceSheetCommand,
9
+ reportCashFlowStatementCommand, reportGeneralLedgerCommand,
8
10
  } from "../../commands/report/index.js";
9
11
 
10
12
  export function registerReportCommands(program: Command): void {
@@ -139,4 +141,46 @@ export function registerReportCommands(program: Command): void {
139
141
  .action(async (opts) => {
140
142
  await reportCollectionEfficiencyCommand(opts);
141
143
  });
144
+
145
+ report
146
+ .command("trial-balance")
147
+ .description("Trial balance report")
148
+ .option("--json", "JSON output")
149
+ .option("--to <date>", "As of date")
150
+ .option("--this-fy", "Current financial year")
151
+ .action(async (opts) => {
152
+ await reportTrialBalanceCommand(opts);
153
+ });
154
+
155
+ report
156
+ .command("balance-sheet")
157
+ .description("Balance sheet")
158
+ .option("--json", "JSON output")
159
+ .option("--to <date>", "As of date")
160
+ .option("--this-fy", "Current financial year")
161
+ .action(async (opts) => {
162
+ await reportBalanceSheetCommand(opts);
163
+ });
164
+
165
+ report
166
+ .command("cash-flow-statement")
167
+ .description("Cash flow statement (operating/investing/financing)")
168
+ .option("--json", "JSON output")
169
+ .option("--from <date>", "From date")
170
+ .option("--to <date>", "To date")
171
+ .option("--this-fy", "Current financial year")
172
+ .action(async (opts) => {
173
+ await reportCashFlowStatementCommand(opts);
174
+ });
175
+
176
+ report
177
+ .command("general-ledger <accountId>")
178
+ .description("General ledger for a specific account")
179
+ .option("--json", "JSON output")
180
+ .option("--from <date>", "From date")
181
+ .option("--to <date>", "To date")
182
+ .option("--this-fy", "Current financial year")
183
+ .action(async (accountId: string, opts) => {
184
+ await reportGeneralLedgerCommand(accountId, opts);
185
+ });
142
186
  }
package/src/client.ts CHANGED
@@ -485,6 +485,12 @@ export class HisaaboClient {
485
485
  gstr1CSV(input: GstReportInput) {
486
486
  return c.query<{ csv: string; filename: string }>("gst.gstr1CSV", input);
487
487
  },
488
+ gstr9(input: { financialYear: string }) {
489
+ return c.query<any>("gst.gstr9", input);
490
+ },
491
+ gstr2bUploads(input?: Record<string, unknown>) {
492
+ return c.query<any>("gstr2b.uploads", input ?? {});
493
+ },
488
494
  };
489
495
  }
490
496
 
@@ -587,6 +593,33 @@ export class HisaaboClient {
587
593
  collectionEfficiency(input: { fromDate: string; toDate: string }) {
588
594
  return c.query<any>("reports.collectionEfficiency", input);
589
595
  },
596
+ trialBalance(input?: Record<string, unknown>) {
597
+ return c.query<any>("reports.trialBalance", input ?? {});
598
+ },
599
+ balanceSheet(input?: Record<string, unknown>) {
600
+ return c.query<any>("reports.balanceSheet", input ?? {});
601
+ },
602
+ profitAndLoss(input?: Record<string, unknown>) {
603
+ return c.query<any>("reports.profitAndLoss", input ?? {});
604
+ },
605
+ cashFlowStatement(input?: Record<string, unknown>) {
606
+ return c.query<any>("reports.cashFlowStatement", input ?? {});
607
+ },
608
+ generalLedger(input: { accountId: string; fromDate?: string; toDate?: string }) {
609
+ return c.query<any>("reports.generalLedger", input);
610
+ },
611
+ comparativeTrialBalance(input?: Record<string, unknown>) {
612
+ return c.query<any>("reports.comparativeTrialBalance", input ?? {});
613
+ },
614
+ comparativeBalanceSheet(input?: Record<string, unknown>) {
615
+ return c.query<any>("reports.comparativeBalanceSheet", input ?? {});
616
+ },
617
+ comparativeProfitAndLoss(input?: Record<string, unknown>) {
618
+ return c.query<any>("reports.comparativeProfitAndLoss", input ?? {});
619
+ },
620
+ tallyExport(input?: Record<string, unknown>) {
621
+ return c.query<any>("reports.tallyExport", input ?? {});
622
+ },
590
623
  };
591
624
  }
592
625
 
@@ -935,6 +968,221 @@ export class HisaaboClient {
935
968
  },
936
969
  };
937
970
  }
971
+
972
+ // ── Journal ───────────────────────────────────────────────────
973
+
974
+ get journal() {
975
+ const c = this;
976
+ return {
977
+ list(input?: Record<string, unknown>) {
978
+ return c.query<any>("journal.list", input ?? {});
979
+ },
980
+ getById(id: string) {
981
+ return c.query<any>("journal.getById", { id });
982
+ },
983
+ create(input: Record<string, unknown>) {
984
+ return c.mutate<any>("journal.create", input);
985
+ },
986
+ update(input: Record<string, unknown>) {
987
+ return c.mutate<any>("journal.update", input);
988
+ },
989
+ void(id: string) {
990
+ return c.mutate<any>("journal.void", { id });
991
+ },
992
+ delete(id: string) {
993
+ return c.mutate<any>("journal.delete", { id });
994
+ },
995
+ templateList() {
996
+ return c.query<any>("journal.templateList");
997
+ },
998
+ templateCreate(input: Record<string, unknown>) {
999
+ return c.mutate<any>("journal.templateCreate", input);
1000
+ },
1001
+ templateDelete(id: string) {
1002
+ return c.mutate<any>("journal.templateDelete", { id });
1003
+ },
1004
+ createFromTemplate(input: Record<string, unknown>) {
1005
+ return c.mutate<any>("journal.createFromTemplate", input);
1006
+ },
1007
+ };
1008
+ }
1009
+
1010
+ // ── ITC ───────────────────────────────────────────────────────
1011
+
1012
+ get itc() {
1013
+ const c = this;
1014
+ return {
1015
+ dashboard(input?: Record<string, unknown>) {
1016
+ return c.query<any>("itc.dashboard", input ?? {});
1017
+ },
1018
+ ledger(input?: Record<string, unknown>) {
1019
+ return c.query<any>("itc.ledger", input ?? {});
1020
+ },
1021
+ agingAlerts() {
1022
+ return c.query<any>("itc.agingAlerts");
1023
+ },
1024
+ markBlocked(input: Record<string, unknown>) {
1025
+ return c.mutate<any>("itc.markBlocked", input);
1026
+ },
1027
+ markEligible(input: Record<string, unknown>) {
1028
+ return c.mutate<any>("itc.markEligible", input);
1029
+ },
1030
+ recordUtilization(input: Record<string, unknown>) {
1031
+ return c.mutate<any>("itc.recordUtilization", input);
1032
+ },
1033
+ gstr3bTable4(input?: Record<string, unknown>) {
1034
+ return c.query<any>("itc.gstr3bTable4", input ?? {});
1035
+ },
1036
+ };
1037
+ }
1038
+
1039
+ // ── Bank Recon ────────────────────────────────────────────────
1040
+
1041
+ get bankRecon() {
1042
+ const c = this;
1043
+ return {
1044
+ importList(input?: Record<string, unknown>) {
1045
+ return c.query<any>("bankRecon.importList", input ?? {});
1046
+ },
1047
+ importDetail(importId: string) {
1048
+ return c.query<any>("bankRecon.importDetail", { importId });
1049
+ },
1050
+ summary(importId: string) {
1051
+ return c.query<any>("bankRecon.summary", { importId });
1052
+ },
1053
+ lines(input: Record<string, unknown>) {
1054
+ return c.query<any>("bankRecon.lines", input);
1055
+ },
1056
+ ruleList() {
1057
+ return c.query<any>("bankRecon.ruleList");
1058
+ },
1059
+ ruleCreate(input: Record<string, unknown>) {
1060
+ return c.mutate<any>("bankRecon.ruleCreate", input);
1061
+ },
1062
+ ruleUpdate(input: Record<string, unknown>) {
1063
+ return c.mutate<any>("bankRecon.ruleUpdate", input);
1064
+ },
1065
+ ruleDelete(id: string) {
1066
+ return c.mutate<any>("bankRecon.ruleDelete", { id });
1067
+ },
1068
+ templateList() {
1069
+ return c.query<any>("bankRecon.templateList");
1070
+ },
1071
+ confirmMatch(input: Record<string, unknown>) {
1072
+ return c.mutate<any>("bankRecon.confirmMatch", input);
1073
+ },
1074
+ manualMatch(input: Record<string, unknown>) {
1075
+ return c.mutate<any>("bankRecon.manualMatch", input);
1076
+ },
1077
+ unmatch(input: Record<string, unknown>) {
1078
+ return c.mutate<any>("bankRecon.unmatch", input);
1079
+ },
1080
+ createExpense(input: Record<string, unknown>) {
1081
+ return c.mutate<any>("bankRecon.createExpense", input);
1082
+ },
1083
+ ignoreLine(input: Record<string, unknown>) {
1084
+ return c.mutate<any>("bankRecon.ignoreLine", input);
1085
+ },
1086
+ };
1087
+ }
1088
+
1089
+ // ── E-Invoice ─────────────────────────────────────────────────
1090
+
1091
+ get eInvoice() {
1092
+ const c = this;
1093
+ return {
1094
+ dashboard(input?: Record<string, unknown>) {
1095
+ return c.query<any>("eInvoice.dashboard", input ?? {});
1096
+ },
1097
+ generate(input: Record<string, unknown>) {
1098
+ return c.mutate<any>("eInvoice.generate", input);
1099
+ },
1100
+ cancel(input: Record<string, unknown>) {
1101
+ return c.mutate<any>("eInvoice.cancel", input);
1102
+ },
1103
+ retryFailed(input: Record<string, unknown>) {
1104
+ return c.mutate<any>("eInvoice.retryFailed", input);
1105
+ },
1106
+ bulkRetry(input?: Record<string, unknown>) {
1107
+ return c.mutate<any>("eInvoice.bulkRetry", input ?? {});
1108
+ },
1109
+ getStatus(invoiceId: string) {
1110
+ return c.query<any>("eInvoice.getStatus", { invoiceId });
1111
+ },
1112
+ };
1113
+ }
1114
+
1115
+ // ── E-Way Bill ────────────────────────────────────────────────
1116
+
1117
+ get ewayBill() {
1118
+ const c = this;
1119
+ return {
1120
+ dashboard(input?: Record<string, unknown>) {
1121
+ return c.query<any>("ewayBill.dashboard", input ?? {});
1122
+ },
1123
+ generate(input: Record<string, unknown>) {
1124
+ return c.mutate<any>("ewayBill.generate", input);
1125
+ },
1126
+ cancel(input: Record<string, unknown>) {
1127
+ return c.mutate<any>("ewayBill.cancel", input);
1128
+ },
1129
+ updateVehicle(input: Record<string, unknown>) {
1130
+ return c.mutate<any>("ewayBill.updateVehicle", input);
1131
+ },
1132
+ extend(input: Record<string, unknown>) {
1133
+ return c.mutate<any>("ewayBill.extend", input);
1134
+ },
1135
+ getByInvoice(invoiceId: string) {
1136
+ return c.query<any>("ewayBill.getByInvoice", { invoiceId });
1137
+ },
1138
+ expiringList(input?: Record<string, unknown>) {
1139
+ return c.query<any>("ewayBill.expiringList", input ?? {});
1140
+ },
1141
+ };
1142
+ }
1143
+
1144
+ // ── GSTR-2B ───────────────────────────────────────────────────
1145
+
1146
+ get gstr2b() {
1147
+ const c = this;
1148
+ return {
1149
+ uploads(input?: Record<string, unknown>) {
1150
+ return c.query<any>("gstr2b.uploads", input ?? {});
1151
+ },
1152
+ records(input: Record<string, unknown>) {
1153
+ return c.query<any>("gstr2b.records", input);
1154
+ },
1155
+ summary(input: Record<string, unknown>) {
1156
+ return c.query<any>("gstr2b.summary", input);
1157
+ },
1158
+ missingInBooks(input: Record<string, unknown>) {
1159
+ return c.query<any>("gstr2b.missingInBooks", input);
1160
+ },
1161
+ missingIn2B(input: Record<string, unknown>) {
1162
+ return c.query<any>("gstr2b.missingIn2B", input);
1163
+ },
1164
+ };
1165
+ }
1166
+
1167
+ // ── Account ───────────────────────────────────────────────────
1168
+
1169
+ get account() {
1170
+ const c = this;
1171
+ return {
1172
+ list(input?: Record<string, unknown>) {
1173
+ return c.query<any>("account.list", input ?? {});
1174
+ },
1175
+ create(input: Record<string, unknown>) {
1176
+ return c.mutate<any>("account.create", input);
1177
+ },
1178
+ update(input: Record<string, unknown>) {
1179
+ return c.mutate<any>("account.update", input);
1180
+ },
1181
+ delete(id: string) {
1182
+ return c.mutate<any>("account.delete", { id });
1183
+ },
1184
+ };
1185
+ }
938
1186
  }
939
1187
 
940
1188
  // ── Type definitions ───────────────────────────────────────────────────────
@@ -0,0 +1,127 @@
1
+ import { HisaaboClient, HisaaboApiError } from "../../client.js";
2
+ import { requireAuth } from "../../config.js";
3
+ import { fatalError, outputJSON, EXIT } from "../../output.js";
4
+ import { formatAmount, formatDate } from "../../format.js";
5
+
6
+ function handleError(e: unknown): never {
7
+ if (e instanceof HisaaboApiError) {
8
+ const err = e.hisaaboError;
9
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
10
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
11
+ }
12
+ fatalError(String(e instanceof Error ? e.message : e));
13
+ }
14
+
15
+ export async function bankReconImportsCommand(opts: { json?: boolean }): Promise<void> {
16
+ const cfg = requireAuth();
17
+ const client = new HisaaboClient(cfg);
18
+
19
+ try {
20
+ const result = await client.bankRecon.importList();
21
+
22
+ if (opts.json) {
23
+ outputJSON(result);
24
+ return;
25
+ }
26
+
27
+ const imports = Array.isArray(result) ? result
28
+ : Array.isArray(result?.data) ? result.data
29
+ : [];
30
+
31
+ console.log("\n Bank Reconciliation Imports\n");
32
+ console.log(` ${"═".repeat(65)}\n`);
33
+
34
+ if (imports.length === 0) {
35
+ console.log(" No imports found.\n");
36
+ return;
37
+ }
38
+
39
+ for (const imp of imports as Array<Record<string, unknown>>) {
40
+ const id = String(imp["id"] ?? "-").slice(0, 8);
41
+ const date = formatDate(String(imp["createdAt"] ?? imp["importDate"] ?? ""));
42
+ const account = String(imp["accountName"] ?? imp["bankAccount"] ?? "-").padEnd(20);
43
+ const lines = String(imp["totalLines"] ?? imp["lineCount"] ?? "-").padStart(6);
44
+ const matched = String(imp["matchedLines"] ?? imp["matched"] ?? "-").padStart(8);
45
+ const status = String(imp["status"] ?? "-").padEnd(10);
46
+ console.log(` ${id} ${date.padEnd(13)} ${account} Lines:${lines} Matched:${matched} ${status}`);
47
+ }
48
+ console.log();
49
+
50
+ } catch (e) {
51
+ handleError(e);
52
+ }
53
+ }
54
+
55
+ export async function bankReconSummaryCommand(importId: string, opts: { json?: boolean }): Promise<void> {
56
+ const cfg = requireAuth();
57
+ const client = new HisaaboClient(cfg);
58
+
59
+ try {
60
+ const result = await client.bankRecon.summary(importId);
61
+
62
+ if (opts.json) {
63
+ outputJSON(result);
64
+ return;
65
+ }
66
+
67
+ const r = result as Record<string, unknown>;
68
+ console.log(`\n Bank Recon Summary — ${importId}\n`);
69
+ console.log(` ${"═".repeat(55)}\n`);
70
+
71
+ const total = String(r["totalLines"] ?? r["total"] ?? "0");
72
+ const matched = String(r["matchedLines"] ?? r["matched"] ?? "0");
73
+ const unmatched = String(r["unmatchedLines"] ?? r["unmatched"] ?? "0");
74
+ const ignored = String(r["ignoredLines"] ?? r["ignored"] ?? "0");
75
+ const openingBalance = String(r["openingBalance"] ?? "0");
76
+ const closingBalance = String(r["closingBalance"] ?? "0");
77
+
78
+ console.log(` Total Lines: ${total.padStart(8)}`);
79
+ console.log(` Matched: ${matched.padStart(8)}`);
80
+ console.log(` Unmatched: ${unmatched.padStart(8)}`);
81
+ console.log(` Ignored: ${ignored.padStart(8)}`);
82
+ console.log(` Opening Balance: ${formatAmount(openingBalance).padStart(14)}`);
83
+ console.log(` Closing Balance: ${formatAmount(closingBalance).padStart(14)}`);
84
+ console.log();
85
+
86
+ } catch (e) {
87
+ handleError(e);
88
+ }
89
+ }
90
+
91
+ export async function bankReconRulesCommand(opts: { json?: boolean }): Promise<void> {
92
+ const cfg = requireAuth();
93
+ const client = new HisaaboClient(cfg);
94
+
95
+ try {
96
+ const result = await client.bankRecon.ruleList();
97
+
98
+ if (opts.json) {
99
+ outputJSON(result);
100
+ return;
101
+ }
102
+
103
+ const rules = Array.isArray(result) ? result
104
+ : Array.isArray(result?.data) ? result.data
105
+ : [];
106
+
107
+ console.log("\n Bank Recon Rules\n");
108
+ console.log(` ${"═".repeat(60)}\n`);
109
+
110
+ if (rules.length === 0) {
111
+ console.log(" No rules configured.\n");
112
+ return;
113
+ }
114
+
115
+ for (const rule of rules as Array<Record<string, unknown>>) {
116
+ const id = String(rule["id"] ?? "-").slice(0, 8);
117
+ const name = String(rule["name"] ?? "-").padEnd(25);
118
+ const condition = String(rule["condition"] ?? rule["matchPattern"] ?? "-").padEnd(20);
119
+ const action = String(rule["action"] ?? "-").padEnd(12);
120
+ console.log(` ${id} ${name} ${condition} ${action}`);
121
+ }
122
+ console.log();
123
+
124
+ } catch (e) {
125
+ handleError(e);
126
+ }
127
+ }
@@ -0,0 +1,109 @@
1
+ import { HisaaboClient, HisaaboApiError } from "../../client.js";
2
+ import { requireAuth } from "../../config.js";
3
+ import { fatalError, outputJSON, EXIT } from "../../output.js";
4
+
5
+ function handleError(e: unknown): never {
6
+ if (e instanceof HisaaboApiError) {
7
+ const err = e.hisaaboError;
8
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
9
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
10
+ }
11
+ fatalError(String(e instanceof Error ? e.message : e));
12
+ }
13
+
14
+ export async function eInvoiceDashboardCommand(opts: { json?: boolean; from?: string; to?: string }): Promise<void> {
15
+ const cfg = requireAuth();
16
+ const client = new HisaaboClient(cfg);
17
+
18
+ try {
19
+ const result = await client.eInvoice.dashboard({ fromDate: opts.from, toDate: opts.to });
20
+
21
+ if (opts.json) {
22
+ outputJSON(result);
23
+ return;
24
+ }
25
+
26
+ const r = result as Record<string, unknown>;
27
+ console.log("\n E-Invoice Dashboard\n");
28
+ console.log(` ${"═".repeat(50)}\n`);
29
+
30
+ const generated = String(r["totalGenerated"] ?? r["generated"] ?? "0");
31
+ const cancelled = String(r["totalCancelled"] ?? r["cancelled"] ?? "0");
32
+ const failed = String(r["totalFailed"] ?? r["failed"] ?? "0");
33
+ const pending = String(r["pending"] ?? "0");
34
+
35
+ console.log(` Generated: ${generated.padStart(8)}`);
36
+ console.log(` Cancelled: ${cancelled.padStart(8)}`);
37
+ console.log(` Failed: ${failed.padStart(8)}`);
38
+ console.log(` Pending: ${pending.padStart(8)}`);
39
+ console.log();
40
+
41
+ } catch (e) {
42
+ handleError(e);
43
+ }
44
+ }
45
+
46
+ export async function eInvoiceGenerateCommand(invoiceId: string, opts: { json?: boolean }): Promise<void> {
47
+ const cfg = requireAuth();
48
+ const client = new HisaaboClient(cfg);
49
+
50
+ try {
51
+ const result = await client.eInvoice.generate({ invoiceId });
52
+
53
+ if (opts.json) {
54
+ outputJSON(result);
55
+ return;
56
+ }
57
+
58
+ const r = result as Record<string, unknown>;
59
+ const irn = String(r["irn"] ?? r["invoiceReferenceNumber"] ?? "-");
60
+ const ackNo = String(r["ackNo"] ?? r["acknowledgementNumber"] ?? "-");
61
+ console.log(` E-Invoice generated.\n`);
62
+ console.log(` IRN: ${irn}`);
63
+ console.log(` ACK: ${ackNo}`);
64
+ console.log();
65
+
66
+ } catch (e) {
67
+ handleError(e);
68
+ }
69
+ }
70
+
71
+ export async function eInvoiceCancelCommand(invoiceId: string, opts: { json?: boolean; reason?: string }): Promise<void> {
72
+ const cfg = requireAuth();
73
+ const client = new HisaaboClient(cfg);
74
+
75
+ try {
76
+ const result = await client.eInvoice.cancel({ invoiceId, cancelReason: opts.reason ?? "1" });
77
+
78
+ if (opts.json) {
79
+ outputJSON(result);
80
+ return;
81
+ }
82
+
83
+ console.log(` E-Invoice for ${invoiceId} cancelled.\n`);
84
+
85
+ } catch (e) {
86
+ handleError(e);
87
+ }
88
+ }
89
+
90
+ export async function eInvoiceRetryCommand(invoiceId: string, opts: { json?: boolean }): Promise<void> {
91
+ const cfg = requireAuth();
92
+ const client = new HisaaboClient(cfg);
93
+
94
+ try {
95
+ const result = await client.eInvoice.retryFailed({ invoiceId });
96
+
97
+ if (opts.json) {
98
+ outputJSON(result);
99
+ return;
100
+ }
101
+
102
+ const r = result as Record<string, unknown>;
103
+ const status = String(r["status"] ?? "queued");
104
+ console.log(` Retry queued for invoice ${invoiceId}. Status: ${status}\n`);
105
+
106
+ } catch (e) {
107
+ handleError(e);
108
+ }
109
+ }
@@ -0,0 +1,108 @@
1
+ import { HisaaboClient, HisaaboApiError } from "../../client.js";
2
+ import { requireAuth } from "../../config.js";
3
+ import { fatalError, outputJSON, EXIT } from "../../output.js";
4
+ import { formatDate } from "../../format.js";
5
+
6
+ function handleError(e: unknown): never {
7
+ if (e instanceof HisaaboApiError) {
8
+ const err = e.hisaaboError;
9
+ if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
10
+ if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
11
+ }
12
+ fatalError(String(e instanceof Error ? e.message : e));
13
+ }
14
+
15
+ export async function ewbDashboardCommand(opts: { json?: boolean; from?: string; to?: string }): Promise<void> {
16
+ const cfg = requireAuth();
17
+ const client = new HisaaboClient(cfg);
18
+
19
+ try {
20
+ const result = await client.ewayBill.dashboard({ fromDate: opts.from, toDate: opts.to });
21
+
22
+ if (opts.json) {
23
+ outputJSON(result);
24
+ return;
25
+ }
26
+
27
+ const r = result as Record<string, unknown>;
28
+ console.log("\n E-Way Bill Dashboard\n");
29
+ console.log(` ${"═".repeat(50)}\n`);
30
+
31
+ const generated = String(r["totalGenerated"] ?? r["generated"] ?? "0");
32
+ const cancelled = String(r["totalCancelled"] ?? r["cancelled"] ?? "0");
33
+ const expired = String(r["totalExpired"] ?? r["expired"] ?? "0");
34
+ const active = String(r["active"] ?? "0");
35
+
36
+ console.log(` Generated: ${generated.padStart(8)}`);
37
+ console.log(` Active: ${active.padStart(8)}`);
38
+ console.log(` Cancelled: ${cancelled.padStart(8)}`);
39
+ console.log(` Expired: ${expired.padStart(8)}`);
40
+ console.log();
41
+
42
+ } catch (e) {
43
+ handleError(e);
44
+ }
45
+ }
46
+
47
+ export async function ewbGenerateCommand(invoiceId: string, opts: { json?: boolean }): Promise<void> {
48
+ const cfg = requireAuth();
49
+ const client = new HisaaboClient(cfg);
50
+
51
+ try {
52
+ const result = await client.ewayBill.generate({ invoiceId });
53
+
54
+ if (opts.json) {
55
+ outputJSON(result);
56
+ return;
57
+ }
58
+
59
+ const r = result as Record<string, unknown>;
60
+ const ewbNo = String(r["eWayBillNo"] ?? r["ewbNumber"] ?? r["ewbNo"] ?? "-");
61
+ const validUpto = String(r["validUpto"] ?? r["validTill"] ?? "-");
62
+ console.log(` E-Way Bill generated.\n`);
63
+ console.log(` EWB No: ${ewbNo}`);
64
+ console.log(` Valid Upto: ${validUpto}`);
65
+ console.log();
66
+
67
+ } catch (e) {
68
+ handleError(e);
69
+ }
70
+ }
71
+
72
+ export async function ewbExpiringCommand(opts: { json?: boolean; days?: number }): Promise<void> {
73
+ const cfg = requireAuth();
74
+ const client = new HisaaboClient(cfg);
75
+
76
+ try {
77
+ const result = await client.ewayBill.expiringList({ withinDays: opts.days ?? 3 });
78
+
79
+ if (opts.json) {
80
+ outputJSON(result);
81
+ return;
82
+ }
83
+
84
+ const bills = Array.isArray(result) ? result
85
+ : Array.isArray(result?.data) ? result.data
86
+ : [];
87
+
88
+ console.log(`\n Expiring E-Way Bills (within ${opts.days ?? 3} days)\n`);
89
+ console.log(` ${"═".repeat(65)}\n`);
90
+
91
+ if (bills.length === 0) {
92
+ console.log(" No expiring e-way bills.\n");
93
+ return;
94
+ }
95
+
96
+ for (const bill of bills as Array<Record<string, unknown>>) {
97
+ const ewbNo = String(bill["eWayBillNo"] ?? bill["ewbNumber"] ?? "-").padEnd(14);
98
+ const invoiceNo = String(bill["invoiceNumber"] ?? bill["invoice"] ?? "-").padEnd(14);
99
+ const party = String(bill["partyName"] ?? bill["party"] ?? "-").padEnd(22);
100
+ const validUpto = formatDate(String(bill["validUpto"] ?? bill["validTill"] ?? ""));
101
+ console.log(` ${ewbNo} ${invoiceNo} ${party} Expires: ${validUpto}`);
102
+ }
103
+ console.log();
104
+
105
+ } catch (e) {
106
+ handleError(e);
107
+ }
108
+ }