@hisaabo/cli 0.7.5 → 0.8.6
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,29 +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
|
-
|
|
5
|
-
export async function automatedInvoiceRunNowCommand(id: string, opts: { json?: boolean }): Promise<void> {
|
|
6
|
-
const cfg = requireAuth();
|
|
7
|
-
const client = new HisaaboClient(cfg);
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
const result = await client.recurringInvoice.runNow(id);
|
|
11
|
-
|
|
12
|
-
if (opts.json) {
|
|
13
|
-
outputJSON(result);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
success(`Manually triggered recurring invoice template: ${id}`);
|
|
18
|
-
|
|
19
|
-
} catch (e) {
|
|
20
|
-
if (e instanceof HisaaboApiError) {
|
|
21
|
-
const err = e.hisaaboError;
|
|
22
|
-
if (err.code === "not_found") fatalError(`Template not found: ${id}`, EXIT.NOT_FOUND);
|
|
23
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
24
|
-
if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
|
|
25
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
26
|
-
}
|
|
27
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { HisaaboClient, HisaaboApiError, type RecurringInvoiceSuggestion } from "../../client.js";
|
|
2
|
-
import { requireAuth } from "../../config.js";
|
|
3
|
-
import { fatalError, outputJSON, outputTable, EXIT, type ColumnDef } from "../../output.js";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
|
|
6
|
-
const FREQUENCY_LABELS: Record<string, string> = {
|
|
7
|
-
weekly: "Weekly",
|
|
8
|
-
biweekly: "Every 2 Weeks",
|
|
9
|
-
monthly: "Monthly",
|
|
10
|
-
quarterly: "Quarterly",
|
|
11
|
-
half_yearly: "Every 6 Months",
|
|
12
|
-
yearly: "Yearly",
|
|
13
|
-
custom: "Custom",
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
function confidenceBadge(confidence: number): string {
|
|
17
|
-
const pct = Math.round(confidence * 100);
|
|
18
|
-
const label = `${pct}%`;
|
|
19
|
-
if (confidence >= 0.8) return chalk.green(label);
|
|
20
|
-
if (confidence >= 0.5) return chalk.yellow(label);
|
|
21
|
-
return chalk.dim(label);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface SuggestionsOpts {
|
|
25
|
-
json?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export async function automatedInvoiceSuggestionsCommand(opts: SuggestionsOpts): Promise<void> {
|
|
29
|
-
const cfg = requireAuth();
|
|
30
|
-
const client = new HisaaboClient(cfg);
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const result = await client.recurringInvoice.suggestions();
|
|
34
|
-
|
|
35
|
-
if (opts.json) {
|
|
36
|
-
outputJSON(result);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (result.length === 0) {
|
|
41
|
-
console.log("\n No recurring invoice suggestions yet.\n");
|
|
42
|
-
console.log(" Suggestions appear after patterns are detected in your invoice history.\n");
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
console.log(`\n Recurring Invoice Suggestions ${result.length} found\n`);
|
|
47
|
-
|
|
48
|
-
const cols: ColumnDef<RecurringInvoiceSuggestion>[] = [
|
|
49
|
-
{ key: "partyName", header: "Party", width: 24 },
|
|
50
|
-
{ key: "frequency", header: "Suggested Frequency", width: 20, format: (v) => FREQUENCY_LABELS[String(v ?? "")] ?? String(v ?? "") },
|
|
51
|
-
{ key: "confidence", header: "Confidence", width: 12, align: "right", format: (v) => confidenceBadge(Number(v ?? 0)) },
|
|
52
|
-
{ key: "reason", header: "Reason", width: 36 },
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
outputTable(result, cols);
|
|
56
|
-
|
|
57
|
-
console.log();
|
|
58
|
-
console.log(` Tip: run ${chalk.cyan("hisaabo automated-invoice create --party-id <id>")} to set up a template.\n`);
|
|
59
|
-
|
|
60
|
-
} catch (e) {
|
|
61
|
-
if (e instanceof HisaaboApiError) {
|
|
62
|
-
const err = e.hisaaboError;
|
|
63
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
64
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
65
|
-
}
|
|
66
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,54 +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
|
-
|
|
5
|
-
interface UpdateOpts {
|
|
6
|
-
json?: boolean;
|
|
7
|
-
name?: string;
|
|
8
|
-
frequency?: string;
|
|
9
|
-
startDate?: string;
|
|
10
|
-
endDate?: string;
|
|
11
|
-
maxRuns?: string;
|
|
12
|
-
notes?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function automatedInvoiceUpdateCommand(id: string, opts: UpdateOpts): Promise<void> {
|
|
16
|
-
const cfg = requireAuth();
|
|
17
|
-
const client = new HisaaboClient(cfg);
|
|
18
|
-
|
|
19
|
-
const data: Record<string, unknown> = {};
|
|
20
|
-
if (opts.name !== undefined) data["name"] = opts.name;
|
|
21
|
-
if (opts.frequency !== undefined) data["frequency"] = opts.frequency;
|
|
22
|
-
if (opts.startDate !== undefined) data["startDate"] = opts.startDate;
|
|
23
|
-
if (opts.endDate !== undefined) data["endDate"] = opts.endDate;
|
|
24
|
-
if (opts.maxRuns !== undefined) data["maxRuns"] = parseInt(opts.maxRuns, 10);
|
|
25
|
-
if (opts.notes !== undefined) data["notes"] = opts.notes;
|
|
26
|
-
|
|
27
|
-
if (Object.keys(data).length === 0) {
|
|
28
|
-
fatalError("No fields to update. Provide at least one option.", EXIT.USAGE);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const result = await client.recurringInvoice.update(
|
|
33
|
-
id,
|
|
34
|
-
data as Parameters<typeof client.recurringInvoice.update>[1],
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
if (opts.json) {
|
|
38
|
-
outputJSON(result);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
success(`Updated recurring invoice template: ${result.name} (${result.id})`);
|
|
43
|
-
|
|
44
|
-
} catch (e) {
|
|
45
|
-
if (e instanceof HisaaboApiError) {
|
|
46
|
-
const err = e.hisaaboError;
|
|
47
|
-
if (err.code === "not_found") fatalError(`Recurring invoice template not found: ${id}`, EXIT.NOT_FOUND);
|
|
48
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
49
|
-
if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
|
|
50
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
51
|
-
}
|
|
52
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { HisaaboClient, HisaaboApiError } from "../../client.js";
|
|
2
|
-
import { requireAuth } from "../../config.js";
|
|
3
|
-
import { fatalError, outputJSON, EXIT, hasColor } from "../../output.js";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
|
|
6
|
-
const FREE_PLAN_LIMIT = 5;
|
|
7
|
-
const BAR_WIDTH = 20;
|
|
8
|
-
|
|
9
|
-
function usageBar(used: number, limit: number): string {
|
|
10
|
-
const pct = limit > 0 ? Math.min(used / limit, 1) : 0;
|
|
11
|
-
const filled = Math.round(pct * BAR_WIDTH);
|
|
12
|
-
const empty = BAR_WIDTH - filled;
|
|
13
|
-
const filledChar = "█".repeat(filled);
|
|
14
|
-
const emptyChar = "░".repeat(empty);
|
|
15
|
-
|
|
16
|
-
if (!hasColor()) return `[${filledChar}${emptyChar}]`;
|
|
17
|
-
|
|
18
|
-
const bar = pct >= 1
|
|
19
|
-
? chalk.red(filledChar)
|
|
20
|
-
: pct >= 0.8
|
|
21
|
-
? chalk.yellow(filledChar)
|
|
22
|
-
: chalk.green(filledChar);
|
|
23
|
-
|
|
24
|
-
return `[${bar}${chalk.dim(emptyChar)}]`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface UsageOpts {
|
|
28
|
-
json?: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export async function automatedInvoiceUsageCommand(opts: UsageOpts): Promise<void> {
|
|
32
|
-
const cfg = requireAuth();
|
|
33
|
-
const client = new HisaaboClient(cfg);
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
const result = await client.recurringInvoice.planUsage();
|
|
37
|
-
|
|
38
|
-
if (opts.json) {
|
|
39
|
-
outputJSON(result);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const limit = FREE_PLAN_LIMIT;
|
|
44
|
-
const pct = limit > 0 ? Math.round((result.runsThisMonth / limit) * 100) : 0;
|
|
45
|
-
|
|
46
|
-
console.log("\n Plan Usage — Recurring Invoices\n");
|
|
47
|
-
console.log(` Templates: ${result.totalTemplates}`);
|
|
48
|
-
console.log(` Runs/month: ${result.runsThisMonth} / ${limit} ${usageBar(result.runsThisMonth, limit)} ${pct}%`);
|
|
49
|
-
|
|
50
|
-
if (result.runsThisMonth >= limit) {
|
|
51
|
-
const msg = " Monthly run limit reached. Upgrade your plan for unlimited runs.";
|
|
52
|
-
console.log(hasColor() ? chalk.red(msg) : msg);
|
|
53
|
-
} else {
|
|
54
|
-
const remaining = limit - result.runsThisMonth;
|
|
55
|
-
console.log(` Remaining: ${remaining} run${remaining !== 1 ? "s" : ""} this month`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
console.log();
|
|
59
|
-
|
|
60
|
-
} catch (e) {
|
|
61
|
-
if (e instanceof HisaaboApiError) {
|
|
62
|
-
const err = e.hisaaboError;
|
|
63
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
64
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
65
|
-
}
|
|
66
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { HisaaboClient, HisaaboApiError, type GatewayChargeRate } from "../../client.js";
|
|
2
|
-
import { requireAuth } from "../../config.js";
|
|
3
|
-
import { fatalError, outputJSON, outputTable, EXIT, type ColumnDef } from "../../output.js";
|
|
4
|
-
|
|
5
|
-
function formatChargeRate(rate: GatewayChargeRate | undefined): string {
|
|
6
|
-
if (!rate) return "-";
|
|
7
|
-
return rate.type === "percentage" ? `${rate.value}%` : `Flat ${rate.value}`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export async function bankGatewayConfigCommand(
|
|
11
|
-
accountId: string,
|
|
12
|
-
opts: { json?: boolean },
|
|
13
|
-
): Promise<void> {
|
|
14
|
-
const cfg = requireAuth();
|
|
15
|
-
const client = new HisaaboClient(cfg);
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
const config = await client.bankAccount.getGatewayConfig(accountId);
|
|
19
|
-
|
|
20
|
-
if (!config) {
|
|
21
|
-
fatalError(`No gateway configuration found for account: ${accountId}`, EXIT.NOT_FOUND);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (opts.json) {
|
|
25
|
-
outputJSON(config);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
console.log(`\n Gateway Configuration`);
|
|
30
|
-
console.log(" " + "\u2500".repeat(45));
|
|
31
|
-
console.log(` Account: ${accountId}`);
|
|
32
|
-
console.log(` Settlement Account: ${config.settlementAccountId}`);
|
|
33
|
-
console.log(` Expense Category: ${config.expenseCategory}`);
|
|
34
|
-
console.log(` Auto Settle: ${config.autoSettle ? "Yes" : "No"}`);
|
|
35
|
-
console.log(` Active: ${config.isActive ? "Yes" : "No"}`);
|
|
36
|
-
console.log();
|
|
37
|
-
|
|
38
|
-
const modes = ["credit_card", "debit_card", "upi", "net_banking", "wallet", "default"] as const;
|
|
39
|
-
const rows = modes.map((mode) => ({
|
|
40
|
-
mode,
|
|
41
|
-
rate: formatChargeRate(config.chargeConfig[mode]),
|
|
42
|
-
}));
|
|
43
|
-
|
|
44
|
-
const cols: ColumnDef<{ mode: string; rate: string }>[] = [
|
|
45
|
-
{ key: "mode", header: "Payment Mode", width: 18 },
|
|
46
|
-
{ key: "rate", header: "Charge Rate", width: 16 },
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
console.log(" Charge Rates:\n");
|
|
50
|
-
outputTable(rows, cols);
|
|
51
|
-
console.log();
|
|
52
|
-
} catch (e) {
|
|
53
|
-
if (e instanceof HisaaboApiError) {
|
|
54
|
-
const err = e.hisaaboError;
|
|
55
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
56
|
-
if (err.code === "not_found") fatalError(`Bank account not found: ${accountId}`, EXIT.NOT_FOUND);
|
|
57
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
58
|
-
}
|
|
59
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import * as readline from "readline";
|
|
2
|
-
import { HisaaboClient, HisaaboApiError, type BankAccountSummary, type BankTransactionRow } from "../../client.js";
|
|
3
|
-
import { requireAuth } from "../../config.js";
|
|
4
|
-
import {
|
|
5
|
-
fatalError, outputJSON, outputTable, paginationFooter, EXIT, success, type ColumnDef,
|
|
6
|
-
} from "../../output.js";
|
|
7
|
-
import { formatAmount, formatDate, formatINR } from "../../format.js";
|
|
8
|
-
|
|
9
|
-
async function prompt(rl: readline.Interface, q: string): Promise<string> {
|
|
10
|
-
return new Promise((resolve) => rl.question(q, resolve));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function bankListCommand(opts: { json?: boolean }): Promise<void> {
|
|
14
|
-
const cfg = requireAuth();
|
|
15
|
-
const client = new HisaaboClient(cfg);
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
const [accounts, summary] = await Promise.all([
|
|
19
|
-
client.bankAccount.list(),
|
|
20
|
-
client.bankAccount.summary(),
|
|
21
|
-
]);
|
|
22
|
-
|
|
23
|
-
if (opts.json) {
|
|
24
|
-
outputJSON({ accounts, summary });
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
console.log("\n Bank Accounts\n");
|
|
29
|
-
console.log(` ${"═".repeat(60)}\n`);
|
|
30
|
-
|
|
31
|
-
const cols: ColumnDef<BankAccountSummary>[] = [
|
|
32
|
-
{ key: "accountName", header: "Name", width: 22 },
|
|
33
|
-
{ key: "bankName", header: "Bank", width: 16, format: (v) => String(v ?? "-") },
|
|
34
|
-
{ key: "accountType", header: "Type", width: 10 },
|
|
35
|
-
{ key: "accountNumber", header: "Account #", width: 16, format: (v) => String(v ?? "-") },
|
|
36
|
-
{ key: "currentBalance", header: "Balance (₹)", align: "right", width: 14, format: (v) => formatAmount(String(v ?? "0")) },
|
|
37
|
-
{ key: "isDefault", header: "Default", width: 8, format: (v) => v ? "Yes" : "" },
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
outputTable(accounts, cols);
|
|
41
|
-
console.log(`\n Total Balance: ${formatINR(summary.totalBalance)}`);
|
|
42
|
-
console.log(` Cash in Hand: ${formatINR(summary.cashInHand)}`);
|
|
43
|
-
console.log(` Bank Balance: ${formatINR(summary.bankBalance)}\n`);
|
|
44
|
-
|
|
45
|
-
} catch (e) {
|
|
46
|
-
if (e instanceof HisaaboApiError) {
|
|
47
|
-
const err = e.hisaaboError;
|
|
48
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
49
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
50
|
-
}
|
|
51
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export async function bankGetCommand(id: string, opts: { json?: boolean }): Promise<void> {
|
|
56
|
-
const cfg = requireAuth();
|
|
57
|
-
const client = new HisaaboClient(cfg);
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
const account = await client.bankAccount.get(id);
|
|
61
|
-
if (!account) fatalError(`Bank account not found: ${id}`, EXIT.NOT_FOUND);
|
|
62
|
-
|
|
63
|
-
if (opts.json) {
|
|
64
|
-
outputJSON(account);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
console.log(`\n ${account!.accountName} (${account!.accountType})`);
|
|
69
|
-
console.log(" " + "─".repeat(45));
|
|
70
|
-
if (account!.bankName) console.log(` Bank: ${account!.bankName}`);
|
|
71
|
-
if (account!.accountNumber) console.log(` Account: ${account!.accountNumber}`);
|
|
72
|
-
if (account!.ifsc) console.log(` IFSC: ${account!.ifsc}`);
|
|
73
|
-
console.log(` Balance: ${formatINR(account!.currentBalance)}`);
|
|
74
|
-
console.log();
|
|
75
|
-
|
|
76
|
-
} catch (e) {
|
|
77
|
-
if (e instanceof HisaaboApiError) {
|
|
78
|
-
const err = e.hisaaboError;
|
|
79
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
80
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
81
|
-
}
|
|
82
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export async function bankCreateCommand(opts: {
|
|
87
|
-
json?: boolean;
|
|
88
|
-
name?: string;
|
|
89
|
-
type?: string;
|
|
90
|
-
bank?: string;
|
|
91
|
-
accountNumber?: string;
|
|
92
|
-
ifsc?: string;
|
|
93
|
-
openingBalance?: string;
|
|
94
|
-
default?: boolean;
|
|
95
|
-
yes?: boolean;
|
|
96
|
-
}): Promise<void> {
|
|
97
|
-
const cfg = requireAuth();
|
|
98
|
-
const client = new HisaaboClient(cfg);
|
|
99
|
-
const isNonInteractive = !process.stdin.isTTY || opts.yes;
|
|
100
|
-
|
|
101
|
-
let name = opts.name;
|
|
102
|
-
let accountType = (opts.type ?? "current") as "savings" | "current" | "cash" | "credit" | "other";
|
|
103
|
-
let bankName = opts.bank;
|
|
104
|
-
let accountNumber = opts.accountNumber;
|
|
105
|
-
let ifsc = opts.ifsc;
|
|
106
|
-
let openingBalance = opts.openingBalance;
|
|
107
|
-
|
|
108
|
-
if (!isNonInteractive) {
|
|
109
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
110
|
-
if (!name) name = (await prompt(rl, " Account Name: ")).trim();
|
|
111
|
-
const typeStr = await prompt(rl, " Type (savings/current/cash/credit/other) [current]: ");
|
|
112
|
-
accountType = (typeStr.trim() || "current") as typeof accountType;
|
|
113
|
-
const bankStr = await prompt(rl, " Bank Name: ");
|
|
114
|
-
if (bankStr.trim()) bankName = bankStr.trim();
|
|
115
|
-
const numStr = await prompt(rl, " Account Number: ");
|
|
116
|
-
if (numStr.trim()) accountNumber = numStr.trim();
|
|
117
|
-
const ifscStr = await prompt(rl, " IFSC: ");
|
|
118
|
-
if (ifscStr.trim()) ifsc = ifscStr.trim();
|
|
119
|
-
const balStr = await prompt(rl, " Opening Balance [0]: ");
|
|
120
|
-
openingBalance = balStr.trim() || "0";
|
|
121
|
-
rl.close();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (!name) fatalError("--name is required", EXIT.USAGE);
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
const account = await client.bankAccount.create({
|
|
128
|
-
accountName: name,
|
|
129
|
-
accountType,
|
|
130
|
-
bankName,
|
|
131
|
-
accountNumber,
|
|
132
|
-
ifsc,
|
|
133
|
-
openingBalance,
|
|
134
|
-
isDefault: opts.default,
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
if (opts.json) {
|
|
138
|
-
outputJSON(account);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
success(`Created: ${account.accountName}`);
|
|
143
|
-
console.log(` ID: ${account.id}\n`);
|
|
144
|
-
|
|
145
|
-
} catch (e) {
|
|
146
|
-
if (e instanceof HisaaboApiError) {
|
|
147
|
-
const err = e.hisaaboError;
|
|
148
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
149
|
-
if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
|
|
150
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
151
|
-
}
|
|
152
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export async function bankTransferCommand(opts: {
|
|
157
|
-
json?: boolean;
|
|
158
|
-
from?: string;
|
|
159
|
-
to?: string;
|
|
160
|
-
amount?: string;
|
|
161
|
-
description?: string;
|
|
162
|
-
date?: string;
|
|
163
|
-
}): Promise<void> {
|
|
164
|
-
const cfg = requireAuth();
|
|
165
|
-
const client = new HisaaboClient(cfg);
|
|
166
|
-
|
|
167
|
-
if (!opts.from) fatalError("--from account ID is required", EXIT.USAGE);
|
|
168
|
-
if (!opts.to) fatalError("--to account ID is required", EXIT.USAGE);
|
|
169
|
-
if (!opts.amount) fatalError("--amount is required", EXIT.USAGE);
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
const result = await client.bankAccount.transfer({
|
|
173
|
-
fromAccountId: opts.from,
|
|
174
|
-
toAccountId: opts.to,
|
|
175
|
-
amount: opts.amount,
|
|
176
|
-
description: opts.description,
|
|
177
|
-
transactionDate: opts.date,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
if (opts.json) {
|
|
181
|
-
outputJSON(result);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
success(`Transfer recorded: ${formatINR(opts.amount)}`);
|
|
186
|
-
|
|
187
|
-
} catch (e) {
|
|
188
|
-
if (e instanceof HisaaboApiError) {
|
|
189
|
-
const err = e.hisaaboError;
|
|
190
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
191
|
-
if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
|
|
192
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
193
|
-
}
|
|
194
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export async function bankTransactionsCommand(accountId: string, opts: {
|
|
199
|
-
json?: boolean;
|
|
200
|
-
from?: string;
|
|
201
|
-
to?: string;
|
|
202
|
-
page?: number;
|
|
203
|
-
limit?: number;
|
|
204
|
-
}): Promise<void> {
|
|
205
|
-
const cfg = requireAuth();
|
|
206
|
-
const client = new HisaaboClient(cfg);
|
|
207
|
-
const page = opts.page ?? 1;
|
|
208
|
-
const limit = opts.limit ?? 20;
|
|
209
|
-
|
|
210
|
-
try {
|
|
211
|
-
const result = await client.bankAccount.listTransactions({
|
|
212
|
-
bankAccountId: accountId,
|
|
213
|
-
fromDate: opts.from,
|
|
214
|
-
toDate: opts.to,
|
|
215
|
-
page,
|
|
216
|
-
limit,
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
if (opts.json) {
|
|
220
|
-
outputJSON(result);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const cols: ColumnDef<BankTransactionRow>[] = [
|
|
225
|
-
{ key: "transactionDate", header: "Date", width: 13, format: (v) => formatDate(String(v ?? "")) },
|
|
226
|
-
{ key: "type", header: "Type", width: 12 },
|
|
227
|
-
{ key: "description", header: "Description", width: 25, format: (v) => String(v ?? "-") },
|
|
228
|
-
{ key: "amount", header: "Amount (₹)", align: "right", width: 13, format: (v) => formatAmount(String(v ?? "0")) },
|
|
229
|
-
{ key: "balanceAfter", header: "Balance (₹)", align: "right", width: 13, format: (v) => formatAmount(String(v ?? "0")) },
|
|
230
|
-
];
|
|
231
|
-
|
|
232
|
-
console.log(`\n Transactions for ${accountId}\n`);
|
|
233
|
-
outputTable(result.data, cols);
|
|
234
|
-
paginationFooter(result.page, result.limit, result.total);
|
|
235
|
-
|
|
236
|
-
} catch (e) {
|
|
237
|
-
if (e instanceof HisaaboApiError) {
|
|
238
|
-
const err = e.hisaaboError;
|
|
239
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
240
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
241
|
-
}
|
|
242
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
243
|
-
}
|
|
244
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { HisaaboClient, HisaaboApiError, type GatewayChargeConfig } from "../../client.js";
|
|
2
|
-
import { requireAuth } from "../../config.js";
|
|
3
|
-
import { fatalError, outputJSON, EXIT, success } from "../../output.js";
|
|
4
|
-
|
|
5
|
-
export interface UpdateGatewayOpts {
|
|
6
|
-
json?: boolean;
|
|
7
|
-
chargeCreditCard?: string;
|
|
8
|
-
chargeDebitCard?: string;
|
|
9
|
-
chargeUpi?: string;
|
|
10
|
-
chargeNetBanking?: string;
|
|
11
|
-
chargeWallet?: string;
|
|
12
|
-
chargeDefault?: string;
|
|
13
|
-
settlementAccount?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function parseChargeRate(value: string): { type: "percentage" | "flat"; value: string } {
|
|
17
|
-
// If value starts with "flat:" treat as flat amount, otherwise percentage
|
|
18
|
-
if (value.toLowerCase().startsWith("flat:")) {
|
|
19
|
-
return { type: "flat", value: value.slice(5) };
|
|
20
|
-
}
|
|
21
|
-
return { type: "percentage", value };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function bankUpdateGatewayCommand(
|
|
25
|
-
accountId: string,
|
|
26
|
-
opts: UpdateGatewayOpts,
|
|
27
|
-
): Promise<void> {
|
|
28
|
-
const cfg = requireAuth();
|
|
29
|
-
const client = new HisaaboClient(cfg);
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
// Fetch existing config to merge with updates
|
|
33
|
-
const existing = await client.bankAccount.getGatewayConfig(accountId);
|
|
34
|
-
|
|
35
|
-
const chargeConfig: GatewayChargeConfig = existing?.chargeConfig ?? {};
|
|
36
|
-
|
|
37
|
-
if (opts.chargeCreditCard !== undefined) {
|
|
38
|
-
chargeConfig.credit_card = parseChargeRate(opts.chargeCreditCard);
|
|
39
|
-
}
|
|
40
|
-
if (opts.chargeDebitCard !== undefined) {
|
|
41
|
-
chargeConfig.debit_card = parseChargeRate(opts.chargeDebitCard);
|
|
42
|
-
}
|
|
43
|
-
if (opts.chargeUpi !== undefined) {
|
|
44
|
-
chargeConfig.upi = parseChargeRate(opts.chargeUpi);
|
|
45
|
-
}
|
|
46
|
-
if (opts.chargeNetBanking !== undefined) {
|
|
47
|
-
chargeConfig.net_banking = parseChargeRate(opts.chargeNetBanking);
|
|
48
|
-
}
|
|
49
|
-
if (opts.chargeWallet !== undefined) {
|
|
50
|
-
chargeConfig.wallet = parseChargeRate(opts.chargeWallet);
|
|
51
|
-
}
|
|
52
|
-
if (opts.chargeDefault !== undefined) {
|
|
53
|
-
chargeConfig.default = parseChargeRate(opts.chargeDefault);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const settlementAccountId = opts.settlementAccount ?? existing?.settlementAccountId;
|
|
57
|
-
if (!settlementAccountId) {
|
|
58
|
-
fatalError("--settlement-account is required when creating a new gateway config", EXIT.USAGE);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const result = await client.bankAccount.upsertGatewayConfig({
|
|
62
|
-
bankAccountId: accountId,
|
|
63
|
-
settlementAccountId,
|
|
64
|
-
chargeConfig,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if (opts.json) {
|
|
68
|
-
outputJSON(result);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
success(`Gateway configuration updated for account: ${accountId}`);
|
|
73
|
-
console.log(` Settlement Account: ${result.settlementAccountId}\n`);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
if (e instanceof HisaaboApiError) {
|
|
76
|
-
const err = e.hisaaboError;
|
|
77
|
-
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
78
|
-
if (err.code === "validation_failed") fatalError(e.message, EXIT.VALIDATION);
|
|
79
|
-
if (err.code === "not_found") fatalError(`Bank account not found: ${accountId}`, EXIT.NOT_FOUND);
|
|
80
|
-
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
81
|
-
}
|
|
82
|
-
fatalError(String(e instanceof Error ? e.message : e));
|
|
83
|
-
}
|
|
84
|
-
}
|