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β
| Property | Value |
|---|---|
| Interface Code | T145 |
| Request Encrypted | β Yes |
| Response Encrypted | β Yes |
| Request Body | { "productionBatchNo": "...", "invoiceNo": "...", "referenceNo": "...", "pageNo": 1, "pageSize": 10 } |
| Response Format | JSON with pagination |
Flow Descriptionβ
- Client submits query with at least one identifier (
productionBatchNo,invoiceNo, orreferenceNo) and pagination parameters. - Server validates that at least one search identifier is provided.
- Server queries stock records matching the criteria across all branches.
- Server returns paginated results with supplier details, stock-in information, and amounts.
- Client displays records or uses data for audit/compliance reporting.
π‘ Tip: At least one of
productionBatchNo,invoiceNo, orreferenceNomust be providedβcannot all be empty. Use T147 for current-branch-only queries.
- PHP
- JavaScript / TypeScript
- Python
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";
}
try {
// Call T145: Goods Stock Records Query
const filters = {
productionBatchNo: '1200983', // Optional: batch number
invoiceNo: '320001127399', // Optional: invoice number
referenceNo: '425502528294126235', // Optional: reference number
pageNo: 1,
pageSize: 10
};
const response = await client.queryStockRecords(filters);
const content = response?.data?.content ?? response;
const records = content?.records ?? [];
const page = content?.page ?? {};
if (records.length > 0) {
console.log(`β
Retrieved ${records.length} stock record(s)`);
console.log(` Page: ${page.pageNo}/${page.pageCount} (Total: ${page.totalSize})`);
for (const record of records) {
console.log(` β’ Supplier: ${record.supplierName} (TIN: ${record.supplierTin})`);
console.log(` Stock-In Type: ${record.stockInType}`);
console.log(` Date: ${record.stockInDate}`);
console.log(` Invoice: ${record.invoiceNo}`);
console.log(` Amount: ${record.totalAmount}`);
console.log(` Branch: ${record.branchName}`);
console.log('');
}
return content;
} else {
console.warn('β οΈ No stock records found for provided criteria');
return { records: [], page };
}
} catch (error: any) {
console.error(`β Query failed: ${error.message}`);
if (error.returnCode) {
console.error(` Return Code: ${error.returnCode}`);
}
throw error;
}
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.query_stock_records(filters)
content = response.get("data", {}).get("content", response)
records = content.get("records", [])
page = content.get("page", {})
if records:
print(f"β
Retrieved {len(records)} stock record(s)")
print(f" Page: {page.get('pageNo')}/{page.get('pageCount')} (Total: {page.get('totalSize')})")
for record in records:
print(f" β’ Supplier: {record['supplierName']} (TIN: {record['supplierTin']})")
print(f" Stock-In Type: {record['stockInType']}")
print(f" Date: {record['stockInDate']}")
print(f" Invoice: {record['invoiceNo']}")
print(f" Amount: {record['totalAmount']}")
print(f" Branch: {record['branchName']}")
print()
else:
print("β οΈ No stock records found for provided criteria")
except Exception as e:
print(f"β Query failed: {e}")
if hasattr(e, "return_code"):
print(f" Return Code: {e.return_code}")
raise
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)β
| Field | Required | Type | Length | Description |
|---|---|---|---|---|
productionBatchNo | β No | String | β€50 | Production batch number for filtering; at least one of productionBatchNo, invoiceNo, or referenceNo must be provided |
invoiceNo | β No | String | β€20 | Invoice number for filtering; corresponds to the invoice that triggered the stock-in |
referenceNo | β No | String | β€50 | Seller's reference number for filtering |
pageNo | β Yes | Number | β€10 | Current page number (starts from 1) |
pageSize | β Yes | Number | β€3 | Records per page; cannot exceed 100 |
π‘ Tip: At least one search identifier (
productionBatchNo,invoiceNo, orreferenceNo) 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β
| Field | Required | Type | Description |
|---|---|---|---|
pageNo | β Yes | Number | Current page number |
pageSize | β Yes | Number | Records per page |
totalSize | β Yes | Number | Total number of matching records |
pageCount | β Yes | Number | Total number of pages |
Stock Records Array Itemsβ
| Field | Required | Type | Length | Description |
|---|---|---|---|---|
supplierTin | β No | String | β€50 | Supplier's Taxpayer Identification Number |
supplierName | β No | String | β€100 | Supplier name/business name |
adjustType | β No | String (3) | 3 | 101=Expired Goods, 102=Damaged Goods, 103=Personal Uses, 104=Others, 105=Raw Material(s) |
remarks | β No | String | β€1024 | Stock record remarks/notes |
stockInDate | β No | Date | - | Stock-in date (yyyy-MM-dd) |
stockInType | β No | String (3) | 3 | 101=Import, 102=Local Purchase, 103=Manufacture/Assembling, 104=Opening Stock |
productionBatchNo | β No | String | β€50 | Production batch number (required if stockInType=103) |
productionDate | β No | Date | - | Production date (yyyy-MM-dd; required if stockInType=103) |
branchId | β No | String | β€18 | Branch identifier where stock was received |
branchName | β No | String | β€500 | Branch name |
invoiceNo | β No | String | β€20 | Associated invoice number |
referenceNo | β No | String | β€50 | Seller's reference number |
totalAmount | β No | Number | - | Total stock-in amount |
π‘ Tip: Use
stockInTypeto filter records by source (import, local purchase, manufacture, opening stock). For manufactured goods (stockInType=103),productionBatchNoandproductionDatewill be populated.
Return Codesβ
| Code | Message | Description |
|---|---|---|
00 | SUCCESS | Stock records retrieved successfully |
99 | Unknown error | Generic server error |
400 | Device does not exist | deviceNo not registered for this TIN |
402 | Device key expired | Device credentials expired; re-run T102 |
403 | Device status is abnormal | Device blocked or suspended |
1521 | pageNo:cannot be empty! | Missing page number in request |
1522 | pageNo:The byte length cannot be less than 0 and cannot be greater than 20! | Page number format error |
1523 | pageNo:Cannot be greater than -1! | Page number must be positive |
1524 | pageSize:cannot be empty! | Missing page size in request |
1525 | pageSize:The byte length cannot be less than 0 and cannot be greater than 3! | Page size format error |
1526 | pageSize: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 |
2844 | productionBatchNo:cannot be empty! | Production batch number format error |
2845 | productionBatchNo:Byte length cannot be greater than 50! | Production batch number too long |
2846 | referenceNo:cannot be empty! | Reference number format error |
2847 | referenceNo:Byte length cannot be greater than 20! | Reference number too long |
π‘ Tip: Error
2843is the most commonβensure at least one search identifier (productionBatchNo,invoiceNo, orreferenceNo) is provided.
Common Use Casesβ
-
Stock Audit Trail
Query historical stock-in records for compliance audits and financial reconciliation. -
Supplier Verification
Filter records bysupplierTinorsupplierNameto verify supplier transactions. -
Invoice-to-Stock Reconciliation
Match stock records to invoices usinginvoiceNofor accounting reconciliation. -
Batch Traceability
Track manufactured goods byproductionBatchNofor quality control and recalls. -
Branch Stock Analysis
Analyze stock-in patterns across branches usingbranchId/branchNamefilters. -
Stock-In Type Reporting
Generate reports bystockInType(import, local purchase, manufacture, opening stock). -
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