feat(medusa): Create fulfillment with location (#2931)

* remove duplicate key from oas

* changeset

* initial suggestion for adding locations to fulfillments

* update migration

* re-add functionality for removing entire reservations

* fix tests

* add location when adjusting reserved inventory of a line_item

* add changest

* handle multiple reservations for a product in the same channel

* confirm inventory in stock location previous to creating the fulfillment

* fix tests after updating create-fulfillment to confirm inventory prior to creating fulfillment

* remove bugged code

* initial validation

* initial changes for review

* chekcpoint

* update validate inventory at location

* redo some unwanted changes

* typing

* update snapshots

* redo change for eslintrc

* add eslint disable

* re-order methods in interface

* assert no_notification

* iterate one time less

* add test for validation of correct inventory adjustments in case of no inventory service installation

* ensure correct adjustments for order cancellations

* remove comment

* fix tests

* fix but with coalescing

* remove location id from confirm inventory

* don't throw when adjusting reservations for a line item without reservations

* move reservation adjustments to the api

* add multiplication for updating a reservation quantity

* move inventory adjustments from the service layer to the api

* delete reservation if quantity is adjusted to 0

* rename updateReservation to updateReservationItem

* update dto fields

* reference the correct fields

* update with transaction

* add jsdocs

* force boolean cast

* context-ize cancel and create fulfillment transaction methods

* undo notification cast

* update with changes

* refactor withTransaction to variable

* use maps

* fix service mocks
This commit is contained in:
Philip Korsholm
2023-01-09 14:44:34 +01:00
committed by GitHub
parent 28bec599ae
commit 16716f5a4f
16 changed files with 546 additions and 86 deletions
@@ -51,6 +51,9 @@ export class Fulfillment extends BaseEntity {
@Column()
provider_id: string
@Column({ nullable: true, type: "text" })
location_id: string | null
@ManyToOne(() => FulfillmentProvider)
@JoinColumn({ name: "provider_id" })
provider: FulfillmentProvider
@@ -127,6 +130,10 @@ export class Fulfillment extends BaseEntity {
* description: "The id of the Fulfillment Provider responsible for handling the fulfillment"
* type: string
* example: manual
* location_id:
* description: "The id of the stock location the fulfillment will be shipped from"
* type: string
* example: sloc_01G8TJSYT9M6AVS5N4EMNFS1EK
* provider:
* description: Available if the relation `provider` is expanded.
* $ref: "#/components/schemas/FulfillmentProvider"