@floristcloud/api-lib 1.2.227 → 1.2.228
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/integration/moysklad/get-moysklad-money-account-links.query.js +8 -0
- package/build/commands/integration/moysklad/get-moysklad-payment-sync-check.query.js +10 -0
- package/build/commands/integration/moysklad/index.js +4 -0
- package/build/commands/integration/moysklad/list-moysklad-money-targets.query.js +8 -0
- package/build/commands/integration/moysklad/save-moysklad-money-account-link.command.js +10 -0
- package/build/commands/order/get-order-list.query.js +4 -70
- package/build/constant/client-registration.constant.js +11 -0
- package/build/constant/error.js +30 -0
- package/build/constant/index.js +2 -0
- package/build/constant/write-off-image.constant.js +11 -0
- package/build/enum/external-entity-type.enum.js +1 -0
- package/build/enum/index.js +2 -0
- package/build/enum/money-account-integration-link-kind.enum.js +9 -0
- package/build/enum/notification-type.enum.js +3 -0
- package/build/enum/order-source.enum.js +9 -0
- package/build/enum/payment-invoice-file-deletion-status.enum.js +9 -0
- package/build/schemas/client/register-client-webshop-request.schema.js +5 -4
- package/build/schemas/integration/moysklad/enable-moysklad-request.schema.js +2 -0
- package/build/schemas/integration/moysklad/index.js +9 -0
- package/build/schemas/integration/moysklad/moysklad-money-account-link.schema.js +11 -0
- package/build/schemas/integration/moysklad/moysklad-money-account-links-response.schema.js +6 -0
- package/build/schemas/integration/moysklad/moysklad-money-target-ref.schema.js +17 -0
- package/build/schemas/integration/moysklad/moysklad-money-target.schema.js +14 -0
- package/build/schemas/integration/moysklad/moysklad-money-targets-response.schema.js +6 -0
- package/build/schemas/integration/moysklad/moysklad-payment-sync-check-request.schema.js +8 -0
- package/build/schemas/integration/moysklad/moysklad-payment-sync-check-response.schema.js +6 -0
- package/build/schemas/integration/moysklad/moysklad-payment-sync-check.schema.js +10 -0
- package/build/schemas/integration/moysklad/moysklad-status.schema.js +1 -0
- package/build/schemas/integration/moysklad/save-moysklad-money-account-link-request.schema.js +10 -0
- package/build/schemas/order/get-order-list-request.schema.js +67 -0
- package/build/schemas/order/get-order-list-response-data.schema.js +6 -0
- package/build/schemas/order/get-order-list-response.schema.js +6 -0
- package/build/schemas/order/index.js +4 -0
- package/build/schemas/order/order-creator.schema.js +5 -0
- package/build/schemas/order/order-extended.schema.js +4 -0
- package/build/schemas/pre-order/get-pre-order-list-request.schema.js +2 -0
- package/build/schemas/pre-order/pre-order.schema.js +4 -0
- package/build/schemas/write-off/write-off-image.schema.js +4 -0
- package/commands/integration/moysklad/get-moysklad-money-account-links.query.ts +7 -0
- package/commands/integration/moysklad/get-moysklad-payment-sync-check.query.ts +10 -0
- package/commands/integration/moysklad/index.ts +5 -0
- package/commands/integration/moysklad/list-moysklad-money-targets.query.ts +7 -0
- package/commands/integration/moysklad/save-moysklad-money-account-link.command.ts +10 -0
- package/commands/order/get-order-list.query.ts +3 -76
- package/constant/client-registration.constant.ts +8 -0
- package/constant/error.ts +30 -0
- package/constant/index.ts +2 -0
- package/constant/write-off-image.constant.ts +8 -0
- package/enum/external-entity-type.enum.ts +1 -0
- package/enum/index.ts +3 -0
- package/enum/money-account-integration-link-kind.enum.ts +5 -0
- package/enum/notification-type.enum.ts +3 -0
- package/enum/order-source.enum.ts +8 -0
- package/enum/payment-invoice-file-deletion-status.enum.ts +5 -0
- package/package.json +1 -1
- package/schemas/client/register-client-webshop-request.schema.ts +10 -4
- package/schemas/integration/moysklad/enable-moysklad-request.schema.ts +2 -0
- package/schemas/integration/moysklad/index.ts +10 -0
- package/schemas/integration/moysklad/moysklad-money-account-link.schema.ts +9 -0
- package/schemas/integration/moysklad/moysklad-money-account-links-response.schema.ts +4 -0
- package/schemas/integration/moysklad/moysklad-money-target-ref.schema.ts +15 -0
- package/schemas/integration/moysklad/moysklad-money-target.schema.ts +12 -0
- package/schemas/integration/moysklad/moysklad-money-targets-response.schema.ts +4 -0
- package/schemas/integration/moysklad/moysklad-payment-sync-check-request.schema.ts +6 -0
- package/schemas/integration/moysklad/moysklad-payment-sync-check-response.schema.ts +4 -0
- package/schemas/integration/moysklad/moysklad-payment-sync-check.schema.ts +8 -0
- package/schemas/integration/moysklad/moysklad-status.schema.ts +1 -0
- package/schemas/integration/moysklad/save-moysklad-money-account-link-request.schema.ts +8 -0
- package/schemas/order/get-order-list-request.schema.ts +71 -0
- package/schemas/order/get-order-list-response-data.schema.ts +3 -0
- package/schemas/order/get-order-list-response.schema.ts +3 -0
- package/schemas/order/index.ts +8 -0
- package/schemas/order/order-creator.schema.ts +2 -0
- package/schemas/order/order-extended.schema.ts +4 -0
- package/schemas/pre-order/get-pre-order-list-request.schema.ts +2 -0
- package/schemas/pre-order/pre-order.schema.ts +4 -0
- package/schemas/write-off/write-off-image.schema.ts +4 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { MoyskladPaymentSyncCheckRequestSchema } from '../../../schemas/integration/moysklad/moysklad-payment-sync-check-request.schema';
|
|
3
|
+
import { MoyskladPaymentSyncCheckResponseSchema } from '../../../schemas/integration/moysklad/moysklad-payment-sync-check-response.schema';
|
|
4
|
+
|
|
5
|
+
export namespace GetMoyskladPaymentSyncCheckContractQuery {
|
|
6
|
+
export const RequestSchema = MoyskladPaymentSyncCheckRequestSchema;
|
|
7
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
8
|
+
export const ResponseSchema = MoyskladPaymentSyncCheckResponseSchema;
|
|
9
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
10
|
+
}
|
|
@@ -19,3 +19,8 @@ export * from './update-moysklad-order-state-mapping.command';
|
|
|
19
19
|
export * from './get-seller-sync-status.query';
|
|
20
20
|
|
|
21
21
|
export * from './retry-seller-sync.command';
|
|
22
|
+
|
|
23
|
+
export * from './list-moysklad-money-targets.query';
|
|
24
|
+
export * from './get-moysklad-money-account-links.query';
|
|
25
|
+
export * from './save-moysklad-money-account-link.command';
|
|
26
|
+
export * from './get-moysklad-payment-sync-check.query';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { MoyskladMoneyTargetsResponseSchema } from '../../../schemas/integration/moysklad/moysklad-money-targets-response.schema';
|
|
3
|
+
|
|
4
|
+
export namespace ListMoyskladMoneyTargetsContractQuery {
|
|
5
|
+
export const ResponseSchema = MoyskladMoneyTargetsResponseSchema;
|
|
6
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { MoyskladMoneyAccountLinksResponseSchema } from '../../../schemas/integration/moysklad/moysklad-money-account-links-response.schema';
|
|
3
|
+
import { SaveMoyskladMoneyAccountLinkRequestSchema } from '../../../schemas/integration/moysklad/save-moysklad-money-account-link-request.schema';
|
|
4
|
+
|
|
5
|
+
export namespace SaveMoyskladMoneyAccountLinkContractCommand {
|
|
6
|
+
export const RequestSchema = SaveMoyskladMoneyAccountLinkRequestSchema;
|
|
7
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
8
|
+
export const ResponseSchema = MoyskladMoneyAccountLinksResponseSchema;
|
|
9
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
10
|
+
}
|
|
@@ -1,79 +1,6 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { queryBooleanSchema } from '../../helpers/query-boolean.helper';
|
|
5
|
-
import { OrderStatusEnum, OrderTypeEnum } from '../../enum';
|
|
6
|
-
|
|
7
|
-
const GetOrderListRequestSchema = z
|
|
8
|
-
.object({
|
|
9
|
-
page: z.string().transform(val => Number(val) || 1),
|
|
10
|
-
count: z.string().transform(val => Number(val) || 10),
|
|
11
|
-
startDate: z.coerce.date().optional(),
|
|
12
|
-
endDate: z.coerce.date().optional(),
|
|
13
|
-
isDelivery: z.coerce.boolean().optional(),
|
|
14
|
-
isPaid: z.coerce.boolean().optional(),
|
|
15
|
-
consignmentUUID: z.string().optional(),
|
|
16
|
-
tag: z.string().optional(),
|
|
17
|
-
clientUUID: z.string().optional(),
|
|
18
|
-
searchQuery: z.string().optional(),
|
|
19
|
-
consignmentDeliveryDate: z.coerce.date().optional(),
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Используйте `deliveryDateFrom` / `deliveryDateTo`. Оставлен ради сохранённых
|
|
22
|
-
* ссылок и MCP-клиентов: трактуется как период из одного дня (from = to = deliveryDate).
|
|
23
|
-
*/
|
|
24
|
-
deliveryDate: z.coerce.date().optional(),
|
|
25
|
-
// Период даты отгрузки/выдачи заказа (`plannedShipmentDate`) — и доставка, и самовывоз; имена
|
|
26
|
-
// остались от фильтра по дате доставки. Календарные дни `YYYY-MM-DD`, обе границы включительно.
|
|
27
|
-
deliveryDateFrom: z.coerce.date().optional(),
|
|
28
|
-
deliveryDateTo: z.coerce.date().optional(),
|
|
29
|
-
byProductSearchQuery: z.string().optional(),
|
|
30
|
-
statuses: z.nativeEnum(OrderStatusEnum).array().optional(),
|
|
31
|
-
type: z.nativeEnum(OrderTypeEnum).optional(),
|
|
32
|
-
city: z.string().optional(),
|
|
33
|
-
responsibleUserUUID: z.string().optional(),
|
|
34
|
-
group: z.string().optional(),
|
|
35
|
-
// Только заказы, ещё не включённые ни в один счёт на оплату — список для пикера при
|
|
36
|
-
// выставлении счёта. Комбинируется с остальными критериями обычным AND.
|
|
37
|
-
withoutPaymentInvoice: z.coerce.boolean().optional(),
|
|
38
|
-
// То же для передаточного документа — пикер заказов при выпуске УПД. Здесь `queryBooleanSchema`,
|
|
39
|
-
// а не `z.coerce.boolean()`: в query всегда приходит текст, и `Boolean('false') === true`,
|
|
40
|
-
// то есть флаг соседа невозможно выключить явным значением, только опустив параметр.
|
|
41
|
-
withoutTransferDocument: queryBooleanSchema,
|
|
42
|
-
})
|
|
43
|
-
.refine(
|
|
44
|
-
value => {
|
|
45
|
-
const { startDate, endDate } = value;
|
|
46
|
-
if (startDate && endDate) {
|
|
47
|
-
return dateRangeCheck(startDate, endDate);
|
|
48
|
-
}
|
|
49
|
-
return true;
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
message: 'validation.dateRange',
|
|
53
|
-
path: ['endDate', 'startDate'],
|
|
54
|
-
},
|
|
55
|
-
)
|
|
56
|
-
.refine(
|
|
57
|
-
value => {
|
|
58
|
-
const { deliveryDateFrom, deliveryDateTo } = value;
|
|
59
|
-
if (deliveryDateFrom && deliveryDateTo) {
|
|
60
|
-
return dateRangeCheck(deliveryDateFrom, deliveryDateTo);
|
|
61
|
-
}
|
|
62
|
-
return true;
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
message: 'validation.dateRange',
|
|
66
|
-
path: ['deliveryDateTo', 'deliveryDateFrom'],
|
|
67
|
-
},
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const GetOrderListResponseSchema = z.object({
|
|
71
|
-
message: z.string().optional(),
|
|
72
|
-
data: z.object({
|
|
73
|
-
orderList: OrderExtendedSchema.array(),
|
|
74
|
-
total: z.number(),
|
|
75
|
-
}),
|
|
76
|
-
});
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { GetOrderListRequestSchema } from '../../schemas/order/get-order-list-request.schema';
|
|
3
|
+
import { GetOrderListResponseSchema } from '../../schemas/order/get-order-list-response.schema';
|
|
77
4
|
|
|
78
5
|
export namespace GetOrderListContractQuery {
|
|
79
6
|
export const RequestSchema = GetOrderListRequestSchema;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Потолки полей публичной заявки на регистрацию с витрины. Тело запроса до 1 МиБ, а данные заявки уходят
|
|
2
|
+
// в письма админам и в payload уведомлений — без границы туда попадает мегабайт текста.
|
|
3
|
+
export const CLIENT_REGISTRATION_NAME_MAX_LENGTH = 255;
|
|
4
|
+
export const CLIENT_REGISTRATION_CONTACT_NAME_MAX_LENGTH = 255;
|
|
5
|
+
// Номер с кодом страны и разделителями укладывается с запасом.
|
|
6
|
+
export const CLIENT_REGISTRATION_PHONE_MAX_LENGTH = 32;
|
|
7
|
+
// Предел длины адреса по RFC 5321.
|
|
8
|
+
export const CLIENT_REGISTRATION_EMAIL_MAX_LENGTH = 254;
|
package/constant/error.ts
CHANGED
|
@@ -68,6 +68,11 @@ export const ERRORS = {
|
|
|
68
68
|
MONEY_ACCOUNT_FETCH_FAILED: { code: 'M006', message: 'Error when retrieving a list of money accounts', httpCode: 500 },
|
|
69
69
|
MONEY_ACCOUNT_HAS_TRANSACTIONS: { code: 'M007', message: 'Money account has transactions', httpCode: 400 },
|
|
70
70
|
MONEY_ACCOUNT_ACCESS_DENIED: { code: 'M008', message: 'Money account access denied', httpCode: 500 },
|
|
71
|
+
MONEY_ACCOUNT_INTEGRATION_LINK_FAILED: {
|
|
72
|
+
code: 'M009',
|
|
73
|
+
message: 'Failed to read or save money account integration link',
|
|
74
|
+
httpCode: 500,
|
|
75
|
+
},
|
|
71
76
|
|
|
72
77
|
//NOTIFICATION
|
|
73
78
|
NOTIFICATION_NOT_CREATED: { code: 'N001', message: 'Failed to create Notification', httpCode: 500 },
|
|
@@ -1898,6 +1903,11 @@ export const ERRORS = {
|
|
|
1898
1903
|
message: 'Latest sync job for this entity is not DEAD; cannot retry',
|
|
1899
1904
|
httpCode: 409,
|
|
1900
1905
|
},
|
|
1906
|
+
OUTBOUND_SYNC_ENTITY_LOCK_LOST: {
|
|
1907
|
+
code: 'OS006',
|
|
1908
|
+
message: 'Outbound sync job lost its entity lock before writing to the external system; will retry shortly',
|
|
1909
|
+
httpCode: 409,
|
|
1910
|
+
},
|
|
1901
1911
|
MOYSKLAD_STOCK_SYNC_CAP_EXCEEDED: {
|
|
1902
1912
|
code: 'MS015',
|
|
1903
1913
|
message: 'MoySklad stock-sync concurrency cap exceeded; will retry shortly',
|
|
@@ -1938,6 +1948,26 @@ export const ERRORS = {
|
|
|
1938
1948
|
message: 'The demand is waiting for the order to be pushed to MoySklad; will retry shortly',
|
|
1939
1949
|
httpCode: 409,
|
|
1940
1950
|
},
|
|
1951
|
+
MOYSKLAD_PAYMENT_CLIENT_NOT_LINKED: {
|
|
1952
|
+
code: 'MS024',
|
|
1953
|
+
message: 'Payment client has no MoySklad link; import clients first',
|
|
1954
|
+
httpCode: 400,
|
|
1955
|
+
},
|
|
1956
|
+
MOYSKLAD_PAYMENT_WAITING_ORDER_PUSH: {
|
|
1957
|
+
code: 'MS025',
|
|
1958
|
+
message: 'The payment is waiting for its order to be created in MoySklad; will retry shortly',
|
|
1959
|
+
httpCode: 409,
|
|
1960
|
+
},
|
|
1961
|
+
MOYSKLAD_MONEY_TARGET_NOT_FOUND: {
|
|
1962
|
+
code: 'MS026',
|
|
1963
|
+
message: 'The MoySklad cash desk or bank account was not found in the connected account',
|
|
1964
|
+
httpCode: 400,
|
|
1965
|
+
},
|
|
1966
|
+
MOYSKLAD_PAYMENT_CREATE_LOCK_BUSY: {
|
|
1967
|
+
code: 'MS027',
|
|
1968
|
+
message: 'Another payment is being created in MoySklad for this account; will retry shortly',
|
|
1969
|
+
httpCode: 409,
|
|
1970
|
+
},
|
|
1941
1971
|
|
|
1942
1972
|
// 1C COMMERCEML INTEGRATION
|
|
1943
1973
|
ONE_C_NOT_CONNECTED: { code: 'OC001', message: '1C integration is not connected for this company', httpCode: 404 },
|
package/constant/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './report.constant';
|
|
|
8
8
|
export * from './oksm';
|
|
9
9
|
export * from './okei';
|
|
10
10
|
export * from './contact-phone.constant';
|
|
11
|
+
export * from './client-registration.constant';
|
|
11
12
|
export * from './settings.constant';
|
|
12
13
|
export * from './consignment-product-enrichment.constant';
|
|
13
14
|
export * from './attribute-normalization.constant';
|
|
@@ -18,3 +19,4 @@ export * from './order-external-number.constant';
|
|
|
18
19
|
export * from './discount-rules-pricing-type-list.constant';
|
|
19
20
|
export * from './measure-unit-limits';
|
|
20
21
|
export * from './product-resolution.constant';
|
|
22
|
+
export * from './write-off-image.constant';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retention policy for write-off photos (FC-632): 90 days from the record's creation. After that a photo counts as
|
|
3
|
+
* unavailable — clients show «фото удалено», the export gives no link, archives skip it.
|
|
4
|
+
*
|
|
5
|
+
* This is a policy, not a storage check. The lifecycle rule on `write-offs/` deletes new photos around this time
|
|
6
|
+
* (with up to a day of lag), while older photos under `images/` are not deleted by it and may still be in the bucket.
|
|
7
|
+
*/
|
|
8
|
+
export const WRITE_OFF_IMAGE_RETENTION_DAYS = 90;
|
package/enum/index.ts
CHANGED
|
@@ -57,6 +57,7 @@ export * from './image-type.enum';
|
|
|
57
57
|
export * from './import-error-code.enum';
|
|
58
58
|
export * from './integration-check-status.enum';
|
|
59
59
|
export * from './integration-provider.enum';
|
|
60
|
+
export * from './money-account-integration-link-kind.enum';
|
|
60
61
|
export * from './integration-status.enum';
|
|
61
62
|
export * from './inventory-movement-type.enum';
|
|
62
63
|
export * from './invoice-product-field.enum';
|
|
@@ -204,3 +205,5 @@ export * from './product-resolution-image-reason.enum';
|
|
|
204
205
|
export * from './product-resolution-matched-attribute.enum';
|
|
205
206
|
export * from './product-resolution-decision-action.enum';
|
|
206
207
|
export * from './product-resolution-write-mode.enum';
|
|
208
|
+
|
|
209
|
+
export * from './order-source.enum';
|
|
@@ -22,4 +22,7 @@ export enum NotificationTypeEnum {
|
|
|
22
22
|
PRE_ORDER_CREATED = 'PRE_ORDER_CREATED',
|
|
23
23
|
// Клиенту: рассылка сценария PRE_ORDER_COLLECTION_OPENED — открыт сбор предзаказов.
|
|
24
24
|
PRE_ORDER_COLLECTION_OPENED = 'PRE_ORDER_COLLECTION_OPENED',
|
|
25
|
+
// Админам: на витрине подана заявка с телефоном или email клиента, у которого нет учётной записи.
|
|
26
|
+
// Заявитель получает нейтральный ответ; привязывать заявку к клиенту автоматически нельзя — это захват аккаунта.
|
|
27
|
+
CLIENT_REGISTRATION_CONFLICT = 'CLIENT_REGISTRATION_CONFLICT',
|
|
25
28
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { PasswordSchema } from '../auth/password.schema';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { ClientTypeEnum } from '../../enum/client-type.enum';
|
|
4
|
+
import {
|
|
5
|
+
CLIENT_REGISTRATION_CONTACT_NAME_MAX_LENGTH,
|
|
6
|
+
CLIENT_REGISTRATION_EMAIL_MAX_LENGTH,
|
|
7
|
+
CLIENT_REGISTRATION_NAME_MAX_LENGTH,
|
|
8
|
+
CLIENT_REGISTRATION_PHONE_MAX_LENGTH,
|
|
9
|
+
} from '../../constant/client-registration.constant';
|
|
4
10
|
|
|
5
11
|
export const RegisterClientWebshopRequestSchema = z.object({
|
|
6
|
-
name: z.string(),
|
|
12
|
+
name: z.string().max(CLIENT_REGISTRATION_NAME_MAX_LENGTH),
|
|
7
13
|
password: PasswordSchema,
|
|
8
|
-
contactName: z.string().nullable(),
|
|
9
|
-
phone: z.string(),
|
|
10
|
-
email: z.email().toLowerCase(),
|
|
14
|
+
contactName: z.string().max(CLIENT_REGISTRATION_CONTACT_NAME_MAX_LENGTH).nullable(),
|
|
15
|
+
phone: z.string().max(CLIENT_REGISTRATION_PHONE_MAX_LENGTH),
|
|
16
|
+
email: z.email().max(CLIENT_REGISTRATION_EMAIL_MAX_LENGTH).toLowerCase(),
|
|
11
17
|
type: z.nativeEnum(ClientTypeEnum),
|
|
12
18
|
});
|
|
@@ -19,4 +19,6 @@ export const EnableMoyskladRequestSchema = z.object({
|
|
|
19
19
|
// Posted demand (отгрузка) in MS. No default on purpose: a client that does not send them keeps the saved values.
|
|
20
20
|
isDemandEnabled: z.boolean().optional(),
|
|
21
21
|
demandOrderStatus: z.enum(MOYSKLAD_DEMAND_ORDER_STATUS_LIST).optional(),
|
|
22
|
+
// Выгрузка оплат клиентов в МС. Без default по той же причине, что у отгрузок.
|
|
23
|
+
isPaymentSyncEnabled: z.boolean().optional(),
|
|
22
24
|
});
|
|
@@ -32,3 +32,13 @@ export * from './seller-sync-status.schema';
|
|
|
32
32
|
export * from './seller-sync-status-response.schema';
|
|
33
33
|
|
|
34
34
|
export * from './seller-sync-request.schema';
|
|
35
|
+
|
|
36
|
+
export * from './moysklad-money-target-ref.schema';
|
|
37
|
+
export * from './moysklad-money-target.schema';
|
|
38
|
+
export * from './moysklad-money-targets-response.schema';
|
|
39
|
+
export * from './moysklad-money-account-link.schema';
|
|
40
|
+
export * from './moysklad-money-account-links-response.schema';
|
|
41
|
+
export * from './save-moysklad-money-account-link-request.schema';
|
|
42
|
+
export * from './moysklad-payment-sync-check-request.schema';
|
|
43
|
+
export * from './moysklad-payment-sync-check.schema';
|
|
44
|
+
export * from './moysklad-payment-sync-check-response.schema';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { MoneyAccountIntegrationLinkKindEnum } from '../../../enum/money-account-integration-link-kind.enum';
|
|
3
|
+
|
|
4
|
+
export const MoyskladMoneyAccountLinkSchema = z.object({
|
|
5
|
+
moneyAccountUUID: z.uuid(),
|
|
6
|
+
kind: z.nativeEnum(MoneyAccountIntegrationLinkKindEnum),
|
|
7
|
+
organizationId: z.string(),
|
|
8
|
+
externalAccountId: z.string().nullable(),
|
|
9
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { MoneyAccountIntegrationLinkKindEnum } from '../../../enum/money-account-integration-link-kind.enum';
|
|
3
|
+
|
|
4
|
+
// Место денег в МойСкладе: касса юрлица (CASH, своего id у неё нет) или его расчётный счёт (BANK, externalAccountId). Идентификаторы МойСклада —
|
|
5
|
+
// 8-4-4-4-12, но не RFC 9562, поэтому z.guid(), а не z.uuid().
|
|
6
|
+
export const MoyskladMoneyTargetRefSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
kind: z.nativeEnum(MoneyAccountIntegrationLinkKindEnum),
|
|
9
|
+
organizationId: z.guid(),
|
|
10
|
+
externalAccountId: z.guid().nullable(),
|
|
11
|
+
})
|
|
12
|
+
.refine(target => (target.kind === MoneyAccountIntegrationLinkKindEnum.BANK) === (target.externalAccountId !== null), {
|
|
13
|
+
message: 'externalAccountId is required for BANK and must be null for CASH',
|
|
14
|
+
path: ['externalAccountId'],
|
|
15
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { MoneyAccountIntegrationLinkKindEnum } from '../../../enum/money-account-integration-link-kind.enum';
|
|
3
|
+
|
|
4
|
+
// Вариант для выпадающего списка: касса или расчётный счёт юрлица МойСклада с подписями.
|
|
5
|
+
export const MoyskladMoneyTargetSchema = z.object({
|
|
6
|
+
kind: z.nativeEnum(MoneyAccountIntegrationLinkKindEnum),
|
|
7
|
+
organizationId: z.string(),
|
|
8
|
+
organizationName: z.string(),
|
|
9
|
+
externalAccountId: z.string().nullable(),
|
|
10
|
+
accountNumber: z.string().nullable(),
|
|
11
|
+
bankName: z.string().nullable(),
|
|
12
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// isSynced — оплата клиента на этот счёт уйдёт в МойСклад. isOrganizationMismatch — юрлицо счёта в МС не совпадает
|
|
4
|
+
// с юрлицом заказа: документ оплаты создастся на юрлицо счёта, но со ссылкой на заказ другого юрлица.
|
|
5
|
+
export const MoyskladPaymentSyncCheckSchema = z.object({
|
|
6
|
+
isSynced: z.boolean(),
|
|
7
|
+
isOrganizationMismatch: z.boolean(),
|
|
8
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { MoyskladMoneyTargetRefSchema } from './moysklad-money-target-ref.schema';
|
|
3
|
+
|
|
4
|
+
// target = null снимает связь: оплаты со счёта перестают уходить в МойСклад.
|
|
5
|
+
export const SaveMoyskladMoneyAccountLinkRequestSchema = z.object({
|
|
6
|
+
moneyAccountUUID: z.uuid(),
|
|
7
|
+
target: MoyskladMoneyTargetRefSchema.nullable(),
|
|
8
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { dateRangeCheck } from '../../helpers/date.helper';
|
|
3
|
+
import { queryBooleanSchema } from '../../helpers/query-boolean.helper';
|
|
4
|
+
import { OrderStatusEnum, OrderTypeEnum, OrderSourceEnum } from '../../enum';
|
|
5
|
+
|
|
6
|
+
export const GetOrderListRequestSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
page: z.string().transform(val => Number(val) || 1),
|
|
9
|
+
count: z.string().transform(val => Number(val) || 10),
|
|
10
|
+
startDate: z.coerce.date().optional(),
|
|
11
|
+
endDate: z.coerce.date().optional(),
|
|
12
|
+
isDelivery: z.coerce.boolean().optional(),
|
|
13
|
+
isPaid: z.coerce.boolean().optional(),
|
|
14
|
+
consignmentUUID: z.string().optional(),
|
|
15
|
+
tag: z.string().optional(),
|
|
16
|
+
clientUUID: z.string().optional(),
|
|
17
|
+
// Филиал клиента (`Order.branchUUID`). Точное совпадение; осмысленно вместе с `clientUUID`,
|
|
18
|
+
// но не требует его — филиал и так принадлежит одному клиенту.
|
|
19
|
+
branchUUID: z.uuid().optional(),
|
|
20
|
+
searchQuery: z.string().optional(),
|
|
21
|
+
consignmentDeliveryDate: z.coerce.date().optional(),
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Используйте `deliveryDateFrom` / `deliveryDateTo`. Оставлен ради сохранённых
|
|
24
|
+
* ссылок и MCP-клиентов: трактуется как период из одного дня (from = to = deliveryDate).
|
|
25
|
+
*/
|
|
26
|
+
deliveryDate: z.coerce.date().optional(),
|
|
27
|
+
// Период даты отгрузки/выдачи заказа (`plannedShipmentDate`) — и доставка, и самовывоз; имена
|
|
28
|
+
// остались от фильтра по дате доставки. Календарные дни `YYYY-MM-DD`, обе границы включительно.
|
|
29
|
+
deliveryDateFrom: z.coerce.date().optional(),
|
|
30
|
+
deliveryDateTo: z.coerce.date().optional(),
|
|
31
|
+
byProductSearchQuery: z.string().optional(),
|
|
32
|
+
statuses: z.nativeEnum(OrderStatusEnum).array().optional(),
|
|
33
|
+
source: z.nativeEnum(OrderSourceEnum).optional(),
|
|
34
|
+
type: z.nativeEnum(OrderTypeEnum).optional(),
|
|
35
|
+
city: z.string().optional(),
|
|
36
|
+
responsibleUserUUID: z.string().optional(),
|
|
37
|
+
group: z.string().optional(),
|
|
38
|
+
// Только заказы, ещё не включённые ни в один счёт на оплату — список для пикера при
|
|
39
|
+
// выставлении счёта. Комбинируется с остальными критериями обычным AND.
|
|
40
|
+
withoutPaymentInvoice: z.coerce.boolean().optional(),
|
|
41
|
+
// То же для передаточного документа — пикер заказов при выпуске УПД. Здесь `queryBooleanSchema`,
|
|
42
|
+
// а не `z.coerce.boolean()`: в query всегда приходит текст, и `Boolean('false') === true`,
|
|
43
|
+
// то есть флаг соседа невозможно выключить явным значением, только опустив параметр.
|
|
44
|
+
withoutTransferDocument: queryBooleanSchema,
|
|
45
|
+
})
|
|
46
|
+
.refine(
|
|
47
|
+
value => {
|
|
48
|
+
const { startDate, endDate } = value;
|
|
49
|
+
if (startDate && endDate) {
|
|
50
|
+
return dateRangeCheck(startDate, endDate);
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
message: 'validation.dateRange',
|
|
56
|
+
path: ['endDate', 'startDate'],
|
|
57
|
+
},
|
|
58
|
+
)
|
|
59
|
+
.refine(
|
|
60
|
+
value => {
|
|
61
|
+
const { deliveryDateFrom, deliveryDateTo } = value;
|
|
62
|
+
if (deliveryDateFrom && deliveryDateTo) {
|
|
63
|
+
return dateRangeCheck(deliveryDateFrom, deliveryDateTo);
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
message: 'validation.dateRange',
|
|
69
|
+
path: ['deliveryDateTo', 'deliveryDateFrom'],
|
|
70
|
+
},
|
|
71
|
+
);
|
package/schemas/order/index.ts
CHANGED
|
@@ -29,3 +29,11 @@ export * from './order-vat-transition-execute-result.schema';
|
|
|
29
29
|
export * from './order-vat-transition-execute-response.schema';
|
|
30
30
|
|
|
31
31
|
export * from './order-vat-source-confirmation.schema';
|
|
32
|
+
|
|
33
|
+
export * from './get-order-list-request.schema';
|
|
34
|
+
|
|
35
|
+
export * from './get-order-list-response.schema';
|
|
36
|
+
|
|
37
|
+
export * from './get-order-list-response-data.schema';
|
|
38
|
+
|
|
39
|
+
export * from './order-creator.schema';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { OrderCreatorSchema } from './order-creator.schema';
|
|
2
|
+
import { OrderSourceEnum } from '../../enum/order-source.enum';
|
|
1
3
|
import { z } from 'zod';
|
|
2
4
|
import { ClientSchema } from '../client/client-base.schema';
|
|
3
5
|
import { BranchSchema } from '../branch/branch.schema';
|
|
@@ -6,6 +8,8 @@ import { DeliveryRouteSchema } from '../delivery-route/delivery-route.schema';
|
|
|
6
8
|
import { OrderSchema } from './order-base.schema';
|
|
7
9
|
|
|
8
10
|
export const OrderExtendedSchema = OrderSchema.extend({
|
|
11
|
+
source: z.nativeEnum(OrderSourceEnum).nullable(),
|
|
12
|
+
creator: OrderCreatorSchema.nullable(),
|
|
9
13
|
client: ClientSchema,
|
|
10
14
|
branch: BranchSchema.nullable(),
|
|
11
15
|
delivery: OrderDeliverySchema.nullable(),
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { OrderSourceEnum } from '../../enum/order-source.enum';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
import { optionalQueryBooleanSchema } from '../../helpers/optional-query-boolean.helper';
|
|
3
4
|
import { PreOrderStatusEnum } from '../../enum';
|
|
4
5
|
|
|
5
6
|
export const GetPreOrderListRequestSchema = z.object({
|
|
7
|
+
source: z.nativeEnum(OrderSourceEnum).optional(),
|
|
6
8
|
page: z.string().transform(val => Number(val) || 1),
|
|
7
9
|
excludeClosed: optionalQueryBooleanSchema,
|
|
8
10
|
count: z.coerce.number().optional().default(10),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { OrderCreatorSchema } from '../order/order-creator.schema';
|
|
2
|
+
import { OrderSourceEnum } from '../../enum/order-source.enum';
|
|
1
3
|
import { PreOrderConversionCurrentOrderSchema } from './pre-order-conversion-current-order.schema';
|
|
2
4
|
import { PreOrderConversionChangeSchema } from './pre-order-conversion-change.schema';
|
|
3
5
|
import { PreOrderConversionSummarySchema } from './pre-order-conversion-summary.schema';
|
|
@@ -23,6 +25,8 @@ export const PreOrderSchema = z.object({
|
|
|
23
25
|
});
|
|
24
26
|
|
|
25
27
|
export const PreOrderExtendedSchema = PreOrderSchema.extend({
|
|
28
|
+
source: z.nativeEnum(OrderSourceEnum).nullable(),
|
|
29
|
+
creator: OrderCreatorSchema.nullable(),
|
|
26
30
|
client: ClientSchema,
|
|
27
31
|
branch: BranchSchema.nullable(),
|
|
28
32
|
preOrderCollection: PreOrderCollectionSchema.nullable(),
|
|
@@ -6,4 +6,8 @@ export const WriteOffImageSchema = z.object({
|
|
|
6
6
|
url: z.string(),
|
|
7
7
|
createdAt: z.date(),
|
|
8
8
|
deletedAt: z.date().nullable(),
|
|
9
|
+
// Retention policy (WRITE_OFF_IMAGE_RETENTION_DAYS), not a storage check: once expired, treat the photo as
|
|
10
|
+
// unavailable whether or not the file is still in the bucket. The record itself stays.
|
|
11
|
+
fileExpiresAt: z.date(),
|
|
12
|
+
isFileExpired: z.boolean(),
|
|
9
13
|
});
|