stockTransaction¶
Supported, no replacement yet
This endpoint remains fully supported. No replacement exists in the new API yet, and no action is needed. When a replacement ships you will get 12 months' notice, and this site will be updated.
Reference¶
/rest/stockMgmt/stockTransaction
POST
Adds a stock transaction.
- Type represents type of stock transaction:
- "1" - Usage
- "2" - UsageUpdate
- "3" - Purchase
- "5" - Consumable Purchase
For all Transaction Types where part/store lookup is required
- lookupPartByPartNumber
- if set to 0 or not supplied value in partId field will be used to look up Part by Part ID
- if set to 1, value in partId field will be used to look up Part by Part Number and a new part created if not found
- lookupStoreByResourceRef
- if set to 0 or not supplied values in fromStoreId and toStoreId will be used to look up Store by Store ID
- if set to 1 values in fromStoreId and toStoreId will be used to look up Store by Resource Ref
Transaction Type = USAGE
- the apptID field or the jobRef field must be populated
- fromStoreId must be populated
- USAGE Stock Transaction record added with link to job and, optionally, appointment
- Stock level on fromStore adjusted
- Search for matching JobPart record - if found, change status of JobPart record to Used and change quantity_used
- a Materials Job Cost record is added using the cost associated to the Part unless the unitCost field is included in which case this cost is used
- returns JobCost record Id
- create new part record??? (No - does not make sense to do so as fromStore will not exists at that time)
Transaction Type = USAGE UPDATE
- the apptID field or the jobRef field must be populated
- fromStoreId or toStoreId must be populated
- The quantity is a delta value and is +ve (selecting from/to store should avoid -ve values)
- USAGE_UPDATE Stock Transaction record added with link to job and, optionally, appointment
- Stock level on fromStore or toStore adjusted
- Search for matching JobPart record - if found, change quantity_used
- the jobCostId field must be populated.
- the Job Cost record is updated or, if the quantity ends up as zero, deleted.
- create new part record??? (No - does not make sense to do so as fromStore will not exists at that time)
Transaction Type = PURCHASE
- toStoreId must be populated
- qty must be populated
- PURCHASE Stock Transaction record added with link to job and, optionally, appointment if provided
- Stock level on toStore increased
- if part does not exist, add part using partDescription, partCategoryId, reOrderLevel (defaults to 1 if not provided), reOrderQty (defaults to 1 if not provided), uomId (defaults to 0 if not provided), vendorId, clientGroupId
- if poRef is supplied
- vendorId must be provided
- lookup PO by ref/vendorId
- if found
- add PO line and, if cost supplied, use cost supplied, otherwise use cost from Part Library
- if not found
- add new PO (what status? SUBMITTED?) and add PO line as above
- if grnRef is supplied
- vendorId must be provided
- lookup GRN by ref/vendorId
- if found
- add GRN line and, if cost supplied, use cost supplied, otherwise use cost from part library
- if not found
- add new GRN and add GRN line as above
- if poRef provided, match GRN line to PO line by matching part number and quantity
- returns newPartId if appropriate
Transaction Type = CONSUMABLE PURCHASE
- toStoreId must be populated
- lookupStoreByResoureRef must be 1
- employee record needs to exists for resource
- Employee record looked up and EmployeeCost record added
- if part does not exist, add part using partDescription, partCategoryId, reOrderLevel (defaults to 1 if not provided), reOrderQty (defaults to 1 if not provided), uomId (defaults to 0 if not provided), vendorId
- if poRef is supplied
- vendorId must be provided
- lookup PO by ref/vendorId
- if found
- add PO line and, if cost supplied, use cost supplied, otherwise use cost from Part Library
- if not found
- add new PO and add PO line as above
- if grnRef is supplied
- vendorId must be provided
- lookup GRN by ref/vendorId
- if found
- add GRN line and, if cost supplied, use cost supplied, otherwise use cost from part library
- if not found
- add new GRN and add GRN line as above
- if poRef provided, match GRN line to PO line by matching part number and quantity
- returns newPartId if appropriate
- exceptions must be thrown in clear format
acceptable request representations:
available response representations:
- application/json
transaction={ "type" : "1" "lookupPartByPartNumber" : "1", "lookupStoreByStoreNumber" : "1",
"partId" : "32728", "partDescription" : "12 inch nail", "partCategoryId": "3",
"reOrderLevel" : "3",
"reOrderQty" : "7", "uomId" : "1" "jobRef" : "J00089", "unitCost" : "34.45", "dateTime" : "12/12/2013 12:34", "vendorId" : "2", "poRef" : "33",
"grnRef" : "4432",
"fromStoreId" : "56", "toStoreId": "8", "ref" : "bdbfh888", "apptId" : "338892", "qty" : "7", // change in quantity
"jobCostId" : "7574"}available response representations:
- 200 - application/json
{
"result" : "success or fail",
"result_msg" : "error message",
# may also return
"jobCostId" : "5656",
"newPartId" : "8181"
}See the Stock Management API matrix for the full list of endpoints in this category.