@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
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
|
|
3
|
+
export function registerDashboardCommands(program: Command): void {
|
|
4
|
+
const dash = program
|
|
5
|
+
.command("dashboard")
|
|
6
|
+
.alias("dash")
|
|
7
|
+
.description("Business dashboard & analytics");
|
|
8
|
+
|
|
9
|
+
// ── summary ──────────────────────────────────────────────────────────────
|
|
10
|
+
dash
|
|
11
|
+
.command("summary")
|
|
12
|
+
.description("Financial summary overview (FY to date)")
|
|
13
|
+
.option("--json", "JSON output")
|
|
14
|
+
.action(async (opts) => {
|
|
15
|
+
const { dashboardCommand } = await import("../../commands/dashboard/summary.js");
|
|
16
|
+
await dashboardCommand({ json: opts.json });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// ── sales-trend ──────────────────────────────────────────────────────────
|
|
20
|
+
dash
|
|
21
|
+
.command("sales-trend")
|
|
22
|
+
.description("Sales trend over time")
|
|
23
|
+
.option("--months <n>", "Number of months to show", (v) => parseInt(v, 10))
|
|
24
|
+
.option("--from <date>", "Start date (YYYY-MM-DD)")
|
|
25
|
+
.option("--to <date>", "End date (YYYY-MM-DD)")
|
|
26
|
+
.option("--granularity <g>", "daily | weekly | monthly")
|
|
27
|
+
.option("--json", "JSON output")
|
|
28
|
+
.option("--format <format>", "table | tsv | csv")
|
|
29
|
+
.action(async (opts) => {
|
|
30
|
+
const { dashboardSalesTrendCommand } = await import("../../commands/dashboard/sales-trend.js");
|
|
31
|
+
await dashboardSalesTrendCommand(opts);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// ── top-outstanding ───────────────────────────────────────────────────────
|
|
35
|
+
dash
|
|
36
|
+
.command("top-outstanding")
|
|
37
|
+
.description("Parties with highest outstanding balances")
|
|
38
|
+
.option("--limit <n>", "Max rows to show", (v) => parseInt(v, 10))
|
|
39
|
+
.option("--json", "JSON output")
|
|
40
|
+
.option("--format <format>", "table | tsv | csv")
|
|
41
|
+
.action(async (opts) => {
|
|
42
|
+
const { dashboardTopOutstandingCommand } = await import("../../commands/dashboard/top-outstanding.js");
|
|
43
|
+
await dashboardTopOutstandingCommand(opts);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// ── top-customers ─────────────────────────────────────────────────────────
|
|
47
|
+
dash
|
|
48
|
+
.command("top-customers")
|
|
49
|
+
.description("Top customers by revenue")
|
|
50
|
+
.option("--limit <n>", "Max rows to show", (v) => parseInt(v, 10))
|
|
51
|
+
.option("--from <date>", "Start date (YYYY-MM-DD)")
|
|
52
|
+
.option("--to <date>", "End date (YYYY-MM-DD)")
|
|
53
|
+
.option("--this-month", "Filter to current calendar month")
|
|
54
|
+
.option("--this-fy", "Filter to current financial year")
|
|
55
|
+
.option("--json", "JSON output")
|
|
56
|
+
.option("--format <format>", "table | tsv | csv")
|
|
57
|
+
.action(async (opts) => {
|
|
58
|
+
const { dashboardTopCustomersCommand } = await import("../../commands/dashboard/top-customers.js");
|
|
59
|
+
await dashboardTopCustomersCommand({
|
|
60
|
+
limit: opts.limit,
|
|
61
|
+
from: opts.from,
|
|
62
|
+
to: opts.to,
|
|
63
|
+
thisMonth: opts.thisMonth,
|
|
64
|
+
thisFy: opts.thisFy,
|
|
65
|
+
json: opts.json,
|
|
66
|
+
format: opts.format,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// ── top-items ─────────────────────────────────────────────────────────────
|
|
71
|
+
dash
|
|
72
|
+
.command("top-items")
|
|
73
|
+
.description("Top selling items by revenue and quantity")
|
|
74
|
+
.option("--limit <n>", "Max rows to show", (v) => parseInt(v, 10))
|
|
75
|
+
.option("--type <type>", "Item type filter (product | service)")
|
|
76
|
+
.option("--from <date>", "Start date (YYYY-MM-DD)")
|
|
77
|
+
.option("--to <date>", "End date (YYYY-MM-DD)")
|
|
78
|
+
.option("--this-month", "Filter to current calendar month")
|
|
79
|
+
.option("--this-fy", "Filter to current financial year")
|
|
80
|
+
.option("--json", "JSON output")
|
|
81
|
+
.option("--format <format>", "table | tsv | csv")
|
|
82
|
+
.action(async (opts) => {
|
|
83
|
+
const { dashboardTopItemsCommand } = await import("../../commands/dashboard/top-items.js");
|
|
84
|
+
await dashboardTopItemsCommand({
|
|
85
|
+
limit: opts.limit,
|
|
86
|
+
type: opts.type,
|
|
87
|
+
from: opts.from,
|
|
88
|
+
to: opts.to,
|
|
89
|
+
thisMonth: opts.thisMonth,
|
|
90
|
+
thisFy: opts.thisFy,
|
|
91
|
+
json: opts.json,
|
|
92
|
+
format: opts.format,
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// ── expenses (alias: expenses-by-category) ───────────────────────────────
|
|
97
|
+
const expensesCmd = dash
|
|
98
|
+
.command("expenses")
|
|
99
|
+
.description("Expenses broken down by category")
|
|
100
|
+
.option("--from <date>", "Start date (YYYY-MM-DD)")
|
|
101
|
+
.option("--to <date>", "End date (YYYY-MM-DD)")
|
|
102
|
+
.option("--this-month", "Filter to current calendar month")
|
|
103
|
+
.option("--this-fy", "Filter to current financial year")
|
|
104
|
+
.option("--json", "JSON output")
|
|
105
|
+
.option("--format <format>", "table | tsv | csv")
|
|
106
|
+
.action(async (opts) => {
|
|
107
|
+
const { dashboardExpensesCommand } = await import("../../commands/dashboard/expenses.js");
|
|
108
|
+
await dashboardExpensesCommand({
|
|
109
|
+
from: opts.from,
|
|
110
|
+
to: opts.to,
|
|
111
|
+
thisMonth: opts.thisMonth,
|
|
112
|
+
thisFy: opts.thisFy,
|
|
113
|
+
json: opts.json,
|
|
114
|
+
format: opts.format,
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
expensesCmd.alias("expenses-by-category");
|
|
118
|
+
|
|
119
|
+
// ── invoice-breakdown ─────────────────────────────────────────────────────
|
|
120
|
+
dash
|
|
121
|
+
.command("invoice-breakdown")
|
|
122
|
+
.description("Invoice count and amounts by status")
|
|
123
|
+
.option("--from <date>", "Start date (YYYY-MM-DD)")
|
|
124
|
+
.option("--to <date>", "End date (YYYY-MM-DD)")
|
|
125
|
+
.option("--this-month", "Filter to current calendar month")
|
|
126
|
+
.option("--this-fy", "Filter to current financial year")
|
|
127
|
+
.option("--json", "JSON output")
|
|
128
|
+
.action(async (opts) => {
|
|
129
|
+
const { dashboardInvoiceBreakdownCommand } = await import("../../commands/dashboard/invoice-breakdown.js");
|
|
130
|
+
await dashboardInvoiceBreakdownCommand({
|
|
131
|
+
from: opts.from,
|
|
132
|
+
to: opts.to,
|
|
133
|
+
thisMonth: opts.thisMonth,
|
|
134
|
+
thisFy: opts.thisFy,
|
|
135
|
+
json: opts.json,
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// ── profit-loss (alias: pl) ───────────────────────────────────────────────
|
|
140
|
+
const plCmd = dash
|
|
141
|
+
.command("profit-loss")
|
|
142
|
+
.description("Profit & Loss statement")
|
|
143
|
+
.option("--from <date>", "Start date (YYYY-MM-DD, default: FY start)")
|
|
144
|
+
.option("--to <date>", "End date (YYYY-MM-DD, default: today)")
|
|
145
|
+
.option("--this-month", "Scope to current calendar month")
|
|
146
|
+
.option("--this-fy", "Scope to current financial year")
|
|
147
|
+
.option("--json", "JSON output")
|
|
148
|
+
.action(async (opts) => {
|
|
149
|
+
const { dashboardProfitLossCommand } = await import("../../commands/dashboard/profit-loss.js");
|
|
150
|
+
await dashboardProfitLossCommand({
|
|
151
|
+
from: opts.from,
|
|
152
|
+
to: opts.to,
|
|
153
|
+
thisMonth: opts.thisMonth,
|
|
154
|
+
thisFy: opts.thisFy,
|
|
155
|
+
json: opts.json,
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
plCmd.alias("pl");
|
|
159
|
+
|
|
160
|
+
// ── receivables-aging ─────────────────────────────────────────────────────
|
|
161
|
+
dash
|
|
162
|
+
.command("receivables-aging")
|
|
163
|
+
.description("Receivables aging buckets (current / 1-30 / 31-60 / 61-90 / 90+)")
|
|
164
|
+
.option("--json", "JSON output")
|
|
165
|
+
.option("--format <format>", "table | tsv | csv")
|
|
166
|
+
.action(async (opts) => {
|
|
167
|
+
const { dashboardReceivablesAgingCommand } = await import("../../commands/dashboard/receivables-aging.js");
|
|
168
|
+
await dashboardReceivablesAgingCommand({ json: opts.json, format: opts.format });
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// ── payment-modes ─────────────────────────────────────────────────────────
|
|
172
|
+
dash
|
|
173
|
+
.command("payment-modes")
|
|
174
|
+
.description("Payment mode breakdown (cash / UPI / bank transfer / etc.)")
|
|
175
|
+
.option("--from <date>", "Start date (YYYY-MM-DD)")
|
|
176
|
+
.option("--to <date>", "End date (YYYY-MM-DD)")
|
|
177
|
+
.option("--this-month", "Filter to current calendar month")
|
|
178
|
+
.option("--this-fy", "Filter to current financial year")
|
|
179
|
+
.option("--json", "JSON output")
|
|
180
|
+
.option("--format <format>", "table | tsv | csv")
|
|
181
|
+
.action(async (opts) => {
|
|
182
|
+
const { dashboardPaymentModesCommand } = await import("../../commands/dashboard/payment-modes.js");
|
|
183
|
+
await dashboardPaymentModesCommand({
|
|
184
|
+
from: opts.from,
|
|
185
|
+
to: opts.to,
|
|
186
|
+
thisMonth: opts.thisMonth,
|
|
187
|
+
thisFy: opts.thisFy,
|
|
188
|
+
json: opts.json,
|
|
189
|
+
format: opts.format,
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// ── collection-efficiency ─────────────────────────────────────────────────
|
|
194
|
+
dash
|
|
195
|
+
.command("collection-efficiency")
|
|
196
|
+
.description("Collection rate, DSO, and aging breakdown")
|
|
197
|
+
.option("--from <date>", "Start date (YYYY-MM-DD)")
|
|
198
|
+
.option("--to <date>", "End date (YYYY-MM-DD)")
|
|
199
|
+
.option("--this-month", "Filter to current calendar month")
|
|
200
|
+
.option("--this-fy", "Filter to current financial year")
|
|
201
|
+
.option("--json", "JSON output")
|
|
202
|
+
.option("--format <format>", "table | tsv | csv")
|
|
203
|
+
.action(async (opts) => {
|
|
204
|
+
const { dashboardCollectionEfficiencyCommand } = await import("../../commands/dashboard/collection-efficiency.js");
|
|
205
|
+
await dashboardCollectionEfficiencyCommand({
|
|
206
|
+
from: opts.from,
|
|
207
|
+
to: opts.to,
|
|
208
|
+
thisMonth: opts.thisMonth,
|
|
209
|
+
thisFy: opts.thisFy,
|
|
210
|
+
json: opts.json,
|
|
211
|
+
format: opts.format,
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// ── monthly-comparison ────────────────────────────────────────────────────
|
|
216
|
+
dash
|
|
217
|
+
.command("monthly-comparison")
|
|
218
|
+
.description("Month-over-month comparison of sales, expenses, profit, and collections")
|
|
219
|
+
.option("--json", "JSON output")
|
|
220
|
+
.option("--format <format>", "table | tsv | csv")
|
|
221
|
+
.action(async (opts) => {
|
|
222
|
+
const { dashboardMonthlyComparisonCommand } = await import("../../commands/dashboard/monthly-comparison.js");
|
|
223
|
+
await dashboardMonthlyComparisonCommand({ json: opts.json, format: opts.format });
|
|
224
|
+
});
|
|
225
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import type { DocTypeConfig } from "../../commands/document/factory.js";
|
|
3
|
+
|
|
4
|
+
const DOC_TYPES: DocTypeConfig[] = [
|
|
5
|
+
{
|
|
6
|
+
cmd: "quotation",
|
|
7
|
+
label: "Quotation",
|
|
8
|
+
nsKey: "quotation",
|
|
9
|
+
statuses: ["draft", "sent", "accepted", "rejected", "expired", "cancelled"],
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
cmd: "credit-note",
|
|
13
|
+
label: "Credit Note",
|
|
14
|
+
nsKey: "creditNote",
|
|
15
|
+
statuses: ["draft", "confirmed", "cancelled"],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
cmd: "debit-note",
|
|
19
|
+
label: "Debit Note",
|
|
20
|
+
nsKey: "debitNote",
|
|
21
|
+
statuses: ["draft", "confirmed", "cancelled"],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
cmd: "delivery-challan",
|
|
25
|
+
label: "Delivery Challan",
|
|
26
|
+
nsKey: "deliveryChallan",
|
|
27
|
+
statuses: ["draft", "dispatched", "delivered", "cancelled"],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
cmd: "proforma",
|
|
31
|
+
label: "Proforma Invoice",
|
|
32
|
+
nsKey: "proforma",
|
|
33
|
+
statuses: ["draft", "sent", "accepted", "rejected", "expired", "converted", "cancelled"],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
cmd: "sales-return",
|
|
37
|
+
label: "Sales Return",
|
|
38
|
+
nsKey: "salesReturn",
|
|
39
|
+
statuses: ["draft", "confirmed", "cancelled"],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
cmd: "purchase-return",
|
|
43
|
+
label: "Purchase Return",
|
|
44
|
+
nsKey: "purchaseReturn",
|
|
45
|
+
statuses: ["draft", "confirmed", "cancelled"],
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
export function registerDocumentCommands(program: Command): void {
|
|
50
|
+
for (const dt of DOC_TYPES) {
|
|
51
|
+
const parent = program.command(dt.cmd).description(`${dt.label} management`);
|
|
52
|
+
|
|
53
|
+
parent
|
|
54
|
+
.command("list")
|
|
55
|
+
.description(`List ${dt.label.toLowerCase()}s`)
|
|
56
|
+
.option("--json", "JSON output")
|
|
57
|
+
.option("--format <format>", "Output format: table, tsv, csv, ids")
|
|
58
|
+
.option("--status <status>", `Filter by status: ${dt.statuses.join(", ")}`)
|
|
59
|
+
.option("--party <search>", "Filter by party name")
|
|
60
|
+
.option("--from <date>", "Start date (YYYY-MM-DD)")
|
|
61
|
+
.option("--to <date>", "End date (YYYY-MM-DD)")
|
|
62
|
+
.option("--this-month", "Current month")
|
|
63
|
+
.option("--this-fy", "Current financial year")
|
|
64
|
+
.option("--page <n>", "Page number", parseInt)
|
|
65
|
+
.option("--limit <n>", "Items per page", parseInt)
|
|
66
|
+
.action(async (opts) => {
|
|
67
|
+
const { docListCommand } = await import("../../commands/document/factory.js");
|
|
68
|
+
await docListCommand(dt, opts);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
parent
|
|
72
|
+
.command("get <id>")
|
|
73
|
+
.description(`Get ${dt.label.toLowerCase()} details`)
|
|
74
|
+
.option("--json", "JSON output")
|
|
75
|
+
.action(async (id, opts) => {
|
|
76
|
+
const { docGetCommand } = await import("../../commands/document/factory.js");
|
|
77
|
+
await docGetCommand(dt, id, opts);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
parent
|
|
81
|
+
.command("create")
|
|
82
|
+
.description(`Create a new ${dt.label.toLowerCase()}`)
|
|
83
|
+
.option("--json", "JSON output")
|
|
84
|
+
.option("--party-id <id>", "Party UUID")
|
|
85
|
+
.option("--party <name>", "Party search name")
|
|
86
|
+
.option("--date <date>", "Document date (YYYY-MM-DD)")
|
|
87
|
+
.option("--due-date <date>", "Due date (YYYY-MM-DD)")
|
|
88
|
+
.option("--item <desc>", "Item description (repeatable)", (v, a: string[]) => [...a, v], [] as string[])
|
|
89
|
+
.option("--qty <n>", "Quantity per item (repeatable)", (v, a: string[]) => [...a, v], [] as string[])
|
|
90
|
+
.option("--rate <n>", "Rate per item (repeatable)", (v, a: string[]) => [...a, v], [] as string[])
|
|
91
|
+
.option("--notes <text>", "Notes")
|
|
92
|
+
.option("--discount <pct>", "Discount percent")
|
|
93
|
+
.option("-y, --yes", "Skip confirmation")
|
|
94
|
+
.action(async (opts) => {
|
|
95
|
+
const { docCreateCommand } = await import("../../commands/document/factory.js");
|
|
96
|
+
await docCreateCommand(dt, opts);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
parent
|
|
100
|
+
.command("update-status <id> <status>")
|
|
101
|
+
.description(`Update ${dt.label.toLowerCase()} status (${dt.statuses.join(", ")})`)
|
|
102
|
+
.option("--json", "JSON output")
|
|
103
|
+
.action(async (id, status, opts) => {
|
|
104
|
+
const { docStatusCommand } = await import("../../commands/document/factory.js");
|
|
105
|
+
await docStatusCommand(dt, id, status, opts);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
parent
|
|
109
|
+
.command("delete <id>")
|
|
110
|
+
.description(`Delete a ${dt.label.toLowerCase()}`)
|
|
111
|
+
.option("-y, --yes", "Skip confirmation")
|
|
112
|
+
.option("--json", "JSON output")
|
|
113
|
+
.action(async (id, opts) => {
|
|
114
|
+
const { docDeleteCommand } = await import("../../commands/document/factory.js");
|
|
115
|
+
await docDeleteCommand(dt, id, opts);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ── document convert ──────────────────────────────────────────────────────
|
|
120
|
+
|
|
121
|
+
program
|
|
122
|
+
.command("document")
|
|
123
|
+
.description("Document conversion operations")
|
|
124
|
+
.command("convert")
|
|
125
|
+
.description("Convert one document type to another")
|
|
126
|
+
.requiredOption("--from-type <type>", "Source type (quotation, proforma, delivery-challan, etc.)")
|
|
127
|
+
.requiredOption("--from-id <id>", "Source document ID")
|
|
128
|
+
.requiredOption("--to-type <type>", "Target type (invoice, credit-note, etc.)")
|
|
129
|
+
.option("--json", "JSON output")
|
|
130
|
+
.option("-y, --yes", "Skip confirmation")
|
|
131
|
+
.action(async (opts) => {
|
|
132
|
+
const { HisaaboClient, HisaaboApiError } = await import("../../client.js");
|
|
133
|
+
const { requireAuth } = await import("../../config.js");
|
|
134
|
+
const { fatalError, outputJSON, success, EXIT } = await import("../../output.js");
|
|
135
|
+
|
|
136
|
+
const cfg = requireAuth();
|
|
137
|
+
const client = new HisaaboClient(cfg);
|
|
138
|
+
|
|
139
|
+
if (!opts.yes && process.stdin.isTTY) {
|
|
140
|
+
const readline = await import("readline");
|
|
141
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
142
|
+
const answer = await new Promise<string>((resolve) => {
|
|
143
|
+
rl.question(
|
|
144
|
+
` Convert ${opts.fromType} ${opts.fromId} → ${opts.toType}? (y/N): `,
|
|
145
|
+
resolve,
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
rl.close();
|
|
149
|
+
if (answer.trim().toLowerCase() !== "y") {
|
|
150
|
+
console.log(" Cancelled.");
|
|
151
|
+
process.exit(EXIT.SUCCESS);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
const result = await client.document.convert({
|
|
157
|
+
fromType: opts.fromType,
|
|
158
|
+
fromId: opts.fromId,
|
|
159
|
+
toType: opts.toType,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
if (opts.json) {
|
|
163
|
+
outputJSON(result);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const newId = result.id ?? result.documentId ?? "(unknown)";
|
|
168
|
+
const newNum = result.documentNumber ?? result.number ?? newId;
|
|
169
|
+
success(`Converted: ${opts.fromType} → ${opts.toType} ${newNum}`);
|
|
170
|
+
console.log(` New ID: ${newId}\n`);
|
|
171
|
+
|
|
172
|
+
} catch (e) {
|
|
173
|
+
if (e instanceof HisaaboApiError) {
|
|
174
|
+
const err = e.hisaaboError;
|
|
175
|
+
if (err.code === "not_found") fatalError(`Source document not found: ${opts.fromId}`, EXIT.NOT_FOUND);
|
|
176
|
+
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
177
|
+
if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
|
|
178
|
+
if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
|
|
179
|
+
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
180
|
+
}
|
|
181
|
+
fatalError(String(e instanceof Error ? e.message : e));
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { expenseListCommand } from "../../commands/expense/list.js";
|
|
3
|
+
import { expenseCreateCommand } from "../../commands/expense/create.js";
|
|
4
|
+
import { expenseDeleteCommand } from "../../commands/expense/delete.js";
|
|
5
|
+
|
|
6
|
+
export function registerExpenseCommands(program: Command): void {
|
|
7
|
+
// ── expense ───────────────────────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
const expense = program.command("expense").description("Expense tracking");
|
|
10
|
+
|
|
11
|
+
expense
|
|
12
|
+
.command("list")
|
|
13
|
+
.description("List expenses")
|
|
14
|
+
.option("--json", "JSON output")
|
|
15
|
+
.option("--format <format>", "Output format: table, tsv, csv, ids")
|
|
16
|
+
.option("--category <cat>", "Filter by category")
|
|
17
|
+
.option("--from <date>", "From date")
|
|
18
|
+
.option("--to <date>", "To date")
|
|
19
|
+
.option("--page <n>", "Page number", parseInt)
|
|
20
|
+
.option("--limit <n>", "Items per page", parseInt)
|
|
21
|
+
.action(async (opts) => {
|
|
22
|
+
await expenseListCommand(opts);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
expense
|
|
26
|
+
.command("create")
|
|
27
|
+
.description("Create a new expense")
|
|
28
|
+
.option("--json", "JSON output")
|
|
29
|
+
.option("--category <cat>", "Expense category")
|
|
30
|
+
.option("--amount <amount>", "Amount")
|
|
31
|
+
.option("--mode <mode>", "cash/bank/upi/cheque/other")
|
|
32
|
+
.option("--description <text>", "Description")
|
|
33
|
+
.option("--date <date>", "Expense date")
|
|
34
|
+
.option("--reference <ref>", "Reference number")
|
|
35
|
+
.action(async (opts) => {
|
|
36
|
+
await expenseCreateCommand({
|
|
37
|
+
json: opts.json,
|
|
38
|
+
category: opts.category,
|
|
39
|
+
amount: opts.amount,
|
|
40
|
+
mode: opts.mode,
|
|
41
|
+
description: opts.description,
|
|
42
|
+
date: opts.date,
|
|
43
|
+
reference: opts.reference,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
expense
|
|
48
|
+
.command("delete <id>")
|
|
49
|
+
.description("Delete an expense")
|
|
50
|
+
.option("-y, --yes", "Skip confirmation")
|
|
51
|
+
.option("--json", "JSON output")
|
|
52
|
+
.action(async (id, opts) => {
|
|
53
|
+
await expenseDeleteCommand(id, { yes: opts.yes, json: opts.json });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expense
|
|
57
|
+
.command("update <id>")
|
|
58
|
+
.description("Update an expense")
|
|
59
|
+
.option("--amount <amount>", "New amount")
|
|
60
|
+
.option("--category <cat>", "Expense category")
|
|
61
|
+
.option("--date <YYYY-MM-DD>", "Expense date")
|
|
62
|
+
.option("--description <text>", "Description")
|
|
63
|
+
.option("--payment-mode <mode>", "Payment mode: cash, upi, bank, cheque, other")
|
|
64
|
+
.option("--reference <ref>", "Reference number")
|
|
65
|
+
.option("--json", "JSON output")
|
|
66
|
+
.action(async (id, opts) => {
|
|
67
|
+
const { expenseUpdateCommand } = await import("../../commands/expense/update.js");
|
|
68
|
+
await expenseUpdateCommand(id, {
|
|
69
|
+
json: opts.json,
|
|
70
|
+
amount: opts.amount,
|
|
71
|
+
category: opts.category,
|
|
72
|
+
date: opts.date,
|
|
73
|
+
description: opts.description,
|
|
74
|
+
paymentMode: opts.paymentMode,
|
|
75
|
+
reference: opts.reference,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
expense
|
|
80
|
+
.command("categories")
|
|
81
|
+
.description("List all expense categories")
|
|
82
|
+
.option("--json", "JSON output")
|
|
83
|
+
.action(async (opts) => {
|
|
84
|
+
const { expenseCategoriesCommand } = await import("../../commands/expense/categories.js");
|
|
85
|
+
await expenseCategoriesCommand({ json: opts.json });
|
|
86
|
+
});
|
|
87
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { gstR1Command, gstR3bCommand, gstR1CsvCommand } from "../../commands/gst/index.js";
|
|
3
|
+
|
|
4
|
+
export function registerGstCommands(program: Command): void {
|
|
5
|
+
// ── gst ───────────────────────────────────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
const gst = program.command("gst").description("GST reports");
|
|
8
|
+
|
|
9
|
+
gst
|
|
10
|
+
.command("r1")
|
|
11
|
+
.description("GSTR-1 report")
|
|
12
|
+
.option("--json", "JSON output")
|
|
13
|
+
.option("--quarter <q>", "Quarter: Q1, Q2, Q3, Q4")
|
|
14
|
+
.option("--month <n>", "Month number (1-12)", parseInt)
|
|
15
|
+
.option("--year <n>", "Year", parseInt)
|
|
16
|
+
.action(async (opts) => {
|
|
17
|
+
await gstR1Command({ json: opts.json, quarter: opts.quarter, month: opts.month, year: opts.year });
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
gst
|
|
21
|
+
.command("r3b")
|
|
22
|
+
.description("GSTR-3B report")
|
|
23
|
+
.option("--json", "JSON output")
|
|
24
|
+
.option("--quarter <q>", "Quarter: Q1, Q2, Q3, Q4")
|
|
25
|
+
.option("--month <n>", "Month number (1-12)", parseInt)
|
|
26
|
+
.option("--year <n>", "Year", parseInt)
|
|
27
|
+
.action(async (opts) => {
|
|
28
|
+
await gstR3bCommand({ json: opts.json, quarter: opts.quarter, month: opts.month, year: opts.year });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
gst
|
|
32
|
+
.command("r1-csv")
|
|
33
|
+
.description("Download GSTR-1 as GSTN-compatible CSV")
|
|
34
|
+
.option("--quarter <q>", "Quarter")
|
|
35
|
+
.option("--month <n>", "Month", parseInt)
|
|
36
|
+
.option("--year <n>", "Year", parseInt)
|
|
37
|
+
.option("--output <path>", "Output file path")
|
|
38
|
+
.action(async (opts) => {
|
|
39
|
+
await gstR1CsvCommand({ quarter: opts.quarter, month: opts.month, year: opts.year, output: opts.output });
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import {
|
|
3
|
+
importPartiesCommand,
|
|
4
|
+
importItemsCommand,
|
|
5
|
+
importInvoicesCommand,
|
|
6
|
+
importPaymentsCommand,
|
|
7
|
+
} from "../../commands/import/index.js";
|
|
8
|
+
|
|
9
|
+
export function registerImportCommands(program: Command): void {
|
|
10
|
+
// ── import ────────────────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
const importCmd = program.command("import").description("Bulk import data");
|
|
13
|
+
|
|
14
|
+
importCmd
|
|
15
|
+
.command("parties <file>")
|
|
16
|
+
.description("Import parties from JSON or CSV file")
|
|
17
|
+
.option("--json", "JSON output")
|
|
18
|
+
.option("--format <format>", "json or csv (auto-detected from extension)")
|
|
19
|
+
.action(async (file, opts) => {
|
|
20
|
+
await importPartiesCommand(file, { json: opts.json, format: opts.format });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
importCmd
|
|
24
|
+
.command("items <file>")
|
|
25
|
+
.description("Import items from JSON or CSV file")
|
|
26
|
+
.option("--json", "JSON output")
|
|
27
|
+
.option("--format <format>", "json or csv (auto-detected from extension)")
|
|
28
|
+
.action(async (file, opts) => {
|
|
29
|
+
await importItemsCommand(file, { json: opts.json, format: opts.format });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
importCmd
|
|
33
|
+
.command("invoices <file>")
|
|
34
|
+
.description("Import invoices from JSON or CSV file")
|
|
35
|
+
.option("--json", "JSON output")
|
|
36
|
+
.option("--format <format>", "json or csv (auto-detected from extension)")
|
|
37
|
+
.action(async (file, opts) => {
|
|
38
|
+
await importInvoicesCommand(file, { json: opts.json, format: opts.format });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
importCmd
|
|
42
|
+
.command("payments <file>")
|
|
43
|
+
.description("Import payments from JSON or CSV file")
|
|
44
|
+
.option("--json", "JSON output")
|
|
45
|
+
.option("--format <format>", "json or csv (auto-detected from extension)")
|
|
46
|
+
.action(async (file, opts) => {
|
|
47
|
+
await importPaymentsCommand(file, { json: opts.json, format: opts.format });
|
|
48
|
+
});
|
|
49
|
+
}
|