Skip to main content

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

- assetIdIntegerNot required. Physical asset the part was used on.
- costCenterIdIntegerNot required.
- inventoryAssetIdIntegerRequired for insert.
- inventoryTransactionIdIntegerNot required. Pass to update existing record.
- inventoryTransactionTypeIdIntegerRequired for insert.
- notesStringNot required.
- partIdIntegerRequired for insert.
- quantityFloatRequired for insert. Must be > 0.
- referenceNumberStringNot required. e.g. 'PO 1234'
- referenceTypeStringNot required. e.g. 'PO', 'WO'
- sourceRecordIdIntegerNot required. For automated processes only.
- sourceSchemaNameStringNot required. For automated processes only.
- sourceTableNameStringNot required. For automated processes only.
- supplierIdIntegerNot required.
- unitCostFloatNot 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