@floristcloud/api-lib 1.2.162 → 1.2.164

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 (40) hide show
  1. package/build/commands/pre-order/group/group-create-pre-orders-from-standing-orders.command.js +4 -30
  2. package/build/constant/error-i18n-key.js +11 -0
  3. package/build/constant/error.js +51 -0
  4. package/build/schemas/pre-order/analyze-create-pre-orders-from-standing-orders-response-data-analyses-mappings.schema.js +5 -0
  5. package/build/schemas/pre-order/analyze-create-pre-orders-from-standing-orders-response-data-analyses.schema.js +2 -0
  6. package/build/schemas/pre-order/analyze-create-pre-orders-from-standing-orders-response-data-error-list.schema.js +1 -0
  7. package/build/schemas/pre-order/group-create-pre-orders-from-standing-orders-request.schema.js +18 -0
  8. package/build/schemas/pre-order/group-create-pre-orders-from-standing-orders-response.schema.js +9 -0
  9. package/build/schemas/pre-order/index.js +12 -0
  10. package/build/schemas/pre-order/pre-order-from-standing-order.schema.js +8 -0
  11. package/build/schemas/pre-order/standing-order-conversion-created.schema.js +11 -0
  12. package/build/schemas/pre-order/standing-order-conversion-failed-error.schema.js +8 -0
  13. package/build/schemas/pre-order/standing-order-conversion-failed.schema.js +9 -0
  14. package/build/schemas/pre-order/standing-order-conversion-plan-allocation.schema.js +8 -0
  15. package/build/schemas/pre-order/standing-order-conversion-plan-entry.schema.js +9 -0
  16. package/build/schemas/pre-order/standing-order-conversion-plan-line.schema.js +9 -0
  17. package/build/schemas/pre-order/standing-order-conversion-result.schema.js +10 -0
  18. package/build/schemas/pre-order/standing-order-conversion-target-pre-order.schema.js +8 -0
  19. package/build/schemas/pre-order/standing-order-conversion-target.schema.js +13 -0
  20. package/commands/pre-order/group/analyze-create-pre-orders-from-standing-orders.command.ts +2 -1
  21. package/commands/pre-order/group/group-create-pre-orders-from-standing-orders.command.ts +3 -30
  22. package/constant/error-i18n-key.ts +12 -0
  23. package/constant/error.ts +51 -0
  24. package/package.json +1 -1
  25. package/schemas/pre-order/analyze-create-pre-orders-from-standing-orders-response-data-analyses-mappings.schema.ts +5 -0
  26. package/schemas/pre-order/analyze-create-pre-orders-from-standing-orders-response-data-analyses.schema.ts +2 -0
  27. package/schemas/pre-order/analyze-create-pre-orders-from-standing-orders-response-data-error-list.schema.ts +1 -0
  28. package/schemas/pre-order/group-create-pre-orders-from-standing-orders-request.schema.ts +16 -0
  29. package/schemas/pre-order/group-create-pre-orders-from-standing-orders-response.schema.ts +7 -0
  30. package/schemas/pre-order/index.ts +12 -0
  31. package/schemas/pre-order/pre-order-from-standing-order.schema.ts +6 -0
  32. package/schemas/pre-order/standing-order-conversion-created.schema.ts +9 -0
  33. package/schemas/pre-order/standing-order-conversion-failed-error.schema.ts +6 -0
  34. package/schemas/pre-order/standing-order-conversion-failed.schema.ts +7 -0
  35. package/schemas/pre-order/standing-order-conversion-plan-allocation.schema.ts +6 -0
  36. package/schemas/pre-order/standing-order-conversion-plan-entry.schema.ts +7 -0
  37. package/schemas/pre-order/standing-order-conversion-plan-line.schema.ts +7 -0
  38. package/schemas/pre-order/standing-order-conversion-result.schema.ts +8 -0
  39. package/schemas/pre-order/standing-order-conversion-target-pre-order.schema.ts +6 -0
  40. package/schemas/pre-order/standing-order-conversion-target.schema.ts +11 -0
@@ -1,36 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GroupCreatePreOrdersFromStandingOrdersContractCommand = void 0;
4
- const zod_1 = require("zod");
5
- const schemas_1 = require("../../../schemas");
6
- const GroupCreatePreOrdersFromStandingOrdersRequestSchema = zod_1.z.object({
7
- standingOrderUUIDs: zod_1.z.uuid().array(),
8
- preOrderCollectionUUIDs: zod_1.z.uuid().array(),
9
- matchingConfig: schemas_1.MatchingConfigSchema.optional().nullable(),
10
- });
11
- const GroupCreatePreOrdersFromStandingOrdersResponseSchema = zod_1.z.object({
12
- message: zod_1.z.string().optional(),
13
- data: zod_1.z.object({
14
- created: zod_1.z
15
- .object({
16
- standingOrderUUID: zod_1.z.uuid(),
17
- preOrders: schemas_1.PreOrderSchema.array(),
18
- warnings: zod_1.z.array(schemas_1.ErrorMessageSchema),
19
- })
20
- .array(),
21
- failed: zod_1.z
22
- .object({
23
- standingOrderUUID: zod_1.z.uuid(),
24
- error: zod_1.z.object({
25
- code: zod_1.z.string(),
26
- message: zod_1.z.string(),
27
- }),
28
- })
29
- .array(),
30
- }),
31
- });
4
+ const group_create_pre_orders_from_standing_orders_request_schema_1 = require("../../../schemas/pre-order/group-create-pre-orders-from-standing-orders-request.schema");
5
+ const group_create_pre_orders_from_standing_orders_response_schema_1 = require("../../../schemas/pre-order/group-create-pre-orders-from-standing-orders-response.schema");
32
6
  var GroupCreatePreOrdersFromStandingOrdersContractCommand;
33
7
  (function (GroupCreatePreOrdersFromStandingOrdersContractCommand) {
34
- GroupCreatePreOrdersFromStandingOrdersContractCommand.RequestSchema = GroupCreatePreOrdersFromStandingOrdersRequestSchema;
35
- GroupCreatePreOrdersFromStandingOrdersContractCommand.ResponseSchema = GroupCreatePreOrdersFromStandingOrdersResponseSchema;
8
+ GroupCreatePreOrdersFromStandingOrdersContractCommand.RequestSchema = group_create_pre_orders_from_standing_orders_request_schema_1.GroupCreatePreOrdersFromStandingOrdersRequestSchema;
9
+ GroupCreatePreOrdersFromStandingOrdersContractCommand.ResponseSchema = group_create_pre_orders_from_standing_orders_response_schema_1.GroupCreatePreOrdersFromStandingOrdersResponseSchema;
36
10
  })(GroupCreatePreOrdersFromStandingOrdersContractCommand || (exports.GroupCreatePreOrdersFromStandingOrdersContractCommand = GroupCreatePreOrdersFromStandingOrdersContractCommand = {}));
@@ -71,6 +71,17 @@ exports.ErrorI18nKey = {
71
71
  soProductNotCreated: 'preOrderFromStandingOrder.productNotCreated',
72
72
  soCriticalError: 'preOrderFromStandingOrder.criticalError',
73
73
  soNoPreOrdersCreated: 'preOrderFromStandingOrder.noPreOrdersCreated',
74
+ soItemSkippedInsufficientBalance: 'preOrderFromStandingOrder.itemSkippedInsufficientBalance',
75
+ soPlanItemPartiallyAllocated: 'preOrderFromStandingOrder.planItemPartiallyAllocated',
76
+ soLineAlreadyConverted: 'preOrderFromStandingOrder.lineAlreadyConverted',
77
+ // Standing-order → pre-order conversion plan validation
78
+ soPlanMismatch: 'standingOrderPlan.mismatch',
79
+ soPlanDuplicateStandingOrder: 'standingOrderPlan.duplicateStandingOrder',
80
+ soPlanDuplicateLine: 'standingOrderPlan.duplicateLine',
81
+ soPlanDuplicateItem: 'standingOrderPlan.duplicateItem',
82
+ soPlanLineNotInStandingOrder: 'standingOrderPlan.lineNotInStandingOrder',
83
+ soPlanItemNotAvailable: 'standingOrderPlan.itemNotAvailable',
84
+ soPlanQuantityExceedsLine: 'standingOrderPlan.quantityExceedsLine',
74
85
  // Pre-order → standing-order conversion warnings
75
86
  preOrderToSoSourceEmpty: 'preOrderToStandingOrder.sourceEmpty',
76
87
  preOrderToSoItemSkipped: 'preOrderToStandingOrder.itemSkipped',
@@ -994,6 +994,47 @@ exports.ERRORS = {
994
994
  message: 'No pre-orders were created for this standing order: no matching items found in the selected collections',
995
995
  httpCode: 400,
996
996
  },
997
+ PRE_ORDER_SO_ITEM_SKIPPED_INSUFFICIENT_BALANCE: {
998
+ code: 'PO055',
999
+ message: 'Standing-order item was skipped: the collection item balance is no longer sufficient',
1000
+ httpCode: 400,
1001
+ },
1002
+ PRE_ORDER_SO_PLAN_ITEM_PARTIALLY_ALLOCATED: {
1003
+ code: 'PO056',
1004
+ message: 'Only part of the standing-order item quantity was added to the pre-order',
1005
+ httpCode: 400,
1006
+ },
1007
+ // PRE ORDER — standing-order → pre-order conversion plan validation and repeat guard
1008
+ PRE_ORDER_SO_PLAN_MISMATCH: {
1009
+ code: 'PO049',
1010
+ message: 'Conversion plan must cover exactly the requested standing orders',
1011
+ httpCode: 400,
1012
+ },
1013
+ PRE_ORDER_SO_PLAN_DUPLICATE_ENTRY: {
1014
+ code: 'PO050',
1015
+ message: 'Conversion plan contains duplicate entries',
1016
+ httpCode: 400,
1017
+ },
1018
+ PRE_ORDER_SO_PLAN_LINE_NOT_IN_STANDING_ORDER: {
1019
+ code: 'PO051',
1020
+ message: 'Planned line does not belong to its standing order',
1021
+ httpCode: 400,
1022
+ },
1023
+ PRE_ORDER_SO_PLAN_ITEM_NOT_AVAILABLE: {
1024
+ code: 'PO052',
1025
+ message: 'Planned collection item does not belong to the selected collections',
1026
+ httpCode: 400,
1027
+ },
1028
+ PRE_ORDER_SO_PLAN_QUANTITY_EXCEEDS_LINE: {
1029
+ code: 'PO053',
1030
+ message: 'Planned quantity exceeds the standing-order line quantity',
1031
+ httpCode: 400,
1032
+ },
1033
+ PRE_ORDER_SO_LINE_ALREADY_CONVERTED: {
1034
+ code: 'PO054',
1035
+ message: 'Standing-order line has already been converted into this collection',
1036
+ httpCode: 409,
1037
+ },
997
1038
  // PRE ORDER — pre-order → standing-order conversion
998
1039
  PRE_ORDER_TO_STANDING_ORDER_FAILED: {
999
1040
  code: 'PO044',
@@ -1630,6 +1671,16 @@ exports.ERRORS = {
1630
1671
  },
1631
1672
  OZEXPORT_DISABLED: { code: 'OZ012', message: 'ozexport integration is disabled for this company', httpCode: 409 },
1632
1673
  OZEXPORT_CATALOG_FETCH_FAILED: { code: 'OZ013', message: 'Failed to read the ozexport catalog', httpCode: 500 },
1674
+ OZEXPORT_LOGIN_LIMITED: {
1675
+ code: 'OZ014',
1676
+ message: 'Too many ozexport login attempts for this account, try again later',
1677
+ httpCode: 429,
1678
+ },
1679
+ OZEXPORT_ACCOUNT_BUSY: {
1680
+ code: 'OZ015',
1681
+ message: 'The ozexport account is busy with another session, try again in a few minutes',
1682
+ httpCode: 409,
1683
+ },
1633
1684
  // SUPPLIER OFFERS / SUPPLIER SYNC JOBS (FC-513)
1634
1685
  SUPPLIER_OFFER_NOT_SAVED: { code: 'SOF001', message: 'Failed to save supplier offers', httpCode: 500 },
1635
1686
  SUPPLIER_OFFER_NOT_DELETED: { code: 'SOF002', message: 'Failed to delete supplier offers', httpCode: 500 },
@@ -8,4 +8,9 @@ exports.AnalyzeCreatePreOrdersFromStandingOrdersResponseDataAnalysesMappingsSche
8
8
  standingOrderProduct: pre_order_product_extended_schema_1.PreOrderProductExtendedSchema,
9
9
  matches: zod_1.z.array(copy_analysis_match_schema_1.CopyAnalysisMatchSchema),
10
10
  remainingQuantity: zod_1.z.number(),
11
+ /**
12
+ * Requested collections this standing-order line has already been converted into. Sending the
13
+ * line into one of them again is rejected, so the preview has to leave it out of the plan.
14
+ */
15
+ alreadyConvertedCollectionUUIDs: zod_1.z.uuid().array(),
11
16
  });
@@ -5,8 +5,10 @@ const zod_1 = require("zod");
5
5
  const error_message_schema_1 = require("../error-message.schema");
6
6
  const analyze_create_pre_orders_from_standing_orders_response_data_analyses_mappings_schema_1 = require("./analyze-create-pre-orders-from-standing-orders-response-data-analyses-mappings.schema");
7
7
  const pre_order_schema_1 = require("./pre-order.schema");
8
+ const standing_order_conversion_target_schema_1 = require("./standing-order-conversion-target.schema");
8
9
  exports.AnalyzeCreatePreOrdersFromStandingOrdersResponseDataAnalysesSchema = zod_1.z.object({
9
10
  standingOrder: pre_order_schema_1.PreOrderWithClientSchema,
10
11
  mappings: zod_1.z.record(zod_1.z.string(), analyze_create_pre_orders_from_standing_orders_response_data_analyses_mappings_schema_1.AnalyzeCreatePreOrdersFromStandingOrdersResponseDataAnalysesMappingsSchema),
11
12
  warnings: zod_1.z.record(zod_1.z.string(), zod_1.z.array(error_message_schema_1.ErrorMessageSchema)),
13
+ targets: standing_order_conversion_target_schema_1.StandingOrderConversionTargetSchema.array(),
12
14
  });
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AnalyzeCreatePreOrdersFromStandingOrdersResponseDataErrorListSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.AnalyzeCreatePreOrdersFromStandingOrdersResponseDataErrorListSchema = zod_1.z.object({
6
+ standingOrderUUID: zod_1.z.uuid(),
6
7
  code: zod_1.z.string(),
7
8
  message: zod_1.z.string(),
8
9
  });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupCreatePreOrdersFromStandingOrdersRequestSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const matching_config_schema_1 = require("../pre-order-product/matching-config.schema");
6
+ const standing_order_conversion_plan_entry_schema_1 = require("./standing-order-conversion-plan-entry.schema");
7
+ exports.GroupCreatePreOrdersFromStandingOrdersRequestSchema = zod_1.z.object({
8
+ standingOrderUUIDs: zod_1.z.uuid().array(),
9
+ preOrderCollectionUUIDs: zod_1.z.uuid().array(),
10
+ matchingConfig: matching_config_schema_1.MatchingConfigSchema.optional().nullable(),
11
+ /**
12
+ * The conversion the user confirmed in the preview. Without it the server re-runs the matching
13
+ * and converts whatever it finds at that moment; with it the matching is skipped and exactly
14
+ * these allocations are created. Carries the collection item choice and quantity only — the
15
+ * price always comes from the collection item.
16
+ */
17
+ plan: standing_order_conversion_plan_entry_schema_1.StandingOrderConversionPlanEntrySchema.array().optional(),
18
+ });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupCreatePreOrdersFromStandingOrdersResponseSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const standing_order_conversion_result_schema_1 = require("./standing-order-conversion-result.schema");
6
+ exports.GroupCreatePreOrdersFromStandingOrdersResponseSchema = zod_1.z.object({
7
+ message: zod_1.z.string().optional(),
8
+ data: standing_order_conversion_result_schema_1.StandingOrderConversionResultSchema,
9
+ });
@@ -32,6 +32,8 @@ __exportStar(require("./group-copy-pre-orders-to-collection-response-data-create
32
32
  __exportStar(require("./group-copy-pre-orders-to-collection-response-data-failed.schema"), exports);
33
33
  __exportStar(require("./group-copy-pre-orders-to-collection-response-data.schema"), exports);
34
34
  __exportStar(require("./group-copy-pre-orders-to-collection-response.schema"), exports);
35
+ __exportStar(require("./group-create-pre-orders-from-standing-orders-request.schema"), exports);
36
+ __exportStar(require("./group-create-pre-orders-from-standing-orders-response.schema"), exports);
35
37
  __exportStar(require("./group-delete-pre-order-request.schema"), exports);
36
38
  __exportStar(require("./group-delete-pre-order-response.schema"), exports);
37
39
  __exportStar(require("./group-update-pre-order-request.schema"), exports);
@@ -39,5 +41,15 @@ __exportStar(require("./group-update-pre-order-response.schema"), exports);
39
41
  __exportStar(require("./pre-order-extended-for-client-list.schema"), exports);
40
42
  __exportStar(require("./pre-order-extended-for-client.schema"), exports);
41
43
  __exportStar(require("./pre-order-for-client.schema"), exports);
44
+ __exportStar(require("./pre-order-from-standing-order.schema"), exports);
42
45
  __exportStar(require("./pre-order-summary.schema"), exports);
43
46
  __exportStar(require("./pre-order.schema"), exports);
47
+ __exportStar(require("./standing-order-conversion-created.schema"), exports);
48
+ __exportStar(require("./standing-order-conversion-failed-error.schema"), exports);
49
+ __exportStar(require("./standing-order-conversion-failed.schema"), exports);
50
+ __exportStar(require("./standing-order-conversion-plan-allocation.schema"), exports);
51
+ __exportStar(require("./standing-order-conversion-plan-entry.schema"), exports);
52
+ __exportStar(require("./standing-order-conversion-plan-line.schema"), exports);
53
+ __exportStar(require("./standing-order-conversion-result.schema"), exports);
54
+ __exportStar(require("./standing-order-conversion-target-pre-order.schema"), exports);
55
+ __exportStar(require("./standing-order-conversion-target.schema"), exports);
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PreOrderFromStandingOrderSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const pre_order_schema_1 = require("./pre-order.schema");
6
+ exports.PreOrderFromStandingOrderSchema = pre_order_schema_1.PreOrderSchema.extend({
7
+ preOrderCollectionUUID: zod_1.z.string(),
8
+ });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandingOrderConversionCreatedSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const error_message_schema_1 = require("../error-message.schema");
6
+ const pre_order_from_standing_order_schema_1 = require("./pre-order-from-standing-order.schema");
7
+ exports.StandingOrderConversionCreatedSchema = zod_1.z.object({
8
+ standingOrderUUID: zod_1.z.uuid(),
9
+ preOrders: pre_order_from_standing_order_schema_1.PreOrderFromStandingOrderSchema.array(),
10
+ warnings: error_message_schema_1.ErrorMessageSchema.array(),
11
+ });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandingOrderConversionFailedErrorSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const error_message_schema_1 = require("../error-message.schema");
6
+ exports.StandingOrderConversionFailedErrorSchema = error_message_schema_1.ErrorMessageSchema.extend({
7
+ code: zod_1.z.string(),
8
+ });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandingOrderConversionFailedSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const standing_order_conversion_failed_error_schema_1 = require("./standing-order-conversion-failed-error.schema");
6
+ exports.StandingOrderConversionFailedSchema = zod_1.z.object({
7
+ standingOrderUUID: zod_1.z.uuid(),
8
+ error: standing_order_conversion_failed_error_schema_1.StandingOrderConversionFailedErrorSchema,
9
+ });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandingOrderConversionPlanAllocationSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.StandingOrderConversionPlanAllocationSchema = zod_1.z.object({
6
+ preOrderCollectionItemUUID: zod_1.z.uuid(),
7
+ quantity: zod_1.z.number().int().positive(),
8
+ });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandingOrderConversionPlanEntrySchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const standing_order_conversion_plan_line_schema_1 = require("./standing-order-conversion-plan-line.schema");
6
+ exports.StandingOrderConversionPlanEntrySchema = zod_1.z.object({
7
+ standingOrderUUID: zod_1.z.uuid(),
8
+ lines: standing_order_conversion_plan_line_schema_1.StandingOrderConversionPlanLineSchema.array(),
9
+ });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandingOrderConversionPlanLineSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const standing_order_conversion_plan_allocation_schema_1 = require("./standing-order-conversion-plan-allocation.schema");
6
+ exports.StandingOrderConversionPlanLineSchema = zod_1.z.object({
7
+ standingOrderProductUUID: zod_1.z.uuid(),
8
+ allocations: standing_order_conversion_plan_allocation_schema_1.StandingOrderConversionPlanAllocationSchema.array(),
9
+ });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandingOrderConversionResultSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const standing_order_conversion_created_schema_1 = require("./standing-order-conversion-created.schema");
6
+ const standing_order_conversion_failed_schema_1 = require("./standing-order-conversion-failed.schema");
7
+ exports.StandingOrderConversionResultSchema = zod_1.z.object({
8
+ created: standing_order_conversion_created_schema_1.StandingOrderConversionCreatedSchema.array(),
9
+ failed: standing_order_conversion_failed_schema_1.StandingOrderConversionFailedSchema.array(),
10
+ });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandingOrderConversionTargetPreOrderSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.StandingOrderConversionTargetPreOrderSchema = zod_1.z.object({
6
+ uuid: zod_1.z.uuid(),
7
+ preOrderNum: zod_1.z.number(),
8
+ });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandingOrderConversionTargetSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const standing_order_conversion_target_pre_order_schema_1 = require("./standing-order-conversion-target-pre-order.schema");
6
+ exports.StandingOrderConversionTargetSchema = zod_1.z.object({
7
+ preOrderCollectionUUID: zod_1.z.uuid(),
8
+ /**
9
+ * The open pre-order of the same client and branch the lines will be appended to; `null` means
10
+ * a new pre-order is created. A snapshot of the analysis moment: execution looks it up again.
11
+ */
12
+ existingPreOrder: standing_order_conversion_target_pre_order_schema_1.StandingOrderConversionTargetPreOrderSchema.nullable(),
13
+ });
@@ -1,10 +1,11 @@
1
- import { z } from 'zod';
1
+ import type { z } from 'zod';
2
2
  import { AnalyzeCreatePreOrdersFromStandingOrdersRequestSchema } from '../../../schemas/pre-order/analyze-create-pre-orders-from-standing-orders-request.schema';
3
3
  import { AnalyzeCreatePreOrdersFromStandingOrdersResponseSchema } from '../../../schemas/pre-order/analyze-create-pre-orders-from-standing-orders-response.schema';
4
4
 
5
5
  export namespace AnalyzeCreatePreOrdersFromStandingOrdersContractCommand {
6
6
  export const RequestSchema = AnalyzeCreatePreOrdersFromStandingOrdersRequestSchema;
7
7
  export type Request = z.infer<typeof RequestSchema>;
8
+
8
9
  export const ResponseSchema = AnalyzeCreatePreOrdersFromStandingOrdersResponseSchema;
9
10
  export type Response = z.infer<typeof ResponseSchema>;
10
11
  }
@@ -1,33 +1,6 @@
1
- import { z } from 'zod';
2
- import { ErrorMessageSchema, MatchingConfigSchema, PreOrderSchema } from '../../../schemas';
3
-
4
- const GroupCreatePreOrdersFromStandingOrdersRequestSchema = z.object({
5
- standingOrderUUIDs: z.uuid().array(),
6
- preOrderCollectionUUIDs: z.uuid().array(),
7
- matchingConfig: MatchingConfigSchema.optional().nullable(),
8
- });
9
-
10
- const GroupCreatePreOrdersFromStandingOrdersResponseSchema = z.object({
11
- message: z.string().optional(),
12
- data: z.object({
13
- created: z
14
- .object({
15
- standingOrderUUID: z.uuid(),
16
- preOrders: PreOrderSchema.array(),
17
- warnings: z.array(ErrorMessageSchema),
18
- })
19
- .array(),
20
- failed: z
21
- .object({
22
- standingOrderUUID: z.uuid(),
23
- error: z.object({
24
- code: z.string(),
25
- message: z.string(),
26
- }),
27
- })
28
- .array(),
29
- }),
30
- });
1
+ import type { z } from 'zod';
2
+ import { GroupCreatePreOrdersFromStandingOrdersRequestSchema } from '../../../schemas/pre-order/group-create-pre-orders-from-standing-orders-request.schema';
3
+ import { GroupCreatePreOrdersFromStandingOrdersResponseSchema } from '../../../schemas/pre-order/group-create-pre-orders-from-standing-orders-response.schema';
31
4
 
32
5
  export namespace GroupCreatePreOrdersFromStandingOrdersContractCommand {
33
6
  export const RequestSchema = GroupCreatePreOrdersFromStandingOrdersRequestSchema;
@@ -74,6 +74,18 @@ export const ErrorI18nKey = {
74
74
  soProductNotCreated: 'preOrderFromStandingOrder.productNotCreated',
75
75
  soCriticalError: 'preOrderFromStandingOrder.criticalError',
76
76
  soNoPreOrdersCreated: 'preOrderFromStandingOrder.noPreOrdersCreated',
77
+ soItemSkippedInsufficientBalance: 'preOrderFromStandingOrder.itemSkippedInsufficientBalance',
78
+ soPlanItemPartiallyAllocated: 'preOrderFromStandingOrder.planItemPartiallyAllocated',
79
+ soLineAlreadyConverted: 'preOrderFromStandingOrder.lineAlreadyConverted',
80
+
81
+ // Standing-order → pre-order conversion plan validation
82
+ soPlanMismatch: 'standingOrderPlan.mismatch',
83
+ soPlanDuplicateStandingOrder: 'standingOrderPlan.duplicateStandingOrder',
84
+ soPlanDuplicateLine: 'standingOrderPlan.duplicateLine',
85
+ soPlanDuplicateItem: 'standingOrderPlan.duplicateItem',
86
+ soPlanLineNotInStandingOrder: 'standingOrderPlan.lineNotInStandingOrder',
87
+ soPlanItemNotAvailable: 'standingOrderPlan.itemNotAvailable',
88
+ soPlanQuantityExceedsLine: 'standingOrderPlan.quantityExceedsLine',
77
89
 
78
90
  // Pre-order → standing-order conversion warnings
79
91
  preOrderToSoSourceEmpty: 'preOrderToStandingOrder.sourceEmpty',
package/constant/error.ts CHANGED
@@ -1030,6 +1030,47 @@ export const ERRORS = {
1030
1030
  message: 'No pre-orders were created for this standing order: no matching items found in the selected collections',
1031
1031
  httpCode: 400,
1032
1032
  },
1033
+ PRE_ORDER_SO_ITEM_SKIPPED_INSUFFICIENT_BALANCE: {
1034
+ code: 'PO055',
1035
+ message: 'Standing-order item was skipped: the collection item balance is no longer sufficient',
1036
+ httpCode: 400,
1037
+ },
1038
+ PRE_ORDER_SO_PLAN_ITEM_PARTIALLY_ALLOCATED: {
1039
+ code: 'PO056',
1040
+ message: 'Only part of the standing-order item quantity was added to the pre-order',
1041
+ httpCode: 400,
1042
+ },
1043
+ // PRE ORDER — standing-order → pre-order conversion plan validation and repeat guard
1044
+ PRE_ORDER_SO_PLAN_MISMATCH: {
1045
+ code: 'PO049',
1046
+ message: 'Conversion plan must cover exactly the requested standing orders',
1047
+ httpCode: 400,
1048
+ },
1049
+ PRE_ORDER_SO_PLAN_DUPLICATE_ENTRY: {
1050
+ code: 'PO050',
1051
+ message: 'Conversion plan contains duplicate entries',
1052
+ httpCode: 400,
1053
+ },
1054
+ PRE_ORDER_SO_PLAN_LINE_NOT_IN_STANDING_ORDER: {
1055
+ code: 'PO051',
1056
+ message: 'Planned line does not belong to its standing order',
1057
+ httpCode: 400,
1058
+ },
1059
+ PRE_ORDER_SO_PLAN_ITEM_NOT_AVAILABLE: {
1060
+ code: 'PO052',
1061
+ message: 'Planned collection item does not belong to the selected collections',
1062
+ httpCode: 400,
1063
+ },
1064
+ PRE_ORDER_SO_PLAN_QUANTITY_EXCEEDS_LINE: {
1065
+ code: 'PO053',
1066
+ message: 'Planned quantity exceeds the standing-order line quantity',
1067
+ httpCode: 400,
1068
+ },
1069
+ PRE_ORDER_SO_LINE_ALREADY_CONVERTED: {
1070
+ code: 'PO054',
1071
+ message: 'Standing-order line has already been converted into this collection',
1072
+ httpCode: 409,
1073
+ },
1033
1074
  // PRE ORDER — pre-order → standing-order conversion
1034
1075
  PRE_ORDER_TO_STANDING_ORDER_FAILED: {
1035
1076
  code: 'PO044',
@@ -1699,6 +1740,16 @@ export const ERRORS = {
1699
1740
  },
1700
1741
  OZEXPORT_DISABLED: { code: 'OZ012', message: 'ozexport integration is disabled for this company', httpCode: 409 },
1701
1742
  OZEXPORT_CATALOG_FETCH_FAILED: { code: 'OZ013', message: 'Failed to read the ozexport catalog', httpCode: 500 },
1743
+ OZEXPORT_LOGIN_LIMITED: {
1744
+ code: 'OZ014',
1745
+ message: 'Too many ozexport login attempts for this account, try again later',
1746
+ httpCode: 429,
1747
+ },
1748
+ OZEXPORT_ACCOUNT_BUSY: {
1749
+ code: 'OZ015',
1750
+ message: 'The ozexport account is busy with another session, try again in a few minutes',
1751
+ httpCode: 409,
1752
+ },
1702
1753
 
1703
1754
  // SUPPLIER OFFERS / SUPPLIER SYNC JOBS (FC-513)
1704
1755
  SUPPLIER_OFFER_NOT_SAVED: { code: 'SOF001', message: 'Failed to save supplier offers', httpCode: 500 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floristcloud/api-lib",
3
- "version": "1.2.162",
3
+ "version": "1.2.164",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -6,4 +6,9 @@ export const AnalyzeCreatePreOrdersFromStandingOrdersResponseDataAnalysesMapping
6
6
  standingOrderProduct: PreOrderProductExtendedSchema,
7
7
  matches: z.array(CopyAnalysisMatchSchema),
8
8
  remainingQuantity: z.number(),
9
+ /**
10
+ * Requested collections this standing-order line has already been converted into. Sending the
11
+ * line into one of them again is rejected, so the preview has to leave it out of the plan.
12
+ */
13
+ alreadyConvertedCollectionUUIDs: z.uuid().array(),
9
14
  });
@@ -2,9 +2,11 @@ import { z } from 'zod';
2
2
  import { ErrorMessageSchema } from '../error-message.schema';
3
3
  import { AnalyzeCreatePreOrdersFromStandingOrdersResponseDataAnalysesMappingsSchema } from './analyze-create-pre-orders-from-standing-orders-response-data-analyses-mappings.schema';
4
4
  import { PreOrderWithClientSchema } from './pre-order.schema';
5
+ import { StandingOrderConversionTargetSchema } from './standing-order-conversion-target.schema';
5
6
 
6
7
  export const AnalyzeCreatePreOrdersFromStandingOrdersResponseDataAnalysesSchema = z.object({
7
8
  standingOrder: PreOrderWithClientSchema,
8
9
  mappings: z.record(z.string(), AnalyzeCreatePreOrdersFromStandingOrdersResponseDataAnalysesMappingsSchema),
9
10
  warnings: z.record(z.string(), z.array(ErrorMessageSchema)),
11
+ targets: StandingOrderConversionTargetSchema.array(),
10
12
  });
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  export const AnalyzeCreatePreOrdersFromStandingOrdersResponseDataErrorListSchema = z.object({
4
+ standingOrderUUID: z.uuid(),
4
5
  code: z.string(),
5
6
  message: z.string(),
6
7
  });
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { MatchingConfigSchema } from '../pre-order-product/matching-config.schema';
3
+ import { StandingOrderConversionPlanEntrySchema } from './standing-order-conversion-plan-entry.schema';
4
+
5
+ export const GroupCreatePreOrdersFromStandingOrdersRequestSchema = z.object({
6
+ standingOrderUUIDs: z.uuid().array(),
7
+ preOrderCollectionUUIDs: z.uuid().array(),
8
+ matchingConfig: MatchingConfigSchema.optional().nullable(),
9
+ /**
10
+ * The conversion the user confirmed in the preview. Without it the server re-runs the matching
11
+ * and converts whatever it finds at that moment; with it the matching is skipped and exactly
12
+ * these allocations are created. Carries the collection item choice and quantity only — the
13
+ * price always comes from the collection item.
14
+ */
15
+ plan: StandingOrderConversionPlanEntrySchema.array().optional(),
16
+ });
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import { StandingOrderConversionResultSchema } from './standing-order-conversion-result.schema';
3
+
4
+ export const GroupCreatePreOrdersFromStandingOrdersResponseSchema = z.object({
5
+ message: z.string().optional(),
6
+ data: StandingOrderConversionResultSchema,
7
+ });
@@ -16,6 +16,8 @@ export * from './group-copy-pre-orders-to-collection-response-data-created.schem
16
16
  export * from './group-copy-pre-orders-to-collection-response-data-failed.schema';
17
17
  export * from './group-copy-pre-orders-to-collection-response-data.schema';
18
18
  export * from './group-copy-pre-orders-to-collection-response.schema';
19
+ export * from './group-create-pre-orders-from-standing-orders-request.schema';
20
+ export * from './group-create-pre-orders-from-standing-orders-response.schema';
19
21
  export * from './group-delete-pre-order-request.schema';
20
22
  export * from './group-delete-pre-order-response.schema';
21
23
  export * from './group-update-pre-order-request.schema';
@@ -23,5 +25,15 @@ export * from './group-update-pre-order-response.schema';
23
25
  export * from './pre-order-extended-for-client-list.schema';
24
26
  export * from './pre-order-extended-for-client.schema';
25
27
  export * from './pre-order-for-client.schema';
28
+ export * from './pre-order-from-standing-order.schema';
26
29
  export * from './pre-order-summary.schema';
27
30
  export * from './pre-order.schema';
31
+ export * from './standing-order-conversion-created.schema';
32
+ export * from './standing-order-conversion-failed-error.schema';
33
+ export * from './standing-order-conversion-failed.schema';
34
+ export * from './standing-order-conversion-plan-allocation.schema';
35
+ export * from './standing-order-conversion-plan-entry.schema';
36
+ export * from './standing-order-conversion-plan-line.schema';
37
+ export * from './standing-order-conversion-result.schema';
38
+ export * from './standing-order-conversion-target-pre-order.schema';
39
+ export * from './standing-order-conversion-target.schema';
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ import { PreOrderSchema } from './pre-order.schema';
3
+
4
+ export const PreOrderFromStandingOrderSchema = PreOrderSchema.extend({
5
+ preOrderCollectionUUID: z.string(),
6
+ });
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ import { ErrorMessageSchema } from '../error-message.schema';
3
+ import { PreOrderFromStandingOrderSchema } from './pre-order-from-standing-order.schema';
4
+
5
+ export const StandingOrderConversionCreatedSchema = z.object({
6
+ standingOrderUUID: z.uuid(),
7
+ preOrders: PreOrderFromStandingOrderSchema.array(),
8
+ warnings: ErrorMessageSchema.array(),
9
+ });
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ import { ErrorMessageSchema } from '../error-message.schema';
3
+
4
+ export const StandingOrderConversionFailedErrorSchema = ErrorMessageSchema.extend({
5
+ code: z.string(),
6
+ });
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import { StandingOrderConversionFailedErrorSchema } from './standing-order-conversion-failed-error.schema';
3
+
4
+ export const StandingOrderConversionFailedSchema = z.object({
5
+ standingOrderUUID: z.uuid(),
6
+ error: StandingOrderConversionFailedErrorSchema,
7
+ });
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+
3
+ export const StandingOrderConversionPlanAllocationSchema = z.object({
4
+ preOrderCollectionItemUUID: z.uuid(),
5
+ quantity: z.number().int().positive(),
6
+ });
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import { StandingOrderConversionPlanLineSchema } from './standing-order-conversion-plan-line.schema';
3
+
4
+ export const StandingOrderConversionPlanEntrySchema = z.object({
5
+ standingOrderUUID: z.uuid(),
6
+ lines: StandingOrderConversionPlanLineSchema.array(),
7
+ });
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import { StandingOrderConversionPlanAllocationSchema } from './standing-order-conversion-plan-allocation.schema';
3
+
4
+ export const StandingOrderConversionPlanLineSchema = z.object({
5
+ standingOrderProductUUID: z.uuid(),
6
+ allocations: StandingOrderConversionPlanAllocationSchema.array(),
7
+ });
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import { StandingOrderConversionCreatedSchema } from './standing-order-conversion-created.schema';
3
+ import { StandingOrderConversionFailedSchema } from './standing-order-conversion-failed.schema';
4
+
5
+ export const StandingOrderConversionResultSchema = z.object({
6
+ created: StandingOrderConversionCreatedSchema.array(),
7
+ failed: StandingOrderConversionFailedSchema.array(),
8
+ });
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+
3
+ export const StandingOrderConversionTargetPreOrderSchema = z.object({
4
+ uuid: z.uuid(),
5
+ preOrderNum: z.number(),
6
+ });
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ import { StandingOrderConversionTargetPreOrderSchema } from './standing-order-conversion-target-pre-order.schema';
3
+
4
+ export const StandingOrderConversionTargetSchema = z.object({
5
+ preOrderCollectionUUID: z.uuid(),
6
+ /**
7
+ * The open pre-order of the same client and branch the lines will be appended to; `null` means
8
+ * a new pre-order is created. A snapshot of the analysis moment: execution looks it up again.
9
+ */
10
+ existingPreOrder: StandingOrderConversionTargetPreOrderSchema.nullable(),
11
+ });