@hisaabo/cli 0.9.0 → 0.10.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/README.md +154 -4
- package/dist/bin/{audit-trail-IJ6SKACR.js → audit-trail-RTPTWZAL.js} +12 -15
- package/dist/bin/{categories-O6TODPAH.js → categories-JJDTOT5T.js} +3 -3
- package/dist/bin/{check-slug-P7RFU6OP.js → check-slug-5L2VDAEN.js} +16 -4
- package/dist/bin/chunk-2DDIXPNI.js +1512 -0
- package/dist/bin/chunk-ALOHN6GR.js +78 -0
- package/dist/bin/{chunk-QUITS2FE.js → chunk-ESX7V56A.js} +95 -20
- package/dist/bin/chunk-M7DVLVD5.js +245 -0
- package/dist/bin/{chunk-WDN7RIE3.js → chunk-VXEEFNIY.js} +133 -47
- package/dist/bin/client-NFYNYEDI.js +17 -0
- package/dist/bin/{collection-efficiency-DA5RWG3V.js → collection-efficiency-UF3AJPQB.js} +12 -56
- package/dist/bin/{config-4LLNT4SH.js → config-7HVBRHL3.js} +2 -2
- package/dist/bin/{create-C5INBPQO.js → create-2BZQLXQA.js} +18 -9
- package/dist/bin/{default-account-2GMQ7ZA4.js → default-account-MR6O5LPT.js} +7 -13
- package/dist/bin/{expenses-S2YVA5UT.js → expenses-CU6JGDVX.js} +12 -11
- package/dist/bin/{export-YOOODNVX.js → export-GFYQIQLT.js} +9 -24
- package/dist/bin/{export-6PMJ2YVL.js → export-WS24LYNH.js} +47 -11
- package/dist/bin/{factory-6MUCSXTL.js → factory-JSEQCPY3.js} +51 -57
- package/dist/bin/{get-GMQRROK2.js → get-HGMB7T6Y.js} +5 -4
- package/dist/bin/{get-ZV3SC2VY.js → get-KAOGGRJR.js} +4 -4
- package/dist/bin/hisaabo.js +2024 -837
- package/dist/bin/{import-UUHMLCKX.js → import-6CEMNCTM.js} +30 -33
- package/dist/bin/{invitations-OVORTTMF.js → invitations-LASABD2X.js} +11 -14
- package/dist/bin/{invite-GGHBZY4U.js → invite-VCBXS7VY.js} +13 -15
- package/dist/bin/{invoice-breakdown-32XXAZDP.js → invoice-breakdown-3XXSYA77.js} +12 -37
- package/dist/bin/{items-6NOIMH6B.js → items-PJPN6ZX3.js} +11 -10
- package/dist/bin/{items-toggle-L6W6QKQD.js → items-toggle-53C35MJU.js} +6 -5
- package/dist/bin/{list-RAR56EMQ.js → list-63EKE6DT.js} +13 -16
- package/dist/bin/{list-OXAVDXH7.js → list-7OSZX6C7.js} +5 -5
- package/dist/bin/{list-FC5JHKHD.js → list-OOROCQR2.js} +11 -12
- package/dist/bin/{members-Y6XJVHHR.js → members-SPHU5F4M.js} +7 -7
- package/dist/bin/monthly-comparison-3FFJT63K.js +79 -0
- package/dist/bin/{order-cancel-QRTCNART.js → order-cancel-RW4NYHKN.js} +8 -18
- package/dist/bin/{order-confirm-LGQOMC4O.js → order-confirm-NXFL2EIQ.js} +7 -15
- package/dist/bin/{order-get-4XAQCRYV.js → order-get-QPSOY2RT.js} +11 -11
- package/dist/bin/{order-update-KZY4H2UR.js → order-update-7DWKEROO.js} +4 -4
- package/dist/bin/{output-NUOL7KJW.js → output-XFDIL3A6.js} +5 -1
- package/dist/bin/{payment-modes-DY2ZEMK7.js → payment-modes-Z5WV3E3O.js} +12 -27
- package/dist/bin/{profit-loss-5GJBG3PL.js → profit-loss-AOISAJ56.js} +14 -13
- package/dist/bin/{receivables-aging-6A7XJKDT.js → receivables-aging-5JHFECGB.js} +13 -66
- package/dist/bin/{remove-ZBX34TIQ.js → remove-TC4UWMOL.js} +7 -15
- package/dist/bin/{revoke-ZTAMW2Q2.js → revoke-QHLNPGI5.js} +7 -3
- package/dist/bin/{revoke-XDNOA2GJ.js → revoke-SXVNALYQ.js} +7 -15
- package/dist/bin/{revoke-all-365NRBOA.js → revoke-all-CYW6A5UE.js} +8 -4
- package/dist/bin/{revoke-invitation-PQH7XNYA.js → revoke-invitation-Z33EUJTS.js} +7 -3
- package/dist/bin/safety-TPD2P7I5.js +18 -0
- package/dist/bin/{sales-trend-D6PQ7MHY.js → sales-trend-WCW6X5BI.js} +16 -16
- package/dist/bin/sequence-HOQ4PQRK.js +56 -0
- package/dist/bin/{store-SVRZBUFO.js → store-DDMHTNTO.js} +15 -8
- package/dist/bin/{summary-H6U7O5GJ.js → summary-TYAL2D3Q.js} +7 -5
- package/dist/bin/{top-customers-ATBN6RDI.js → top-customers-GMIS6GC3.js} +13 -11
- package/dist/bin/{top-items-XXU6KYTC.js → top-items-BK54JO3G.js} +16 -14
- package/dist/bin/{top-outstanding-JTQNGGW4.js → top-outstanding-L4NRJ6NE.js} +9 -11
- package/dist/bin/{unpaid-invoices-BTNQFWCH.js → unpaid-invoices-CEUFEYH7.js} +8 -8
- package/dist/bin/{untracked-PAMEDJ6Y.js → untracked-T6DIDMDQ.js} +9 -9
- package/dist/bin/{update-EK4NJWU4.js → update-EPNB2U74.js} +4 -4
- package/dist/bin/{update-EGHPFXLK.js → update-I2DZRVLR.js} +10 -17
- package/dist/bin/{update-6ZMX2OYX.js → update-MFNOVS6D.js} +4 -4
- package/dist/bin/{update-role-24PDTNFK.js → update-role-D2ETEL2Q.js} +7 -4
- package/dist/bin/{update-settings-AASI6WZX.js → update-settings-UGXLQRYI.js} +15 -9
- package/package.json +8 -7
- package/dist/bin/chunk-NO4FIFMS.js +0 -176
- package/dist/bin/chunk-ZPYC767N.js +0 -157
- package/dist/bin/client-36JX5MR3.js +0 -11
- package/dist/bin/monthly-comparison-IAUZ6SBJ.js +0 -176
- package/dist/bin/sequence-KZWADVD7.js +0 -66
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
confirmOrExit
|
|
4
|
+
} from "./chunk-ALOHN6GR.js";
|
|
2
5
|
import {
|
|
3
6
|
HisaaboApiError,
|
|
4
7
|
HisaaboClient
|
|
5
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VXEEFNIY.js";
|
|
6
9
|
import {
|
|
7
10
|
requireAuth
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ESX7V56A.js";
|
|
9
12
|
import {
|
|
10
13
|
EXIT,
|
|
11
14
|
fatalError,
|
|
12
15
|
success
|
|
13
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-2DDIXPNI.js";
|
|
14
17
|
|
|
15
18
|
// src/commands/session/revoke-all.ts
|
|
16
|
-
async function revokeAllSessionsCommand() {
|
|
19
|
+
async function revokeAllSessionsCommand(opts = {}) {
|
|
17
20
|
const cfg = requireAuth();
|
|
18
21
|
const client = new HisaaboClient(cfg);
|
|
22
|
+
await confirmOrExit("Sign out from all devices?", opts);
|
|
19
23
|
try {
|
|
20
24
|
await client.auth.logoutAll();
|
|
21
25
|
success("Signed out from all devices.");
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
confirmOrExit
|
|
4
|
+
} from "./chunk-ALOHN6GR.js";
|
|
2
5
|
import {
|
|
3
6
|
HisaaboApiError,
|
|
4
7
|
HisaaboClient
|
|
5
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VXEEFNIY.js";
|
|
6
9
|
import {
|
|
7
10
|
requireAuth
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ESX7V56A.js";
|
|
9
12
|
import {
|
|
10
13
|
EXIT,
|
|
11
14
|
fatalError,
|
|
12
15
|
outputJSON,
|
|
13
16
|
success
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-2DDIXPNI.js";
|
|
15
18
|
|
|
16
19
|
// src/commands/tenant/revoke-invitation.ts
|
|
17
20
|
async function revokeInvitationCommand(invitationId, opts) {
|
|
18
21
|
const cfg = requireAuth();
|
|
19
22
|
const client = new HisaaboClient(cfg);
|
|
23
|
+
await confirmOrExit(`Revoke invitation ${invitationId}?`, opts);
|
|
20
24
|
try {
|
|
21
25
|
const result = await client.tenant.revokeInvitation({ invitationId });
|
|
22
26
|
if (opts.json) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
MAX_DOWNLOAD_BYTES,
|
|
4
|
+
confirmOrExit,
|
|
5
|
+
isUuid,
|
|
6
|
+
requireUuid,
|
|
7
|
+
safeFilename,
|
|
8
|
+
writeFileSafe
|
|
9
|
+
} from "./chunk-ALOHN6GR.js";
|
|
10
|
+
import "./chunk-2DDIXPNI.js";
|
|
11
|
+
export {
|
|
12
|
+
MAX_DOWNLOAD_BYTES,
|
|
13
|
+
confirmOrExit,
|
|
14
|
+
isUuid,
|
|
15
|
+
requireUuid,
|
|
16
|
+
safeFilename,
|
|
17
|
+
writeFileSafe
|
|
18
|
+
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
apiFrom,
|
|
4
|
+
apiTo,
|
|
3
5
|
formatAmount
|
|
4
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-M7DVLVD5.js";
|
|
5
7
|
import {
|
|
6
8
|
HisaaboApiError,
|
|
7
9
|
HisaaboClient
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-VXEEFNIY.js";
|
|
9
11
|
import {
|
|
10
12
|
requireAuth
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ESX7V56A.js";
|
|
12
14
|
import {
|
|
13
15
|
EXIT,
|
|
14
16
|
fatalError,
|
|
@@ -17,7 +19,7 @@ import {
|
|
|
17
19
|
outputJSON,
|
|
18
20
|
outputTSV,
|
|
19
21
|
outputTable
|
|
20
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-2DDIXPNI.js";
|
|
21
23
|
|
|
22
24
|
// src/commands/dashboard/sales-trend.ts
|
|
23
25
|
import chalk from "chalk";
|
|
@@ -25,27 +27,25 @@ async function dashboardSalesTrendCommand(opts) {
|
|
|
25
27
|
const cfg = requireAuth();
|
|
26
28
|
const client = new HisaaboClient(cfg);
|
|
27
29
|
const input = {};
|
|
28
|
-
if (opts.months) input
|
|
29
|
-
if (opts.from) input
|
|
30
|
-
if (opts.to) input
|
|
31
|
-
if (opts.granularity
|
|
30
|
+
if (opts.months) input.months = opts.months;
|
|
31
|
+
if (opts.from) input.fromDate = apiFrom(opts.from);
|
|
32
|
+
if (opts.to) input.toDate = apiTo(opts.to);
|
|
33
|
+
if (opts.granularity === "week" || opts.granularity === "month" || opts.granularity === "fy") input.granularity = opts.granularity;
|
|
32
34
|
try {
|
|
33
35
|
const data = await client.dashboard.salesTrend(input);
|
|
34
36
|
if (opts.json) {
|
|
35
37
|
outputJSON(data);
|
|
36
38
|
return;
|
|
37
39
|
}
|
|
38
|
-
const rows =
|
|
39
|
-
period:
|
|
40
|
-
sales: formatAmount(
|
|
41
|
-
collections: formatAmount(
|
|
42
|
-
|
|
43
|
-
})) : [];
|
|
40
|
+
const rows = data.map((r) => ({
|
|
41
|
+
period: r.period,
|
|
42
|
+
sales: formatAmount(r.invoiced),
|
|
43
|
+
collections: formatAmount(r.collected)
|
|
44
|
+
}));
|
|
44
45
|
const columns = [
|
|
45
46
|
{ key: "period", header: "Period", align: "left" },
|
|
46
47
|
{ key: "sales", header: "Sales \u20B9", align: "right" },
|
|
47
|
-
{ key: "collections", header: "Collection \u20B9", align: "right" }
|
|
48
|
-
{ key: "invoices", header: "Invoices", align: "right" }
|
|
48
|
+
{ key: "collections", header: "Collection \u20B9", align: "right" }
|
|
49
49
|
];
|
|
50
50
|
if (opts.format === "tsv") {
|
|
51
51
|
outputTSV(rows, columns);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
HisaaboApiError,
|
|
4
|
+
HisaaboClient
|
|
5
|
+
} from "./chunk-VXEEFNIY.js";
|
|
6
|
+
import {
|
|
7
|
+
requireAuth
|
|
8
|
+
} from "./chunk-ESX7V56A.js";
|
|
9
|
+
import {
|
|
10
|
+
EXIT,
|
|
11
|
+
fatalError,
|
|
12
|
+
outputJSON,
|
|
13
|
+
success
|
|
14
|
+
} from "./chunk-2DDIXPNI.js";
|
|
15
|
+
|
|
16
|
+
// src/commands/business/sequence.ts
|
|
17
|
+
var DOCUMENT_TYPES = ["invoice", "payment", "quotation", "credit_note", "delivery_challan", "proforma"];
|
|
18
|
+
function isDocumentType(v) {
|
|
19
|
+
return v !== void 0 && DOCUMENT_TYPES.includes(v);
|
|
20
|
+
}
|
|
21
|
+
async function businessSequenceCommand(opts) {
|
|
22
|
+
const cfg = requireAuth();
|
|
23
|
+
const client = new HisaaboClient(cfg);
|
|
24
|
+
const documentType = opts.type === "sale" ? "invoice" : opts.type;
|
|
25
|
+
if (!isDocumentType(documentType)) {
|
|
26
|
+
fatalError(`--type must be one of: ${DOCUMENT_TYPES.join(", ")}.`, EXIT.USAGE);
|
|
27
|
+
}
|
|
28
|
+
if (opts.nextNumber === void 0 || !/^\d+$/.test(opts.nextNumber) || parseInt(opts.nextNumber, 10) < 1) {
|
|
29
|
+
fatalError("--next-number must be a positive integer.", EXIT.USAGE);
|
|
30
|
+
}
|
|
31
|
+
const newNumber = parseInt(opts.nextNumber, 10);
|
|
32
|
+
try {
|
|
33
|
+
const result = await client.business.updateSequenceNumber({ documentType, newNumber });
|
|
34
|
+
if (opts.json) {
|
|
35
|
+
outputJSON(result);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
success(`${documentType} sequence updated: next number \u2192 ${newNumber}.`);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
if (e instanceof HisaaboApiError) {
|
|
41
|
+
const err = e.hisaaboError;
|
|
42
|
+
if (err.code === "unauthorized") fatalError("Session expired. Run: hisaabo login", EXIT.AUTH);
|
|
43
|
+
if (err.code === "forbidden") fatalError(err.message, EXIT.FORBIDDEN);
|
|
44
|
+
if (err.code === "validation_failed") {
|
|
45
|
+
const msgs = Object.entries(err.fields).map(([f, ms]) => ` ${f}: ${ms.join(", ")}`).join("\n");
|
|
46
|
+
fatalError(`Validation failed:
|
|
47
|
+
${msgs}`, EXIT.VALIDATION);
|
|
48
|
+
}
|
|
49
|
+
if (err.code === "network_error") fatalError(err.message, EXIT.NETWORK);
|
|
50
|
+
}
|
|
51
|
+
fatalError(String(e instanceof Error ? e.message : e));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
businessSequenceCommand
|
|
56
|
+
};
|
|
@@ -3,23 +3,24 @@ import {
|
|
|
3
3
|
formatAmount,
|
|
4
4
|
formatDate,
|
|
5
5
|
formatStatus
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-M7DVLVD5.js";
|
|
7
7
|
import {
|
|
8
8
|
HisaaboApiError,
|
|
9
9
|
HisaaboClient
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-VXEEFNIY.js";
|
|
11
11
|
import {
|
|
12
12
|
requireAuth
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ESX7V56A.js";
|
|
14
14
|
import {
|
|
15
15
|
EXIT,
|
|
16
16
|
fatalError,
|
|
17
17
|
outputJSON,
|
|
18
18
|
outputTable,
|
|
19
19
|
paginationFooter
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-2DDIXPNI.js";
|
|
21
21
|
|
|
22
22
|
// src/commands/store/index.ts
|
|
23
|
+
var ORDER_STATUSES = ["pending", "confirmed", "preparing", "ready", "delivered", "cancelled"];
|
|
23
24
|
async function storeSettingsCommand(opts) {
|
|
24
25
|
const cfg = requireAuth();
|
|
25
26
|
const client = new HisaaboClient(cfg);
|
|
@@ -32,8 +33,7 @@ async function storeSettingsCommand(opts) {
|
|
|
32
33
|
console.log("\n Store Settings\n " + "\u2500".repeat(35));
|
|
33
34
|
console.log(` Enabled: ${settings.storeEnabled ? "Yes" : "No"}`);
|
|
34
35
|
if (settings.storeSlug) console.log(` Slug: ${settings.storeSlug}`);
|
|
35
|
-
if (settings.
|
|
36
|
-
if (settings.storeDescription) console.log(` About: ${settings.storeDescription}`);
|
|
36
|
+
if (settings.storeTagline) console.log(` Tagline: ${settings.storeTagline}`);
|
|
37
37
|
console.log();
|
|
38
38
|
} catch (e) {
|
|
39
39
|
if (e instanceof HisaaboApiError) {
|
|
@@ -50,7 +50,14 @@ async function storeOrdersCommand(opts) {
|
|
|
50
50
|
const page = opts.page ?? 1;
|
|
51
51
|
const limit = opts.limit ?? 20;
|
|
52
52
|
try {
|
|
53
|
-
|
|
53
|
+
if (opts.status !== void 0 && !ORDER_STATUSES.includes(opts.status)) {
|
|
54
|
+
fatalError(`--status must be one of: ${ORDER_STATUSES.join(", ")}`, EXIT.USAGE);
|
|
55
|
+
}
|
|
56
|
+
const result = await client.store.listOrders({
|
|
57
|
+
status: opts.status,
|
|
58
|
+
page,
|
|
59
|
+
limit
|
|
60
|
+
});
|
|
54
61
|
if (opts.json) {
|
|
55
62
|
outputJSON({ data: result.data, pagination: { page: result.page, limit: result.limit, total: result.total } });
|
|
56
63
|
return;
|
|
@@ -61,7 +68,7 @@ async function storeOrdersCommand(opts) {
|
|
|
61
68
|
const cols = [
|
|
62
69
|
{ key: "orderNumber", header: "#", width: 12 },
|
|
63
70
|
{ key: "customerName", header: "Customer", width: 20 },
|
|
64
|
-
{ key: "createdAt", header: "Date", width: 13, format: (v) => formatDate(
|
|
71
|
+
{ key: "createdAt", header: "Date", width: 13, format: (v) => formatDate(v) },
|
|
65
72
|
{ key: "totalAmount", header: "Amount (\u20B9)", align: "right", width: 13, format: (v) => formatAmount(String(v ?? "0")) },
|
|
66
73
|
{ key: "status", header: "Status", width: 10, format: (v) => formatStatus(String(v ?? "")) }
|
|
67
74
|
];
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
apiFrom,
|
|
4
|
+
apiTo,
|
|
3
5
|
currentFY,
|
|
4
6
|
formatAmount,
|
|
5
7
|
formatRelativeDate,
|
|
6
8
|
formatStatus,
|
|
7
9
|
fyStart,
|
|
8
10
|
todayISO
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-M7DVLVD5.js";
|
|
10
12
|
import {
|
|
11
13
|
HisaaboApiError,
|
|
12
14
|
HisaaboClient
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VXEEFNIY.js";
|
|
14
16
|
import {
|
|
15
17
|
requireAuth
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-ESX7V56A.js";
|
|
17
19
|
import {
|
|
18
20
|
EXIT,
|
|
19
21
|
fatalError,
|
|
20
22
|
hasColor,
|
|
21
23
|
outputJSON,
|
|
22
24
|
termWidth
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-2DDIXPNI.js";
|
|
24
26
|
|
|
25
27
|
// src/commands/dashboard/summary.ts
|
|
26
28
|
import chalk from "chalk";
|
|
@@ -49,7 +51,7 @@ async function dashboardCommand(opts) {
|
|
|
49
51
|
const from = fyStart();
|
|
50
52
|
const to = todayISO();
|
|
51
53
|
try {
|
|
52
|
-
const summary = await client.dashboard.summary({ fromDate: from, toDate: to });
|
|
54
|
+
const summary = await client.dashboard.summary({ fromDate: apiFrom(from), toDate: apiTo(to) });
|
|
53
55
|
if (opts.json) {
|
|
54
56
|
outputJSON(summary);
|
|
55
57
|
return;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
apiFrom,
|
|
4
|
+
apiTo,
|
|
3
5
|
formatAmount,
|
|
4
6
|
fyStart,
|
|
5
7
|
monthEnd,
|
|
6
8
|
monthStart,
|
|
7
9
|
todayISO
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-M7DVLVD5.js";
|
|
9
11
|
import {
|
|
10
12
|
HisaaboApiError,
|
|
11
13
|
HisaaboClient
|
|
12
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VXEEFNIY.js";
|
|
13
15
|
import {
|
|
14
16
|
requireAuth
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ESX7V56A.js";
|
|
16
18
|
import {
|
|
17
19
|
EXIT,
|
|
18
20
|
fatalError,
|
|
@@ -21,7 +23,7 @@ import {
|
|
|
21
23
|
outputJSON,
|
|
22
24
|
outputTSV,
|
|
23
25
|
outputTable
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-2DDIXPNI.js";
|
|
25
27
|
|
|
26
28
|
// src/commands/dashboard/top-customers.ts
|
|
27
29
|
import chalk from "chalk";
|
|
@@ -40,18 +42,18 @@ async function dashboardTopCustomersCommand(opts) {
|
|
|
40
42
|
try {
|
|
41
43
|
const data = await client.dashboard.topCustomers({
|
|
42
44
|
limit: opts.limit,
|
|
43
|
-
fromDate,
|
|
44
|
-
toDate
|
|
45
|
+
fromDate: apiFrom(fromDate),
|
|
46
|
+
toDate: apiTo(toDate)
|
|
45
47
|
});
|
|
46
48
|
if (opts.json) {
|
|
47
49
|
outputJSON(data);
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
|
-
const rows =
|
|
51
|
-
party:
|
|
52
|
-
revenue: formatAmount(
|
|
53
|
-
invoices: String(r
|
|
54
|
-
}))
|
|
52
|
+
const rows = data.map((r) => ({
|
|
53
|
+
party: r.partyName,
|
|
54
|
+
revenue: formatAmount(r.totalAmount),
|
|
55
|
+
invoices: String(r.invoiceCount)
|
|
56
|
+
}));
|
|
55
57
|
const columns = [
|
|
56
58
|
{ key: "party", header: "Customer", align: "left" },
|
|
57
59
|
{ key: "revenue", header: "Revenue \u20B9", align: "right" },
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
apiFrom,
|
|
4
|
+
apiTo,
|
|
3
5
|
formatAmount,
|
|
4
6
|
fyStart,
|
|
5
7
|
monthEnd,
|
|
6
8
|
monthStart,
|
|
7
9
|
todayISO
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-M7DVLVD5.js";
|
|
9
11
|
import {
|
|
10
12
|
HisaaboApiError,
|
|
11
13
|
HisaaboClient
|
|
12
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VXEEFNIY.js";
|
|
13
15
|
import {
|
|
14
16
|
requireAuth
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ESX7V56A.js";
|
|
16
18
|
import {
|
|
17
19
|
EXIT,
|
|
18
20
|
fatalError,
|
|
@@ -21,7 +23,7 @@ import {
|
|
|
21
23
|
outputJSON,
|
|
22
24
|
outputTSV,
|
|
23
25
|
outputTable
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-2DDIXPNI.js";
|
|
25
27
|
|
|
26
28
|
// src/commands/dashboard/top-items.ts
|
|
27
29
|
import chalk from "chalk";
|
|
@@ -40,23 +42,23 @@ async function dashboardTopItemsCommand(opts) {
|
|
|
40
42
|
try {
|
|
41
43
|
const data = await client.dashboard.topSellingItems({
|
|
42
44
|
limit: opts.limit,
|
|
43
|
-
itemType: opts.type,
|
|
44
|
-
fromDate,
|
|
45
|
-
toDate
|
|
45
|
+
itemType: opts.type === "product" || opts.type === "service" ? opts.type : void 0,
|
|
46
|
+
fromDate: apiFrom(fromDate),
|
|
47
|
+
toDate: apiTo(toDate)
|
|
46
48
|
});
|
|
47
49
|
if (opts.json) {
|
|
48
50
|
outputJSON(data);
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
51
|
-
const rows =
|
|
52
|
-
item:
|
|
53
|
-
qty:
|
|
54
|
-
revenue: formatAmount(
|
|
55
|
-
type:
|
|
56
|
-
}))
|
|
53
|
+
const rows = data.map((r) => ({
|
|
54
|
+
item: r.itemName,
|
|
55
|
+
qty: r.totalQty,
|
|
56
|
+
revenue: formatAmount(r.totalAmount),
|
|
57
|
+
type: r.unit ?? "-"
|
|
58
|
+
}));
|
|
57
59
|
const columns = [
|
|
58
60
|
{ key: "item", header: "Item", align: "left" },
|
|
59
|
-
{ key: "type", header: "
|
|
61
|
+
{ key: "type", header: "Unit", align: "left" },
|
|
60
62
|
{ key: "qty", header: "Qty Sold", align: "right" },
|
|
61
63
|
{ key: "revenue", header: "Revenue \u20B9", align: "right" }
|
|
62
64
|
];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
formatAmount
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-M7DVLVD5.js";
|
|
5
5
|
import {
|
|
6
6
|
HisaaboApiError,
|
|
7
7
|
HisaaboClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VXEEFNIY.js";
|
|
9
9
|
import {
|
|
10
10
|
requireAuth
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ESX7V56A.js";
|
|
12
12
|
import {
|
|
13
13
|
EXIT,
|
|
14
14
|
fatalError,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
outputJSON,
|
|
18
18
|
outputTSV,
|
|
19
19
|
outputTable
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-2DDIXPNI.js";
|
|
21
21
|
|
|
22
22
|
// src/commands/dashboard/top-outstanding.ts
|
|
23
23
|
import chalk from "chalk";
|
|
@@ -30,15 +30,13 @@ async function dashboardTopOutstandingCommand(opts) {
|
|
|
30
30
|
outputJSON(data);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
const rows =
|
|
34
|
-
party:
|
|
35
|
-
outstanding: formatAmount(
|
|
36
|
-
|
|
37
|
-
})) : [];
|
|
33
|
+
const rows = data.map((r) => ({
|
|
34
|
+
party: r.partyName,
|
|
35
|
+
outstanding: formatAmount(r.outstanding)
|
|
36
|
+
}));
|
|
38
37
|
const columns = [
|
|
39
38
|
{ key: "party", header: "Party", align: "left" },
|
|
40
|
-
{ key: "outstanding", header: "Outstanding \u20B9", align: "right" }
|
|
41
|
-
{ key: "oldestAge", header: "Oldest Invoice", align: "right" }
|
|
39
|
+
{ key: "outstanding", header: "Outstanding \u20B9", align: "right" }
|
|
42
40
|
];
|
|
43
41
|
if (opts.format === "tsv") {
|
|
44
42
|
outputTSV(rows, columns);
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
formatAmount,
|
|
4
4
|
formatDate
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-M7DVLVD5.js";
|
|
6
6
|
import {
|
|
7
7
|
HisaaboApiError,
|
|
8
8
|
HisaaboClient
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VXEEFNIY.js";
|
|
10
10
|
import {
|
|
11
11
|
requireAuth
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ESX7V56A.js";
|
|
13
13
|
import {
|
|
14
14
|
EXIT,
|
|
15
15
|
fatalError,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
outputJSON,
|
|
18
18
|
outputTSV,
|
|
19
19
|
outputTable
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-2DDIXPNI.js";
|
|
21
21
|
|
|
22
22
|
// src/commands/payment/unpaid-invoices.ts
|
|
23
23
|
async function paymentUnpaidInvoicesCommand(partyId, opts) {
|
|
@@ -29,7 +29,7 @@ async function paymentUnpaidInvoicesCommand(partyId, opts) {
|
|
|
29
29
|
outputJSON(result);
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const invoices =
|
|
32
|
+
const invoices = result;
|
|
33
33
|
if (invoices.length === 0) {
|
|
34
34
|
console.log("\n No unpaid invoices for this party.\n");
|
|
35
35
|
return;
|
|
@@ -39,10 +39,10 @@ async function paymentUnpaidInvoicesCommand(partyId, opts) {
|
|
|
39
39
|
`);
|
|
40
40
|
const cols = [
|
|
41
41
|
{ key: "invoiceNumber", header: "Invoice #", width: 14 },
|
|
42
|
-
{ key: "invoiceDate", header: "Date", width: 13, format: (v) => formatDate(
|
|
42
|
+
{ key: "invoiceDate", header: "Date", width: 13, format: (v) => formatDate(v) },
|
|
43
43
|
{ key: "totalAmount", header: "Total (\u20B9)", align: "right", width: 13, format: (v) => formatAmount(String(v ?? "0")) },
|
|
44
|
-
{ key: "
|
|
45
|
-
{ key: "
|
|
44
|
+
{ key: "amountPaid", header: "Paid (\u20B9)", align: "right", width: 13, format: (v) => formatAmount(String(v ?? "0")) },
|
|
45
|
+
{ key: "balance", header: "Outstanding (\u20B9)", align: "right", width: 16, format: (v) => formatAmount(String(v ?? "0")) },
|
|
46
46
|
{ key: "status", header: "Status", width: 10, format: (v) => String(v ?? "").toUpperCase() }
|
|
47
47
|
];
|
|
48
48
|
if (opts.format === "tsv") outputTSV(invoices, cols);
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
formatAmount,
|
|
4
4
|
formatDate
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-M7DVLVD5.js";
|
|
6
6
|
import {
|
|
7
7
|
HisaaboApiError,
|
|
8
8
|
HisaaboClient
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VXEEFNIY.js";
|
|
10
10
|
import {
|
|
11
11
|
requireAuth
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ESX7V56A.js";
|
|
13
13
|
import {
|
|
14
14
|
EXIT,
|
|
15
15
|
fatalError,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
outputTSV,
|
|
19
19
|
outputTable,
|
|
20
20
|
paginationFooter
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-2DDIXPNI.js";
|
|
22
22
|
|
|
23
23
|
// src/commands/payment/untracked.ts
|
|
24
24
|
async function paymentUntrackedCommand(opts) {
|
|
@@ -32,17 +32,17 @@ async function paymentUntrackedCommand(opts) {
|
|
|
32
32
|
outputJSON(result);
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
const payments =
|
|
36
|
-
const total = result
|
|
37
|
-
const resultPage = result
|
|
38
|
-
const resultLimit = result
|
|
35
|
+
const payments = result.data;
|
|
36
|
+
const total = result.total;
|
|
37
|
+
const resultPage = result.page;
|
|
38
|
+
const resultLimit = result.limit;
|
|
39
39
|
console.log(`
|
|
40
40
|
Untracked Payments ${total} total
|
|
41
41
|
`);
|
|
42
42
|
const cols = [
|
|
43
43
|
{ key: "paymentNumber", header: "#", width: 12 },
|
|
44
44
|
{ key: "partyName", header: "Party", width: 22 },
|
|
45
|
-
{ key: "paymentDate", header: "Date", width: 13, format: (v) => formatDate(
|
|
45
|
+
{ key: "paymentDate", header: "Date", width: 13, format: (v) => formatDate(v) },
|
|
46
46
|
{ key: "amount", header: "Amount (\u20B9)", align: "right", width: 13, format: (v) => formatAmount(String(v ?? "0")) },
|
|
47
47
|
{ key: "mode", header: "Mode", width: 8 },
|
|
48
48
|
{ key: "referenceNumber", header: "Ref#", width: 14, format: (v) => String(v ?? "-") }
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
formatINR
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-M7DVLVD5.js";
|
|
5
5
|
import {
|
|
6
6
|
HisaaboApiError,
|
|
7
7
|
HisaaboClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VXEEFNIY.js";
|
|
9
9
|
import {
|
|
10
10
|
requireAuth
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ESX7V56A.js";
|
|
12
12
|
import {
|
|
13
13
|
EXIT,
|
|
14
14
|
fatalError,
|
|
15
15
|
outputJSON,
|
|
16
16
|
success
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-2DDIXPNI.js";
|
|
18
18
|
|
|
19
19
|
// src/commands/payment/update.ts
|
|
20
20
|
async function paymentUpdateCommand(id, opts) {
|
|
@@ -2,40 +2,33 @@
|
|
|
2
2
|
import {
|
|
3
3
|
HisaaboApiError,
|
|
4
4
|
HisaaboClient
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-VXEEFNIY.js";
|
|
6
6
|
import {
|
|
7
7
|
requireAuth
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ESX7V56A.js";
|
|
9
9
|
import {
|
|
10
10
|
EXIT,
|
|
11
11
|
fatalError,
|
|
12
12
|
outputJSON,
|
|
13
13
|
success
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2DDIXPNI.js";
|
|
15
15
|
|
|
16
16
|
// src/commands/business/update.ts
|
|
17
17
|
async function businessUpdateCommand(opts) {
|
|
18
18
|
const cfg = requireAuth();
|
|
19
19
|
const client = new HisaaboClient(cfg);
|
|
20
20
|
const payload = {};
|
|
21
|
-
if (opts.name !== void 0) payload
|
|
22
|
-
if (opts.gstin !== void 0) payload
|
|
23
|
-
if (opts.address !== void 0) payload
|
|
24
|
-
if (opts.state !== void 0) payload
|
|
25
|
-
if (opts.phone !== void 0) payload
|
|
26
|
-
if (opts.email !== void 0) payload
|
|
27
|
-
if (opts.financialYearStart !== void 0) {
|
|
28
|
-
const month = parseInt(opts.financialYearStart, 10);
|
|
29
|
-
if (isNaN(month) || month < 1 || month > 12) {
|
|
30
|
-
fatalError("--financial-year-start must be a month number (1\u201312).", EXIT.USAGE);
|
|
31
|
-
}
|
|
32
|
-
payload["financialYearStart"] = month;
|
|
33
|
-
}
|
|
21
|
+
if (opts.name !== void 0) payload.name = opts.name;
|
|
22
|
+
if (opts.gstin !== void 0) payload.gstin = opts.gstin;
|
|
23
|
+
if (opts.address !== void 0) payload.address = opts.address;
|
|
24
|
+
if (opts.state !== void 0) payload.state = opts.state;
|
|
25
|
+
if (opts.phone !== void 0) payload.phone = opts.phone;
|
|
26
|
+
if (opts.email !== void 0) payload.email = opts.email;
|
|
34
27
|
if (Object.keys(payload).length === 0) {
|
|
35
28
|
fatalError("No fields to update. Pass at least one option (--name, --gstin, etc.).", EXIT.USAGE);
|
|
36
29
|
}
|
|
37
30
|
try {
|
|
38
|
-
const result = await client.business.update(payload);
|
|
31
|
+
const result = await client.business.update(cfg.businessId, payload);
|
|
39
32
|
if (opts.json) {
|
|
40
33
|
outputJSON(result);
|
|
41
34
|
return;
|