Inventory Management
Manage inventory items
Overview
DriverSdk provides order inventory management api to let the user report the quantity of items that were successfully collected and delivered on every order destination.
Inventory item list is provided by the DriverSdk for each destination via the waypoint model.
Inventory items should be marked as collected/delivered when the user is at the destination by calling the DriverSdk with the successfully collected/delivered quantity.
Inventory item-by-item approval may be enforced by the DriverSdk before leaving the destination, this behaviour is configured on Bringg Cloud Platform and applied automatically by the DriverSdk.
Every inventory item is represented by the Inventory model which exposes the amount of items that should be collected/delivered (4 cans of beer are represented as a single Inventory with Inventory.originalQuantity = 4)
When a user approves a collected/delivered quantity the DriverSdk will automatically mark any remaining quantity as rejected (Inventory.rejectedQuantity = Inventory.originalQuantity - Inventory.currentQuantity)
When items are not collected on a pickup destination the SDK will automatically reject the connected drop-off item and adjust the order pricing accordingly if needed.
Get the inventory list
Waypoint model holds a collection of all inventory items related to the destination.
Inventories may also have nested sub-inventory items (inventory.hasSubInventory() = TRUE).
Sub item collection is populated on the parent item (inventory.subInventory)
To get a list of a destination top-level inventories use:
DriverSdkProvider.driverSdk.data.waypoint(waypointId)).value?.inventories
The waypoint also expose a method that returns a flattened inventory list - all parent items and nested sub-items will be returned:
DriverSdkProvider.driverSdk.data.waypoint(waypointId)).value?.flattenedInventoryList
Driver inventory actions
In order to change quantities of inventories, the SDK exposes the DriverInventoryActions interface:
interface DriverInventoryActions {
fun incrementCurrentQuantity(inventoryId: Long): LiveData<InventoryIncrementQtyResult>
fun accept(inventoryId: Long, acceptedQuantity: Int): LiveData<InventoryQtyChangeResult>
}
Increment inventory quantity
A convenience function to increase the quantity of a specific inventory by one.
Code Sample:
driverSdk.inventory.incrementCurrentQuantity(inventory.id)
Parameters
inventoryId long NOT NULLABLE |
the unique id of the inventory item |
LiveData
A sealed class containing the quantity increment request results.
Results can be one of the following options:
Success Result |
inventory Inventory Model NOT NULLABLE |
Returns the invntory model on success. On success driverSdk.data.taskList will post the entire task list including the update task driverSdk.data.task will post the updated task to active observers and driverSdk.data.waypoint will post the updated waypoint to active observers |
---|---|---|
ItemFullyApplied Result |
inventory Inventory Model NULLABLE |
Returns the invntory model on success. |
Error Result |
error ErrorCode NOT NULLABLE inventory Inventory Model NULLABLE |
In case of failure, contains one of the following error codes ErrorCode May also return the invntory on some of the relevant errors |
InventoryIncrementQtyResult Errors
NOT_LOGGED_IN |
see Authenticaction |
NOT_ONLINE |
the user has to be online to perform any task actions, see Shifts |
TASK_NOT_FOUND |
the task associated with this item is not available to the user anymore |
WAYPOINT_NOT_FOUND |
the waypint associated with this item is not available to the user anymore |
ITEM_NOT_FOUND |
no item with the provided id is assigned to this user |
Accept inventory quantity
To Accept the quantity of a specific inventory you can use the accept function.
Code Sample:
DriverSdkProvider.driverSdk().inventory.accept(item.id, item.originalQuantity).observe(this, this)
Parameters
inventoryId long NOT NULLABLE |
the unique id of the inventory item |
acceptedQuantity int NOT NULLABLE |
Quantity to accept |
LiveData
A sealed class containing the quantity change request results
Results can be one of the following options:
Success Result |
inventory Inventory Model NOT NULLABLE |
Returns the invntory model on success. On success driverSdk.data.taskList will post the entire task list including the update task driverSdk.data.task will post the updated task to active observers and driverSdk.data.waypoint will post the updated waypoint to active observers |
---|---|---|
Error Result |
error ErrorCode NOT NULLABLE inventory Inventory Model NULLABLE |
In case of failure, contains one of the following error codes ErrorCode May also return the invntory on some of the relevant errors |
InventoryIncrementQtyResult Errors
NOT_LOGGED_IN |
see Authenticaction |
NOT_ONLINE |
the user has to be online to perform any task actions, see Shifts |
TASK_NOT_FOUND |
the task associated with this item is not available to the user anymore |
ITEM_NOT_FOUND |
no item with the provided id is assigned to this user |
INVALID_QUANTITY |
valid quantity should be greater or equal to 0 and smaller than inventory.originalQuantity |
NO_CHANGES_FOUND |
this quantity is already applied on this item |
Driver inventory Scan actions
In several use cases, especially in the logistics world, inventory management is being done via different types and scenarios of barcode scanning.
The driver SDK exposed several APIs that will help you implement inventory management by scanning a barcode.
interface InventoryScanActions {
fun findFirstRemainingItem(waypointId: Long, scanData: ScanData, scanOptions: InventoryScanOptions): LiveData<FindInventoryScanResult>
fun markItemScanned(inventoryId: Long, scanData: ScanData, scanOptions: InventoryScanOptions): LiveData<DriverScanResult>
fun createInventory(inventoryBuilder: InventoryBuilder, scanData: ScanData): LiveData<CreateInventoryScanResult>
}
Find inventory item for a scan string
Use this function to find the first inventory item for a scan string input.
Example:
driverSdk.scan.inventory.findFirstRemainingItem(waypointId, scanData, InventoryScanOptions())
Parameters
waypointId long NOT NULLABLE |
the unique id of the waypoint for this inventory update |
scanData ScanData NOT NULLABLE |
A class that contains information about the scan like scan string, or if the scan was taken from camera by the driver or it was entered by manual input (keyboard) |
scanOptions InventoryScanOptions NOT NULLABLE |
SDK scan logic can be configuration |
LiveData
A sealed class containing the inventory request results.
Results can be one of the following options:
Success Result |
inventory Inventory Model NOT NULLABLE |
Returns the invntory model on success. |
Error Result |
error ErrorCode NOT NULLABLE |
In case of failure, contains one of the following error codes ErrorCode |
---|---|---|
DifferentDestination Result |
task Task Model NOT NULLABLE waypoint Waypoint Model NOT NULLABLE inventory Inventory Model NOT NULLABLE |
In case scanned item belongs to a different location. |
Mark inventory items as scanned
Marking a specific inventory item as scanned.
driverSdk.scan.inventory.markItemScanned(inventoryItemId, scanData, InventoryScanOptions())
Parameters
inventoryId long NOT NULLABLE |
the unique id of the inventory |
scanData ScanData NOT NULLABLE |
A class that contains information about the scan like scan string, or if the scan was taken from camera by the driver or it was entered by manual input (keyboard) |
scanOptions InventoryScanOptions NOT NULLABLE |
SDK scan logic can be configuration |
LiveData
Success Result |
inventory Inventory Model NOT NULLABLE |
Returns the invntory model on success. |
---|---|---|
InvalidItemScan Result |
inventory Inventory Model NOT NULLABLE |
In case scanned item belongs to a different location. |
ItemAlreadyScanned Result |
inventory Inventory Model NOT NULLABLE |
In case scanned item was already scanned |
Error Result |
error ErrorCode NOT NULLABLE |
In case of failure, contains one of the following error codes ErrorCode |
Updated over 3 years ago