feat(core-flows, order): add workflow to create change order actions (#8056)
what: - adds workflow to create change order actions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { ChangeActionType } from "@medusajs/utils"
|
||||
import { OrderChangeEvent } from "../../../../types"
|
||||
import { ChangeActionType, calculateOrderChange } from "../../../../utils"
|
||||
import { calculateOrderChange } from "../../../../utils"
|
||||
|
||||
describe("Order Exchange - Actions", function () {
|
||||
const originalOrder = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ChangeActionType } from "@medusajs/utils"
|
||||
import { OrderChangeEvent } from "../../../../types"
|
||||
import { ChangeActionType, calculateOrderChange } from "../../../../utils"
|
||||
import { calculateOrderChange } from "../../../../utils"
|
||||
|
||||
describe("Order Return - Actions", function () {
|
||||
const originalOrder = {
|
||||
|
||||
@@ -3,8 +3,7 @@ import {
|
||||
CreateOrderChangeActionDTO,
|
||||
OrderTypes,
|
||||
} from "@medusajs/types"
|
||||
import { promiseAll } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../../utils"
|
||||
import { ChangeActionType, promiseAll } from "@medusajs/utils"
|
||||
|
||||
async function createOrderChange(
|
||||
service,
|
||||
|
||||
@@ -3,8 +3,7 @@ import {
|
||||
CreateOrderChangeActionDTO,
|
||||
OrderTypes,
|
||||
} from "@medusajs/types"
|
||||
import { promiseAll } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../../utils"
|
||||
import { ChangeActionType, promiseAll } from "@medusajs/utils"
|
||||
|
||||
async function createOrderChange(
|
||||
service,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Context, OrderTypes } from "@medusajs/types"
|
||||
import { ChangeActionType } from "../../utils"
|
||||
import { ChangeActionType } from "@medusajs/utils"
|
||||
|
||||
export async function cancelFulfillment(
|
||||
this: any,
|
||||
|
||||
@@ -3,8 +3,7 @@ import {
|
||||
CreateOrderChangeActionDTO,
|
||||
OrderTypes,
|
||||
} from "@medusajs/types"
|
||||
import { promiseAll } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../../utils"
|
||||
import { ChangeActionType, promiseAll } from "@medusajs/utils"
|
||||
|
||||
async function createOrderChange(
|
||||
service,
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
OrderTypes,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
ChangeActionType,
|
||||
ClaimType,
|
||||
ReturnStatus,
|
||||
getShippingMethodsTotals,
|
||||
@@ -12,7 +13,6 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { ClaimItem, OrderClaim, Return, ReturnItem } from "@models"
|
||||
import { OrderChangeType } from "@types"
|
||||
import { ChangeActionType } from "../../utils"
|
||||
|
||||
function createClaimAndReturnEntities(em, data, order) {
|
||||
const claimReference = em.create(OrderClaim, {
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
OrderTypes,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
ChangeActionType,
|
||||
ReturnStatus,
|
||||
getShippingMethodsTotals,
|
||||
isString,
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { ExchangeItem, OrderExchange, Return, ReturnItem } from "@models"
|
||||
import { OrderChangeType } from "@types"
|
||||
import { ChangeActionType } from "../../utils"
|
||||
|
||||
function createExchangeAndReturnEntities(em, data, order) {
|
||||
const exchangeReference = em.create(OrderExchange, {
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
OrderTypes,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
ChangeActionType,
|
||||
ReturnStatus,
|
||||
getShippingMethodsTotals,
|
||||
isDefined,
|
||||
@@ -12,7 +13,6 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { Return, ReturnItem } from "@models"
|
||||
import { OrderChangeType } from "@types"
|
||||
import { ChangeActionType } from "../../utils"
|
||||
|
||||
function createReturnReference(em, data, order) {
|
||||
return em.create(Return, {
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { Context, OrderTypes } from "@medusajs/types"
|
||||
import { MathBN, ReturnStatus, promiseAll } from "@medusajs/utils"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
ReturnStatus,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import { OrderChangeType } from "@types"
|
||||
import { ChangeActionType } from "../../utils"
|
||||
|
||||
function createReturnItems(data) {
|
||||
return data.items.map((item) => ({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Context, OrderTypes } from "@medusajs/types"
|
||||
import { ChangeActionType } from "../../utils"
|
||||
import { ChangeActionType } from "@medusajs/utils"
|
||||
|
||||
export async function registerFulfillment(
|
||||
this: any,
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
CreateOrderChangeActionDTO,
|
||||
OrderTypes,
|
||||
} from "@medusajs/types"
|
||||
import { ChangeActionType } from "../../utils"
|
||||
import { ChangeActionType } from "@medusajs/utils"
|
||||
|
||||
export async function registerShipment(
|
||||
this: any,
|
||||
|
||||
@@ -2233,6 +2233,7 @@ export default class OrderModuleService<
|
||||
includeActions: boolean,
|
||||
sharedContext?: Context
|
||||
): Promise<any> {
|
||||
orderChangeIds = deduplicate(orderChangeIds)
|
||||
const options = {
|
||||
select: [
|
||||
"id",
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
export enum ChangeActionType {
|
||||
CANCEL = "CANCEL",
|
||||
FULFILL_ITEM = "FULFILL_ITEM",
|
||||
CANCEL_ITEM_FULFILLMENT = "CANCEL_ITEM_FULFILLMENT",
|
||||
ITEM_ADD = "ITEM_ADD",
|
||||
ITEM_REMOVE = "ITEM_REMOVE",
|
||||
RECEIVE_DAMAGED_RETURN_ITEM = "RECEIVE_DAMAGED_RETURN_ITEM",
|
||||
RECEIVE_RETURN_ITEM = "RECEIVE_RETURN_ITEM",
|
||||
RETURN_ITEM = "RETURN_ITEM",
|
||||
CANCEL_RETURN_ITEM = "CANCEL_RETURN_ITEM",
|
||||
SHIPPING_ADD = "SHIPPING_ADD",
|
||||
SHIPPING_REMOVE = "SHIPPING_REMOVE",
|
||||
SHIP_ITEM = "SHIP_ITEM",
|
||||
WRITE_OFF_ITEM = "WRITE_OFF_ITEM",
|
||||
REINSTATE_ITEM = "REINSTATE_ITEM",
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
import { MathBN, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { MathBN, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import { ChangeActionType } from "@medusajs/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
|
||||
OrderChangeProcessing.registerActionType(ChangeActionType.CANCEL, {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { MathBN, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { MathBN, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { VirtualOrder } from "@types"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { MathBN, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { VirtualOrder } from "@types"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { MathBN, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { EVENT_STATUS } from "@types"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
transformPropertiesToBigNumber,
|
||||
} from "@medusajs/utils"
|
||||
import { EVENT_STATUS } from "@types"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { MathBN, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { MathBN, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { MathBN, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import { ChangeActionType, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import { setActionReference } from "../set-action-reference"
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import { ChangeActionType, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
|
||||
OrderChangeProcessing.registerActionType(ChangeActionType.SHIPPING_REMOVE, {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { MathBN, MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { ChangeActionType } from "../action-key"
|
||||
import {
|
||||
ChangeActionType,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
isDefined,
|
||||
} from "@medusajs/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import {
|
||||
setActionReference,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from "./action-key"
|
||||
export * from "./actions"
|
||||
export * from "./apply-order-changes"
|
||||
export * from "./calculate-order-change"
|
||||
|
||||
Reference in New Issue
Block a user