feat(order): Claim and Exchange entities (#7681)

This commit is contained in:
Carlos R. L. Rodrigues
2024-06-12 14:49:15 -03:00
committed by GitHub
parent 85d487d90b
commit 75811cd4b3
18 changed files with 877 additions and 56 deletions
@@ -1,5 +1,5 @@
import { CreateOrderDTO, OrderDTO } from "@medusajs/types"
import { MathBN, MedusaError } from "@medusajs/utils"
import { MathBN, MedusaError, isPresent } from "@medusajs/utils"
import {
WorkflowData,
createWorkflow,
@@ -50,8 +50,16 @@ function prepareLineItems(data) {
}
function getOrderInput(data) {
const shippingAddress = data.input.shipping_address ?? { id: undefined }
delete shippingAddress.id
const billingAddress = data.input.billing_address ?? { id: undefined }
delete billingAddress.id
const data_ = {
...data.input,
shipping_address: isPresent(shippingAddress) ? shippingAddress : undefined,
billing_address: isPresent(billingAddress) ? billingAddress : undefined,
currency_code: data.input.currency_code ?? data.region.currency_code,
region_id: data.region.id,
}
+28
View File
@@ -53,3 +53,31 @@ export enum ReturnStatus {
*/
CANCELED = "canceled",
}
/**
* @enum
*
* The claim's type.
*/
export enum ClaimType {
/**
* The claim refunds an amount to the customer.
*/
REFUND = "refund",
/**
* The claim replaces the returned item with a new one.
*/
REPLACE = "replace",
}
/**
* @enum
*
* The claim's item reason.
*/
export enum ClaimReason {
MISSING_ITEM = "missing_item",
WRONG_ITEM = "wrong_item",
PRODUCTION_FAILURE = "production_failure",
OTHER = "other",
}