Stock Receipts: Validation Rules

When a stock receipt is created, validation will be performed on several fields. If any of these validations fail, then the API will return an HTTP-400 response.

StockReceipt_OtherHeader

Field Validation
StockReceiptCode StockReceipts.StockReceiptOtherNextNumber from Sequences
site_code When stock receipt records are created, this will be set to the site code passed to the API. Must be a valid site code.
   
terminal_id Valid station that is used by the API. Retrieved from JWT.
external_document_reference Unique reference code from supplier.
supplier_code Supplier must exist in the Infinity database and be active .
total_cost_excluding_input_tax Cannot be less than zero.
Created Product delivery date. Cannot be greater than date now.
Status When a record is created, the status should be 2 (Completed/Submitted).
stock_receipt_person_code Must be supplied in request.

 

StockReceipt OtherLine

Field Validation
StockReceiptCode StockReceiptCode from StockReceipt_OtherHeader.
LineNumber Incremented starting from 1 for each line related to the header record.
Product_code Unique product code (UPC). Must exist in Infinity for the branch and be active .
Quantity  The quantity of product received. Must be greater than zero.
unit_cost_price_excluding_input_tax Cost price per unit.
Status When a record is created, the status should be 2 (Completed/Submitted).

 

API Input Fields

The following fields should be passed to the Stock Receipts API.

Field Description Data Example
Site_code The branch in Infinity. Integer 101
Terminal_id The station to which the request is being sent in the payload. Integer 150
Supplier_code The supplier delivering the order. String Fuel Supplier A, Fuel Supplier B
External_document_reference The stock receipt's external document reference code. String  
Stock_receipt_date The receipted date. String (date/time) 23/07/2019
Extended_cost_price_excluding_input_tax The cost of the stock receipted line, excluding sales tax. Number ($decimal) 50.26
stock_receipt_person_code The person that has prepared this stock receipt. String 103880846
Line_number Describes the lines that make up a stock receipt. Number 1
Product_code The unique ID UPC. String 15424564
Supplier_product_code The supplier’s unique product code. String NZ1542
Receipt_quantity The quantity of the product being ordered. Number 5000
Unit_cost_price_excluding_input_tax Price per unit of the item being purchased. Numeric 2.19

 

Validations

Error handling will be done in standard API error handling functionality.

Code Message Field Condition
Site_code_not_found The site code does not exist. Site_code A record does not exist in InfinityAPI.Sites WHERE Sites.SiteCode = supplied site_code AND Sites.IsArchived = FALSE.
Supplier_code_not_active The Supplier must be active. Supplier_ code The supplier code must be active. Customer.CustType = 'R' (vendor) and Customer.InActive = 0 (0 = Active, 1 = Inactive).
Invalid_date The transaction date cannot be greater than the current date and time. Stock_receipt_date Created > current date and time.
Product_code_not _found The product code does not exist. Product_code A record does not exist in InfinityAPI.products.products WHERE products.ProductCode = supplied product_code AND products.IsArchived = FALSE.
Quantity_greater_than _zero The Quantity must be greater than zero. Receipt_quantity Input quantity must be greater than zero.
Unit_price_greater_than_zero The unit price must be greater than zero. Unit_cost_price_excluding_input_tax Input unit price is greater than zero.
Stock_receipts_not_enabled Stock receipts are not enabled for this site. AutoDeliveryEnabled = True Auto delivery is true.
Successful_transaction The transaction has been successfully accepted. Status 200 Stock receipt transaction was successfully accepted.