@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.
Files changed (173) hide show
  1. package/build/commands/client/get-client-calculate.query.js +6 -4
  2. package/build/commands/consignment/execute-consignment-product-update.command.js +5 -4
  3. package/build/commands/integration/moysklad/execute-moysklad-import.command.js +3 -2
  4. package/build/commands/integration/moysklad/preview-moysklad-products.query.js +3 -2
  5. package/build/commands/integration/moysklad/scan-moysklad-import.query.js +3 -2
  6. package/build/commands/order/create-order.command.js +2 -1
  7. package/build/commands/order/update-order.command.js +3 -2
  8. package/build/commands/order/webshop/get-order-sales-by-month.query.js +2 -1
  9. package/build/commands/order-product/create-order-product.command.js +2 -1
  10. package/build/commands/order-product/group/price-valuation-execute.command.js +3 -1
  11. package/build/commands/order-product/update-order-product.command.js +2 -1
  12. package/build/commands/payment-invoice/create-payment-invoice.command.js +3 -1
  13. package/build/commands/payment-invoice/pay-payment-invoice.command.js +3 -1
  14. package/build/commands/pre-order-collection-item/execute-pre-order-collection-item-update.command.js +3 -2
  15. package/build/commands/pre-order-collection-item/multiplicity-option/create-pre-order-collection-item-multiplicity-option.command.js +2 -1
  16. package/build/commands/pre-order-collection-item/multiplicity-option/update-pre-order-collection-item-multiplicity-option.command.js +2 -1
  17. package/build/commands/product/create-product.command.js +4 -3
  18. package/build/commands/product/group/update-group-product-prices.command.js +3 -2
  19. package/build/commands/product/group/update-group-product-update-batch.command.js +4 -3
  20. package/build/commands/product/multiplicity-option/create-product-multiplicity-option.command.js +2 -1
  21. package/build/commands/product/multiplicity-option/update-product-multiplicity-option.command.js +2 -1
  22. package/build/commands/product/update-product.command.js +4 -3
  23. package/build/commands/report/export-sales-by-client.query.js +3 -0
  24. package/build/commands/report/export-sales-by-position.query.js +3 -0
  25. package/build/commands/report/export-sales-revenue.query.js +3 -0
  26. package/build/commands/report/get-cash-flow.query.js +8 -5
  27. package/build/commands/report/get-daily-orders-summary.query.js +2 -1
  28. package/build/commands/report/get-report-for-period.query.js +10 -9
  29. package/build/commands/report/get-report-group-by-client.query.js +15 -10
  30. package/build/commands/report/get-report-group-by-position.query.js +15 -14
  31. package/build/commands/report/get-sales-by-client.query.js +3 -0
  32. package/build/commands/report/get-sales-summary.query.js +17 -11
  33. package/build/commands/transaction/generate-check-transaction.command.js +2 -1
  34. package/build/commands/transaction/generate-pre-payment-check.command.js +2 -1
  35. package/build/commands/transaction/get-sum-transaction-by-money-account.query.js +3 -1
  36. package/build/commands/transaction/get-transaction-summary.query.js +5 -3
  37. package/build/commands/write-off/get-write-off-sum-by-order.query.js +3 -1
  38. package/build/commands/write-off/update-write-off-price.command.js +2 -1
  39. package/build/constant/index.js +1 -0
  40. package/build/constant/report.constant.js +9 -0
  41. package/build/enum/index.js +1 -0
  42. package/build/enum/report-order-date-basis.enum.js +18 -0
  43. package/build/schemas/action-log/action-log-money.schema.js +28 -0
  44. package/build/schemas/action-log/index.js +1 -0
  45. package/build/schemas/action-log/order-info.schema.js +3 -2
  46. package/build/schemas/action-log/order-product-info.schema.js +2 -1
  47. package/build/schemas/action-log/order-product-update-action-log.schema.js +2 -1
  48. package/build/schemas/action-log/pre-order-product-info.schema.js +2 -1
  49. package/build/schemas/action-log/pre-order-product-update-action-log.schema.js +2 -1
  50. package/build/schemas/action-log/transaction-info.schema.js +2 -1
  51. package/build/schemas/bank-payment/bank-payment.schema.js +2 -1
  52. package/build/schemas/client/client-debt.schema.js +8 -5
  53. package/build/schemas/client/client.schema.js +2 -1
  54. package/build/schemas/consignment/consignment.schema.js +10 -9
  55. package/build/schemas/consignment-transfer/accept-consignment-transfer.schema.js +3 -1
  56. package/build/schemas/consignment-transfer/consignment-transfer-request-item.schema.js +2 -1
  57. package/build/schemas/delivery-route/delivery-route.schema.js +2 -1
  58. package/build/schemas/discount-rules/discount-rules.schema.js +9 -2
  59. package/build/schemas/index.js +4 -0
  60. package/build/schemas/money-account/money-account-with-balance.schema.js +2 -2
  61. package/build/schemas/money.schema.js +27 -0
  62. package/build/schemas/non-negative-money.schema.js +17 -0
  63. package/build/schemas/order/order.schema.js +10 -9
  64. package/build/schemas/order-product/order-product-multiplicity-optiom.schema.js +2 -1
  65. package/build/schemas/order-product/order-product.schema.js +5 -4
  66. package/build/schemas/order-product/price-correction-analyze-item.schema.js +10 -8
  67. package/build/schemas/order-product/price-correction-execute-result-item.schema.js +3 -2
  68. package/build/schemas/order-service-line/order-service-line.schema.js +12 -5
  69. package/build/schemas/payment-invoice/payment-invoice.schema.js +5 -4
  70. package/build/schemas/positive-money.schema.js +18 -0
  71. package/build/schemas/pre-order/pre-order.schema.js +2 -1
  72. package/build/schemas/pre-order-collection-item/pre-order-collection-item-multiplicity-option.schema.js +2 -1
  73. package/build/schemas/pre-order-collection-item/pre-order-collection-item.schema.js +4 -3
  74. package/build/schemas/pre-order-product/pre-order-product.schema.js +5 -4
  75. package/build/schemas/product/product-multiplicity-option.schema.js +2 -1
  76. package/build/schemas/product/product.schema.js +6 -5
  77. package/build/schemas/report/client-by-weeks.schema.js +2 -1
  78. package/build/schemas/report/client-statement.schema.js +2 -1
  79. package/build/schemas/report/inventory-turnover-category-item.schema.js +1 -1
  80. package/build/schemas/report/inventory-turnover-detailed-item.schema.js +1 -1
  81. package/build/schemas/report/report-order-filter.schema.js +28 -0
  82. package/build/schemas/report/sales-by-client-row.schema.js +9 -8
  83. package/build/schemas/report/sales-by-client-top-item.schema.js +2 -1
  84. package/build/schemas/service/service.schema.js +8 -3
  85. package/build/schemas/settings/settings.schema.js +6 -2
  86. package/build/schemas/transaction/transaction.schema.js +2 -1
  87. package/commands/client/get-client-calculate.query.ts +6 -4
  88. package/commands/consignment/execute-consignment-product-update.command.ts +5 -4
  89. package/commands/integration/moysklad/execute-moysklad-import.command.ts +3 -2
  90. package/commands/integration/moysklad/preview-moysklad-products.query.ts +3 -2
  91. package/commands/integration/moysklad/scan-moysklad-import.query.ts +3 -2
  92. package/commands/order/create-order.command.ts +2 -1
  93. package/commands/order/update-order.command.ts +3 -2
  94. package/commands/order/webshop/get-order-sales-by-month.query.ts +3 -1
  95. package/commands/order-product/create-order-product.command.ts +2 -1
  96. package/commands/order-product/group/price-valuation-execute.command.ts +4 -1
  97. package/commands/order-product/update-order-product.command.ts +2 -1
  98. package/commands/payment-invoice/create-payment-invoice.command.ts +4 -1
  99. package/commands/payment-invoice/pay-payment-invoice.command.ts +4 -1
  100. package/commands/pre-order-collection-item/execute-pre-order-collection-item-update.command.ts +3 -2
  101. package/commands/pre-order-collection-item/multiplicity-option/create-pre-order-collection-item-multiplicity-option.command.ts +3 -1
  102. package/commands/pre-order-collection-item/multiplicity-option/update-pre-order-collection-item-multiplicity-option.command.ts +3 -1
  103. package/commands/product/create-product.command.ts +4 -3
  104. package/commands/product/group/update-group-product-prices.command.ts +3 -2
  105. package/commands/product/group/update-group-product-update-batch.command.ts +4 -3
  106. package/commands/product/multiplicity-option/create-product-multiplicity-option.command.ts +3 -1
  107. package/commands/product/multiplicity-option/update-product-multiplicity-option.command.ts +3 -1
  108. package/commands/product/update-product.command.ts +4 -3
  109. package/commands/report/export-sales-by-client.query.ts +3 -0
  110. package/commands/report/export-sales-by-position.query.ts +3 -0
  111. package/commands/report/export-sales-revenue.query.ts +3 -0
  112. package/commands/report/get-cash-flow.query.ts +8 -5
  113. package/commands/report/get-daily-orders-summary.query.ts +2 -1
  114. package/commands/report/get-report-for-period.query.ts +10 -9
  115. package/commands/report/get-report-group-by-client.query.ts +15 -10
  116. package/commands/report/get-report-group-by-position.query.ts +15 -14
  117. package/commands/report/get-sales-by-client.query.ts +3 -0
  118. package/commands/report/get-sales-summary.query.ts +17 -11
  119. package/commands/transaction/generate-check-transaction.command.ts +2 -1
  120. package/commands/transaction/generate-pre-payment-check.command.ts +2 -1
  121. package/commands/transaction/get-sum-transaction-by-money-account.query.ts +3 -1
  122. package/commands/transaction/get-transaction-summary.query.ts +5 -3
  123. package/commands/write-off/get-write-off-sum-by-order.query.ts +4 -1
  124. package/commands/write-off/update-write-off-price.command.ts +2 -1
  125. package/constant/index.ts +1 -0
  126. package/constant/report.constant.ts +6 -0
  127. package/enum/index.ts +1 -0
  128. package/enum/report-order-date-basis.enum.ts +14 -0
  129. package/package.json +1 -1
  130. package/schemas/action-log/action-log-money.schema.ts +26 -0
  131. package/schemas/action-log/index.ts +1 -0
  132. package/schemas/action-log/order-info.schema.ts +3 -2
  133. package/schemas/action-log/order-product-info.schema.ts +2 -1
  134. package/schemas/action-log/order-product-update-action-log.schema.ts +2 -1
  135. package/schemas/action-log/pre-order-product-info.schema.ts +2 -1
  136. package/schemas/action-log/pre-order-product-update-action-log.schema.ts +2 -1
  137. package/schemas/action-log/transaction-info.schema.ts +2 -1
  138. package/schemas/bank-payment/bank-payment.schema.ts +2 -1
  139. package/schemas/client/client-debt.schema.ts +8 -5
  140. package/schemas/client/client.schema.ts +2 -1
  141. package/schemas/consignment/consignment.schema.ts +10 -9
  142. package/schemas/consignment-transfer/accept-consignment-transfer.schema.ts +4 -1
  143. package/schemas/consignment-transfer/consignment-transfer-request-item.schema.ts +2 -1
  144. package/schemas/delivery-route/delivery-route.schema.ts +2 -1
  145. package/schemas/discount-rules/discount-rules.schema.ts +9 -2
  146. package/schemas/index.ts +4 -0
  147. package/schemas/money-account/money-account-with-balance.schema.ts +2 -1
  148. package/schemas/money.schema.ts +25 -0
  149. package/schemas/non-negative-money.schema.ts +15 -0
  150. package/schemas/order/order.schema.ts +10 -9
  151. package/schemas/order-product/order-product-multiplicity-optiom.schema.ts +2 -1
  152. package/schemas/order-product/order-product.schema.ts +5 -4
  153. package/schemas/order-product/price-correction-analyze-item.schema.ts +10 -8
  154. package/schemas/order-product/price-correction-execute-result-item.schema.ts +3 -2
  155. package/schemas/order-service-line/order-service-line.schema.ts +13 -5
  156. package/schemas/payment-invoice/payment-invoice.schema.ts +5 -4
  157. package/schemas/positive-money.schema.ts +16 -0
  158. package/schemas/pre-order/pre-order.schema.ts +2 -1
  159. package/schemas/pre-order-collection-item/pre-order-collection-item-multiplicity-option.schema.ts +3 -1
  160. package/schemas/pre-order-collection-item/pre-order-collection-item.schema.ts +4 -3
  161. package/schemas/pre-order-product/pre-order-product.schema.ts +5 -4
  162. package/schemas/product/product-multiplicity-option.schema.ts +2 -1
  163. package/schemas/product/product.schema.ts +6 -5
  164. package/schemas/report/client-by-weeks.schema.ts +2 -1
  165. package/schemas/report/client-statement.schema.ts +2 -1
  166. package/schemas/report/inventory-turnover-category-item.schema.ts +1 -1
  167. package/schemas/report/inventory-turnover-detailed-item.schema.ts +1 -1
  168. package/schemas/report/report-order-filter.schema.ts +26 -0
  169. package/schemas/report/sales-by-client-row.schema.ts +9 -8
  170. package/schemas/report/sales-by-client-top-item.schema.ts +2 -1
  171. package/schemas/service/service.schema.ts +9 -3
  172. package/schemas/settings/settings.schema.ts +7 -2
  173. package/schemas/transaction/transaction.schema.ts +2 -1
@@ -6,10 +6,11 @@ const enum_1 = require("../../enum");
6
6
  const money_account_schema_1 = require("../money-account/money-account.schema");
7
7
  const client_1 = require("../client");
8
8
  const order_schema_1 = require("../order/order.schema");
9
+ const money_schema_1 = require("../money.schema");
9
10
  exports.TransactionSchema = zod_1.z.object({
10
11
  uuid: zod_1.z.uuid(),
11
12
  moneyAccountUUID: zod_1.z.uuid(),
12
- amount: zod_1.z.number(),
13
+ amount: money_schema_1.MoneySchema,
13
14
  comment: zod_1.z.string(),
14
15
  clientUUID: zod_1.z.string().nullable(),
15
16
  orderUUID: zod_1.z.string().nullable(),
@@ -1,12 +1,14 @@
1
1
  import { z } from 'zod';
2
+ import { MoneySchema } from '../../schemas/money.schema';
2
3
 
3
4
  const GetClientCalculateResponseSchema = z.object({
4
5
  message: z.string().optional(),
5
6
  data: z.object({
6
- transactionSum: z.number(),
7
- ordersSum: z.number(),
8
- writeOffSum: z.number(),
9
- calculation: z.number(),
7
+ transactionSum: MoneySchema,
8
+ ordersSum: MoneySchema,
9
+ writeOffSum: MoneySchema,
10
+ // Сальдо по клиенту: может быть отрицательным, поэтому знаковых ограничений нет.
11
+ calculation: MoneySchema,
10
12
  }),
11
13
  });
12
14
 
@@ -1,10 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { ErrorMessageSchema } from '../../schemas/error-message.schema';
3
+ import { MoneySchema } from '../../schemas/money.schema';
3
4
 
4
5
  const OptionUpdateSchema = z.object({
5
6
  title: z.string().nullable().optional(),
6
7
  optionMultiplicity: z.number().nullable().optional(),
7
- optionPrice: z.number().nullable().optional(),
8
+ optionPrice: MoneySchema.nullable().optional(),
8
9
  });
9
10
 
10
11
  const ConsignmentProductPositionUpdateSchema = z.object({
@@ -12,9 +13,9 @@ const ConsignmentProductPositionUpdateSchema = z.object({
12
13
  multiplicity: z.number().nullable().optional(),
13
14
  quantity: z.number().nullable().optional(),
14
15
  balance: z.number().nullable().optional(),
15
- price: z.number().nullable().optional(),
16
- costPrice: z.number().nullable().optional(),
17
- invoicePrice: z.number().nullable().optional(),
16
+ price: MoneySchema.nullable().optional(),
17
+ costPrice: MoneySchema.nullable().optional(),
18
+ invoicePrice: MoneySchema.nullable().optional(),
18
19
  invoiceNumber: z.string().nullable().optional(),
19
20
  multiplicityDescription: z.string().nullable().optional(),
20
21
  vat: z.number().nullable().optional(),
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { SalesUnitEnum } from '../../../enum';
3
+ import { MoneySchema } from '../../../schemas/money.schema';
3
4
 
4
5
  const ExecutableItemSchema = z.object({
5
6
  externalSourceId: z.string(),
@@ -11,8 +12,8 @@ const ExecutableItemSchema = z.object({
11
12
  color: z.string().nullable(),
12
13
  country: z.string().nullable(),
13
14
  grower: z.string().nullable(),
14
- price: z.number(),
15
- costPrice: z.number(),
15
+ price: MoneySchema,
16
+ costPrice: MoneySchema,
16
17
  balance: z.number(),
17
18
  vat: z.number().nullable(),
18
19
  salesUnit: z.nativeEnum(SalesUnitEnum),
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { MoneySchema } from '../../../schemas/money.schema';
2
3
 
3
4
  const PreviewMoyskladProductsRequestSchema = z.object({
4
5
  limit: z.coerce.number().int().min(1).max(100).default(20),
@@ -13,8 +14,8 @@ const MappedProductPreviewSchema = z.object({
13
14
  color: z.string().nullable(),
14
15
  country: z.string().nullable(),
15
16
  grower: z.string().nullable(),
16
- price: z.number(),
17
- costPrice: z.number(),
17
+ price: MoneySchema,
18
+ costPrice: MoneySchema,
18
19
  balance: z.number(),
19
20
  categoryName: z.string().nullable(),
20
21
  });
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { SalesUnitEnum } from '../../../enum';
3
+ import { MoneySchema } from '../../../schemas/money.schema';
3
4
 
4
5
  const ScannedItemSchema = z.object({
5
6
  externalSourceId: z.string(),
@@ -13,8 +14,8 @@ const ScannedItemSchema = z.object({
13
14
  color: z.string().nullable(),
14
15
  country: z.string().nullable(),
15
16
  grower: z.string().nullable(),
16
- price: z.number(),
17
- costPrice: z.number(),
17
+ price: MoneySchema,
18
+ costPrice: MoneySchema,
18
19
  balance: z.number(),
19
20
  categoryName: z.string().nullable(),
20
21
  vat: z.number().nullable(),
@@ -1,11 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { OrderTypeEnum } from '../../enum';
3
3
  import { OrderDeliverySchema, OrderSchema } from '../../schemas';
4
+ import { MoneySchema } from '../../schemas/money.schema';
4
5
 
5
6
  const CreateOrderRequestSchema = z.object({
6
7
  clientUUID: z.uuid(),
7
8
  branchUUID: z.uuid().nullable(),
8
- deliveryCost: z.number(),
9
+ deliveryCost: MoneySchema,
9
10
  deliveryVat: z.number().nullable(),
10
11
  type: z.nativeEnum(OrderTypeEnum),
11
12
  comment: z.string().nullable(),
@@ -1,11 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { OrderStatusEnum, OrderTypeEnum } from '../../enum';
3
3
  import { OrderSchema } from '../../schemas';
4
+ import { MoneySchema } from '../../schemas/money.schema';
4
5
 
5
6
  const UpdateOrderRequestSchema = z.object({
6
7
  clientUUID: z.uuid(),
7
8
  branchUUID: z.uuid().nullable(),
8
- deliveryCost: z.coerce.number(),
9
+ deliveryCost: MoneySchema,
9
10
  type: z.nativeEnum(OrderTypeEnum),
10
11
  comment: z.string().nullable(),
11
12
  clientComment: z.string().nullable(),
@@ -13,7 +14,7 @@ const UpdateOrderRequestSchema = z.object({
13
14
  status: z.nativeEnum(OrderStatusEnum),
14
15
  isPaid: z.coerce.boolean(),
15
16
  deliveryVat: z.coerce.number().nullable(),
16
- deliveryVatAmount: z.coerce.number(),
17
+ deliveryVatAmount: MoneySchema,
17
18
  completedAt: z.coerce.date().nullable().optional(),
18
19
  paymentDueAt: z.coerce.date().nullable().optional(),
19
20
  });
@@ -1,4 +1,6 @@
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 GetOrderSalesByMonthRequestSchema = z.object({
4
6
  month: z.coerce.number().int().min(1).max(12),
@@ -6,7 +8,7 @@ const GetOrderSalesByMonthRequestSchema = z.object({
6
8
 
7
9
  const GetOrderSalesByMonthResponseSchema = z.object({
8
10
  message: z.string().optional(),
9
- data: z.number(),
11
+ data: NonNegativeMoneySchema,
10
12
  });
11
13
 
12
14
  export namespace GetOrderSalesByMonthContractQuery {
@@ -1,9 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  import { OrderProductSchema } from '../../schemas';
3
+ import { MoneySchema } from '../../schemas/money.schema';
3
4
 
4
5
  const CreateOrderProductRequestSchema = z.object({
5
6
  quantity: z.number(),
6
- price: z.number(),
7
+ price: MoneySchema,
7
8
  comment: z.string().nullable(),
8
9
  tag: z.string().nullable(),
9
10
  isEditable: z.coerce.boolean(),
@@ -1,11 +1,14 @@
1
1
  import { z } from 'zod';
2
2
  import { PriceCorrectionExecuteResultItemSchema } from '../../../schemas';
3
+ import { MoneySchema } from '../../../schemas/money.schema';
4
+ import { NonNegativeMoneySchema } from '../../../schemas/non-negative-money.schema';
3
5
 
4
6
  const PRICE_VALUATION_BATCH_LIMIT = 50;
5
7
 
6
8
  const PriceValuationExecuteItemSchema = z.object({
7
9
  orderProductUUID: z.string().uuid(),
8
- price: z.number().nonnegative(),
10
+ // Неотрицательность проверяем по знаку строки: минус — единственный признак отрицательной суммы.
11
+ price: NonNegativeMoneySchema,
9
12
  });
10
13
 
11
14
  const PriceValuationExecuteRequestSchema = z.object({
@@ -1,10 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { OrderProductSchema } from '../../schemas';
3
+ import { MoneySchema } from '../../schemas/money.schema';
3
4
 
4
5
  const UpdateOrderProductRequestSchema = z.object({
5
6
  productUUID: z.uuid(),
6
7
  quantity: z.number(),
7
- price: z.number(),
8
+ price: MoneySchema,
8
9
  comment: z.string().nullable(),
9
10
  tag: z.string().nullable(),
10
11
  isEditable: z.coerce.boolean(),
@@ -1,5 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { PaymentInvoiceSchema } from '../../schemas/payment-invoice/payment-invoice.schema';
3
+ import { MoneySchema } from '../../schemas/money.schema';
4
+ import { PositiveMoneySchema } from '../../schemas/positive-money.schema';
3
5
 
4
6
  // Потолок числа заказов в счёте. Это защита от абсурдного запроса, а не бизнес-правило: счёт за месяц
5
7
  // клиенту с ежедневными поставками — это уже 30 строк, поэтому 10-20 отрезали бы живые сценарии.
@@ -15,7 +17,8 @@ const CreatePaymentInvoiceRequestSchema = z
15
17
  clientUUID: z.uuid(),
16
18
  invoiceDate: z.coerce.date(),
17
19
  orderUUIDs: z.uuid().array().max(MAX_INVOICE_ORDER_COUNT).optional(),
18
- amount: z.coerce.number().positive().optional(),
20
+ // Строго положительная сумма: отсекаем минус по знаку строки и нулевые записи вида "0" / "0.00".
21
+ amount: PositiveMoneySchema.optional(),
19
22
  })
20
23
  .refine(value => Boolean(value.orderUUIDs?.length) || value.amount !== undefined, {
21
24
  message: 'Either orderUUIDs or amount must be provided',
@@ -1,10 +1,13 @@
1
1
  import { z } from 'zod';
2
2
  import { PaymentInvoiceSchema } from '../../schemas/payment-invoice/payment-invoice.schema';
3
+ import { MoneySchema } from '../../schemas/money.schema';
4
+ import { PositiveMoneySchema } from '../../schemas/positive-money.schema';
3
5
 
4
6
  // Оплата по счёту. amount не передан — гасим остаток целиком; передан — частичная оплата.
5
7
  const PayPaymentInvoiceRequestSchema = z.object({
6
8
  moneyAccountUUID: z.uuid(),
7
- amount: z.coerce.number().positive().optional(),
9
+ // Строго положительная сумма: отсекаем минус по знаку строки и нулевые записи вида "0" / "0.00".
10
+ amount: PositiveMoneySchema.optional(),
8
11
  comment: z.string().optional(),
9
12
  cashFlowItemUUID: z.uuid().nullable().optional(),
10
13
  createdAt: z.coerce.date().optional(),
@@ -1,10 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { ErrorMessageSchema } from '../../schemas/error-message.schema';
3
+ import { MoneySchema } from '../../schemas/money.schema';
3
4
 
4
5
  const OptionUpdateSchema = z.object({
5
6
  title: z.string().nullable().optional(),
6
7
  optionMultiplicity: z.number().nullable().optional(),
7
- optionPrice: z.number().nullable().optional(),
8
+ optionPrice: MoneySchema.nullable().optional(),
8
9
  });
9
10
 
10
11
  const PositionUpdateSchema = z.object({
@@ -12,7 +13,7 @@ const PositionUpdateSchema = z.object({
12
13
  multiplicity: z.number().nullable().optional(),
13
14
  quantity: z.number().nullable().optional(),
14
15
  balance: z.number().nullable().optional(),
15
- price: z.number().nullable().optional(),
16
+ price: MoneySchema.nullable().optional(),
16
17
  advancedPrice: z.string().nullable().optional(),
17
18
  grower: z.string().nullable().optional(),
18
19
  size: z.string().nullable().optional(),
@@ -1,10 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { PreOrderCollectionItemMultiplicityOptionSchema } from '../../../schemas';
3
+ import { MoneySchema } from '../../../schemas/money.schema';
4
+ import { NonNegativeMoneySchema } from '../../../schemas/non-negative-money.schema';
3
5
 
4
6
  const CreatePreOrderCollectionItemMultiplicityOptionRequestSchema = z.object({
5
7
  title: z.string().max(100).nullable().optional(),
6
8
  optionMultiplicity: z.coerce.number().int().min(1),
7
- optionPrice: z.coerce.number().min(0).nullable().optional(),
9
+ optionPrice: NonNegativeMoneySchema.nullable().optional(),
8
10
  rank: z.coerce.number().int().min(0).default(0).optional(),
9
11
  });
10
12
 
@@ -1,11 +1,13 @@
1
1
  import { z } from 'zod';
2
2
  import { PreOrderCollectionItemMultiplicityOptionSchema } from '../../../schemas';
3
+ import { MoneySchema } from '../../../schemas/money.schema';
4
+ import { NonNegativeMoneySchema } from '../../../schemas/non-negative-money.schema';
3
5
 
4
6
  const UpdatePreOrderCollectionItemMultiplicityOptionRequestSchema = z
5
7
  .object({
6
8
  title: z.string().max(100).nullable(),
7
9
  optionMultiplicity: z.coerce.number().int().min(1),
8
- optionPrice: z.coerce.number().min(0).nullable(),
10
+ optionPrice: NonNegativeMoneySchema.nullable(),
9
11
  rank: z.coerce.number().int().min(0).default(0),
10
12
  })
11
13
  .partial();
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { ProductMarkEnum, SalesUnitEnum } from '../../enum';
3
3
  import { ProductExtendedForAdminSchema } from '../../schemas';
4
+ import { MoneySchema } from '../../schemas/money.schema';
4
5
 
5
6
  const CreateProductRequestSchema = z.object({
6
7
  name: z.string(),
@@ -8,8 +9,8 @@ const CreateProductRequestSchema = z.object({
8
9
  categoryUUID: z.string(),
9
10
  balance: z.number(),
10
11
  quantity: z.number(),
11
- price: z.number(),
12
- costPrice: z.number(),
12
+ price: MoneySchema,
13
+ costPrice: MoneySchema,
13
14
  multiplicity: z.number(),
14
15
  isOpen: z.coerce.boolean(),
15
16
 
@@ -20,7 +21,7 @@ const CreateProductRequestSchema = z.object({
20
21
  size: z.string().nullable(),
21
22
  size2: z.string().nullable(),
22
23
  size3: z.string().nullable(),
23
- invoicePrice: z.number().nullable(),
24
+ invoicePrice: MoneySchema.nullable(),
24
25
  invoiceNumber: z.string().nullable(),
25
26
  imageUUID: z.string().nullable(),
26
27
  country: z.string().nullable(),
@@ -1,11 +1,12 @@
1
1
  import { z } from 'zod';
2
+ import { MoneySchema } from '../../../schemas/money.schema';
2
3
 
3
4
  const UpdateGroupProductPricesRequestSchema = z.object({
4
5
  data: z
5
6
  .object({
6
7
  productUUID: z.string(),
7
- newCost: z.coerce.number(),
8
- newPrice: z.coerce.number().optional(),
8
+ newCost: MoneySchema,
9
+ newPrice: MoneySchema.optional(),
9
10
  })
10
11
  .array(),
11
12
  });
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { SalesUnitEnum } from '../../../enum';
3
3
  import { ErrorMessageSchema } from '../../../schemas/error-message.schema';
4
+ import { MoneySchema } from '../../../schemas/money.schema';
4
5
 
5
6
  const UpdateGroupProductUpdateBatchRequestSchema = z.object({
6
7
  productUUIDList: z.array(z.string()),
@@ -8,15 +9,15 @@ const UpdateGroupProductUpdateBatchRequestSchema = z.object({
8
9
  .object({
9
10
  name: z.string(),
10
11
  categoryUUID: z.string(),
11
- price: z.coerce.number(),
12
- costPrice: z.coerce.number(),
12
+ price: MoneySchema,
13
+ costPrice: MoneySchema,
13
14
  color: z.string().nullable(),
14
15
  size: z.string().nullable(),
15
16
  multiplicity: z.coerce.number(),
16
17
  size2: z.string().nullable(),
17
18
  grower: z.string().nullable(),
18
19
  country: z.string().nullable(),
19
- invoicePrice: z.coerce.number().nullable(),
20
+ invoicePrice: MoneySchema.nullable(),
20
21
  invoiceNumber: z.string().nullable(),
21
22
  imageUUID: z.string().nullable(),
22
23
  multiplicityDescription: z.string().nullable(),
@@ -1,10 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { ProductMultiplicityOptionSchema } from '../../../schemas';
3
+ import { MoneySchema } from '../../../schemas/money.schema';
4
+ import { NonNegativeMoneySchema } from '../../../schemas/non-negative-money.schema';
3
5
 
4
6
  const CreateProductMultiplicityOptionRequestSchema = z.object({
5
7
  title: z.string().max(100).nullable().optional(),
6
8
  optionMultiplicity: z.coerce.number().int().min(1),
7
- optionPrice: z.coerce.number().min(0).nullable().optional(),
9
+ optionPrice: NonNegativeMoneySchema.nullable().optional(),
8
10
  rank: z.coerce.number().int().min(0).default(0).optional(),
9
11
  });
10
12
 
@@ -1,11 +1,13 @@
1
1
  import { z } from 'zod';
2
2
  import { ProductMultiplicityOptionSchema } from '../../../schemas';
3
+ import { MoneySchema } from '../../../schemas/money.schema';
4
+ import { NonNegativeMoneySchema } from '../../../schemas/non-negative-money.schema';
3
5
 
4
6
  const UpdateProductMultiplicityOptionRequestSchema = z
5
7
  .object({
6
8
  title: z.string().max(100).nullable(),
7
9
  optionMultiplicity: z.coerce.number().int().min(1),
8
- optionPrice: z.coerce.number().min(0).nullable(),
10
+ optionPrice: NonNegativeMoneySchema.nullable(),
9
11
  rank: z.coerce.number().int().min(0).default(0),
10
12
  })
11
13
  .partial();
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { ProductMarkEnum, SalesUnitEnum } from '../../enum';
3
3
  import { ProductExtendedForAdminSchema } from '../../schemas';
4
+ import { MoneySchema } from '../../schemas/money.schema';
4
5
 
5
6
  const UpdateProductRequestSchema = z.object({
6
7
  name: z.string(),
@@ -8,8 +9,8 @@ const UpdateProductRequestSchema = z.object({
8
9
  categoryUUID: z.string(),
9
10
  balance: z.number(),
10
11
  quantity: z.number(),
11
- price: z.number(),
12
- costPrice: z.number(),
12
+ price: MoneySchema,
13
+ costPrice: MoneySchema,
13
14
  multiplicity: z.number(),
14
15
  isOpen: z.coerce.boolean(),
15
16
 
@@ -20,7 +21,7 @@ const UpdateProductRequestSchema = z.object({
20
21
  size: z.string().nullable(),
21
22
  size2: z.string().nullable(),
22
23
  size3: z.string().nullable(),
23
- invoicePrice: z.number().nullable(),
24
+ invoicePrice: MoneySchema.nullable(),
24
25
  invoiceNumber: z.string().nullable(),
25
26
  imageUUID: z.string().nullable(),
26
27
  country: z.string().nullable(),
@@ -1,11 +1,14 @@
1
1
  import { z } from 'zod';
2
2
  import { dateRangeCheck, isStatementPeriodWithinLimit } from '../../helpers/date.helper';
3
+ import { ReportOrderFilterSchema } from '../../schemas/report/report-order-filter.schema';
3
4
 
4
5
  const ExportSalesByClientRequestSchema = z
5
6
  .object({
6
7
  startDate: z.coerce.date(),
7
8
  endDate: z.coerce.date(),
8
9
  })
10
+ // dateBasis / excludeClientUUID — те же, что у JSON-эндпоинтов отчётов по заказам.
11
+ .merge(ReportOrderFilterSchema)
9
12
  .refine(value => dateRangeCheck(value.startDate, value.endDate), {
10
13
  message: 'validation.dateRange',
11
14
  path: ['endDate', 'startDate'],
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { dateRangeCheck, isStatementPeriodWithinLimit } from '../../helpers/date.helper';
3
3
  import { SalesByPositionGroupByEnum } from '../../enum/sales-by-position-group-by.enum';
4
+ import { ReportOrderFilterSchema } from '../../schemas/report/report-order-filter.schema';
4
5
 
5
6
  const ExportSalesByPositionRequestSchema = z
6
7
  .object({
@@ -8,6 +9,8 @@ const ExportSalesByPositionRequestSchema = z
8
9
  endDate: z.coerce.date(),
9
10
  groupBy: z.nativeEnum(SalesByPositionGroupByEnum).default(SalesByPositionGroupByEnum.PRODUCT),
10
11
  })
12
+ // dateBasis / excludeClientUUID — те же, что у JSON-эндпоинтов отчётов по заказам.
13
+ .merge(ReportOrderFilterSchema)
11
14
  .refine(value => dateRangeCheck(value.startDate, value.endDate), {
12
15
  message: 'validation.dateRange',
13
16
  path: ['endDate', 'startDate'],
@@ -1,6 +1,7 @@
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 { ReportOrderFilterSchema } from '../../schemas/report/report-order-filter.schema';
4
5
 
5
6
  const ExportSalesRevenueRequestSchema = z
6
7
  .object({
@@ -8,6 +9,8 @@ const ExportSalesRevenueRequestSchema = z
8
9
  endDate: z.coerce.date().optional(),
9
10
  periodType: z.nativeEnum(ReportPeriodTypeEnum).default(ReportPeriodTypeEnum.DAY),
10
11
  })
12
+ // dateBasis / excludeClientUUID — те же, что у JSON-эндпоинтов отчётов по заказам.
13
+ .merge(ReportOrderFilterSchema)
11
14
  .refine(
12
15
  value => {
13
16
  const { startDate, endDate } = value;
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { dateRangeCheck, isStatementPeriodWithinLimit } from '../../helpers/date.helper';
3
+ import { MoneySchema } from '../../schemas/money.schema';
3
4
 
4
5
  const GetCashFlowRequestSchema = z
5
6
  .object({
@@ -28,8 +29,8 @@ const CashFlowItemRowSchema = z.object({
28
29
  // null — строка "Без статьи": платежи, которым статью ещё не проставили.
29
30
  cashFlowItemUUID: z.string().nullable(),
30
31
  cashFlowItemName: z.string().nullable(),
31
- income: z.number(),
32
- expense: z.number(),
32
+ income: MoneySchema,
33
+ expense: MoneySchema,
33
34
  transactionCount: z.number(),
34
35
  });
35
36
 
@@ -43,9 +44,11 @@ const GetCashFlowResponseSchema = z.object({
43
44
  byItem: CashFlowItemRowSchema.array(),
44
45
  byMonth: CashFlowMonthRowSchema.array(),
45
46
  totals: z.object({
46
- income: z.number(),
47
- expense: z.number(),
48
- total: z.number(),
47
+ income: MoneySchema,
48
+ expense: MoneySchema,
49
+ // Сальдо (`income - expense`) — знаковая величина, минус здесь легален,
50
+ // поэтому ограничения на знак нет и быть не должно.
51
+ total: MoneySchema,
49
52
  }),
50
53
  }),
51
54
  });
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { dateRangeCheck, isStatementPeriodWithinLimit } from '../../helpers/date.helper';
3
+ import { MoneySchema } from '../../schemas/money.schema';
3
4
 
4
5
  const GetDailyOrdersSummaryRequestSchema = z
5
6
  .object({
@@ -24,7 +25,7 @@ const UnitsByMeasureSchema = z.object({
24
25
  const metricsShape = {
25
26
  ordersCreated: z.number(),
26
27
  ordersCompleted: z.number(),
27
- totalSum: z.number(),
28
+ totalSum: MoneySchema,
28
29
  unitsByMeasure: UnitsByMeasureSchema,
29
30
  };
30
31
 
@@ -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 GetReportForPeriodRequestSchema = z
5
6
  .object({
@@ -25,17 +26,17 @@ const GetReportForPeriodResponseSchema = z.object({
25
26
  data: z.object({
26
27
  totalOrders: z.number(),
27
28
  soldUnits: z.number(),
28
- totalSales: z.number(),
29
- totalCost: z.number(),
29
+ totalSales: MoneySchema,
30
+ totalCost: MoneySchema,
30
31
  totalUnits: z.number(),
31
- totalWriteOff: z.number(),
32
- totalWriteOffCost: z.number(),
32
+ totalWriteOff: z.number(), // количество списанных единиц (SUM по quantity), не деньги
33
+ totalWriteOffCost: MoneySchema,
33
34
  totalWriteOffByOrder: z.number(),
34
- totalWriteOffCostByOrder: z.number(),
35
- totalVatAmount: z.number(),
36
- totalDeliveryCost: z.number(),
37
- middlePrice: z.number(),
38
- grossProfit: z.number(),
35
+ totalWriteOffCostByOrder: MoneySchema,
36
+ totalVatAmount: MoneySchema,
37
+ totalDeliveryCost: MoneySchema,
38
+ middlePrice: MoneySchema,
39
+ grossProfit: MoneySchema,
39
40
  marginality: z.number(),
40
41
  }),
41
42
  });
@@ -1,6 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import { OrderByEnum, ReportSortByEnum } from '../../enum';
3
3
  import { dateRangeCheck } from '../../helpers/date.helper';
4
+ import { MoneySchema } from '../../schemas/money.schema';
5
+ import { ReportOrderFilterSchema } from '../../schemas/report/report-order-filter.schema';
4
6
 
5
7
  const GetReportGroupByClientRequestSchema = z
6
8
  .object({
@@ -21,6 +23,9 @@ const GetReportGroupByClientRequestSchema = z
21
23
  // Без значения — ограничения нет: панель по-прежнему получает все строки.
22
24
  limit: z.coerce.number().int().positive().optional().describe('Keep only the top N rows; implies sorting by gross profit desc.'),
23
25
  })
26
+ // dateBasis / excludeClientUUID общие с sales/summary: обе цифры живут на одном экране и должны
27
+ // сужаться одинаково.
28
+ .merge(ReportOrderFilterSchema)
24
29
  .refine(
25
30
  value => {
26
31
  const { startDate, endDate } = value;
@@ -45,16 +50,16 @@ const GetReportGroupByClientResponseSchema = z.object({
45
50
  clientName: z.string(),
46
51
  totalOrders: z.number(),
47
52
  soldUnits: z.number(),
48
- totalSales: z.number(),
49
- totalSalesCost: z.number(),
50
- totalWriteOff: z.number(),
51
- totalWriteOffSales: z.number(),
52
- totalVatAmount: z.number(),
53
- totalDeliveryCost: z.number(),
54
- totalServiceAmount: z.number(),
55
- totalPayments: z.number(),
56
- middlePrice: z.number(),
57
- grossProfit: z.number(),
53
+ totalSales: MoneySchema,
54
+ totalSalesCost: MoneySchema,
55
+ totalWriteOff: z.number(), // количество списанных единиц (SUM по quantity), не деньги
56
+ totalWriteOffSales: MoneySchema, // деньги: SUM(write_off.quantity * order_product.price)
57
+ totalVatAmount: MoneySchema,
58
+ totalDeliveryCost: MoneySchema,
59
+ totalServiceAmount: MoneySchema,
60
+ totalPayments: MoneySchema,
61
+ middlePrice: MoneySchema,
62
+ grossProfit: MoneySchema,
58
63
  marginality: z.number(),
59
64
  }),
60
65
  ),