feat(types,fulfillment): ability to delete a canceled fulfillment (#10602)

This commit is contained in:
Riqwan Thamir
2024-12-16 11:17:45 +01:00
committed by GitHub
parent 7c773fc108
commit 90ad2566fd
4 changed files with 103 additions and 2 deletions
@@ -653,6 +653,28 @@ export default class FulfillmentModuleService
)
}
@InjectManager()
@EmitEvents()
async deleteFulfillment(
id: string,
@MedusaContext() sharedContext: Context = {}
): Promise<void> {
const fulfillment = await this.fulfillmentService_.retrieve(
id,
{},
sharedContext
)
if (!isPresent(fulfillment.canceled_at)) {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`Fulfillment with id ${fulfillment.id} needs to be canceled first before deleting`
)
}
await this.fulfillmentService_.delete(id, sharedContext)
}
@InjectManager()
@EmitEvents()
async createReturnFulfillment(