@floristcloud/api-lib 1.2.55 → 1.2.56
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/build/commands/report/export-sales-by-client.query.js +11 -21
- package/build/commands/report/export-sales-by-position.query.js +31 -0
- package/build/commands/report/index.js +1 -0
- package/build/constant/error.js +1 -0
- package/build/enum/index.js +1 -0
- package/build/enum/sales-by-position-group-by.enum.js +8 -0
- package/commands/report/export-sales-by-client.query.ts +15 -30
- package/commands/report/export-sales-by-position.query.ts +33 -0
- package/commands/report/index.ts +1 -0
- package/constant/error.ts +1 -0
- package/enum/index.ts +1 -0
- package/enum/sales-by-position-group-by.enum.ts +4 -0
- package/package.json +1 -1
|
@@ -5,32 +5,22 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const date_helper_1 = require("../../helpers/date.helper");
|
|
6
6
|
const ExportSalesByClientRequestSchema = zod_1.z
|
|
7
7
|
.object({
|
|
8
|
-
startDate: zod_1.z.coerce.date()
|
|
9
|
-
endDate: zod_1.z.coerce.date()
|
|
8
|
+
startDate: zod_1.z.coerce.date(),
|
|
9
|
+
endDate: zod_1.z.coerce.date(),
|
|
10
10
|
})
|
|
11
|
-
.refine(value => {
|
|
12
|
-
const { startDate, endDate } = value;
|
|
13
|
-
if (startDate && endDate) {
|
|
14
|
-
return (0, date_helper_1.dateRangeCheck)(startDate, endDate);
|
|
15
|
-
}
|
|
16
|
-
return true;
|
|
17
|
-
}, {
|
|
11
|
+
.refine(value => (0, date_helper_1.dateRangeCheck)(value.startDate, value.endDate), {
|
|
18
12
|
message: 'End date must be greater than start date',
|
|
19
13
|
path: ['endDate', 'startDate'],
|
|
14
|
+
})
|
|
15
|
+
.refine(value => (0, date_helper_1.isStatementPeriodWithinLimit)(value.startDate, value.endDate), {
|
|
16
|
+
message: 'Report period must not exceed 1 year',
|
|
17
|
+
path: ['endDate', 'startDate'],
|
|
20
18
|
});
|
|
21
19
|
const ExportSalesByClientResponseSchema = zod_1.z.object({
|
|
22
|
-
data: zod_1.z.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
totalOrders: zod_1.z.number(),
|
|
27
|
-
soldUnits: zod_1.z.number(),
|
|
28
|
-
totalSales: zod_1.z.number(),
|
|
29
|
-
avgCheck: zod_1.z.number(),
|
|
30
|
-
totalWriteOff: zod_1.z.number(),
|
|
31
|
-
grossProfit: zod_1.z.number(),
|
|
32
|
-
marginality: zod_1.z.number(),
|
|
33
|
-
})),
|
|
20
|
+
data: zod_1.z.object({
|
|
21
|
+
fileUrl: zod_1.z.string(),
|
|
22
|
+
fileKey: zod_1.z.string(),
|
|
23
|
+
}),
|
|
34
24
|
});
|
|
35
25
|
var ExportSalesByClientContractQuery;
|
|
36
26
|
(function (ExportSalesByClientContractQuery) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExportSalesByPositionContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const date_helper_1 = require("../../helpers/date.helper");
|
|
6
|
+
const sales_by_position_group_by_enum_1 = require("../../enum/sales-by-position-group-by.enum");
|
|
7
|
+
const ExportSalesByPositionRequestSchema = zod_1.z
|
|
8
|
+
.object({
|
|
9
|
+
startDate: zod_1.z.coerce.date(),
|
|
10
|
+
endDate: zod_1.z.coerce.date(),
|
|
11
|
+
groupBy: zod_1.z.nativeEnum(sales_by_position_group_by_enum_1.SalesByPositionGroupByEnum).default(sales_by_position_group_by_enum_1.SalesByPositionGroupByEnum.PRODUCT),
|
|
12
|
+
})
|
|
13
|
+
.refine(value => (0, date_helper_1.dateRangeCheck)(value.startDate, value.endDate), {
|
|
14
|
+
message: 'End date must be greater than start date',
|
|
15
|
+
path: ['endDate', 'startDate'],
|
|
16
|
+
})
|
|
17
|
+
.refine(value => (0, date_helper_1.isStatementPeriodWithinLimit)(value.startDate, value.endDate), {
|
|
18
|
+
message: 'Report period must not exceed 1 year',
|
|
19
|
+
path: ['endDate', 'startDate'],
|
|
20
|
+
});
|
|
21
|
+
const ExportSalesByPositionResponseSchema = zod_1.z.object({
|
|
22
|
+
data: zod_1.z.object({
|
|
23
|
+
fileUrl: zod_1.z.string(),
|
|
24
|
+
fileKey: zod_1.z.string(),
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
var ExportSalesByPositionContractQuery;
|
|
28
|
+
(function (ExportSalesByPositionContractQuery) {
|
|
29
|
+
ExportSalesByPositionContractQuery.RequestSchema = ExportSalesByPositionRequestSchema;
|
|
30
|
+
ExportSalesByPositionContractQuery.ResponseSchema = ExportSalesByPositionResponseSchema;
|
|
31
|
+
})(ExportSalesByPositionContractQuery || (exports.ExportSalesByPositionContractQuery = ExportSalesByPositionContractQuery = {}));
|
|
@@ -19,6 +19,7 @@ __exportStar(require("./get-report-group-by-client.query"), exports);
|
|
|
19
19
|
__exportStar(require("./get-report-group-by-position.query"), exports);
|
|
20
20
|
__exportStar(require("./export-sales-revenue.query"), exports);
|
|
21
21
|
__exportStar(require("./export-sales-by-client.query"), exports);
|
|
22
|
+
__exportStar(require("./export-sales-by-position.query"), exports);
|
|
22
23
|
__exportStar(require("./export-inventory-stock.query"), exports);
|
|
23
24
|
__exportStar(require("./export-inventory-movement.query"), exports);
|
|
24
25
|
__exportStar(require("./export-inventory-turnover.query"), exports);
|
package/build/constant/error.js
CHANGED
|
@@ -96,6 +96,7 @@ exports.ERRORS = {
|
|
|
96
96
|
USER_ROLE_MISMATCH_EMPLOYEE: { code: 'U014', message: 'User does not have employee role required for employee login', httpCode: 403 },
|
|
97
97
|
USER_CANNOT_DEACTIVATE_SELF: { code: 'U015', message: 'You cannot deactivate your own account', httpCode: 400 },
|
|
98
98
|
USER_CANNOT_REMOVE_OWN_ADMIN_ROLE: { code: 'U016', message: 'You cannot remove the ADMIN role from your own account', httpCode: 400 },
|
|
99
|
+
USER_CANNOT_REMOVE_LAST_ADMIN: { code: 'U017', message: 'The company must keep at least one active administrator', httpCode: 400 },
|
|
99
100
|
//AUTH
|
|
100
101
|
FAILED_TO_UPDATE: { code: 'A010', message: 'User update failed', httpCode: 500 },
|
|
101
102
|
RESTORE_TOKEN_ERROR: { code: 'A012', message: 'Invalid recovery token', httpCode: 500 },
|
package/build/enum/index.js
CHANGED
|
@@ -61,6 +61,7 @@ __exportStar(require("./write-off-status.enum"), exports);
|
|
|
61
61
|
__exportStar(require("./position-report-type.enum"), exports);
|
|
62
62
|
__exportStar(require("./discount-price-routing.enum"), exports);
|
|
63
63
|
__exportStar(require("./sales-unit.enum"), exports);
|
|
64
|
+
__exportStar(require("./sales-by-position-group-by.enum"), exports);
|
|
64
65
|
__exportStar(require("./client-import-entity-property.enum"), exports);
|
|
65
66
|
__exportStar(require("./client-import-errors.enum"), exports);
|
|
66
67
|
__exportStar(require("./pre-order-collection-item-import-entity-property.enum"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SalesByPositionGroupByEnum = void 0;
|
|
4
|
+
var SalesByPositionGroupByEnum;
|
|
5
|
+
(function (SalesByPositionGroupByEnum) {
|
|
6
|
+
SalesByPositionGroupByEnum["CATEGORY"] = "CATEGORY";
|
|
7
|
+
SalesByPositionGroupByEnum["PRODUCT"] = "PRODUCT";
|
|
8
|
+
})(SalesByPositionGroupByEnum || (exports.SalesByPositionGroupByEnum = SalesByPositionGroupByEnum = {}));
|
|
@@ -1,40 +1,25 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { dateRangeCheck } from '../../helpers/date.helper';
|
|
2
|
+
import { dateRangeCheck, isStatementPeriodWithinLimit } from '../../helpers/date.helper';
|
|
3
3
|
|
|
4
4
|
const ExportSalesByClientRequestSchema = z
|
|
5
5
|
.object({
|
|
6
|
-
startDate: z.coerce.date()
|
|
7
|
-
endDate: z.coerce.date()
|
|
6
|
+
startDate: z.coerce.date(),
|
|
7
|
+
endDate: z.coerce.date(),
|
|
8
8
|
})
|
|
9
|
-
.refine(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
message: 'End date must be greater than start date',
|
|
19
|
-
path: ['endDate', 'startDate'],
|
|
20
|
-
},
|
|
21
|
-
);
|
|
9
|
+
.refine(value => dateRangeCheck(value.startDate, value.endDate), {
|
|
10
|
+
message: 'End date must be greater than start date',
|
|
11
|
+
path: ['endDate', 'startDate'],
|
|
12
|
+
})
|
|
13
|
+
.refine(value => isStatementPeriodWithinLimit(value.startDate, value.endDate), {
|
|
14
|
+
message: 'Report period must not exceed 1 year',
|
|
15
|
+
path: ['endDate', 'startDate'],
|
|
16
|
+
});
|
|
22
17
|
|
|
23
18
|
const ExportSalesByClientResponseSchema = z.object({
|
|
24
|
-
data: z.
|
|
25
|
-
z.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
responsibleUserName: z.string().optional(),
|
|
29
|
-
totalOrders: z.number(),
|
|
30
|
-
soldUnits: z.number(),
|
|
31
|
-
totalSales: z.number(),
|
|
32
|
-
avgCheck: z.number(),
|
|
33
|
-
totalWriteOff: z.number(),
|
|
34
|
-
grossProfit: z.number(),
|
|
35
|
-
marginality: z.number(),
|
|
36
|
-
}),
|
|
37
|
-
),
|
|
19
|
+
data: z.object({
|
|
20
|
+
fileUrl: z.string(),
|
|
21
|
+
fileKey: z.string(),
|
|
22
|
+
}),
|
|
38
23
|
});
|
|
39
24
|
|
|
40
25
|
export namespace ExportSalesByClientContractQuery {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { dateRangeCheck, isStatementPeriodWithinLimit } from '../../helpers/date.helper';
|
|
3
|
+
import { SalesByPositionGroupByEnum } from '../../enum/sales-by-position-group-by.enum';
|
|
4
|
+
|
|
5
|
+
const ExportSalesByPositionRequestSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
startDate: z.coerce.date(),
|
|
8
|
+
endDate: z.coerce.date(),
|
|
9
|
+
groupBy: z.nativeEnum(SalesByPositionGroupByEnum).default(SalesByPositionGroupByEnum.PRODUCT),
|
|
10
|
+
})
|
|
11
|
+
.refine(value => dateRangeCheck(value.startDate, value.endDate), {
|
|
12
|
+
message: 'End date must be greater than start date',
|
|
13
|
+
path: ['endDate', 'startDate'],
|
|
14
|
+
})
|
|
15
|
+
.refine(value => isStatementPeriodWithinLimit(value.startDate, value.endDate), {
|
|
16
|
+
message: 'Report period must not exceed 1 year',
|
|
17
|
+
path: ['endDate', 'startDate'],
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const ExportSalesByPositionResponseSchema = z.object({
|
|
21
|
+
data: z.object({
|
|
22
|
+
fileUrl: z.string(),
|
|
23
|
+
fileKey: z.string(),
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export namespace ExportSalesByPositionContractQuery {
|
|
28
|
+
export const RequestSchema = ExportSalesByPositionRequestSchema;
|
|
29
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
30
|
+
|
|
31
|
+
export const ResponseSchema = ExportSalesByPositionResponseSchema;
|
|
32
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
33
|
+
}
|
package/commands/report/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './get-report-group-by-client.query';
|
|
|
3
3
|
export * from './get-report-group-by-position.query';
|
|
4
4
|
export * from './export-sales-revenue.query';
|
|
5
5
|
export * from './export-sales-by-client.query';
|
|
6
|
+
export * from './export-sales-by-position.query';
|
|
6
7
|
export * from './export-inventory-stock.query';
|
|
7
8
|
export * from './export-inventory-movement.query';
|
|
8
9
|
export * from './export-inventory-turnover.query';
|
package/constant/error.ts
CHANGED
|
@@ -99,6 +99,7 @@ export const ERRORS = {
|
|
|
99
99
|
USER_ROLE_MISMATCH_EMPLOYEE: { code: 'U014', message: 'User does not have employee role required for employee login', httpCode: 403 },
|
|
100
100
|
USER_CANNOT_DEACTIVATE_SELF: { code: 'U015', message: 'You cannot deactivate your own account', httpCode: 400 },
|
|
101
101
|
USER_CANNOT_REMOVE_OWN_ADMIN_ROLE: { code: 'U016', message: 'You cannot remove the ADMIN role from your own account', httpCode: 400 },
|
|
102
|
+
USER_CANNOT_REMOVE_LAST_ADMIN: { code: 'U017', message: 'The company must keep at least one active administrator', httpCode: 400 },
|
|
102
103
|
|
|
103
104
|
//AUTH
|
|
104
105
|
FAILED_TO_UPDATE: { code: 'A010', message: 'User update failed', httpCode: 500 },
|
package/enum/index.ts
CHANGED
|
@@ -45,6 +45,7 @@ export * from './write-off-status.enum';
|
|
|
45
45
|
export * from './position-report-type.enum';
|
|
46
46
|
export * from './discount-price-routing.enum';
|
|
47
47
|
export * from './sales-unit.enum';
|
|
48
|
+
export * from './sales-by-position-group-by.enum';
|
|
48
49
|
export * from './client-import-entity-property.enum';
|
|
49
50
|
export * from './client-import-errors.enum';
|
|
50
51
|
export * from './pre-order-collection-item-import-entity-property.enum';
|