feat(order): fulfillment workflow (#7385)

FIXES: CORE-2162 CORE-2167 CORE-2041
This commit is contained in:
Carlos R. L. Rodrigues authored and GitHub committed 2024-05-27 12:49:33 +00:00
1 parent 639758ffec
commit 62ef82f497
43 files changed
+1730 -195

No files matched your search

@@ -489,7 +489,6 @@ moduleIntegrationTestRunner({
await service.registerShipment({
order_id: createdOrder.id,
reference: Modules.FULFILLMENT,
shipping_method: createdOrder.shipping_methods![0].id,
items: createdOrder.items!.map((item) => {
return {
id: item.id,
@@ -2149,35 +2149,12 @@ export default class OrderModuleService<
): Promise<void> {
let shippingMethodId
if (!isString(data.shipping_method)) {
const methods = await this.createShippingMethods(
data.order_id,
data.shipping_method as any,
sharedContext
)
shippingMethodId = methods[0].id
} else {
shippingMethodId = data.shipping_method
}
const method = await this.shippingMethodService_.retrieve(
shippingMethodId,
{
relations: ["tax_lines", "adjustments"],
},
sharedContext
)
const calculatedAmount = getShippingMethodsTotals([method as any], {})[
method.id
]
const actions: CreateOrderChangeActionDTO[] = data.items.map((item) => {
return {
action: ChangeActionType.SHIP_ITEM,
internal_note: item.internal_note,
reference: data.reference,
reference_id: shippingMethodId,
reference_id: data.reference_id,
details: {
reference_id: item.id,
quantity: item.quantity,
@@ -2191,7 +2168,6 @@ export default class OrderModuleService<
action: ChangeActionType.SHIPPING_ADD,
reference: data.reference,
reference_id: shippingMethodId,
amount: calculatedAmount.total,
})
}