@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.
- package/LICENSE +31 -0
- package/README.md +9 -0
- package/dist/bin/{audit-trail-DLSSSM4T.js → audit-trail-IJ6SKACR.js} +2 -2
- package/dist/bin/{categories-63QR6WCV.js → categories-O6TODPAH.js} +2 -2
- package/dist/bin/{check-slug-NXO55WKH.js → check-slug-P7RFU6OP.js} +2 -2
- package/dist/bin/chunk-NO4FIFMS.js +0 -0
- package/dist/bin/{chunk-7MJDOL6B.js → chunk-QUITS2FE.js} +28 -0
- package/dist/bin/{chunk-M42SETRZ.js → chunk-WDN7RIE3.js} +23 -2
- package/dist/bin/chunk-ZPYC767N.js +0 -0
- package/dist/bin/{client-T32CIZA3.js → client-36JX5MR3.js} +1 -1
- package/dist/bin/{collection-efficiency-T6PWNTZO.js → collection-efficiency-DA5RWG3V.js} +2 -2
- package/dist/bin/{config-V4QFCONN.js → config-4LLNT4SH.js} +3 -1
- package/dist/bin/{create-NUKHDWLK.js → create-C5INBPQO.js} +2 -2
- package/dist/bin/{default-account-JWFPHMRF.js → default-account-2GMQ7ZA4.js} +2 -2
- package/dist/bin/{expenses-2UWUZVLI.js → expenses-S2YVA5UT.js} +2 -2
- package/dist/bin/{export-XSX7WQH7.js → export-YOOODNVX.js} +2 -2
- package/dist/bin/export-ZA43MLWO.js +191 -0
- package/dist/bin/{factory-BWOKRIP4.js → factory-6MUCSXTL.js} +2 -2
- package/dist/bin/{get-CHNTG3IM.js → get-GMQRROK2.js} +2 -2
- package/dist/bin/{get-ZSZ6SL3N.js → get-ZV3SC2VY.js} +2 -2
- package/dist/bin/hisaabo.js +100 -57
- package/dist/bin/import-UUHMLCKX.js +267 -0
- package/dist/bin/{invitations-H2SL3XAD.js → invitations-OVORTTMF.js} +2 -2
- package/dist/bin/{invite-EW73UIBE.js → invite-GGHBZY4U.js} +2 -2
- package/dist/bin/{invoice-breakdown-XP4QATCF.js → invoice-breakdown-32XXAZDP.js} +2 -2
- package/dist/bin/{items-DPD6EFTP.js → items-6NOIMH6B.js} +2 -2
- package/dist/bin/{items-toggle-R4OPSE4W.js → items-toggle-L6W6QKQD.js} +2 -2
- package/dist/bin/{list-PKHBE475.js → list-FC5JHKHD.js} +2 -2
- package/dist/bin/{list-KLEHBMQ2.js → list-OXAVDXH7.js} +2 -2
- package/dist/bin/{list-UR7OOJVF.js → list-RAR56EMQ.js} +2 -2
- package/dist/bin/{members-XA3TF4IQ.js → members-Y6XJVHHR.js} +2 -2
- package/dist/bin/{monthly-comparison-OLVS5HEY.js → monthly-comparison-IAUZ6SBJ.js} +2 -2
- package/dist/bin/{order-cancel-MXMJFFRR.js → order-cancel-QRTCNART.js} +2 -2
- package/dist/bin/{order-confirm-IXU45Q4L.js → order-confirm-LGQOMC4O.js} +2 -2
- package/dist/bin/{order-get-RDXMHLJ7.js → order-get-4XAQCRYV.js} +2 -2
- package/dist/bin/{order-update-KGIPBEJX.js → order-update-KZY4H2UR.js} +2 -2
- package/dist/bin/output-NUOL7KJW.js +0 -0
- package/dist/bin/{payment-modes-CZL35SVS.js → payment-modes-DY2ZEMK7.js} +2 -2
- package/dist/bin/{profit-loss-M332OSC5.js → profit-loss-5GJBG3PL.js} +2 -2
- package/dist/bin/{receivables-aging-OXRHGMBF.js → receivables-aging-6A7XJKDT.js} +2 -2
- package/dist/bin/{remove-I5HD2Y4K.js → remove-ZBX34TIQ.js} +2 -2
- package/dist/bin/{revoke-OC6AOMIZ.js → revoke-XDNOA2GJ.js} +2 -2
- package/dist/bin/{revoke-MFLWGCMP.js → revoke-ZTAMW2Q2.js} +2 -2
- package/dist/bin/{revoke-all-FSAPBB3P.js → revoke-all-365NRBOA.js} +2 -2
- package/dist/bin/{revoke-invitation-JXDPXTOW.js → revoke-invitation-PQH7XNYA.js} +2 -2
- package/dist/bin/{sales-trend-KK63WNDL.js → sales-trend-D6PQ7MHY.js} +2 -2
- package/dist/bin/{sequence-IQ4HUJ3W.js → sequence-KZWADVD7.js} +2 -2
- package/dist/bin/{store-6QT6HKG2.js → store-SVRZBUFO.js} +2 -2
- package/dist/bin/{summary-3FTF5B4A.js → summary-H6U7O5GJ.js} +2 -2
- package/dist/bin/{top-customers-HNYGXBQZ.js → top-customers-ATBN6RDI.js} +2 -2
- package/dist/bin/{top-items-JUDG3BVW.js → top-items-XXU6KYTC.js} +2 -2
- package/dist/bin/{top-outstanding-WK26ZNE5.js → top-outstanding-JTQNGGW4.js} +2 -2
- package/dist/bin/{unpaid-invoices-RYFIIIK7.js → unpaid-invoices-BTNQFWCH.js} +2 -2
- package/dist/bin/{untracked-FAFS3KCK.js → untracked-PAMEDJ6Y.js} +2 -2
- package/dist/bin/{update-5YSPXIWO.js → update-6ZMX2OYX.js} +2 -2
- package/dist/bin/{update-I46XLU77.js → update-EGHPFXLK.js} +2 -2
- package/dist/bin/{update-NAW2JWZS.js → update-EK4NJWU4.js} +2 -2
- package/dist/bin/{update-role-5GV42MSN.js → update-role-24PDTNFK.js} +2 -2
- package/dist/bin/{update-settings-KYSQDIEO.js → update-settings-AASI6WZX.js} +2 -2
- package/package.json +35 -9
- package/.turbo/turbo-build.log +0 -13
- package/.turbo/turbo-typecheck.log +0 -4
- package/CLI-UX-ARCHITECTURE.md +0 -1269
- package/src/auth.ts +0 -221
- package/src/bin/hisaabo.ts +0 -74
- package/src/bin/registrars/api-key.ts +0 -44
- package/src/bin/registrars/auth.ts +0 -222
- package/src/bin/registrars/automated-invoice.ts +0 -167
- package/src/bin/registrars/bank-recon.ts +0 -34
- package/src/bin/registrars/bank.ts +0 -124
- package/src/bin/registrars/business.ts +0 -120
- package/src/bin/registrars/dashboard.ts +0 -225
- package/src/bin/registrars/document.ts +0 -184
- package/src/bin/registrars/einvoice.ts +0 -46
- package/src/bin/registrars/ewb.ts +0 -37
- package/src/bin/registrars/expense.ts +0 -87
- package/src/bin/registrars/gst.ts +0 -57
- package/src/bin/registrars/import.ts +0 -49
- package/src/bin/registrars/invoice.ts +0 -117
- package/src/bin/registrars/itc.ts +0 -56
- package/src/bin/registrars/item.ts +0 -112
- package/src/bin/registrars/journal.ts +0 -47
- package/src/bin/registrars/party.ts +0 -81
- package/src/bin/registrars/payment.ts +0 -128
- package/src/bin/registrars/report.ts +0 -186
- package/src/bin/registrars/session.ts +0 -32
- package/src/bin/registrars/shipment.ts +0 -74
- package/src/bin/registrars/store.ts +0 -128
- package/src/bin/registrars/target.ts +0 -46
- package/src/bin/registrars/tenant.ts +0 -73
- package/src/client.ts +0 -2071
- package/src/commands/api-key/create.ts +0 -72
- package/src/commands/api-key/list.ts +0 -71
- package/src/commands/api-key/revoke.ts +0 -46
- package/src/commands/automated-invoice/create.ts +0 -85
- package/src/commands/automated-invoice/delete.ts +0 -42
- package/src/commands/automated-invoice/get.ts +0 -113
- package/src/commands/automated-invoice/history.ts +0 -65
- package/src/commands/automated-invoice/index.ts +0 -11
- package/src/commands/automated-invoice/list.ts +0 -91
- package/src/commands/automated-invoice/pause.ts +0 -29
- package/src/commands/automated-invoice/resume.ts +0 -29
- package/src/commands/automated-invoice/run-now.ts +0 -29
- package/src/commands/automated-invoice/suggestions.ts +0 -68
- package/src/commands/automated-invoice/update.ts +0 -54
- package/src/commands/automated-invoice/usage.ts +0 -68
- package/src/commands/bank/gateway-config.ts +0 -61
- package/src/commands/bank/index.ts +0 -244
- package/src/commands/bank/update-gateway.ts +0 -84
- package/src/commands/bank-recon/index.ts +0 -127
- package/src/commands/business/audit-trail.ts +0 -79
- package/src/commands/business/export.ts +0 -52
- package/src/commands/business/get.ts +0 -55
- package/src/commands/business/sequence.ts +0 -65
- package/src/commands/business/update.ts +0 -64
- package/src/commands/dashboard/collection-efficiency.ts +0 -164
- package/src/commands/dashboard/expenses.ts +0 -76
- package/src/commands/dashboard/invoice-breakdown.ts +0 -89
- package/src/commands/dashboard/monthly-comparison.ts +0 -193
- package/src/commands/dashboard/payment-modes.ts +0 -121
- package/src/commands/dashboard/profit-loss.ts +0 -146
- package/src/commands/dashboard/receivables-aging.ts +0 -169
- package/src/commands/dashboard/sales-trend.ts +0 -68
- package/src/commands/dashboard/summary.ts +0 -105
- package/src/commands/dashboard/top-customers.ts +0 -70
- package/src/commands/dashboard/top-items.ts +0 -74
- package/src/commands/dashboard/top-outstanding.ts +0 -61
- package/src/commands/dashboard.ts +0 -105
- package/src/commands/document/factory.ts +0 -590
- package/src/commands/einvoice/index.ts +0 -109
- package/src/commands/ewb/index.ts +0 -108
- package/src/commands/expense/categories.ts +0 -40
- package/src/commands/expense/create.ts +0 -51
- package/src/commands/expense/delete.ts +0 -45
- package/src/commands/expense/list.ts +0 -65
- package/src/commands/expense/update.ts +0 -58
- package/src/commands/gst/index.ts +0 -194
- package/src/commands/import/index.ts +0 -168
- package/src/commands/invoice/create.ts +0 -262
- package/src/commands/invoice/delete.ts +0 -44
- package/src/commands/invoice/get.ts +0 -113
- package/src/commands/invoice/list.ts +0 -126
- package/src/commands/invoice/pdf.ts +0 -75
- package/src/commands/invoice/status.ts +0 -41
- package/src/commands/itc/index.ts +0 -163
- package/src/commands/item/categories.ts +0 -40
- package/src/commands/item/create.ts +0 -98
- package/src/commands/item/delete.ts +0 -44
- package/src/commands/item/list.ts +0 -81
- package/src/commands/item/low-stock-count.ts +0 -32
- package/src/commands/item/merge.ts +0 -53
- package/src/commands/item/price-history.ts +0 -59
- package/src/commands/item/rename-unit.ts +0 -39
- package/src/commands/item/sales-stats.ts +0 -44
- package/src/commands/item/stock-history.ts +0 -70
- package/src/commands/item/stock.ts +0 -46
- package/src/commands/item/switch-base-unit.ts +0 -42
- package/src/commands/item/update.ts +0 -59
- package/src/commands/item/variants-create.ts +0 -58
- package/src/commands/item/variants-delete.ts +0 -47
- package/src/commands/item/variants-list.ts +0 -63
- package/src/commands/item/variants-update.ts +0 -61
- package/src/commands/journal/index.ts +0 -156
- package/src/commands/party/create.ts +0 -88
- package/src/commands/party/delete.ts +0 -44
- package/src/commands/party/get.ts +0 -42
- package/src/commands/party/ledger-report.ts +0 -81
- package/src/commands/party/ledger.ts +0 -63
- package/src/commands/party/list.ts +0 -69
- package/src/commands/party/merge.ts +0 -50
- package/src/commands/party/stats.ts +0 -40
- package/src/commands/party/top-items.ts +0 -57
- package/src/commands/party/update.ts +0 -65
- package/src/commands/payment/create.ts +0 -131
- package/src/commands/payment/default-account.ts +0 -56
- package/src/commands/payment/delete.ts +0 -46
- package/src/commands/payment/get.ts +0 -59
- package/src/commands/payment/list.ts +0 -66
- package/src/commands/payment/unpaid-invoices.ts +0 -69
- package/src/commands/payment/untracked.ts +0 -70
- package/src/commands/payment/update.ts +0 -54
- package/src/commands/report/index.ts +0 -736
- package/src/commands/session/list.ts +0 -91
- package/src/commands/session/revoke-all.ts +0 -20
- package/src/commands/session/revoke.ts +0 -32
- package/src/commands/shipment/index.ts +0 -170
- package/src/commands/store/check-slug.ts +0 -48
- package/src/commands/store/index.ts +0 -77
- package/src/commands/store/items-toggle.ts +0 -41
- package/src/commands/store/items.ts +0 -61
- package/src/commands/store/order-cancel.ts +0 -48
- package/src/commands/store/order-confirm.ts +0 -45
- package/src/commands/store/order-get.ts +0 -66
- package/src/commands/store/order-update.ts +0 -52
- package/src/commands/store/update-settings.ts +0 -52
- package/src/commands/target/index.ts +0 -118
- package/src/commands/tenant/invitations.ts +0 -62
- package/src/commands/tenant/invite.ts +0 -57
- package/src/commands/tenant/list.ts +0 -46
- package/src/commands/tenant/members.ts +0 -55
- package/src/commands/tenant/remove.ts +0 -47
- package/src/commands/tenant/revoke-invitation.ts +0 -32
- package/src/commands/tenant/update-role.ts +0 -41
- package/src/config.ts +0 -120
- package/src/error-handler.ts +0 -53
- package/src/format.ts +0 -181
- package/src/output.ts +0 -228
- package/src/spinner.ts +0 -39
- package/tsconfig.json +0 -22
- package/tsup.config.ts +0 -18
|
@@ -1,108 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { HisaaboClient, HisaaboApiError } from "../../client.js";
|
|
2
|
-
import { requireAuth } from "../../config.js";
|
|
3
|
-
import { fatalError, outputJSON, EXIT } from "../../output.js";
|
|
4
|
-
|
|
5
|
-
interface CategoriesOpts {
|
|
6
|
-
json?: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export async function expenseCategoriesCommand(opts: CategoriesOpts): Promise<void> {
|
|
10
|
-
const cfg = requireAuth();
|
|
11
|
-
const client = new HisaaboClient(cfg);
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const categories = await client.expense.categories();
|
|
15
|
-
|
|
16
|
-
if (opts.json) {
|
|
17
|
-
outputJSON(categories);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!categories || categories.length === 0) {
|
|
22
|
-
console.log("\n No expense categories found.\n");
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
console.log(`\n Expense Categories (${categories.length})\n`);
|
|
27
|
-
for (const cat of categories) {
|
|
28
|
-
console.log(` ${cat}`);
|
|
29
|
-
}
|
|
30
|
-
console.log();
|
|
31
|
-
|
|
32
|
-
} catch (e) {
|
|
33
|
-
if (e instanceof HisaaboApiError) {
|
|
34
|
-
const err = e.hisaaboError;
|
|
35
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
36
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
37
|
-
}
|
|
38
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { HisaaboClient, HisaaboApiError } from "../../client.js";
|
|
2
|
-
import { requireAuth } from "../../config.js";
|
|
3
|
-
import { fatalError, outputJSON, EXIT, success } from "../../output.js";
|
|
4
|
-
import { formatINR, todayISO } from "../../format.js";
|
|
5
|
-
|
|
6
|
-
interface CreateOpts {
|
|
7
|
-
json?: boolean;
|
|
8
|
-
category?: string;
|
|
9
|
-
amount?: string;
|
|
10
|
-
mode?: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
date?: string;
|
|
13
|
-
reference?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function expenseCreateCommand(opts: CreateOpts): Promise<void> {
|
|
17
|
-
const cfg = requireAuth();
|
|
18
|
-
const client = new HisaaboClient(cfg);
|
|
19
|
-
|
|
20
|
-
if (!opts.category) fatalError("--category is required", EXIT.USAGE);
|
|
21
|
-
if (!opts.amount) fatalError("--amount is required", EXIT.USAGE);
|
|
22
|
-
|
|
23
|
-
const mode = (opts.mode ?? "cash") as "cash" | "bank" | "upi" | "cheque" | "other";
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const expense = await client.expense.create({
|
|
27
|
-
category: opts.category,
|
|
28
|
-
amount: opts.amount,
|
|
29
|
-
mode,
|
|
30
|
-
description: opts.description,
|
|
31
|
-
expenseDate: opts.date ?? todayISO(),
|
|
32
|
-
referenceNumber: opts.reference,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (opts.json) {
|
|
36
|
-
outputJSON(expense);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
success(`Created: ${expense.category} ${formatINR(expense.amount)}`);
|
|
41
|
-
|
|
42
|
-
} catch (e) {
|
|
43
|
-
if (e instanceof HisaaboApiError) {
|
|
44
|
-
const err = e.hisaaboError;
|
|
45
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
46
|
-
if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
|
|
47
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
48
|
-
}
|
|
49
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as readline from "readline";
|
|
2
|
-
import { HisaaboClient, HisaaboApiError } from "../../client.js";
|
|
3
|
-
import { requireAuth } from "../../config.js";
|
|
4
|
-
import { fatalError, outputJSON, EXIT, success } from "../../output.js";
|
|
5
|
-
|
|
6
|
-
export async function expenseDeleteCommand(id: string, opts: { yes?: boolean; json?: boolean }): Promise<void> {
|
|
7
|
-
const cfg = requireAuth();
|
|
8
|
-
const client = new HisaaboClient(cfg);
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
// Fetch expense first
|
|
12
|
-
const _list = await client.expense.list({ page: 1, limit: 1 });
|
|
13
|
-
// We can't get by ID directly; use delete and check error
|
|
14
|
-
if (!opts.yes && process.stdin.isTTY) {
|
|
15
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
16
|
-
const answer = await new Promise<string>((resolve) => {
|
|
17
|
-
rl.question(` Delete expense ${id}? (y/N): `, resolve);
|
|
18
|
-
});
|
|
19
|
-
rl.close();
|
|
20
|
-
if (answer.trim().toLowerCase() !== "y") {
|
|
21
|
-
console.log(" Cancelled.");
|
|
22
|
-
process.exit(0);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const result = await client.expense.delete(id);
|
|
27
|
-
|
|
28
|
-
if (opts.json) {
|
|
29
|
-
outputJSON(result);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
success(`Deleted expense: ${id}`);
|
|
34
|
-
|
|
35
|
-
} catch (e) {
|
|
36
|
-
if (e instanceof HisaaboApiError) {
|
|
37
|
-
const err = e.hisaaboError;
|
|
38
|
-
if (err.code === "not_found") fatalError(`Expense not found: ${id}`, EXIT.NOT_FOUND);
|
|
39
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
40
|
-
if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
|
|
41
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
42
|
-
}
|
|
43
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { HisaaboClient, HisaaboApiError, type ExpenseSummary } from "../../client.js";
|
|
2
|
-
import { requireAuth } from "../../config.js";
|
|
3
|
-
import {
|
|
4
|
-
fatalError, outputJSON, outputTable, outputTSV, outputCSV, outputIds,
|
|
5
|
-
paginationFooter, EXIT, type ColumnDef,
|
|
6
|
-
} from "../../output.js";
|
|
7
|
-
import { formatAmount, formatDate } from "../../format.js";
|
|
8
|
-
|
|
9
|
-
interface ListOpts {
|
|
10
|
-
json?: boolean;
|
|
11
|
-
format?: string;
|
|
12
|
-
category?: string;
|
|
13
|
-
from?: string;
|
|
14
|
-
to?: string;
|
|
15
|
-
page?: number;
|
|
16
|
-
limit?: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export async function expenseListCommand(opts: ListOpts): Promise<void> {
|
|
20
|
-
const cfg = requireAuth();
|
|
21
|
-
const client = new HisaaboClient(cfg);
|
|
22
|
-
const page = opts.page ?? 1;
|
|
23
|
-
const limit = opts.limit ?? 20;
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const result = await client.expense.list({
|
|
27
|
-
category: opts.category ?? null,
|
|
28
|
-
fromDate: opts.from ?? null,
|
|
29
|
-
toDate: opts.to ?? null,
|
|
30
|
-
page,
|
|
31
|
-
limit,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if (opts.json) {
|
|
35
|
-
outputJSON({ data: result.data, pagination: { page: result.page, limit: result.limit, total: result.total } });
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
console.log(`\n Expenses ${result.total} total\n`);
|
|
40
|
-
|
|
41
|
-
const cols: ColumnDef<ExpenseSummary>[] = [
|
|
42
|
-
{ key: "expenseDate", header: "Date", width: 13, format: (v) => formatDate(String(v ?? "")) },
|
|
43
|
-
{ key: "category", header: "Category", width: 18 },
|
|
44
|
-
{ key: "description", header: "Description", width: 22, format: (v) => String(v ?? "-") },
|
|
45
|
-
{ key: "amount", header: "Amount (₹)", align: "right", width: 13, format: (v) => formatAmount(String(v ?? "0")) },
|
|
46
|
-
{ key: "mode", header: "Mode", width: 8 },
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
if (opts.format === "tsv") outputTSV(result.data, cols);
|
|
50
|
-
else if (opts.format === "csv") outputCSV(result.data, cols);
|
|
51
|
-
else if (opts.format === "ids") outputIds(result.data.map((r) => r.id));
|
|
52
|
-
else {
|
|
53
|
-
outputTable(result.data, cols);
|
|
54
|
-
paginationFooter(result.page, result.limit, result.total);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
} catch (e) {
|
|
58
|
-
if (e instanceof HisaaboApiError) {
|
|
59
|
-
const err = e.hisaaboError;
|
|
60
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
61
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
62
|
-
}
|
|
63
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { HisaaboClient, HisaaboApiError, type ExpenseCreateInput } from "../../client.js";
|
|
2
|
-
import { requireAuth } from "../../config.js";
|
|
3
|
-
import { fatalError, outputJSON, EXIT, success } from "../../output.js";
|
|
4
|
-
import { formatINR } from "../../format.js";
|
|
5
|
-
|
|
6
|
-
interface UpdateOpts {
|
|
7
|
-
json?: boolean;
|
|
8
|
-
amount?: string;
|
|
9
|
-
category?: string;
|
|
10
|
-
date?: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
paymentMode?: string;
|
|
13
|
-
reference?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function expenseUpdateCommand(id: string, opts: UpdateOpts): Promise<void> {
|
|
17
|
-
const cfg = requireAuth();
|
|
18
|
-
const client = new HisaaboClient(cfg);
|
|
19
|
-
|
|
20
|
-
// Build update payload — only send fields explicitly provided
|
|
21
|
-
const data: Partial<ExpenseCreateInput> = {};
|
|
22
|
-
|
|
23
|
-
if (opts.amount !== undefined) data.amount = opts.amount;
|
|
24
|
-
if (opts.category !== undefined) data.category = opts.category;
|
|
25
|
-
if (opts.date !== undefined) data.expenseDate = opts.date;
|
|
26
|
-
if (opts.description !== undefined) data.description = opts.description;
|
|
27
|
-
if (opts.paymentMode !== undefined) data.mode = opts.paymentMode as ExpenseCreateInput["mode"];
|
|
28
|
-
if (opts.reference !== undefined) data.referenceNumber = opts.reference;
|
|
29
|
-
|
|
30
|
-
if (Object.keys(data).length === 0) {
|
|
31
|
-
fatalError(
|
|
32
|
-
"No fields to update. Provide at least one option: --amount, --category, --date, --description, --payment-mode, --reference",
|
|
33
|
-
EXIT.USAGE,
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
const expense = await client.expense.update(id, data);
|
|
39
|
-
|
|
40
|
-
if (opts.json) {
|
|
41
|
-
outputJSON(expense);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
success(`Updated: ${expense.category} — ${formatINR(expense.amount)}`);
|
|
46
|
-
|
|
47
|
-
} catch (e) {
|
|
48
|
-
if (e instanceof HisaaboApiError) {
|
|
49
|
-
const err = e.hisaaboError;
|
|
50
|
-
if (err.code === "not_found") fatalError(`Expense not found: ${id}`, EXIT.NOT_FOUND);
|
|
51
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
52
|
-
if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
|
|
53
|
-
if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
|
|
54
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
55
|
-
}
|
|
56
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { HisaaboClient, HisaaboApiError } from "../../client.js";
|
|
2
|
-
import { requireAuth } from "../../config.js";
|
|
3
|
-
import { fatalError, outputJSON, EXIT } from "../../output.js";
|
|
4
|
-
import { formatAmount, quarterRange, formatDate } from "../../format.js";
|
|
5
|
-
import * as fs from "fs";
|
|
6
|
-
|
|
7
|
-
interface GstOpts {
|
|
8
|
-
json?: boolean;
|
|
9
|
-
quarter?: string;
|
|
10
|
-
month?: number;
|
|
11
|
-
year?: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function resolveMonthYear(opts: GstOpts): { month: number; year: number } {
|
|
15
|
-
if (opts.quarter) {
|
|
16
|
-
const range = quarterRange(opts.quarter);
|
|
17
|
-
return { month: range.month, year: range.year };
|
|
18
|
-
}
|
|
19
|
-
const now = new Date();
|
|
20
|
-
return {
|
|
21
|
-
month: opts.month ?? (now.getMonth() + 1),
|
|
22
|
-
year: opts.year ?? now.getFullYear(),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function gstR1Command(opts: GstOpts): Promise<void> {
|
|
27
|
-
const cfg = requireAuth();
|
|
28
|
-
const client = new HisaaboClient(cfg);
|
|
29
|
-
const { month, year } = resolveMonthYear(opts);
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const report = await client.gst.gstr1({ month, year });
|
|
33
|
-
|
|
34
|
-
if (opts.json) {
|
|
35
|
-
outputJSON(report);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const quarterLabel = opts.quarter ? `${opts.quarter} ` : "";
|
|
40
|
-
console.log(`\n GSTR-1 Summary ${quarterLabel}FY ${year}-${String(year + 1).slice(2)}`);
|
|
41
|
-
console.log(` ${"═".repeat(60)}\n`);
|
|
42
|
-
|
|
43
|
-
if (report.summary && typeof report.summary === "object") {
|
|
44
|
-
const s = report.summary as Record<string, unknown>;
|
|
45
|
-
if (s["totalTaxableValue"]) console.log(` Total Taxable: ${formatAmount(String(s["totalTaxableValue"]))}`);
|
|
46
|
-
if (s["totalTax"]) console.log(` Total Tax: ${formatAmount(String(s["totalTax"]))}`);
|
|
47
|
-
if (s["totalInvoices"]) console.log(` Total Invoices: ${s["totalInvoices"]}`);
|
|
48
|
-
}
|
|
49
|
-
console.log();
|
|
50
|
-
console.log(" Use --json for full report data.");
|
|
51
|
-
console.log(" Use: hisaabo gst r1-csv to download GSTN-compatible CSV.\n");
|
|
52
|
-
|
|
53
|
-
} catch (e) {
|
|
54
|
-
if (e instanceof HisaaboApiError) {
|
|
55
|
-
const err = e.hisaaboError;
|
|
56
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
57
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
58
|
-
}
|
|
59
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export async function gstR3bCommand(opts: GstOpts): Promise<void> {
|
|
64
|
-
const cfg = requireAuth();
|
|
65
|
-
const client = new HisaaboClient(cfg);
|
|
66
|
-
const { month, year } = resolveMonthYear(opts);
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
const report = await client.gst.gstr3b({ month, year });
|
|
70
|
-
|
|
71
|
-
if (opts.json) {
|
|
72
|
-
outputJSON(report);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
console.log(`\n GSTR-3B Summary ${month}/${year}`);
|
|
77
|
-
console.log(` ${"═".repeat(60)}\n`);
|
|
78
|
-
|
|
79
|
-
if (report.summary && typeof report.summary === "object") {
|
|
80
|
-
const s = report.summary as Record<string, unknown>;
|
|
81
|
-
Object.entries(s).forEach(([k, v]) => {
|
|
82
|
-
console.log(` ${k.padEnd(28)}: ${String(v ?? "-")}`);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
console.log();
|
|
86
|
-
|
|
87
|
-
} catch (e) {
|
|
88
|
-
if (e instanceof HisaaboApiError) {
|
|
89
|
-
const err = e.hisaaboError;
|
|
90
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
91
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
92
|
-
}
|
|
93
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function gstR1CsvCommand(opts: GstOpts & { output?: string }): Promise<void> {
|
|
98
|
-
const cfg = requireAuth();
|
|
99
|
-
const client = new HisaaboClient(cfg);
|
|
100
|
-
const { month, year } = resolveMonthYear(opts);
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
const result = await client.gst.gstr1CSV({ month, year });
|
|
104
|
-
const outputPath = opts.output ?? result.filename;
|
|
105
|
-
fs.writeFileSync(outputPath, result.csv);
|
|
106
|
-
console.log(` Saved: ${outputPath}`);
|
|
107
|
-
|
|
108
|
-
} catch (e) {
|
|
109
|
-
if (e instanceof HisaaboApiError) {
|
|
110
|
-
const err = e.hisaaboError;
|
|
111
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
112
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
113
|
-
}
|
|
114
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export async function gstR9Command(financialYear: string, opts: GstOpts): Promise<void> {
|
|
119
|
-
const cfg = requireAuth();
|
|
120
|
-
const client = new HisaaboClient(cfg);
|
|
121
|
-
|
|
122
|
-
try {
|
|
123
|
-
const report = await client.gst.gstr9({ financialYear });
|
|
124
|
-
|
|
125
|
-
if (opts.json) {
|
|
126
|
-
outputJSON(report);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
console.log(`\n GSTR-9 Annual Return — FY ${financialYear}`);
|
|
131
|
-
console.log(` ${"═".repeat(60)}\n`);
|
|
132
|
-
|
|
133
|
-
const r = report as Record<string, unknown>;
|
|
134
|
-
if (r["summary"] && typeof r["summary"] === "object") {
|
|
135
|
-
const s = r["summary"] as Record<string, unknown>;
|
|
136
|
-
if (s["totalTurnover"]) console.log(` Total Turnover: ${formatAmount(String(s["totalTurnover"]))}`);
|
|
137
|
-
if (s["totalTax"]) console.log(` Total Tax: ${formatAmount(String(s["totalTax"]))}`);
|
|
138
|
-
if (s["totalITC"]) console.log(` Total ITC: ${formatAmount(String(s["totalITC"]))}`);
|
|
139
|
-
}
|
|
140
|
-
console.log();
|
|
141
|
-
console.log(" Use --json for full GSTR-9 data.\n");
|
|
142
|
-
|
|
143
|
-
} catch (e) {
|
|
144
|
-
if (e instanceof HisaaboApiError) {
|
|
145
|
-
const err = e.hisaaboError;
|
|
146
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
147
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
148
|
-
}
|
|
149
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export async function gstr2bUploadsCommand(opts: GstOpts): Promise<void> {
|
|
154
|
-
const cfg = requireAuth();
|
|
155
|
-
const client = new HisaaboClient(cfg);
|
|
156
|
-
|
|
157
|
-
try {
|
|
158
|
-
const result = await client.gst.gstr2bUploads();
|
|
159
|
-
|
|
160
|
-
if (opts.json) {
|
|
161
|
-
outputJSON(result);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const uploads = Array.isArray(result) ? result
|
|
166
|
-
: Array.isArray(result?.data) ? result.data
|
|
167
|
-
: [];
|
|
168
|
-
|
|
169
|
-
console.log("\n GSTR-2B Uploads\n");
|
|
170
|
-
console.log(` ${"═".repeat(60)}\n`);
|
|
171
|
-
|
|
172
|
-
if (uploads.length === 0) {
|
|
173
|
-
console.log(" No uploads found.\n");
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
for (const up of uploads as Array<Record<string, unknown>>) {
|
|
178
|
-
const id = String(up["id"] ?? "-").slice(0, 8);
|
|
179
|
-
const period = String(up["period"] ?? up["returnPeriod"] ?? "-").padEnd(10);
|
|
180
|
-
const date = formatDate(String(up["uploadedAt"] ?? up["createdAt"] ?? ""));
|
|
181
|
-
const records = String(up["totalRecords"] ?? up["records"] ?? "-").padStart(8);
|
|
182
|
-
console.log(` ${id} ${period} ${date.padEnd(13)} Records: ${records}`);
|
|
183
|
-
}
|
|
184
|
-
console.log();
|
|
185
|
-
|
|
186
|
-
} catch (e) {
|
|
187
|
-
if (e instanceof HisaaboApiError) {
|
|
188
|
-
const err = e.hisaaboError;
|
|
189
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
190
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
191
|
-
}
|
|
192
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
193
|
-
}
|
|
194
|
-
}
|