Income/Expense Import
นำเข้าข้อมูลรายได้/รายจ่ายของพนักงานตามงวดเงินเดือน
Endpoint
POST /api/v1/open-apis/salary/import?path_action=inex_importRequest Parameters
Query Parameter
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
path_action | string | Yes | ระบุเป็น inex_import | "inex_import" |
Request Body (JSON)
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
year_month | string | Yes | งวดเงินเดือน (YYYY-MM) | "2026-03" |
import_data | array | Yes | ข้อมูลรายได้/รายจ่ายของพนักงาน | ดูตัวอย่างด้านล่าง |
import_data[] Fields
| Field | Type | Required | Description |
|---|---|---|---|
emp_code | string | Yes | รหัสพนักงาน |
Income-{id} | number/string | No | จำนวนเงินรายได้ตามประเภท |
Expense-{id} | number/string | No | จำนวนเงินรายจ่ายตามประเภท |
- ค่าเงินรองรับรูปแบบ comma separator เช่น
"1,000.50" - ค่าที่เป็น
0จะลบข้อมูลเก่าออกโดยไม่เพิ่มใหม่ - ค่าที่เป็นค่าว่าง
""หรือnullจะถูกข้ามไป - การนำเข้าเป็นแบบ UPSERT — ลบข้อมูลเก่าแล้วเพิ่มใหม่
Example Request Body
{
"year_month": "2026-03",
"import_data": [
{
"emp_code": "EMP001",
"Income-SAL001": "25000",
"Income-SAL002": "5000",
"Expense-EXP001": "1000"
},
{
"emp_code": "EMP002",
"Income-SAL001": "30,000.50",
"Expense-EXP001": "1500"
}
]
}Response Format
Success Response
{
"code": 200,
"message": "สำเร็จ",
"payload": {
"import_log_id": "20260305IMP00000001",
"all_record": 2,
"insert_record": 2,
"error_record": 0,
"errors": []
}
}Response Fields
| Field | Type | Description |
|---|---|---|
import_log_id | string | รหัส log การนำเข้า (20 ตัวอักษร) |
all_record | number | จำนวนรายการทั้งหมดที่ส่งเข้ามา |
insert_record | number | จำนวนรายการที่นำเข้าสำเร็จ |
error_record | number | จำนวนรายการที่เกิดข้อผิดพลาด |
errors | array | รายละเอียดข้อผิดพลาด |
Error Detail Fields
| Field | Type | Description |
|---|---|---|
row | number | ลำดับแถวที่เกิดข้อผิดพลาด |
emp_code | string | รหัสพนักงานที่เกิดข้อผิดพลาด |
column | string | คอลัมน์ที่เกิดข้อผิดพลาด |
message | string | รายละเอียดข้อผิดพลาด |
Error Response
{
"code": 400,
"message": "import_data is not an array",
"payload": []
}| HTTP Status | Description |
|---|---|
400 | รูปแบบข้อมูลไม่ถูกต้อง, year_month ไม่ถูกต้อง, ไม่พบงวดเงินเดือน |
401 | API Key ไม่ถูกต้องหรือไม่ได้ส่ง |
Code Examples
cURL
curl -X POST "https://openapi.humansoft.co.th/api/v1/open-apis/salary/import?path_action=inex_import" \
-H "Ocp-Apim-Subscription-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"year_month": "2026-03",
"import_data": [
{
"emp_code": "EMP001",
"Income-SAL001": "25000",
"Expense-EXP001": "1000"
}
]
}'Related APIs
- Income/Expense Template - ดึง Template คอลัมน์ก่อนนำเข้า
- Income/Expense Import Log - ดูประวัติการนำเข้า
Last updated on