@medusajs/order 0.1.3-snapshot-20240718083016 → 0.1.3-snapshot-20240719133408
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +6 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -26
- package/dist/index.js.map +1 -1
- package/dist/migrations/Migration20240219102530.d.ts +1 -0
- package/dist/migrations/Migration20240219102530.d.ts.map +1 -0
- package/dist/migrations/Migration20240219102530.js +38 -4
- package/dist/migrations/Migration20240219102530.js.map +1 -1
- package/dist/migrations/Migration20240604100512.d.ts +5 -0
- package/dist/migrations/Migration20240604100512.d.ts.map +1 -0
- package/dist/migrations/Migration20240604100512.js +364 -0
- package/dist/migrations/Migration20240604100512.js.map +1 -0
- package/dist/migrations/Migration20240715102100.d.ts +5 -0
- package/dist/migrations/Migration20240715102100.d.ts.map +1 -0
- package/dist/migrations/Migration20240715102100.js +15 -0
- package/dist/migrations/Migration20240715102100.js.map +1 -0
- package/dist/migrations/Migration20240715174100.d.ts +5 -0
- package/dist/migrations/Migration20240715174100.d.ts.map +1 -0
- package/dist/migrations/Migration20240715174100.js +21 -0
- package/dist/migrations/Migration20240715174100.js.map +1 -0
- package/dist/migrations/Migration20240716081800.d.ts +5 -0
- package/dist/migrations/Migration20240716081800.d.ts.map +1 -0
- package/dist/migrations/Migration20240716081800.js +67 -0
- package/dist/migrations/Migration20240716081800.js.map +1 -0
- package/dist/models/address.d.ts +2 -1
- package/dist/models/address.d.ts.map +1 -0
- package/dist/models/adjustment-line.d.ts +3 -1
- package/dist/models/adjustment-line.d.ts.map +1 -0
- package/dist/models/adjustment-line.js +5 -0
- package/dist/models/adjustment-line.js.map +1 -1
- package/dist/models/claim-item-image.d.ts +19 -0
- package/dist/models/claim-item-image.d.ts.map +1 -0
- package/dist/models/claim-item-image.js +109 -0
- package/dist/models/claim-item-image.js.map +1 -0
- package/dist/models/claim-item.d.ts +29 -0
- package/dist/models/claim-item.d.ts.map +1 -0
- package/dist/models/claim-item.js +156 -0
- package/dist/models/claim-item.js.map +1 -0
- package/dist/models/claim.d.ts +36 -0
- package/dist/models/claim.d.ts.map +1 -0
- package/dist/models/claim.js +195 -0
- package/dist/models/claim.js.map +1 -0
- package/dist/models/exchange-item.d.ts +24 -0
- package/dist/models/exchange-item.d.ts.map +1 -0
- package/dist/models/exchange-item.js +138 -0
- package/dist/models/exchange-item.js.map +1 -0
- package/dist/models/exchange.d.ts +34 -0
- package/dist/models/exchange.d.ts.map +1 -0
- package/dist/models/exchange.js +188 -0
- package/dist/models/exchange.js.map +1 -0
- package/dist/models/index.d.ts +9 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +17 -1
- package/dist/models/index.js.map +1 -1
- package/dist/models/line-item-adjustment.d.ts +3 -1
- package/dist/models/line-item-adjustment.d.ts.map +1 -0
- package/dist/models/line-item-adjustment.js +3 -3
- package/dist/models/line-item-adjustment.js.map +1 -1
- package/dist/models/line-item-tax-line.d.ts +3 -1
- package/dist/models/line-item-tax-line.d.ts.map +1 -0
- package/dist/models/line-item-tax-line.js +3 -3
- package/dist/models/line-item-tax-line.js.map +1 -1
- package/dist/models/line-item.d.ts +3 -1
- package/dist/models/line-item.d.ts.map +1 -0
- package/dist/models/line-item.js +18 -4
- package/dist/models/line-item.js.map +1 -1
- package/dist/models/order-change-action.d.ts +15 -4
- package/dist/models/order-change-action.d.ts.map +1 -0
- package/dist/models/order-change-action.js +102 -7
- package/dist/models/order-change-action.js.map +1 -1
- package/dist/models/order-change.d.ts +17 -5
- package/dist/models/order-change.d.ts.map +1 -0
- package/dist/models/order-change.js +109 -4
- package/dist/models/order-change.js.map +1 -1
- package/dist/models/order-item.d.ts +5 -4
- package/dist/models/order-item.d.ts.map +1 -0
- package/dist/models/order-item.js +13 -13
- package/dist/models/order-item.js.map +1 -1
- package/dist/models/order-shipping-method.d.ts +14 -4
- package/dist/models/order-shipping-method.d.ts.map +1 -0
- package/dist/models/order-shipping-method.js +89 -13
- package/dist/models/order-shipping-method.js.map +1 -1
- package/dist/models/order-summary.d.ts +6 -7
- package/dist/models/order-summary.d.ts.map +1 -0
- package/dist/models/order-summary.js +9 -6
- package/dist/models/order-summary.js.map +1 -1
- package/dist/models/order.d.ts +6 -4
- package/dist/models/order.d.ts.map +1 -0
- package/dist/models/order.js +11 -1
- package/dist/models/order.js.map +1 -1
- package/dist/models/return-item.d.ts +29 -0
- package/dist/models/return-item.d.ts.map +1 -0
- package/dist/models/return-item.js +170 -0
- package/dist/models/return-item.js.map +1 -0
- package/dist/models/return-reason.d.ts +21 -0
- package/dist/models/return-reason.d.ts.map +1 -0
- package/dist/models/return-reason.js +120 -0
- package/dist/models/return-reason.js.map +1 -0
- package/dist/models/return.d.ts +39 -0
- package/dist/models/return.d.ts.map +1 -0
- package/dist/models/return.js +216 -0
- package/dist/models/return.js.map +1 -0
- package/dist/models/shipping-method-adjustment.d.ts +3 -1
- package/dist/models/shipping-method-adjustment.d.ts.map +1 -0
- package/dist/models/shipping-method-adjustment.js +3 -3
- package/dist/models/shipping-method-adjustment.js.map +1 -1
- package/dist/models/shipping-method-tax-line.d.ts +3 -1
- package/dist/models/shipping-method-tax-line.d.ts.map +1 -0
- package/dist/models/shipping-method-tax-line.js +3 -3
- package/dist/models/shipping-method-tax-line.js.map +1 -1
- package/dist/models/shipping-method.d.ts +2 -0
- package/dist/models/shipping-method.d.ts.map +1 -0
- package/dist/models/shipping-method.js +17 -4
- package/dist/models/shipping-method.js.map +1 -1
- package/dist/models/tax-line.d.ts +2 -0
- package/dist/models/tax-line.d.ts.map +1 -0
- package/dist/models/tax-line.js +7 -0
- package/dist/models/tax-line.js.map +1 -1
- package/dist/models/transaction.d.ts +15 -3
- package/dist/models/transaction.d.ts.map +1 -0
- package/dist/models/transaction.js +109 -4
- package/dist/models/transaction.js.map +1 -1
- package/dist/repositories/claim.d.ts +9 -0
- package/dist/repositories/claim.d.ts.map +1 -0
- package/dist/repositories/claim.js +11 -0
- package/dist/repositories/claim.js.map +1 -0
- package/dist/repositories/exchange.d.ts +9 -0
- package/dist/repositories/exchange.d.ts.map +1 -0
- package/dist/repositories/exchange.js +11 -0
- package/dist/repositories/exchange.js.map +1 -0
- package/dist/repositories/index.d.ts +4 -1
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +7 -16
- package/dist/repositories/index.js.map +1 -1
- package/dist/repositories/order.d.ts +1 -3
- package/dist/repositories/order.d.ts.map +1 -0
- package/dist/repositories/order.js +2 -85
- package/dist/repositories/order.js.map +1 -1
- package/dist/repositories/return.d.ts +9 -0
- package/dist/repositories/return.d.ts.map +1 -0
- package/dist/repositories/return.js +11 -0
- package/dist/repositories/return.js.map +1 -0
- package/dist/services/actions/cancel-claim.d.ts +3 -0
- package/dist/services/actions/cancel-claim.d.ts.map +1 -0
- package/dist/services/actions/cancel-claim.js +107 -0
- package/dist/services/actions/cancel-claim.js.map +1 -0
- package/dist/services/actions/cancel-exchange.d.ts +3 -0
- package/dist/services/actions/cancel-exchange.d.ts.map +1 -0
- package/dist/services/actions/cancel-exchange.js +92 -0
- package/dist/services/actions/cancel-exchange.js.map +1 -0
- package/dist/services/actions/cancel-fulfillment.d.ts +3 -0
- package/dist/services/actions/cancel-fulfillment.d.ts.map +1 -0
- package/dist/services/actions/cancel-fulfillment.js +32 -0
- package/dist/services/actions/cancel-fulfillment.js.map +1 -0
- package/dist/services/actions/cancel-return.d.ts +3 -0
- package/dist/services/actions/cancel-return.d.ts.map +1 -0
- package/dist/services/actions/cancel-return.js +72 -0
- package/dist/services/actions/cancel-return.js.map +1 -0
- package/dist/services/actions/create-claim.d.ts +3 -0
- package/dist/services/actions/create-claim.d.ts.map +1 -0
- package/dist/services/actions/create-claim.js +228 -0
- package/dist/services/actions/create-claim.js.map +1 -0
- package/dist/services/actions/create-exchange.d.ts +3 -0
- package/dist/services/actions/create-exchange.d.ts.map +1 -0
- package/dist/services/actions/create-exchange.js +193 -0
- package/dist/services/actions/create-exchange.js.map +1 -0
- package/dist/services/actions/create-return.d.ts +3 -0
- package/dist/services/actions/create-return.d.ts.map +1 -0
- package/dist/services/actions/create-return.js +102 -0
- package/dist/services/actions/create-return.js.map +1 -0
- package/dist/services/actions/index.d.ts +11 -0
- package/dist/services/actions/index.d.ts.map +1 -0
- package/dist/services/actions/index.js +27 -0
- package/dist/services/actions/index.js.map +1 -0
- package/dist/services/actions/receive-return.d.ts +3 -0
- package/dist/services/actions/receive-return.d.ts.map +1 -0
- package/dist/services/actions/receive-return.js +72 -0
- package/dist/services/actions/receive-return.js.map +1 -0
- package/dist/services/actions/register-fulfillment.d.ts +3 -0
- package/dist/services/actions/register-fulfillment.d.ts.map +1 -0
- package/dist/services/actions/register-fulfillment.js +30 -0
- package/dist/services/actions/register-fulfillment.js.map +1 -0
- package/dist/services/actions/register-shipment.d.ts +3 -0
- package/dist/services/actions/register-shipment.d.ts.map +1 -0
- package/dist/services/actions/register-shipment.js +38 -0
- package/dist/services/actions/register-shipment.js.map +1 -0
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +1 -3
- package/dist/services/index.js.map +1 -1
- package/dist/services/order-module-service.d.ts +138 -67
- package/dist/services/order-module-service.d.ts.map +1 -0
- package/dist/services/order-module-service.js +993 -241
- package/dist/services/order-module-service.js.map +1 -1
- package/dist/services/order-service.d.ts +5 -4
- package/dist/services/order-service.d.ts.map +1 -0
- package/dist/services/order-service.js +1 -1
- package/dist/services/order-service.js.map +1 -1
- package/dist/types/address.d.ts +1 -0
- package/dist/types/address.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/line-item-adjustment.d.ts +1 -0
- package/dist/types/line-item-adjustment.d.ts.map +1 -0
- package/dist/types/line-item-tax-line.d.ts +1 -0
- package/dist/types/line-item-tax-line.d.ts.map +1 -0
- package/dist/types/line-item.d.ts +1 -0
- package/dist/types/line-item.d.ts.map +1 -0
- package/dist/types/order-change.d.ts +6 -0
- package/dist/types/order-change.d.ts.map +1 -0
- package/dist/types/order-change.js +3 -0
- package/dist/types/order-change.js.map +1 -0
- package/dist/types/order-detail.d.ts +2 -1
- package/dist/types/order-detail.d.ts.map +1 -0
- package/dist/types/order.d.ts +3 -2
- package/dist/types/order.d.ts.map +1 -0
- package/dist/types/shipping-method-adjustment.d.ts +1 -0
- package/dist/types/shipping-method-adjustment.d.ts.map +1 -0
- package/dist/types/shipping-method-tax-line.d.ts +1 -0
- package/dist/types/shipping-method-tax-line.d.ts.map +1 -0
- package/dist/types/shipping-method.d.ts +4 -0
- package/dist/types/shipping-method.d.ts.map +1 -0
- package/dist/types/tax-line.d.ts +1 -0
- package/dist/types/tax-line.d.ts.map +1 -0
- package/dist/types/transaction.d.ts +1 -0
- package/dist/types/transaction.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +40 -21
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/index.js +0 -1
- package/dist/types/utils/index.js.map +1 -1
- package/dist/utils/actions/cancel-item-fulfillment.d.ts +2 -0
- package/dist/utils/actions/cancel-item-fulfillment.d.ts.map +1 -0
- package/dist/utils/actions/cancel-item-fulfillment.js +34 -0
- package/dist/utils/actions/cancel-item-fulfillment.js.map +1 -0
- package/dist/utils/actions/cancel-return.d.ts +1 -0
- package/dist/utils/actions/cancel-return.d.ts.map +1 -0
- package/dist/utils/actions/cancel-return.js +6 -10
- package/dist/utils/actions/cancel-return.js.map +1 -1
- package/dist/utils/actions/fulfill-item.d.ts +1 -0
- package/dist/utils/actions/fulfill-item.d.ts.map +1 -0
- package/dist/utils/actions/fulfill-item.js +6 -10
- package/dist/utils/actions/fulfill-item.js.map +1 -1
- package/dist/utils/actions/index.d.ts +4 -1
- package/dist/utils/actions/index.d.ts.map +1 -0
- package/dist/utils/actions/index.js +3 -1
- package/dist/utils/actions/index.js.map +1 -1
- package/dist/utils/actions/item-add.d.ts +1 -0
- package/dist/utils/actions/item-add.d.ts.map +1 -0
- package/dist/utils/actions/item-add.js +15 -24
- package/dist/utils/actions/item-add.js.map +1 -1
- package/dist/utils/actions/item-remove.d.ts +1 -0
- package/dist/utils/actions/item-remove.d.ts.map +1 -0
- package/dist/utils/actions/item-remove.js +8 -22
- package/dist/utils/actions/item-remove.js.map +1 -1
- package/dist/utils/actions/receive-damaged-return-item.d.ts +1 -0
- package/dist/utils/actions/receive-damaged-return-item.d.ts.map +1 -0
- package/dist/utils/actions/receive-damaged-return-item.js +9 -35
- package/dist/utils/actions/receive-damaged-return-item.js.map +1 -1
- package/dist/utils/actions/receive-return-item.d.ts +1 -0
- package/dist/utils/actions/receive-return-item.d.ts.map +1 -0
- package/dist/utils/actions/receive-return-item.js +7 -36
- package/dist/utils/actions/receive-return-item.js.map +1 -1
- package/dist/utils/actions/reinstate-item.d.ts +2 -0
- package/dist/utils/actions/reinstate-item.d.ts.map +1 -0
- package/dist/utils/actions/reinstate-item.js +32 -0
- package/dist/utils/actions/reinstate-item.js.map +1 -0
- package/dist/utils/actions/return-item.d.ts +1 -0
- package/dist/utils/actions/return-item.d.ts.map +1 -0
- package/dist/utils/actions/return-item.js +8 -12
- package/dist/utils/actions/return-item.js.map +1 -1
- package/dist/utils/actions/ship-item.d.ts +1 -0
- package/dist/utils/actions/ship-item.d.ts.map +1 -0
- package/dist/utils/actions/ship-item.js +6 -10
- package/dist/utils/actions/ship-item.js.map +1 -1
- package/dist/utils/actions/shipping-add.d.ts +1 -0
- package/dist/utils/actions/shipping-add.d.ts.map +1 -0
- package/dist/utils/actions/shipping-add.js +16 -16
- package/dist/utils/actions/shipping-add.js.map +1 -1
- package/dist/utils/actions/shipping-remove.d.ts +2 -0
- package/dist/utils/actions/shipping-remove.d.ts.map +1 -0
- package/dist/utils/actions/shipping-remove.js +25 -0
- package/dist/utils/actions/shipping-remove.js.map +1 -0
- package/dist/utils/actions/write-off-item.d.ts +1 -0
- package/dist/utils/actions/write-off-item.d.ts.map +1 -0
- package/dist/utils/actions/write-off-item.js +6 -10
- package/dist/utils/actions/write-off-item.js.map +1 -1
- package/dist/utils/apply-order-changes.d.ts +18 -0
- package/dist/utils/apply-order-changes.d.ts.map +1 -0
- package/dist/utils/apply-order-changes.js +95 -0
- package/dist/utils/apply-order-changes.js.map +1 -0
- package/dist/utils/base-repository-find.d.ts +3 -0
- package/dist/utils/base-repository-find.d.ts.map +1 -0
- package/dist/utils/base-repository-find.js +142 -0
- package/dist/utils/base-repository-find.js.map +1 -0
- package/dist/utils/calculate-order-change.d.ts +11 -5
- package/dist/utils/calculate-order-change.d.ts.map +1 -0
- package/dist/utils/calculate-order-change.js +58 -183
- package/dist/utils/calculate-order-change.js.map +1 -1
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/set-action-reference.d.ts +2 -0
- package/dist/utils/set-action-reference.d.ts.map +1 -0
- package/dist/utils/set-action-reference.js +11 -0
- package/dist/utils/set-action-reference.js.map +1 -0
- package/dist/utils/transform-order.d.ts +4 -2
- package/dist/utils/transform-order.d.ts.map +1 -0
- package/dist/utils/transform-order.js +131 -17
- package/dist/utils/transform-order.js.map +1 -1
- package/package.json +8 -14
- package/dist/joiner-config.d.ts +0 -5
- package/dist/joiner-config.js +0 -36
- package/dist/joiner-config.js.map +0 -1
- package/dist/module-definition.d.ts +0 -2
- package/dist/module-definition.js +0 -59
- package/dist/module-definition.js.map +0 -1
- package/dist/scripts/bin/run-seed.d.ts +0 -3
- package/dist/scripts/bin/run-seed.js +0 -49
- package/dist/scripts/bin/run-seed.js.map +0 -1
- package/dist/services/order-change-service.d.ts +0 -15
- package/dist/services/order-change-service.js +0 -96
- package/dist/services/order-change-service.js.map +0 -1
- package/dist/utils/action-key.d.ts +0 -13
- package/dist/utils/action-key.js +0 -18
- package/dist/utils/action-key.js.map +0 -1
- package/dist/utils/actions/cancel.d.ts +0 -1
- package/dist/utils/actions/cancel.js +0 -8
- package/dist/utils/actions/cancel.js.map +0 -1
@@ -4,7 +4,6 @@ exports.EVENT_STATUS = void 0;
|
|
4
4
|
var EVENT_STATUS;
|
5
5
|
(function (EVENT_STATUS) {
|
6
6
|
EVENT_STATUS["PENDING"] = "pending";
|
7
|
-
EVENT_STATUS["VOIDED"] = "voided";
|
8
7
|
EVENT_STATUS["DONE"] = "done";
|
9
8
|
})(EVENT_STATUS || (exports.EVENT_STATUS = EVENT_STATUS = {}));
|
10
9
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/utils/index.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/utils/index.ts"],"names":[],"mappings":";;;AA0DA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,6BAAa,CAAA;AACf,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cancel-item-fulfillment.d.ts","sourceRoot":"","sources":["../../../src/utils/actions/cancel-item-fulfillment.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const utils_1 = require("@medusajs/utils");
|
4
|
+
const calculate_order_change_1 = require("../calculate-order-change");
|
5
|
+
const set_action_reference_1 = require("../set-action-reference");
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.CANCEL_ITEM_FULFILLMENT, {
|
7
|
+
operation({ action, currentOrder, options }) {
|
8
|
+
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
9
|
+
existing.detail.fulfilled_quantity ??= 0;
|
10
|
+
existing.detail.fulfilled_quantity = utils_1.MathBN.sub(existing.detail.fulfilled_quantity, action.details.quantity);
|
11
|
+
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
12
|
+
},
|
13
|
+
validate({ action, currentOrder }) {
|
14
|
+
const refId = action.details?.reference_id;
|
15
|
+
if (!(0, utils_1.isDefined)(refId)) {
|
16
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Reference ID is required.");
|
17
|
+
}
|
18
|
+
const existing = currentOrder.items.find((item) => item.id === refId);
|
19
|
+
if (!existing) {
|
20
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Item ID "${refId}" not found.`);
|
21
|
+
}
|
22
|
+
if (!action.details?.quantity) {
|
23
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to cancel item fulfillment ${refId} is required.`);
|
24
|
+
}
|
25
|
+
if (action.details?.quantity < 1) {
|
26
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to cancel item ${refId} must be greater than 0.`);
|
27
|
+
}
|
28
|
+
const greater = utils_1.MathBN.gt(action.details?.quantity, existing.detail?.fulfilled_quantity);
|
29
|
+
if (greater) {
|
30
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Cannot cancel more items than what was fulfilled for item ${refId}.`);
|
31
|
+
}
|
32
|
+
},
|
33
|
+
});
|
34
|
+
//# sourceMappingURL=cancel-item-fulfillment.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cancel-item-fulfillment.js","sourceRoot":"","sources":["../../../src/utils/actions/cancel-item-fulfillment.ts"],"names":[],"mappings":";;AAAA,2CAKwB;AACxB,sEAAiE;AACjE,kEAA4D;AAE5D,8CAAqB,CAAC,kBAAkB,CACtC,wBAAgB,CAAC,uBAAuB,EACxC;IACE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;QACzC,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAA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CAC3D,CAAA;QACH,CAAC;QAED,MAAM,OAAO,GAAG,cAAM,CAAC,EAAE,CACvB,MAAM,CAAC,OAAO,EAAE,QAAQ,EACxB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CACpC,CAAA;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,6DAA6D,KAAK,GAAG,CACtE,CAAA;QACH,CAAC;IACH,CAAC;CACF,CACF,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cancel-return.d.ts","sourceRoot":"","sources":["../../../src/utils/actions/cancel-return.ts"],"names":[],"mappings":""}
|
@@ -1,20 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@medusajs/utils");
|
4
|
-
const action_key_1 = require("../action-key");
|
5
4
|
const calculate_order_change_1 = require("../calculate-order-change");
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
const set_action_reference_1 = require("../set-action-reference");
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.CANCEL_RETURN_ITEM, {
|
7
|
+
operation({ action, currentOrder, options }) {
|
9
8
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
10
|
-
|
9
|
+
existing.detail.return_requested_quantity ??= 0;
|
11
10
|
existing.detail.return_requested_quantity = utils_1.MathBN.sub(existing.detail.return_requested_quantity, action.details.quantity);
|
11
|
+
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
12
12
|
return action.details.unit_price * action.details.quantity;
|
13
13
|
},
|
14
|
-
revert({ action, currentOrder }) {
|
15
|
-
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
16
|
-
existing.detail.return_requested_quantity = utils_1.MathBN.add(existing.detail.return_requested_quantity, action.details.quantity);
|
17
|
-
},
|
18
14
|
validate({ action, currentOrder }) {
|
19
15
|
const refId = action.details?.reference_id;
|
20
16
|
if (!(0, utils_1.isDefined)(refId)) {
|
@@ -25,7 +21,7 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.C
|
|
25
21
|
}
|
26
22
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
27
23
|
if (!existing) {
|
28
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
24
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Item ID "${refId}" not found.`);
|
29
25
|
}
|
30
26
|
if (!action.details?.quantity) {
|
31
27
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to cancel return of item ${refId} is required.`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cancel-return.js","sourceRoot":"","sources":["../../../src/utils/actions/cancel-return.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"cancel-return.js","sourceRoot":"","sources":["../../../src/utils/actions/cancel-return.ts"],"names":[],"mappings":";;AAAA,2CAKwB;AACxB,sEAAiE;AACjE,kEAA4D;AAE5D,8CAAqB,CAAC,kBAAkB,CAAC,wBAAgB,CAAC,kBAAkB,EAAE;IAC5E,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;QACzC,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CAAC,YAAY,CACjD,CAAA;QAEF,QAAQ,CAAC,MAAM,CAAC,yBAAyB,KAAK,CAAC,CAAA;QAE/C,QAAQ,CAAC,MAAM,CAAC,yBAAyB,GAAG,cAAM,CAAC,GAAG,CACpD,QAAQ,CAAC,MAAM,CAAC,yBAAyB,EACzC,MAAM,CAAC,OAAO,CAAC,QAAQ,CACxB,CAAA;QAED,IAAA,yCAAkB,EAAC,QAAQ,EAAE,MAAM,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AyB,CAC3C,CAAA;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,uEAAuE,KAAK,GAAG,CAChF,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fulfill-item.d.ts","sourceRoot":"","sources":["../../../src/utils/actions/fulfill-item.ts"],"names":[],"mappings":""}
|
@@ -1,18 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@medusajs/utils");
|
4
|
-
const action_key_1 = require("../action-key");
|
5
4
|
const calculate_order_change_1 = require("../calculate-order-change");
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
const set_action_reference_1 = require("../set-action-reference");
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.FULFILL_ITEM, {
|
7
|
+
operation({ action, currentOrder, options }) {
|
9
8
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
10
|
-
|
9
|
+
existing.detail.fulfilled_quantity ??= 0;
|
11
10
|
existing.detail.fulfilled_quantity = utils_1.MathBN.add(existing.detail.fulfilled_quantity, action.details.quantity);
|
12
|
-
|
13
|
-
revert({ action, currentOrder }) {
|
14
|
-
const existing = currentOrder.items.find((item) => item.id === action.reference_id);
|
15
|
-
existing.detail.fulfilled_quantity = utils_1.MathBN.sub(existing.detail.fulfilled_quantity, action.details.quantity);
|
11
|
+
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
16
12
|
},
|
17
13
|
validate({ action, currentOrder }) {
|
18
14
|
const refId = action.details?.reference_id;
|
@@ -21,7 +17,7 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.C
|
|
21
17
|
}
|
22
18
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
23
19
|
if (!existing) {
|
24
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
20
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Item ID "${refId}" not found.`);
|
25
21
|
}
|
26
22
|
if (!action.details?.quantity) {
|
27
23
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to fulfill of item ${refId} is required.`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fulfill-item.js","sourceRoot":"","sources":["../../../src/utils/actions/fulfill-item.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"fulfill-item.js","sourceRoot":"","sources":["../../../src/utils/actions/fulfill-item.ts"],"names":[],"mappings":";;AAAA,2CAKwB;AACxB,sEAAiE;AACjE,kEAA4D;AAE5D,8CAAqB,CAAC,kBAAkB,CAAC,wBAAgB,CAAC,YAAY,EAAE;IACtE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;QACzC,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CAAC,YAAY,CACjD,CAAA;QAEF,QAAQ,CAAC,MAAM,CAAC,kBAAkB,KAAK,CAAC,CAAA;QAExC,QAAQ,CAAC,MAAM,CAAC,kBAAkB,GAAG,cAAM,CAAC,GAAG,CAC7C,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAClC,MAAM,CAAC,OAAO,CAAC,QAAQ,CACxB,CAAA;QAED,IAAA,yCAAkB,EAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/C,CAAC;IACD,QAAQ,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,EAAE,YAAY,CAAA;QAC1C,IAAI,CAAC,IAAA,iBAAS,EAAC,KAAK,CAAC,EAAE,CA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el-return";
|
3
3
|
export * from "./fulfill-item";
|
4
4
|
export * from "./item-add";
|
@@ -8,3 +8,6 @@ export * from "./receive-return-item";
|
|
8
8
|
export * from "./return-item";
|
9
9
|
export * from "./ship-item";
|
10
10
|
export * from "./shipping-add";
|
11
|
+
export * from "./shipping-remove";
|
12
|
+
export * from "./write-off-item";
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA"}
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./cancel"), exports);
|
17
|
+
__exportStar(require("./cancel-item-fulfillment"), exports);
|
18
18
|
__exportStar(require("./cancel-return"), exports);
|
19
19
|
__exportStar(require("./fulfill-item"), exports);
|
20
20
|
__exportStar(require("./item-add"), exports);
|
@@ -24,4 +24,6 @@ __exportStar(require("./receive-return-item"), exports);
|
|
24
24
|
__exportStar(require("./return-item"), exports);
|
25
25
|
__exportStar(require("./ship-item"), exports);
|
26
26
|
__exportStar(require("./shipping-add"), exports);
|
27
|
+
__exportStar(require("./shipping-remove"), exports);
|
28
|
+
__exportStar(require("./write-off-item"), exports);
|
27
29
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC;AACzC,kDAA+B;AAC/B,iDAA8B;AAC9B,6CAA0B;AAC1B,gDAA6B;AAC7B,gEAA6C;AAC7C,wDAAqC;AACrC,gDAA6B;AAC7B,8CAA2B;AAC3B,iDAA8B;AAC9B,oDAAiC;AACjC,mDAAgC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"item-add.d.ts","sourceRoot":"","sources":["../../../src/utils/actions/item-add.ts"],"names":[],"mappings":""}
|
@@ -1,42 +1,33 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@medusajs/utils");
|
4
|
-
const action_key_1 = require("../action-key");
|
5
4
|
const calculate_order_change_1 = require("../calculate-order-change");
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
const set_action_reference_1 = require("../set-action-reference");
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.ITEM_ADD, {
|
7
|
+
operation({ action, currentOrder, options }) {
|
8
|
+
let existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
10
9
|
if (existing) {
|
11
|
-
|
10
|
+
existing.detail.quantity ??= 0;
|
12
11
|
existing.quantity = utils_1.MathBN.add(existing.quantity, action.details.quantity);
|
13
12
|
existing.detail.quantity = utils_1.MathBN.add(existing.detail.quantity, action.details.quantity);
|
14
13
|
}
|
15
14
|
else {
|
16
|
-
|
17
|
-
id: action.reference_id,
|
15
|
+
existing = {
|
16
|
+
id: action.details.reference_id,
|
17
|
+
order_id: currentOrder.id,
|
18
|
+
return_id: action.return_id,
|
19
|
+
claim_id: action.claim_id,
|
20
|
+
exchange_id: action.exchange_id,
|
18
21
|
unit_price: action.details.unit_price,
|
19
22
|
quantity: action.details.quantity,
|
20
|
-
}
|
23
|
+
};
|
24
|
+
currentOrder.items.push(existing);
|
21
25
|
}
|
26
|
+
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
22
27
|
return utils_1.MathBN.mult(action.details.unit_price, action.details.quantity);
|
23
28
|
},
|
24
|
-
revert({ action, currentOrder }) {
|
25
|
-
const existingIndex = currentOrder.items.findIndex((item) => item.id === action.reference_id);
|
26
|
-
if (existingIndex > -1) {
|
27
|
-
const existing = currentOrder.items[existingIndex];
|
28
|
-
existing.quantity = utils_1.MathBN.sub(existing.quantity, action.details.quantity);
|
29
|
-
existing.detail.quantity = utils_1.MathBN.sub(existing.detail.quantity, action.details.quantity);
|
30
|
-
if (utils_1.MathBN.lte(existing.quantity, 0)) {
|
31
|
-
currentOrder.items.splice(existingIndex, 1);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
},
|
35
29
|
validate({ action }) {
|
36
|
-
const refId = action.reference_id;
|
37
|
-
if (!(0, utils_1.isDefined)(action.reference_id)) {
|
38
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Reference ID is required.");
|
39
|
-
}
|
30
|
+
const refId = action.details?.reference_id;
|
40
31
|
if (!(0, utils_1.isDefined)(action.amount) && !(0, utils_1.isDefined)(action.details?.unit_price)) {
|
41
32
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Unit price of item ${refId} is required if no action.amount is provided.`);
|
42
33
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"item-add.js","sourceRoot":"","sources":["../../../src/utils/actions/item-add.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"item-add.js","sourceRoot":"","sources":["../../../src/utils/actions/item-add.ts"],"names":[],"mappings":";;AAAA,2CAKwB;AAExB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AAU,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IACxE,CAAC;IACD,QAAQ,CAAC,EAAE,MAAM,EAAE;QACjB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,EAAE,YAAY,CAAA;QAE1C,IAAI,CAAC,IAAA,iBAAS,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAA,iBAAS,EAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,sBAAsB,KAAK,+CAA+C,CAC3E,CAAA;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,oBAAoB,KAAK,eAAe,CACzC,CAAA;QACH,CAAC;QAED,IAAI,cAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,oBAAoB,KAAK,0BAA0B,CACpD,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"item-remove.d.ts","sourceRoot":"","sources":["../../../src/utils/actions/item-remove.ts"],"names":[],"mappings":""}
|
@@ -1,44 +1,30 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@medusajs/utils");
|
4
|
-
const action_key_1 = require("../action-key");
|
5
4
|
const calculate_order_change_1 = require("../calculate-order-change");
|
6
|
-
|
5
|
+
const set_action_reference_1 = require("../set-action-reference");
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.ITEM_REMOVE, {
|
7
7
|
isDeduction: true,
|
8
|
-
operation({ action, currentOrder }) {
|
9
|
-
|
10
|
-
const existingIndex = currentOrder.items.findIndex((item) => item.id === action.reference_id);
|
8
|
+
operation({ action, currentOrder, options }) {
|
9
|
+
const existingIndex = currentOrder.items.findIndex((item) => item.id === action.details.reference_id);
|
11
10
|
const existing = currentOrder.items[existingIndex];
|
12
|
-
|
11
|
+
existing.detail.quantity ??= 0;
|
13
12
|
existing.quantity = utils_1.MathBN.sub(existing.quantity, action.details.quantity);
|
14
13
|
existing.detail.quantity = utils_1.MathBN.sub(existing.detail.quantity, action.details.quantity);
|
14
|
+
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
15
15
|
if (utils_1.MathBN.lte(existing.quantity, 0)) {
|
16
16
|
currentOrder.items.splice(existingIndex, 1);
|
17
17
|
}
|
18
18
|
return utils_1.MathBN.mult(existing.unit_price, action.details.quantity);
|
19
19
|
},
|
20
|
-
revert({ action, currentOrder }) {
|
21
|
-
const existing = currentOrder.items.find((item) => item.id === action.reference_id);
|
22
|
-
if (existing) {
|
23
|
-
existing.quantity = utils_1.MathBN.add(existing.quantity, action.details.quantity);
|
24
|
-
existing.detail.quantity = utils_1.MathBN.add(existing.detail.quantity, action.details.quantity);
|
25
|
-
}
|
26
|
-
else {
|
27
|
-
currentOrder.items.push({
|
28
|
-
id: action.reference_id,
|
29
|
-
unit_price: action.details.unit_price,
|
30
|
-
quantity: action.details.quantity,
|
31
|
-
});
|
32
|
-
}
|
33
|
-
},
|
34
20
|
validate({ action, currentOrder }) {
|
35
|
-
const refId = action.reference_id;
|
21
|
+
const refId = action.details?.reference_id;
|
36
22
|
if (!(0, utils_1.isDefined)(refId)) {
|
37
23
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Reference ID is required.");
|
38
24
|
}
|
39
25
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
40
26
|
if (!existing) {
|
41
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
27
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Item ID "${refId}" not found.`);
|
42
28
|
}
|
43
29
|
if (!(0, utils_1.isDefined)(action.amount) && !(0, utils_1.isDefined)(action.details?.unit_price)) {
|
44
30
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Unit price of item ${refId} is required if no action.amount is provided.`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"item-remove.js","sourceRoot":"","sources":["../../../src/utils/actions/item-remove.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"item-remove.js","sourceRoot":"","sources":["../../../src/utils/actions/item-remove.ts"],"names":[],"mappings":";;AAAA,2CAKwB;AACxB,sEAAiE;AACjE,kEAA4D;AAE5D,8CAAqB,CAAC,kBAAkB,CAAC,wBAAgB,CAAC,WAAW,EAAE;IACrE,WAAW,EAAE,IAAI;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;QACzC,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,CAAC,SAAS,CAChD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CAAC,YAAY,CAClD,CAAA;QAED,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAElD,QAAQ,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAA;QAE9B,QAAQ,CAAC,QAAQ,GAAG,cAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAC1E,QAAQ,CAAC,MAAM,CAAC,QAAQ,GAAG,cAAM,CAAC,GAAG,CACnC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EACxB,MAAM,CAAC,OAAO,CAAC,QAAQ,CACxB,CAAA;QAED,IAAA,yCAAkB,E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,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,oBAAoB,KAAK,eAAe,CACzC,CAAA;QACH,CAAC;QAED,IAAI,cAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,oBAAoB,KAAK,0BAA0B,CACpD,CAAA;QACH,CAAC;QAED,MAAM,YAAY,GAAG,cAAM,CAAC,GAAG,CAC7B,QAAQ,CAAC,QAAQ,EACjB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CACpC,CAAA;QAED,MAAM,OAAO,GAAG,cAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;QACjE,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,sCAAsC,KAAK,GAAG,CAC/C,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"receive-damaged-return-item.d.ts","sourceRoot":"","sources":["../../../src/utils/actions/receive-damaged-return-item.ts"],"names":[],"mappings":""}
|
@@ -1,48 +1,22 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@medusajs/utils");
|
4
|
-
const _types_1 = require("../../types");
|
5
|
-
const action_key_1 = require("../action-key");
|
6
4
|
const calculate_order_change_1 = require("../calculate-order-change");
|
7
|
-
|
5
|
+
const set_action_reference_1 = require("../set-action-reference");
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.RECEIVE_DAMAGED_RETURN_ITEM, {
|
8
7
|
isDeduction: true,
|
9
|
-
|
10
|
-
operation({ action, currentOrder, previousEvents }) {
|
11
|
-
var _a, _b;
|
8
|
+
operation({ action, currentOrder, previousEvents, options }) {
|
12
9
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
13
10
|
let toReturn = action.details.quantity;
|
14
|
-
|
15
|
-
|
11
|
+
existing.detail.return_dismissed_quantity ??= 0;
|
12
|
+
existing.detail.return_requested_quantity ??= 0;
|
16
13
|
existing.detail.return_dismissed_quantity = utils_1.MathBN.add(existing.detail.return_dismissed_quantity, toReturn);
|
17
14
|
existing.detail.return_requested_quantity = utils_1.MathBN.sub(existing.detail.return_requested_quantity, toReturn);
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
let ret = utils_1.MathBN.min(toReturn, previousEvent.details.quantity);
|
22
|
-
toReturn = utils_1.MathBN.sub(toReturn, ret);
|
23
|
-
previousEvent.details.quantity = utils_1.MathBN.sub(previousEvent.details.quantity, ret);
|
24
|
-
if (utils_1.MathBN.lte(previousEvent.details.quantity, 0)) {
|
25
|
-
previousEvent.status = _types_1.EVENT_STATUS.DONE;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
15
|
+
existing.detail.written_off_quantity ??= 0;
|
16
|
+
existing.detail.written_off_quantity = utils_1.MathBN.add(existing.detail.written_off_quantity, action.details.quantity);
|
17
|
+
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
29
18
|
return utils_1.MathBN.mult(existing.unit_price, action.details.quantity);
|
30
19
|
},
|
31
|
-
revert({ action, currentOrder, previousEvents }) {
|
32
|
-
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
33
|
-
existing.detail.return_dismissed_quantity = utils_1.MathBN.sub(existing.detail.return_dismissed_quantity, action.details.quantity);
|
34
|
-
existing.detail.return_requested_quantity = utils_1.MathBN.add(existing.detail.return_requested_quantity, action.details.quantity);
|
35
|
-
if (previousEvents) {
|
36
|
-
for (const previousEvent of previousEvents) {
|
37
|
-
if (!previousEvent.original_) {
|
38
|
-
continue;
|
39
|
-
}
|
40
|
-
previousEvent.details = JSON.parse(JSON.stringify(previousEvent.original_.details));
|
41
|
-
delete previousEvent.original_;
|
42
|
-
previousEvent.status = _types_1.EVENT_STATUS.PENDING;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
},
|
46
20
|
validate({ action, currentOrder }) {
|
47
21
|
const refId = action.details?.reference_id;
|
48
22
|
if (!(0, utils_1.isDefined)(refId)) {
|
@@ -50,7 +24,7 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.C
|
|
50
24
|
}
|
51
25
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
52
26
|
if (!existing) {
|
53
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
27
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Item ID "${refId}" not found.`);
|
54
28
|
}
|
55
29
|
if (!action.details?.quantity) {
|
56
30
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to return of item ${refId} is required.`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"receive-damaged-return-item.js","sourceRoot":"","sources":["../../../src/utils/actions/receive-damaged-return-item.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"receive-damaged-return-item.js","sourceRoot":"","sources":["../../../src/utils/actions/receive-damaged-return-item.ts"],"names":[],"mappings":";;AAAA,2CAKwB;AACxB,sEAAiE;AACjE,kEAA4D;AAE5D,8CAAqB,CAAC,kBAAkB,CACtC,wBAAgB,CAAC,2BAA2B,EAC5C;IACE,WAAW,EAAE,IAAI;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE;QACzD,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CAAC,YAAY,CACjD,CAAA;QAEF,IAAI,QAAQ,GAAG,MAAM,CAAC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E,CAAC;YACd,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,YAAY,KAAK,cAAc,CAChC,CAAA;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,8BAA8B,KAAK,eAAe,CACnD,CAAA;QACH,CAAC;QAED,MAAM,iBAAiB,GAAG,QAAQ,EAAE,MAAM,CAAC,yBAAyB,IAAI,CAAC,CAAA;QACzE,IAAI,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,iBAAiB,EAAE,CAAC;YACjD,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,6EAA6E,KAAK,GAAG,CACtF,CAAA;QACH,CAAC;IACH,CAAC;CACF,CACF,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"receive-return-item.d.ts","sourceRoot":"","sources":["../../../src/utils/actions/receive-return-item.ts"],"names":[],"mappings":""}
|
@@ -1,49 +1,20 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@medusajs/utils");
|
4
|
-
const _types_1 = require("../../types");
|
5
|
-
const action_key_1 = require("../action-key");
|
6
4
|
const calculate_order_change_1 = require("../calculate-order-change");
|
7
|
-
|
5
|
+
const set_action_reference_1 = require("../set-action-reference");
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.RECEIVE_RETURN_ITEM, {
|
8
7
|
isDeduction: true,
|
9
|
-
|
10
|
-
operation({ action, currentOrder, previousEvents }) {
|
11
|
-
var _a, _b;
|
8
|
+
operation({ action, currentOrder, previousEvents, options }) {
|
12
9
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
13
10
|
let toReturn = action.details.quantity;
|
14
|
-
|
15
|
-
|
11
|
+
existing.detail.return_received_quantity ??= 0;
|
12
|
+
existing.detail.return_requested_quantity ??= 0;
|
16
13
|
existing.detail.return_received_quantity = utils_1.MathBN.add(existing.detail.return_received_quantity, toReturn);
|
17
14
|
existing.detail.return_requested_quantity = utils_1.MathBN.sub(existing.detail.return_requested_quantity, toReturn);
|
18
|
-
|
19
|
-
for (const previousEvent of previousEvents) {
|
20
|
-
previousEvent.original_ = JSON.parse(JSON.stringify(previousEvent));
|
21
|
-
let ret = utils_1.MathBN.min(toReturn, previousEvent.details.quantity);
|
22
|
-
toReturn = utils_1.MathBN.sub(toReturn, ret);
|
23
|
-
previousEvent.details.quantity = utils_1.MathBN.sub(previousEvent.details.quantity, ret);
|
24
|
-
if (utils_1.MathBN.lte(previousEvent.details.quantity, 0)) {
|
25
|
-
previousEvent.status = _types_1.EVENT_STATUS.DONE;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
15
|
+
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
29
16
|
return utils_1.MathBN.mult(existing.unit_price, action.details.quantity);
|
30
17
|
},
|
31
|
-
revert({ action, currentOrder, previousEvents }) {
|
32
|
-
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
33
|
-
existing.detail.return_received_quantity = utils_1.MathBN.sub(existing.detail.return_received_quantity, action.details.quantity);
|
34
|
-
existing.detail.return_requested_quantity = utils_1.MathBN.add(existing.detail.return_requested_quantity, action.details.quantity);
|
35
|
-
if (previousEvents) {
|
36
|
-
for (const previousEvent of previousEvents) {
|
37
|
-
if (!previousEvent.original_) {
|
38
|
-
continue;
|
39
|
-
}
|
40
|
-
previousEvent.details = JSON.parse(JSON.stringify(previousEvent.original_.details));
|
41
|
-
(0, utils_1.transformPropertiesToBigNumber)(previousEvent.details?.metadata);
|
42
|
-
delete previousEvent.original_;
|
43
|
-
previousEvent.status = _types_1.EVENT_STATUS.PENDING;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
},
|
47
18
|
validate({ action, currentOrder }) {
|
48
19
|
const refId = action.details?.reference_id;
|
49
20
|
if (!(0, utils_1.isDefined)(refId)) {
|
@@ -51,7 +22,7 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.C
|
|
51
22
|
}
|
52
23
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
53
24
|
if (!existing) {
|
54
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
25
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Item ID "${refId}" not found.`);
|
55
26
|
}
|
56
27
|
if (!action.details?.quantity) {
|
57
28
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to receive return of item ${refId} is required.`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"receive-return-item.js","sourceRoot":"","sources":["../../../src/utils/actions/receive-return-item.ts"],"names":[],"mappings":";;AAAA,2CAKwB;AACxB,
|
1
|
+
{"version":3,"file":"receive-return-item.js","sourceRoot":"","sources":["../../../src/utils/actions/receive-return-item.ts"],"names":[],"mappings":";;AAAA,2CAKwB;AACxB,sEAAiE;AACjE,kEAA4D;AAE5D,8CAAqB,CAAC,kBAAkB,CAAC,wBAAgB,CAAC,mBAAmB,EAAE;IAC7E,WAAW,EAAE,IAAI;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE;QACzD,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CAAC,YAAY,CACjD,CAAA;QAEF,IAAI,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAA;QAEtC,QAAQ,CAAC,MAAM,CAAC,wBAAwB,KAAK,CAAC,CAAA;QAC9C,QAAQ,CAAC,MAAM,CAAC,yBAAyB,KAAK,CAAC,CAAA;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I,CAAC,CAAA;QAE1E,MAAM,OAAO,GAAG,cAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;QACtE,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,6EAA6E,KAAK,GAAG,CACtF,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"reinstate-item.d.ts","sourceRoot":"","sources":["../../../src/utils/actions/reinstate-item.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const utils_1 = require("@medusajs/utils");
|
4
|
+
const calculate_order_change_1 = require("../calculate-order-change");
|
5
|
+
const set_action_reference_1 = require("../set-action-reference");
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.REINSTATE_ITEM, {
|
7
|
+
operation({ action, currentOrder, options }) {
|
8
|
+
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
9
|
+
existing.detail.written_off_quantity ??= 0;
|
10
|
+
existing.detail.written_off_quantity = utils_1.MathBN.sub(existing.detail.written_off_quantity, action.details.quantity);
|
11
|
+
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
12
|
+
},
|
13
|
+
validate({ action, currentOrder }) {
|
14
|
+
const refId = action.details?.reference_id;
|
15
|
+
if (!(0, utils_1.isDefined)(refId)) {
|
16
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Details reference ID is required.");
|
17
|
+
}
|
18
|
+
const existing = currentOrder.items.find((item) => item.id === refId);
|
19
|
+
if (!existing) {
|
20
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Item ID "${refId}" not found.`);
|
21
|
+
}
|
22
|
+
if (!action.details?.quantity) {
|
23
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to reinstate item ${refId} is required.`);
|
24
|
+
}
|
25
|
+
const quantityAvailable = existing.quantity ?? 0;
|
26
|
+
const greater = utils_1.MathBN.gt(action.details?.quantity, quantityAvailable);
|
27
|
+
if (greater) {
|
28
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Cannot unclaim more items than what was ordered.");
|
29
|
+
}
|
30
|
+
},
|
31
|
+
});
|
32
|
+
//# sourceMappingURL=reinstate-item.js.map
|