@open-mercato/core 0.6.3-develop.3525.3.cc18b8a43f → 0.6.3-develop.3562.1.71049275ff
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/auth/api/users/route.js +49 -9
- package/dist/modules/auth/api/users/route.js.map +2 -2
- package/dist/modules/auth/backend/roles/[id]/edit/page.js +32 -14
- package/dist/modules/auth/backend/roles/[id]/edit/page.js.map +2 -2
- package/dist/modules/auth/backend/users/[id]/edit/page.js +1 -1
- package/dist/modules/auth/backend/users/[id]/edit/page.js.map +2 -2
- package/dist/modules/auth/backend/users/create/page.js +1 -1
- package/dist/modules/auth/backend/users/create/page.js.map +2 -2
- package/dist/modules/auth/backend/users/roleOptions.js +1 -1
- package/dist/modules/auth/backend/users/roleOptions.js.map +2 -2
- package/dist/modules/auth/commands/roles.js +8 -0
- package/dist/modules/auth/commands/roles.js.map +2 -2
- package/dist/modules/auth/components/AclEditor.js +53 -26
- package/dist/modules/auth/components/AclEditor.js.map +2 -2
- package/dist/modules/dashboards/components/WidgetVisibilityEditor.js +41 -12
- package/dist/modules/dashboards/components/WidgetVisibilityEditor.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +104 -0
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/data/validators.js +20 -1
- package/dist/modules/sales/data/validators.js.map +2 -2
- package/package.json +7 -7
- package/src/modules/auth/api/users/route.ts +51 -9
- package/src/modules/auth/backend/roles/[id]/edit/page.tsx +35 -13
- package/src/modules/auth/backend/users/[id]/edit/page.tsx +1 -1
- package/src/modules/auth/backend/users/create/page.tsx +1 -1
- package/src/modules/auth/backend/users/roleOptions.ts +2 -1
- package/src/modules/auth/commands/roles.ts +8 -0
- package/src/modules/auth/components/AclEditor.tsx +50 -24
- package/src/modules/dashboards/components/WidgetVisibilityEditor.tsx +38 -12
- package/src/modules/sales/commands/documents.ts +116 -0
- package/src/modules/sales/data/validators.ts +38 -0
- package/src/modules/sales/i18n/de.json +2 -0
- package/src/modules/sales/i18n/en.json +2 -0
- package/src/modules/sales/i18n/es.json +2 -0
- package/src/modules/sales/i18n/pl.json +2 -0
|
@@ -57,6 +57,9 @@ import {
|
|
|
57
57
|
} from "../../customers/data/entities.js";
|
|
58
58
|
import {
|
|
59
59
|
enforceAdjustmentSign,
|
|
60
|
+
validateReturnAdjustmentWithinRemaining,
|
|
61
|
+
RETURN_ADJUSTMENT_EXCEEDS_REMAINING_GROSS_MESSAGE,
|
|
62
|
+
RETURN_ADJUSTMENT_EXCEEDS_REMAINING_NET_MESSAGE,
|
|
60
63
|
quoteCreateSchema,
|
|
61
64
|
quoteLineCreateSchema,
|
|
62
65
|
quoteAdjustmentCreateSchema,
|
|
@@ -5599,6 +5602,57 @@ const orderAdjustmentUpsertCommand = {
|
|
|
5599
5602
|
shippingMethodCode: order.shippingMethodCode ?? null,
|
|
5600
5603
|
paymentMethodCode: order.paymentMethodCode ?? null
|
|
5601
5604
|
});
|
|
5605
|
+
const effectiveAdjustment = nextAdjustments.find(
|
|
5606
|
+
(adj) => adj.id === adjustmentId
|
|
5607
|
+
);
|
|
5608
|
+
if (effectiveAdjustment?.kind === "return") {
|
|
5609
|
+
const baselineAdjustments = nextAdjustments.filter(
|
|
5610
|
+
(adj) => adj.id !== adjustmentId
|
|
5611
|
+
);
|
|
5612
|
+
const baselineCalculation = await salesCalculationService.calculateDocumentTotals({
|
|
5613
|
+
documentKind: "order",
|
|
5614
|
+
lines: calcLines,
|
|
5615
|
+
adjustments: baselineAdjustments,
|
|
5616
|
+
context: calculationContext,
|
|
5617
|
+
existingTotals: resolveExistingPaymentTotals(order)
|
|
5618
|
+
});
|
|
5619
|
+
const issues = validateReturnAdjustmentWithinRemaining({
|
|
5620
|
+
kind: "return",
|
|
5621
|
+
amountNet: effectiveAdjustment.amountNet ?? effectiveAdjustment.amountGross ?? 0,
|
|
5622
|
+
amountGross: effectiveAdjustment.amountGross ?? effectiveAdjustment.amountNet ?? 0,
|
|
5623
|
+
remainingNet: Number(
|
|
5624
|
+
baselineCalculation.totals?.grandTotalNetAmount ?? 0
|
|
5625
|
+
),
|
|
5626
|
+
remainingGross: Number(
|
|
5627
|
+
baselineCalculation.totals?.grandTotalGrossAmount ?? 0
|
|
5628
|
+
)
|
|
5629
|
+
});
|
|
5630
|
+
if (issues.length > 0) {
|
|
5631
|
+
const { translate } = await resolveTranslations();
|
|
5632
|
+
const grossIssue = issues.find((issue) => issue.path === "amountGross");
|
|
5633
|
+
const netIssue = issues.find((issue) => issue.path === "amountNet");
|
|
5634
|
+
const fieldErrors = {};
|
|
5635
|
+
if (grossIssue) {
|
|
5636
|
+
fieldErrors.amountGross = translate(
|
|
5637
|
+
"sales.adjustments.error.returnExceedsRemainingGrandTotalGross",
|
|
5638
|
+
RETURN_ADJUSTMENT_EXCEEDS_REMAINING_GROSS_MESSAGE
|
|
5639
|
+
);
|
|
5640
|
+
}
|
|
5641
|
+
if (netIssue) {
|
|
5642
|
+
fieldErrors.amountNet = translate(
|
|
5643
|
+
"sales.adjustments.error.returnExceedsRemainingGrandTotalNet",
|
|
5644
|
+
RETURN_ADJUSTMENT_EXCEEDS_REMAINING_NET_MESSAGE
|
|
5645
|
+
);
|
|
5646
|
+
}
|
|
5647
|
+
throw new CrudHttpError(400, {
|
|
5648
|
+
error: fieldErrors.amountGross ?? fieldErrors.amountNet ?? translate(
|
|
5649
|
+
"sales.adjustments.error.returnExceedsRemainingGrandTotalGross",
|
|
5650
|
+
RETURN_ADJUSTMENT_EXCEEDS_REMAINING_GROSS_MESSAGE
|
|
5651
|
+
),
|
|
5652
|
+
fieldErrors
|
|
5653
|
+
});
|
|
5654
|
+
}
|
|
5655
|
+
}
|
|
5602
5656
|
const calculation = await salesCalculationService.calculateDocumentTotals({
|
|
5603
5657
|
documentKind: "order",
|
|
5604
5658
|
lines: calcLines,
|
|
@@ -5942,6 +5996,56 @@ const quoteAdjustmentUpsertCommand = {
|
|
|
5942
5996
|
shippingMethodCode: quote.shippingMethodCode ?? null,
|
|
5943
5997
|
paymentMethodCode: quote.paymentMethodCode ?? null
|
|
5944
5998
|
});
|
|
5999
|
+
const effectiveAdjustment = nextAdjustments.find(
|
|
6000
|
+
(adj) => adj.id === adjustmentId
|
|
6001
|
+
);
|
|
6002
|
+
if (effectiveAdjustment?.kind === "return") {
|
|
6003
|
+
const baselineAdjustments = nextAdjustments.filter(
|
|
6004
|
+
(adj) => adj.id !== adjustmentId
|
|
6005
|
+
);
|
|
6006
|
+
const baselineCalculation = await salesCalculationService.calculateDocumentTotals({
|
|
6007
|
+
documentKind: "quote",
|
|
6008
|
+
lines: calcLines,
|
|
6009
|
+
adjustments: baselineAdjustments,
|
|
6010
|
+
context: calculationContext
|
|
6011
|
+
});
|
|
6012
|
+
const issues = validateReturnAdjustmentWithinRemaining({
|
|
6013
|
+
kind: "return",
|
|
6014
|
+
amountNet: effectiveAdjustment.amountNet ?? effectiveAdjustment.amountGross ?? 0,
|
|
6015
|
+
amountGross: effectiveAdjustment.amountGross ?? effectiveAdjustment.amountNet ?? 0,
|
|
6016
|
+
remainingNet: Number(
|
|
6017
|
+
baselineCalculation.totals?.grandTotalNetAmount ?? 0
|
|
6018
|
+
),
|
|
6019
|
+
remainingGross: Number(
|
|
6020
|
+
baselineCalculation.totals?.grandTotalGrossAmount ?? 0
|
|
6021
|
+
)
|
|
6022
|
+
});
|
|
6023
|
+
if (issues.length > 0) {
|
|
6024
|
+
const { translate } = await resolveTranslations();
|
|
6025
|
+
const grossIssue = issues.find((issue) => issue.path === "amountGross");
|
|
6026
|
+
const netIssue = issues.find((issue) => issue.path === "amountNet");
|
|
6027
|
+
const fieldErrors = {};
|
|
6028
|
+
if (grossIssue) {
|
|
6029
|
+
fieldErrors.amountGross = translate(
|
|
6030
|
+
"sales.adjustments.error.returnExceedsRemainingGrandTotalGross",
|
|
6031
|
+
RETURN_ADJUSTMENT_EXCEEDS_REMAINING_GROSS_MESSAGE
|
|
6032
|
+
);
|
|
6033
|
+
}
|
|
6034
|
+
if (netIssue) {
|
|
6035
|
+
fieldErrors.amountNet = translate(
|
|
6036
|
+
"sales.adjustments.error.returnExceedsRemainingGrandTotalNet",
|
|
6037
|
+
RETURN_ADJUSTMENT_EXCEEDS_REMAINING_NET_MESSAGE
|
|
6038
|
+
);
|
|
6039
|
+
}
|
|
6040
|
+
throw new CrudHttpError(400, {
|
|
6041
|
+
error: fieldErrors.amountGross ?? fieldErrors.amountNet ?? translate(
|
|
6042
|
+
"sales.adjustments.error.returnExceedsRemainingGrandTotalGross",
|
|
6043
|
+
RETURN_ADJUSTMENT_EXCEEDS_REMAINING_GROSS_MESSAGE
|
|
6044
|
+
),
|
|
6045
|
+
fieldErrors
|
|
6046
|
+
});
|
|
6047
|
+
}
|
|
6048
|
+
}
|
|
5945
6049
|
const calculation = await salesCalculationService.calculateDocumentTotals({
|
|
5946
6050
|
documentKind: "quote",
|
|
5947
6051
|
lines: calcLines,
|