erpnext-queue-client 1.7.0 → 1.8.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/dist/erpnext/doctypes/stock.d.ts +2 -2
- package/dist/erpnext/doctypes/stock.js +12 -44
- package/dist/erpnext/model/Report.d.ts +174 -1
- package/dist/erpnext/model/Report.js +45 -1
- package/dist/erpnext/model/Stock.d.ts +25 -26
- package/dist/erpnext/model/Stock.js +6 -6
- package/dist/erpnext/reports.d.ts +13 -0
- package/dist/erpnext/reports.js +116 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TemporalClient } from "../../client";
|
|
2
2
|
import { ERPNextMethodRequest } from "../methodRequest";
|
|
3
3
|
import { StockBalanceReportItemType, StockProjectedQuantityReportItemType } from "../model/Stock";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { ERPNextReports } from "../reports";
|
|
5
|
+
export declare class ERPNextStock extends ERPNextReports {
|
|
6
6
|
protected methodRequest: ERPNextMethodRequest;
|
|
7
7
|
constructor(temporalClient: TemporalClient);
|
|
8
8
|
getStockBalanceAtDate(date: Date, warehouse?: string): Promise<StockBalanceReportItemType[]>;
|
|
@@ -10,62 +10,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ERPNextStock = void 0;
|
|
13
|
-
const
|
|
14
|
-
const utils_1 = require("../../utils/utils");
|
|
13
|
+
const zod_1 = require("zod");
|
|
15
14
|
const methodRequest_1 = require("../methodRequest");
|
|
16
15
|
const Stock_1 = require("../model/Stock");
|
|
17
|
-
const
|
|
18
|
-
class ERPNextStock {
|
|
16
|
+
const reports_1 = require("../reports");
|
|
17
|
+
class ERPNextStock extends reports_1.ERPNextReports {
|
|
19
18
|
constructor(temporalClient) {
|
|
20
|
-
|
|
19
|
+
super(temporalClient);
|
|
21
20
|
this.methodRequest = new methodRequest_1.ERPNextMethodRequest(temporalClient);
|
|
22
21
|
}
|
|
23
22
|
getStockBalanceAtDate(date_1) {
|
|
24
23
|
return __awaiter(this, arguments, void 0, function* (date, warehouse = "") {
|
|
25
|
-
var _a;
|
|
26
24
|
const dateString = date.toISOString().substring(0, 10);
|
|
27
|
-
const result = yield this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
report_name: "Stock Balance",
|
|
32
|
-
filters: `"from_date":"${dateString}","to_date":"${dateString}"${warehouse ? `,"warehouse":"${warehouse}"` : ""}`,
|
|
33
|
-
},
|
|
34
|
-
responseValidationModel: Stock_1.StockBalanceReportRequest,
|
|
35
|
-
});
|
|
36
|
-
const { name } = result;
|
|
37
|
-
for (let i = 0; i < 100; i++) {
|
|
38
|
-
const reportResponse = yield this.methodRequest.request({
|
|
39
|
-
methodName: `frappe.desk.query_report.run`,
|
|
40
|
-
body: {
|
|
41
|
-
report_name: "Stock Balance",
|
|
42
|
-
filters: Object.assign({ from_date: dateString, to_date: dateString }, (warehouse && { warehouse })),
|
|
43
|
-
},
|
|
44
|
-
requestMethod: "POST",
|
|
45
|
-
responseValidationModel: Stock_1.StockBalanceReport,
|
|
46
|
-
});
|
|
47
|
-
// Casting to correct type since Typescript is not able to infer the type correctly.
|
|
48
|
-
// Type safety is ensured by zod
|
|
49
|
-
if ((reportResponse === null || reportResponse === void 0 ? void 0 : reportResponse.result) && ((_a = reportResponse === null || reportResponse === void 0 ? void 0 : reportResponse.doc) === null || _a === void 0 ? void 0 : _a.name) === name)
|
|
50
|
-
return reportResponse === null || reportResponse === void 0 ? void 0 : reportResponse.result.filter((r) => !(0, lodash_1.isArray)(r));
|
|
51
|
-
yield (0, utils_1.timeout)(1000);
|
|
52
|
-
}
|
|
53
|
-
throw new Error(`Failed to get stock Balance${warehouse && ` for warehouse ${warehouse}`}`);
|
|
25
|
+
const result = yield this.getReport("Stock Balance", {
|
|
26
|
+
filters: Object.assign({ from_date: dateString, to_date: dateString }, (warehouse ? { warehouse } : {})),
|
|
27
|
+
}, Stock_1.StockBalanceReportItem);
|
|
28
|
+
return result;
|
|
54
29
|
});
|
|
55
30
|
}
|
|
56
31
|
getStockProjectedQuantityReport(warehouse, sku) {
|
|
57
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
const result = yield this.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
filters: Object.assign(Object.assign({}, (warehouse && { warehouse })), (sku && { item_code: sku })),
|
|
63
|
-
},
|
|
64
|
-
requestMethod: "POST",
|
|
65
|
-
responseValidationModel: Stock_1.StockProjectedQuantityReport,
|
|
66
|
-
});
|
|
67
|
-
// We need to cast here, since typescript is not able to infer the type correctly. Type safety is ensured by zod
|
|
68
|
-
return result.result.filter((r) => !(0, lodash_1.isArray)(r));
|
|
33
|
+
const result = yield this.getReport("Stock Projected Qty", {
|
|
34
|
+
filters: Object.assign(Object.assign({}, (warehouse && { warehouse })), (sku && { item_code: sku })),
|
|
35
|
+
}, Stock_1.StockProjectedQuantityReportItem);
|
|
36
|
+
return result;
|
|
69
37
|
});
|
|
70
38
|
}
|
|
71
39
|
getStockFromBin(topLevelWarehouse) {
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import { z, ZodTypeAny } from "zod";
|
|
2
|
+
export declare const EnqueueReportResponse: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
name: string;
|
|
6
|
+
}, {
|
|
7
|
+
name: string;
|
|
8
|
+
}>;
|
|
9
|
+
export type EnqueueReportResponseType = z.infer<typeof EnqueueReportResponse>;
|
|
2
10
|
export declare const ReportColumn: z.ZodObject<{
|
|
3
11
|
label: z.ZodString;
|
|
4
12
|
fieldname: z.ZodString;
|
|
@@ -22,3 +30,168 @@ export declare const ReportColumn: z.ZodObject<{
|
|
|
22
30
|
convertible?: string | null | undefined;
|
|
23
31
|
}>;
|
|
24
32
|
export type ReportColumnType = z.infer<typeof ReportColumn>;
|
|
33
|
+
export declare const Report: <RModel extends ZodTypeAny>(reportRowModel: RModel) => z.ZodObject<{
|
|
34
|
+
chart: z.ZodNullable<z.ZodOptional<z.ZodAny>>;
|
|
35
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
36
|
+
label: z.ZodString;
|
|
37
|
+
fieldname: z.ZodString;
|
|
38
|
+
fieldtype: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
39
|
+
options: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
40
|
+
width: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
41
|
+
convertible: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
label: string;
|
|
44
|
+
fieldname: string;
|
|
45
|
+
options?: string | null | undefined;
|
|
46
|
+
fieldtype?: string | null | undefined;
|
|
47
|
+
width?: number | null | undefined;
|
|
48
|
+
convertible?: string | null | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
label: string;
|
|
51
|
+
fieldname: string;
|
|
52
|
+
options?: string | null | undefined;
|
|
53
|
+
fieldtype?: string | null | undefined;
|
|
54
|
+
width?: number | null | undefined;
|
|
55
|
+
convertible?: string | null | undefined;
|
|
56
|
+
}>, "many">;
|
|
57
|
+
execution_time: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
58
|
+
message: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
59
|
+
report_summary: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
60
|
+
result: z.ZodUnion<[z.ZodArray<z.ZodUnion<[RModel, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">]>, "many">, z.ZodArray<RModel, "many">]>;
|
|
61
|
+
skip_total_row: z.ZodEffects<z.ZodNullable<z.ZodOptional<z.ZodNumber>>, boolean, number | null | undefined>;
|
|
62
|
+
status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
63
|
+
prepared_report: z.ZodBoolean;
|
|
64
|
+
doc: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
65
|
+
name: z.ZodString;
|
|
66
|
+
owner: z.ZodString;
|
|
67
|
+
creation: z.ZodString;
|
|
68
|
+
modified: z.ZodString;
|
|
69
|
+
modified_by: z.ZodString;
|
|
70
|
+
idx: z.ZodNumber;
|
|
71
|
+
docstatus: z.ZodNumber;
|
|
72
|
+
report_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
73
|
+
ref_report_doctype: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
74
|
+
status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
75
|
+
report_start_time: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
76
|
+
report_end_time: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
77
|
+
filters: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
78
|
+
columns: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
79
|
+
doctype: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
name: string;
|
|
82
|
+
owner: string;
|
|
83
|
+
creation: string;
|
|
84
|
+
modified: string;
|
|
85
|
+
modified_by: string;
|
|
86
|
+
idx: number;
|
|
87
|
+
docstatus: number;
|
|
88
|
+
status?: string | null | undefined;
|
|
89
|
+
filters?: string | null | undefined;
|
|
90
|
+
doctype?: string | null | undefined;
|
|
91
|
+
report_name?: string | null | undefined;
|
|
92
|
+
columns?: string | null | undefined;
|
|
93
|
+
ref_report_doctype?: string | null | undefined;
|
|
94
|
+
report_start_time?: string | null | undefined;
|
|
95
|
+
report_end_time?: string | null | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
name: string;
|
|
98
|
+
owner: string;
|
|
99
|
+
creation: string;
|
|
100
|
+
modified: string;
|
|
101
|
+
modified_by: string;
|
|
102
|
+
idx: number;
|
|
103
|
+
docstatus: number;
|
|
104
|
+
status?: string | null | undefined;
|
|
105
|
+
filters?: string | null | undefined;
|
|
106
|
+
doctype?: string | null | undefined;
|
|
107
|
+
report_name?: string | null | undefined;
|
|
108
|
+
columns?: string | null | undefined;
|
|
109
|
+
ref_report_doctype?: string | null | undefined;
|
|
110
|
+
report_start_time?: string | null | undefined;
|
|
111
|
+
report_end_time?: string | null | undefined;
|
|
112
|
+
}>>>;
|
|
113
|
+
add_total_row: z.ZodBoolean;
|
|
114
|
+
}, "strip", z.ZodTypeAny, {
|
|
115
|
+
result: (z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many"> | RModel)["_output"][] | RModel["_output"][];
|
|
116
|
+
columns: {
|
|
117
|
+
label: string;
|
|
118
|
+
fieldname: string;
|
|
119
|
+
options?: string | null | undefined;
|
|
120
|
+
fieldtype?: string | null | undefined;
|
|
121
|
+
width?: number | null | undefined;
|
|
122
|
+
convertible?: string | null | undefined;
|
|
123
|
+
}[];
|
|
124
|
+
skip_total_row: boolean;
|
|
125
|
+
add_total_row: boolean;
|
|
126
|
+
prepared_report: boolean;
|
|
127
|
+
message?: string | null | undefined;
|
|
128
|
+
status?: string | null | undefined;
|
|
129
|
+
chart?: any;
|
|
130
|
+
report_summary?: string | null | undefined;
|
|
131
|
+
execution_time?: number | null | undefined;
|
|
132
|
+
doc?: {
|
|
133
|
+
name: string;
|
|
134
|
+
owner: string;
|
|
135
|
+
creation: string;
|
|
136
|
+
modified: string;
|
|
137
|
+
modified_by: string;
|
|
138
|
+
idx: number;
|
|
139
|
+
docstatus: number;
|
|
140
|
+
status?: string | null | undefined;
|
|
141
|
+
filters?: string | null | undefined;
|
|
142
|
+
doctype?: string | null | undefined;
|
|
143
|
+
report_name?: string | null | undefined;
|
|
144
|
+
columns?: string | null | undefined;
|
|
145
|
+
ref_report_doctype?: string | null | undefined;
|
|
146
|
+
report_start_time?: string | null | undefined;
|
|
147
|
+
report_end_time?: string | null | undefined;
|
|
148
|
+
} | null | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
result: (z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many"> | RModel)["_input"][] | RModel["_input"][];
|
|
151
|
+
columns: {
|
|
152
|
+
label: string;
|
|
153
|
+
fieldname: string;
|
|
154
|
+
options?: string | null | undefined;
|
|
155
|
+
fieldtype?: string | null | undefined;
|
|
156
|
+
width?: number | null | undefined;
|
|
157
|
+
convertible?: string | null | undefined;
|
|
158
|
+
}[];
|
|
159
|
+
add_total_row: boolean;
|
|
160
|
+
prepared_report: boolean;
|
|
161
|
+
message?: string | null | undefined;
|
|
162
|
+
status?: string | null | undefined;
|
|
163
|
+
chart?: any;
|
|
164
|
+
report_summary?: string | null | undefined;
|
|
165
|
+
skip_total_row?: number | null | undefined;
|
|
166
|
+
execution_time?: number | null | undefined;
|
|
167
|
+
doc?: {
|
|
168
|
+
name: string;
|
|
169
|
+
owner: string;
|
|
170
|
+
creation: string;
|
|
171
|
+
modified: string;
|
|
172
|
+
modified_by: string;
|
|
173
|
+
idx: number;
|
|
174
|
+
docstatus: number;
|
|
175
|
+
status?: string | null | undefined;
|
|
176
|
+
filters?: string | null | undefined;
|
|
177
|
+
doctype?: string | null | undefined;
|
|
178
|
+
report_name?: string | null | undefined;
|
|
179
|
+
columns?: string | null | undefined;
|
|
180
|
+
ref_report_doctype?: string | null | undefined;
|
|
181
|
+
report_start_time?: string | null | undefined;
|
|
182
|
+
report_end_time?: string | null | undefined;
|
|
183
|
+
} | null | undefined;
|
|
184
|
+
}>;
|
|
185
|
+
export declare const PendingPreparedReport: z.ZodObject<{
|
|
186
|
+
prepared_report: z.ZodBoolean;
|
|
187
|
+
doc: z.ZodNull;
|
|
188
|
+
add_total_row: z.ZodBoolean;
|
|
189
|
+
}, "strip", z.ZodTypeAny, {
|
|
190
|
+
add_total_row: boolean;
|
|
191
|
+
prepared_report: boolean;
|
|
192
|
+
doc: null;
|
|
193
|
+
}, {
|
|
194
|
+
add_total_row: boolean;
|
|
195
|
+
prepared_report: boolean;
|
|
196
|
+
doc: null;
|
|
197
|
+
}>;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReportColumn = void 0;
|
|
3
|
+
exports.PendingPreparedReport = exports.Report = exports.ReportColumn = exports.EnqueueReportResponse = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
exports.EnqueueReportResponse = zod_1.z
|
|
6
|
+
.object({
|
|
7
|
+
name: zod_1.z.string(),
|
|
8
|
+
})
|
|
9
|
+
.describe("EnqueueReportResponse");
|
|
5
10
|
exports.ReportColumn = zod_1.z.object({
|
|
6
11
|
label: zod_1.z.string(),
|
|
7
12
|
fieldname: zod_1.z.string(),
|
|
@@ -10,3 +15,42 @@ exports.ReportColumn = zod_1.z.object({
|
|
|
10
15
|
width: zod_1.z.number().optional().nullable(),
|
|
11
16
|
convertible: zod_1.z.string().optional().nullable(),
|
|
12
17
|
});
|
|
18
|
+
const ReportMeta = zod_1.z.object({
|
|
19
|
+
name: zod_1.z.string(),
|
|
20
|
+
owner: zod_1.z.string(),
|
|
21
|
+
creation: zod_1.z.string(),
|
|
22
|
+
modified: zod_1.z.string(),
|
|
23
|
+
modified_by: zod_1.z.string(),
|
|
24
|
+
idx: zod_1.z.number(),
|
|
25
|
+
docstatus: zod_1.z.number(),
|
|
26
|
+
report_name: zod_1.z.string().optional().nullable(),
|
|
27
|
+
ref_report_doctype: zod_1.z.string().optional().nullable(),
|
|
28
|
+
status: zod_1.z.string().optional().nullable(),
|
|
29
|
+
report_start_time: zod_1.z.string().optional().nullable(),
|
|
30
|
+
report_end_time: zod_1.z.string().optional().nullable(),
|
|
31
|
+
filters: zod_1.z.string().optional().nullable(),
|
|
32
|
+
columns: zod_1.z.string().optional().nullable(),
|
|
33
|
+
doctype: zod_1.z.string().optional().nullable(),
|
|
34
|
+
});
|
|
35
|
+
const TotalRow = zod_1.z.array(zod_1.z.string().or(zod_1.z.number()));
|
|
36
|
+
const Report = (reportRowModel) => zod_1.z
|
|
37
|
+
.object({
|
|
38
|
+
chart: zod_1.z.any().optional().nullable(),
|
|
39
|
+
columns: zod_1.z.array(exports.ReportColumn),
|
|
40
|
+
execution_time: zod_1.z.number().optional().nullable(),
|
|
41
|
+
message: zod_1.z.string().optional().nullable(),
|
|
42
|
+
report_summary: zod_1.z.string().optional().nullable(),
|
|
43
|
+
result: zod_1.z.array(reportRowModel.or(TotalRow)).or(zod_1.z.array(reportRowModel)),
|
|
44
|
+
skip_total_row: zod_1.z.number().optional().nullable().transform(Boolean),
|
|
45
|
+
status: zod_1.z.string().optional().nullable(),
|
|
46
|
+
prepared_report: zod_1.z.boolean(),
|
|
47
|
+
doc: ReportMeta.optional().nullable(),
|
|
48
|
+
add_total_row: zod_1.z.boolean(),
|
|
49
|
+
})
|
|
50
|
+
.describe("Report Generator " + reportRowModel.description);
|
|
51
|
+
exports.Report = Report;
|
|
52
|
+
exports.PendingPreparedReport = zod_1.z.object({
|
|
53
|
+
prepared_report: zod_1.z.boolean(),
|
|
54
|
+
doc: zod_1.z.null(),
|
|
55
|
+
add_total_row: zod_1.z.boolean(),
|
|
56
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
declare const StockBalanceReportItem: z.ZodObject<{
|
|
2
|
+
export declare const StockBalanceReportItem: z.ZodObject<{
|
|
3
3
|
bal_qty: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
4
4
|
bal_val: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
5
5
|
brand: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
6
6
|
company: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
7
|
-
currency: z.ZodNullable<z.ZodOptional<z.ZodString
|
|
7
|
+
currency: z.ZodNullable<z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>>;
|
|
8
8
|
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
9
9
|
in_qty: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
10
10
|
in_val: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
11
11
|
item_code: z.ZodString;
|
|
12
12
|
item_group: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
13
13
|
item_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
14
|
-
name: z.ZodString
|
|
14
|
+
name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
15
|
opening_qty: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
16
16
|
opening_val: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
17
17
|
out_qty: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -22,16 +22,16 @@ declare const StockBalanceReportItem: z.ZodObject<{
|
|
|
22
22
|
val_rate: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
23
23
|
warehouse: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
24
24
|
}, "strip", z.ZodTypeAny, {
|
|
25
|
-
name: string;
|
|
26
25
|
item_code: string;
|
|
27
26
|
description?: string | null | undefined;
|
|
28
27
|
brand?: string | null | undefined;
|
|
28
|
+
name?: string | null | undefined;
|
|
29
29
|
company?: string | null | undefined;
|
|
30
30
|
item_name?: string | null | undefined;
|
|
31
31
|
item_group?: string | null | undefined;
|
|
32
32
|
stock_uom?: string | null | undefined;
|
|
33
33
|
warehouse?: string | null | undefined;
|
|
34
|
-
currency?: string | null | undefined;
|
|
34
|
+
currency?: string | number | null | undefined;
|
|
35
35
|
bal_qty?: number | null | undefined;
|
|
36
36
|
bal_val?: number | null | undefined;
|
|
37
37
|
in_qty?: number | null | undefined;
|
|
@@ -44,16 +44,16 @@ declare const StockBalanceReportItem: z.ZodObject<{
|
|
|
44
44
|
reorder_qty?: number | null | undefined;
|
|
45
45
|
val_rate?: number | null | undefined;
|
|
46
46
|
}, {
|
|
47
|
-
name: string;
|
|
48
47
|
item_code: string;
|
|
49
48
|
description?: string | null | undefined;
|
|
50
49
|
brand?: string | null | undefined;
|
|
50
|
+
name?: string | null | undefined;
|
|
51
51
|
company?: string | null | undefined;
|
|
52
52
|
item_name?: string | null | undefined;
|
|
53
53
|
item_group?: string | null | undefined;
|
|
54
54
|
stock_uom?: string | null | undefined;
|
|
55
55
|
warehouse?: string | null | undefined;
|
|
56
|
-
currency?: string | null | undefined;
|
|
56
|
+
currency?: string | number | null | undefined;
|
|
57
57
|
bal_qty?: number | null | undefined;
|
|
58
58
|
bal_val?: number | null | undefined;
|
|
59
59
|
in_qty?: number | null | undefined;
|
|
@@ -104,14 +104,14 @@ export declare const StockBalanceReport: z.ZodObject<{
|
|
|
104
104
|
bal_val: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
105
105
|
brand: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
106
106
|
company: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
107
|
-
currency: z.ZodNullable<z.ZodOptional<z.ZodString
|
|
107
|
+
currency: z.ZodNullable<z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>>;
|
|
108
108
|
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
109
109
|
in_qty: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
110
110
|
in_val: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
111
111
|
item_code: z.ZodString;
|
|
112
112
|
item_group: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
113
113
|
item_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
114
|
-
name: z.ZodString
|
|
114
|
+
name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
115
115
|
opening_qty: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
116
116
|
opening_val: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
117
117
|
out_qty: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -122,16 +122,16 @@ export declare const StockBalanceReport: z.ZodObject<{
|
|
|
122
122
|
val_rate: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
123
123
|
warehouse: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
124
124
|
}, "strip", z.ZodTypeAny, {
|
|
125
|
-
name: string;
|
|
126
125
|
item_code: string;
|
|
127
126
|
description?: string | null | undefined;
|
|
128
127
|
brand?: string | null | undefined;
|
|
128
|
+
name?: string | null | undefined;
|
|
129
129
|
company?: string | null | undefined;
|
|
130
130
|
item_name?: string | null | undefined;
|
|
131
131
|
item_group?: string | null | undefined;
|
|
132
132
|
stock_uom?: string | null | undefined;
|
|
133
133
|
warehouse?: string | null | undefined;
|
|
134
|
-
currency?: string | null | undefined;
|
|
134
|
+
currency?: string | number | null | undefined;
|
|
135
135
|
bal_qty?: number | null | undefined;
|
|
136
136
|
bal_val?: number | null | undefined;
|
|
137
137
|
in_qty?: number | null | undefined;
|
|
@@ -144,16 +144,16 @@ export declare const StockBalanceReport: z.ZodObject<{
|
|
|
144
144
|
reorder_qty?: number | null | undefined;
|
|
145
145
|
val_rate?: number | null | undefined;
|
|
146
146
|
}, {
|
|
147
|
-
name: string;
|
|
148
147
|
item_code: string;
|
|
149
148
|
description?: string | null | undefined;
|
|
150
149
|
brand?: string | null | undefined;
|
|
150
|
+
name?: string | null | undefined;
|
|
151
151
|
company?: string | null | undefined;
|
|
152
152
|
item_name?: string | null | undefined;
|
|
153
153
|
item_group?: string | null | undefined;
|
|
154
154
|
stock_uom?: string | null | undefined;
|
|
155
155
|
warehouse?: string | null | undefined;
|
|
156
|
-
currency?: string | null | undefined;
|
|
156
|
+
currency?: string | number | null | undefined;
|
|
157
157
|
bal_qty?: number | null | undefined;
|
|
158
158
|
bal_val?: number | null | undefined;
|
|
159
159
|
in_qty?: number | null | undefined;
|
|
@@ -219,16 +219,16 @@ export declare const StockBalanceReport: z.ZodObject<{
|
|
|
219
219
|
add_total_row: z.ZodBoolean;
|
|
220
220
|
}, "strip", z.ZodTypeAny, {
|
|
221
221
|
result: ((string | number)[] | {
|
|
222
|
-
name: string;
|
|
223
222
|
item_code: string;
|
|
224
223
|
description?: string | null | undefined;
|
|
225
224
|
brand?: string | null | undefined;
|
|
225
|
+
name?: string | null | undefined;
|
|
226
226
|
company?: string | null | undefined;
|
|
227
227
|
item_name?: string | null | undefined;
|
|
228
228
|
item_group?: string | null | undefined;
|
|
229
229
|
stock_uom?: string | null | undefined;
|
|
230
230
|
warehouse?: string | null | undefined;
|
|
231
|
-
currency?: string | null | undefined;
|
|
231
|
+
currency?: string | number | null | undefined;
|
|
232
232
|
bal_qty?: number | null | undefined;
|
|
233
233
|
bal_val?: number | null | undefined;
|
|
234
234
|
in_qty?: number | null | undefined;
|
|
@@ -270,16 +270,16 @@ export declare const StockBalanceReport: z.ZodObject<{
|
|
|
270
270
|
} | null | undefined;
|
|
271
271
|
}, {
|
|
272
272
|
result: ((string | number)[] | {
|
|
273
|
-
name: string;
|
|
274
273
|
item_code: string;
|
|
275
274
|
description?: string | null | undefined;
|
|
276
275
|
brand?: string | null | undefined;
|
|
276
|
+
name?: string | null | undefined;
|
|
277
277
|
company?: string | null | undefined;
|
|
278
278
|
item_name?: string | null | undefined;
|
|
279
279
|
item_group?: string | null | undefined;
|
|
280
280
|
stock_uom?: string | null | undefined;
|
|
281
281
|
warehouse?: string | null | undefined;
|
|
282
|
-
currency?: string | null | undefined;
|
|
282
|
+
currency?: string | number | null | undefined;
|
|
283
283
|
bal_qty?: number | null | undefined;
|
|
284
284
|
bal_val?: number | null | undefined;
|
|
285
285
|
in_qty?: number | null | undefined;
|
|
@@ -326,7 +326,7 @@ export type StockBalanceReportItemType = z.infer<typeof StockBalanceReportItem>;
|
|
|
326
326
|
export declare const StockProjectedQuantityReportItem: z.ZodObject<{
|
|
327
327
|
item_code: z.ZodString;
|
|
328
328
|
item_name: z.ZodString;
|
|
329
|
-
description: z.ZodString
|
|
329
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
330
330
|
item_group: z.ZodString;
|
|
331
331
|
brand: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
332
332
|
warehouse: z.ZodString;
|
|
@@ -344,7 +344,6 @@ export declare const StockProjectedQuantityReportItem: z.ZodObject<{
|
|
|
344
344
|
re_order_qty: z.ZodNumber;
|
|
345
345
|
shortage_qty: z.ZodNumber;
|
|
346
346
|
}, "strip", z.ZodTypeAny, {
|
|
347
|
-
description: string;
|
|
348
347
|
item_code: string;
|
|
349
348
|
item_name: string;
|
|
350
349
|
item_group: string;
|
|
@@ -362,9 +361,9 @@ export declare const StockProjectedQuantityReportItem: z.ZodObject<{
|
|
|
362
361
|
re_order_level: number;
|
|
363
362
|
re_order_qty: number;
|
|
364
363
|
shortage_qty: number;
|
|
364
|
+
description?: string | null | undefined;
|
|
365
365
|
brand?: string | null | undefined;
|
|
366
366
|
}, {
|
|
367
|
-
description: string;
|
|
368
367
|
item_code: string;
|
|
369
368
|
item_name: string;
|
|
370
369
|
item_group: string;
|
|
@@ -382,6 +381,7 @@ export declare const StockProjectedQuantityReportItem: z.ZodObject<{
|
|
|
382
381
|
re_order_level: number;
|
|
383
382
|
re_order_qty: number;
|
|
384
383
|
shortage_qty: number;
|
|
384
|
+
description?: string | null | undefined;
|
|
385
385
|
brand?: string | null | undefined;
|
|
386
386
|
}>;
|
|
387
387
|
export type StockProjectedQuantityReportItemType = z.infer<typeof StockProjectedQuantityReportItem>;
|
|
@@ -389,7 +389,7 @@ export declare const StockProjectedQuantityReport: z.ZodObject<{
|
|
|
389
389
|
result: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
390
390
|
item_code: z.ZodString;
|
|
391
391
|
item_name: z.ZodString;
|
|
392
|
-
description: z.ZodString
|
|
392
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
393
393
|
item_group: z.ZodString;
|
|
394
394
|
brand: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
395
395
|
warehouse: z.ZodString;
|
|
@@ -407,7 +407,6 @@ export declare const StockProjectedQuantityReport: z.ZodObject<{
|
|
|
407
407
|
re_order_qty: z.ZodNumber;
|
|
408
408
|
shortage_qty: z.ZodNumber;
|
|
409
409
|
}, "strip", z.ZodTypeAny, {
|
|
410
|
-
description: string;
|
|
411
410
|
item_code: string;
|
|
412
411
|
item_name: string;
|
|
413
412
|
item_group: string;
|
|
@@ -425,9 +424,9 @@ export declare const StockProjectedQuantityReport: z.ZodObject<{
|
|
|
425
424
|
re_order_level: number;
|
|
426
425
|
re_order_qty: number;
|
|
427
426
|
shortage_qty: number;
|
|
427
|
+
description?: string | null | undefined;
|
|
428
428
|
brand?: string | null | undefined;
|
|
429
429
|
}, {
|
|
430
|
-
description: string;
|
|
431
430
|
item_code: string;
|
|
432
431
|
item_name: string;
|
|
433
432
|
item_group: string;
|
|
@@ -445,6 +444,7 @@ export declare const StockProjectedQuantityReport: z.ZodObject<{
|
|
|
445
444
|
re_order_level: number;
|
|
446
445
|
re_order_qty: number;
|
|
447
446
|
shortage_qty: number;
|
|
447
|
+
description?: string | null | undefined;
|
|
448
448
|
brand?: string | null | undefined;
|
|
449
449
|
}>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">]>, "many">;
|
|
450
450
|
columns: z.ZodArray<z.ZodUnion<[z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">, z.ZodObject<{
|
|
@@ -478,7 +478,6 @@ export declare const StockProjectedQuantityReport: z.ZodObject<{
|
|
|
478
478
|
add_total_row: z.ZodBoolean;
|
|
479
479
|
}, "strip", z.ZodTypeAny, {
|
|
480
480
|
result: ((string | number)[] | {
|
|
481
|
-
description: string;
|
|
482
481
|
item_code: string;
|
|
483
482
|
item_name: string;
|
|
484
483
|
item_group: string;
|
|
@@ -496,6 +495,7 @@ export declare const StockProjectedQuantityReport: z.ZodObject<{
|
|
|
496
495
|
re_order_level: number;
|
|
497
496
|
re_order_qty: number;
|
|
498
497
|
shortage_qty: number;
|
|
498
|
+
description?: string | null | undefined;
|
|
499
499
|
brand?: string | null | undefined;
|
|
500
500
|
})[];
|
|
501
501
|
columns: ((string | number)[] | {
|
|
@@ -515,7 +515,6 @@ export declare const StockProjectedQuantityReport: z.ZodObject<{
|
|
|
515
515
|
report_summary?: string | null | undefined;
|
|
516
516
|
}, {
|
|
517
517
|
result: ((string | number)[] | {
|
|
518
|
-
description: string;
|
|
519
518
|
item_code: string;
|
|
520
519
|
item_name: string;
|
|
521
520
|
item_group: string;
|
|
@@ -533,6 +532,7 @@ export declare const StockProjectedQuantityReport: z.ZodObject<{
|
|
|
533
532
|
re_order_level: number;
|
|
534
533
|
re_order_qty: number;
|
|
535
534
|
shortage_qty: number;
|
|
535
|
+
description?: string | null | undefined;
|
|
536
536
|
brand?: string | null | undefined;
|
|
537
537
|
})[];
|
|
538
538
|
columns: ((string | number)[] | {
|
|
@@ -563,4 +563,3 @@ export declare const StockProjectedQuantityDict: z.ZodRecord<z.ZodString, z.ZodO
|
|
|
563
563
|
ordered_qty: number;
|
|
564
564
|
}>>;
|
|
565
565
|
export type StockProjectedQuantityDictType = z.infer<typeof StockProjectedQuantityDict>;
|
|
566
|
-
export {};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StockProjectedQuantityDict = exports.StockProjectedQuantityReport = exports.StockProjectedQuantityReportItem = exports.StockBalanceReport = exports.StockBalanceReportRequest = void 0;
|
|
3
|
+
exports.StockProjectedQuantityDict = exports.StockProjectedQuantityReport = exports.StockProjectedQuantityReportItem = exports.StockBalanceReport = exports.StockBalanceReportRequest = exports.StockBalanceReportItem = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const Report_1 = require("./Report");
|
|
6
|
-
|
|
6
|
+
exports.StockBalanceReportItem = zod_1.z
|
|
7
7
|
.object({
|
|
8
8
|
bal_qty: zod_1.z.number().optional().nullable(),
|
|
9
9
|
bal_val: zod_1.z.number().optional().nullable(),
|
|
10
10
|
brand: zod_1.z.string().optional().nullable(),
|
|
11
11
|
company: zod_1.z.string().optional().nullable(),
|
|
12
|
-
currency: zod_1.z.string().optional().nullable(),
|
|
12
|
+
currency: zod_1.z.number().or(zod_1.z.string()).optional().nullable(),
|
|
13
13
|
description: zod_1.z.string().optional().nullable(),
|
|
14
14
|
in_qty: zod_1.z.number().optional().nullable(),
|
|
15
15
|
in_val: zod_1.z.number().optional().nullable(),
|
|
16
16
|
item_code: zod_1.z.string(),
|
|
17
17
|
item_group: zod_1.z.string().optional().nullable(),
|
|
18
18
|
item_name: zod_1.z.string().optional().nullable(),
|
|
19
|
-
name: zod_1.z.string(),
|
|
19
|
+
name: zod_1.z.string().optional().nullable(),
|
|
20
20
|
opening_qty: zod_1.z.number().optional().nullable(),
|
|
21
21
|
opening_val: zod_1.z.number().optional().nullable(),
|
|
22
22
|
out_qty: zod_1.z.number().optional().nullable(),
|
|
@@ -56,7 +56,7 @@ exports.StockBalanceReport = zod_1.z
|
|
|
56
56
|
columns: zod_1.z.array(Report_1.ReportColumn),
|
|
57
57
|
result: zod_1.z.array(zod_1.z.union([
|
|
58
58
|
zod_1.z.array(zod_1.z.union([zod_1.z.string(), zod_1.z.number()])),
|
|
59
|
-
StockBalanceReportItem,
|
|
59
|
+
exports.StockBalanceReportItem,
|
|
60
60
|
])),
|
|
61
61
|
prepared_report: zod_1.z.boolean(),
|
|
62
62
|
doc: StockBalanceReportMeta.optional().nullable(),
|
|
@@ -67,7 +67,7 @@ exports.StockProjectedQuantityReportItem = zod_1.z
|
|
|
67
67
|
.object({
|
|
68
68
|
item_code: zod_1.z.string(),
|
|
69
69
|
item_name: zod_1.z.string(),
|
|
70
|
-
description: zod_1.z.string(),
|
|
70
|
+
description: zod_1.z.string().optional().nullable(),
|
|
71
71
|
item_group: zod_1.z.string(),
|
|
72
72
|
brand: zod_1.z.string().optional().nullable(),
|
|
73
73
|
warehouse: zod_1.z.string(),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z, ZodTypeAny } from "zod";
|
|
2
|
+
import { TemporalClient } from "../client";
|
|
3
|
+
import { ERPNextMethodRequest } from "./methodRequest";
|
|
4
|
+
import { EnqueueReportResponseType } from "./model/Report";
|
|
5
|
+
export declare class ERPNextReports extends ERPNextMethodRequest {
|
|
6
|
+
private resourceRequest;
|
|
7
|
+
constructor(temporalClient: TemporalClient);
|
|
8
|
+
enqueueReport(reportName: string, body: Record<string, unknown>): Promise<EnqueueReportResponseType>;
|
|
9
|
+
isPreparedReport(reportName: string): Promise<boolean>;
|
|
10
|
+
getReport<RModel extends ZodTypeAny>(reportName: string, body: Record<string, unknown>, reportRowModel?: RModel): Promise<z.infer<typeof reportRowModel extends undefined ? ZodTypeAny : RModel>[]>;
|
|
11
|
+
getEnqueuedReport<RModel extends ZodTypeAny>(reportName: string, body: Record<string, unknown>, enqueuedReportName: string, reportRowModel?: RModel): Promise<z.infer<typeof reportRowModel extends undefined ? ZodTypeAny : RModel>[]>;
|
|
12
|
+
enqueueAndGetReport<RModel extends ZodTypeAny>(reportName: string, body: Record<string, unknown>, reportRowModel?: RModel): Promise<z.infer<typeof reportRowModel extends undefined ? ZodTypeAny : RModel>[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ERPNextReports = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const methodRequest_1 = require("./methodRequest");
|
|
15
|
+
const Report_1 = require("./model/Report");
|
|
16
|
+
const lodash_1 = require("lodash");
|
|
17
|
+
const utils_1 = require("../utils/utils");
|
|
18
|
+
const resourceRequest_1 = require("./resourceRequest");
|
|
19
|
+
class ERPNextReports extends methodRequest_1.ERPNextMethodRequest {
|
|
20
|
+
constructor(temporalClient) {
|
|
21
|
+
super(temporalClient);
|
|
22
|
+
this.resourceRequest = new resourceRequest_1.ERPNextResourceRequest(temporalClient);
|
|
23
|
+
}
|
|
24
|
+
enqueueReport(reportName, body) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const result = yield this.request({
|
|
27
|
+
methodName: "frappe.core.doctype.prepared_report.prepared_report.make_prepared_report",
|
|
28
|
+
requestMethod: "POST",
|
|
29
|
+
body: Object.assign({ report_name: reportName }, body),
|
|
30
|
+
responseValidationModel: Report_1.EnqueueReportResponse,
|
|
31
|
+
});
|
|
32
|
+
return result;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
isPreparedReport(reportName) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const result = yield this.resourceRequest.getList({
|
|
38
|
+
resourceName: "Report",
|
|
39
|
+
filters: [["name", "=", reportName]],
|
|
40
|
+
fields: ["prepared_report"],
|
|
41
|
+
limit: 1,
|
|
42
|
+
resourceModel: zod_1.z
|
|
43
|
+
.object({
|
|
44
|
+
prepared_report: zod_1.z.number().transform(Boolean),
|
|
45
|
+
})
|
|
46
|
+
.describe("Report prepared_report"),
|
|
47
|
+
});
|
|
48
|
+
if (!result.length)
|
|
49
|
+
throw new Error(`Report ${reportName} not found`);
|
|
50
|
+
return result[0].prepared_report;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
getReport(reportName, body, reportRowModel) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
if (yield this.isPreparedReport(reportName)) {
|
|
56
|
+
return this.enqueueAndGetReport(reportName, body, reportRowModel);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const responseValidationModel = (0, Report_1.Report)(reportRowModel !== null && reportRowModel !== void 0 ? reportRowModel : zod_1.z.any());
|
|
60
|
+
const reportResponse = yield this.request({
|
|
61
|
+
methodName: `frappe.desk.query_report.run`,
|
|
62
|
+
body: Object.assign({ report_name: reportName }, body),
|
|
63
|
+
requestMethod: "POST",
|
|
64
|
+
responseValidationModel,
|
|
65
|
+
});
|
|
66
|
+
return reportResponse === null || reportResponse === void 0 ? void 0 : reportResponse.result.filter((r) => !(0, lodash_1.isArray)(r));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
getEnqueuedReport(reportName, body, enqueuedReportName, reportRowModel) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
var _a;
|
|
73
|
+
for (let i = 0; i < 100; i++) {
|
|
74
|
+
const responseValidationModel = (0, Report_1.Report)(reportRowModel !== null && reportRowModel !== void 0 ? reportRowModel : zod_1.z.any());
|
|
75
|
+
const reportResponse = yield this.request({
|
|
76
|
+
methodName: `frappe.desk.query_report.run`,
|
|
77
|
+
body: Object.assign({ report_name: reportName }, body),
|
|
78
|
+
requestMethod: "POST",
|
|
79
|
+
responseValidationModel: zod_1.z.any(),
|
|
80
|
+
});
|
|
81
|
+
// Casting to correct type since Typescript is not able to infer the type correctly.
|
|
82
|
+
// Type safety is ensured by zod
|
|
83
|
+
if ((reportResponse === null || reportResponse === void 0 ? void 0 : reportResponse.result) &&
|
|
84
|
+
((_a = reportResponse === null || reportResponse === void 0 ? void 0 : reportResponse.doc) === null || _a === void 0 ? void 0 : _a.name) === enqueuedReportName) {
|
|
85
|
+
const validatedReponse = responseValidationModel.parse(reportResponse);
|
|
86
|
+
return validatedReponse === null || validatedReponse === void 0 ? void 0 : validatedReponse.result.filter((r) => !(0, lodash_1.isArray)(r));
|
|
87
|
+
}
|
|
88
|
+
yield (0, utils_1.timeout)(1000);
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`Failed to get report ${reportName} with body ${JSON.stringify(body)}`);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
enqueueAndGetReport(reportName, body, reportRowModel) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
var _a;
|
|
96
|
+
const result = yield this.enqueueReport(reportName, body);
|
|
97
|
+
const { name } = result;
|
|
98
|
+
for (let i = 0; i < 100; i++) {
|
|
99
|
+
const responseValidationModel = (0, Report_1.Report)(reportRowModel !== null && reportRowModel !== void 0 ? reportRowModel : zod_1.z.any());
|
|
100
|
+
const reportResponse = yield this.request({
|
|
101
|
+
methodName: `frappe.desk.query_report.run`,
|
|
102
|
+
body: Object.assign({ report_name: reportName }, body),
|
|
103
|
+
requestMethod: "POST",
|
|
104
|
+
responseValidationModel,
|
|
105
|
+
});
|
|
106
|
+
// Casting to correct type since Typescript is not able to infer the type correctly.
|
|
107
|
+
// Type safety is ensured by zod
|
|
108
|
+
if ((reportResponse === null || reportResponse === void 0 ? void 0 : reportResponse.result) && ((_a = reportResponse === null || reportResponse === void 0 ? void 0 : reportResponse.doc) === null || _a === void 0 ? void 0 : _a.name) === name)
|
|
109
|
+
return reportResponse === null || reportResponse === void 0 ? void 0 : reportResponse.result.filter((r) => !(0, lodash_1.isArray)(r));
|
|
110
|
+
yield (0, utils_1.timeout)(1000);
|
|
111
|
+
}
|
|
112
|
+
throw new Error(`Failed to get report ${reportName} with body ${JSON.stringify(body)}`);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.ERPNextReports = ERPNextReports;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { StockEntry } from "./erpnext/model/StockEntry";
|
|
|
22
22
|
import { StockReconciliation } from "./erpnext/model/StockReconciliation";
|
|
23
23
|
import { Supplier } from "./erpnext/model/Supplier";
|
|
24
24
|
import { Waitlist } from "./erpnext/model/Waitlist";
|
|
25
|
+
import { ERPNextReports } from "./erpnext/reports";
|
|
25
26
|
import { ERPNextResourceRequest } from "./erpnext/resourceRequest";
|
|
26
27
|
export declare class ERPNextQueueClient {
|
|
27
28
|
temporalClient: TemporalClient;
|
|
@@ -46,6 +47,7 @@ export declare class ERPNextQueueClient {
|
|
|
46
47
|
paymentEntry: ERPNextDoctypeSubmittableResourceRequest<typeof PaymentEntry>;
|
|
47
48
|
stockReconciliation: ERPNextDoctypeSubmittableResourceRequest<typeof StockReconciliation>;
|
|
48
49
|
stock: ERPNextStock;
|
|
50
|
+
reports: ERPNextReports;
|
|
49
51
|
productBundle: ERPNextDoctypeResourceRequest<typeof ProductBundle>;
|
|
50
52
|
/**
|
|
51
53
|
* @description Provide either a temporal client or connection details to create a new client
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const StockEntry_1 = require("./erpnext/model/StockEntry");
|
|
|
25
25
|
const StockReconciliation_1 = require("./erpnext/model/StockReconciliation");
|
|
26
26
|
const Supplier_1 = require("./erpnext/model/Supplier");
|
|
27
27
|
const Waitlist_1 = require("./erpnext/model/Waitlist");
|
|
28
|
+
const reports_1 = require("./erpnext/reports");
|
|
28
29
|
const resourceRequest_1 = require("./erpnext/resourceRequest");
|
|
29
30
|
class ERPNextQueueClient {
|
|
30
31
|
/**
|
|
@@ -56,6 +57,7 @@ class ERPNextQueueClient {
|
|
|
56
57
|
this.supplier = new doctypeResourceRequest_1.ERPNextDoctypeResourceRequest(this.temporalClient, "Supplier", Supplier_1.Supplier);
|
|
57
58
|
this.paymentEntry = new doctypeSubmittableResourceRequest_1.ERPNextDoctypeSubmittableResourceRequest(this.temporalClient, "Payment Entry", PaymentEntry_1.PaymentEntry);
|
|
58
59
|
this.stockReconciliation = new doctypeSubmittableResourceRequest_1.ERPNextDoctypeSubmittableResourceRequest(this.temporalClient, "Stock Reconciliation", StockReconciliation_1.StockReconciliation);
|
|
60
|
+
this.reports = new reports_1.ERPNextReports(this.temporalClient);
|
|
59
61
|
this.stock = new stock_1.ERPNextStock(this.temporalClient);
|
|
60
62
|
this.productBundle = new doctypeResourceRequest_1.ERPNextDoctypeResourceRequest(this.temporalClient, "Product Bundle", ProductBundle_1.ProductBundle);
|
|
61
63
|
}
|