@livup/wms_module
v1.2.14
Published
LivUp Warehouse management system core - this node_module contains the basic schemas and methods for a WMS implementation
Downloads
279
Readme
livup-wms-module
├── project_root
├ ├── model
├ ├── schema
├ ├── test
├ ├── utils
├ ├── wms_module.js
├ ├── wms_error.js
├ ├── errorCodes.js
├ ├── .eslintrc
├ ├── .gitignore
├ ├── package.json
Running tests: npm test
Usage:
map: [[[]]] (variable according with the number of coordinates of the storage)
position: Object { x: Number, y: Number, z: Number} (variable according with the number of coordinates of the storage)
item: Object { itemCode: String (required)- item unique identifier, info: Object - generic info about the item, quantity: Number (required) - quantity stored }
WMSModule
- constructor
- parameters
├ ├──── mongoose (required)
├ ├──── storageModelName - String (required)
├ ├──── containerModelName - String (required)
├ ├──── storedCollectionName - String (required)
createStorageModel()
createContainerModel({position})
├ ├──── position - Object (required)
- createTransactionModel({transactionModelName})
├ ├──── position - Object (required)
Container
Container:
- addItems(items, code): add items array inside container identified by the code provided. If container already exists update it or creates a new one in database using code
├ ├──── items - [items]
├ ├──── code - String: container unique code identifier
- findOne({code}): returns a container matching code if exists
├ ├──── code - String: container unique code identifier
- removeItem(item, code): remove item from container identified by code
├ ├──── item - Object
├ ├──── code - String: container unique code identifier
- createInstance({ name, code, items, containerModelName })
├ ├──── name - String (required): unique name for container
├ ├──── code - String (required, unique): unique identifier for container
├ ├──── items - Object
├ ├──── containerModelName - Name of the model to be used to generate the instance.
Storage
- createInstance({name, code, containerModelName, positionCapacity, mapNumberOfCoordinates ,map}: creates a new Storage in database
├ ├──── name - String (required): unique name for storage
├ ├──── code - String (required, unique): unique identifier for storage
├ ├──── positionCapacity - Number (required): how many containers can be stored in a same position
├ ├──── mapNumberOfCoordinates - Number (required): number of coordinates used in map
├ ├──── map - [[containerModelName]]: map of stored containers identified by position
- findOne({code}): returns a storage matching code if exists
├ ├──── code - String: storage unique code identifier
- findOneAndPopulateMap({code}): returns a storage matching code if exists and populate map
├ ├──── code - String: storage unique code identifier
- checkIfPositionIsAvailable(containerId, position, storageCode) - check if a position is available inside storage
├ ├──── containerId - String : containerId you want to store
├ ├──── position - Object : position you want to check
├ ├──── storageCode - String: storage you want to check position
- addContainerToStorage(container, storageCode, position) - adds a container into a position
├ ├──── container: Object - container to store
├ ├──── storageCode: - String: storage unique code identifier
├ ├──── position: Object - position to store
- removeContainerFromStorage(container, storage)
├ ├──── container: Object - container you want to remove
├ ├──── storage: Object - storage that will have container removed
- getPositions({ items, storageCode }) - finds items inside storage and returns an array of containers found for each item
├ ├──── items: Array of Items you want to look for
├ ├──── storageCode: String - code of storage you are searching
Transaction
createTransactionModel() - Generate the base schema and models based on the given model names. It should be called after the model names were given.
AddTransaction({container, storage, info, quantity, item, status, kind}) - Creates a transaction on the transaction database.
├ ├──── container - Container object which is suffering the transaction
├ ├──── storage - Storage object which is suffering the transaction
├ ├──── info - Object that can hold any additional infomation needed.
├ ├──── quantity - Total amount this transaction registers. It uses positive values to add and negative to remove
├ ├──── item - : {ObjectId, Quantity}Item related to the transaction. It should hold the initial intended value of the transaction
├ ├──── status - String for use of the application
├ ├──── kind - Definition of the kind of transaction (redundant with the quantity signal, but easier to use for query)
Step-by-Step Example of use
The very first step is setting the name of the 3 kinds of models to be used. (containerModelName, storageModelName , storedCollectionName) for the container, storage and items respectively. This is done through the use creation of a WMSModule object with those names and the mongoose reference as parameters.
After the names are set we can create the models. The WMSModule has 3 main functions to do that: createStorageModel, createContainerModel, createTransactionModel.
The storage and the container ones return the models that can be used to instantiate the objects through the function createInstance.
The Transaction module make use of static methods to work. At anytime one can call addTransaction(whateverArguments) and the module generate the necessary transaction.
The instantiated stores and container are able to do several operations related to themselves and each other, please refer to the list above for a detailed explanation of each.
Extension of the operations can be done through the use of them as father class to any other new classes that are needed.