@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.
- package/.turbo/turbo-build.log +1 -1
- package/dist/modules/attachments/lib/reconcileOrganization.js +9 -7
- package/dist/modules/attachments/lib/reconcileOrganization.js.map +2 -2
- package/dist/modules/customers/api/companies/[id]/people/route.js +2 -2
- package/dist/modules/customers/api/companies/[id]/people/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/companies/route.js +2 -2
- package/dist/modules/customers/api/deals/[id]/companies/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/people/route.js +2 -2
- package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js +4 -4
- package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/entity-roles-factory.js +3 -3
- package/dist/modules/customers/api/entity-roles-factory.js.map +2 -2
- package/dist/modules/customers/api/labels/assign/route.js +2 -2
- package/dist/modules/customers/api/labels/assign/route.js.map +2 -2
- package/dist/modules/customers/api/labels/unassign/route.js +2 -2
- package/dist/modules/customers/api/labels/unassign/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js +3 -7
- package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/companies/context.js +3 -3
- package/dist/modules/customers/api/people/[id]/companies/context.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +2 -2
- package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +2 -2
- package/dist/modules/customers/api/todos/route.js +2 -2
- package/dist/modules/customers/api/todos/route.js.map +2 -2
- package/dist/modules/customers/commands/addresses.js +3 -3
- package/dist/modules/customers/commands/addresses.js.map +2 -2
- package/dist/modules/customers/commands/comments.js +3 -3
- package/dist/modules/customers/commands/comments.js.map +2 -2
- package/dist/modules/customers/commands/companies.js +2 -2
- package/dist/modules/customers/commands/companies.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +3 -3
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/commands/dictionaries.js +3 -3
- package/dist/modules/customers/commands/dictionaries.js.map +2 -2
- package/dist/modules/customers/commands/entity-roles.js +3 -3
- package/dist/modules/customers/commands/entity-roles.js.map +2 -2
- package/dist/modules/customers/commands/interactions.js +6 -6
- package/dist/modules/customers/commands/interactions.js.map +2 -2
- package/dist/modules/customers/commands/labels.js +7 -7
- package/dist/modules/customers/commands/labels.js.map +2 -2
- package/dist/modules/customers/commands/people.js +3 -3
- package/dist/modules/customers/commands/people.js.map +2 -2
- package/dist/modules/customers/commands/personCompanyLinks.js +6 -6
- package/dist/modules/customers/commands/personCompanyLinks.js.map +2 -2
- package/dist/modules/customers/commands/pipeline-stages.js +3 -3
- package/dist/modules/customers/commands/pipeline-stages.js.map +2 -2
- package/dist/modules/customers/commands/pipelines.js +3 -3
- package/dist/modules/customers/commands/pipelines.js.map +2 -2
- package/dist/modules/customers/commands/shared.js +3 -3
- package/dist/modules/customers/commands/shared.js.map +2 -2
- package/dist/modules/customers/commands/tags.js +7 -7
- package/dist/modules/customers/commands/tags.js.map +2 -2
- package/dist/modules/customers/commands/todos.js +3 -3
- package/dist/modules/customers/commands/todos.js.map +2 -2
- package/dist/modules/customers/lib/personCompanies.js +4 -4
- package/dist/modules/customers/lib/personCompanies.js.map +2 -2
- package/dist/modules/perspectives/data/validators.js +4 -0
- package/dist/modules/perspectives/data/validators.js.map +2 -2
- package/dist/modules/sales/api/notes/route.js +2 -4
- package/dist/modules/sales/api/notes/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/accept/route.js +2 -2
- package/dist/modules/sales/api/quotes/accept/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/public/[token]/route.js +3 -7
- package/dist/modules/sales/api/quotes/public/[token]/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/send/route.js +2 -2
- package/dist/modules/sales/api/quotes/send/route.js.map +2 -2
- package/dist/modules/sales/api/returns/[id]/route.js +2 -2
- package/dist/modules/sales/api/returns/[id]/route.js.map +2 -2
- package/dist/modules/sales/commands/configuration.js +11 -11
- package/dist/modules/sales/commands/configuration.js.map +2 -2
- package/dist/modules/sales/commands/documentAddresses.js +3 -3
- package/dist/modules/sales/commands/documentAddresses.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +31 -39
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/commands/notes.js +7 -7
- package/dist/modules/sales/commands/notes.js.map +2 -2
- package/dist/modules/sales/commands/payments.js +2 -2
- package/dist/modules/sales/commands/payments.js.map +2 -2
- package/dist/modules/sales/commands/returns.js +8 -8
- package/dist/modules/sales/commands/returns.js.map +2 -2
- package/dist/modules/sales/commands/shared.js +2 -2
- package/dist/modules/sales/commands/shared.js.map +2 -2
- package/dist/modules/sales/commands/shipments.js +5 -5
- package/dist/modules/sales/commands/shipments.js.map +2 -2
- package/dist/modules/sales/commands/statuses.js +2 -2
- package/dist/modules/sales/commands/statuses.js.map +2 -2
- package/dist/modules/sales/commands/tags.js +3 -3
- package/dist/modules/sales/commands/tags.js.map +2 -2
- package/dist/modules/sales/lib/calculations.js +6 -0
- package/dist/modules/sales/lib/calculations.js.map +2 -2
- package/package.json +7 -7
- package/src/modules/attachments/lib/reconcileOrganization.ts +16 -7
- package/src/modules/customer_accounts/i18n/de.json +12 -0
- package/src/modules/customer_accounts/i18n/en.json +12 -0
- package/src/modules/customer_accounts/i18n/es.json +34 -22
- package/src/modules/customer_accounts/i18n/pl.json +32 -20
- package/src/modules/customers/api/companies/[id]/people/route.ts +2 -2
- package/src/modules/customers/api/deals/[id]/companies/route.ts +2 -2
- package/src/modules/customers/api/deals/[id]/people/route.ts +2 -2
- package/src/modules/customers/api/dictionaries/[kind]/[id]/route.ts +4 -4
- package/src/modules/customers/api/entity-roles-factory.ts +3 -3
- package/src/modules/customers/api/labels/assign/route.ts +2 -2
- package/src/modules/customers/api/labels/unassign/route.ts +2 -2
- package/src/modules/customers/api/people/[id]/companies/[linkId]/route.ts +3 -7
- package/src/modules/customers/api/people/[id]/companies/context.ts +3 -3
- package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +2 -2
- package/src/modules/customers/api/todos/route.ts +2 -2
- package/src/modules/customers/commands/addresses.ts +3 -3
- package/src/modules/customers/commands/comments.ts +3 -3
- package/src/modules/customers/commands/companies.ts +2 -2
- package/src/modules/customers/commands/deals.ts +3 -3
- package/src/modules/customers/commands/dictionaries.ts +3 -3
- package/src/modules/customers/commands/entity-roles.ts +3 -3
- package/src/modules/customers/commands/interactions.ts +6 -6
- package/src/modules/customers/commands/labels.ts +7 -7
- package/src/modules/customers/commands/people.ts +3 -3
- package/src/modules/customers/commands/personCompanyLinks.ts +6 -6
- package/src/modules/customers/commands/pipeline-stages.ts +3 -3
- package/src/modules/customers/commands/pipelines.ts +3 -3
- package/src/modules/customers/commands/shared.ts +3 -3
- package/src/modules/customers/commands/tags.ts +7 -7
- package/src/modules/customers/commands/todos.ts +3 -3
- package/src/modules/customers/lib/personCompanies.ts +4 -4
- package/src/modules/perspectives/data/validators.ts +4 -0
- package/src/modules/sales/api/notes/route.ts +2 -4
- package/src/modules/sales/api/quotes/accept/route.ts +2 -2
- package/src/modules/sales/api/quotes/public/[token]/route.ts +3 -7
- package/src/modules/sales/api/quotes/send/route.ts +2 -2
- package/src/modules/sales/api/returns/[id]/route.ts +2 -2
- package/src/modules/sales/commands/configuration.ts +11 -11
- package/src/modules/sales/commands/documentAddresses.ts +3 -3
- package/src/modules/sales/commands/documents.ts +23 -31
- package/src/modules/sales/commands/notes.ts +7 -7
- package/src/modules/sales/commands/payments.ts +2 -2
- package/src/modules/sales/commands/returns.ts +8 -8
- package/src/modules/sales/commands/shared.ts +2 -2
- package/src/modules/sales/commands/shipments.ts +5 -5
- package/src/modules/sales/commands/statuses.ts +2 -2
- package/src/modules/sales/commands/tags.ts +3 -3
- 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
|
|
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
|
|
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
|
|
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
|
}
|