fix(medusa): Use get for creating fulfillments (#3498)
* use get * changeset * use set * add tests --------- Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Oliver Windall Juhl
parent
fe4b8feb7e
commit
0d1b63d773
@@ -114,8 +114,8 @@ export default async (req, res) => {
|
||||
await orderServiceTx.retrieve(id, {
|
||||
relations: ["fulfillments"],
|
||||
})
|
||||
const existingFulfillmentMap = new Map(
|
||||
existingFulfillments.map((fulfillment) => [fulfillment.id, fulfillment])
|
||||
const existingFulfillmentSet = new Set(
|
||||
existingFulfillments.map((fulfillment) => fulfillment.id)
|
||||
)
|
||||
|
||||
await orderServiceTx.createFulfillment(id, validatedBody.items, {
|
||||
@@ -137,7 +137,7 @@ export default async (req, res) => {
|
||||
pvInventoryService.withTransaction(transactionManager)
|
||||
|
||||
await updateInventoryAndReservations(
|
||||
fulfillments.filter((f) => !existingFulfillmentMap[f.id]),
|
||||
fulfillments.filter((f) => !existingFulfillmentSet.has(f.id)),
|
||||
{
|
||||
inventoryService: pvInventoryServiceTx,
|
||||
locationId: validatedBody.location_id,
|
||||
|
||||
Reference in New Issue
Block a user