@floristcloud/api-lib 1.2.189 → 1.2.191
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/get-write-off-breakdown.query.js +10 -0
- package/build/commands/report/get-write-off-by-client.query.js +10 -0
- package/build/commands/report/get-write-off-summary.query.js +4 -76
- package/build/commands/report/index.js +2 -0
- package/build/constant/error.js +7 -0
- package/build/constant/report.constant.js +7 -1
- package/build/enum/index.js +1 -0
- package/build/enum/write-off-breakdown-group-by.enum.js +18 -0
- package/build/schemas/report/get-write-off-breakdown-request.schema.js +26 -0
- package/build/schemas/report/get-write-off-breakdown-response-data.schema.js +12 -0
- package/build/schemas/report/get-write-off-breakdown-response.schema.js +9 -0
- package/build/schemas/report/get-write-off-by-client-request.schema.js +29 -0
- package/build/schemas/report/get-write-off-by-client-response-data.schema.js +12 -0
- package/build/schemas/report/get-write-off-by-client-response.schema.js +9 -0
- package/build/schemas/report/get-write-off-summary-request.schema.js +34 -0
- package/build/schemas/report/get-write-off-summary-response-data.schema.js +12 -0
- package/build/schemas/report/get-write-off-summary-response.schema.js +9 -0
- package/build/schemas/report/index.js +25 -0
- package/build/schemas/report/write-off-breakdown-category-row.schema.js +9 -0
- package/build/schemas/report/write-off-breakdown-consignment-row.schema.js +11 -0
- package/build/schemas/report/write-off-breakdown-consignment.schema.js +11 -0
- package/build/schemas/report/write-off-breakdown-grower-row.schema.js +9 -0
- package/build/schemas/report/write-off-breakdown-reason-row.schema.js +9 -0
- package/build/schemas/report/write-off-breakdown-row-base.schema.js +21 -0
- package/build/schemas/report/write-off-breakdown-row.schema.js +15 -0
- package/build/schemas/report/write-off-breakdown-totals.schema.js +18 -0
- package/build/schemas/report/write-off-by-client-row.schema.js +21 -0
- package/build/schemas/report/write-off-by-client-totals.schema.js +20 -0
- package/build/schemas/report/write-off-report-page.schema.js +13 -0
- package/build/schemas/report/write-off-summary-by-client.schema.js +18 -0
- package/build/schemas/report/write-off-summary-client-row.schema.js +13 -0
- package/build/schemas/report/write-off-summary-reason-row.schema.js +12 -0
- package/build/schemas/report/write-off-summary-totals.schema.js +18 -0
- package/build/schemas/report/write-off-summary-warehouse.schema.js +12 -0
- package/commands/report/get-write-off-breakdown.query.ts +11 -0
- package/commands/report/get-write-off-by-client.query.ts +11 -0
- package/commands/report/get-write-off-summary.query.ts +3 -82
- package/commands/report/index.ts +2 -0
- package/constant/error.ts +7 -0
- package/constant/report.constant.ts +8 -0
- package/enum/index.ts +1 -0
- package/enum/write-off-breakdown-group-by.enum.ts +14 -0
- package/package.json +1 -1
- package/schemas/report/get-write-off-breakdown-request.schema.ts +26 -0
- package/schemas/report/get-write-off-breakdown-response-data.schema.ts +10 -0
- package/schemas/report/get-write-off-breakdown-response.schema.ts +7 -0
- package/schemas/report/get-write-off-by-client-request.schema.ts +27 -0
- package/schemas/report/get-write-off-by-client-response-data.schema.ts +10 -0
- package/schemas/report/get-write-off-by-client-response.schema.ts +7 -0
- package/schemas/report/get-write-off-summary-request.schema.ts +36 -0
- package/schemas/report/get-write-off-summary-response-data.schema.ts +10 -0
- package/schemas/report/get-write-off-summary-response.schema.ts +7 -0
- package/schemas/report/index.ts +25 -0
- package/schemas/report/write-off-breakdown-category-row.schema.ts +7 -0
- package/schemas/report/write-off-breakdown-consignment-row.schema.ts +9 -0
- package/schemas/report/write-off-breakdown-consignment.schema.ts +9 -0
- package/schemas/report/write-off-breakdown-grower-row.schema.ts +7 -0
- package/schemas/report/write-off-breakdown-reason-row.schema.ts +7 -0
- package/schemas/report/write-off-breakdown-row-base.schema.ts +19 -0
- package/schemas/report/write-off-breakdown-row.schema.ts +13 -0
- package/schemas/report/write-off-breakdown-totals.schema.ts +16 -0
- package/schemas/report/write-off-by-client-row.schema.ts +19 -0
- package/schemas/report/write-off-by-client-totals.schema.ts +18 -0
- package/schemas/report/write-off-report-page.schema.ts +11 -0
- package/schemas/report/write-off-summary-by-client.schema.ts +16 -0
- package/schemas/report/write-off-summary-client-row.schema.ts +11 -0
- package/schemas/report/write-off-summary-reason-row.schema.ts +10 -0
- package/schemas/report/write-off-summary-totals.schema.ts +16 -0
- package/schemas/report/write-off-summary-warehouse.schema.ts +10 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffBreakdownContractQuery = void 0;
|
|
4
|
+
const get_write_off_breakdown_request_schema_1 = require("../../schemas/report/get-write-off-breakdown-request.schema");
|
|
5
|
+
const get_write_off_breakdown_response_schema_1 = require("../../schemas/report/get-write-off-breakdown-response.schema");
|
|
6
|
+
var GetWriteOffBreakdownContractQuery;
|
|
7
|
+
(function (GetWriteOffBreakdownContractQuery) {
|
|
8
|
+
GetWriteOffBreakdownContractQuery.RequestSchema = get_write_off_breakdown_request_schema_1.GetWriteOffBreakdownRequestSchema;
|
|
9
|
+
GetWriteOffBreakdownContractQuery.ResponseSchema = get_write_off_breakdown_response_schema_1.GetWriteOffBreakdownResponseSchema;
|
|
10
|
+
})(GetWriteOffBreakdownContractQuery || (exports.GetWriteOffBreakdownContractQuery = GetWriteOffBreakdownContractQuery = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffByClientContractQuery = void 0;
|
|
4
|
+
const get_write_off_by_client_request_schema_1 = require("../../schemas/report/get-write-off-by-client-request.schema");
|
|
5
|
+
const get_write_off_by_client_response_schema_1 = require("../../schemas/report/get-write-off-by-client-response.schema");
|
|
6
|
+
var GetWriteOffByClientContractQuery;
|
|
7
|
+
(function (GetWriteOffByClientContractQuery) {
|
|
8
|
+
GetWriteOffByClientContractQuery.RequestSchema = get_write_off_by_client_request_schema_1.GetWriteOffByClientRequestSchema;
|
|
9
|
+
GetWriteOffByClientContractQuery.ResponseSchema = get_write_off_by_client_response_schema_1.GetWriteOffByClientResponseSchema;
|
|
10
|
+
})(GetWriteOffByClientContractQuery || (exports.GetWriteOffByClientContractQuery = GetWriteOffByClientContractQuery = {}));
|
|
@@ -1,82 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetWriteOffSummaryContractQuery = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const money_schema_1 = require("../../schemas/money.schema");
|
|
7
|
-
const write_off_report_date_basis_enum_1 = require("../../enum/write-off-report-date-basis.enum");
|
|
8
|
-
const report_constant_1 = require("../../constant/report.constant");
|
|
9
|
-
const GetWriteOffSummaryRequestSchema = zod_1.z
|
|
10
|
-
.object({
|
|
11
|
-
startDate: zod_1.z.coerce.date(),
|
|
12
|
-
endDate: zod_1.z.coerce.date(),
|
|
13
|
-
dateBasis: zod_1.z.nativeEnum(write_off_report_date_basis_enum_1.WriteOffReportDateBasisEnum).default(write_off_report_date_basis_enum_1.WriteOffReportDateBasisEnum.WRITE_OFF_DATE),
|
|
14
|
-
// Тот же формат, что в ReportOrderFilterSchema: CSV или повтор параметра. Применяется
|
|
15
|
-
// только к разрезу по клиентам — у складских списаний клиента нет.
|
|
16
|
-
excludeClientUUID: zod_1.z
|
|
17
|
-
.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())])
|
|
18
|
-
.transform(value => (Array.isArray(value) ? value : value.split(',')).map(item => item.trim()).filter(Boolean))
|
|
19
|
-
.pipe(zod_1.z.array(zod_1.z.string().uuid()).max(report_constant_1.REPORT_EXCLUDE_CLIENT_LIMIT))
|
|
20
|
-
.optional(),
|
|
21
|
-
clientLimit: zod_1.z.coerce
|
|
22
|
-
.number()
|
|
23
|
-
.int()
|
|
24
|
-
.positive()
|
|
25
|
-
.max(report_constant_1.REPORT_WRITE_OFF_CLIENT_LIMIT_MAX)
|
|
26
|
-
.default(report_constant_1.REPORT_WRITE_OFF_CLIENT_LIMIT_DEFAULT),
|
|
27
|
-
})
|
|
28
|
-
.refine(value => (0, date_helper_1.dateRangeCheck)(value.startDate, value.endDate), {
|
|
29
|
-
message: 'validation.dateRange',
|
|
30
|
-
path: ['endDate', 'startDate'],
|
|
31
|
-
})
|
|
32
|
-
.refine(value => (0, date_helper_1.isStatementPeriodWithinLimit)(value.startDate, value.endDate), {
|
|
33
|
-
message: 'validation.reportPeriodMax',
|
|
34
|
-
path: ['endDate', 'startDate'],
|
|
35
|
-
});
|
|
36
|
-
const WriteOffSummaryReasonRowSchema = zod_1.z.object({
|
|
37
|
-
// Свободный текст из справочника причин, схлопнут только по краевым пробелам (TRIM).
|
|
38
|
-
// Регистр не нормализуем: «Брак» и «брак» останутся разными строками.
|
|
39
|
-
reason: zod_1.z.string(),
|
|
40
|
-
units: zod_1.z.number(),
|
|
41
|
-
cost: money_schema_1.MoneySchema,
|
|
42
|
-
});
|
|
43
|
-
const WriteOffSummaryClientRowSchema = zod_1.z.object({
|
|
44
|
-
clientUUID: zod_1.z.string(),
|
|
45
|
-
clientName: zod_1.z.string(),
|
|
46
|
-
orderCount: zod_1.z.number(),
|
|
47
|
-
units: zod_1.z.number(),
|
|
48
|
-
cost: money_schema_1.MoneySchema,
|
|
49
|
-
orderAmount: money_schema_1.MoneySchema,
|
|
50
|
-
});
|
|
51
|
-
const GetWriteOffSummaryResponseSchema = zod_1.z.object({
|
|
52
|
-
message: zod_1.z.string().optional(),
|
|
53
|
-
data: zod_1.z.object({
|
|
54
|
-
// totals = warehouse + byClient, считается по всем строкам — усечение `clientLimit`
|
|
55
|
-
// на итоги не влияет.
|
|
56
|
-
totals: zod_1.z.object({
|
|
57
|
-
units: zod_1.z.number(),
|
|
58
|
-
cost: money_schema_1.MoneySchema,
|
|
59
|
-
}),
|
|
60
|
-
// Списания без заказа: до этого отчёта они не попадали ни в одну сводку.
|
|
61
|
-
warehouse: zod_1.z.object({
|
|
62
|
-
units: zod_1.z.number(),
|
|
63
|
-
cost: money_schema_1.MoneySchema,
|
|
64
|
-
byReason: WriteOffSummaryReasonRowSchema.array(),
|
|
65
|
-
}),
|
|
66
|
-
// Списания по заказу: клиенту они уже вернулись на баланс, то есть это выручка,
|
|
67
|
-
// которой по факту не было.
|
|
68
|
-
byClient: zod_1.z.object({
|
|
69
|
-
units: zod_1.z.number(),
|
|
70
|
-
cost: money_schema_1.MoneySchema,
|
|
71
|
-
orderAmount: money_schema_1.MoneySchema,
|
|
72
|
-
rows: WriteOffSummaryClientRowSchema.array(),
|
|
73
|
-
// Сколько клиентов всего — чтобы отличить усечённый ответ от полного.
|
|
74
|
-
rowsTotal: zod_1.z.number(),
|
|
75
|
-
}),
|
|
76
|
-
}),
|
|
77
|
-
});
|
|
4
|
+
const get_write_off_summary_request_schema_1 = require("../../schemas/report/get-write-off-summary-request.schema");
|
|
5
|
+
const get_write_off_summary_response_schema_1 = require("../../schemas/report/get-write-off-summary-response.schema");
|
|
78
6
|
var GetWriteOffSummaryContractQuery;
|
|
79
7
|
(function (GetWriteOffSummaryContractQuery) {
|
|
80
|
-
GetWriteOffSummaryContractQuery.RequestSchema = GetWriteOffSummaryRequestSchema;
|
|
81
|
-
GetWriteOffSummaryContractQuery.ResponseSchema = GetWriteOffSummaryResponseSchema;
|
|
8
|
+
GetWriteOffSummaryContractQuery.RequestSchema = get_write_off_summary_request_schema_1.GetWriteOffSummaryRequestSchema;
|
|
9
|
+
GetWriteOffSummaryContractQuery.ResponseSchema = get_write_off_summary_response_schema_1.GetWriteOffSummaryResponseSchema;
|
|
82
10
|
})(GetWriteOffSummaryContractQuery || (exports.GetWriteOffSummaryContractQuery = GetWriteOffSummaryContractQuery = {}));
|
|
@@ -29,6 +29,8 @@ __exportStar(require("./get-report-by-client-weeks.query"), exports);
|
|
|
29
29
|
__exportStar(require("./get-daily-orders-summary.query"), exports);
|
|
30
30
|
__exportStar(require("./get-cash-flow.query"), exports);
|
|
31
31
|
__exportStar(require("./get-write-off-summary.query"), exports);
|
|
32
|
+
__exportStar(require("./get-write-off-breakdown.query"), exports);
|
|
33
|
+
__exportStar(require("./get-write-off-by-client.query"), exports);
|
|
32
34
|
__exportStar(require("./get-inventory-stock.query"), exports);
|
|
33
35
|
__exportStar(require("./get-inventory-turnover.query"), exports);
|
|
34
36
|
__exportStar(require("./get-sales-by-client.query"), exports);
|
package/build/constant/error.js
CHANGED
|
@@ -1499,6 +1499,8 @@ exports.ERRORS = {
|
|
|
1499
1499
|
REPORT_EXPORT_FAILED: { code: 'REP002', message: 'Failed to export report', httpCode: 500 },
|
|
1500
1500
|
REPORT_NO_DATA: { code: 'REP003', message: 'No data available for the selected period', httpCode: 404 },
|
|
1501
1501
|
WRITE_OFF_SUMMARY_REPORT_FAILED: { code: 'REP004', message: 'Failed to build write-off summary report', httpCode: 500 },
|
|
1502
|
+
WRITE_OFF_BREAKDOWN_REPORT_FAILED: { code: 'REP005', message: 'Failed to build write-off breakdown report', httpCode: 500 },
|
|
1503
|
+
WRITE_OFF_BY_CLIENT_REPORT_FAILED: { code: 'REP006', message: 'Failed to build write-off by client report', httpCode: 500 },
|
|
1502
1504
|
STATEMENT_PERIOD_TOO_LONG: { code: 'REP004', message: 'Statement period must not exceed 1 year', httpCode: 400 },
|
|
1503
1505
|
// PAYMENT INVOICE
|
|
1504
1506
|
PAYMENT_INVOICE_CREATE_FAILED: { code: 'PINV001', message: 'Failed to create payment invoice', httpCode: 500 },
|
|
@@ -1775,6 +1777,10 @@ exports.ERRORS = {
|
|
|
1775
1777
|
message: 'Product stock cannot be recomputed: it is not in the 1C sync consignment',
|
|
1776
1778
|
httpCode: 409,
|
|
1777
1779
|
},
|
|
1780
|
+
// Файл обмена больше ONE_C_MAX_EXCHANGE_FILE_BYTES: тело сбрасывается без чтения в память.
|
|
1781
|
+
ONE_C_EXCHANGE_FILE_TOO_LARGE: { code: 'OC024', message: '1C exchange file exceeds the size limit', httpCode: 413 },
|
|
1782
|
+
// Приём каталога выключен на интеграции (CompanyIntegration.isCatalogExchangeEnabled), обмен заказами продолжается.
|
|
1783
|
+
ONE_C_CATALOG_EXCHANGE_DISABLED: { code: 'OC025', message: '1C catalog exchange is disabled for this company', httpCode: 409 },
|
|
1778
1784
|
// COMPANY INTEGRATION (общая запись интеграции компании)
|
|
1779
1785
|
COMPANY_INTEGRATION_FETCH_FAILED: { code: 'CINT001', message: 'Failed to read company integration', httpCode: 500 },
|
|
1780
1786
|
COMPANY_INTEGRATION_NOT_SAVED: { code: 'CINT002', message: 'Failed to save company integration', httpCode: 500 },
|
|
@@ -1785,6 +1791,7 @@ exports.ERRORS = {
|
|
|
1785
1791
|
message: 'The unit is not among the saved units of the company integration',
|
|
1786
1792
|
httpCode: 400,
|
|
1787
1793
|
},
|
|
1794
|
+
INTEGRATION_WAREHOUSES_NOT_SAVED: { code: 'CINT006', message: 'Failed to save integration warehouses', httpCode: 500 },
|
|
1788
1795
|
// OZEXPORT INTEGRATION (FC-513)
|
|
1789
1796
|
OZEXPORT_AUTH_FAILED: { code: 'OZ001', message: 'ozexport rejected the username or password', httpCode: 400 },
|
|
1790
1797
|
OZEXPORT_PARSER_UNAVAILABLE: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REPORT_WRITE_OFF_CLIENT_LIMIT_MAX = exports.REPORT_WRITE_OFF_CLIENT_LIMIT_DEFAULT = exports.REPORT_EXCLUDE_CLIENT_LIMIT = void 0;
|
|
3
|
+
exports.REPORT_WRITE_OFF_BREAKDOWN_LIMIT_MAX = exports.REPORT_WRITE_OFF_BREAKDOWN_LIMIT_DEFAULT = exports.REPORT_WRITE_OFF_CLIENT_LIMIT_MAX = exports.REPORT_WRITE_OFF_CLIENT_LIMIT_DEFAULT = exports.REPORT_EXCLUDE_CLIENT_LIMIT = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Потолок списка исключаемых из отчёта клиентов. Список едет в query-строке и дальше в SQL
|
|
6
6
|
* как `= ANY($n::text[])`, поэтому ограничение защищает и от переполнения URL, и от запроса
|
|
@@ -14,3 +14,9 @@ exports.REPORT_EXCLUDE_CLIENT_LIMIT = 500;
|
|
|
14
14
|
*/
|
|
15
15
|
exports.REPORT_WRITE_OFF_CLIENT_LIMIT_DEFAULT = 50;
|
|
16
16
|
exports.REPORT_WRITE_OFF_CLIENT_LIMIT_MAX = 500;
|
|
17
|
+
/**
|
|
18
|
+
* Страница строк в разрезах вкладки «Списания» (`breakdown`, `by-client`). Итоги считаются по всем
|
|
19
|
+
* строкам независимо от `limit`/`offset`; полный список фронт выбирает постранично через `offset`.
|
|
20
|
+
*/
|
|
21
|
+
exports.REPORT_WRITE_OFF_BREAKDOWN_LIMIT_DEFAULT = 50;
|
|
22
|
+
exports.REPORT_WRITE_OFF_BREAKDOWN_LIMIT_MAX = 500;
|
package/build/enum/index.js
CHANGED
|
@@ -164,6 +164,7 @@ __exportStar(require("./userRole.enum"), exports);
|
|
|
164
164
|
__exportStar(require("./userStatus.enum"), exports);
|
|
165
165
|
__exportStar(require("./webshop-main-display-mode.enum"), exports);
|
|
166
166
|
__exportStar(require("./webshop-mode.enum"), exports);
|
|
167
|
+
__exportStar(require("./write-off-breakdown-group-by.enum"), exports);
|
|
167
168
|
__exportStar(require("./write-off-report-date-basis.enum"), exports);
|
|
168
169
|
__exportStar(require("./write-off-status.enum"), exports);
|
|
169
170
|
__exportStar(require("./one-c-stock-conflict-status.enum"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffBreakdownGroupByEnum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Разрез отчёта `/report/write-off/breakdown` — по какому признаку группируются списания.
|
|
6
|
+
*
|
|
7
|
+
* `CONSIGNMENT` — партия (база процента — приход партии целиком, на любой оси периода).
|
|
8
|
+
* `GROWER` — производитель `product.grower`, без учёта регистра и краевых пробелов.
|
|
9
|
+
* `CATEGORY` — категория, снимок `write_off.category_uuid` на момент списания.
|
|
10
|
+
* `REASON` — причина, свободный текст без краевых пробелов; процента у причин нет.
|
|
11
|
+
*/
|
|
12
|
+
var WriteOffBreakdownGroupByEnum;
|
|
13
|
+
(function (WriteOffBreakdownGroupByEnum) {
|
|
14
|
+
WriteOffBreakdownGroupByEnum["CONSIGNMENT"] = "CONSIGNMENT";
|
|
15
|
+
WriteOffBreakdownGroupByEnum["GROWER"] = "GROWER";
|
|
16
|
+
WriteOffBreakdownGroupByEnum["CATEGORY"] = "CATEGORY";
|
|
17
|
+
WriteOffBreakdownGroupByEnum["REASON"] = "REASON";
|
|
18
|
+
})(WriteOffBreakdownGroupByEnum || (exports.WriteOffBreakdownGroupByEnum = WriteOffBreakdownGroupByEnum = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffBreakdownRequestSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const date_helper_1 = require("../../helpers/date.helper");
|
|
6
|
+
const write_off_breakdown_group_by_enum_1 = require("../../enum/write-off-breakdown-group-by.enum");
|
|
7
|
+
const write_off_report_date_basis_enum_1 = require("../../enum/write-off-report-date-basis.enum");
|
|
8
|
+
const report_order_filter_schema_1 = require("./report-order-filter.schema");
|
|
9
|
+
const write_off_report_page_schema_1 = require("./write-off-report-page.schema");
|
|
10
|
+
exports.GetWriteOffBreakdownRequestSchema = write_off_report_page_schema_1.WriteOffReportPageSchema.extend({
|
|
11
|
+
startDate: zod_1.z.coerce.date(),
|
|
12
|
+
endDate: zod_1.z.coerce.date(),
|
|
13
|
+
// Дефолт тот же, что у write-off/summary: один и тот же запрос без оси не должен давать разную
|
|
14
|
+
// выборку на двух эндпоинтах. Вкладка «Списания» передаёт ось явно.
|
|
15
|
+
dateBasis: zod_1.z.nativeEnum(write_off_report_date_basis_enum_1.WriteOffReportDateBasisEnum).default(write_off_report_date_basis_enum_1.WriteOffReportDateBasisEnum.WRITE_OFF_DATE),
|
|
16
|
+
groupBy: zod_1.z.nativeEnum(write_off_breakdown_group_by_enum_1.WriteOffBreakdownGroupByEnum),
|
|
17
|
+
excludeClientUUID: report_order_filter_schema_1.ReportOrderFilterSchema.shape.excludeClientUUID.describe('Clients whose order write-offs are dropped. Warehouse write-offs have no client and stay.'),
|
|
18
|
+
})
|
|
19
|
+
.refine(value => (0, date_helper_1.dateRangeCheck)(value.startDate, value.endDate), {
|
|
20
|
+
message: 'validation.dateRange',
|
|
21
|
+
path: ['endDate', 'startDate'],
|
|
22
|
+
})
|
|
23
|
+
.refine(value => (0, date_helper_1.isStatementPeriodWithinLimit)(value.startDate, value.endDate), {
|
|
24
|
+
message: 'validation.reportPeriodMax',
|
|
25
|
+
path: ['endDate', 'startDate'],
|
|
26
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffBreakdownResponseDataSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const write_off_breakdown_row_schema_1 = require("./write-off-breakdown-row.schema");
|
|
6
|
+
const write_off_breakdown_totals_schema_1 = require("./write-off-breakdown-totals.schema");
|
|
7
|
+
exports.GetWriteOffBreakdownResponseDataSchema = zod_1.z.object({
|
|
8
|
+
totals: write_off_breakdown_totals_schema_1.WriteOffBreakdownTotalsSchema,
|
|
9
|
+
rows: write_off_breakdown_row_schema_1.WriteOffBreakdownRowSchema.array(),
|
|
10
|
+
// Строк во всём разрезе — чтобы отличить страницу от полного списка.
|
|
11
|
+
rowsTotal: zod_1.z.number(),
|
|
12
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffBreakdownResponseSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const get_write_off_breakdown_response_data_schema_1 = require("./get-write-off-breakdown-response-data.schema");
|
|
6
|
+
exports.GetWriteOffBreakdownResponseSchema = zod_1.z.object({
|
|
7
|
+
message: zod_1.z.string().optional(),
|
|
8
|
+
data: get_write_off_breakdown_response_data_schema_1.GetWriteOffBreakdownResponseDataSchema,
|
|
9
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffByClientRequestSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const date_helper_1 = require("../../helpers/date.helper");
|
|
6
|
+
const report_order_date_basis_enum_1 = require("../../enum/report-order-date-basis.enum");
|
|
7
|
+
const report_order_filter_schema_1 = require("./report-order-filter.schema");
|
|
8
|
+
const write_off_report_page_schema_1 = require("./write-off-report-page.schema");
|
|
9
|
+
/**
|
|
10
|
+
* Ось разреза — заказы периода, а не списания: списание по заказу попадает сюда независимо от
|
|
11
|
+
* своей даты, иначе процент делил бы брак по заказу прошлого месяца на выручку текущего.
|
|
12
|
+
*
|
|
13
|
+
* Параметр назван `orderDateBasis`, а не `dateBasis`, как в отчётах продаж: остальные запросы
|
|
14
|
+
* вкладки шлют `dateBasis` с осью списаний, и общее имя позволило бы молча перепутать перечисления.
|
|
15
|
+
*/
|
|
16
|
+
exports.GetWriteOffByClientRequestSchema = write_off_report_page_schema_1.WriteOffReportPageSchema.extend({
|
|
17
|
+
startDate: zod_1.z.coerce.date(),
|
|
18
|
+
endDate: zod_1.z.coerce.date(),
|
|
19
|
+
orderDateBasis: zod_1.z.nativeEnum(report_order_date_basis_enum_1.ReportOrderDateBasisEnum).default(report_order_date_basis_enum_1.ReportOrderDateBasisEnum.CREATED_AT),
|
|
20
|
+
excludeClientUUID: report_order_filter_schema_1.ReportOrderFilterSchema.shape.excludeClientUUID,
|
|
21
|
+
})
|
|
22
|
+
.refine(value => (0, date_helper_1.dateRangeCheck)(value.startDate, value.endDate), {
|
|
23
|
+
message: 'validation.dateRange',
|
|
24
|
+
path: ['endDate', 'startDate'],
|
|
25
|
+
})
|
|
26
|
+
.refine(value => (0, date_helper_1.isStatementPeriodWithinLimit)(value.startDate, value.endDate), {
|
|
27
|
+
message: 'validation.reportPeriodMax',
|
|
28
|
+
path: ['endDate', 'startDate'],
|
|
29
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffByClientResponseDataSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const write_off_by_client_row_schema_1 = require("./write-off-by-client-row.schema");
|
|
6
|
+
const write_off_by_client_totals_schema_1 = require("./write-off-by-client-totals.schema");
|
|
7
|
+
exports.GetWriteOffByClientResponseDataSchema = zod_1.z.object({
|
|
8
|
+
totals: write_off_by_client_totals_schema_1.WriteOffByClientTotalsSchema,
|
|
9
|
+
rows: write_off_by_client_row_schema_1.WriteOffByClientRowSchema.array(),
|
|
10
|
+
// Клиентов со списаниями всего — чтобы отличить страницу от полного списка.
|
|
11
|
+
rowsTotal: zod_1.z.number(),
|
|
12
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffByClientResponseSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const get_write_off_by_client_response_data_schema_1 = require("./get-write-off-by-client-response-data.schema");
|
|
6
|
+
exports.GetWriteOffByClientResponseSchema = zod_1.z.object({
|
|
7
|
+
message: zod_1.z.string().optional(),
|
|
8
|
+
data: get_write_off_by_client_response_data_schema_1.GetWriteOffByClientResponseDataSchema,
|
|
9
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffSummaryRequestSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const date_helper_1 = require("../../helpers/date.helper");
|
|
6
|
+
const write_off_report_date_basis_enum_1 = require("../../enum/write-off-report-date-basis.enum");
|
|
7
|
+
const report_constant_1 = require("../../constant/report.constant");
|
|
8
|
+
exports.GetWriteOffSummaryRequestSchema = zod_1.z
|
|
9
|
+
.object({
|
|
10
|
+
startDate: zod_1.z.coerce.date(),
|
|
11
|
+
endDate: zod_1.z.coerce.date(),
|
|
12
|
+
dateBasis: zod_1.z.nativeEnum(write_off_report_date_basis_enum_1.WriteOffReportDateBasisEnum).default(write_off_report_date_basis_enum_1.WriteOffReportDateBasisEnum.WRITE_OFF_DATE),
|
|
13
|
+
// Тот же формат, что в ReportOrderFilterSchema: CSV или повтор параметра. Применяется
|
|
14
|
+
// только к разрезу по клиентам — у складских списаний клиента нет.
|
|
15
|
+
excludeClientUUID: zod_1.z
|
|
16
|
+
.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())])
|
|
17
|
+
.transform(value => (Array.isArray(value) ? value : value.split(',')).map(item => item.trim()).filter(Boolean))
|
|
18
|
+
.pipe(zod_1.z.array(zod_1.z.string().uuid()).max(report_constant_1.REPORT_EXCLUDE_CLIENT_LIMIT))
|
|
19
|
+
.optional(),
|
|
20
|
+
clientLimit: zod_1.z.coerce
|
|
21
|
+
.number()
|
|
22
|
+
.int()
|
|
23
|
+
.positive()
|
|
24
|
+
.max(report_constant_1.REPORT_WRITE_OFF_CLIENT_LIMIT_MAX)
|
|
25
|
+
.default(report_constant_1.REPORT_WRITE_OFF_CLIENT_LIMIT_DEFAULT),
|
|
26
|
+
})
|
|
27
|
+
.refine(value => (0, date_helper_1.dateRangeCheck)(value.startDate, value.endDate), {
|
|
28
|
+
message: 'validation.dateRange',
|
|
29
|
+
path: ['endDate', 'startDate'],
|
|
30
|
+
})
|
|
31
|
+
.refine(value => (0, date_helper_1.isStatementPeriodWithinLimit)(value.startDate, value.endDate), {
|
|
32
|
+
message: 'validation.reportPeriodMax',
|
|
33
|
+
path: ['endDate', 'startDate'],
|
|
34
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffSummaryResponseDataSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const write_off_summary_by_client_schema_1 = require("./write-off-summary-by-client.schema");
|
|
6
|
+
const write_off_summary_totals_schema_1 = require("./write-off-summary-totals.schema");
|
|
7
|
+
const write_off_summary_warehouse_schema_1 = require("./write-off-summary-warehouse.schema");
|
|
8
|
+
exports.GetWriteOffSummaryResponseDataSchema = zod_1.z.object({
|
|
9
|
+
totals: write_off_summary_totals_schema_1.WriteOffSummaryTotalsSchema,
|
|
10
|
+
warehouse: write_off_summary_warehouse_schema_1.WriteOffSummaryWarehouseSchema,
|
|
11
|
+
byClient: write_off_summary_by_client_schema_1.WriteOffSummaryByClientSchema,
|
|
12
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWriteOffSummaryResponseSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const get_write_off_summary_response_data_schema_1 = require("./get-write-off-summary-response-data.schema");
|
|
6
|
+
exports.GetWriteOffSummaryResponseSchema = zod_1.z.object({
|
|
7
|
+
message: zod_1.z.string().optional(),
|
|
8
|
+
data: get_write_off_summary_response_data_schema_1.GetWriteOffSummaryResponseDataSchema,
|
|
9
|
+
});
|
|
@@ -22,3 +22,28 @@ __exportStar(require("./daily-orders-summary-by-day-item.schema"), exports);
|
|
|
22
22
|
__exportStar(require("./daily-orders-summary-by-responsible-item.schema"), exports);
|
|
23
23
|
__exportStar(require("./get-daily-orders-summary-response-data.schema"), exports);
|
|
24
24
|
__exportStar(require("./get-daily-orders-summary-response.schema"), exports);
|
|
25
|
+
__exportStar(require("./get-write-off-summary-request.schema"), exports);
|
|
26
|
+
__exportStar(require("./write-off-summary-reason-row.schema"), exports);
|
|
27
|
+
__exportStar(require("./write-off-summary-client-row.schema"), exports);
|
|
28
|
+
__exportStar(require("./write-off-summary-totals.schema"), exports);
|
|
29
|
+
__exportStar(require("./write-off-summary-warehouse.schema"), exports);
|
|
30
|
+
__exportStar(require("./write-off-summary-by-client.schema"), exports);
|
|
31
|
+
__exportStar(require("./get-write-off-summary-response-data.schema"), exports);
|
|
32
|
+
__exportStar(require("./get-write-off-summary-response.schema"), exports);
|
|
33
|
+
__exportStar(require("./write-off-report-page.schema"), exports);
|
|
34
|
+
__exportStar(require("./get-write-off-breakdown-request.schema"), exports);
|
|
35
|
+
__exportStar(require("./write-off-breakdown-totals.schema"), exports);
|
|
36
|
+
__exportStar(require("./write-off-breakdown-row-base.schema"), exports);
|
|
37
|
+
__exportStar(require("./write-off-breakdown-consignment.schema"), exports);
|
|
38
|
+
__exportStar(require("./write-off-breakdown-consignment-row.schema"), exports);
|
|
39
|
+
__exportStar(require("./write-off-breakdown-grower-row.schema"), exports);
|
|
40
|
+
__exportStar(require("./write-off-breakdown-category-row.schema"), exports);
|
|
41
|
+
__exportStar(require("./write-off-breakdown-reason-row.schema"), exports);
|
|
42
|
+
__exportStar(require("./write-off-breakdown-row.schema"), exports);
|
|
43
|
+
__exportStar(require("./get-write-off-breakdown-response-data.schema"), exports);
|
|
44
|
+
__exportStar(require("./get-write-off-breakdown-response.schema"), exports);
|
|
45
|
+
__exportStar(require("./get-write-off-by-client-request.schema"), exports);
|
|
46
|
+
__exportStar(require("./write-off-by-client-totals.schema"), exports);
|
|
47
|
+
__exportStar(require("./write-off-by-client-row.schema"), exports);
|
|
48
|
+
__exportStar(require("./get-write-off-by-client-response-data.schema"), exports);
|
|
49
|
+
__exportStar(require("./get-write-off-by-client-response.schema"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffBreakdownCategoryRowSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const write_off_breakdown_group_by_enum_1 = require("../../enum/write-off-breakdown-group-by.enum");
|
|
6
|
+
const write_off_breakdown_row_base_schema_1 = require("./write-off-breakdown-row-base.schema");
|
|
7
|
+
exports.WriteOffBreakdownCategoryRowSchema = write_off_breakdown_row_base_schema_1.WriteOffBreakdownRowBaseSchema.extend({
|
|
8
|
+
groupBy: zod_1.z.literal(write_off_breakdown_group_by_enum_1.WriteOffBreakdownGroupByEnum.CATEGORY),
|
|
9
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffBreakdownConsignmentRowSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const write_off_breakdown_group_by_enum_1 = require("../../enum/write-off-breakdown-group-by.enum");
|
|
6
|
+
const write_off_breakdown_consignment_schema_1 = require("./write-off-breakdown-consignment.schema");
|
|
7
|
+
const write_off_breakdown_row_base_schema_1 = require("./write-off-breakdown-row-base.schema");
|
|
8
|
+
exports.WriteOffBreakdownConsignmentRowSchema = write_off_breakdown_row_base_schema_1.WriteOffBreakdownRowBaseSchema.extend({
|
|
9
|
+
groupBy: zod_1.z.literal(write_off_breakdown_group_by_enum_1.WriteOffBreakdownGroupByEnum.CONSIGNMENT),
|
|
10
|
+
consignment: write_off_breakdown_consignment_schema_1.WriteOffBreakdownConsignmentSchema,
|
|
11
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffBreakdownConsignmentSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/** Партия в строке разреза по поставкам. */
|
|
6
|
+
exports.WriteOffBreakdownConsignmentSchema = zod_1.z.object({
|
|
7
|
+
uuid: zod_1.z.string(),
|
|
8
|
+
id: zod_1.z.number(),
|
|
9
|
+
label: zod_1.z.string().nullable(),
|
|
10
|
+
deliveryDate: zod_1.z.coerce.date(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffBreakdownGrowerRowSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const write_off_breakdown_group_by_enum_1 = require("../../enum/write-off-breakdown-group-by.enum");
|
|
6
|
+
const write_off_breakdown_row_base_schema_1 = require("./write-off-breakdown-row-base.schema");
|
|
7
|
+
exports.WriteOffBreakdownGrowerRowSchema = write_off_breakdown_row_base_schema_1.WriteOffBreakdownRowBaseSchema.extend({
|
|
8
|
+
groupBy: zod_1.z.literal(write_off_breakdown_group_by_enum_1.WriteOffBreakdownGroupByEnum.GROWER),
|
|
9
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffBreakdownReasonRowSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const write_off_breakdown_group_by_enum_1 = require("../../enum/write-off-breakdown-group-by.enum");
|
|
6
|
+
const write_off_breakdown_row_base_schema_1 = require("./write-off-breakdown-row-base.schema");
|
|
7
|
+
exports.WriteOffBreakdownReasonRowSchema = write_off_breakdown_row_base_schema_1.WriteOffBreakdownRowBaseSchema.extend({
|
|
8
|
+
groupBy: zod_1.z.literal(write_off_breakdown_group_by_enum_1.WriteOffBreakdownGroupByEnum.REASON),
|
|
9
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffBreakdownRowBaseSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const money_schema_1 = require("../money.schema");
|
|
6
|
+
/**
|
|
7
|
+
* Общая часть строки разреза списаний.
|
|
8
|
+
*
|
|
9
|
+
* `key` — устойчивый идентификатор группы (uuid партии или категории, нормализованный
|
|
10
|
+
* производитель, причина); у групп «Без категории» и «Не указан» — пустая строка.
|
|
11
|
+
* `receivedCost` — база процента, `share` — доля списаний от неё в процентах с округлением на бэке;
|
|
12
|
+
* `null` там, где процент не считается, и при нулевой базе.
|
|
13
|
+
*/
|
|
14
|
+
exports.WriteOffBreakdownRowBaseSchema = zod_1.z.object({
|
|
15
|
+
key: zod_1.z.string(),
|
|
16
|
+
label: zod_1.z.string(),
|
|
17
|
+
units: zod_1.z.number(),
|
|
18
|
+
cost: money_schema_1.MoneySchema,
|
|
19
|
+
receivedCost: money_schema_1.MoneySchema.nullable(),
|
|
20
|
+
share: zod_1.z.number().nullable(),
|
|
21
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffBreakdownRowSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const write_off_breakdown_category_row_schema_1 = require("./write-off-breakdown-category-row.schema");
|
|
6
|
+
const write_off_breakdown_consignment_row_schema_1 = require("./write-off-breakdown-consignment-row.schema");
|
|
7
|
+
const write_off_breakdown_grower_row_schema_1 = require("./write-off-breakdown-grower-row.schema");
|
|
8
|
+
const write_off_breakdown_reason_row_schema_1 = require("./write-off-breakdown-reason-row.schema");
|
|
9
|
+
/** Строка разреза: форма зависит от `groupBy`, поэтому фронт сужает тип по дискриминатору. */
|
|
10
|
+
exports.WriteOffBreakdownRowSchema = zod_1.z.discriminatedUnion('groupBy', [
|
|
11
|
+
write_off_breakdown_consignment_row_schema_1.WriteOffBreakdownConsignmentRowSchema,
|
|
12
|
+
write_off_breakdown_grower_row_schema_1.WriteOffBreakdownGrowerRowSchema,
|
|
13
|
+
write_off_breakdown_category_row_schema_1.WriteOffBreakdownCategoryRowSchema,
|
|
14
|
+
write_off_breakdown_reason_row_schema_1.WriteOffBreakdownReasonRowSchema,
|
|
15
|
+
]);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffBreakdownTotalsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const money_schema_1 = require("../money.schema");
|
|
6
|
+
/**
|
|
7
|
+
* Итог разреза по всем строкам, независимо от `limit`/`offset`.
|
|
8
|
+
*
|
|
9
|
+
* `receivedCost` — себестоимость прихода всех партий периода, `share` — доля списаний от него в
|
|
10
|
+
* процентах. Обе величины есть только на оси `CONSIGNMENT_DELIVERY_DATE`: на оси даты списания
|
|
11
|
+
* товар мог прийти раньше периода, и делить его на приход периода некорректно.
|
|
12
|
+
*/
|
|
13
|
+
exports.WriteOffBreakdownTotalsSchema = zod_1.z.object({
|
|
14
|
+
units: zod_1.z.number(),
|
|
15
|
+
cost: money_schema_1.MoneySchema,
|
|
16
|
+
receivedCost: money_schema_1.MoneySchema.nullable(),
|
|
17
|
+
share: zod_1.z.number().nullable(),
|
|
18
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffByClientRowSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const money_schema_1 = require("../money.schema");
|
|
6
|
+
/**
|
|
7
|
+
* Клиент со списаниями по заказам периода.
|
|
8
|
+
*
|
|
9
|
+
* `revenue` — выручка всех заказов клиента за период (товары по цене продажи, без доставки и
|
|
10
|
+
* услуг), `share` — `writeOffOrderAmount ÷ revenue` в процентах; `null` при нулевой выручке.
|
|
11
|
+
*/
|
|
12
|
+
exports.WriteOffByClientRowSchema = zod_1.z.object({
|
|
13
|
+
clientUUID: zod_1.z.string(),
|
|
14
|
+
clientName: zod_1.z.string(),
|
|
15
|
+
revenue: money_schema_1.MoneySchema,
|
|
16
|
+
ordersWithWriteOff: zod_1.z.number(),
|
|
17
|
+
writeOffOrderAmount: money_schema_1.MoneySchema,
|
|
18
|
+
cost: money_schema_1.MoneySchema,
|
|
19
|
+
units: zod_1.z.number(),
|
|
20
|
+
share: zod_1.z.number().nullable(),
|
|
21
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffByClientTotalsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const money_schema_1 = require("../money.schema");
|
|
6
|
+
/**
|
|
7
|
+
* Итог разреза по клиентам.
|
|
8
|
+
*
|
|
9
|
+
* `revenue` — выручка ВСЕХ клиентов периода, а не только тех, у кого были списания: `share` здесь —
|
|
10
|
+
* доля брака по клиентам вообще. Она не равна ни сумме, ни среднему долей по строкам.
|
|
11
|
+
* Списания (`writeOffOrderAmount`, `cost`, `units`) суммируются по всем строкам независимо от
|
|
12
|
+
* `limit`/`offset`.
|
|
13
|
+
*/
|
|
14
|
+
exports.WriteOffByClientTotalsSchema = zod_1.z.object({
|
|
15
|
+
revenue: money_schema_1.MoneySchema,
|
|
16
|
+
writeOffOrderAmount: money_schema_1.MoneySchema,
|
|
17
|
+
cost: money_schema_1.MoneySchema,
|
|
18
|
+
units: zod_1.z.number(),
|
|
19
|
+
share: zod_1.z.number().nullable(),
|
|
20
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffReportPageSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const report_constant_1 = require("../../constant/report.constant");
|
|
6
|
+
/**
|
|
7
|
+
* Страница строк разреза списаний. Итоги от неё не зависят; чтобы выбрать список целиком (выгрузка
|
|
8
|
+
* в Excel), фронт идёт по `offset` с шагом `limit`, пока не наберёт `rowsTotal`.
|
|
9
|
+
*/
|
|
10
|
+
exports.WriteOffReportPageSchema = zod_1.z.object({
|
|
11
|
+
limit: zod_1.z.coerce.number().int().positive().max(report_constant_1.REPORT_WRITE_OFF_BREAKDOWN_LIMIT_MAX).default(report_constant_1.REPORT_WRITE_OFF_BREAKDOWN_LIMIT_DEFAULT),
|
|
12
|
+
offset: zod_1.z.coerce.number().int().nonnegative().default(0),
|
|
13
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffSummaryByClientSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const money_schema_1 = require("../money.schema");
|
|
6
|
+
const write_off_summary_client_row_schema_1 = require("./write-off-summary-client-row.schema");
|
|
7
|
+
/**
|
|
8
|
+
* Списания по заказу: клиенту они уже вернулись на баланс, то есть это выручка, которой по факту
|
|
9
|
+
* не было.
|
|
10
|
+
*/
|
|
11
|
+
exports.WriteOffSummaryByClientSchema = zod_1.z.object({
|
|
12
|
+
units: zod_1.z.number(),
|
|
13
|
+
cost: money_schema_1.MoneySchema,
|
|
14
|
+
orderAmount: money_schema_1.MoneySchema,
|
|
15
|
+
rows: write_off_summary_client_row_schema_1.WriteOffSummaryClientRowSchema.array(),
|
|
16
|
+
// Сколько клиентов всего — чтобы отличить усечённый ответ от полного.
|
|
17
|
+
rowsTotal: zod_1.z.number(),
|
|
18
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffSummaryClientRowSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const money_schema_1 = require("../money.schema");
|
|
6
|
+
exports.WriteOffSummaryClientRowSchema = zod_1.z.object({
|
|
7
|
+
clientUUID: zod_1.z.string(),
|
|
8
|
+
clientName: zod_1.z.string(),
|
|
9
|
+
orderCount: zod_1.z.number(),
|
|
10
|
+
units: zod_1.z.number(),
|
|
11
|
+
cost: money_schema_1.MoneySchema,
|
|
12
|
+
orderAmount: money_schema_1.MoneySchema,
|
|
13
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteOffSummaryReasonRowSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const money_schema_1 = require("../money.schema");
|
|
6
|
+
exports.WriteOffSummaryReasonRowSchema = zod_1.z.object({
|
|
7
|
+
// Свободный текст из справочника причин, схлопнут только по краевым пробелам (TRIM).
|
|
8
|
+
// Регистр не нормализуем: «Брак» и «брак» останутся разными строками.
|
|
9
|
+
reason: zod_1.z.string(),
|
|
10
|
+
units: zod_1.z.number(),
|
|
11
|
+
cost: money_schema_1.MoneySchema,
|
|
12
|
+
});
|