chore(order): link order and payment collection (#7334)

This commit is contained in:
Carlos R. L. Rodrigues
2024-05-14 17:37:27 -03:00
committed by GitHub
parent 7a8937fcba
commit 70fd355e46
12 changed files with 161 additions and 80 deletions

View File

@@ -1,10 +1,10 @@
export * from "./cart-payment-collection"
export * from "./cart-promotion"
export * from "./fulfillment-set-location"
export * from "./order-payment-collection"
export * from "./order-promotion"
export * from "./order-region"
export * from "./product-sales-channel"
export * from "./product-shipping-profile"
export * from "./product-variant-inventory-item"
export * from "./product-variant-price-set"
export * from "./publishable-api-key-sales-channel"

View File

@@ -0,0 +1,64 @@
import { Modules } from "@medusajs/modules-sdk"
import { ModuleJoinerConfig } from "@medusajs/types"
import { LINKS } from "@medusajs/utils"
export const OrderPaymentCollection: ModuleJoinerConfig = {
serviceName: LINKS.OrderPaymentCollection,
isLink: true,
databaseConfig: {
tableName: "order_payment_collection",
idPrefix: "capaycol",
},
alias: [
{
name: ["order_payment_collection", "order_payment_collections"],
args: {
entity: "LinkOrderPaymentCollection",
},
},
],
primaryKeys: ["id", "order_id", "payment_collection_id"],
relationships: [
{
serviceName: Modules.ORDER,
primaryKey: "id",
foreignKey: "order_id",
alias: "order",
},
{
serviceName: Modules.PAYMENT,
primaryKey: "id",
foreignKey: "payment_collection_id",
alias: "payment_collection",
},
],
extends: [
{
serviceName: Modules.ORDER,
fieldAlias: {
payment_collections: {
path: "payment_collections_link.payment_collection",
isList: true,
},
},
relationship: {
serviceName: LINKS.OrderPaymentCollection,
primaryKey: "order_id",
foreignKey: "id",
alias: "payment_collections_link",
},
},
{
serviceName: Modules.PAYMENT,
fieldAlias: {
order: "order_link.order",
},
relationship: {
serviceName: LINKS.OrderPaymentCollection,
primaryKey: "payment_collection_id",
foreignKey: "id",
alias: "order_link",
},
},
],
}

View File

@@ -1,60 +0,0 @@
import { Modules } from "@medusajs/modules-sdk"
import { ModuleJoinerConfig } from "@medusajs/types"
import { LINKS } from "@medusajs/utils"
export const ProductShippingProfile: ModuleJoinerConfig = {
serviceName: LINKS.ProductShippingProfile,
isLink: true,
databaseConfig: {
tableName: "product_shipping_profile",
idPrefix: "psprof",
},
alias: [
{
name: "product_shipping_profile",
args: {
entity: "LinkProductShippingProfile",
},
},
],
primaryKeys: ["id", "product_id", "profile_id"],
relationships: [
{
serviceName: Modules.PRODUCT,
primaryKey: "id",
foreignKey: "product_id",
alias: "product",
},
{
serviceName: "shippingProfileService",
isInternalService: true,
primaryKey: "id",
foreignKey: "profile_id",
alias: "profile",
},
],
extends: [
{
serviceName: Modules.PRODUCT,
fieldAlias: {
profile: "shipping_profile.profile",
},
relationship: {
serviceName: LINKS.ProductShippingProfile,
primaryKey: "product_id",
foreignKey: "id",
alias: "shipping_profile",
},
},
{
serviceName: "shippingProfileService",
relationship: {
serviceName: LINKS.ProductShippingProfile,
isInternalService: true,
primaryKey: "profile_id",
foreignKey: "id",
alias: "product_link",
},
},
],
}