Skip to main content

Goods Stock Records Query (T145)

Query historical stock records with pagination support. This endpoint returns stock-in records including supplier information, stock-in types, production batch details, and financial amounts. Request and response are encrypted.


Endpoint Overview​

PropertyValue
Interface CodeT145
Request Encryptedβœ… Yes
Response Encryptedβœ… Yes
Request Body{ "productionBatchNo": "...", "invoiceNo": "...", "referenceNo": "...", "pageNo": 1, "pageSize": 10 }
Response FormatJSON with pagination

Flow Description​

  1. Client submits query with at least one identifier (productionBatchNo, invoiceNo, or referenceNo) and pagination parameters.
  2. Server validates that at least one search identifier is provided.
  3. Server queries stock records matching the criteria across all branches.
  4. Server returns paginated results with supplier details, stock-in information, and amounts.
  5. Client displays records or uses data for audit/compliance reporting.

πŸ’‘ Tip: At least one of productionBatchNo, invoiceNo, or referenceNo must be providedβ€”cannot all be empty. Use T147 for current-branch-only queries.


try {
// Call T145: Goods Stock Records Query
$filters = [
'productionBatchNo' => '1200983', // Optional: batch number
'invoiceNo' => '320001127399', // Optional: invoice number
'referenceNo' => '425502528294126235', // Optional: reference number
'pageNo' => 1,
'pageSize' => 10
];

$response = $client->queryStockRecords($filters);
$content = $response['data']['content'] ?? $response;
$records = $content['records'] ?? [];
$page = $content['page'] ?? [];

if (!empty($records)) {
echo "βœ… Retrieved " . count($records) . " stock record(s)\n";
echo " Page: {$page['pageNo']}/{$page['pageCount']} (Total: {$page['totalSize']})\n";

foreach ($records as $record) {
echo " β€’ Supplier: {$record['supplierName']} (TIN: {$record['supplierTin']})\n";
echo " Stock-In Type: {$record['stockInType']}\n";
echo " Date: {$record['stockInDate']}\n";
echo " Invoice: {$record['invoiceNo']}\n";
echo " Amount: {$record['totalAmount']}\n";
echo " Branch: {$record['branchName']}\n";
echo "\n";
}
} else {
echo "⚠️ No stock records found for provided criteria\n";
}

} catch (\UraEfrisSdk\Exceptions\APIException $e) {
echo "❌ Query failed: " . $e->getMessage() . "\n";
echo " Return Code: " . $e->getReturnCode() . "\n";
}

Request Structure​

{
"data": {
"content": "BASE64_ENCRYPTED_PAYLOAD",
"signature": "JKQWJK34K32JJEK2JQWJ5678",
"dataDescription": {
"codeType": "1",
"encryptCode": "2",
"zipCode": "0"
}
},
"globalInfo": {
"interfaceCode": "T145",
"appId": "AP04",
"version": "1.1.20191201",
"tin": "1000029771",
"deviceNo": "TCS9e0df01728335239",
"taxpayerID": "1"
}
}

Request Fields (Encrypted Payload)​

FieldRequiredTypeLengthDescription
productionBatchNo❌ NoString≀50Production batch number for filtering; at least one of productionBatchNo, invoiceNo, or referenceNo must be provided
invoiceNo❌ NoString≀20Invoice number for filtering; corresponds to the invoice that triggered the stock-in
referenceNo❌ NoString≀50Seller's reference number for filtering
pageNoβœ… YesNumber≀10Current page number (starts from 1)
pageSizeβœ… YesNumber≀3Records per page; cannot exceed 100

πŸ’‘ Tip: At least one search identifier (productionBatchNo, invoiceNo, or referenceNo) must be providedβ€”all three cannot be empty simultaneously.


Response Structure​

{
"data": {
"content": {
"page": {
"pageNo": "1",
"pageSize": "10",
"totalSize": "50",
"pageCount": "5"
},
"records": [
{
"supplierTin": "1010039929",
"supplierName": "Mr. EMUR SAM",
"adjustType": "101",
"remarks": "Increase inventory",
"stockInDate": "2025-02-19",
"stockInType": "101",
"productionBatchNo": "1200983",
"productionDate": "2025-02-19",
"branchId": "2020090132456",
"invoiceNo": "320001127399",
"referenceNo": "425502528294126235",
"branchName": "PARAMOUR COSMETICS LIMITED",
"totalAmount": "1000.00"
}
]
}
},
"globalInfo": {
"interfaceCode": "T145",
"returnStateInfo": {
"returnCode": "00",
"returnMessage": "SUCCESS"
}
}
}

Response Fields​

Pagination Object​

FieldRequiredTypeDescription
pageNoβœ… YesNumberCurrent page number
pageSizeβœ… YesNumberRecords per page
totalSizeβœ… YesNumberTotal number of matching records
pageCountβœ… YesNumberTotal number of pages

Stock Records Array Items​

FieldRequiredTypeLengthDescription
supplierTin❌ NoString≀50Supplier's Taxpayer Identification Number
supplierName❌ NoString≀100Supplier name/business name
adjustType❌ NoString (3)3101=Expired Goods, 102=Damaged Goods, 103=Personal Uses, 104=Others, 105=Raw Material(s)
remarks❌ NoString≀1024Stock record remarks/notes
stockInDate❌ NoDate-Stock-in date (yyyy-MM-dd)
stockInType❌ NoString (3)3101=Import, 102=Local Purchase, 103=Manufacture/Assembling, 104=Opening Stock
productionBatchNo❌ NoString≀50Production batch number (required if stockInType=103)
productionDate❌ NoDate-Production date (yyyy-MM-dd; required if stockInType=103)
branchId❌ NoString≀18Branch identifier where stock was received
branchName❌ NoString≀500Branch name
invoiceNo❌ NoString≀20Associated invoice number
referenceNo❌ NoString≀50Seller's reference number
totalAmount❌ NoNumber-Total stock-in amount

πŸ’‘ Tip: Use stockInType to filter records by source (import, local purchase, manufacture, opening stock). For manufactured goods (stockInType=103), productionBatchNo and productionDate will be populated.


Return Codes​

CodeMessageDescription
00SUCCESSStock records retrieved successfully
99Unknown errorGeneric server error
400Device does not existdeviceNo not registered for this TIN
402Device key expiredDevice credentials expired; re-run T102
403Device status is abnormalDevice blocked or suspended
1521pageNo:cannot be empty!Missing page number in request
1522pageNo:The byte length cannot be less than 0 and cannot be greater than 20!Page number format error
1523pageNo:Cannot be greater than -1!Page number must be positive
1524pageSize:cannot be empty!Missing page size in request
1525pageSize:The byte length cannot be less than 0 and cannot be greater than 3!Page size format error
1526pageSize:Cannot be greater than 100!Page size exceeds maximum (100)
2843'productionBatchNo'、'invoiceNo'、'referenceNo' cannot be empty at the same time!At least one search identifier required
2844productionBatchNo:cannot be empty!Production batch number format error
2845productionBatchNo:Byte length cannot be greater than 50!Production batch number too long
2846referenceNo:cannot be empty!Reference number format error
2847referenceNo:Byte length cannot be greater than 20!Reference number too long

πŸ’‘ Tip: Error 2843 is the most commonβ€”ensure at least one search identifier (productionBatchNo, invoiceNo, or referenceNo) is provided.


Common Use Cases​

  1. Stock Audit Trail
    Query historical stock-in records for compliance audits and financial reconciliation.

  2. Supplier Verification
    Filter records by supplierTin or supplierName to verify supplier transactions.

  3. Invoice-to-Stock Reconciliation
    Match stock records to invoices using invoiceNo for accounting reconciliation.

  4. Batch Traceability
    Track manufactured goods by productionBatchNo for quality control and recalls.

  5. Branch Stock Analysis
    Analyze stock-in patterns across branches using branchId/branchName filters.

  6. Stock-In Type Reporting
    Generate reports by stockInType (import, local purchase, manufacture, opening stock).

  7. Reference Number Lookup
    Locate stock records using seller's reference numbers for transaction tracking.


Integration Checklist​

βœ… Ensure at least one search identifier is provided (productionBatchNo, invoiceNo, or referenceNo)
βœ… Validate pageNo β‰₯ 1 and pageSize ≀ 100 before submitting request
βœ… Handle empty records array gracefully (no matching records found)
βœ… Implement pagination logic using pageCount and totalSize from response
βœ… Cache frequently-queried stock records to reduce API calls
βœ… Log query parameters for audit trail compliance
βœ… Cross-reference invoiceNo with T106/T108 invoice queries for validation
βœ… Use T147 for current-branch-only queries (better performance for single-branch operations)
βœ… Validate stockInType values against T115 dictionary for display purposes
βœ… Handle date format consistently (yyyy-MM-dd) across all date fields