chore(core-flows): return fulfillment link (#8304)
This commit is contained in:
@@ -14,18 +14,18 @@ import {
|
||||
UpdateServiceZoneDTO,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
arrayDifference,
|
||||
deepEqualObj,
|
||||
EmitEvents,
|
||||
getSetDifference,
|
||||
InjectManager,
|
||||
InjectTransactionManager,
|
||||
isDefined,
|
||||
isPresent,
|
||||
isString,
|
||||
MedusaContext,
|
||||
MedusaError,
|
||||
ModulesSdkUtils,
|
||||
arrayDifference,
|
||||
deepEqualObj,
|
||||
getSetDifference,
|
||||
isDefined,
|
||||
isPresent,
|
||||
isString,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
@@ -617,9 +617,8 @@ export default class FulfillmentModuleService
|
||||
...fulfillmentRest
|
||||
} = fulfillment
|
||||
|
||||
let fulfillmentThirdPartyData!: any
|
||||
try {
|
||||
fulfillmentThirdPartyData =
|
||||
const providerResult =
|
||||
await this.fulfillmentProviderService_.createFulfillment(
|
||||
provider_id,
|
||||
fulfillmentData || {},
|
||||
@@ -630,7 +629,8 @@ export default class FulfillmentModuleService
|
||||
await this.fulfillmentService_.update(
|
||||
{
|
||||
id: fulfillment.id,
|
||||
data: fulfillmentThirdPartyData ?? {},
|
||||
data: providerResult.data ?? {},
|
||||
labels: providerResult.labels ?? [],
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
@@ -662,9 +662,8 @@ export default class FulfillmentModuleService
|
||||
sharedContext
|
||||
)
|
||||
|
||||
let fulfillmentThirdPartyData!: any
|
||||
try {
|
||||
fulfillmentThirdPartyData =
|
||||
const providerResult =
|
||||
await this.fulfillmentProviderService_.createReturn(
|
||||
fulfillment.provider_id,
|
||||
fulfillment as Record<any, any>
|
||||
@@ -672,7 +671,8 @@ export default class FulfillmentModuleService
|
||||
await this.fulfillmentService_.update(
|
||||
{
|
||||
id: fulfillment.id,
|
||||
data: fulfillmentThirdPartyData ?? {},
|
||||
data: providerResult.data ?? {},
|
||||
labels: providerResult.labels ?? [],
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ export * from "./order-cart"
|
||||
export * from "./order-fulfillment"
|
||||
export * from "./order-payment-collection"
|
||||
export * from "./order-promotion"
|
||||
export * from "./order-return-fulfillment"
|
||||
export * from "./product-sales-channel"
|
||||
export * from "./product-variant-inventory-item"
|
||||
export * from "./product-variant-price-set"
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { ModuleJoinerConfig } from "@medusajs/types"
|
||||
import { LINKS, Modules } from "@medusajs/utils"
|
||||
|
||||
export const ReturnFulfillment: ModuleJoinerConfig = {
|
||||
serviceName: LINKS.ReturnFulfillment,
|
||||
isLink: true,
|
||||
databaseConfig: {
|
||||
tableName: "return_fulfillment",
|
||||
idPrefix: "retful",
|
||||
},
|
||||
alias: [
|
||||
{
|
||||
name: ["return_fulfillment", "return_fulfillments"],
|
||||
args: {
|
||||
entity: "LinkReturnFulfillment",
|
||||
},
|
||||
},
|
||||
],
|
||||
primaryKeys: ["id", "return_id", "fulfillment_id"],
|
||||
relationships: [
|
||||
{
|
||||
serviceName: Modules.ORDER,
|
||||
primaryKey: "id",
|
||||
foreignKey: "return_id",
|
||||
alias: "return",
|
||||
args: {
|
||||
methodSuffix: "Returns",
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceName: Modules.FULFILLMENT,
|
||||
primaryKey: "id",
|
||||
foreignKey: "fulfillment_id",
|
||||
alias: "fulfillments",
|
||||
args: {
|
||||
methodSuffix: "Fulfillments",
|
||||
},
|
||||
},
|
||||
],
|
||||
extends: [
|
||||
{
|
||||
serviceName: Modules.ORDER,
|
||||
fieldAlias: {
|
||||
return_fulfillments: {
|
||||
path: "return_fulfillment_link.fulfillments",
|
||||
isList: true,
|
||||
},
|
||||
},
|
||||
relationship: {
|
||||
serviceName: LINKS.OrderFulfillment,
|
||||
primaryKey: "return_id",
|
||||
foreignKey: "id",
|
||||
alias: "return_fulfillment_link",
|
||||
isList: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
serviceName: Modules.FULFILLMENT,
|
||||
relationship: {
|
||||
serviceName: LINKS.OrderFulfillment,
|
||||
primaryKey: "fulfillment_id",
|
||||
foreignKey: "id",
|
||||
alias: "return_link",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user