chore(): Reorganize modules (#7210)
**What** Move all modules to the modules directory
This commit is contained in:
committed by
GitHub
parent
7a351eef09
commit
4eae25e1ef
@@ -0,0 +1,5 @@
|
||||
describe("noop", function () {
|
||||
it("should run", function () {
|
||||
expect(true).toBe(true)
|
||||
})
|
||||
})
|
||||
2
packages/modules/inventory-next/src/services/index.ts
Normal file
2
packages/modules/inventory-next/src/services/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { default as InventoryModuleService } from "./inventory"
|
||||
export { default as InventoryLevelService } from "./inventory-level"
|
||||
@@ -0,0 +1,79 @@
|
||||
import {
|
||||
Context,
|
||||
CreateInventoryLevelInput,
|
||||
DAL,
|
||||
SharedContext,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
InjectTransactionManager,
|
||||
MedusaContext,
|
||||
ModulesSdkUtils,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
import { InventoryLevel } from "../models/inventory-level"
|
||||
import { InventoryLevelRepository } from "@repositories"
|
||||
|
||||
type InjectedDependencies = {
|
||||
inventoryLevelRepository: InventoryLevelRepository
|
||||
}
|
||||
|
||||
export default class InventoryLevelService<
|
||||
TEntity extends InventoryLevel = InventoryLevel
|
||||
> extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
|
||||
InventoryLevel
|
||||
)<TEntity> {
|
||||
protected readonly inventoryLevelRepository: InventoryLevelRepository
|
||||
|
||||
constructor(container: InjectedDependencies) {
|
||||
super(container)
|
||||
this.inventoryLevelRepository = container.inventoryLevelRepository
|
||||
}
|
||||
|
||||
async retrieveStockedQuantity(
|
||||
inventoryItemId: string,
|
||||
locationIds: string[] | string,
|
||||
context: Context = {}
|
||||
): Promise<number> {
|
||||
const locationIdArray = Array.isArray(locationIds)
|
||||
? locationIds
|
||||
: [locationIds]
|
||||
|
||||
return await this.inventoryLevelRepository.getStockedQuantity(
|
||||
inventoryItemId,
|
||||
locationIdArray,
|
||||
context
|
||||
)
|
||||
}
|
||||
|
||||
async getAvailableQuantity(
|
||||
inventoryItemId: string,
|
||||
locationIds: string[] | string,
|
||||
context: Context = {}
|
||||
): Promise<number> {
|
||||
const locationIdArray = Array.isArray(locationIds)
|
||||
? locationIds
|
||||
: [locationIds]
|
||||
|
||||
return await this.inventoryLevelRepository.getAvailableQuantity(
|
||||
inventoryItemId,
|
||||
locationIdArray,
|
||||
context
|
||||
)
|
||||
}
|
||||
|
||||
async getReservedQuantity(
|
||||
inventoryItemId: string,
|
||||
locationIds: string[] | string,
|
||||
context: Context = {}
|
||||
) {
|
||||
if (!Array.isArray(locationIds)) {
|
||||
locationIds = [locationIds]
|
||||
}
|
||||
|
||||
return await this.inventoryLevelRepository.getReservedQuantity(
|
||||
inventoryItemId,
|
||||
locationIds,
|
||||
context
|
||||
)
|
||||
}
|
||||
}
|
||||
1036
packages/modules/inventory-next/src/services/inventory.ts
Normal file
1036
packages/modules/inventory-next/src/services/inventory.ts
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user