system.kanoa.inventory.addInventoryTransaction(inventoryTransactionInfo, userId)
Adds a new inventory transaction record, adjusting the on-hand inventory balance for the affected part and inventory asset (bin/location) by the given quantity.
Passing an inventoryTransactionId inside inventoryTransactionInfo updates the existing record instead of inserting a new one; omit it (or pass None) to insert.
Typical uses include recording receipts, issues, transfers, and adjustments against a part's stock.
Parameters
inventoryTransactionInfo Dictionary
| - assetId | Integer | Not required. Physical asset the part was used on. |
| - costCenterId | Integer | Not required. |
| - inventoryAssetId | Integer | Required for insert. |
| - inventoryTransactionId | Integer | Not required. Pass to update existing record. |
| - inventoryTransactionTypeId | Integer | Required for insert. |
| - notes | String | Not required. |
| - partId | Integer | Required for insert. |
| - quantity | Float | Required for insert. Must be > 0. |
| - referenceNumber | String | Not required. e.g. 'PO 1234' |
| - referenceType | String | Not required. e.g. 'PO', 'WO' |
| - sourceRecordId | Integer | Not required. For automated processes only. |
| - sourceSchemaName | String | Not required. For automated processes only. |
| - sourceTableName | String | Not required. For automated processes only. |
| - supplierId | Integer | Not required. |
| - unitCost | Float | Not required. |
userId Integer:Id of the user executing the function
Returns
inventoryTransactionId Integer
message String None if success
Example
inventoryTransactionInfo = {
'inventoryAssetId': 42,
'inventoryTransactionTypeId': 1,
'partId': 1057,
'quantity': 25.0,
'unitCost': 4.35,
'referenceType': 'PO',
'referenceNumber': 'PO 1234',
'supplierId': 8,
'notes': 'Receipt against purchase order for stockroom replenishment'
}
userId = system.kanoa.security.getIDPUserId({'userName': 'SYSTEM'})
inventoryTransactionId, message = system.kanoa.inventory.addInventoryTransaction(inventoryTransactionInfo, userId)
print inventoryTransactionId, message