@floristcloud/api-lib 1.2.108 → 1.2.110
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/client/get-client-calculate.query.js +6 -4
- package/build/commands/consignment/execute-consignment-product-update.command.js +5 -4
- package/build/commands/integration/moysklad/execute-moysklad-import.command.js +3 -2
- package/build/commands/integration/moysklad/preview-moysklad-products.query.js +3 -2
- package/build/commands/integration/moysklad/scan-moysklad-import.query.js +3 -2
- package/build/commands/order/create-order.command.js +2 -1
- package/build/commands/order/update-order.command.js +3 -2
- package/build/commands/order/webshop/get-order-sales-by-month.query.js +2 -1
- package/build/commands/order-product/create-order-product.command.js +2 -1
- package/build/commands/order-product/group/price-valuation-execute.command.js +3 -1
- package/build/commands/order-product/update-order-product.command.js +2 -1
- package/build/commands/payment-invoice/create-payment-invoice.command.js +3 -1
- package/build/commands/payment-invoice/pay-payment-invoice.command.js +3 -1
- package/build/commands/pre-order-collection-item/execute-pre-order-collection-item-update.command.js +3 -2
- package/build/commands/pre-order-collection-item/multiplicity-option/create-pre-order-collection-item-multiplicity-option.command.js +2 -1
- package/build/commands/pre-order-collection-item/multiplicity-option/update-pre-order-collection-item-multiplicity-option.command.js +2 -1
- package/build/commands/product/create-product.command.js +4 -3
- package/build/commands/product/group/update-group-product-prices.command.js +3 -2
- package/build/commands/product/group/update-group-product-update-batch.command.js +4 -3
- package/build/commands/product/multiplicity-option/create-product-multiplicity-option.command.js +2 -1
- package/build/commands/product/multiplicity-option/update-product-multiplicity-option.command.js +2 -1
- package/build/commands/product/update-product.command.js +4 -3
- package/build/commands/report/export-sales-by-client.query.js +3 -0
- package/build/commands/report/export-sales-by-position.query.js +3 -0
- package/build/commands/report/export-sales-revenue.query.js +3 -0
- package/build/commands/report/get-cash-flow.query.js +8 -5
- package/build/commands/report/get-daily-orders-summary.query.js +2 -1
- package/build/commands/report/get-report-for-period.query.js +10 -9
- package/build/commands/report/get-report-group-by-client.query.js +15 -10
- package/build/commands/report/get-report-group-by-position.query.js +15 -14
- package/build/commands/report/get-sales-by-client.query.js +3 -0
- package/build/commands/report/get-sales-summary.query.js +17 -11
- package/build/commands/transaction/generate-check-transaction.command.js +2 -1
- package/build/commands/transaction/generate-pre-payment-check.command.js +2 -1
- package/build/commands/transaction/get-sum-transaction-by-money-account.query.js +3 -1
- package/build/commands/transaction/get-transaction-summary.query.js +5 -3
- package/build/commands/write-off/get-write-off-sum-by-order.query.js +3 -1
- package/build/commands/write-off/update-write-off-price.command.js +2 -1
- package/build/constant/index.js +1 -0
- package/build/constant/report.constant.js +9 -0
- package/build/enum/index.js +1 -0
- package/build/enum/report-order-date-basis.enum.js +18 -0
- package/build/schemas/action-log/action-log-money.schema.js +28 -0
- package/build/schemas/action-log/index.js +1 -0
- package/build/schemas/action-log/order-info.schema.js +3 -2
- package/build/schemas/action-log/order-product-info.schema.js +2 -1
- package/build/schemas/action-log/order-product-update-action-log.schema.js +2 -1
- package/build/schemas/action-log/pre-order-product-info.schema.js +2 -1
- package/build/schemas/action-log/pre-order-product-update-action-log.schema.js +2 -1
- package/build/schemas/action-log/transaction-info.schema.js +2 -1
- package/build/schemas/bank-payment/bank-payment.schema.js +2 -1
- package/build/schemas/client/client-debt.schema.js +8 -5
- package/build/schemas/client/client.schema.js +2 -1
- package/build/schemas/consignment/consignment.schema.js +10 -9
- package/build/schemas/consignment-transfer/accept-consignment-transfer.schema.js +3 -1
- package/build/schemas/consignment-transfer/consignment-transfer-request-item.schema.js +2 -1
- package/build/schemas/delivery-route/delivery-route.schema.js +2 -1
- package/build/schemas/discount-rules/discount-rules.schema.js +9 -2
- package/build/schemas/index.js +4 -0
- package/build/schemas/money-account/money-account-with-balance.schema.js +2 -2
- package/build/schemas/money.schema.js +27 -0
- package/build/schemas/non-negative-money.schema.js +17 -0
- package/build/schemas/order/order.schema.js +10 -9
- package/build/schemas/order-product/order-product-multiplicity-optiom.schema.js +2 -1
- package/build/schemas/order-product/order-product.schema.js +5 -4
- package/build/schemas/order-product/price-correction-analyze-item.schema.js +10 -8
- package/build/schemas/order-product/price-correction-execute-result-item.schema.js +3 -2
- package/build/schemas/order-service-line/order-service-line.schema.js +12 -5
- package/build/schemas/payment-invoice/payment-invoice.schema.js +5 -4
- package/build/schemas/positive-money.schema.js +18 -0
- package/build/schemas/pre-order/pre-order.schema.js +2 -1
- package/build/schemas/pre-order-collection-item/pre-order-collection-item-multiplicity-option.schema.js +2 -1
- package/build/schemas/pre-order-collection-item/pre-order-collection-item.schema.js +4 -3
- package/build/schemas/pre-order-product/pre-order-product.schema.js +5 -4
- package/build/schemas/product/product-multiplicity-option.schema.js +2 -1
- package/build/schemas/product/product.schema.js +6 -5
- package/build/schemas/report/client-by-weeks.schema.js +2 -1
- package/build/schemas/report/client-statement.schema.js +2 -1
- package/build/schemas/report/inventory-turnover-category-item.schema.js +1 -1
- package/build/schemas/report/inventory-turnover-detailed-item.schema.js +1 -1
- package/build/schemas/report/report-order-filter.schema.js +28 -0
- package/build/schemas/report/sales-by-client-row.schema.js +9 -8
- package/build/schemas/report/sales-by-client-top-item.schema.js +2 -1
- package/build/schemas/service/service.schema.js +8 -3
- package/build/schemas/settings/settings.schema.js +6 -2
- package/build/schemas/transaction/transaction.schema.js +2 -1
- package/commands/client/get-client-calculate.query.ts +6 -4
- package/commands/consignment/execute-consignment-product-update.command.ts +5 -4
- package/commands/integration/moysklad/execute-moysklad-import.command.ts +3 -2
- package/commands/integration/moysklad/preview-moysklad-products.query.ts +3 -2
- package/commands/integration/moysklad/scan-moysklad-import.query.ts +3 -2
- package/commands/order/create-order.command.ts +2 -1
- package/commands/order/update-order.command.ts +3 -2
- package/commands/order/webshop/get-order-sales-by-month.query.ts +3 -1
- package/commands/order-product/create-order-product.command.ts +2 -1
- package/commands/order-product/group/price-valuation-execute.command.ts +4 -1
- package/commands/order-product/update-order-product.command.ts +2 -1
- package/commands/payment-invoice/create-payment-invoice.command.ts +4 -1
- package/commands/payment-invoice/pay-payment-invoice.command.ts +4 -1
- package/commands/pre-order-collection-item/execute-pre-order-collection-item-update.command.ts +3 -2
- package/commands/pre-order-collection-item/multiplicity-option/create-pre-order-collection-item-multiplicity-option.command.ts +3 -1
- package/commands/pre-order-collection-item/multiplicity-option/update-pre-order-collection-item-multiplicity-option.command.ts +3 -1
- package/commands/product/create-product.command.ts +4 -3
- package/commands/product/group/update-group-product-prices.command.ts +3 -2
- package/commands/product/group/update-group-product-update-batch.command.ts +4 -3
- package/commands/product/multiplicity-option/create-product-multiplicity-option.command.ts +3 -1
- package/commands/product/multiplicity-option/update-product-multiplicity-option.command.ts +3 -1
- package/commands/product/update-product.command.ts +4 -3
- package/commands/report/export-sales-by-client.query.ts +3 -0
- package/commands/report/export-sales-by-position.query.ts +3 -0
- package/commands/report/export-sales-revenue.query.ts +3 -0
- package/commands/report/get-cash-flow.query.ts +8 -5
- package/commands/report/get-daily-orders-summary.query.ts +2 -1
- package/commands/report/get-report-for-period.query.ts +10 -9
- package/commands/report/get-report-group-by-client.query.ts +15 -10
- package/commands/report/get-report-group-by-position.query.ts +15 -14
- package/commands/report/get-sales-by-client.query.ts +3 -0
- package/commands/report/get-sales-summary.query.ts +17 -11
- package/commands/transaction/generate-check-transaction.command.ts +2 -1
- package/commands/transaction/generate-pre-payment-check.command.ts +2 -1
- package/commands/transaction/get-sum-transaction-by-money-account.query.ts +3 -1
- package/commands/transaction/get-transaction-summary.query.ts +5 -3
- package/commands/write-off/get-write-off-sum-by-order.query.ts +4 -1
- package/commands/write-off/update-write-off-price.command.ts +2 -1
- package/constant/index.ts +1 -0
- package/constant/report.constant.ts +6 -0
- package/enum/index.ts +1 -0
- package/enum/report-order-date-basis.enum.ts +14 -0
- package/package.json +1 -1
- package/schemas/action-log/action-log-money.schema.ts +26 -0
- package/schemas/action-log/index.ts +1 -0
- package/schemas/action-log/order-info.schema.ts +3 -2
- package/schemas/action-log/order-product-info.schema.ts +2 -1
- package/schemas/action-log/order-product-update-action-log.schema.ts +2 -1
- package/schemas/action-log/pre-order-product-info.schema.ts +2 -1
- package/schemas/action-log/pre-order-product-update-action-log.schema.ts +2 -1
- package/schemas/action-log/transaction-info.schema.ts +2 -1
- package/schemas/bank-payment/bank-payment.schema.ts +2 -1
- package/schemas/client/client-debt.schema.ts +8 -5
- package/schemas/client/client.schema.ts +2 -1
- package/schemas/consignment/consignment.schema.ts +10 -9
- package/schemas/consignment-transfer/accept-consignment-transfer.schema.ts +4 -1
- package/schemas/consignment-transfer/consignment-transfer-request-item.schema.ts +2 -1
- package/schemas/delivery-route/delivery-route.schema.ts +2 -1
- package/schemas/discount-rules/discount-rules.schema.ts +9 -2
- package/schemas/index.ts +4 -0
- package/schemas/money-account/money-account-with-balance.schema.ts +2 -1
- package/schemas/money.schema.ts +25 -0
- package/schemas/non-negative-money.schema.ts +15 -0
- package/schemas/order/order.schema.ts +10 -9
- package/schemas/order-product/order-product-multiplicity-optiom.schema.ts +2 -1
- package/schemas/order-product/order-product.schema.ts +5 -4
- package/schemas/order-product/price-correction-analyze-item.schema.ts +10 -8
- package/schemas/order-product/price-correction-execute-result-item.schema.ts +3 -2
- package/schemas/order-service-line/order-service-line.schema.ts +13 -5
- package/schemas/payment-invoice/payment-invoice.schema.ts +5 -4
- package/schemas/positive-money.schema.ts +16 -0
- package/schemas/pre-order/pre-order.schema.ts +2 -1
- package/schemas/pre-order-collection-item/pre-order-collection-item-multiplicity-option.schema.ts +3 -1
- package/schemas/pre-order-collection-item/pre-order-collection-item.schema.ts +4 -3
- package/schemas/pre-order-product/pre-order-product.schema.ts +5 -4
- package/schemas/product/product-multiplicity-option.schema.ts +2 -1
- package/schemas/product/product.schema.ts +6 -5
- package/schemas/report/client-by-weeks.schema.ts +2 -1
- package/schemas/report/client-statement.schema.ts +2 -1
- package/schemas/report/inventory-turnover-category-item.schema.ts +1 -1
- package/schemas/report/inventory-turnover-detailed-item.schema.ts +1 -1
- package/schemas/report/report-order-filter.schema.ts +26 -0
- package/schemas/report/sales-by-client-row.schema.ts +9 -8
- package/schemas/report/sales-by-client-top-item.schema.ts +2 -1
- package/schemas/service/service.schema.ts +9 -3
- package/schemas/settings/settings.schema.ts +7 -2
- package/schemas/transaction/transaction.schema.ts +2 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { OrderByEnum, PositionReportTypeEnum, ReportSortByEnum } from '../../enum';
|
|
3
3
|
import { dateRangeCheck } from '../../helpers/date.helper';
|
|
4
|
+
import { MoneySchema } from '../../schemas/money.schema';
|
|
4
5
|
|
|
5
6
|
const GetReportGroupByPositionRequestSchema = z
|
|
6
7
|
.object({
|
|
@@ -49,15 +50,15 @@ const GetReportGroupByPositionResponseSchema = z.object({
|
|
|
49
50
|
name: z.string(),
|
|
50
51
|
}),
|
|
51
52
|
totalOrders: z.number(),
|
|
52
|
-
totalSales:
|
|
53
|
+
totalSales: MoneySchema,
|
|
53
54
|
soldUnits: z.number(),
|
|
54
|
-
totalCost:
|
|
55
|
+
totalCost: MoneySchema,
|
|
55
56
|
totalUnits: z.number(),
|
|
56
|
-
totalWriteOff: z.number(),
|
|
57
|
-
totalWriteOffCost:
|
|
58
|
-
totalVatAmount:
|
|
59
|
-
middlePrice:
|
|
60
|
-
grossProfit:
|
|
57
|
+
totalWriteOff: z.number(), // количество списанных единиц (SUM по quantity), не деньги
|
|
58
|
+
totalWriteOffCost: MoneySchema,
|
|
59
|
+
totalVatAmount: MoneySchema,
|
|
60
|
+
middlePrice: MoneySchema,
|
|
61
|
+
grossProfit: MoneySchema,
|
|
61
62
|
marginality: z.number(),
|
|
62
63
|
}),
|
|
63
64
|
)
|
|
@@ -69,14 +70,14 @@ const GetReportGroupByPositionResponseSchema = z.object({
|
|
|
69
70
|
productKey: z.string(),
|
|
70
71
|
totalOrders: z.number(),
|
|
71
72
|
soldUnits: z.number(),
|
|
72
|
-
totalSales:
|
|
73
|
-
totalCost:
|
|
73
|
+
totalSales: MoneySchema,
|
|
74
|
+
totalCost: MoneySchema,
|
|
74
75
|
totalUnits: z.number(),
|
|
75
|
-
totalWriteOff: z.number(),
|
|
76
|
-
totalWriteOffCost:
|
|
77
|
-
totalVatAmount:
|
|
78
|
-
middlePrice:
|
|
79
|
-
grossProfit:
|
|
76
|
+
totalWriteOff: z.number(), // количество списанных единиц (SUM по quantity), не деньги
|
|
77
|
+
totalWriteOffCost: MoneySchema,
|
|
78
|
+
totalVatAmount: MoneySchema,
|
|
79
|
+
middlePrice: MoneySchema,
|
|
80
|
+
grossProfit: MoneySchema,
|
|
80
81
|
marginality: z.number(),
|
|
81
82
|
}),
|
|
82
83
|
)
|
|
@@ -3,6 +3,7 @@ import { OrderByEnum, ReportSortByEnum } from '../../enum';
|
|
|
3
3
|
import { dateRangeCheck, isStatementPeriodWithinLimit } from '../../helpers/date.helper';
|
|
4
4
|
import { isPageAccompaniedByCount } from '../../helpers/pagination.helper';
|
|
5
5
|
import { SalesByClientRowSchema } from '../../schemas/report/sales-by-client-row.schema';
|
|
6
|
+
import { ReportOrderFilterSchema } from '../../schemas/report/report-order-filter.schema';
|
|
6
7
|
|
|
7
8
|
const GetSalesByClientRequestSchema = z
|
|
8
9
|
.object({
|
|
@@ -16,6 +17,8 @@ const GetSalesByClientRequestSchema = z
|
|
|
16
17
|
page: z.coerce.number().int().positive().optional().describe('1-based page number, requires "count".'),
|
|
17
18
|
count: z.coerce.number().int().positive().optional().describe('Rows per page. Without it every client row is returned.'),
|
|
18
19
|
})
|
|
20
|
+
// dateBasis / excludeClientUUID — те же, что у JSON-эндпоинтов отчётов по заказам.
|
|
21
|
+
.merge(ReportOrderFilterSchema)
|
|
19
22
|
.refine(value => dateRangeCheck(value.startDate, value.endDate), {
|
|
20
23
|
message: 'validation.dateRange',
|
|
21
24
|
path: ['endDate', 'startDate'],
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { dateRangeCheck } from '../../helpers/date.helper';
|
|
3
3
|
import { ReportPeriodTypeEnum } from '../../enum/report-period-type.enum';
|
|
4
|
+
import { MoneySchema } from '../../schemas/money.schema';
|
|
5
|
+
import { ReportOrderFilterSchema } from '../../schemas/report/report-order-filter.schema';
|
|
4
6
|
|
|
5
7
|
const GetSalesSummaryRequestSchema = z
|
|
6
8
|
.object({
|
|
@@ -8,6 +10,9 @@ const GetSalesSummaryRequestSchema = z
|
|
|
8
10
|
endDate: z.coerce.date().optional(),
|
|
9
11
|
periodType: z.nativeEnum(ReportPeriodTypeEnum).default(ReportPeriodTypeEnum.DAY),
|
|
10
12
|
})
|
|
13
|
+
// dateBasis / excludeClientUUID общие с group-client: обе цифры живут на одном экране и должны
|
|
14
|
+
// сужаться одинаково.
|
|
15
|
+
.merge(ReportOrderFilterSchema)
|
|
11
16
|
.refine(
|
|
12
17
|
value => {
|
|
13
18
|
const { startDate, endDate } = value;
|
|
@@ -23,27 +28,28 @@ const GetSalesSummaryRequestSchema = z
|
|
|
23
28
|
);
|
|
24
29
|
|
|
25
30
|
const SalesSummaryTotalsSchema = z.object({
|
|
26
|
-
totalRevenue:
|
|
27
|
-
totalRevenueWithDelivery:
|
|
31
|
+
totalRevenue: MoneySchema,
|
|
32
|
+
totalRevenueWithDelivery: MoneySchema,
|
|
28
33
|
totalOrders: z.number(),
|
|
29
34
|
uniqueClients: z.number(),
|
|
30
35
|
soldUnits: z.number(),
|
|
31
|
-
avgCheck:
|
|
32
|
-
totalVatAmount:
|
|
33
|
-
totalCost:
|
|
34
|
-
totalDeliveryCost:
|
|
35
|
-
totalServiceAmount:
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
avgCheck: MoneySchema,
|
|
37
|
+
totalVatAmount: MoneySchema,
|
|
38
|
+
totalCost: MoneySchema,
|
|
39
|
+
totalDeliveryCost: MoneySchema,
|
|
40
|
+
totalServiceAmount: MoneySchema,
|
|
41
|
+
// Сумма скидки в деньгах (SUM(order.discount_amount)) — в отличие от процента `discountPercent`
|
|
42
|
+
totalDiscountAmount: MoneySchema,
|
|
43
|
+
grossProfit: MoneySchema,
|
|
38
44
|
marginality: z.number(),
|
|
39
45
|
});
|
|
40
46
|
|
|
41
47
|
const SalesSummarySeriesItemSchema = z.object({
|
|
42
48
|
period: z.string(),
|
|
43
|
-
revenue:
|
|
49
|
+
revenue: MoneySchema,
|
|
44
50
|
orders: z.number(),
|
|
45
51
|
units: z.number(),
|
|
46
|
-
avgCheck:
|
|
52
|
+
avgCheck: MoneySchema,
|
|
47
53
|
});
|
|
48
54
|
|
|
49
55
|
const GetSalesSummaryResponseSchema = z.object({
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { DeleteDataResponseSchema } from '../../schemas';
|
|
3
|
+
import { MoneySchema } from '../../schemas/money.schema';
|
|
3
4
|
|
|
4
5
|
const GenerateCheckTransactionRequestSchema = z.object({
|
|
5
6
|
orderUUID: z.string(),
|
|
6
|
-
amount:
|
|
7
|
+
amount: MoneySchema,
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
const GenerateCheckTransactionResponseSchema = z.object({
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { DeleteDataResponseSchema } from '../../schemas';
|
|
3
|
+
import { MoneySchema } from '../../schemas/money.schema';
|
|
3
4
|
|
|
4
5
|
const GeneratePrepaymentCheckRequestSchema = z.object({
|
|
5
6
|
clientUUID: z.string(),
|
|
6
|
-
amount:
|
|
7
|
+
amount: MoneySchema,
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
const GeneratePrepaymentCheckResponseSchema = z.object({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { dateRangeCheck } from '../../helpers/date.helper';
|
|
3
|
+
import { MoneySchema } from '../../schemas/money.schema';
|
|
3
4
|
|
|
4
5
|
const GetSumTransactionByMoneyAccountRequestSchema = z
|
|
5
6
|
.object({
|
|
@@ -24,7 +25,8 @@ const GetSumTransactionByMoneyAccountRequestSchema = z
|
|
|
24
25
|
const GetSumTransactionByMoneyAccountResponseSchema = z.object({
|
|
25
26
|
message: z.string().optional(),
|
|
26
27
|
data: z.object({
|
|
27
|
-
|
|
28
|
+
// Сальдо по кассе: расход может превысить приход, поэтому знаковых ограничений нет.
|
|
29
|
+
sum: MoneySchema,
|
|
28
30
|
}),
|
|
29
31
|
});
|
|
30
32
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { dateRangeCheck } from '../../helpers/date.helper';
|
|
3
3
|
import { TransactionTypeEnum } from '../../enum';
|
|
4
|
+
import { MoneySchema } from '../../schemas/money.schema';
|
|
4
5
|
|
|
5
6
|
const GetTransactionSummaryRequestSchema = z
|
|
6
7
|
.object({
|
|
@@ -30,9 +31,10 @@ const GetTransactionSummaryRequestSchema = z
|
|
|
30
31
|
const GetTransactionSummaryResponseSchema = z.object({
|
|
31
32
|
message: z.string().optional(),
|
|
32
33
|
data: z.object({
|
|
33
|
-
income:
|
|
34
|
-
expense:
|
|
35
|
-
|
|
34
|
+
income: MoneySchema,
|
|
35
|
+
expense: MoneySchema,
|
|
36
|
+
// Разница income − expense: минус здесь легитимен, поэтому знаковых ограничений нет.
|
|
37
|
+
total: MoneySchema,
|
|
36
38
|
}),
|
|
37
39
|
});
|
|
38
40
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { MoneySchema } from '../../schemas/money.schema';
|
|
3
|
+
import { NonNegativeMoneySchema } from '../../schemas/non-negative-money.schema';
|
|
2
4
|
|
|
3
5
|
const GetWriteOffSumByOrderRequestSchema = z.object({});
|
|
4
6
|
|
|
5
7
|
const GetWriteOffSumByOrderResponseSchema = z.object({
|
|
6
8
|
message: z.string().optional(),
|
|
7
|
-
|
|
9
|
+
// Сумма списаний (количество × цена позиции) — деньги, отрицательной быть не может.
|
|
10
|
+
data: NonNegativeMoneySchema,
|
|
8
11
|
});
|
|
9
12
|
|
|
10
13
|
export namespace GetWriteOffSumByOrderContractQuery {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { WriteOffSchema } from '../../schemas';
|
|
3
|
+
import { MoneySchema } from '../../schemas/money.schema';
|
|
3
4
|
|
|
4
5
|
const UpdateWriteOffPriceRequestSchema = z.object({
|
|
5
6
|
quantity: z.coerce.number(),
|
|
6
|
-
price:
|
|
7
|
+
price: MoneySchema,
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
const UpdateWriteOffPriceResponseSchema = z.object({
|
package/constant/index.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Потолок списка исключаемых из отчёта клиентов. Список едет в query-строке и дальше в SQL
|
|
3
|
+
* как `= ANY($n::text[])`, поэтому ограничение защищает и от переполнения URL, и от запроса
|
|
4
|
+
* с массивом в тысячи элементов.
|
|
5
|
+
*/
|
|
6
|
+
export const REPORT_EXCLUDE_CLIENT_LIMIT = 500;
|
package/enum/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ось периода для отчётов по заказам — ровно одна дата на отчёт.
|
|
3
|
+
*
|
|
4
|
+
* CREATED_AT — по дате создания заказа (историческое поведение всех отчётов).
|
|
5
|
+
* COMPLETED_AT — по дате отгрузки (завершения); заказ, созданный в июне и отгруженный в июле,
|
|
6
|
+
* попадёт в июль.
|
|
7
|
+
*
|
|
8
|
+
* Дизъюнкции («любая из дат») здесь намеренно нет: заказ, созданный в июне и отгруженный в июле,
|
|
9
|
+
* попал бы в оба месяца, сумма отчётов по месяцам перестала бы сходиться с отчётом за квартал.
|
|
10
|
+
*/
|
|
11
|
+
export enum ReportOrderDateBasisEnum {
|
|
12
|
+
CREATED_AT = 'CREATED_AT',
|
|
13
|
+
COMPLETED_AT = 'COMPLETED_AT',
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { MoneySchema } from '../money.schema';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Денежная величина внутри записи журнала аудита.
|
|
6
|
+
*
|
|
7
|
+
* Отличается от обычного `MoneySchema` тем, что принимает ОБА формата: и десятичную строку,
|
|
8
|
+
* которой деньги пишутся сейчас, и JSON-число, которым они писались раньше.
|
|
9
|
+
*
|
|
10
|
+
* Причина в природе самих данных. `action_log.payload` — это неизменяемый журнал: он фиксирует,
|
|
11
|
+
* что произошло, в том виде, в каком это выглядело на момент события. На проде в нём 265 402
|
|
12
|
+
* записи с деньгами-числами, разложенными по шести разным формам payload'а на разной глубине
|
|
13
|
+
* вложенности. Переписать их миграцией мешает и объём, и то, что `jsonb_set` требует конкретный
|
|
14
|
+
* путь: рекурсивно искать `jsonb_path_exists` умеет, а записывать — нет. Любая форма, не учтённая
|
|
15
|
+
* в такой миграции, осталась бы непочиненной и роняла бы чтение.
|
|
16
|
+
*
|
|
17
|
+
* Но главное — переписывать историю аудита под новую схему неправильно по существу, даже когда
|
|
18
|
+
* переписывание чисто техническое.
|
|
19
|
+
*
|
|
20
|
+
* Поэтому снисходительность живёт здесь и только здесь. Во всех остальных местах, включая JSON-поля
|
|
21
|
+
* `settings.delivery_pricing_tiers` и `discount_rules.data`, деньги мигрированы в строки, и там
|
|
22
|
+
* используется строгий `MoneySchema`.
|
|
23
|
+
*
|
|
24
|
+
* Новые записи журнала уже пишутся строками: `Decimal.toJSON()` возвращает строку.
|
|
25
|
+
*/
|
|
26
|
+
export const ActionLogMoneySchema = z.union([MoneySchema, z.number().transform(value => value.toFixed(2))]);
|
|
@@ -21,3 +21,4 @@ export * from './consignment-items-create-action-log.schema';
|
|
|
21
21
|
export * from './consignment-items-delete-action-log.schema';
|
|
22
22
|
export * from './group-update-consignment-items-action-log.schema';
|
|
23
23
|
export * from './transfer-consignment-items-action-log.schema';
|
|
24
|
+
export * from './action-log-money.schema';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { ActionLogMoneySchema } from './action-log-money.schema';
|
|
2
3
|
|
|
3
4
|
export const OrderInfoSchema = z.object({
|
|
4
5
|
orderUUID: z.string(),
|
|
@@ -6,7 +7,7 @@ export const OrderInfoSchema = z.object({
|
|
|
6
7
|
clientUUID: z.string(),
|
|
7
8
|
clientName: z.string(),
|
|
8
9
|
createdAt: z.coerce.date(),
|
|
9
|
-
totalCost:
|
|
10
|
+
totalCost: ActionLogMoneySchema,
|
|
10
11
|
deliveryAddress: z.string().nullable().optional(),
|
|
11
|
-
deliveryCost:
|
|
12
|
+
deliveryCost: ActionLogMoneySchema.nullable().optional(),
|
|
12
13
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { ActionLogMoneySchema } from './action-log-money.schema';
|
|
2
3
|
|
|
3
4
|
export const OrderProductInfoSchema = z.object({
|
|
4
5
|
orderUUID: z.string(),
|
|
@@ -8,7 +9,7 @@ export const OrderProductInfoSchema = z.object({
|
|
|
8
9
|
categoryUUID: z.string().nullable(),
|
|
9
10
|
categoryName: z.string().nullable(),
|
|
10
11
|
quantity: z.coerce.number(),
|
|
11
|
-
price:
|
|
12
|
+
price: ActionLogMoneySchema,
|
|
12
13
|
consignmentUUID: z.string().nullable(),
|
|
13
14
|
consignmentDeliveryDate: z.coerce.date().nullable(),
|
|
14
15
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { OrderProductInfoSchema } from './order-product-info.schema';
|
|
3
|
+
import { ActionLogMoneySchema } from './action-log-money.schema';
|
|
3
4
|
|
|
4
5
|
export const OrderProductUpdateActionLogSchema = z.object({
|
|
5
6
|
orderProduct: OrderProductInfoSchema,
|
|
6
7
|
newQuantity: z.coerce.number(),
|
|
7
|
-
newPrice:
|
|
8
|
+
newPrice: ActionLogMoneySchema,
|
|
8
9
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { ActionLogMoneySchema } from './action-log-money.schema';
|
|
2
3
|
|
|
3
4
|
export const PreOrderProductInfoSchema = z.object({
|
|
4
5
|
preOrderUUID: z.string(),
|
|
@@ -6,6 +7,6 @@ export const PreOrderProductInfoSchema = z.object({
|
|
|
6
7
|
name: z.string(),
|
|
7
8
|
categoryName: z.string().nullable(),
|
|
8
9
|
quantity: z.coerce.number(),
|
|
9
|
-
price:
|
|
10
|
+
price: ActionLogMoneySchema,
|
|
10
11
|
comment: z.string().nullable(),
|
|
11
12
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { PreOrderProductInfoSchema } from './pre-order-product-info.schema';
|
|
3
|
+
import { ActionLogMoneySchema } from './action-log-money.schema';
|
|
3
4
|
|
|
4
5
|
export const PreOrderProductUpdateActionLogSchema = z.object({
|
|
5
6
|
preOrderProduct: PreOrderProductInfoSchema,
|
|
6
7
|
newQuantity: z.coerce.number(),
|
|
7
|
-
newPrice:
|
|
8
|
+
newPrice: ActionLogMoneySchema,
|
|
8
9
|
newComment: z.string().nullable(),
|
|
9
10
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { TransactionTypeEnum } from '../../enum';
|
|
3
|
+
import { ActionLogMoneySchema } from './action-log-money.schema';
|
|
3
4
|
|
|
4
5
|
export const TransactionInfoSchema = z.object({
|
|
5
6
|
transactionUUID: z.string(),
|
|
6
7
|
createdAt: z.coerce.date(),
|
|
7
|
-
amount:
|
|
8
|
+
amount: ActionLogMoneySchema,
|
|
8
9
|
moneyAccountName: z.string(),
|
|
9
10
|
type: z.nativeEnum(TransactionTypeEnum),
|
|
10
11
|
clientName: z.string().nullable(),
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BankProviderEnum } from '../../enum/bank-provider.enum';
|
|
3
3
|
import { BankPaymentEventStatusEnum } from '../../enum/bank-payment-event-status.enum';
|
|
4
|
+
import { MoneySchema } from '../money.schema';
|
|
4
5
|
|
|
5
6
|
export const BankPaymentSchema = z.object({
|
|
6
7
|
uuid: z.uuid(),
|
|
7
8
|
provider: z.nativeEnum(BankProviderEnum),
|
|
8
9
|
externalEventId: z.string(),
|
|
9
10
|
accountNumber: z.string(),
|
|
10
|
-
amount:
|
|
11
|
+
amount: MoneySchema,
|
|
11
12
|
currency: z.string(),
|
|
12
13
|
purpose: z.string(),
|
|
13
14
|
status: z.nativeEnum(BankPaymentEventStatusEnum),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { MoneySchema } from '../money.schema';
|
|
2
3
|
|
|
3
4
|
export const ClientDebtItemSchema = z.object({
|
|
4
5
|
clientUUID: z.uuid(),
|
|
@@ -7,11 +8,13 @@ export const ClientDebtItemSchema = z.object({
|
|
|
7
8
|
group: z.string().nullable(),
|
|
8
9
|
city: z.string().nullable(),
|
|
9
10
|
responsibleUserName: z.string().nullable(),
|
|
10
|
-
currentBalance:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
currentBalance: MoneySchema,
|
|
12
|
+
// Знаковые величины: сальдо транзакций и остатки по заказам законно уходят в минус
|
|
13
|
+
// (переплата клиента, возврат), поэтому ограничения на знак здесь нет и быть не должно.
|
|
14
|
+
transactionNet: MoneySchema,
|
|
15
|
+
completedOrdersBalance: MoneySchema,
|
|
16
|
+
completedOrdersBalanceWithDelay: MoneySchema,
|
|
17
|
+
nonCompletedBalance: MoneySchema,
|
|
15
18
|
hasOverdueDebt: z.boolean().nullable(),
|
|
16
19
|
});
|
|
17
20
|
|
|
@@ -7,6 +7,7 @@ import { ClientIndividualProfileSchema } from './client-individual-profile.schem
|
|
|
7
7
|
import { ClientLegalProfileSchema } from './client-legal-profile.schema';
|
|
8
8
|
import { DiscountRulesSchema } from '../discount-rules/discount-rules.schema';
|
|
9
9
|
import { ClientMarkingSchema } from './client-marking.schema';
|
|
10
|
+
import { MoneySchema } from '../money.schema';
|
|
10
11
|
|
|
11
12
|
export const ClientSchema = z.object({
|
|
12
13
|
uuid: z.uuid(),
|
|
@@ -29,7 +30,7 @@ export const ClientSchema = z.object({
|
|
|
29
30
|
comment: z.string().nullable(),
|
|
30
31
|
paymentGraceDaysAfterCompletion: z.number().nullable(),
|
|
31
32
|
|
|
32
|
-
balance:
|
|
33
|
+
balance: MoneySchema,
|
|
33
34
|
|
|
34
35
|
deletedAt: z.date().nullable(),
|
|
35
36
|
createdAt: z.date(),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ConsignmentImportSchemaRelationEntityPropertyEnum, ConsignmentStatusEnum, ConsingmentImportErrorsEnum } from '../../enum';
|
|
3
3
|
import { ClientSchema } from '../client';
|
|
4
|
+
import { MoneySchema } from '../money.schema';
|
|
4
5
|
|
|
5
6
|
export const ConsignmentSchema = z.object({
|
|
6
7
|
uuid: z.uuid(),
|
|
@@ -20,25 +21,25 @@ export const ConsignmentSchema = z.object({
|
|
|
20
21
|
|
|
21
22
|
export const ConsignmentWithStatisticForListSchema = ConsignmentSchema.extend({
|
|
22
23
|
statistic: z.object({
|
|
23
|
-
totalCostPrice:
|
|
24
|
+
totalCostPrice: MoneySchema,
|
|
24
25
|
currentProductBalance: z.number(),
|
|
25
|
-
currentCostPrice:
|
|
26
|
+
currentCostPrice: MoneySchema,
|
|
26
27
|
totalProductQuantity: z.number(),
|
|
27
|
-
totalSellings:
|
|
28
|
-
totalApprovedWriteOffSellings:
|
|
28
|
+
totalSellings: MoneySchema,
|
|
29
|
+
totalApprovedWriteOffSellings: MoneySchema,
|
|
29
30
|
}),
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
export const ConsignmentWithStatisticSchema = ConsignmentSchema.extend({
|
|
33
34
|
statistic: z.object({
|
|
34
|
-
totalCostPrice:
|
|
35
|
+
totalCostPrice: MoneySchema,
|
|
35
36
|
currentProductBalance: z.number(),
|
|
36
|
-
currentCostPrice:
|
|
37
|
+
currentCostPrice: MoneySchema,
|
|
37
38
|
totalProductQuantity: z.number(),
|
|
38
|
-
totalSellings:
|
|
39
|
+
totalSellings: MoneySchema,
|
|
39
40
|
writeOffQuantity: z.number(),
|
|
40
|
-
writeOffCostPrice:
|
|
41
|
-
writeOffCostPriceByOrderProduct:
|
|
41
|
+
writeOffCostPrice: MoneySchema,
|
|
42
|
+
writeOffCostPriceByOrderProduct: MoneySchema,
|
|
42
43
|
}),
|
|
43
44
|
});
|
|
44
45
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ConsignmentTransferRequestSchema } from './consignment-transfer-request.schema';
|
|
3
|
+
import { MoneySchema } from '../money.schema';
|
|
4
|
+
import { NonNegativeMoneySchema } from '../non-negative-money.schema';
|
|
3
5
|
|
|
4
6
|
export const AcceptConsignmentTransferRequestSchema = z
|
|
5
7
|
.object({
|
|
@@ -17,7 +19,8 @@ export const AcceptConsignmentTransferRequestSchema = z
|
|
|
17
19
|
z.object({
|
|
18
20
|
itemUUID: z.uuid(),
|
|
19
21
|
categoryUUID: z.uuid(),
|
|
20
|
-
|
|
22
|
+
// Отрицательную цену отсекаем по знаку строки — минус и есть признак отрицательности.
|
|
23
|
+
price: NonNegativeMoneySchema.optional(),
|
|
21
24
|
}),
|
|
22
25
|
)
|
|
23
26
|
.min(1),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { MoneySchema } from '../money.schema';
|
|
2
3
|
|
|
3
4
|
export const ConsignmentTransferRequestItemSchema = z.object({
|
|
4
5
|
uuid: z.uuid(),
|
|
@@ -6,7 +7,7 @@ export const ConsignmentTransferRequestItemSchema = z.object({
|
|
|
6
7
|
targetProductUUID: z.uuid().nullable(),
|
|
7
8
|
name: z.string(),
|
|
8
9
|
quantity: z.number().int(),
|
|
9
|
-
transferPrice:
|
|
10
|
+
transferPrice: MoneySchema,
|
|
10
11
|
categoryName: z.string().nullable(),
|
|
11
12
|
multiplicity: z.number().int(),
|
|
12
13
|
grower: z.string().nullable(),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { DeliveryRouteStatusEnum, OrderDeliveryStatusEnum, OrderStatusEnum } from '../../enum';
|
|
3
|
+
import { MoneySchema } from '../money.schema';
|
|
3
4
|
|
|
4
5
|
export const DeliveryRouteSchema = z.object({
|
|
5
6
|
uuid: z.uuid(),
|
|
@@ -34,7 +35,7 @@ export const DeliveryRouteWithOrdersSchema = DeliveryRouteSchema.extend({
|
|
|
34
35
|
orderNumber: z.number(),
|
|
35
36
|
orderStatus: z.nativeEnum(OrderStatusEnum),
|
|
36
37
|
orderCreatedAt: z.coerce.date(),
|
|
37
|
-
totalCost:
|
|
38
|
+
totalCost: MoneySchema,
|
|
38
39
|
clientName: z.string(),
|
|
39
40
|
clientCity: z.string().nullable(),
|
|
40
41
|
clientAddress: z.string().nullable(),
|
|
@@ -2,10 +2,17 @@ import { z } from 'zod';
|
|
|
2
2
|
import { DiscountRulesTypeEnum, DiscountRulesApplyTypeEnum, DiscountRulesStatusEnum, DiscountRulesModeTypeEnum } from '../../enum';
|
|
3
3
|
import { ClientSchema } from '../client';
|
|
4
4
|
import { ProductSchema } from '../product/product.schema';
|
|
5
|
+
import { MoneySchema } from '../money.schema';
|
|
6
|
+
import { PositiveMoneySchema } from '../positive-money.schema';
|
|
5
7
|
|
|
8
|
+
// PERCENT — это процент, а не деньги: остаётся числом 0..100. FIXED — денежная величина, едет строкой.
|
|
6
9
|
export const discountRulesModeSchema = z.discriminatedUnion('typeDiscount', [
|
|
7
10
|
z.object({ typeDiscount: z.literal(DiscountRulesModeTypeEnum.PERCENT), discountValue: z.number().min(0).max(100) }),
|
|
8
|
-
z.object({
|
|
11
|
+
z.object({
|
|
12
|
+
typeDiscount: z.literal(DiscountRulesModeTypeEnum.FIXED),
|
|
13
|
+
// Строго положительная сумма: минус отсекаем по знаку строки, нули вида "0" / "0.00" — сравнением.
|
|
14
|
+
discountValue: PositiveMoneySchema,
|
|
15
|
+
}),
|
|
9
16
|
]);
|
|
10
17
|
|
|
11
18
|
// Rules schemas other data
|
|
@@ -113,7 +120,7 @@ export const DiscountRulesSplitQuantityResponseSchema = z.object({
|
|
|
113
120
|
productUUID: z.string(),
|
|
114
121
|
quantity: z.number(),
|
|
115
122
|
withDiscount: z.boolean(),
|
|
116
|
-
price:
|
|
123
|
+
price: MoneySchema,
|
|
117
124
|
})
|
|
118
125
|
.array()
|
|
119
126
|
.nullable(),
|
package/schemas/index.ts
CHANGED
|
@@ -77,3 +77,7 @@ export * from './account-deletion-request/account-deletion-request.schema';
|
|
|
77
77
|
export * from './consignment-transfer';
|
|
78
78
|
export * from './api-error.schema';
|
|
79
79
|
export * from './access-policy';
|
|
80
|
+
export * from './money.schema';
|
|
81
|
+
export * from './non-negative-money.schema';
|
|
82
|
+
export * from './positive-money.schema';
|
|
83
|
+
export * from './report/report-order-filter.schema';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { MoneyAccountSchema } from './money-account.schema';
|
|
3
|
+
import { MoneySchema } from '../money.schema';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Денежный счёт в ответах списков. `balance` — текущий остаток счёта (приход минус расход),
|
|
@@ -7,5 +8,5 @@ import { MoneyAccountSchema } from './money-account.schema';
|
|
|
7
8
|
* получают ровно прежнюю форму ответа.
|
|
8
9
|
*/
|
|
9
10
|
export const MoneyAccountWithBalanceSchema = MoneyAccountSchema.extend({
|
|
10
|
-
balance:
|
|
11
|
+
balance: MoneySchema.optional(),
|
|
11
12
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Единственное описание денежной величины в контрактах.
|
|
5
|
+
*
|
|
6
|
+
* Деньги пересекают границу строкой — точным десятичным представлением, а не float64.
|
|
7
|
+
* `"8755.48"` доезжает до получателя ровно таким, каким его отправили: ни JSON.parse, ни
|
|
8
|
+
* арифметика на `number` больше не участвуют в передаче, поэтому двоичный мусор вида
|
|
9
|
+
* `8755.479000000001` физически неоткуда взяться. Каждая сторона разбирает строку своей
|
|
10
|
+
* реализацией Decimal: сервер — Prisma.Decimal, клиент — своей библиотекой.
|
|
11
|
+
*
|
|
12
|
+
* В `libs/contracts` намеренно НЕТ зависимости от decimal-библиотеки: пакет публикуется как
|
|
13
|
+
* `@floristcloud/api-lib` и ставится в браузерные бандлы, где лишняя зависимость — это лишние
|
|
14
|
+
* килобайты и риск конфликта версий с той Decimal-реализацией, которую уже выбрал клиент.
|
|
15
|
+
* Контракт описывает формат провода, а не арифметику.
|
|
16
|
+
*
|
|
17
|
+
* Формат: необязательный минус, целая часть, до двух знаков после точки. Знак минуса —
|
|
18
|
+
* единственный признак отрицательной величины.
|
|
19
|
+
*
|
|
20
|
+
* Сама по себе схема знак не ограничивает: разницы, сальдо и балансы клиентов законно уходят
|
|
21
|
+
* в минус. Там, где величина не может быть отрицательной или нулевой, берите готовые
|
|
22
|
+
* `NonNegativeMoneySchema` и `PositiveMoneySchema` — не повторяйте `refine` по месту.
|
|
23
|
+
* Модификаторы `.optional()` и `.nullable()` работают напрямую.
|
|
24
|
+
*/
|
|
25
|
+
export const MoneySchema = z.string().regex(/^-?\d+(\.\d{1,2})?$/);
|