@open-mercato/core 0.6.8-develop.7077.1.94f1126c13 → 0.6.8-develop.7079.1.dbf29dd6a1

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.
@@ -1,4 +1,4 @@
1
- [build:core] found 4341 entry points
1
+ [build:core] found 4342 entry points
2
2
  [build:core] built successfully
3
3
  [build:core:generated] found 218 entry points
4
4
  [build:core:generated] built successfully
@@ -16,14 +16,6 @@
16
16
  "type": "string",
17
17
  "defaultValue": "Free shipping on orders over $50"
18
18
  },
19
- {
20
- "identifier": "sales_channels_enabled",
21
- "name": "Sales Channels",
22
- "description": "Show sales channel pickers, filters, and management UI. Disable for tenants that do not use sales channels.",
23
- "category": "sales",
24
- "type": "boolean",
25
- "defaultValue": true
26
- },
27
19
  {
28
20
  "identifier": "order_review_threshold",
29
21
  "name": "Order Review Threshold",
@@ -135,6 +135,7 @@ const dateOnlySchema = z.string().trim().regex(/^\d{4}-\d{2}-\d{2}$/, { message:
135
135
  message: "invalid_date"
136
136
  });
137
137
  const addressSnapshotSchema = z.record(z.string(), z.unknown()).nullable().optional();
138
+ const exchangeRateSchema = z.coerce.number().min(0);
138
139
  const documentUpdateSchema = z.object({
139
140
  id: z.string().uuid(),
140
141
  customerEntityId: z.string().uuid().nullable().optional(),
@@ -152,6 +153,13 @@ const documentUpdateSchema = z.object({
152
153
  orderNumber: z.string().trim().min(1).max(191).optional(),
153
154
  quoteNumber: z.string().trim().min(1).max(191).optional(),
154
155
  currencyCode: currencyCodeSchema.optional(),
156
+ // Order-only columns — SalesQuote declares none of them. Declared here
157
+ // because the create schema declares them and a caller reusing its create
158
+ // payload on an update otherwise lost them silently; `applyDocumentUpdate`
159
+ // rejects each with a 400 on a quote rather than dropping it.
160
+ exchangeRate: z.union([z.null(), exchangeRateSchema]).optional(),
161
+ paymentStatusEntryId: z.string().uuid().nullable().optional(),
162
+ fulfillmentStatusEntryId: z.string().uuid().nullable().optional(),
155
163
  channelId: z.string().uuid().nullable().optional(),
156
164
  statusEntryId: z.string().uuid().nullable().optional(),
157
165
  placedAt: z.union([dateOnlySchema, z.null()]).optional(),
@@ -170,7 +178,7 @@ const documentUpdateSchema = z.object({
170
178
  customFields: z.record(z.string(), z.unknown()).optional(),
171
179
  customFieldSetId: z.string().uuid().nullable().optional()
172
180
  }).refine(
173
- (input) => typeof input.currencyCode === "string" || input.placedAt !== void 0 || input.expectedDeliveryAt !== void 0 || input.channelId !== void 0 || input.statusEntryId !== void 0 || input.shippingAddressId !== void 0 || input.billingAddressId !== void 0 || input.customerEntityId !== void 0 || input.customerContactId !== void 0 || input.customerSnapshot !== void 0 || input.metadata !== void 0 || input.customerReference !== void 0 || input.externalReference !== void 0 || input.comment !== void 0 || input.comments !== void 0 || input.internalNotes !== void 0 || input.orderNumber !== void 0 || input.quoteNumber !== void 0 || input.shippingAddressSnapshot !== void 0 || input.billingAddressSnapshot !== void 0 || input.shippingMethodId !== void 0 || input.shippingMethodCode !== void 0 || input.shippingMethodSnapshot !== void 0 || input.paymentMethodId !== void 0 || input.paymentMethodCode !== void 0 || input.paymentMethodSnapshot !== void 0 || input.tags !== void 0 || input.customFields !== void 0 || input.customFieldSetId !== void 0,
181
+ (input) => typeof input.currencyCode === "string" || input.placedAt !== void 0 || input.expectedDeliveryAt !== void 0 || input.channelId !== void 0 || input.statusEntryId !== void 0 || input.exchangeRate !== void 0 || input.paymentStatusEntryId !== void 0 || input.fulfillmentStatusEntryId !== void 0 || input.shippingAddressId !== void 0 || input.billingAddressId !== void 0 || input.customerEntityId !== void 0 || input.customerContactId !== void 0 || input.customerSnapshot !== void 0 || input.metadata !== void 0 || input.customerReference !== void 0 || input.externalReference !== void 0 || input.comment !== void 0 || input.comments !== void 0 || input.internalNotes !== void 0 || input.orderNumber !== void 0 || input.quoteNumber !== void 0 || input.shippingAddressSnapshot !== void 0 || input.billingAddressSnapshot !== void 0 || input.shippingMethodId !== void 0 || input.shippingMethodCode !== void 0 || input.shippingMethodSnapshot !== void 0 || input.paymentMethodId !== void 0 || input.paymentMethodCode !== void 0 || input.paymentMethodSnapshot !== void 0 || input.tags !== void 0 || input.customFields !== void 0 || input.customFieldSetId !== void 0,
174
182
  { message: "update_payload_empty" }
175
183
  );
176
184
  function cloneJson(value) {
@@ -542,6 +550,17 @@ async function applyDocumentUpdate({
542
550
  if (typeof input.currencyCode === "string") {
543
551
  entity.currencyCode = input.currencyCode;
544
552
  }
553
+ if (kind === "quote" && input.exchangeRate !== void 0) {
554
+ throw new CrudHttpError(400, {
555
+ error: translate(
556
+ "sales.quotes.exchange_rate_unsupported",
557
+ "Exchange rate is not available on quotes."
558
+ )
559
+ });
560
+ }
561
+ if (kind === "order" && input.exchangeRate !== void 0) {
562
+ entity.exchangeRate = toNumericString(input.exchangeRate);
563
+ }
545
564
  if (input.channelId !== void 0) {
546
565
  if (input.channelId === null) {
547
566
  entity.channelId = null;
@@ -586,6 +605,56 @@ async function applyDocumentUpdate({
586
605
  entity.statusEntryId = input.statusEntryId ?? null;
587
606
  entity.status = statusValue;
588
607
  }
608
+ if (kind === "quote" && input.paymentStatusEntryId !== void 0) {
609
+ throw new CrudHttpError(400, {
610
+ error: translate(
611
+ "sales.quotes.payment_status_unsupported",
612
+ "Payment status is not available on quotes."
613
+ )
614
+ });
615
+ }
616
+ if (kind === "order" && input.paymentStatusEntryId !== void 0) {
617
+ const paymentStatusValue = await resolveDictionaryEntryValue(
618
+ em,
619
+ input.paymentStatusEntryId,
620
+ { tenantId }
621
+ );
622
+ if (input.paymentStatusEntryId && !paymentStatusValue) {
623
+ throw new CrudHttpError(400, {
624
+ error: translate(
625
+ "sales.documents.detail.statusInvalid",
626
+ "Selected status could not be found."
627
+ )
628
+ });
629
+ }
630
+ entity.paymentStatusEntryId = input.paymentStatusEntryId ?? null;
631
+ entity.paymentStatus = paymentStatusValue;
632
+ }
633
+ if (kind === "quote" && input.fulfillmentStatusEntryId !== void 0) {
634
+ throw new CrudHttpError(400, {
635
+ error: translate(
636
+ "sales.quotes.fulfillment_status_unsupported",
637
+ "Fulfillment status is not available on quotes."
638
+ )
639
+ });
640
+ }
641
+ if (kind === "order" && input.fulfillmentStatusEntryId !== void 0) {
642
+ const fulfillmentStatusValue = await resolveDictionaryEntryValue(
643
+ em,
644
+ input.fulfillmentStatusEntryId,
645
+ { tenantId }
646
+ );
647
+ if (input.fulfillmentStatusEntryId && !fulfillmentStatusValue) {
648
+ throw new CrudHttpError(400, {
649
+ error: translate(
650
+ "sales.documents.detail.statusInvalid",
651
+ "Selected status could not be found."
652
+ )
653
+ });
654
+ }
655
+ entity.fulfillmentStatusEntryId = input.fulfillmentStatusEntryId ?? null;
656
+ entity.fulfillmentStatus = fulfillmentStatusValue;
657
+ }
589
658
  if (input.placedAt !== void 0) {
590
659
  if (input.placedAt === null) {
591
660
  entity.placedAt = null;
@@ -2464,6 +2533,15 @@ function buildDocumentUpdateChangeKeys(kind, input) {
2464
2533
  if (input.internalNotes !== void 0) keys.add("internalNotes");
2465
2534
  if (input.placedAt !== void 0) keys.add("placedAt");
2466
2535
  if (input.expectedDeliveryAt !== void 0) keys.add("expectedDeliveryAt");
2536
+ if (input.exchangeRate !== void 0) keys.add("exchangeRate");
2537
+ if (input.paymentStatusEntryId !== void 0) {
2538
+ keys.add("paymentStatusEntryId");
2539
+ keys.add("paymentStatus");
2540
+ }
2541
+ if (input.fulfillmentStatusEntryId !== void 0) {
2542
+ keys.add("fulfillmentStatusEntryId");
2543
+ keys.add("fulfillmentStatus");
2544
+ }
2467
2545
  }
2468
2546
  if (input.shippingAddressId !== void 0 || input.shippingAddressSnapshot !== void 0) {
2469
2547
  keys.add("shippingAddressId");