@open-mercato/core 0.9.1-develop.7477.1.64ba865101 → 0.9.1-develop.7496.1.3346415f94

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 (81) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/business_rules/data/validators.js +8 -3
  3. package/dist/modules/business_rules/data/validators.js.map +2 -2
  4. package/dist/modules/catalog/api/dictionaries/[key]/route.js +35 -7
  5. package/dist/modules/catalog/api/dictionaries/[key]/route.js.map +2 -2
  6. package/dist/modules/communication_channels/lib/email-mime.js +1 -2
  7. package/dist/modules/communication_channels/lib/email-mime.js.map +2 -2
  8. package/dist/modules/configs/cli.js +8 -2
  9. package/dist/modules/configs/cli.js.map +2 -2
  10. package/dist/modules/customers/api/companies/[id]/people/route.js +3 -0
  11. package/dist/modules/customers/api/companies/[id]/people/route.js.map +2 -2
  12. package/dist/modules/customers/api/companies/route.js +3 -3
  13. package/dist/modules/customers/api/companies/route.js.map +2 -2
  14. package/dist/modules/customers/api/deals/[id]/companies/route.js +3 -0
  15. package/dist/modules/customers/api/deals/[id]/companies/route.js.map +2 -2
  16. package/dist/modules/customers/api/deals/[id]/people/route.js +3 -0
  17. package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
  18. package/dist/modules/customers/api/dictionaries/kind-settings/route.js +6 -0
  19. package/dist/modules/customers/api/dictionaries/kind-settings/route.js.map +2 -2
  20. package/dist/modules/customers/api/labels/route.js +10 -1
  21. package/dist/modules/customers/api/labels/route.js.map +2 -2
  22. package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js +6 -0
  23. package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js.map +2 -2
  24. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +3 -0
  25. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +2 -2
  26. package/dist/modules/customers/api/people/[id]/companies/route.js +6 -0
  27. package/dist/modules/customers/api/people/[id]/companies/route.js.map +2 -2
  28. package/dist/modules/customers/api/people/route.js +3 -3
  29. package/dist/modules/customers/api/people/route.js.map +2 -2
  30. package/dist/modules/customers/commands/deals.js +2 -0
  31. package/dist/modules/customers/commands/deals.js.map +2 -2
  32. package/dist/modules/customers/components/detail/InlineEditors.js +7 -3
  33. package/dist/modules/customers/components/detail/InlineEditors.js.map +2 -2
  34. package/dist/modules/customers/components/detail/PersonHighlights.js +1 -1
  35. package/dist/modules/customers/components/detail/PersonHighlights.js.map +2 -2
  36. package/dist/modules/customers/components/detail/PlannedActivitiesSection.js +4 -5
  37. package/dist/modules/customers/components/detail/PlannedActivitiesSection.js.map +2 -2
  38. package/dist/modules/data_sync/di.js.map +2 -2
  39. package/dist/modules/data_sync/lib/sync-schedule-service.js +60 -27
  40. package/dist/modules/data_sync/lib/sync-schedule-service.js.map +2 -2
  41. package/dist/modules/messages/commands/messages.js +10 -7
  42. package/dist/modules/messages/commands/messages.js.map +2 -2
  43. package/dist/modules/messages/lib/constants.js +3 -1
  44. package/dist/modules/messages/lib/constants.js.map +2 -2
  45. package/dist/modules/messages/subscribers/message-notification.js +2 -1
  46. package/dist/modules/messages/subscribers/message-notification.js.map +2 -2
  47. package/dist/modules/sales/api/documents/factory.js +3 -4
  48. package/dist/modules/sales/api/documents/factory.js.map +2 -2
  49. package/dist/modules/sales/commands/payments.js +9 -1
  50. package/dist/modules/sales/commands/payments.js.map +2 -2
  51. package/package.json +7 -7
  52. package/src/modules/business_rules/data/validators.ts +12 -3
  53. package/src/modules/catalog/api/dictionaries/[key]/route.ts +49 -7
  54. package/src/modules/communication_channels/lib/email-mime.ts +1 -2
  55. package/src/modules/configs/cli.ts +10 -1
  56. package/src/modules/customers/api/companies/[id]/people/route.ts +3 -0
  57. package/src/modules/customers/api/companies/route.ts +6 -6
  58. package/src/modules/customers/api/deals/[id]/companies/route.ts +3 -0
  59. package/src/modules/customers/api/deals/[id]/people/route.ts +3 -0
  60. package/src/modules/customers/api/dictionaries/kind-settings/route.ts +6 -0
  61. package/src/modules/customers/api/labels/route.ts +10 -1
  62. package/src/modules/customers/api/people/[id]/companies/[linkId]/route.ts +6 -0
  63. package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +3 -0
  64. package/src/modules/customers/api/people/[id]/companies/route.ts +6 -0
  65. package/src/modules/customers/api/people/route.ts +6 -6
  66. package/src/modules/customers/commands/deals.ts +2 -0
  67. package/src/modules/customers/components/detail/InlineEditors.tsx +8 -4
  68. package/src/modules/customers/components/detail/PersonHighlights.tsx +4 -1
  69. package/src/modules/customers/components/detail/PlannedActivitiesSection.tsx +4 -5
  70. package/src/modules/customers/i18n/de.json +2 -0
  71. package/src/modules/customers/i18n/en.json +2 -0
  72. package/src/modules/customers/i18n/es.json +2 -0
  73. package/src/modules/customers/i18n/ko.json +2 -0
  74. package/src/modules/customers/i18n/pl.json +2 -0
  75. package/src/modules/data_sync/di.ts +1 -0
  76. package/src/modules/data_sync/lib/sync-schedule-service.ts +80 -28
  77. package/src/modules/messages/commands/messages.ts +10 -7
  78. package/src/modules/messages/lib/constants.ts +6 -0
  79. package/src/modules/messages/subscribers/message-notification.ts +2 -0
  80. package/src/modules/sales/api/documents/factory.ts +6 -7
  81. package/src/modules/sales/commands/payments.ts +10 -2
@@ -24,7 +24,7 @@ import { parseScopedCommandInput, resolveCrudRecordId } from '../utils'
24
24
  import { documentUpdateSchema } from '../../commands/documents'
25
25
  import { buildIlikeTerm } from '@open-mercato/shared/lib/db/buildIlikeTerm'
26
26
  import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'
27
- import { parseIdsParam } from '@open-mercato/shared/lib/crud/ids'
27
+ import { isUuidListParam, parseIdsParam, splitIdListParam } from '@open-mercato/shared/lib/crud/ids'
28
28
  import type { RbacService } from '@open-mercato/core/modules/auth/services/rbacService'
29
29
  import { parseDecryptedFieldValue } from '@open-mercato/shared/lib/encryption/tenantDataEncryptionService'
30
30
 
@@ -111,7 +111,10 @@ const listSchema = z
111
111
  totalGrossMax: z.coerce.number().optional(),
112
112
  dateFrom: z.string().optional(),
113
113
  dateTo: z.string().optional(),
114
- tagIds: z.string().optional(),
114
+ tagIds: z
115
+ .string()
116
+ .optional()
117
+ .refine(isUuidListParam, { message: 'tagIds must be a comma-separated list of UUIDs' }),
115
118
  tagIdsEmpty: z.string().optional(),
116
119
  sortField: z.string().optional(),
117
120
  sortDir: z.enum(['asc', 'desc']).optional(),
@@ -180,11 +183,7 @@ function buildFilters(query: ListQuery, numberColumn: string, kind: DocumentKind
180
183
  if (Object.keys(dateRange).length) {
181
184
  filters.created_at = dateRange
182
185
  }
183
- const tagIdsRaw = typeof query.tagIds === 'string' ? query.tagIds : ''
184
- const tagIds = tagIdsRaw
185
- .split(',')
186
- .map((value) => value.trim())
187
- .filter((value) => value.length > 0)
186
+ const tagIds = splitIdListParam(query.tagIds)
188
187
  if (parseBooleanToken(query.tagIdsEmpty) === true) {
189
188
  filters.id = { $eq: '00000000-0000-0000-0000-000000000000' }
190
189
  } else if (tagIds.length) {
@@ -250,7 +250,14 @@ export async function restorePaymentSnapshot(em: EntityManager, snapshot: Paymen
250
250
  em.persist(entity)
251
251
  }
252
252
 
253
- async function recomputeOrderPaymentTotals(
253
+ const NON_SETTLING_PAYMENT_STATUSES = new Set(['failed', 'canceled', 'cancelled'])
254
+
255
+ export function paymentCountsTowardOrderBalance(payment: Pick<SalesPayment, 'status'>): boolean {
256
+ const status = typeof payment.status === 'string' ? payment.status.trim().toLowerCase() : ''
257
+ return !NON_SETTLING_PAYMENT_STATUSES.has(status)
258
+ }
259
+
260
+ export async function recomputeOrderPaymentTotals(
254
261
  em: EntityManager,
255
262
  order: SalesOrder,
256
263
  options?: { lock?: boolean }
@@ -282,10 +289,11 @@ async function recomputeOrderPaymentTotals(
282
289
  if (paymentId) paymentIds.add(paymentId)
283
290
  })
284
291
 
285
- const payments =
292
+ const loadedPayments =
286
293
  paymentIds.size > 0
287
294
  ? await findWithDecryption(em, SalesPayment, { id: { $in: Array.from(paymentIds) }, deletedAt: null, ...scope }, {}, scope)
288
295
  : await findWithDecryption(em, SalesPayment, { order: orderId, deletedAt: null, ...scope }, {}, scope)
296
+ const payments = loadedPayments.filter(paymentCountsTowardOrderBalance)
289
297
 
290
298
  const resolvePaidAmount = (payment: SalesPayment) => {
291
299
  const captured = toNumber(payment.capturedAmount)