@open-mercato/core 0.7.1-develop.7113.1.9d83dca10c → 0.7.1-develop.7120.1.a0154ac412
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/helpers/integration/crmFixtures.js.map +1 -1
- package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js +9 -2
- package/dist/modules/communication_channels/api/post/channels/[id]/test-send/route.js.map +2 -2
- package/dist/modules/communication_channels/lib/outbound-recipient.js +5 -1
- package/dist/modules/communication_channels/lib/outbound-recipient.js.map +2 -2
- package/dist/modules/communication_channels/lib/test-seed.js +5 -0
- package/dist/modules/communication_channels/lib/test-seed.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.js +1 -1
- package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.js.map +1 -1
- package/dist/modules/customers/backend/customers/deals/page.js +4 -3
- package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/components/QuickDealDialog.js +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/components/QuickDealDialog.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/components/StatusFilterPopover.js +1 -1
- package/dist/modules/customers/backend/customers/deals/pipeline/components/StatusFilterPopover.js.map +1 -1
- package/dist/modules/customers/backend/customers/deals/pipeline/page.js +1 -1
- package/dist/modules/customers/backend/customers/deals/pipeline/page.js.map +2 -2
- package/dist/modules/customers/cli.js +5 -5
- package/dist/modules/customers/cli.js.map +2 -2
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/components/detail/pipelineStageUtils.js +1 -0
- package/dist/modules/customers/components/detail/pipelineStageUtils.js.map +2 -2
- package/dist/modules/customers/components/linking/adapters/dealAdapter.js +2 -2
- package/dist/modules/customers/components/linking/adapters/dealAdapter.js.map +2 -2
- package/dist/modules/customers/lib/closureStage.js.map +2 -2
- package/dist/modules/customers/lib/dealStatus.js +6 -4
- package/dist/modules/customers/lib/dealStatus.js.map +2 -2
- package/dist/modules/customers/lib/dealsSummaryQueries.js +3 -3
- package/dist/modules/customers/lib/dealsSummaryQueries.js.map +1 -1
- package/dist/modules/customers/migrations/Migration20260824180000_deal_status_lost.js +30 -0
- package/dist/modules/customers/migrations/Migration20260824180000_deal_status_lost.js.map +7 -0
- package/dist/modules/dashboards/widgets/dashboard/pipeline-summary/config.js.map +1 -1
- package/dist/modules/eudr/notifications.js +5 -0
- package/dist/modules/eudr/notifications.js.map +2 -2
- package/dist/modules/query_index/lib/search-tokens.js +59 -28
- package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +120 -37
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/warranty_claims/notifications.js +5 -0
- package/dist/modules/warranty_claims/notifications.js.map +2 -2
- package/dist/modules/wms/notifications.js +2 -0
- package/dist/modules/wms/notifications.js.map +2 -2
- package/package.json +7 -7
- package/src/helpers/integration/crmFixtures.ts +1 -1
- package/src/modules/communication_channels/api/post/channels/[id]/test-send/route.ts +21 -9
- package/src/modules/communication_channels/lib/adapter.ts +11 -0
- package/src/modules/communication_channels/lib/outbound-recipient.ts +14 -1
- package/src/modules/communication_channels/lib/test-seed.ts +19 -0
- package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealClosure.ts +1 -1
- package/src/modules/customers/backend/customers/deals/page.tsx +4 -3
- package/src/modules/customers/backend/customers/deals/pipeline/components/QuickDealDialog.tsx +5 -5
- package/src/modules/customers/backend/customers/deals/pipeline/components/StatusFilterPopover.tsx +3 -3
- package/src/modules/customers/backend/customers/deals/pipeline/page.tsx +2 -2
- package/src/modules/customers/cli.ts +5 -5
- package/src/modules/customers/commands/deals.ts +4 -3
- package/src/modules/customers/components/detail/pipelineStageUtils.ts +1 -0
- package/src/modules/customers/components/linking/adapters/dealAdapter.tsx +2 -2
- package/src/modules/customers/i18n/de.json +1 -1
- package/src/modules/customers/i18n/en.json +1 -1
- package/src/modules/customers/i18n/es.json +1 -1
- package/src/modules/customers/i18n/ko.json +1 -1
- package/src/modules/customers/i18n/pl.json +1 -1
- package/src/modules/customers/lib/closureStage.ts +2 -1
- package/src/modules/customers/lib/dealStatus.ts +23 -12
- package/src/modules/customers/lib/dealsSummaryQueries.ts +3 -3
- package/src/modules/customers/migrations/Migration20260824180000_deal_status_lost.ts +55 -0
- package/src/modules/dashboards/widgets/dashboard/pipeline-summary/config.ts +1 -1
- package/src/modules/eudr/notifications.ts +5 -0
- package/src/modules/query_index/lib/search-tokens.ts +100 -43
- package/src/modules/sales/commands/documents.ts +153 -39
- package/src/modules/warranty_claims/notifications.ts +5 -0
- package/src/modules/wms/notifications.ts +2 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "crypto";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { registerCommand } from "@open-mercato/shared/lib/commands";
|
|
4
5
|
import { withAtomicFlush } from "@open-mercato/shared/lib/commands/flush";
|
|
@@ -7064,6 +7065,70 @@ const createInvoiceCommand = {
|
|
|
7064
7065
|
await em.flush();
|
|
7065
7066
|
}
|
|
7066
7067
|
};
|
|
7068
|
+
const invoiceUpdateChangeKeys = [
|
|
7069
|
+
"invoiceNumber",
|
|
7070
|
+
"statusEntryId",
|
|
7071
|
+
"status",
|
|
7072
|
+
"issueDate",
|
|
7073
|
+
"dueDate",
|
|
7074
|
+
"currencyCode",
|
|
7075
|
+
"subtotalNetAmount",
|
|
7076
|
+
"subtotalGrossAmount",
|
|
7077
|
+
"discountTotalAmount",
|
|
7078
|
+
"taxTotalAmount",
|
|
7079
|
+
"grandTotalNetAmount",
|
|
7080
|
+
"grandTotalGrossAmount",
|
|
7081
|
+
"paidTotalAmount",
|
|
7082
|
+
"outstandingAmount",
|
|
7083
|
+
"metadata"
|
|
7084
|
+
];
|
|
7085
|
+
function toAuditISOString(value) {
|
|
7086
|
+
if (value instanceof Date) {
|
|
7087
|
+
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
|
7088
|
+
}
|
|
7089
|
+
if (typeof value === "string") {
|
|
7090
|
+
const parsed = new Date(value);
|
|
7091
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
|
|
7092
|
+
}
|
|
7093
|
+
return null;
|
|
7094
|
+
}
|
|
7095
|
+
function auditValuesEqual(left, right) {
|
|
7096
|
+
if (Object.is(left, right)) return true;
|
|
7097
|
+
if (left instanceof Date || right instanceof Date) {
|
|
7098
|
+
const leftIso = toAuditISOString(left);
|
|
7099
|
+
const rightIso = toAuditISOString(right);
|
|
7100
|
+
return leftIso !== null && rightIso !== null && leftIso === rightIso;
|
|
7101
|
+
}
|
|
7102
|
+
return isDeepStrictEqual(left, right);
|
|
7103
|
+
}
|
|
7104
|
+
function buildAuditChanges(before, after, keys) {
|
|
7105
|
+
const changedKeys = keys.filter((key) => !auditValuesEqual(before[key], after[key]));
|
|
7106
|
+
return buildChanges(before, after, changedKeys);
|
|
7107
|
+
}
|
|
7108
|
+
function selectInvoiceUpdateChangeKeys(input) {
|
|
7109
|
+
return invoiceUpdateChangeKeys.filter(
|
|
7110
|
+
(key) => key === "status" ? input.statusEntryId !== void 0 : input[key] !== void 0
|
|
7111
|
+
);
|
|
7112
|
+
}
|
|
7113
|
+
function applyInvoiceHeaderUpdate(invoice, input, resolvedStatus) {
|
|
7114
|
+
if (input.invoiceNumber !== void 0) invoice.invoiceNumber = input.invoiceNumber;
|
|
7115
|
+
if (input.statusEntryId !== void 0) {
|
|
7116
|
+
invoice.statusEntryId = input.statusEntryId;
|
|
7117
|
+
invoice.status = resolvedStatus ?? null;
|
|
7118
|
+
}
|
|
7119
|
+
if (input.issueDate !== void 0) invoice.issueDate = input.issueDate;
|
|
7120
|
+
if (input.dueDate !== void 0) invoice.dueDate = input.dueDate;
|
|
7121
|
+
if (input.currencyCode !== void 0) invoice.currencyCode = input.currencyCode;
|
|
7122
|
+
if (input.subtotalNetAmount !== void 0) invoice.subtotalNetAmount = toNumericString(input.subtotalNetAmount);
|
|
7123
|
+
if (input.subtotalGrossAmount !== void 0) invoice.subtotalGrossAmount = toNumericString(input.subtotalGrossAmount);
|
|
7124
|
+
if (input.discountTotalAmount !== void 0) invoice.discountTotalAmount = toNumericString(input.discountTotalAmount);
|
|
7125
|
+
if (input.taxTotalAmount !== void 0) invoice.taxTotalAmount = toNumericString(input.taxTotalAmount);
|
|
7126
|
+
if (input.grandTotalNetAmount !== void 0) invoice.grandTotalNetAmount = toNumericString(input.grandTotalNetAmount);
|
|
7127
|
+
if (input.grandTotalGrossAmount !== void 0) invoice.grandTotalGrossAmount = toNumericString(input.grandTotalGrossAmount);
|
|
7128
|
+
if (input.paidTotalAmount !== void 0) invoice.paidTotalAmount = toNumericString(input.paidTotalAmount);
|
|
7129
|
+
if (input.outstandingAmount !== void 0) invoice.outstandingAmount = toNumericString(input.outstandingAmount);
|
|
7130
|
+
if (input.metadata !== void 0) invoice.metadata = input.metadata;
|
|
7131
|
+
}
|
|
7067
7132
|
const updateInvoiceCommand = {
|
|
7068
7133
|
id: "sales.invoices.update",
|
|
7069
7134
|
async prepare(input, ctx) {
|
|
@@ -7088,27 +7153,11 @@ const updateInvoiceCommand = {
|
|
|
7088
7153
|
tenantId: parsed.tenantId,
|
|
7089
7154
|
deletedAt: null
|
|
7090
7155
|
});
|
|
7091
|
-
|
|
7092
|
-
"invoiceNumber",
|
|
7093
|
-
"statusEntryId",
|
|
7094
|
-
"status",
|
|
7095
|
-
"issueDate",
|
|
7096
|
-
"dueDate",
|
|
7097
|
-
"currencyCode",
|
|
7098
|
-
"subtotalNetAmount",
|
|
7099
|
-
"subtotalGrossAmount",
|
|
7100
|
-
"discountTotalAmount",
|
|
7101
|
-
"taxTotalAmount",
|
|
7102
|
-
"grandTotalNetAmount",
|
|
7103
|
-
"grandTotalGrossAmount",
|
|
7104
|
-
"paidTotalAmount",
|
|
7105
|
-
"outstandingAmount",
|
|
7106
|
-
"metadata"
|
|
7107
|
-
]);
|
|
7156
|
+
let resolvedStatus;
|
|
7108
7157
|
if (parsed.statusEntryId !== void 0) {
|
|
7109
|
-
|
|
7158
|
+
resolvedStatus = await resolveDictionaryEntryValue(em, parsed.statusEntryId ?? null, { tenantId: invoice.tenantId });
|
|
7110
7159
|
}
|
|
7111
|
-
|
|
7160
|
+
applyInvoiceHeaderUpdate(invoice, parsed, resolvedStatus);
|
|
7112
7161
|
invoice.updatedAt = /* @__PURE__ */ new Date();
|
|
7113
7162
|
await em.flush();
|
|
7114
7163
|
const dataEngine = ctx.container.resolve("dataEngine");
|
|
@@ -7141,11 +7190,16 @@ const updateInvoiceCommand = {
|
|
|
7141
7190
|
const em = ctx.container.resolve("em").fork();
|
|
7142
7191
|
return loadInvoiceSnapshot(em, result.invoiceId);
|
|
7143
7192
|
},
|
|
7144
|
-
buildLog: async ({ result, snapshots }) => {
|
|
7193
|
+
buildLog: async ({ input, result, snapshots }) => {
|
|
7145
7194
|
const before = snapshots.before;
|
|
7146
7195
|
const after = snapshots.after;
|
|
7147
7196
|
if (!after) return null;
|
|
7148
7197
|
const { translate } = await resolveTranslations();
|
|
7198
|
+
const changes = before ? buildAuditChanges(
|
|
7199
|
+
before.invoice,
|
|
7200
|
+
after.invoice,
|
|
7201
|
+
selectInvoiceUpdateChangeKeys(input)
|
|
7202
|
+
) : {};
|
|
7149
7203
|
return {
|
|
7150
7204
|
actionLabel: translate("sales.audit.invoices.update", "Update invoice"),
|
|
7151
7205
|
resourceKind: "sales.invoice",
|
|
@@ -7154,6 +7208,7 @@ const updateInvoiceCommand = {
|
|
|
7154
7208
|
organizationId: after.invoice.organizationId,
|
|
7155
7209
|
snapshotBefore: before,
|
|
7156
7210
|
snapshotAfter: after,
|
|
7211
|
+
changes: Object.keys(changes).length ? changes : null,
|
|
7157
7212
|
payload: {
|
|
7158
7213
|
undo: { before, after }
|
|
7159
7214
|
}
|
|
@@ -7525,6 +7580,41 @@ const createCreditMemoCommand = {
|
|
|
7525
7580
|
await em.flush();
|
|
7526
7581
|
}
|
|
7527
7582
|
};
|
|
7583
|
+
const creditMemoUpdateChangeKeys = [
|
|
7584
|
+
"creditMemoNumber",
|
|
7585
|
+
"statusEntryId",
|
|
7586
|
+
"status",
|
|
7587
|
+
"reason",
|
|
7588
|
+
"issueDate",
|
|
7589
|
+
"currencyCode",
|
|
7590
|
+
"subtotalNetAmount",
|
|
7591
|
+
"subtotalGrossAmount",
|
|
7592
|
+
"taxTotalAmount",
|
|
7593
|
+
"grandTotalNetAmount",
|
|
7594
|
+
"grandTotalGrossAmount",
|
|
7595
|
+
"metadata"
|
|
7596
|
+
];
|
|
7597
|
+
function selectCreditMemoUpdateChangeKeys(input) {
|
|
7598
|
+
return creditMemoUpdateChangeKeys.filter(
|
|
7599
|
+
(key) => key === "status" ? input.statusEntryId !== void 0 : input[key] !== void 0
|
|
7600
|
+
);
|
|
7601
|
+
}
|
|
7602
|
+
function applyCreditMemoHeaderUpdate(creditMemo, input, resolvedStatus) {
|
|
7603
|
+
if (input.creditMemoNumber !== void 0) creditMemo.creditMemoNumber = input.creditMemoNumber;
|
|
7604
|
+
if (input.statusEntryId !== void 0) {
|
|
7605
|
+
creditMemo.statusEntryId = input.statusEntryId;
|
|
7606
|
+
creditMemo.status = resolvedStatus ?? null;
|
|
7607
|
+
}
|
|
7608
|
+
if (input.reason !== void 0) creditMemo.reason = input.reason;
|
|
7609
|
+
if (input.issueDate !== void 0) creditMemo.issueDate = input.issueDate;
|
|
7610
|
+
if (input.currencyCode !== void 0) creditMemo.currencyCode = input.currencyCode;
|
|
7611
|
+
if (input.subtotalNetAmount !== void 0) creditMemo.subtotalNetAmount = toNumericString(input.subtotalNetAmount);
|
|
7612
|
+
if (input.subtotalGrossAmount !== void 0) creditMemo.subtotalGrossAmount = toNumericString(input.subtotalGrossAmount);
|
|
7613
|
+
if (input.taxTotalAmount !== void 0) creditMemo.taxTotalAmount = toNumericString(input.taxTotalAmount);
|
|
7614
|
+
if (input.grandTotalNetAmount !== void 0) creditMemo.grandTotalNetAmount = toNumericString(input.grandTotalNetAmount);
|
|
7615
|
+
if (input.grandTotalGrossAmount !== void 0) creditMemo.grandTotalGrossAmount = toNumericString(input.grandTotalGrossAmount);
|
|
7616
|
+
if (input.metadata !== void 0) creditMemo.metadata = input.metadata;
|
|
7617
|
+
}
|
|
7528
7618
|
const updateCreditMemoCommand = {
|
|
7529
7619
|
id: "sales.credit_memos.update",
|
|
7530
7620
|
async prepare(input, ctx) {
|
|
@@ -7549,24 +7639,11 @@ const updateCreditMemoCommand = {
|
|
|
7549
7639
|
tenantId: parsed.tenantId,
|
|
7550
7640
|
deletedAt: null
|
|
7551
7641
|
});
|
|
7552
|
-
|
|
7553
|
-
"creditMemoNumber",
|
|
7554
|
-
"statusEntryId",
|
|
7555
|
-
"status",
|
|
7556
|
-
"reason",
|
|
7557
|
-
"issueDate",
|
|
7558
|
-
"currencyCode",
|
|
7559
|
-
"subtotalNetAmount",
|
|
7560
|
-
"subtotalGrossAmount",
|
|
7561
|
-
"taxTotalAmount",
|
|
7562
|
-
"grandTotalNetAmount",
|
|
7563
|
-
"grandTotalGrossAmount",
|
|
7564
|
-
"metadata"
|
|
7565
|
-
]);
|
|
7642
|
+
let resolvedStatus;
|
|
7566
7643
|
if (parsed.statusEntryId !== void 0) {
|
|
7567
|
-
|
|
7644
|
+
resolvedStatus = await resolveDictionaryEntryValue(em, parsed.statusEntryId ?? null, { tenantId: creditMemo.tenantId });
|
|
7568
7645
|
}
|
|
7569
|
-
|
|
7646
|
+
applyCreditMemoHeaderUpdate(creditMemo, parsed, resolvedStatus);
|
|
7570
7647
|
creditMemo.updatedAt = /* @__PURE__ */ new Date();
|
|
7571
7648
|
await em.flush();
|
|
7572
7649
|
const dataEngine = ctx.container.resolve("dataEngine");
|
|
@@ -7599,11 +7676,16 @@ const updateCreditMemoCommand = {
|
|
|
7599
7676
|
const em = ctx.container.resolve("em").fork();
|
|
7600
7677
|
return loadCreditMemoSnapshot(em, result.creditMemoId);
|
|
7601
7678
|
},
|
|
7602
|
-
buildLog: async ({ result, snapshots }) => {
|
|
7679
|
+
buildLog: async ({ input, result, snapshots }) => {
|
|
7603
7680
|
const before = snapshots.before;
|
|
7604
7681
|
const after = snapshots.after;
|
|
7605
7682
|
if (!after) return null;
|
|
7606
7683
|
const { translate } = await resolveTranslations();
|
|
7684
|
+
const changes = before ? buildAuditChanges(
|
|
7685
|
+
before.creditMemo,
|
|
7686
|
+
after.creditMemo,
|
|
7687
|
+
selectCreditMemoUpdateChangeKeys(input)
|
|
7688
|
+
) : {};
|
|
7607
7689
|
return {
|
|
7608
7690
|
actionLabel: translate("sales.audit.credit_memos.update", "Update credit memo"),
|
|
7609
7691
|
resourceKind: "sales.credit_memo",
|
|
@@ -7612,6 +7694,7 @@ const updateCreditMemoCommand = {
|
|
|
7612
7694
|
organizationId: after.creditMemo.organizationId,
|
|
7613
7695
|
snapshotBefore: before,
|
|
7614
7696
|
snapshotAfter: after,
|
|
7697
|
+
changes: Object.keys(changes).length ? changes : null,
|
|
7615
7698
|
payload: {
|
|
7616
7699
|
undo: { before, after }
|
|
7617
7700
|
}
|