@floristcloud/api-lib 1.2.109 → 1.2.111

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 (165) 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/get-pre-order-collection-item-grouped-list-for-client.query.js +1 -0
  16. package/build/commands/pre-order-collection-item/get-pre-order-collection-item-list-filter-values-for-client.query.js +2 -0
  17. package/build/commands/pre-order-collection-item/get-pre-order-collection-item-list-filter-values.query.js +2 -0
  18. package/build/commands/pre-order-collection-item/get-pre-order-collection-item-list-for-client.query.js +1 -0
  19. package/build/commands/pre-order-collection-item/get-pre-order-collection-item-list.query.js +1 -0
  20. package/build/commands/pre-order-collection-item/multiplicity-option/create-pre-order-collection-item-multiplicity-option.command.js +2 -1
  21. package/build/commands/pre-order-collection-item/multiplicity-option/update-pre-order-collection-item-multiplicity-option.command.js +2 -1
  22. package/build/commands/product/create-product.command.js +4 -3
  23. package/build/commands/product/group/update-group-product-prices.command.js +3 -2
  24. package/build/commands/product/group/update-group-product-update-batch.command.js +4 -3
  25. package/build/commands/product/multiplicity-option/create-product-multiplicity-option.command.js +2 -1
  26. package/build/commands/product/multiplicity-option/update-product-multiplicity-option.command.js +2 -1
  27. package/build/commands/product/update-product.command.js +4 -3
  28. package/build/commands/report/get-cash-flow.query.js +8 -5
  29. package/build/commands/report/get-daily-orders-summary.query.js +2 -1
  30. package/build/commands/report/get-report-for-period.query.js +10 -9
  31. package/build/commands/report/get-report-group-by-client.query.js +11 -10
  32. package/build/commands/report/get-report-group-by-position.query.js +15 -14
  33. package/build/commands/report/get-sales-summary.query.js +13 -11
  34. package/build/commands/transaction/generate-check-transaction.command.js +2 -1
  35. package/build/commands/transaction/generate-pre-payment-check.command.js +2 -1
  36. package/build/commands/transaction/get-sum-transaction-by-money-account.query.js +3 -1
  37. package/build/commands/transaction/get-transaction-summary.query.js +5 -3
  38. package/build/commands/write-off/get-write-off-sum-by-order.query.js +3 -1
  39. package/build/commands/write-off/update-write-off-price.command.js +2 -1
  40. package/build/schemas/action-log/action-log-money.schema.js +28 -0
  41. package/build/schemas/action-log/index.js +1 -0
  42. package/build/schemas/action-log/order-info.schema.js +3 -2
  43. package/build/schemas/action-log/order-product-info.schema.js +2 -1
  44. package/build/schemas/action-log/order-product-update-action-log.schema.js +2 -1
  45. package/build/schemas/action-log/pre-order-product-info.schema.js +2 -1
  46. package/build/schemas/action-log/pre-order-product-update-action-log.schema.js +2 -1
  47. package/build/schemas/action-log/transaction-info.schema.js +2 -1
  48. package/build/schemas/bank-payment/bank-payment.schema.js +2 -1
  49. package/build/schemas/client/client-debt.schema.js +8 -5
  50. package/build/schemas/client/client.schema.js +2 -1
  51. package/build/schemas/consignment/consignment.schema.js +10 -9
  52. package/build/schemas/consignment-transfer/accept-consignment-transfer.schema.js +3 -1
  53. package/build/schemas/consignment-transfer/consignment-transfer-request-item.schema.js +2 -1
  54. package/build/schemas/delivery-route/delivery-route.schema.js +2 -1
  55. package/build/schemas/discount-rules/discount-rules.schema.js +9 -2
  56. package/build/schemas/index.js +3 -0
  57. package/build/schemas/money-account/money-account-with-balance.schema.js +2 -2
  58. package/build/schemas/money.schema.js +27 -0
  59. package/build/schemas/non-negative-money.schema.js +17 -0
  60. package/build/schemas/order/order.schema.js +10 -9
  61. package/build/schemas/order-product/order-product-multiplicity-optiom.schema.js +2 -1
  62. package/build/schemas/order-product/order-product.schema.js +5 -4
  63. package/build/schemas/order-product/price-correction-analyze-item.schema.js +10 -8
  64. package/build/schemas/order-product/price-correction-execute-result-item.schema.js +3 -2
  65. package/build/schemas/order-service-line/order-service-line.schema.js +12 -5
  66. package/build/schemas/payment-invoice/payment-invoice.schema.js +5 -4
  67. package/build/schemas/positive-money.schema.js +18 -0
  68. package/build/schemas/pre-order/pre-order.schema.js +2 -1
  69. package/build/schemas/pre-order-collection-item/pre-order-collection-item-multiplicity-option.schema.js +2 -1
  70. package/build/schemas/pre-order-collection-item/pre-order-collection-item.schema.js +4 -3
  71. package/build/schemas/pre-order-product/pre-order-product.schema.js +5 -4
  72. package/build/schemas/product/product-multiplicity-option.schema.js +2 -1
  73. package/build/schemas/product/product.schema.js +6 -5
  74. package/build/schemas/report/client-by-weeks.schema.js +2 -1
  75. package/build/schemas/report/client-statement.schema.js +2 -1
  76. package/build/schemas/report/inventory-turnover-category-item.schema.js +1 -1
  77. package/build/schemas/report/inventory-turnover-detailed-item.schema.js +1 -1
  78. package/build/schemas/report/sales-by-client-row.schema.js +9 -8
  79. package/build/schemas/report/sales-by-client-top-item.schema.js +2 -1
  80. package/build/schemas/service/service.schema.js +8 -3
  81. package/build/schemas/settings/settings.schema.js +6 -2
  82. package/build/schemas/transaction/transaction.schema.js +2 -1
  83. package/commands/client/get-client-calculate.query.ts +6 -4
  84. package/commands/consignment/execute-consignment-product-update.command.ts +5 -4
  85. package/commands/integration/moysklad/execute-moysklad-import.command.ts +3 -2
  86. package/commands/integration/moysklad/preview-moysklad-products.query.ts +3 -2
  87. package/commands/integration/moysklad/scan-moysklad-import.query.ts +3 -2
  88. package/commands/order/create-order.command.ts +2 -1
  89. package/commands/order/update-order.command.ts +3 -2
  90. package/commands/order/webshop/get-order-sales-by-month.query.ts +3 -1
  91. package/commands/order-product/create-order-product.command.ts +2 -1
  92. package/commands/order-product/group/price-valuation-execute.command.ts +4 -1
  93. package/commands/order-product/update-order-product.command.ts +2 -1
  94. package/commands/payment-invoice/create-payment-invoice.command.ts +4 -1
  95. package/commands/payment-invoice/pay-payment-invoice.command.ts +4 -1
  96. package/commands/pre-order-collection-item/execute-pre-order-collection-item-update.command.ts +3 -2
  97. package/commands/pre-order-collection-item/get-pre-order-collection-item-grouped-list-for-client.query.ts +1 -0
  98. package/commands/pre-order-collection-item/get-pre-order-collection-item-list-filter-values-for-client.query.ts +2 -0
  99. package/commands/pre-order-collection-item/get-pre-order-collection-item-list-filter-values.query.ts +2 -0
  100. package/commands/pre-order-collection-item/get-pre-order-collection-item-list-for-client.query.ts +1 -0
  101. package/commands/pre-order-collection-item/get-pre-order-collection-item-list.query.ts +1 -0
  102. package/commands/pre-order-collection-item/multiplicity-option/create-pre-order-collection-item-multiplicity-option.command.ts +2 -1
  103. package/commands/pre-order-collection-item/multiplicity-option/update-pre-order-collection-item-multiplicity-option.command.ts +2 -1
  104. package/commands/product/create-product.command.ts +4 -3
  105. package/commands/product/group/update-group-product-prices.command.ts +3 -2
  106. package/commands/product/group/update-group-product-update-batch.command.ts +4 -3
  107. package/commands/product/multiplicity-option/create-product-multiplicity-option.command.ts +2 -1
  108. package/commands/product/multiplicity-option/update-product-multiplicity-option.command.ts +2 -1
  109. package/commands/product/update-product.command.ts +4 -3
  110. package/commands/report/get-cash-flow.query.ts +8 -5
  111. package/commands/report/get-daily-orders-summary.query.ts +2 -1
  112. package/commands/report/get-report-for-period.query.ts +10 -9
  113. package/commands/report/get-report-group-by-client.query.ts +11 -10
  114. package/commands/report/get-report-group-by-position.query.ts +15 -14
  115. package/commands/report/get-sales-summary.query.ts +13 -11
  116. package/commands/transaction/generate-check-transaction.command.ts +2 -1
  117. package/commands/transaction/generate-pre-payment-check.command.ts +2 -1
  118. package/commands/transaction/get-sum-transaction-by-money-account.query.ts +3 -1
  119. package/commands/transaction/get-transaction-summary.query.ts +5 -3
  120. package/commands/write-off/get-write-off-sum-by-order.query.ts +4 -1
  121. package/commands/write-off/update-write-off-price.command.ts +2 -1
  122. package/package.json +1 -1
  123. package/schemas/action-log/action-log-money.schema.ts +26 -0
  124. package/schemas/action-log/index.ts +1 -0
  125. package/schemas/action-log/order-info.schema.ts +3 -2
  126. package/schemas/action-log/order-product-info.schema.ts +2 -1
  127. package/schemas/action-log/order-product-update-action-log.schema.ts +2 -1
  128. package/schemas/action-log/pre-order-product-info.schema.ts +2 -1
  129. package/schemas/action-log/pre-order-product-update-action-log.schema.ts +2 -1
  130. package/schemas/action-log/transaction-info.schema.ts +2 -1
  131. package/schemas/bank-payment/bank-payment.schema.ts +2 -1
  132. package/schemas/client/client-debt.schema.ts +8 -5
  133. package/schemas/client/client.schema.ts +2 -1
  134. package/schemas/consignment/consignment.schema.ts +10 -9
  135. package/schemas/consignment-transfer/accept-consignment-transfer.schema.ts +4 -1
  136. package/schemas/consignment-transfer/consignment-transfer-request-item.schema.ts +2 -1
  137. package/schemas/delivery-route/delivery-route.schema.ts +2 -1
  138. package/schemas/discount-rules/discount-rules.schema.ts +9 -2
  139. package/schemas/index.ts +3 -0
  140. package/schemas/money-account/money-account-with-balance.schema.ts +2 -1
  141. package/schemas/money.schema.ts +25 -0
  142. package/schemas/non-negative-money.schema.ts +15 -0
  143. package/schemas/order/order.schema.ts +10 -9
  144. package/schemas/order-product/order-product-multiplicity-optiom.schema.ts +2 -1
  145. package/schemas/order-product/order-product.schema.ts +5 -4
  146. package/schemas/order-product/price-correction-analyze-item.schema.ts +10 -8
  147. package/schemas/order-product/price-correction-execute-result-item.schema.ts +3 -2
  148. package/schemas/order-service-line/order-service-line.schema.ts +13 -5
  149. package/schemas/payment-invoice/payment-invoice.schema.ts +5 -4
  150. package/schemas/positive-money.schema.ts +16 -0
  151. package/schemas/pre-order/pre-order.schema.ts +2 -1
  152. package/schemas/pre-order-collection-item/pre-order-collection-item-multiplicity-option.schema.ts +3 -1
  153. package/schemas/pre-order-collection-item/pre-order-collection-item.schema.ts +4 -3
  154. package/schemas/pre-order-product/pre-order-product.schema.ts +5 -4
  155. package/schemas/product/product-multiplicity-option.schema.ts +2 -1
  156. package/schemas/product/product.schema.ts +6 -5
  157. package/schemas/report/client-by-weeks.schema.ts +2 -1
  158. package/schemas/report/client-statement.schema.ts +2 -1
  159. package/schemas/report/inventory-turnover-category-item.schema.ts +1 -1
  160. package/schemas/report/inventory-turnover-detailed-item.schema.ts +1 -1
  161. package/schemas/report/sales-by-client-row.schema.ts +9 -8
  162. package/schemas/report/sales-by-client-top-item.schema.ts +2 -1
  163. package/schemas/service/service.schema.ts +9 -3
  164. package/schemas/settings/settings.schema.ts +7 -2
  165. package/schemas/transaction/transaction.schema.ts +2 -1
@@ -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(),
@@ -7,6 +7,7 @@ const GetPreOrderCollectionItemGroupedListForClientRequestSchema = z.object({
7
7
  preOrderCollectionsUUID: z.array(z.string()).optional(),
8
8
  categoriesUUID: z.array(z.string()).optional(),
9
9
  growers: z.array(z.string()).optional(),
10
+ countries: z.array(z.string()).optional(),
10
11
  searchQuery: z.string().optional(),
11
12
  page: z.coerce.number().optional().default(1),
12
13
  count: z.coerce.number().optional().default(10),
@@ -6,6 +6,7 @@ const GetPreOrderCollectionItemListFilterValuesForClientRequestSchema = z.object
6
6
  preOrderCollectionsUUID: z.array(z.string()).optional(),
7
7
  categoriesUUID: z.array(z.string()).optional(),
8
8
  growers: z.array(z.string()).optional(),
9
+ countries: z.array(z.string()).optional(),
9
10
  });
10
11
 
11
12
  const GetPreOrderCollectionItemListFilterValuesForClientResponseSchema = z.object({
@@ -13,6 +14,7 @@ const GetPreOrderCollectionItemListFilterValuesForClientResponseSchema = z.objec
13
14
  data: z.object({
14
15
  sizes: z.array(z.string()).optional(),
15
16
  growers: z.array(z.string()).optional(),
17
+ countries: z.array(z.string()).optional(),
16
18
  colors: z.array(z.string()).optional(),
17
19
  categories: z.array(z.object({ uuid: z.string(), name: z.string() })),
18
20
  preOrderCollectionsUUID: z.array(z.string()).optional(),
@@ -4,6 +4,7 @@ const GetPreOrderCollectionItemListFilterValuesRequestSchema = z.object({
4
4
  sizes: z.array(z.string()).optional(),
5
5
  colors: z.array(z.string()).optional(),
6
6
  growers: z.array(z.string()).optional(),
7
+ countries: z.array(z.string()).optional(),
7
8
  categoriesUUID: z.array(z.string()).optional(),
8
9
  });
9
10
 
@@ -12,6 +13,7 @@ const GetPreOrderCollectionItemListFilterValuesResponseSchema = z.object({
12
13
  data: z.object({
13
14
  sizes: z.array(z.string()),
14
15
  growers: z.array(z.string()),
16
+ countries: z.array(z.string()),
15
17
  categories: z.array(z.object({ uuid: z.string(), name: z.string() })),
16
18
  colors: z.array(z.string()),
17
19
  }),
@@ -7,6 +7,7 @@ const GetPreOrderCollectionItemListForClientRequestSchema = z.object({
7
7
  preOrderCollectionsUUID: z.array(z.string()).optional(),
8
8
  categoriesUUID: z.array(z.string()).optional(),
9
9
  growers: z.array(z.string()).optional(),
10
+ countries: z.array(z.string()).optional(),
10
11
  searchQuery: z.string().optional(),
11
12
  page: z.coerce.number().optional().default(1),
12
13
  count: z.coerce.number().optional().default(10),
@@ -7,6 +7,7 @@ const GetPreOrderCollectionItemListRequestSchema = z.object({
7
7
  sizes: z.array(z.string()).optional(),
8
8
  colors: z.array(z.string()).optional(),
9
9
  growers: z.array(z.string()).optional(),
10
+ countries: z.array(z.string()).optional(),
10
11
  categoriesUUID: z.array(z.string()).optional(),
11
12
  searchQuery: z.string().optional(),
12
13
  hasPreOrder: z.coerce.boolean().optional(),
@@ -1,10 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { PreOrderCollectionItemMultiplicityOptionSchema } from '../../../schemas';
3
+ import { NonNegativeMoneySchema } from '../../../schemas/non-negative-money.schema';
3
4
 
4
5
  const CreatePreOrderCollectionItemMultiplicityOptionRequestSchema = z.object({
5
6
  title: z.string().max(100).nullable().optional(),
6
7
  optionMultiplicity: z.coerce.number().int().min(1),
7
- optionPrice: z.coerce.number().min(0).nullable().optional(),
8
+ optionPrice: NonNegativeMoneySchema.nullable().optional(),
8
9
  rank: z.coerce.number().int().min(0).default(0).optional(),
9
10
  });
10
11
 
@@ -1,11 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { PreOrderCollectionItemMultiplicityOptionSchema } from '../../../schemas';
3
+ import { NonNegativeMoneySchema } from '../../../schemas/non-negative-money.schema';
3
4
 
4
5
  const UpdatePreOrderCollectionItemMultiplicityOptionRequestSchema = z
5
6
  .object({
6
7
  title: z.string().max(100).nullable(),
7
8
  optionMultiplicity: z.coerce.number().int().min(1),
8
- optionPrice: z.coerce.number().min(0).nullable(),
9
+ optionPrice: NonNegativeMoneySchema.nullable(),
9
10
  rank: z.coerce.number().int().min(0).default(0),
10
11
  })
11
12
  .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,11 @@
1
1
  import { z } from 'zod';
2
2
  import { ProductMultiplicityOptionSchema } from '../../../schemas';
3
+ import { NonNegativeMoneySchema } from '../../../schemas/non-negative-money.schema';
3
4
 
4
5
  const CreateProductMultiplicityOptionRequestSchema = z.object({
5
6
  title: z.string().max(100).nullable().optional(),
6
7
  optionMultiplicity: z.coerce.number().int().min(1),
7
- optionPrice: z.coerce.number().min(0).nullable().optional(),
8
+ optionPrice: NonNegativeMoneySchema.nullable().optional(),
8
9
  rank: z.coerce.number().int().min(0).default(0).optional(),
9
10
  });
10
11
 
@@ -1,11 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { ProductMultiplicityOptionSchema } from '../../../schemas';
3
+ import { NonNegativeMoneySchema } from '../../../schemas/non-negative-money.schema';
3
4
 
4
5
  const UpdateProductMultiplicityOptionRequestSchema = z
5
6
  .object({
6
7
  title: z.string().max(100).nullable(),
7
8
  optionMultiplicity: z.coerce.number().int().min(1),
8
- optionPrice: z.coerce.number().min(0).nullable(),
9
+ optionPrice: NonNegativeMoneySchema.nullable(),
9
10
  rank: z.coerce.number().int().min(0).default(0),
10
11
  })
11
12
  .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,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,7 @@
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';
4
5
  import { ReportOrderFilterSchema } from '../../schemas/report/report-order-filter.schema';
5
6
 
6
7
  const GetReportGroupByClientRequestSchema = z
@@ -49,16 +50,16 @@ const GetReportGroupByClientResponseSchema = z.object({
49
50
  clientName: z.string(),
50
51
  totalOrders: z.number(),
51
52
  soldUnits: z.number(),
52
- totalSales: z.number(),
53
- totalSalesCost: z.number(),
54
- totalWriteOff: z.number(),
55
- totalWriteOffSales: z.number(),
56
- totalVatAmount: z.number(),
57
- totalDeliveryCost: z.number(),
58
- totalServiceAmount: z.number(),
59
- totalPayments: z.number(),
60
- middlePrice: z.number(),
61
- 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,
62
63
  marginality: z.number(),
63
64
  }),
64
65
  ),
@@ -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: z.number(),
53
+ totalSales: MoneySchema,
53
54
  soldUnits: z.number(),
54
- totalCost: z.number(),
55
+ totalCost: MoneySchema,
55
56
  totalUnits: z.number(),
56
- totalWriteOff: z.number(),
57
- totalWriteOffCost: z.number(),
58
- totalVatAmount: z.number(),
59
- middlePrice: z.number(),
60
- grossProfit: z.number(),
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: z.number(),
73
- totalCost: z.number(),
73
+ totalSales: MoneySchema,
74
+ totalCost: MoneySchema,
74
75
  totalUnits: z.number(),
75
- totalWriteOff: z.number(),
76
- totalWriteOffCost: z.number(),
77
- totalVatAmount: z.number(),
78
- middlePrice: z.number(),
79
- grossProfit: z.number(),
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
  )
@@ -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 { MoneySchema } from '../../schemas/money.schema';
4
5
  import { ReportOrderFilterSchema } from '../../schemas/report/report-order-filter.schema';
5
6
 
6
7
  const GetSalesSummaryRequestSchema = z
@@ -27,27 +28,28 @@ const GetSalesSummaryRequestSchema = z
27
28
  );
28
29
 
29
30
  const SalesSummaryTotalsSchema = z.object({
30
- totalRevenue: z.number(),
31
- totalRevenueWithDelivery: z.number(),
31
+ totalRevenue: MoneySchema,
32
+ totalRevenueWithDelivery: MoneySchema,
32
33
  totalOrders: z.number(),
33
34
  uniqueClients: z.number(),
34
35
  soldUnits: z.number(),
35
- avgCheck: z.number(),
36
- totalVatAmount: z.number(),
37
- totalCost: z.number(),
38
- totalDeliveryCost: z.number(),
39
- totalServiceAmount: z.number(),
40
- totalDiscountAmount: z.number(),
41
- grossProfit: z.number(),
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,
42
44
  marginality: z.number(),
43
45
  });
44
46
 
45
47
  const SalesSummarySeriesItemSchema = z.object({
46
48
  period: z.string(),
47
- revenue: z.number(),
49
+ revenue: MoneySchema,
48
50
  orders: z.number(),
49
51
  units: z.number(),
50
- avgCheck: z.number(),
52
+ avgCheck: MoneySchema,
51
53
  });
52
54
 
53
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: z.coerce.number(),
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: z.coerce.number(),
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
- sum: z.number(),
28
+ // Сальдо по кассе: расход может превысить приход, поэтому знаковых ограничений нет.
29
+ sum: MoneySchema,
28
30
  }),
29
31
  });
30
32