@medusajs/order 0.1.3-snapshot-20240718073308 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +8 -6
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/dist/joiner-config.d.ts +5 -0
- package/dist/joiner-config.js +36 -0
- package/dist/joiner-config.js.map +1 -0
- package/dist/migrations/Migration20240219102530.d.ts +0 -1
- package/dist/migrations/Migration20240219102530.js +4 -38
- package/dist/migrations/Migration20240219102530.js.map +1 -1
- package/dist/models/address.d.ts +1 -2
- package/dist/models/adjustment-line.d.ts +1 -3
- package/dist/models/adjustment-line.js +0 -5
- package/dist/models/adjustment-line.js.map +1 -1
- package/dist/models/index.d.ts +0 -9
- package/dist/models/index.js +1 -17
- package/dist/models/index.js.map +1 -1
- package/dist/models/line-item-adjustment.d.ts +1 -3
- 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 +1 -3
- 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 +1 -3
- package/dist/models/line-item.js +4 -18
- package/dist/models/line-item.js.map +1 -1
- package/dist/models/order-change-action.d.ts +4 -15
- package/dist/models/order-change-action.js +7 -102
- package/dist/models/order-change-action.js.map +1 -1
- package/dist/models/order-change.d.ts +5 -17
- package/dist/models/order-change.js +4 -109
- package/dist/models/order-change.js.map +1 -1
- package/dist/models/order-item.d.ts +4 -5
- 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 +4 -14
- package/dist/models/order-shipping-method.js +13 -89
- package/dist/models/order-shipping-method.js.map +1 -1
- package/dist/models/order-summary.d.ts +2 -6
- package/dist/models/order-summary.js +6 -9
- package/dist/models/order-summary.js.map +1 -1
- package/dist/models/order.d.ts +4 -6
- package/dist/models/order.js +1 -11
- package/dist/models/order.js.map +1 -1
- package/dist/models/shipping-method-adjustment.d.ts +1 -3
- 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 +1 -3
- 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 +0 -2
- package/dist/models/shipping-method.js +4 -17
- package/dist/models/shipping-method.js.map +1 -1
- package/dist/models/tax-line.d.ts +0 -2
- package/dist/models/tax-line.js +0 -7
- package/dist/models/tax-line.js.map +1 -1
- package/dist/models/transaction.d.ts +3 -15
- package/dist/models/transaction.js +4 -109
- package/dist/models/transaction.js.map +1 -1
- package/dist/module-definition.d.ts +2 -0
- package/dist/module-definition.js +59 -0
- package/dist/module-definition.js.map +1 -0
- package/dist/repositories/index.d.ts +1 -4
- package/dist/repositories/index.js +16 -7
- package/dist/repositories/index.js.map +1 -1
- package/dist/repositories/order.d.ts +3 -1
- package/dist/repositories/order.js +85 -2
- package/dist/repositories/order.js.map +1 -1
- package/dist/scripts/bin/run-seed.d.ts +3 -0
- package/dist/scripts/bin/run-seed.js +49 -0
- package/dist/scripts/bin/run-seed.js.map +1 -0
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +3 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/order-change-service.d.ts +15 -0
- package/dist/services/order-change-service.js +96 -0
- package/dist/services/order-change-service.js.map +1 -0
- package/dist/services/order-module-service.d.ts +67 -138
- package/dist/services/order-module-service.js +240 -990
- package/dist/services/order-module-service.js.map +1 -1
- package/dist/services/order-service.d.ts +4 -5
- package/dist/services/order-service.js +1 -1
- package/dist/services/order-service.js.map +1 -1
- package/dist/types/address.d.ts +0 -1
- package/dist/types/index.d.ts +1 -3
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/line-item-adjustment.d.ts +0 -1
- package/dist/types/line-item-tax-line.d.ts +0 -1
- package/dist/types/line-item.d.ts +0 -1
- package/dist/types/order-detail.d.ts +1 -2
- package/dist/types/order.d.ts +2 -3
- package/dist/types/shipping-method-adjustment.d.ts +0 -1
- package/dist/types/shipping-method-tax-line.d.ts +0 -1
- package/dist/types/shipping-method.d.ts +0 -4
- package/dist/types/tax-line.d.ts +0 -1
- package/dist/types/transaction.d.ts +0 -1
- package/dist/types/utils/index.d.ts +11 -43
- package/dist/types/utils/index.js.map +1 -1
- package/dist/utils/action-key.d.ts +13 -0
- package/dist/utils/action-key.js +18 -0
- package/dist/utils/action-key.js.map +1 -0
- package/dist/utils/actions/cancel-return.d.ts +0 -1
- package/dist/utils/actions/cancel-return.js +6 -7
- package/dist/utils/actions/cancel-return.js.map +1 -1
- package/dist/utils/actions/cancel.d.ts +0 -1
- package/dist/utils/actions/cancel.js +2 -2
- package/dist/utils/actions/cancel.js.map +1 -1
- package/dist/utils/actions/fulfill-item.d.ts +0 -1
- package/dist/utils/actions/fulfill-item.js +6 -7
- package/dist/utils/actions/fulfill-item.js.map +1 -1
- package/dist/utils/actions/index.d.ts +0 -4
- package/dist/utils/actions/index.js +0 -3
- package/dist/utils/actions/index.js.map +1 -1
- package/dist/utils/actions/item-add.d.ts +0 -1
- package/dist/utils/actions/item-add.js +14 -17
- package/dist/utils/actions/item-add.js.map +1 -1
- package/dist/utils/actions/item-remove.d.ts +0 -1
- package/dist/utils/actions/item-remove.js +10 -11
- package/dist/utils/actions/item-remove.js.map +1 -1
- package/dist/utils/actions/receive-damaged-return-item.d.ts +0 -1
- package/dist/utils/actions/receive-damaged-return-item.js +7 -8
- package/dist/utils/actions/receive-damaged-return-item.js.map +1 -1
- package/dist/utils/actions/receive-return-item.d.ts +0 -1
- package/dist/utils/actions/receive-return-item.js +7 -8
- package/dist/utils/actions/receive-return-item.js.map +1 -1
- package/dist/utils/actions/return-item.d.ts +0 -1
- package/dist/utils/actions/return-item.js +8 -9
- package/dist/utils/actions/return-item.js.map +1 -1
- package/dist/utils/actions/ship-item.d.ts +0 -1
- package/dist/utils/actions/ship-item.js +6 -7
- package/dist/utils/actions/ship-item.js.map +1 -1
- package/dist/utils/actions/shipping-add.d.ts +0 -1
- package/dist/utils/actions/shipping-add.js +7 -16
- package/dist/utils/actions/shipping-add.js.map +1 -1
- package/dist/utils/actions/write-off-item.d.ts +0 -1
- package/dist/utils/actions/write-off-item.js +6 -7
- package/dist/utils/actions/write-off-item.js.map +1 -1
- package/dist/utils/calculate-order-change.d.ts +2 -11
- package/dist/utils/calculate-order-change.js +70 -68
- package/dist/utils/calculate-order-change.js.map +1 -1
- package/dist/utils/index.d.ts +1 -4
- package/dist/utils/index.js +1 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/transform-order.d.ts +2 -4
- package/dist/utils/transform-order.js +17 -131
- package/dist/utils/transform-order.js.map +1 -1
- package/package.json +14 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/migrations/Migration20240219102530.d.ts.map +0 -1
- package/dist/migrations/Migration20240604100512.d.ts +0 -5
- package/dist/migrations/Migration20240604100512.d.ts.map +0 -1
- package/dist/migrations/Migration20240604100512.js +0 -364
- package/dist/migrations/Migration20240604100512.js.map +0 -1
- package/dist/migrations/Migration20240715102100.d.ts +0 -5
- package/dist/migrations/Migration20240715102100.d.ts.map +0 -1
- package/dist/migrations/Migration20240715102100.js +0 -15
- package/dist/migrations/Migration20240715102100.js.map +0 -1
- package/dist/migrations/Migration20240715174100.d.ts +0 -5
- package/dist/migrations/Migration20240715174100.d.ts.map +0 -1
- package/dist/migrations/Migration20240715174100.js +0 -21
- package/dist/migrations/Migration20240715174100.js.map +0 -1
- package/dist/migrations/Migration20240716081800.d.ts +0 -5
- package/dist/migrations/Migration20240716081800.d.ts.map +0 -1
- package/dist/migrations/Migration20240716081800.js +0 -67
- package/dist/migrations/Migration20240716081800.js.map +0 -1
- package/dist/models/address.d.ts.map +0 -1
- package/dist/models/adjustment-line.d.ts.map +0 -1
- package/dist/models/claim-item-image.d.ts +0 -19
- package/dist/models/claim-item-image.d.ts.map +0 -1
- package/dist/models/claim-item-image.js +0 -109
- package/dist/models/claim-item-image.js.map +0 -1
- package/dist/models/claim-item.d.ts +0 -29
- package/dist/models/claim-item.d.ts.map +0 -1
- package/dist/models/claim-item.js +0 -156
- package/dist/models/claim-item.js.map +0 -1
- package/dist/models/claim.d.ts +0 -36
- package/dist/models/claim.d.ts.map +0 -1
- package/dist/models/claim.js +0 -195
- package/dist/models/claim.js.map +0 -1
- package/dist/models/exchange-item.d.ts +0 -24
- package/dist/models/exchange-item.d.ts.map +0 -1
- package/dist/models/exchange-item.js +0 -138
- package/dist/models/exchange-item.js.map +0 -1
- package/dist/models/exchange.d.ts +0 -34
- package/dist/models/exchange.d.ts.map +0 -1
- package/dist/models/exchange.js +0 -188
- package/dist/models/exchange.js.map +0 -1
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/line-item-adjustment.d.ts.map +0 -1
- package/dist/models/line-item-tax-line.d.ts.map +0 -1
- package/dist/models/line-item.d.ts.map +0 -1
- package/dist/models/order-change-action.d.ts.map +0 -1
- package/dist/models/order-change.d.ts.map +0 -1
- package/dist/models/order-item.d.ts.map +0 -1
- package/dist/models/order-shipping-method.d.ts.map +0 -1
- package/dist/models/order-summary.d.ts.map +0 -1
- package/dist/models/order.d.ts.map +0 -1
- package/dist/models/return-item.d.ts +0 -29
- package/dist/models/return-item.d.ts.map +0 -1
- package/dist/models/return-item.js +0 -170
- package/dist/models/return-item.js.map +0 -1
- package/dist/models/return-reason.d.ts +0 -21
- package/dist/models/return-reason.d.ts.map +0 -1
- package/dist/models/return-reason.js +0 -120
- package/dist/models/return-reason.js.map +0 -1
- package/dist/models/return.d.ts +0 -39
- package/dist/models/return.d.ts.map +0 -1
- package/dist/models/return.js +0 -216
- package/dist/models/return.js.map +0 -1
- package/dist/models/shipping-method-adjustment.d.ts.map +0 -1
- package/dist/models/shipping-method-tax-line.d.ts.map +0 -1
- package/dist/models/shipping-method.d.ts.map +0 -1
- package/dist/models/tax-line.d.ts.map +0 -1
- package/dist/models/transaction.d.ts.map +0 -1
- package/dist/repositories/claim.d.ts +0 -9
- package/dist/repositories/claim.d.ts.map +0 -1
- package/dist/repositories/claim.js +0 -11
- package/dist/repositories/claim.js.map +0 -1
- package/dist/repositories/exchange.d.ts +0 -9
- package/dist/repositories/exchange.d.ts.map +0 -1
- package/dist/repositories/exchange.js +0 -11
- package/dist/repositories/exchange.js.map +0 -1
- package/dist/repositories/index.d.ts.map +0 -1
- package/dist/repositories/order.d.ts.map +0 -1
- package/dist/repositories/return.d.ts +0 -9
- package/dist/repositories/return.d.ts.map +0 -1
- package/dist/repositories/return.js +0 -11
- package/dist/repositories/return.js.map +0 -1
- package/dist/services/actions/cancel-claim.d.ts +0 -3
- package/dist/services/actions/cancel-claim.d.ts.map +0 -1
- package/dist/services/actions/cancel-claim.js +0 -107
- package/dist/services/actions/cancel-claim.js.map +0 -1
- package/dist/services/actions/cancel-exchange.d.ts +0 -3
- package/dist/services/actions/cancel-exchange.d.ts.map +0 -1
- package/dist/services/actions/cancel-exchange.js +0 -92
- package/dist/services/actions/cancel-exchange.js.map +0 -1
- package/dist/services/actions/cancel-fulfillment.d.ts +0 -3
- package/dist/services/actions/cancel-fulfillment.d.ts.map +0 -1
- package/dist/services/actions/cancel-fulfillment.js +0 -32
- package/dist/services/actions/cancel-fulfillment.js.map +0 -1
- package/dist/services/actions/cancel-return.d.ts +0 -3
- package/dist/services/actions/cancel-return.d.ts.map +0 -1
- package/dist/services/actions/cancel-return.js +0 -72
- package/dist/services/actions/cancel-return.js.map +0 -1
- package/dist/services/actions/create-claim.d.ts +0 -3
- package/dist/services/actions/create-claim.d.ts.map +0 -1
- package/dist/services/actions/create-claim.js +0 -228
- package/dist/services/actions/create-claim.js.map +0 -1
- package/dist/services/actions/create-exchange.d.ts +0 -3
- package/dist/services/actions/create-exchange.d.ts.map +0 -1
- package/dist/services/actions/create-exchange.js +0 -193
- package/dist/services/actions/create-exchange.js.map +0 -1
- package/dist/services/actions/create-return.d.ts +0 -3
- package/dist/services/actions/create-return.d.ts.map +0 -1
- package/dist/services/actions/create-return.js +0 -102
- package/dist/services/actions/create-return.js.map +0 -1
- package/dist/services/actions/index.d.ts +0 -11
- package/dist/services/actions/index.d.ts.map +0 -1
- package/dist/services/actions/index.js +0 -27
- package/dist/services/actions/index.js.map +0 -1
- package/dist/services/actions/receive-return.d.ts +0 -3
- package/dist/services/actions/receive-return.d.ts.map +0 -1
- package/dist/services/actions/receive-return.js +0 -73
- package/dist/services/actions/receive-return.js.map +0 -1
- package/dist/services/actions/register-fulfillment.d.ts +0 -3
- package/dist/services/actions/register-fulfillment.d.ts.map +0 -1
- package/dist/services/actions/register-fulfillment.js +0 -30
- package/dist/services/actions/register-fulfillment.js.map +0 -1
- package/dist/services/actions/register-shipment.d.ts +0 -3
- package/dist/services/actions/register-shipment.d.ts.map +0 -1
- package/dist/services/actions/register-shipment.js +0 -38
- package/dist/services/actions/register-shipment.js.map +0 -1
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/order-module-service.d.ts.map +0 -1
- package/dist/services/order-service.d.ts.map +0 -1
- package/dist/types/address.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/line-item-adjustment.d.ts.map +0 -1
- package/dist/types/line-item-tax-line.d.ts.map +0 -1
- package/dist/types/line-item.d.ts.map +0 -1
- package/dist/types/order-change.d.ts +0 -6
- package/dist/types/order-change.d.ts.map +0 -1
- package/dist/types/order-change.js +0 -3
- package/dist/types/order-change.js.map +0 -1
- package/dist/types/order-detail.d.ts.map +0 -1
- package/dist/types/order.d.ts.map +0 -1
- package/dist/types/shipping-method-adjustment.d.ts.map +0 -1
- package/dist/types/shipping-method-tax-line.d.ts.map +0 -1
- package/dist/types/shipping-method.d.ts.map +0 -1
- package/dist/types/tax-line.d.ts.map +0 -1
- package/dist/types/transaction.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/utils/actions/cancel-item-fulfillment.d.ts +0 -2
- package/dist/utils/actions/cancel-item-fulfillment.d.ts.map +0 -1
- package/dist/utils/actions/cancel-item-fulfillment.js +0 -39
- package/dist/utils/actions/cancel-item-fulfillment.js.map +0 -1
- package/dist/utils/actions/cancel-return.d.ts.map +0 -1
- package/dist/utils/actions/cancel.d.ts.map +0 -1
- package/dist/utils/actions/fulfill-item.d.ts.map +0 -1
- package/dist/utils/actions/index.d.ts.map +0 -1
- package/dist/utils/actions/item-add.d.ts.map +0 -1
- package/dist/utils/actions/item-remove.d.ts.map +0 -1
- package/dist/utils/actions/receive-damaged-return-item.d.ts.map +0 -1
- package/dist/utils/actions/receive-return-item.d.ts.map +0 -1
- package/dist/utils/actions/reinstate-item.d.ts +0 -2
- package/dist/utils/actions/reinstate-item.d.ts.map +0 -1
- package/dist/utils/actions/reinstate-item.js +0 -37
- package/dist/utils/actions/reinstate-item.js.map +0 -1
- package/dist/utils/actions/return-item.d.ts.map +0 -1
- package/dist/utils/actions/ship-item.d.ts.map +0 -1
- package/dist/utils/actions/shipping-add.d.ts.map +0 -1
- package/dist/utils/actions/shipping-remove.d.ts +0 -2
- package/dist/utils/actions/shipping-remove.d.ts.map +0 -1
- package/dist/utils/actions/shipping-remove.js +0 -41
- package/dist/utils/actions/shipping-remove.js.map +0 -1
- package/dist/utils/actions/write-off-item.d.ts.map +0 -1
- package/dist/utils/apply-order-changes.d.ts +0 -18
- package/dist/utils/apply-order-changes.d.ts.map +0 -1
- package/dist/utils/apply-order-changes.js +0 -95
- package/dist/utils/apply-order-changes.js.map +0 -1
- package/dist/utils/base-repository-find.d.ts +0 -3
- package/dist/utils/base-repository-find.d.ts.map +0 -1
- package/dist/utils/base-repository-find.js +0 -142
- package/dist/utils/base-repository-find.js.map +0 -1
- package/dist/utils/calculate-order-change.d.ts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/set-action-reference.d.ts +0 -3
- package/dist/utils/set-action-reference.d.ts.map +0 -1
- package/dist/utils/set-action-reference.js +0 -17
- package/dist/utils/set-action-reference.js.map +0 -1
- package/dist/utils/transform-order.d.ts.map +0 -1
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const
|
3
|
+
const action_key_1 = require("../action-key");
|
4
4
|
const calculate_order_change_1 = require("../calculate-order-change");
|
5
|
-
calculate_order_change_1.OrderChangeProcessing.registerActionType(
|
5
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.CANCEL, {
|
6
6
|
void: true,
|
7
7
|
});
|
8
8
|
//# sourceMappingURL=cancel.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/utils/actions/cancel.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/utils/actions/cancel.ts"],"names":[],"mappings":";;AAAA,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,MAAM,EAAE;IAChE,IAAI,EAAE,IAAI;CACX,CAAC,CAAA"}
|
@@ -1,19 +1,18 @@
|
|
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");
|
4
5
|
const calculate_order_change_1 = require("../calculate-order-change");
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.FULFILL_ITEM, {
|
7
|
+
operation({ action, currentOrder }) {
|
8
|
+
var _a;
|
8
9
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
9
|
-
existing.detail.fulfilled_quantity
|
10
|
+
(_a = existing.detail).fulfilled_quantity ?? (_a.fulfilled_quantity = 0);
|
10
11
|
existing.detail.fulfilled_quantity = utils_1.MathBN.add(existing.detail.fulfilled_quantity, action.details.quantity);
|
11
|
-
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
12
12
|
},
|
13
13
|
revert({ action, currentOrder }) {
|
14
14
|
const existing = currentOrder.items.find((item) => item.id === action.reference_id);
|
15
15
|
existing.detail.fulfilled_quantity = utils_1.MathBN.sub(existing.detail.fulfilled_quantity, action.details.quantity);
|
16
|
-
(0, set_action_reference_1.unsetActionReference)(existing, action);
|
17
16
|
},
|
18
17
|
validate({ action, currentOrder }) {
|
19
18
|
const refId = action.details?.reference_id;
|
@@ -22,7 +21,7 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.Change
|
|
22
21
|
}
|
23
22
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
24
23
|
if (!existing) {
|
25
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
24
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Reference ID "${refId}" not found.`);
|
26
25
|
}
|
27
26
|
if (!action.details?.quantity) {
|
28
27
|
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,2CAAgE;AAChE,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,YAAY,EAAE;IACtE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;;QAChC,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,MAAA,QAAQ,CAAC,MAAM,EAAC,kBA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,eAAe,CACpD,CAAA;SACF;QAED,IAAI,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,CAAC,EAAE;YAChC,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,oBAAoB,KAAK,0BAA0B,CACpD,CAAA;SACF;QAED,MAAM,YAAY,GAAG,cAAM,CAAC,GAAG,CAC7B,QAAQ,CAAC,QAAQ,EACjB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CACpC,CAAA;QACD,MAAM,OAAO,GAAG,cAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;QACjE,IAAI,OAAO,EAAE;YACX,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,4DAA4D,KAAK,GAAG,CACrE,CAAA;SACF;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
export * from "./cancel";
|
2
|
-
export * from "./cancel-item-fulfillment";
|
3
2
|
export * from "./cancel-return";
|
4
3
|
export * from "./fulfill-item";
|
5
4
|
export * from "./item-add";
|
@@ -9,6 +8,3 @@ export * from "./receive-return-item";
|
|
9
8
|
export * from "./return-item";
|
10
9
|
export * from "./ship-item";
|
11
10
|
export * from "./shipping-add";
|
12
|
-
export * from "./shipping-remove";
|
13
|
-
export * from "./write-off-item";
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
__exportStar(require("./cancel"), exports);
|
18
|
-
__exportStar(require("./cancel-item-fulfillment"), exports);
|
19
18
|
__exportStar(require("./cancel-return"), exports);
|
20
19
|
__exportStar(require("./fulfill-item"), exports);
|
21
20
|
__exportStar(require("./item-add"), exports);
|
@@ -25,6 +24,4 @@ __exportStar(require("./receive-return-item"), exports);
|
|
25
24
|
__exportStar(require("./return-item"), exports);
|
26
25
|
__exportStar(require("./ship-item"), exports);
|
27
26
|
__exportStar(require("./shipping-add"), exports);
|
28
|
-
__exportStar(require("./shipping-remove"), exports);
|
29
|
-
__exportStar(require("./write-off-item"), exports);
|
30
27
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,kDAA+B;AAC/B,iDAA8B;AAC9B,6CAA0B;AAC1B,gDAA6B;AAC7B,gEAA6C;AAC7C,wDAAqC;AACrC,gDAA6B;AAC7B,8CAA2B;AAC3B,iDAA8B"}
|
@@ -1,33 +1,28 @@
|
|
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");
|
4
5
|
const calculate_order_change_1 = require("../calculate-order-change");
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.ITEM_ADD, {
|
7
|
+
operation({ action, currentOrder }) {
|
8
|
+
var _a;
|
9
|
+
const existing = currentOrder.items.find((item) => item.id === action.reference_id);
|
9
10
|
if (existing) {
|
10
|
-
existing.detail.quantity
|
11
|
+
(_a = existing.detail).quantity ?? (_a.quantity = 0);
|
11
12
|
existing.quantity = utils_1.MathBN.add(existing.quantity, action.details.quantity);
|
12
13
|
existing.detail.quantity = utils_1.MathBN.add(existing.detail.quantity, action.details.quantity);
|
13
14
|
}
|
14
15
|
else {
|
15
|
-
|
16
|
-
id: action.
|
17
|
-
order_id: currentOrder.id,
|
18
|
-
return_id: action.return_id,
|
19
|
-
claim_id: action.claim_id,
|
20
|
-
exchange_id: action.exchange_id,
|
16
|
+
currentOrder.items.push({
|
17
|
+
id: action.reference_id,
|
21
18
|
unit_price: action.details.unit_price,
|
22
19
|
quantity: action.details.quantity,
|
23
|
-
};
|
24
|
-
currentOrder.items.push(existing);
|
20
|
+
});
|
25
21
|
}
|
26
|
-
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
27
22
|
return utils_1.MathBN.mult(action.details.unit_price, action.details.quantity);
|
28
23
|
},
|
29
24
|
revert({ action, currentOrder }) {
|
30
|
-
const existingIndex = currentOrder.items.findIndex((item) => item.id === action.
|
25
|
+
const existingIndex = currentOrder.items.findIndex((item) => item.id === action.reference_id);
|
31
26
|
if (existingIndex > -1) {
|
32
27
|
const existing = currentOrder.items[existingIndex];
|
33
28
|
existing.quantity = utils_1.MathBN.sub(existing.quantity, action.details.quantity);
|
@@ -35,11 +30,13 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.Change
|
|
35
30
|
if (utils_1.MathBN.lte(existing.quantity, 0)) {
|
36
31
|
currentOrder.items.splice(existingIndex, 1);
|
37
32
|
}
|
38
|
-
(0, set_action_reference_1.unsetActionReference)(existing, action);
|
39
33
|
}
|
40
34
|
},
|
41
35
|
validate({ action }) {
|
42
|
-
const refId = 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
|
+
}
|
43
40
|
if (!(0, utils_1.isDefined)(action.amount) && !(0, utils_1.isDefined)(action.details?.unit_price)) {
|
44
41
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Unit price of item ${refId} is required if no action.amount is provided.`);
|
45
42
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"item-add.js","sourceRoot":"","sources":["../../../src/utils/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AAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,oBAAoB,KAAK,eAAe,CACzC,CAAA;SACF;QAED,IAAI,cAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE;YAC1C,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,oBAAoB,KAAK,0BAA0B,CACpD,CAAA;SACF;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -1,45 +1,44 @@
|
|
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");
|
4
5
|
const calculate_order_change_1 = require("../calculate-order-change");
|
5
|
-
|
6
|
-
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.ITEM_REMOVE, {
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.ITEM_REMOVE, {
|
7
7
|
isDeduction: true,
|
8
|
-
operation({ action, currentOrder
|
9
|
-
|
8
|
+
operation({ action, currentOrder }) {
|
9
|
+
var _a;
|
10
|
+
const existingIndex = currentOrder.items.findIndex((item) => item.id === action.reference_id);
|
10
11
|
const existing = currentOrder.items[existingIndex];
|
11
|
-
existing.detail.quantity
|
12
|
+
(_a = existing.detail).quantity ?? (_a.quantity = 0);
|
12
13
|
existing.quantity = utils_1.MathBN.sub(existing.quantity, action.details.quantity);
|
13
14
|
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
20
|
revert({ action, currentOrder }) {
|
21
|
-
const existing = currentOrder.items.find((item) => item.id === action.
|
21
|
+
const existing = currentOrder.items.find((item) => item.id === action.reference_id);
|
22
22
|
if (existing) {
|
23
23
|
existing.quantity = utils_1.MathBN.add(existing.quantity, action.details.quantity);
|
24
24
|
existing.detail.quantity = utils_1.MathBN.add(existing.detail.quantity, action.details.quantity);
|
25
|
-
(0, set_action_reference_1.unsetActionReference)(existing, action);
|
26
25
|
}
|
27
26
|
else {
|
28
27
|
currentOrder.items.push({
|
29
|
-
id: action.
|
28
|
+
id: action.reference_id,
|
30
29
|
unit_price: action.details.unit_price,
|
31
30
|
quantity: action.details.quantity,
|
32
31
|
});
|
33
32
|
}
|
34
33
|
},
|
35
34
|
validate({ action, currentOrder }) {
|
36
|
-
const refId = action.
|
35
|
+
const refId = action.reference_id;
|
37
36
|
if (!(0, utils_1.isDefined)(refId)) {
|
38
37
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Reference ID is required.");
|
39
38
|
}
|
40
39
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
41
40
|
if (!existing) {
|
42
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
41
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Reference ID "${refId}" not found.`);
|
43
42
|
}
|
44
43
|
if (!(0, utils_1.isDefined)(action.amount) && !(0, utils_1.isDefined)(action.details?.unit_price)) {
|
45
44
|
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,2CAAgE;AAEhE,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,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AAM,CAAC,OAAO,EAAE,QAAQ,EAAE;YAC7B,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,oBAAoB,KAAK,eAAe,CACzC,CAAA;SACF;QAED,IAAI,cAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE;YAC1C,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,oBAAoB,KAAK,0BAA0B,CACpD,CAAA;SACF;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;YACX,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,sCAAsC,KAAK,GAAG,CAC/C,CAAA;SACF;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -2,19 +2,19 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@medusajs/utils");
|
4
4
|
const _types_1 = require("../../types");
|
5
|
+
const action_key_1 = require("../action-key");
|
5
6
|
const calculate_order_change_1 = require("../calculate-order-change");
|
6
|
-
|
7
|
-
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.RECEIVE_DAMAGED_RETURN_ITEM, {
|
7
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.RECEIVE_DAMAGED_RETURN_ITEM, {
|
8
8
|
isDeduction: true,
|
9
9
|
commitsAction: "return_item",
|
10
|
-
operation({ action, currentOrder, previousEvents
|
10
|
+
operation({ action, currentOrder, previousEvents }) {
|
11
|
+
var _a, _b;
|
11
12
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
12
13
|
let toReturn = action.details.quantity;
|
13
|
-
existing.detail.return_dismissed_quantity
|
14
|
-
existing.detail.return_requested_quantity
|
14
|
+
(_a = existing.detail).return_dismissed_quantity ?? (_a.return_dismissed_quantity = 0);
|
15
|
+
(_b = existing.detail).return_requested_quantity ?? (_b.return_requested_quantity = 0);
|
15
16
|
existing.detail.return_dismissed_quantity = utils_1.MathBN.add(existing.detail.return_dismissed_quantity, toReturn);
|
16
17
|
existing.detail.return_requested_quantity = utils_1.MathBN.sub(existing.detail.return_requested_quantity, toReturn);
|
17
|
-
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
18
18
|
if (previousEvents) {
|
19
19
|
for (const previousEvent of previousEvents) {
|
20
20
|
previousEvent.original_ = JSON.parse(JSON.stringify(previousEvent));
|
@@ -32,7 +32,6 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.Change
|
|
32
32
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
33
33
|
existing.detail.return_dismissed_quantity = utils_1.MathBN.sub(existing.detail.return_dismissed_quantity, action.details.quantity);
|
34
34
|
existing.detail.return_requested_quantity = utils_1.MathBN.add(existing.detail.return_requested_quantity, action.details.quantity);
|
35
|
-
(0, set_action_reference_1.unsetActionReference)(existing, action);
|
36
35
|
if (previousEvents) {
|
37
36
|
for (const previousEvent of previousEvents) {
|
38
37
|
if (!previousEvent.original_) {
|
@@ -51,7 +50,7 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.Change
|
|
51
50
|
}
|
52
51
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
53
52
|
if (!existing) {
|
54
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
53
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Reference ID "${refId}" not found.`);
|
55
54
|
}
|
56
55
|
if (!action.details?.quantity) {
|
57
56
|
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,2CAAgE;AAChE,mCAAqC;AACrC,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,CAAC,kBAAkB,CACtC,6BAAgB,CAAC,2BAA2B,EAC5C;IACE,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE;;QAChD,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,MAAA,QAAQ,CAAC,MAAM,EAAC,yBAAyB,QAAzB,yBAAyB,GAAK,CAAC,EAAA;QAC/C,MAAA,QAAQ,CAAC,MAAM,EAAC,yBAAyB,QAAzB,yBAAyB,GAAK,CAAC,EAAA;QAE/C,QAAQ,CAAC,MAAM,CAAC,yBAAyB,GAAG,cAAM,CAAC,GAAG,CACpD,QAAQ,CAAC,MAAM,CAAC,yBAAyB,EACzC,QAAQ,CACT,CAAA;QACD,QAAQ,CAAC,MAAM,CAAC,yBAAyB,GAAG,cAAM,CAAC,GAAG,CACpD,QAAQ,CAAC,MAAM,CAAC,yBAAyB,EACzC,QAAQ,CACT,CAAA;QAED,IAAI,cAAc,EAAE;YAClB,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE;gB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AC,KAAK,CAAC,YAAY,EAC9B,6EAA6E,KAAK,GAAG,CACtF,CAAA;SACF;IACH,CAAC;CACF,CACF,CAAA"}
|
@@ -2,19 +2,19 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@medusajs/utils");
|
4
4
|
const _types_1 = require("../../types");
|
5
|
+
const action_key_1 = require("../action-key");
|
5
6
|
const calculate_order_change_1 = require("../calculate-order-change");
|
6
|
-
|
7
|
-
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.RECEIVE_RETURN_ITEM, {
|
7
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.RECEIVE_RETURN_ITEM, {
|
8
8
|
isDeduction: true,
|
9
9
|
commitsAction: "return_item",
|
10
|
-
operation({ action, currentOrder, previousEvents
|
10
|
+
operation({ action, currentOrder, previousEvents }) {
|
11
|
+
var _a, _b;
|
11
12
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
12
13
|
let toReturn = action.details.quantity;
|
13
|
-
existing.detail.return_received_quantity
|
14
|
-
existing.detail.return_requested_quantity
|
14
|
+
(_a = existing.detail).return_received_quantity ?? (_a.return_received_quantity = 0);
|
15
|
+
(_b = existing.detail).return_requested_quantity ?? (_b.return_requested_quantity = 0);
|
15
16
|
existing.detail.return_received_quantity = utils_1.MathBN.add(existing.detail.return_received_quantity, toReturn);
|
16
17
|
existing.detail.return_requested_quantity = utils_1.MathBN.sub(existing.detail.return_requested_quantity, toReturn);
|
17
|
-
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
18
18
|
if (previousEvents) {
|
19
19
|
for (const previousEvent of previousEvents) {
|
20
20
|
previousEvent.original_ = JSON.parse(JSON.stringify(previousEvent));
|
@@ -32,7 +32,6 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.Change
|
|
32
32
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
33
33
|
existing.detail.return_received_quantity = utils_1.MathBN.sub(existing.detail.return_received_quantity, action.details.quantity);
|
34
34
|
existing.detail.return_requested_quantity = utils_1.MathBN.add(existing.detail.return_requested_quantity, action.details.quantity);
|
35
|
-
(0, set_action_reference_1.unsetActionReference)(existing, action);
|
36
35
|
if (previousEvents) {
|
37
36
|
for (const previousEvent of previousEvents) {
|
38
37
|
if (!previousEvent.original_) {
|
@@ -52,7 +51,7 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.Change
|
|
52
51
|
}
|
53
52
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
54
53
|
if (!existing) {
|
55
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
54
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Reference ID "${refId}" not found.`);
|
56
55
|
}
|
57
56
|
if (!action.details?.quantity) {
|
58
57
|
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,
|
1
|
+
{"version":3,"file":"receive-return-item.js","sourceRoot":"","sources":["../../../src/utils/actions/receive-return-item.ts"],"names":[],"mappings":";;AAAA,2CAKwB;AACxB,mCAAqC;AACrC,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,mBAAmB,EAAE;IAC7E,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE;;QAChD,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,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AED,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,CAAA;QAErE,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,iBAAiB,KAAK,cAAc,CACrC,CAAA;SACF;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE;YAC7B,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,sCAAsC,KAAK,eAAe,CAC3D,CAAA;SACF;QAED,MAAM,iBAAiB,GAAG,QAAQ,EAAE,MAAM,EAAE,yBAAyB,IAAI,CAAC,CAAA;QAE1E,MAAM,OAAO,GAAG,cAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;QACtE,IAAI,OAAO,EAAE;YACX,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,6EAA6E,KAAK,GAAG,CACtF,CAAA;SACF;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -1,22 +1,21 @@
|
|
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");
|
4
5
|
const calculate_order_change_1 = require("../calculate-order-change");
|
5
|
-
|
6
|
-
calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.RETURN_ITEM, {
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.RETURN_ITEM, {
|
7
7
|
isDeduction: true,
|
8
8
|
awaitRequired: true,
|
9
|
-
operation({ action, currentOrder
|
9
|
+
operation({ action, currentOrder }) {
|
10
|
+
var _a;
|
10
11
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
11
|
-
existing.detail.return_requested_quantity
|
12
|
+
(_a = existing.detail).return_requested_quantity ?? (_a.return_requested_quantity = 0);
|
12
13
|
existing.detail.return_requested_quantity = utils_1.MathBN.add(existing.detail.return_requested_quantity, action.details.quantity);
|
13
|
-
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
14
14
|
return utils_1.MathBN.mult(existing.unit_price, action.details.quantity);
|
15
15
|
},
|
16
16
|
revert({ action, currentOrder }) {
|
17
17
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
18
18
|
existing.detail.return_requested_quantity = utils_1.MathBN.sub(existing.detail.return_requested_quantity, action.details.quantity);
|
19
|
-
(0, set_action_reference_1.unsetActionReference)(existing, action);
|
20
19
|
},
|
21
20
|
validate({ action, currentOrder }) {
|
22
21
|
const refId = action.details?.reference_id;
|
@@ -25,15 +24,15 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.Change
|
|
25
24
|
}
|
26
25
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
27
26
|
if (!existing) {
|
28
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
27
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Reference ID "${refId}" not found.`);
|
29
28
|
}
|
30
29
|
if (!action.details?.quantity) {
|
31
30
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to return of item ${refId} is required.`);
|
32
31
|
}
|
33
|
-
const quantityAvailable = utils_1.MathBN.sub(existing.detail?.
|
32
|
+
const quantityAvailable = utils_1.MathBN.sub(existing.detail?.shipped_quantity ?? 0, existing.detail?.return_requested_quantity ?? 0);
|
34
33
|
const greater = utils_1.MathBN.gt(action.details?.quantity, quantityAvailable);
|
35
34
|
if (greater) {
|
36
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Cannot request to return more items than what was
|
35
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Cannot request to return more items than what was shipped for item ${refId}.`);
|
37
36
|
}
|
38
37
|
},
|
39
38
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"return-item.js","sourceRoot":"","sources":["../../../src/utils/actions/return-item.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"return-item.js","sourceRoot":"","sources":["../../../src/utils/actions/return-item.ts"],"names":[],"mappings":";;AAAA,2CAAgE;AAChE,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,WAAW,EAAE;IACrE,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,IAAI;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;;QAChC,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,MAAA,QAAQ,CAAC,MAAM,EAAC,yBAAyB,QAAzB,yBAAyB,GAAK,CAAC,EAAA;QAC/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,OAAO,cAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAClE,CAAC;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;QAC7B,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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ACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -1,19 +1,18 @@
|
|
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");
|
4
5
|
const calculate_order_change_1 = require("../calculate-order-change");
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.SHIP_ITEM, {
|
7
|
+
operation({ action, currentOrder }) {
|
8
|
+
var _a;
|
8
9
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
9
|
-
existing.detail.shipped_quantity
|
10
|
+
(_a = existing.detail).shipped_quantity ?? (_a.shipped_quantity = 0);
|
10
11
|
existing.detail.shipped_quantity = utils_1.MathBN.add(existing.detail.shipped_quantity, action.details.quantity);
|
11
|
-
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
12
12
|
},
|
13
13
|
revert({ action, currentOrder }) {
|
14
14
|
const existing = currentOrder.items.find((item) => item.id === action.reference_id);
|
15
15
|
existing.detail.shipped_quantity = utils_1.MathBN.sub(existing.detail.shipped_quantity, action.details.quantity);
|
16
|
-
(0, set_action_reference_1.unsetActionReference)(existing, action);
|
17
16
|
},
|
18
17
|
validate({ action, currentOrder }) {
|
19
18
|
const refId = action.details?.reference_id;
|
@@ -22,7 +21,7 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.Change
|
|
22
21
|
}
|
23
22
|
const existing = currentOrder.items.find((item) => item.id === refId);
|
24
23
|
if (!existing) {
|
25
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
24
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Reference ID "${refId}" not found.`);
|
26
25
|
}
|
27
26
|
if (!action.details?.quantity) {
|
28
27
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to ship of item ${refId} is required.`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ship-item.js","sourceRoot":"","sources":["../../../src/utils/actions/ship-item.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"ship-item.js","sourceRoot":"","sources":["../../../src/utils/actions/ship-item.ts"],"names":[],"mappings":";;AAAA,2CAAgE;AAChE,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,SAAS,EAAE;IACnE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;;QAChC,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,MAAA,QAAQ,CAAC,MAAM,EAAC,gBAAgB,QAAhB,gBAAgB,GAAK,CAAC,EAAA;QAEtC,QAAQ,CAAC,MAAM,CAAC,gBAAgB,GAAG,cAAM,CAAC,GAAG,CAC3C,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAChC,MAAM,CAAC,OAAO,CAAC,QAAQ,CACxB,CAAA;IACH,CAAC;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;QAC7B,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,YAAY,CACzC,CAAA;QAEF,QAAQ,CAAC,MAAM,CAAC,gBAAgB,GAAG,cAAM,CAAC,GAAG,CAC3C,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAChC,MAAM,CAAC,OAAO,CAAC,QAAQ,CACxB,CAAA;IACH,CAAC;IACD,QAAQ,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,EAAE,YAAY,CAAA;Q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Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@medusajs/utils");
|
4
|
+
const action_key_1 = require("../action-key");
|
4
5
|
const calculate_order_change_1 = require("../calculate-order-change");
|
5
|
-
|
6
|
-
|
7
|
-
operation({ action, currentOrder, options }) {
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.SHIPPING_ADD, {
|
7
|
+
operation({ action, currentOrder }) {
|
8
8
|
const shipping = Array.isArray(currentOrder.shipping_methods)
|
9
9
|
? currentOrder.shipping_methods
|
10
10
|
: [currentOrder.shipping_methods];
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
order_id: currentOrder.id,
|
16
|
-
return_id: action.return_id,
|
17
|
-
claim_id: action.claim_id,
|
18
|
-
exchange_id: action.exchange_id,
|
19
|
-
amount: action.amount,
|
20
|
-
};
|
21
|
-
shipping.push(existing);
|
22
|
-
}
|
23
|
-
(0, set_action_reference_1.setActionReference)(existing, action, options);
|
11
|
+
shipping.push({
|
12
|
+
id: action.reference_id,
|
13
|
+
price: action.amount,
|
14
|
+
});
|
24
15
|
currentOrder.shipping_methods = shipping;
|
25
16
|
},
|
26
17
|
revert({ action, currentOrder }) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"shipping-add.js","sourceRoot":"","sources":["../../../src/utils/actions/shipping-add.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"shipping-add.js","sourceRoot":"","sources":["../../../src/utils/actions/shipping-add.ts"],"names":[],"mappings":";;AAAA,2CAAwD;AACxD,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,YAAY,EAAE;IACtE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;QAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC;YAC3D,CAAC,CAAC,YAAY,CAAC,gBAA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