@hisaabo/cli 0.1.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-typecheck.log +1 -1
- package/README.md +332 -0
- package/dist/bin/audit-trail-5LOCJ7XZ.js +78 -0
- package/dist/bin/categories-64WWZTND.js +47 -0
- package/dist/bin/check-slug-FLHHUDYS.js +65 -0
- package/dist/bin/chunk-4MEL44QX.js +848 -0
- package/dist/bin/chunk-FIMJZAS4.js +84 -0
- package/dist/bin/chunk-NO4FIFMS.js +176 -0
- package/dist/bin/chunk-T63VQXNM.js +156 -0
- package/dist/bin/client-5NZ23GML.js +11 -0
- package/dist/bin/collection-efficiency-U56XNVEE.js +165 -0
- package/dist/bin/config-335MN4I7.js +18 -0
- package/dist/bin/create-RPDEORDD.js +83 -0
- package/dist/bin/default-account-AE6EXZZR.js +58 -0
- package/dist/bin/expenses-5N2QSG54.js +89 -0
- package/dist/bin/export-QICOQK34.js +59 -0
- package/dist/bin/factory-KOCW2AQM.js +483 -0
- package/dist/bin/get-A43QCI2S.js +66 -0
- package/dist/bin/get-GWH6S5SJ.js +71 -0
- package/dist/bin/hisaabo.js +2302 -1510
- package/dist/bin/invitations-P3EEN5WI.js +66 -0
- package/dist/bin/invite-T3CKX53E.js +53 -0
- package/dist/bin/invoice-breakdown-FN5BEFJD.js +97 -0
- package/dist/bin/items-2OOCQKVF.js +62 -0
- package/dist/bin/items-toggle-SKZWCGJH.js +46 -0
- package/dist/bin/list-A2RKI3ZG.js +79 -0
- package/dist/bin/list-NRMBMKMI.js +90 -0
- package/dist/bin/list-T74SN6IR.js +46 -0
- package/dist/bin/members-W2GW3ODT.js +55 -0
- package/dist/bin/monthly-comparison-T34ZFOHL.js +176 -0
- package/dist/bin/order-cancel-TI27JYYD.js +55 -0
- package/dist/bin/order-confirm-VMRAMNTD.js +53 -0
- package/dist/bin/order-get-C2RBUR4O.js +88 -0
- package/dist/bin/order-update-RE3HATNF.js +60 -0
- package/dist/bin/output-NUOL7KJW.js +35 -0
- package/dist/bin/payment-modes-WOOT22I7.js +126 -0
- package/dist/bin/profit-loss-T4RESJ32.js +135 -0
- package/dist/bin/receivables-aging-6XMENEWS.js +161 -0
- package/dist/bin/remove-6QZI4JCY.js +52 -0
- package/dist/bin/revoke-AVEMPAC7.js +40 -0
- package/dist/bin/revoke-YUCFZFNR.js +52 -0
- package/dist/bin/revoke-all-LFW5WBHO.js +33 -0
- package/dist/bin/revoke-invitation-DTGQRJR4.js +40 -0
- package/dist/bin/sales-trend-ZYBRUDUU.js +71 -0
- package/dist/bin/sequence-FPOJTI2P.js +66 -0
- package/dist/bin/store-IOB4Y67C.js +82 -0
- package/dist/bin/summary-5KYBA4ZO.js +113 -0
- package/dist/bin/top-customers-WSQ2UEJL.js +81 -0
- package/dist/bin/top-items-RWQPDGLN.js +84 -0
- package/dist/bin/top-outstanding-QAMO2E7Y.js +64 -0
- package/dist/bin/unpaid-invoices-WB3TK5B4.js +65 -0
- package/dist/bin/untracked-H733MYJL.js +67 -0
- package/dist/bin/update-H6LPO2Z4.js +61 -0
- package/dist/bin/update-JU2X3XU5.js +54 -0
- package/dist/bin/update-TLBUIC5J.js +57 -0
- package/dist/bin/update-role-QST7BVFX.js +45 -0
- package/dist/bin/update-settings-Q2EGRLKZ.js +56 -0
- package/package.json +7 -6
- package/src/auth.ts +12 -3
- package/src/bin/hisaabo.ts +49 -935
- package/src/bin/registrars/api-key.ts +44 -0
- package/src/bin/registrars/auth.ts +222 -0
- package/src/bin/registrars/automated-invoice.ts +167 -0
- package/src/bin/registrars/bank.ts +124 -0
- package/src/bin/registrars/business.ts +120 -0
- package/src/bin/registrars/dashboard.ts +225 -0
- package/src/bin/registrars/document.ts +184 -0
- package/src/bin/registrars/expense.ts +87 -0
- package/src/bin/registrars/gst.ts +41 -0
- package/src/bin/registrars/import.ts +49 -0
- package/src/bin/registrars/invoice.ts +117 -0
- package/src/bin/registrars/item.ts +112 -0
- package/src/bin/registrars/party.ts +81 -0
- package/src/bin/registrars/payment.ts +128 -0
- package/src/bin/registrars/report.ts +142 -0
- package/src/bin/registrars/session.ts +32 -0
- package/src/bin/registrars/shipment.ts +74 -0
- package/src/bin/registrars/store.ts +128 -0
- package/src/bin/registrars/target.ts +46 -0
- package/src/bin/registrars/tenant.ts +73 -0
- package/src/client.ts +589 -15
- package/src/commands/api-key/create.ts +72 -0
- package/src/commands/api-key/list.ts +71 -0
- package/src/commands/api-key/revoke.ts +46 -0
- package/src/commands/automated-invoice/create.ts +85 -0
- package/src/commands/automated-invoice/delete.ts +42 -0
- package/src/commands/automated-invoice/get.ts +113 -0
- package/src/commands/automated-invoice/history.ts +65 -0
- package/src/commands/automated-invoice/index.ts +11 -0
- package/src/commands/automated-invoice/list.ts +91 -0
- package/src/commands/automated-invoice/pause.ts +29 -0
- package/src/commands/automated-invoice/resume.ts +29 -0
- package/src/commands/automated-invoice/run-now.ts +29 -0
- package/src/commands/automated-invoice/suggestions.ts +68 -0
- package/src/commands/automated-invoice/update.ts +54 -0
- package/src/commands/automated-invoice/usage.ts +68 -0
- package/src/commands/bank/gateway-config.ts +61 -0
- package/src/commands/bank/update-gateway.ts +84 -0
- package/src/commands/business/audit-trail.ts +79 -0
- package/src/commands/business/export.ts +52 -0
- package/src/commands/business/get.ts +55 -0
- package/src/commands/business/sequence.ts +65 -0
- package/src/commands/business/update.ts +64 -0
- package/src/commands/dashboard/collection-efficiency.ts +164 -0
- package/src/commands/dashboard/expenses.ts +76 -0
- package/src/commands/dashboard/invoice-breakdown.ts +89 -0
- package/src/commands/dashboard/monthly-comparison.ts +193 -0
- package/src/commands/dashboard/payment-modes.ts +121 -0
- package/src/commands/dashboard/profit-loss.ts +146 -0
- package/src/commands/dashboard/receivables-aging.ts +169 -0
- package/src/commands/dashboard/sales-trend.ts +68 -0
- package/src/commands/dashboard/summary.ts +105 -0
- package/src/commands/dashboard/top-customers.ts +70 -0
- package/src/commands/dashboard/top-items.ts +74 -0
- package/src/commands/dashboard/top-outstanding.ts +61 -0
- package/src/commands/document/factory.ts +590 -0
- package/src/commands/expense/categories.ts +40 -0
- package/src/commands/expense/update.ts +58 -0
- package/src/commands/import/index.ts +68 -0
- package/src/commands/item/categories.ts +40 -0
- package/src/commands/item/low-stock-count.ts +32 -0
- package/src/commands/item/merge.ts +53 -0
- package/src/commands/item/price-history.ts +59 -0
- package/src/commands/item/rename-unit.ts +39 -0
- package/src/commands/item/sales-stats.ts +44 -0
- package/src/commands/item/stock-history.ts +70 -0
- package/src/commands/item/switch-base-unit.ts +42 -0
- package/src/commands/item/update.ts +59 -0
- package/src/commands/item/variants-create.ts +58 -0
- package/src/commands/item/variants-delete.ts +47 -0
- package/src/commands/item/variants-list.ts +63 -0
- package/src/commands/item/variants-update.ts +61 -0
- package/src/commands/party/ledger-report.ts +81 -0
- package/src/commands/party/merge.ts +50 -0
- package/src/commands/party/stats.ts +40 -0
- package/src/commands/party/top-items.ts +57 -0
- package/src/commands/party/update.ts +65 -0
- package/src/commands/payment/default-account.ts +56 -0
- package/src/commands/payment/get.ts +59 -0
- package/src/commands/payment/unpaid-invoices.ts +69 -0
- package/src/commands/payment/untracked.ts +70 -0
- package/src/commands/payment/update.ts +54 -0
- package/src/commands/report/index.ts +348 -1
- package/src/commands/session/list.ts +91 -0
- package/src/commands/session/revoke-all.ts +20 -0
- package/src/commands/session/revoke.ts +32 -0
- package/src/commands/store/check-slug.ts +48 -0
- package/src/commands/store/items-toggle.ts +41 -0
- package/src/commands/store/items.ts +61 -0
- package/src/commands/store/order-cancel.ts +48 -0
- package/src/commands/store/order-confirm.ts +45 -0
- package/src/commands/store/order-get.ts +66 -0
- package/src/commands/store/order-update.ts +52 -0
- package/src/commands/store/update-settings.ts +52 -0
- package/src/commands/tenant/invitations.ts +62 -0
- package/src/commands/tenant/invite.ts +57 -0
- package/src/commands/tenant/list.ts +46 -0
- package/src/commands/tenant/members.ts +55 -0
- package/src/commands/tenant/remove.ts +47 -0
- package/src/commands/tenant/revoke-invitation.ts +32 -0
- package/src/commands/tenant/update-role.ts +41 -0
- package/src/config.ts +51 -2
- package/src/error-handler.ts +53 -0
- package/src/output.ts +1 -0
- package/src/spinner.ts +39 -0
- package/tsup.config.ts +6 -1
- package/src/components/ErrorDisplay.tsx +0 -16
- package/src/components/Header.tsx +0 -26
- package/src/components/MoneyCell.tsx +0 -16
- package/src/components/Spinner.tsx +0 -12
- package/src/components/StatusBadge.tsx +0 -39
- package/src/components/Table.tsx +0 -63
package/src/bin/hisaabo.ts
CHANGED
|
@@ -1,947 +1,61 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { itemDeleteCommand } from "../commands/item/delete.js";
|
|
25
|
-
import { itemStockCommand } from "../commands/item/stock.js";
|
|
26
|
-
import { paymentListCommand } from "../commands/payment/list.js";
|
|
27
|
-
import { paymentCreateCommand } from "../commands/payment/create.js";
|
|
28
|
-
import { paymentDeleteCommand } from "../commands/payment/delete.js";
|
|
29
|
-
import { expenseListCommand } from "../commands/expense/list.js";
|
|
30
|
-
import { expenseCreateCommand } from "../commands/expense/create.js";
|
|
31
|
-
import { expenseDeleteCommand } from "../commands/expense/delete.js";
|
|
32
|
-
import { gstR1Command, gstR3bCommand, gstR1CsvCommand } from "../commands/gst/index.js";
|
|
33
|
-
import {
|
|
34
|
-
reportDaybookCommand, reportOutstandingCommand, reportTaxSummaryCommand,
|
|
35
|
-
reportItemSalesCommand, reportStockSummaryCommand,
|
|
36
|
-
} from "../commands/report/index.js";
|
|
37
|
-
import {
|
|
38
|
-
bankListCommand, bankGetCommand, bankCreateCommand, bankTransferCommand, bankTransactionsCommand,
|
|
39
|
-
} from "../commands/bank/index.js";
|
|
40
|
-
import {
|
|
41
|
-
shipmentListCommand, shipmentGetCommand, shipmentCreateCommand, shipmentUpdateCommand,
|
|
42
|
-
} from "../commands/shipment/index.js";
|
|
43
|
-
import { targetListCommand, targetMyCommand, targetCreateCommand } from "../commands/target/index.js";
|
|
44
|
-
import { storeSettingsCommand, storeOrdersCommand } from "../commands/store/index.js";
|
|
45
|
-
import { importPartiesCommand, importItemsCommand } from "../commands/import/index.js";
|
|
2
|
+
import { fatalError } from "../output.js";
|
|
3
|
+
|
|
4
|
+
import { registerAuthCommands } from "./registrars/auth.js";
|
|
5
|
+
import { registerDashboardCommands } from "./registrars/dashboard.js";
|
|
6
|
+
import { registerInvoiceCommands } from "./registrars/invoice.js";
|
|
7
|
+
import { registerPartyCommands } from "./registrars/party.js";
|
|
8
|
+
import { registerItemCommands } from "./registrars/item.js";
|
|
9
|
+
import { registerPaymentCommands } from "./registrars/payment.js";
|
|
10
|
+
import { registerExpenseCommands } from "./registrars/expense.js";
|
|
11
|
+
import { registerGstCommands } from "./registrars/gst.js";
|
|
12
|
+
import { registerReportCommands } from "./registrars/report.js";
|
|
13
|
+
import { registerBankCommands } from "./registrars/bank.js";
|
|
14
|
+
import { registerShipmentCommands } from "./registrars/shipment.js";
|
|
15
|
+
import { registerTargetCommands } from "./registrars/target.js";
|
|
16
|
+
import { registerStoreCommands } from "./registrars/store.js";
|
|
17
|
+
import { registerImportCommands } from "./registrars/import.js";
|
|
18
|
+
import { registerAutomatedInvoiceCommands } from "./registrars/automated-invoice.js";
|
|
19
|
+
import { registerBusinessCommands } from "./registrars/business.js";
|
|
20
|
+
import { registerDocumentCommands } from "./registrars/document.js";
|
|
21
|
+
import { registerTenantCommands } from "./registrars/tenant.js";
|
|
22
|
+
import { registerApiKeyCommands } from "./registrars/api-key.js";
|
|
23
|
+
import { registerSessionCommands } from "./registrars/session.js";
|
|
46
24
|
|
|
47
25
|
// ── Program ───────────────────────────────────────────────────────────────
|
|
48
26
|
|
|
49
27
|
const program = new Command();
|
|
50
28
|
|
|
29
|
+
declare const __CLI_VERSION__: string | undefined;
|
|
30
|
+
const cliVersion = typeof __CLI_VERSION__ !== "undefined" ? __CLI_VERSION__ : "dev";
|
|
31
|
+
|
|
51
32
|
program
|
|
52
33
|
.name("hisaabo")
|
|
53
34
|
.description("Hisaabo CLI — Invoicing and business management")
|
|
54
|
-
.version(
|
|
55
|
-
|
|
56
|
-
// ──
|
|
57
|
-
|
|
58
|
-
program
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
await loginWithToken(apiUrl, opts.token);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// ── Email/password path ──
|
|
83
|
-
let email = opts.email;
|
|
84
|
-
let password = opts.password;
|
|
85
|
-
|
|
86
|
-
if (!apiUrl || !email || !password) {
|
|
87
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
88
|
-
const ask = (q: string) => new Promise<string>((res) => rl.question(q, res));
|
|
89
|
-
console.log("\n Hisaabo CLI\n " + "─".repeat(11) + "\n");
|
|
90
|
-
if (!apiUrl) {
|
|
91
|
-
const u = await ask(" Server URL [http://localhost:3000]: ");
|
|
92
|
-
apiUrl = u.trim() || "http://localhost:3000";
|
|
93
|
-
}
|
|
94
|
-
if (!email) email = (await ask(" Email: ")).trim();
|
|
95
|
-
if (!password) {
|
|
96
|
-
// Hide password input if possible
|
|
97
|
-
password = (await ask(" Password: ")).trim();
|
|
98
|
-
}
|
|
99
|
-
rl.close();
|
|
100
|
-
console.log("\n Tip: Generate an API key at Settings → API Keys for passwordless CLI access.\n");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
await login(apiUrl, email, password);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// ── logout ────────────────────────────────────────────────────────────────
|
|
107
|
-
|
|
108
|
-
program
|
|
109
|
-
.command("logout")
|
|
110
|
-
.description("Log out and clear saved credentials")
|
|
111
|
-
.action(async () => {
|
|
112
|
-
await logout();
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
// ── whoami ────────────────────────────────────────────────────────────────
|
|
116
|
-
|
|
117
|
-
program
|
|
118
|
-
.command("whoami")
|
|
119
|
-
.description("Show current user and active business")
|
|
120
|
-
.option("--json", "JSON output")
|
|
121
|
-
.action(async (opts) => {
|
|
122
|
-
await whoami(!!opts.json);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// ── switch (business) ─────────────────────────────────────────────────────
|
|
126
|
-
|
|
127
|
-
program
|
|
128
|
-
.command("switch")
|
|
129
|
-
.description("Switch active business")
|
|
130
|
-
.option("--json", "JSON output")
|
|
131
|
-
.action(async (opts) => {
|
|
132
|
-
const cfg = requireAuth();
|
|
133
|
-
const client = new HisaaboClient(cfg);
|
|
134
|
-
try {
|
|
135
|
-
const businesses = await client.business.list();
|
|
136
|
-
if (opts.json) { outputJSON(businesses); return; }
|
|
137
|
-
businesses.forEach((b, i) => {
|
|
138
|
-
const active = b.id === cfg.businessId ? " [active]" : "";
|
|
139
|
-
console.log(` ${i + 1} ${b.name.padEnd(28)}${active}`);
|
|
140
|
-
});
|
|
141
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
142
|
-
const answer = await new Promise<string>((res) => rl.question("\n Select: ", res));
|
|
143
|
-
rl.close();
|
|
144
|
-
const idx = parseInt(answer.trim(), 10) - 1;
|
|
145
|
-
const selected = businesses[Math.max(0, Math.min(idx, businesses.length - 1))];
|
|
146
|
-
if (!selected) fatalError("Invalid selection.", EXIT.USAGE);
|
|
147
|
-
setConfig({ businessId: selected.id, businessName: selected.name });
|
|
148
|
-
success(`Switched to: ${selected.name}`);
|
|
149
|
-
} catch (e) {
|
|
150
|
-
if (e instanceof HisaaboApiError) {
|
|
151
|
-
if (e.hisaaboError.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
152
|
-
}
|
|
153
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
// ── dashboard ─────────────────────────────────────────────────────────────
|
|
158
|
-
|
|
159
|
-
program
|
|
160
|
-
.command("dashboard")
|
|
161
|
-
.alias("dash")
|
|
162
|
-
.description("Show financial summary dashboard")
|
|
163
|
-
.option("--json", "JSON output")
|
|
164
|
-
.action(async (opts) => {
|
|
165
|
-
await dashboardCommand({ json: opts.json });
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// ── invoice ───────────────────────────────────────────────────────────────
|
|
169
|
-
|
|
170
|
-
const invoice = program.command("invoice").description("Invoice management");
|
|
171
|
-
|
|
172
|
-
invoice
|
|
173
|
-
.command("list")
|
|
174
|
-
.description("List invoices")
|
|
175
|
-
.option("--json", "JSON output")
|
|
176
|
-
.option("--format <format>", "Output format: table, tsv, csv, ids")
|
|
177
|
-
.option("--type <type>", "sale or purchase")
|
|
178
|
-
.option("--status <status>", "Filter by status")
|
|
179
|
-
.option("--party <name>", "Filter by party name")
|
|
180
|
-
.option("--party-id <id>", "Filter by party ID")
|
|
181
|
-
.option("--from <date>", "From date (YYYY-MM-DD)")
|
|
182
|
-
.option("--to <date>", "To date (YYYY-MM-DD)")
|
|
183
|
-
.option("--this-month", "Filter to current month")
|
|
184
|
-
.option("--this-quarter", "Filter to current quarter")
|
|
185
|
-
.option("--this-fy", "Filter to current financial year")
|
|
186
|
-
.option("--page <n>", "Page number", parseInt)
|
|
187
|
-
.option("--limit <n>", "Items per page", parseInt)
|
|
188
|
-
.option("--search <q>", "Search invoices")
|
|
189
|
-
.option("--sort-by <field>", "Sort field: date, amount, number")
|
|
190
|
-
.option("--sort-dir <dir>", "Sort direction: asc, desc")
|
|
191
|
-
.action(async (opts) => {
|
|
192
|
-
await invoiceListCommand({
|
|
193
|
-
json: opts.json,
|
|
194
|
-
format: opts.format,
|
|
195
|
-
type: opts.type,
|
|
196
|
-
status: opts.status,
|
|
197
|
-
party: opts.party,
|
|
198
|
-
partyId: opts.partyId,
|
|
199
|
-
from: opts.from,
|
|
200
|
-
to: opts.to,
|
|
201
|
-
thisMonth: opts.thisMonth,
|
|
202
|
-
thisQuarter: opts.thisQuarter,
|
|
203
|
-
thisFy: opts.thisFy,
|
|
204
|
-
page: opts.page,
|
|
205
|
-
limit: opts.limit,
|
|
206
|
-
search: opts.search,
|
|
207
|
-
sortBy: opts.sortBy,
|
|
208
|
-
sortDir: opts.sortDir,
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
invoice
|
|
213
|
-
.command("get <id>")
|
|
214
|
-
.description("Get invoice details")
|
|
215
|
-
.option("--json", "JSON output")
|
|
216
|
-
.action(async (id, opts) => {
|
|
217
|
-
await invoiceGetCommand(id, { json: opts.json });
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
invoice
|
|
221
|
-
.command("create")
|
|
222
|
-
.description("Create a new invoice")
|
|
223
|
-
.option("--json", "JSON output")
|
|
224
|
-
.option("--party <name>", "Party name")
|
|
225
|
-
.option("--party-id <id>", "Party UUID")
|
|
226
|
-
.option("--type <type>", "sale or purchase")
|
|
227
|
-
.option("--item <name>", "Item (repeatable)", (v, a: string[]) => [...a, v], [] as string[])
|
|
228
|
-
.option("--qty <n>", "Quantity (per --item)", (v, a: string[]) => [...a, v], [] as string[])
|
|
229
|
-
.option("--rate <n>", "Unit price (per --item)", (v, a: string[]) => [...a, v], [] as string[])
|
|
230
|
-
.option("--delivery <method>", "Delivery method")
|
|
231
|
-
.option("--notes <text>", "Invoice notes")
|
|
232
|
-
.option("--terms <text>", "Terms and conditions")
|
|
233
|
-
.option("-y, --yes", "Skip confirmation prompts")
|
|
234
|
-
.action(async (opts) => {
|
|
235
|
-
await invoiceCreateCommand({
|
|
236
|
-
json: opts.json,
|
|
237
|
-
party: opts.party,
|
|
238
|
-
partyId: opts.partyId,
|
|
239
|
-
type: opts.type,
|
|
240
|
-
items: opts.item,
|
|
241
|
-
qty: opts.qty,
|
|
242
|
-
rate: opts.rate,
|
|
243
|
-
delivery: opts.delivery,
|
|
244
|
-
notes: opts.notes,
|
|
245
|
-
terms: opts.terms,
|
|
246
|
-
yes: opts.yes,
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
invoice
|
|
251
|
-
.command("status <id> <status>")
|
|
252
|
-
.description("Update invoice status")
|
|
253
|
-
.option("--json", "JSON output")
|
|
254
|
-
.action(async (id, status, opts) => {
|
|
255
|
-
await invoiceStatusCommand(id, status, { json: opts.json });
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
invoice
|
|
259
|
-
.command("pdf <id>")
|
|
260
|
-
.description("Download invoice as PDF")
|
|
261
|
-
.option("--output <path>", "Output path or directory")
|
|
262
|
-
.option("--open", "Open after download")
|
|
263
|
-
.action(async (id, opts) => {
|
|
264
|
-
await invoicePdfCommand(id, { output: opts.output, open: opts.open });
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
invoice
|
|
268
|
-
.command("delete <id>")
|
|
269
|
-
.description("Delete an invoice")
|
|
270
|
-
.option("-y, --yes", "Skip confirmation")
|
|
271
|
-
.option("--json", "JSON output")
|
|
272
|
-
.action(async (id, opts) => {
|
|
273
|
-
await invoiceDeleteCommand(id, { yes: opts.yes, json: opts.json });
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// ── party ─────────────────────────────────────────────────────────────────
|
|
277
|
-
|
|
278
|
-
const party = program.command("party").description("Party (customer/supplier) management");
|
|
279
|
-
|
|
280
|
-
party
|
|
281
|
-
.command("list")
|
|
282
|
-
.description("List parties")
|
|
283
|
-
.option("--json", "JSON output")
|
|
284
|
-
.option("--format <format>", "Output format: table, tsv, csv, ids")
|
|
285
|
-
.option("--type <type>", "customer or supplier")
|
|
286
|
-
.option("--search <q>", "Search")
|
|
287
|
-
.option("--category <cat>", "Filter by category")
|
|
288
|
-
.option("--page <n>", "Page number", parseInt)
|
|
289
|
-
.option("--limit <n>", "Items per page", parseInt)
|
|
290
|
-
.action(async (opts) => {
|
|
291
|
-
await partyListCommand({
|
|
292
|
-
json: opts.json,
|
|
293
|
-
format: opts.format,
|
|
294
|
-
type: opts.type,
|
|
295
|
-
search: opts.search,
|
|
296
|
-
category: opts.category,
|
|
297
|
-
page: opts.page,
|
|
298
|
-
limit: opts.limit,
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
party
|
|
303
|
-
.command("get <id>")
|
|
304
|
-
.description("Get party details")
|
|
305
|
-
.option("--json", "JSON output")
|
|
306
|
-
.action(async (id, opts) => {
|
|
307
|
-
await partyGetCommand(id, { json: opts.json });
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
party
|
|
311
|
-
.command("create")
|
|
312
|
-
.description("Create a new party")
|
|
313
|
-
.option("--json", "JSON output")
|
|
314
|
-
.option("--type <type>", "customer or supplier")
|
|
315
|
-
.option("--name <name>", "Party name")
|
|
316
|
-
.option("--phone <phone>", "Phone number")
|
|
317
|
-
.option("--email <email>", "Email address")
|
|
318
|
-
.option("--gstin <gstin>", "GSTIN")
|
|
319
|
-
.option("--city <city>", "City")
|
|
320
|
-
.option("--category <cat>", "Category")
|
|
321
|
-
.option("-y, --yes", "Skip confirmation")
|
|
322
|
-
.action(async (opts) => {
|
|
323
|
-
await partyCreateCommand(opts);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
party
|
|
327
|
-
.command("delete <id>")
|
|
328
|
-
.description("Delete a party")
|
|
329
|
-
.option("-y, --yes", "Skip confirmation")
|
|
330
|
-
.option("--json", "JSON output")
|
|
331
|
-
.action(async (id, opts) => {
|
|
332
|
-
await partyDeleteCommand(id, { yes: opts.yes, json: opts.json });
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
party
|
|
336
|
-
.command("ledger <partyId>")
|
|
337
|
-
.description("Show party ledger (debit/credit history)")
|
|
338
|
-
.option("--json", "JSON output")
|
|
339
|
-
.option("--format <format>", "Output format: table, tsv, csv")
|
|
340
|
-
.option("--from <date>", "From date")
|
|
341
|
-
.option("--to <date>", "To date")
|
|
342
|
-
.option("--page <n>", "Page number", parseInt)
|
|
343
|
-
.option("--limit <n>", "Items per page", parseInt)
|
|
344
|
-
.action(async (partyId, opts) => {
|
|
345
|
-
await partyLedgerCommand(partyId, opts);
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
// ── item ──────────────────────────────────────────────────────────────────
|
|
349
|
-
|
|
350
|
-
const item = program.command("item").description("Item / product management");
|
|
351
|
-
|
|
352
|
-
item
|
|
353
|
-
.command("list")
|
|
354
|
-
.description("List items")
|
|
355
|
-
.option("--json", "JSON output")
|
|
356
|
-
.option("--format <format>", "Output format: table, tsv, csv, ids")
|
|
357
|
-
.option("--search <q>", "Search")
|
|
358
|
-
.option("--category <cat>", "Filter by category")
|
|
359
|
-
.option("--type <type>", "product or service")
|
|
360
|
-
.option("--low-stock", "Show only low-stock items")
|
|
361
|
-
.option("--page <n>", "Page number", parseInt)
|
|
362
|
-
.option("--limit <n>", "Items per page", parseInt)
|
|
363
|
-
.action(async (opts) => {
|
|
364
|
-
await itemListCommand({
|
|
365
|
-
json: opts.json,
|
|
366
|
-
format: opts.format,
|
|
367
|
-
search: opts.search,
|
|
368
|
-
category: opts.category,
|
|
369
|
-
type: opts.type,
|
|
370
|
-
lowStock: opts.lowStock,
|
|
371
|
-
page: opts.page,
|
|
372
|
-
limit: opts.limit,
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
item
|
|
377
|
-
.command("get <id>")
|
|
378
|
-
.description("Get item details")
|
|
379
|
-
.option("--json", "JSON output")
|
|
380
|
-
.action(async (id, opts) => {
|
|
381
|
-
const cfg = requireAuth();
|
|
382
|
-
const client = new HisaaboClient(cfg);
|
|
383
|
-
try {
|
|
384
|
-
const it = await client.item.get(id);
|
|
385
|
-
if (opts.json) { outputJSON(it); return; }
|
|
386
|
-
console.log(`\n ${it.name} (${it.itemType})`);
|
|
387
|
-
console.log(" " + "─".repeat(40));
|
|
388
|
-
if (it.sku) console.log(` SKU: ${it.sku}`);
|
|
389
|
-
if (it.hsn) console.log(` HSN: ${it.hsn}`);
|
|
390
|
-
console.log(` Unit: ${it.unit}`);
|
|
391
|
-
if (it.salePrice) console.log(` Sale: ₹${it.salePrice}`);
|
|
392
|
-
if (it.purchasePrice) console.log(` Purchase: ₹${it.purchasePrice}`);
|
|
393
|
-
console.log(` Tax: ${it.taxPercent}%`);
|
|
394
|
-
if (it.itemType === "product") console.log(` Stock: ${it.stockQuantity}`);
|
|
395
|
-
console.log();
|
|
396
|
-
} catch (e) {
|
|
397
|
-
if (e instanceof HisaaboApiError && e.hisaaboError.code === "not_found") fatalError(`Item not found: ${id}`, EXIT.NOT_FOUND);
|
|
398
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
item
|
|
403
|
-
.command("create")
|
|
404
|
-
.description("Create a new item")
|
|
405
|
-
.option("--json", "JSON output")
|
|
406
|
-
.option("--name <name>", "Item name")
|
|
407
|
-
.option("--unit <unit>", "Unit (pcs, kg, etc.)")
|
|
408
|
-
.option("--sale-price <price>", "Sale price")
|
|
409
|
-
.option("--purchase-price <price>", "Purchase price")
|
|
410
|
-
.option("--tax <percent>", "Tax percentage")
|
|
411
|
-
.option("--stock <qty>", "Opening stock quantity")
|
|
412
|
-
.option("--hsn <code>", "HSN code")
|
|
413
|
-
.option("--category <cat>", "Category")
|
|
414
|
-
.option("--type <type>", "product or service")
|
|
415
|
-
.option("-y, --yes", "Skip confirmation")
|
|
416
|
-
.action(async (opts) => {
|
|
417
|
-
await itemCreateCommand({
|
|
418
|
-
json: opts.json,
|
|
419
|
-
name: opts.name,
|
|
420
|
-
unit: opts.unit,
|
|
421
|
-
salePrice: opts.salePrice,
|
|
422
|
-
purchasePrice: opts.purchasePrice,
|
|
423
|
-
taxPercent: opts.tax,
|
|
424
|
-
stock: opts.stock,
|
|
425
|
-
hsn: opts.hsn,
|
|
426
|
-
category: opts.category,
|
|
427
|
-
type: opts.type,
|
|
428
|
-
yes: opts.yes,
|
|
429
|
-
});
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
item
|
|
433
|
-
.command("delete <id>")
|
|
434
|
-
.description("Delete an item")
|
|
435
|
-
.option("-y, --yes", "Skip confirmation")
|
|
436
|
-
.option("--json", "JSON output")
|
|
437
|
-
.action(async (id, opts) => {
|
|
438
|
-
await itemDeleteCommand(id, { yes: opts.yes, json: opts.json });
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
item
|
|
442
|
-
.command("stock <id> <adjustment>")
|
|
443
|
-
.description("Adjust item stock (+10, -5, 100)")
|
|
444
|
-
.option("--json", "JSON output")
|
|
445
|
-
.option("--reason <text>", "Reason for adjustment")
|
|
446
|
-
.action(async (id, adjustment, opts) => {
|
|
447
|
-
await itemStockCommand(id, adjustment, { json: opts.json, reason: opts.reason });
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
// ── payment ───────────────────────────────────────────────────────────────
|
|
451
|
-
|
|
452
|
-
const payment = program.command("payment").description("Payment recording");
|
|
453
|
-
|
|
454
|
-
payment
|
|
455
|
-
.command("list")
|
|
456
|
-
.description("List payments")
|
|
457
|
-
.option("--json", "JSON output")
|
|
458
|
-
.option("--format <format>", "Output format: table, tsv, csv, ids")
|
|
459
|
-
.option("--party-id <id>", "Filter by party")
|
|
460
|
-
.option("--from <date>", "From date")
|
|
461
|
-
.option("--to <date>", "To date")
|
|
462
|
-
.option("--page <n>", "Page number", parseInt)
|
|
463
|
-
.option("--limit <n>", "Items per page", parseInt)
|
|
464
|
-
.action(async (opts) => {
|
|
465
|
-
await paymentListCommand(opts);
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
payment
|
|
469
|
-
.command("create")
|
|
470
|
-
.description("Record a payment")
|
|
471
|
-
.option("--json", "JSON output")
|
|
472
|
-
.option("--party-id <id>", "Party UUID")
|
|
473
|
-
.option("--party <name>", "Party name")
|
|
474
|
-
.option("--amount <amount>", "Payment amount")
|
|
475
|
-
.option("--mode <mode>", "cash/bank/upi/cheque/other")
|
|
476
|
-
.option("--invoice-id <id>", "Link to invoice")
|
|
477
|
-
.option("--reference <ref>", "Reference number")
|
|
478
|
-
.option("--date <date>", "Payment date")
|
|
479
|
-
.option("--notes <text>", "Notes")
|
|
480
|
-
.option("-y, --yes", "Skip confirmation")
|
|
481
|
-
.action(async (opts) => {
|
|
482
|
-
await paymentCreateCommand({
|
|
483
|
-
json: opts.json,
|
|
484
|
-
partyId: opts.partyId,
|
|
485
|
-
party: opts.party,
|
|
486
|
-
amount: opts.amount,
|
|
487
|
-
mode: opts.mode,
|
|
488
|
-
invoiceId: opts.invoiceId,
|
|
489
|
-
reference: opts.reference,
|
|
490
|
-
date: opts.date,
|
|
491
|
-
notes: opts.notes,
|
|
492
|
-
yes: opts.yes,
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
payment
|
|
497
|
-
.command("delete <id>")
|
|
498
|
-
.description("Delete a payment")
|
|
499
|
-
.option("-y, --yes", "Skip confirmation")
|
|
500
|
-
.option("--json", "JSON output")
|
|
501
|
-
.action(async (id, opts) => {
|
|
502
|
-
await paymentDeleteCommand(id, { yes: opts.yes, json: opts.json });
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
// ── expense ───────────────────────────────────────────────────────────────
|
|
506
|
-
|
|
507
|
-
const expense = program.command("expense").description("Expense tracking");
|
|
508
|
-
|
|
509
|
-
expense
|
|
510
|
-
.command("list")
|
|
511
|
-
.description("List expenses")
|
|
512
|
-
.option("--json", "JSON output")
|
|
513
|
-
.option("--format <format>", "Output format: table, tsv, csv, ids")
|
|
514
|
-
.option("--category <cat>", "Filter by category")
|
|
515
|
-
.option("--from <date>", "From date")
|
|
516
|
-
.option("--to <date>", "To date")
|
|
517
|
-
.option("--page <n>", "Page number", parseInt)
|
|
518
|
-
.option("--limit <n>", "Items per page", parseInt)
|
|
519
|
-
.action(async (opts) => {
|
|
520
|
-
await expenseListCommand(opts);
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
expense
|
|
524
|
-
.command("create")
|
|
525
|
-
.description("Create a new expense")
|
|
526
|
-
.option("--json", "JSON output")
|
|
527
|
-
.option("--category <cat>", "Expense category")
|
|
528
|
-
.option("--amount <amount>", "Amount")
|
|
529
|
-
.option("--mode <mode>", "cash/bank/upi/cheque/other")
|
|
530
|
-
.option("--description <text>", "Description")
|
|
531
|
-
.option("--date <date>", "Expense date")
|
|
532
|
-
.option("--reference <ref>", "Reference number")
|
|
533
|
-
.action(async (opts) => {
|
|
534
|
-
await expenseCreateCommand({
|
|
535
|
-
json: opts.json,
|
|
536
|
-
category: opts.category,
|
|
537
|
-
amount: opts.amount,
|
|
538
|
-
mode: opts.mode,
|
|
539
|
-
description: opts.description,
|
|
540
|
-
date: opts.date,
|
|
541
|
-
reference: opts.reference,
|
|
542
|
-
});
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
expense
|
|
546
|
-
.command("delete <id>")
|
|
547
|
-
.description("Delete an expense")
|
|
548
|
-
.option("-y, --yes", "Skip confirmation")
|
|
549
|
-
.option("--json", "JSON output")
|
|
550
|
-
.action(async (id, opts) => {
|
|
551
|
-
await expenseDeleteCommand(id, { yes: opts.yes, json: opts.json });
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
// ── gst ───────────────────────────────────────────────────────────────────
|
|
555
|
-
|
|
556
|
-
const gst = program.command("gst").description("GST reports");
|
|
557
|
-
|
|
558
|
-
gst
|
|
559
|
-
.command("r1")
|
|
560
|
-
.description("GSTR-1 report")
|
|
561
|
-
.option("--json", "JSON output")
|
|
562
|
-
.option("--quarter <q>", "Quarter: Q1, Q2, Q3, Q4")
|
|
563
|
-
.option("--month <n>", "Month number (1-12)", parseInt)
|
|
564
|
-
.option("--year <n>", "Year", parseInt)
|
|
565
|
-
.action(async (opts) => {
|
|
566
|
-
await gstR1Command({ json: opts.json, quarter: opts.quarter, month: opts.month, year: opts.year });
|
|
567
|
-
});
|
|
568
|
-
|
|
569
|
-
gst
|
|
570
|
-
.command("r3b")
|
|
571
|
-
.description("GSTR-3B report")
|
|
572
|
-
.option("--json", "JSON output")
|
|
573
|
-
.option("--quarter <q>", "Quarter: Q1, Q2, Q3, Q4")
|
|
574
|
-
.option("--month <n>", "Month number (1-12)", parseInt)
|
|
575
|
-
.option("--year <n>", "Year", parseInt)
|
|
576
|
-
.action(async (opts) => {
|
|
577
|
-
await gstR3bCommand({ json: opts.json, quarter: opts.quarter, month: opts.month, year: opts.year });
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
gst
|
|
581
|
-
.command("r1-csv")
|
|
582
|
-
.description("Download GSTR-1 as GSTN-compatible CSV")
|
|
583
|
-
.option("--quarter <q>", "Quarter")
|
|
584
|
-
.option("--month <n>", "Month", parseInt)
|
|
585
|
-
.option("--year <n>", "Year", parseInt)
|
|
586
|
-
.option("--output <path>", "Output file path")
|
|
587
|
-
.action(async (opts) => {
|
|
588
|
-
await gstR1CsvCommand({ quarter: opts.quarter, month: opts.month, year: opts.year, output: opts.output });
|
|
589
|
-
});
|
|
590
|
-
|
|
591
|
-
// ── report ────────────────────────────────────────────────────────────────
|
|
592
|
-
|
|
593
|
-
const report = program.command("report").description("Business reports");
|
|
594
|
-
|
|
595
|
-
report
|
|
596
|
-
.command("daybook")
|
|
597
|
-
.description("Day book report (all transactions)")
|
|
598
|
-
.option("--json", "JSON output")
|
|
599
|
-
.option("--format <format>", "tsv or csv")
|
|
600
|
-
.option("--from <date>", "From date")
|
|
601
|
-
.option("--to <date>", "To date")
|
|
602
|
-
.option("--this-month", "Current month")
|
|
603
|
-
.option("--this-fy", "Current financial year")
|
|
604
|
-
.action(async (opts) => {
|
|
605
|
-
await reportDaybookCommand(opts);
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
report
|
|
609
|
-
.command("outstanding")
|
|
610
|
-
.description("Outstanding receivables and payables")
|
|
611
|
-
.option("--json", "JSON output")
|
|
612
|
-
.option("--type <type>", "receivable, payable, or both")
|
|
613
|
-
.action(async (opts) => {
|
|
614
|
-
await reportOutstandingCommand({ json: opts.json, type: opts.type });
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
report
|
|
618
|
-
.command("tax-summary")
|
|
619
|
-
.description("Tax summary by rate")
|
|
620
|
-
.option("--json", "JSON output")
|
|
621
|
-
.option("--from <date>", "From date")
|
|
622
|
-
.option("--to <date>", "To date")
|
|
623
|
-
.option("--this-fy", "Current financial year")
|
|
624
|
-
.action(async (opts) => {
|
|
625
|
-
await reportTaxSummaryCommand(opts);
|
|
626
|
-
});
|
|
627
|
-
|
|
628
|
-
report
|
|
629
|
-
.command("item-sales")
|
|
630
|
-
.description("Item sales report")
|
|
631
|
-
.option("--json", "JSON output")
|
|
632
|
-
.option("--from <date>", "From date")
|
|
633
|
-
.option("--to <date>", "To date")
|
|
634
|
-
.option("--this-fy", "Current financial year")
|
|
635
|
-
.action(async (opts) => {
|
|
636
|
-
await reportItemSalesCommand(opts);
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
report
|
|
640
|
-
.command("stock")
|
|
641
|
-
.description("Stock summary report")
|
|
642
|
-
.option("--json", "JSON output")
|
|
643
|
-
.option("--category <cat>", "Filter by category")
|
|
644
|
-
.action(async (opts) => {
|
|
645
|
-
await reportStockSummaryCommand({ json: opts.json, category: opts.category });
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
// ── bank ─────────────────────────────────────────────────────────────────
|
|
649
|
-
|
|
650
|
-
const bank = program.command("bank").description("Bank account management");
|
|
651
|
-
|
|
652
|
-
bank
|
|
653
|
-
.command("list")
|
|
654
|
-
.description("List bank accounts with balances")
|
|
655
|
-
.option("--json", "JSON output")
|
|
656
|
-
.action(async (opts) => {
|
|
657
|
-
await bankListCommand({ json: opts.json });
|
|
658
|
-
});
|
|
659
|
-
|
|
660
|
-
bank
|
|
661
|
-
.command("get <id>")
|
|
662
|
-
.description("Get bank account details")
|
|
663
|
-
.option("--json", "JSON output")
|
|
664
|
-
.action(async (id, opts) => {
|
|
665
|
-
await bankGetCommand(id, { json: opts.json });
|
|
666
|
-
});
|
|
667
|
-
|
|
668
|
-
bank
|
|
669
|
-
.command("create")
|
|
670
|
-
.description("Create a new bank account")
|
|
671
|
-
.option("--json", "JSON output")
|
|
672
|
-
.option("--name <name>", "Account name")
|
|
673
|
-
.option("--type <type>", "savings/current/cash/credit/other")
|
|
674
|
-
.option("--bank <name>", "Bank name")
|
|
675
|
-
.option("--account-number <num>", "Account number")
|
|
676
|
-
.option("--ifsc <code>", "IFSC code")
|
|
677
|
-
.option("--opening-balance <amount>", "Opening balance")
|
|
678
|
-
.option("--default", "Set as default account")
|
|
679
|
-
.option("-y, --yes", "Skip prompts")
|
|
680
|
-
.action(async (opts) => {
|
|
681
|
-
await bankCreateCommand({
|
|
682
|
-
json: opts.json,
|
|
683
|
-
name: opts.name,
|
|
684
|
-
type: opts.type,
|
|
685
|
-
bank: opts.bank,
|
|
686
|
-
accountNumber: opts.accountNumber,
|
|
687
|
-
ifsc: opts.ifsc,
|
|
688
|
-
openingBalance: opts.openingBalance,
|
|
689
|
-
default: opts.default,
|
|
690
|
-
yes: opts.yes,
|
|
691
|
-
});
|
|
692
|
-
});
|
|
693
|
-
|
|
694
|
-
bank
|
|
695
|
-
.command("transfer")
|
|
696
|
-
.description("Transfer between bank accounts")
|
|
697
|
-
.option("--json", "JSON output")
|
|
698
|
-
.option("--from <id>", "Source account ID")
|
|
699
|
-
.option("--to <id>", "Destination account ID")
|
|
700
|
-
.option("--amount <amount>", "Transfer amount")
|
|
701
|
-
.option("--description <text>", "Description")
|
|
702
|
-
.option("--date <date>", "Transfer date")
|
|
703
|
-
.action(async (opts) => {
|
|
704
|
-
await bankTransferCommand({
|
|
705
|
-
json: opts.json,
|
|
706
|
-
from: opts.from,
|
|
707
|
-
to: opts.to,
|
|
708
|
-
amount: opts.amount,
|
|
709
|
-
description: opts.description,
|
|
710
|
-
date: opts.date,
|
|
711
|
-
});
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
bank
|
|
715
|
-
.command("transactions <accountId>")
|
|
716
|
-
.description("List transactions for a bank account")
|
|
717
|
-
.option("--json", "JSON output")
|
|
718
|
-
.option("--from <date>", "From date")
|
|
719
|
-
.option("--to <date>", "To date")
|
|
720
|
-
.option("--page <n>", "Page number", parseInt)
|
|
721
|
-
.option("--limit <n>", "Items per page", parseInt)
|
|
722
|
-
.action(async (accountId, opts) => {
|
|
723
|
-
await bankTransactionsCommand(accountId, {
|
|
724
|
-
json: opts.json,
|
|
725
|
-
from: opts.from,
|
|
726
|
-
to: opts.to,
|
|
727
|
-
page: opts.page,
|
|
728
|
-
limit: opts.limit,
|
|
729
|
-
});
|
|
730
|
-
});
|
|
731
|
-
|
|
732
|
-
// ── shipment ──────────────────────────────────────────────────────────────
|
|
733
|
-
|
|
734
|
-
const shipment = program.command("shipment").description("Shipment tracking");
|
|
735
|
-
|
|
736
|
-
shipment
|
|
737
|
-
.command("list")
|
|
738
|
-
.description("List shipments")
|
|
739
|
-
.option("--json", "JSON output")
|
|
740
|
-
.option("--status <status>", "Filter by status")
|
|
741
|
-
.option("--invoice-id <id>", "Filter by invoice")
|
|
742
|
-
.option("--page <n>", "Page number", parseInt)
|
|
743
|
-
.option("--limit <n>", "Items per page", parseInt)
|
|
744
|
-
.action(async (opts) => {
|
|
745
|
-
await shipmentListCommand({
|
|
746
|
-
json: opts.json,
|
|
747
|
-
status: opts.status,
|
|
748
|
-
invoiceId: opts.invoiceId,
|
|
749
|
-
page: opts.page,
|
|
750
|
-
limit: opts.limit,
|
|
751
|
-
});
|
|
752
|
-
});
|
|
753
|
-
|
|
754
|
-
shipment
|
|
755
|
-
.command("get <id>")
|
|
756
|
-
.description("Get shipment details")
|
|
757
|
-
.option("--json", "JSON output")
|
|
758
|
-
.action(async (id, opts) => {
|
|
759
|
-
await shipmentGetCommand(id, { json: opts.json });
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
shipment
|
|
763
|
-
.command("create")
|
|
764
|
-
.description("Create a new shipment")
|
|
765
|
-
.option("--json", "JSON output")
|
|
766
|
-
.option("--invoice-id <id>", "Invoice ID")
|
|
767
|
-
.option("--party-id <id>", "Party ID")
|
|
768
|
-
.option("--carrier <name>", "Carrier name")
|
|
769
|
-
.option("--tracking <number>", "Tracking number")
|
|
770
|
-
.option("--mode <mode>", "Shipping mode")
|
|
771
|
-
.option("--date <date>", "Shipment date")
|
|
772
|
-
.action(async (opts) => {
|
|
773
|
-
await shipmentCreateCommand({
|
|
774
|
-
json: opts.json,
|
|
775
|
-
invoiceId: opts.invoiceId,
|
|
776
|
-
partyId: opts.partyId,
|
|
777
|
-
carrier: opts.carrier,
|
|
778
|
-
tracking: opts.tracking,
|
|
779
|
-
mode: opts.mode,
|
|
780
|
-
date: opts.date,
|
|
781
|
-
});
|
|
782
|
-
});
|
|
783
|
-
|
|
784
|
-
shipment
|
|
785
|
-
.command("update <id>")
|
|
786
|
-
.description("Update shipment status or tracking")
|
|
787
|
-
.option("--json", "JSON output")
|
|
788
|
-
.option("--status <status>", "New status")
|
|
789
|
-
.option("--tracking <number>", "Tracking number")
|
|
790
|
-
.option("--carrier <name>", "Carrier")
|
|
791
|
-
.action(async (id, opts) => {
|
|
792
|
-
await shipmentUpdateCommand(id, {
|
|
793
|
-
json: opts.json,
|
|
794
|
-
status: opts.status,
|
|
795
|
-
tracking: opts.tracking,
|
|
796
|
-
carrier: opts.carrier,
|
|
797
|
-
});
|
|
798
|
-
});
|
|
799
|
-
|
|
800
|
-
// ── target ────────────────────────────────────────────────────────────────
|
|
801
|
-
|
|
802
|
-
const target = program.command("target").description("Sales target management");
|
|
803
|
-
|
|
804
|
-
target
|
|
805
|
-
.command("list")
|
|
806
|
-
.description("List sales targets")
|
|
807
|
-
.option("--json", "JSON output")
|
|
808
|
-
.action(async (opts) => {
|
|
809
|
-
await targetListCommand({ json: opts.json });
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
target
|
|
813
|
-
.command("my")
|
|
814
|
-
.description("Show my target progress")
|
|
815
|
-
.option("--json", "JSON output")
|
|
816
|
-
.action(async (opts) => {
|
|
817
|
-
await targetMyCommand({ json: opts.json });
|
|
818
|
-
});
|
|
819
|
-
|
|
820
|
-
target
|
|
821
|
-
.command("create")
|
|
822
|
-
.description("Create a new sales target")
|
|
823
|
-
.option("--json", "JSON output")
|
|
824
|
-
.option("--type <type>", "order_count, order_value, or item_quantity")
|
|
825
|
-
.option("--period <period>", "daily, weekly, monthly, quarterly, or custom")
|
|
826
|
-
.option("--value <n>", "Target value")
|
|
827
|
-
.option("--start-date <date>", "Start date")
|
|
828
|
-
.option("--end-date <date>", "End date")
|
|
829
|
-
.option("--notes <text>", "Notes")
|
|
830
|
-
.action(async (opts) => {
|
|
831
|
-
await targetCreateCommand({
|
|
832
|
-
json: opts.json,
|
|
833
|
-
type: opts.type,
|
|
834
|
-
period: opts.period,
|
|
835
|
-
value: opts.value,
|
|
836
|
-
startDate: opts.startDate,
|
|
837
|
-
endDate: opts.endDate,
|
|
838
|
-
notes: opts.notes,
|
|
839
|
-
});
|
|
840
|
-
});
|
|
841
|
-
|
|
842
|
-
// ── store ─────────────────────────────────────────────────────────────────
|
|
843
|
-
|
|
844
|
-
const store = program.command("store").description("Online store management");
|
|
845
|
-
|
|
846
|
-
store
|
|
847
|
-
.command("settings")
|
|
848
|
-
.description("Show store settings")
|
|
849
|
-
.option("--json", "JSON output")
|
|
850
|
-
.action(async (opts) => {
|
|
851
|
-
await storeSettingsCommand({ json: opts.json });
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
store
|
|
855
|
-
.command("orders")
|
|
856
|
-
.description("List store orders")
|
|
857
|
-
.option("--json", "JSON output")
|
|
858
|
-
.option("--status <status>", "Filter by order status")
|
|
859
|
-
.option("--page <n>", "Page number", parseInt)
|
|
860
|
-
.option("--limit <n>", "Items per page", parseInt)
|
|
861
|
-
.action(async (opts) => {
|
|
862
|
-
await storeOrdersCommand({
|
|
863
|
-
json: opts.json,
|
|
864
|
-
status: opts.status,
|
|
865
|
-
page: opts.page,
|
|
866
|
-
limit: opts.limit,
|
|
867
|
-
});
|
|
868
|
-
});
|
|
869
|
-
|
|
870
|
-
// ── import ────────────────────────────────────────────────────────────────
|
|
871
|
-
|
|
872
|
-
const importCmd = program.command("import").description("Bulk import data");
|
|
873
|
-
|
|
874
|
-
importCmd
|
|
875
|
-
.command("parties <file>")
|
|
876
|
-
.description("Import parties from JSON or CSV file")
|
|
877
|
-
.option("--json", "JSON output")
|
|
878
|
-
.option("--format <format>", "json or csv (auto-detected from extension)")
|
|
879
|
-
.action(async (file, opts) => {
|
|
880
|
-
await importPartiesCommand(file, { json: opts.json, format: opts.format });
|
|
881
|
-
});
|
|
882
|
-
|
|
883
|
-
importCmd
|
|
884
|
-
.command("items <file>")
|
|
885
|
-
.description("Import items from JSON or CSV file")
|
|
886
|
-
.option("--json", "JSON output")
|
|
887
|
-
.option("--format <format>", "json or csv (auto-detected from extension)")
|
|
888
|
-
.action(async (file, opts) => {
|
|
889
|
-
await importItemsCommand(file, { json: opts.json, format: opts.format });
|
|
890
|
-
});
|
|
891
|
-
|
|
892
|
-
// ── business (alias) ──────────────────────────────────────────────────────
|
|
893
|
-
|
|
894
|
-
const business = program.command("business").description("Business management");
|
|
895
|
-
|
|
896
|
-
business
|
|
897
|
-
.command("list")
|
|
898
|
-
.description("List all businesses")
|
|
899
|
-
.option("--json", "JSON output")
|
|
900
|
-
.action(async (opts) => {
|
|
901
|
-
const cfg = requireAuth();
|
|
902
|
-
const client = new HisaaboClient(cfg);
|
|
903
|
-
try {
|
|
904
|
-
const businesses = await client.business.list();
|
|
905
|
-
if (opts.json) { outputJSON(businesses); return; }
|
|
906
|
-
businesses.forEach((b, i) => {
|
|
907
|
-
const active = b.id === cfg.businessId ? " [active]" : "";
|
|
908
|
-
console.log(` ${i + 1} ${b.name.padEnd(30)} ${(b.gstin ?? "-").padEnd(18)} ${b.gstRegistrationType}${active}`);
|
|
909
|
-
});
|
|
910
|
-
console.log();
|
|
911
|
-
} catch (e) {
|
|
912
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
913
|
-
}
|
|
914
|
-
});
|
|
915
|
-
|
|
916
|
-
business
|
|
917
|
-
.command("switch")
|
|
918
|
-
.description("Switch active business")
|
|
919
|
-
.option("--json", "JSON output")
|
|
920
|
-
.action(async (opts) => {
|
|
921
|
-
const cfg = requireAuth();
|
|
922
|
-
const client = new HisaaboClient(cfg);
|
|
923
|
-
try {
|
|
924
|
-
const businesses = await client.business.list();
|
|
925
|
-
if (opts.json) { outputJSON(businesses); return; }
|
|
926
|
-
businesses.forEach((b, i) => {
|
|
927
|
-
const active = b.id === cfg.businessId ? " [active]" : "";
|
|
928
|
-
console.log(` ${i + 1} ${b.name.padEnd(28)}${active}`);
|
|
929
|
-
});
|
|
930
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
931
|
-
const answer = await new Promise<string>((res) => rl.question("\n Select: ", res));
|
|
932
|
-
rl.close();
|
|
933
|
-
const idx = parseInt(answer.trim(), 10) - 1;
|
|
934
|
-
const selected = businesses[Math.max(0, Math.min(idx, businesses.length - 1))];
|
|
935
|
-
if (!selected) fatalError("Invalid selection.", EXIT.USAGE);
|
|
936
|
-
setConfig({ businessId: selected.id, businessName: selected.name });
|
|
937
|
-
success(`Switched to: ${selected.name}`);
|
|
938
|
-
} catch (e) {
|
|
939
|
-
if (e instanceof HisaaboApiError) {
|
|
940
|
-
if (e.hisaaboError.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
941
|
-
}
|
|
942
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
943
|
-
}
|
|
944
|
-
});
|
|
35
|
+
.version(cliVersion);
|
|
36
|
+
|
|
37
|
+
// ── Register all command groups ───────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
registerAuthCommands(program);
|
|
40
|
+
registerDashboardCommands(program);
|
|
41
|
+
registerInvoiceCommands(program);
|
|
42
|
+
registerPartyCommands(program);
|
|
43
|
+
registerItemCommands(program);
|
|
44
|
+
registerPaymentCommands(program);
|
|
45
|
+
registerExpenseCommands(program);
|
|
46
|
+
registerGstCommands(program);
|
|
47
|
+
registerReportCommands(program);
|
|
48
|
+
registerBankCommands(program);
|
|
49
|
+
registerShipmentCommands(program);
|
|
50
|
+
registerTargetCommands(program);
|
|
51
|
+
registerStoreCommands(program);
|
|
52
|
+
registerImportCommands(program);
|
|
53
|
+
registerAutomatedInvoiceCommands(program);
|
|
54
|
+
registerBusinessCommands(program);
|
|
55
|
+
registerDocumentCommands(program);
|
|
56
|
+
registerTenantCommands(program);
|
|
57
|
+
registerApiKeyCommands(program);
|
|
58
|
+
registerSessionCommands(program);
|
|
945
59
|
|
|
946
60
|
// ── Run ────────────────────────────────────────────────────────────────────
|
|
947
61
|
|