@open-mercato/core 0.6.7-develop.6552.1.5208a19369 → 0.6.7-develop.6565.1.1026d85fff

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 (141) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/attachments/lib/reconcileOrganization.js +9 -7
  3. package/dist/modules/attachments/lib/reconcileOrganization.js.map +2 -2
  4. package/dist/modules/customers/api/companies/[id]/people/route.js +2 -2
  5. package/dist/modules/customers/api/companies/[id]/people/route.js.map +2 -2
  6. package/dist/modules/customers/api/deals/[id]/companies/route.js +2 -2
  7. package/dist/modules/customers/api/deals/[id]/companies/route.js.map +2 -2
  8. package/dist/modules/customers/api/deals/[id]/people/route.js +2 -2
  9. package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
  10. package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js +4 -4
  11. package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js.map +2 -2
  12. package/dist/modules/customers/api/entity-roles-factory.js +3 -3
  13. package/dist/modules/customers/api/entity-roles-factory.js.map +2 -2
  14. package/dist/modules/customers/api/labels/assign/route.js +2 -2
  15. package/dist/modules/customers/api/labels/assign/route.js.map +2 -2
  16. package/dist/modules/customers/api/labels/unassign/route.js +2 -2
  17. package/dist/modules/customers/api/labels/unassign/route.js.map +2 -2
  18. package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js +3 -7
  19. package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js.map +2 -2
  20. package/dist/modules/customers/api/people/[id]/companies/context.js +3 -3
  21. package/dist/modules/customers/api/people/[id]/companies/context.js.map +2 -2
  22. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +2 -2
  23. package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +2 -2
  24. package/dist/modules/customers/api/todos/route.js +2 -2
  25. package/dist/modules/customers/api/todos/route.js.map +2 -2
  26. package/dist/modules/customers/commands/addresses.js +3 -3
  27. package/dist/modules/customers/commands/addresses.js.map +2 -2
  28. package/dist/modules/customers/commands/comments.js +3 -3
  29. package/dist/modules/customers/commands/comments.js.map +2 -2
  30. package/dist/modules/customers/commands/companies.js +2 -2
  31. package/dist/modules/customers/commands/companies.js.map +2 -2
  32. package/dist/modules/customers/commands/deals.js +3 -3
  33. package/dist/modules/customers/commands/deals.js.map +2 -2
  34. package/dist/modules/customers/commands/dictionaries.js +3 -3
  35. package/dist/modules/customers/commands/dictionaries.js.map +2 -2
  36. package/dist/modules/customers/commands/entity-roles.js +3 -3
  37. package/dist/modules/customers/commands/entity-roles.js.map +2 -2
  38. package/dist/modules/customers/commands/interactions.js +6 -6
  39. package/dist/modules/customers/commands/interactions.js.map +2 -2
  40. package/dist/modules/customers/commands/labels.js +7 -7
  41. package/dist/modules/customers/commands/labels.js.map +2 -2
  42. package/dist/modules/customers/commands/people.js +3 -3
  43. package/dist/modules/customers/commands/people.js.map +2 -2
  44. package/dist/modules/customers/commands/personCompanyLinks.js +6 -6
  45. package/dist/modules/customers/commands/personCompanyLinks.js.map +2 -2
  46. package/dist/modules/customers/commands/pipeline-stages.js +3 -3
  47. package/dist/modules/customers/commands/pipeline-stages.js.map +2 -2
  48. package/dist/modules/customers/commands/pipelines.js +3 -3
  49. package/dist/modules/customers/commands/pipelines.js.map +2 -2
  50. package/dist/modules/customers/commands/shared.js +3 -3
  51. package/dist/modules/customers/commands/shared.js.map +2 -2
  52. package/dist/modules/customers/commands/tags.js +7 -7
  53. package/dist/modules/customers/commands/tags.js.map +2 -2
  54. package/dist/modules/customers/commands/todos.js +3 -3
  55. package/dist/modules/customers/commands/todos.js.map +2 -2
  56. package/dist/modules/customers/lib/personCompanies.js +4 -4
  57. package/dist/modules/customers/lib/personCompanies.js.map +2 -2
  58. package/dist/modules/perspectives/data/validators.js +4 -0
  59. package/dist/modules/perspectives/data/validators.js.map +2 -2
  60. package/dist/modules/sales/api/notes/route.js +2 -4
  61. package/dist/modules/sales/api/notes/route.js.map +2 -2
  62. package/dist/modules/sales/api/quotes/accept/route.js +2 -2
  63. package/dist/modules/sales/api/quotes/accept/route.js.map +2 -2
  64. package/dist/modules/sales/api/quotes/public/[token]/route.js +3 -7
  65. package/dist/modules/sales/api/quotes/public/[token]/route.js.map +2 -2
  66. package/dist/modules/sales/api/quotes/send/route.js +2 -2
  67. package/dist/modules/sales/api/quotes/send/route.js.map +2 -2
  68. package/dist/modules/sales/api/returns/[id]/route.js +2 -2
  69. package/dist/modules/sales/api/returns/[id]/route.js.map +2 -2
  70. package/dist/modules/sales/commands/configuration.js +11 -11
  71. package/dist/modules/sales/commands/configuration.js.map +2 -2
  72. package/dist/modules/sales/commands/documentAddresses.js +3 -3
  73. package/dist/modules/sales/commands/documentAddresses.js.map +2 -2
  74. package/dist/modules/sales/commands/documents.js +31 -39
  75. package/dist/modules/sales/commands/documents.js.map +2 -2
  76. package/dist/modules/sales/commands/notes.js +7 -7
  77. package/dist/modules/sales/commands/notes.js.map +2 -2
  78. package/dist/modules/sales/commands/payments.js +2 -2
  79. package/dist/modules/sales/commands/payments.js.map +2 -2
  80. package/dist/modules/sales/commands/returns.js +8 -8
  81. package/dist/modules/sales/commands/returns.js.map +2 -2
  82. package/dist/modules/sales/commands/shared.js +2 -2
  83. package/dist/modules/sales/commands/shared.js.map +2 -2
  84. package/dist/modules/sales/commands/shipments.js +5 -5
  85. package/dist/modules/sales/commands/shipments.js.map +2 -2
  86. package/dist/modules/sales/commands/statuses.js +2 -2
  87. package/dist/modules/sales/commands/statuses.js.map +2 -2
  88. package/dist/modules/sales/commands/tags.js +3 -3
  89. package/dist/modules/sales/commands/tags.js.map +2 -2
  90. package/dist/modules/sales/lib/calculations.js +6 -0
  91. package/dist/modules/sales/lib/calculations.js.map +2 -2
  92. package/package.json +7 -7
  93. package/src/modules/attachments/lib/reconcileOrganization.ts +16 -7
  94. package/src/modules/customer_accounts/i18n/de.json +12 -0
  95. package/src/modules/customer_accounts/i18n/en.json +12 -0
  96. package/src/modules/customer_accounts/i18n/es.json +34 -22
  97. package/src/modules/customer_accounts/i18n/pl.json +32 -20
  98. package/src/modules/customers/api/companies/[id]/people/route.ts +2 -2
  99. package/src/modules/customers/api/deals/[id]/companies/route.ts +2 -2
  100. package/src/modules/customers/api/deals/[id]/people/route.ts +2 -2
  101. package/src/modules/customers/api/dictionaries/[kind]/[id]/route.ts +4 -4
  102. package/src/modules/customers/api/entity-roles-factory.ts +3 -3
  103. package/src/modules/customers/api/labels/assign/route.ts +2 -2
  104. package/src/modules/customers/api/labels/unassign/route.ts +2 -2
  105. package/src/modules/customers/api/people/[id]/companies/[linkId]/route.ts +3 -7
  106. package/src/modules/customers/api/people/[id]/companies/context.ts +3 -3
  107. package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +2 -2
  108. package/src/modules/customers/api/todos/route.ts +2 -2
  109. package/src/modules/customers/commands/addresses.ts +3 -3
  110. package/src/modules/customers/commands/comments.ts +3 -3
  111. package/src/modules/customers/commands/companies.ts +2 -2
  112. package/src/modules/customers/commands/deals.ts +3 -3
  113. package/src/modules/customers/commands/dictionaries.ts +3 -3
  114. package/src/modules/customers/commands/entity-roles.ts +3 -3
  115. package/src/modules/customers/commands/interactions.ts +6 -6
  116. package/src/modules/customers/commands/labels.ts +7 -7
  117. package/src/modules/customers/commands/people.ts +3 -3
  118. package/src/modules/customers/commands/personCompanyLinks.ts +6 -6
  119. package/src/modules/customers/commands/pipeline-stages.ts +3 -3
  120. package/src/modules/customers/commands/pipelines.ts +3 -3
  121. package/src/modules/customers/commands/shared.ts +3 -3
  122. package/src/modules/customers/commands/tags.ts +7 -7
  123. package/src/modules/customers/commands/todos.ts +3 -3
  124. package/src/modules/customers/lib/personCompanies.ts +4 -4
  125. package/src/modules/perspectives/data/validators.ts +4 -0
  126. package/src/modules/sales/api/notes/route.ts +2 -4
  127. package/src/modules/sales/api/quotes/accept/route.ts +2 -2
  128. package/src/modules/sales/api/quotes/public/[token]/route.ts +3 -7
  129. package/src/modules/sales/api/quotes/send/route.ts +2 -2
  130. package/src/modules/sales/api/returns/[id]/route.ts +2 -2
  131. package/src/modules/sales/commands/configuration.ts +11 -11
  132. package/src/modules/sales/commands/documentAddresses.ts +3 -3
  133. package/src/modules/sales/commands/documents.ts +23 -31
  134. package/src/modules/sales/commands/notes.ts +7 -7
  135. package/src/modules/sales/commands/payments.ts +2 -2
  136. package/src/modules/sales/commands/returns.ts +8 -8
  137. package/src/modules/sales/commands/shared.ts +2 -2
  138. package/src/modules/sales/commands/shipments.ts +5 -5
  139. package/src/modules/sales/commands/statuses.ts +2 -2
  140. package/src/modules/sales/commands/tags.ts +3 -3
  141. package/src/modules/sales/lib/calculations.ts +15 -0
@@ -1,6 +1,6 @@
1
1
  import { DictionaryEntry } from '@open-mercato/core/modules/dictionaries/data/entities'
2
2
  import { registerDictionaryEntryCommands } from '@open-mercato/core/modules/dictionaries/commands/factory'
3
- import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
3
+ import { CrudHttpError, notFound } from '@open-mercato/shared/lib/crud/errors'
4
4
  import {
5
5
  ensureSalesDictionary,
6
6
  getSalesDictionaryDefinition,
@@ -70,7 +70,7 @@ function registerStatusDictionaryCommands(kind: SalesDictionaryKind): void {
70
70
  resolveEntry: async ({ em, ctx, id }) => {
71
71
  const entry = await findOneWithDecryption(em, DictionaryEntry, id, { populate: ['dictionary'] })
72
72
  if (!entry) {
73
- throw new CrudHttpError(404, { error: 'Dictionary entry not found' })
73
+ throw notFound('Dictionary entry not found')
74
74
  }
75
75
  if (entry.dictionary.key !== definition.key) {
76
76
  throw new CrudHttpError(400, { error: 'Entry does not belong to this dictionary.' })
@@ -3,7 +3,7 @@
3
3
  import { registerCommand } from '@open-mercato/shared/lib/commands'
4
4
  import type { CommandHandler } from '@open-mercato/shared/lib/commands'
5
5
  import type { EntityManager } from '@mikro-orm/postgresql'
6
- import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
6
+ import { CrudHttpError, notFound } from '@open-mercato/shared/lib/crud/errors'
7
7
  import { SalesDocumentTag, SalesDocumentTagAssignment } from '../data/entities'
8
8
  import { ensureTenantScope } from './shared'
9
9
  import {
@@ -44,7 +44,7 @@ const updateTagCommand: CommandHandler<SalesTagUpdateInput, { tagId: string }> =
44
44
  const parsed = salesTagUpdateSchema.parse(rawInput ?? {})
45
45
  const em = (ctx.container.resolve('em') as EntityManager).fork()
46
46
  const tag = await em.findOne(SalesDocumentTag, { id: parsed.id })
47
- if (!tag) throw new CrudHttpError(404, { error: 'Tag not found' })
47
+ if (!tag) throw notFound('Tag not found')
48
48
  ensureTenantScope(ctx, parsed.tenantId ?? tag.tenantId)
49
49
  if (parsed.slug && parsed.slug !== tag.slug) {
50
50
  const conflict = await em.findOne(SalesDocumentTag, {
@@ -74,7 +74,7 @@ const deleteTagCommand: CommandHandler<{ id?: string }, { tagId: string }> = {
74
74
  if (!id) throw new CrudHttpError(400, { error: 'Tag id is required' })
75
75
  const em = (ctx.container.resolve('em') as EntityManager).fork()
76
76
  const tag = await em.findOne(SalesDocumentTag, { id })
77
- if (!tag) throw new CrudHttpError(404, { error: 'Tag not found' })
77
+ if (!tag) throw notFound('Tag not found')
78
78
  ensureTenantScope(ctx, tag.tenantId)
79
79
  await em.nativeDelete(SalesDocumentTagAssignment, { tag: tag.id })
80
80
  em.remove(tag)
@@ -208,6 +208,21 @@ function buildBaseDocumentResult(params: {
208
208
  }
209
209
  break
210
210
  default:
211
+ // `return` (credit) adjustments are handled by the dedicated loop below;
212
+ // skip them here so an order-scoped return is not counted twice.
213
+ if (adj.kind === 'return') break
214
+ // Custom / operator-defined kinds carry an operator-controlled sign
215
+ // (positive adds, negative credits). Fold the raw signed amount into the
216
+ // grand total so a persisted adjustment can never be silently dropped
217
+ // from the headline total while still appearing in the itemized
218
+ // breakdown (#4052). No abs()/clamp here: unlike the sign-constrained
219
+ // kinds above, custom kinds are intentionally unconstrained
220
+ // (see enforceAdjustmentSign).
221
+ subtotalNet += net
222
+ subtotalGross += gross
223
+ if (taxPortion) {
224
+ taxTotal += taxPortion
225
+ }
211
226
  break
212
227
  }
213
228
  }