@open-mercato/core 0.7.1-develop.7153.1.7145d295e6 → 0.7.1-develop.7170.1.d95074d7ba

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 (116) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/AGENTS.md +2 -2
  3. package/dist/modules/auth/commands/users.js +14 -1
  4. package/dist/modules/auth/commands/users.js.map +2 -2
  5. package/dist/modules/auth/data/entities.js +2 -2
  6. package/dist/modules/auth/data/entities.js.map +2 -2
  7. package/dist/modules/auth/lib/backendChrome.js +26 -3
  8. package/dist/modules/auth/lib/backendChrome.js.map +2 -2
  9. package/dist/modules/auth/lib/profile-sections.js +1 -1
  10. package/dist/modules/auth/lib/profile-sections.js.map +2 -2
  11. package/dist/modules/auth/migrations/Migration20260907120000_auth.js +19 -0
  12. package/dist/modules/auth/migrations/Migration20260907120000_auth.js.map +7 -0
  13. package/dist/modules/communication_channels/backend/profile/communication-channels/page.meta.js +2 -2
  14. package/dist/modules/communication_channels/backend/profile/communication-channels/page.meta.js.map +1 -1
  15. package/dist/modules/customer_accounts/api/admin/demo-accounts.js +118 -0
  16. package/dist/modules/customer_accounts/api/admin/demo-accounts.js.map +7 -0
  17. package/dist/modules/customer_accounts/api/invitations/accept.js +23 -6
  18. package/dist/modules/customer_accounts/api/invitations/accept.js.map +2 -2
  19. package/dist/modules/customer_accounts/backend/customer_accounts/settings/CustomerAccountsSettingsPageClient.js +10 -13
  20. package/dist/modules/customer_accounts/backend/customer_accounts/settings/CustomerAccountsSettingsPageClient.js.map +2 -2
  21. package/dist/modules/customer_accounts/backend/customer_accounts/useDemoPortalAccounts.js +28 -0
  22. package/dist/modules/customer_accounts/backend/customer_accounts/useDemoPortalAccounts.js.map +7 -0
  23. package/dist/modules/customer_accounts/backend/customer_accounts/users/PortalUsersPageClient.js +6 -1
  24. package/dist/modules/customer_accounts/backend/customer_accounts/users/PortalUsersPageClient.js.map +2 -2
  25. package/dist/modules/customer_accounts/data/entities.js +4 -1
  26. package/dist/modules/customer_accounts/data/entities.js.map +2 -2
  27. package/dist/modules/customer_accounts/lib/exampleAccounts.js +9 -0
  28. package/dist/modules/customer_accounts/lib/exampleAccounts.js.map +7 -0
  29. package/dist/modules/customer_accounts/migrations/Migration20260827160000_customer_accounts.js +16 -0
  30. package/dist/modules/customer_accounts/migrations/Migration20260827160000_customer_accounts.js.map +7 -0
  31. package/dist/modules/customer_accounts/services/customerInvitationService.js +53 -6
  32. package/dist/modules/customer_accounts/services/customerInvitationService.js.map +2 -2
  33. package/dist/modules/customer_accounts/setup.js +2 -6
  34. package/dist/modules/customer_accounts/setup.js.map +2 -2
  35. package/dist/modules/customer_accounts/widgets/injection/account-status/widget.client.js +55 -40
  36. package/dist/modules/customer_accounts/widgets/injection/account-status/widget.client.js.map +2 -2
  37. package/dist/modules/customers/commands/people.js +16 -1
  38. package/dist/modules/customers/commands/people.js.map +2 -2
  39. package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js +18 -36
  40. package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js.map +2 -2
  41. package/dist/modules/data_sync/lib/sync-schedule-service.js +25 -23
  42. package/dist/modules/data_sync/lib/sync-schedule-service.js.map +2 -2
  43. package/dist/modules/entities/api/records.js +18 -15
  44. package/dist/modules/entities/api/records.js.map +3 -3
  45. package/dist/modules/entities/lib/scoped-field-defs.js +52 -0
  46. package/dist/modules/entities/lib/scoped-field-defs.js.map +7 -0
  47. package/dist/modules/entities/lib/validation.js +4 -35
  48. package/dist/modules/entities/lib/validation.js.map +2 -2
  49. package/dist/modules/integrations/backend/integrations/[id]/page.js +32 -54
  50. package/dist/modules/integrations/backend/integrations/[id]/page.js.map +2 -2
  51. package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js +12 -29
  52. package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js.map +2 -2
  53. package/dist/modules/notifications/backend/profile/notification-preferences/page.meta.js +2 -2
  54. package/dist/modules/notifications/backend/profile/notification-preferences/page.meta.js.map +1 -1
  55. package/dist/modules/progress/lib/progressServiceImpl.js +14 -3
  56. package/dist/modules/progress/lib/progressServiceImpl.js.map +2 -2
  57. package/dist/modules/sales/backend/sales/documents/[id]/page.js +9 -9
  58. package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
  59. package/dist/modules/sales/components/documents/LineItemDialog.js +50 -10
  60. package/dist/modules/sales/components/documents/LineItemDialog.js.map +2 -2
  61. package/dist/modules/sales/components/documents/PaymentsSection.js +8 -3
  62. package/dist/modules/sales/components/documents/PaymentsSection.js.map +2 -2
  63. package/dist/modules/sales/components/documents/ReturnEditDialog.js +2 -7
  64. package/dist/modules/sales/components/documents/ReturnEditDialog.js.map +2 -2
  65. package/dist/modules/sales/components/documents/ReturnsSection.js +2 -7
  66. package/dist/modules/sales/components/documents/ReturnsSection.js.map +2 -2
  67. package/dist/modules/sales/components/documents/ShipmentsSection.js +3 -8
  68. package/dist/modules/sales/components/documents/ShipmentsSection.js.map +2 -2
  69. package/package.json +7 -7
  70. package/src/modules/auth/commands/users.ts +14 -1
  71. package/src/modules/auth/data/entities.ts +2 -2
  72. package/src/modules/auth/lib/backendChrome.tsx +46 -2
  73. package/src/modules/auth/lib/profile-sections.tsx +14 -3
  74. package/src/modules/auth/migrations/.snapshot-open-mercato.json +4 -2
  75. package/src/modules/auth/migrations/Migration20260907120000_auth.ts +21 -0
  76. package/src/modules/communication_channels/backend/profile/communication-channels/page.meta.ts +2 -2
  77. package/src/modules/customer_accounts/AGENTS.md +3 -1
  78. package/src/modules/customer_accounts/api/admin/demo-accounts.ts +149 -0
  79. package/src/modules/customer_accounts/api/invitations/accept.ts +23 -6
  80. package/src/modules/customer_accounts/backend/customer_accounts/settings/CustomerAccountsSettingsPageClient.tsx +43 -41
  81. package/src/modules/customer_accounts/backend/customer_accounts/useDemoPortalAccounts.ts +42 -0
  82. package/src/modules/customer_accounts/backend/customer_accounts/users/PortalUsersPageClient.tsx +10 -3
  83. package/src/modules/customer_accounts/data/entities.ts +5 -1
  84. package/src/modules/customer_accounts/i18n/de.json +4 -2
  85. package/src/modules/customer_accounts/i18n/en.json +4 -2
  86. package/src/modules/customer_accounts/i18n/es.json +4 -2
  87. package/src/modules/customer_accounts/i18n/ko.json +4 -2
  88. package/src/modules/customer_accounts/i18n/pl.json +4 -2
  89. package/src/modules/customer_accounts/lib/exampleAccounts.ts +18 -0
  90. package/src/modules/customer_accounts/migrations/.snapshot-open-mercato.json +5 -7
  91. package/src/modules/customer_accounts/migrations/Migration20260827160000_customer_accounts.ts +23 -0
  92. package/src/modules/customer_accounts/services/customerInvitationService.ts +89 -5
  93. package/src/modules/customer_accounts/setup.ts +2 -6
  94. package/src/modules/customer_accounts/widgets/injection/account-status/widget.client.tsx +74 -41
  95. package/src/modules/customers/commands/people.ts +15 -0
  96. package/src/modules/data_sync/backend/data-sync/runs/[id]/page.tsx +19 -44
  97. package/src/modules/data_sync/lib/sync-schedule-service.ts +32 -26
  98. package/src/modules/entities/api/records.ts +24 -15
  99. package/src/modules/entities/lib/scoped-field-defs.ts +76 -0
  100. package/src/modules/entities/lib/validation.ts +5 -45
  101. package/src/modules/integrations/backend/integrations/[id]/page.tsx +33 -62
  102. package/src/modules/integrations/backend/integrations/bundle/[id]/page.tsx +13 -37
  103. package/src/modules/notifications/backend/profile/notification-preferences/page.meta.ts +2 -2
  104. package/src/modules/progress/AGENTS.md +1 -1
  105. package/src/modules/progress/lib/progressServiceImpl.ts +26 -3
  106. package/src/modules/sales/backend/sales/documents/[id]/page.tsx +19 -25
  107. package/src/modules/sales/components/documents/LineItemDialog.tsx +53 -9
  108. package/src/modules/sales/components/documents/PaymentsSection.tsx +8 -8
  109. package/src/modules/sales/components/documents/ReturnEditDialog.tsx +2 -8
  110. package/src/modules/sales/components/documents/ReturnsSection.tsx +8 -7
  111. package/src/modules/sales/components/documents/ShipmentsSection.tsx +9 -8
  112. package/src/modules/sales/i18n/de.json +2 -0
  113. package/src/modules/sales/i18n/en.json +2 -0
  114. package/src/modules/sales/i18n/es.json +2 -0
  115. package/src/modules/sales/i18n/ko.json +2 -0
  116. package/src/modules/sales/i18n/pl.json +2 -0
@@ -50,6 +50,7 @@ import {
50
50
  extractCustomFieldValues
51
51
  } from "./customFieldHelpers.js";
52
52
  import { canonicalizeUnitCode } from "@open-mercato/shared/lib/units/unitCodes";
53
+ import { parseLocaleNumber } from "@open-mercato/shared/lib/number";
53
54
  import { createLogger } from "@open-mercato/shared/lib/logger";
54
55
  const logger = createLogger("sales");
55
56
  function mapTaxRateOption(item) {
@@ -213,6 +214,26 @@ function LineItemDialog({
213
214
  }) {
214
215
  const t = useT();
215
216
  const locale = useLocale();
217
+ const parseUserNumber = React.useCallback(
218
+ (value) => {
219
+ if (value == null) return 0;
220
+ if (typeof value === "number") return Number.isFinite(value) ? value : null;
221
+ if (typeof value !== "string") return null;
222
+ if (!value.trim()) return 0;
223
+ return parseLocaleNumber(value, locale);
224
+ },
225
+ [locale]
226
+ );
227
+ const numberExample = React.useMemo(() => {
228
+ try {
229
+ return new Intl.NumberFormat(locale, {
230
+ minimumFractionDigits: 2,
231
+ maximumFractionDigits: 2
232
+ }).format(110.7);
233
+ } catch {
234
+ return "110.70";
235
+ }
236
+ }, [locale]);
216
237
  const scope = useOrganizationScopeDetail();
217
238
  const resolvedOrganizationId = organizationId ?? scope.organizationId ?? null;
218
239
  const resolvedTenantId = tenantId ?? scope.tenantId ?? null;
@@ -537,7 +558,7 @@ function LineItemDialog({
537
558
  try {
538
559
  const params = new URLSearchParams({ productId, pageSize: "20" });
539
560
  if (variantId) params.set("variantId", variantId);
540
- const quantityValue = normalizeNumber(quantity, Number.NaN);
561
+ const quantityValue = parseUserNumber(quantity) ?? Number.NaN;
541
562
  if (Number.isFinite(quantityValue) && quantityValue > 0) {
542
563
  params.set("quantity", String(quantityValue));
543
564
  }
@@ -607,7 +628,7 @@ function LineItemDialog({
607
628
  setPriceLoading(false);
608
629
  }
609
630
  },
610
- [t]
631
+ [parseUserNumber, t]
611
632
  );
612
633
  const selectPriceAfterRefresh = React.useCallback(
613
634
  (prices, currentPriceId, currentPriceKindId) => {
@@ -639,7 +660,7 @@ function LineItemDialog({
639
660
  );
640
661
  const convertUnitPriceForUnitChange = React.useCallback(
641
662
  (rawUnitPrice, fromUnit, toUnit) => {
642
- const amount = normalizeNumber(rawUnitPrice, Number.NaN);
663
+ const amount = parseUserNumber(rawUnitPrice) ?? Number.NaN;
643
664
  if (!Number.isFinite(amount) || amount <= 0) return null;
644
665
  const fromCode = normalizeUnitCode(fromUnit);
645
666
  const toCode = normalizeUnitCode(toUnit);
@@ -654,7 +675,7 @@ function LineItemDialog({
654
675
  if (!Number.isFinite(convertedAmount) || convertedAmount <= 0) return null;
655
676
  return normalizeUnitPriceInputValue(convertedAmount);
656
677
  },
657
- [resolveUnitPriceFactor]
678
+ [parseUserNumber, resolveUnitPriceFactor]
658
679
  );
659
680
  const applyPriceSelection = React.useCallback(
660
681
  (selected, setFormValue, options) => {
@@ -782,8 +803,16 @@ function LineItemDialog({
782
803
  }
783
804
  );
784
805
  }
785
- const qtyNumber = Number(values.quantity ?? 0);
786
- if (!Number.isFinite(qtyNumber) || qtyNumber <= 0) {
806
+ const qtyNumber = parseUserNumber(values.quantity);
807
+ if (qtyNumber === null) {
808
+ const message = t(
809
+ "sales.documents.items.errorQuantityInvalid",
810
+ "Enter the quantity as a number, for example {{example}}.",
811
+ { example: numberExample }
812
+ );
813
+ throw createCrudFormError(message, { quantity: message });
814
+ }
815
+ if (qtyNumber <= 0) {
787
816
  throw createCrudFormError(
788
817
  t(
789
818
  "sales.documents.items.errorQuantity",
@@ -813,8 +842,16 @@ function LineItemDialog({
813
842
  if (isCustomLine) return entered;
814
843
  return entered ?? normalizeUnitCode(productOption?.defaultSalesUnit) ?? normalizeUnitCode(productOption?.defaultUnit);
815
844
  })();
816
- const unitPriceNumber = Number(values.unitPrice ?? 0);
817
- if (!Number.isFinite(unitPriceNumber) || unitPriceNumber <= 0) {
845
+ const unitPriceNumber = parseUserNumber(values.unitPrice);
846
+ if (unitPriceNumber === null) {
847
+ const message = t(
848
+ "sales.documents.items.errorUnitPriceInvalid",
849
+ "Enter the unit price as a number, for example {{example}}.",
850
+ { example: numberExample }
851
+ );
852
+ throw createCrudFormError(message, { unitPrice: message });
853
+ }
854
+ if (unitPriceNumber <= 0) {
818
855
  throw createCrudFormError(
819
856
  t(
820
857
  "sales.documents.items.errorUnitPrice",
@@ -976,6 +1013,8 @@ function LineItemDialog({
976
1013
  variantOption,
977
1014
  onSaved,
978
1015
  closeDialog,
1016
+ numberExample,
1017
+ parseUserNumber,
979
1018
  resolvedOrganizationId,
980
1019
  resolvedTenantId
981
1020
  ]
@@ -1715,7 +1754,7 @@ function LineItemDialog({
1715
1754
  layout: "full",
1716
1755
  component: ({ values }) => {
1717
1756
  if (isCustomLine) return null;
1718
- const quantity = normalizeNumber(values?.quantity, Number.NaN);
1757
+ const quantity = parseUserNumber(values?.quantity) ?? Number.NaN;
1719
1758
  const enteredUnit = normalizeUnitCode(values?.quantityUnit);
1720
1759
  if (!Number.isFinite(quantity) || quantity <= 0 || !enteredUnit) {
1721
1760
  return /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t(
@@ -1811,7 +1850,8 @@ function LineItemDialog({
1811
1850
  resolveTaxSelection,
1812
1851
  selectPriceAfterRefresh,
1813
1852
  hasTaxMetadata,
1814
- isShippedOrderLine
1853
+ isShippedOrderLine,
1854
+ parseUserNumber
1815
1855
  ]);
1816
1856
  const groups = React.useMemo(() => {
1817
1857
  return [