fix(fulfillment): make relationship between SO and SO type M:1 (#14061)
* fix(fulfillment): make relationship between SO and SO type M:1 * fix: test and types, remap type id to existing column * Fix typo * Fix typo * chore: update changeset * fix: typo --------- Co-authored-by: Nicolas Gorga <62995075+NicolasGorga@users.noreply.github.com>
This commit is contained in:
@@ -35,7 +35,6 @@ import {
|
||||
ModulesSdkUtils,
|
||||
promiseAll,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { isObject } from "@medusajs/utils"
|
||||
import {
|
||||
Fulfillment,
|
||||
FulfillmentProvider,
|
||||
@@ -1282,6 +1281,7 @@ export default class FulfillmentModuleService
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
|
||||
const existingShippingOptions = new Map(
|
||||
shippingOptions.map((s) => [s.id, s])
|
||||
)
|
||||
@@ -1295,15 +1295,15 @@ export default class FulfillmentModuleService
|
||||
const updatedRuleIds: string[] = []
|
||||
const existingRuleIds: string[] = []
|
||||
|
||||
const optionTypeDeletedIds: string[] = []
|
||||
|
||||
dataArray.forEach((shippingOption) => {
|
||||
const existingShippingOption = existingShippingOptions.get(
|
||||
shippingOption.id
|
||||
)! // Guaranteed to exist since the validation above have been performed
|
||||
|
||||
if (isObject(shippingOption.type) && !("id" in shippingOption.type)) {
|
||||
optionTypeDeletedIds.push(existingShippingOption.type.id)
|
||||
// `type_id` doesn't exist on the entity/table, `type_id` argument is mapped to `shipping_option_type_id`
|
||||
if (shippingOption.type_id) {
|
||||
shippingOption.shipping_option_type_id = shippingOption.type_id
|
||||
delete shippingOption.type_id
|
||||
}
|
||||
|
||||
if (!shippingOption.rules) {
|
||||
|
||||
Reference in New Issue
Block a user