Feat/bulk operations for inventory service (#4503)

* initial push

* bulk delete reservations by location ids

* add method to interface (not implemented yet)

* bulk update

* delete reservations by location id bulk

* add create bulk for inventory item

* refactor attach inventory item method

* add changeset

* verbose false

* method override instead of multiple methods

* change up method signature

* redo changes when updating interface

* update createInventoryLevel method

* rename variables

* fix feedback

* return correct string array when emitting event

* refactor inventory service

* redo order changes

* snapshot

* move prep methods
This commit is contained in:
Philip Korsholm
2023-07-18 11:17:57 +02:00
committed by GitHub
parent d440c834d3
commit d184d23c63
20 changed files with 1194 additions and 228 deletions
@@ -296,6 +296,104 @@ describe("Inventory Module", () => {
)
})
describe("updateInventoryLevel", () => {
it("should pass along the correct context when doing a bulk update", async () => {
const inventoryService = appContainer.resolve("inventoryService")
const inventoryItem = await inventoryService.createInventoryItem({
sku: "sku_1",
origin_country: "CH",
mid_code: "mid code",
material: "lycra",
weight: 100,
length: 200,
height: 50,
width: 50,
metadata: {
abc: 123,
},
hs_code: "hs_code 123",
requires_shipping: true,
})
await inventoryService.createInventoryLevel({
inventory_item_id: inventoryItem.id,
location_id: "location_123",
stocked_quantity: 50,
reserved_quantity: 0,
incoming_quantity: 0,
})
let error
try {
await inventoryService.updateInventoryLevels(
[
{
inventory_item_id: inventoryItem.id,
location_id: "location_123",
stocked_quantity: 25,
reserved_quantity: 4,
incoming_quantity: 10,
},
],
{
transactionManager: {},
}
)
} catch (e) {
error = e
}
expect(error.message).toEqual("manager.getRepository is not a function")
})
it("should pass along the correct context when doing a single update", async () => {
const inventoryService = appContainer.resolve("inventoryService")
const inventoryItem = await inventoryService.createInventoryItem({
sku: "sku_1",
origin_country: "CH",
mid_code: "mid code",
material: "lycra",
weight: 100,
length: 200,
height: 50,
width: 50,
metadata: {
abc: 123,
},
hs_code: "hs_code 123",
requires_shipping: true,
})
await inventoryService.createInventoryLevel({
inventory_item_id: inventoryItem.id,
location_id: "location_123",
stocked_quantity: 50,
reserved_quantity: 0,
incoming_quantity: 0,
})
let error
try {
await inventoryService.updateInventoryLevel(
inventoryItem.id,
"location_123",
{
stocked_quantity: 25,
reserved_quantity: 4,
incoming_quantity: 10,
},
{
transactionManager: {},
}
)
} catch (e) {
error = e
}
expect(error.message).toEqual("manager.getRepository is not a function")
})
})
it("deleteInventoryLevel", async () => {
const inventoryService = appContainer.resolve("inventoryService")