Add Petty Cash Item
API สำหรับเพิ่มรายละเอียดค่าใช้จ่าย (เช่น ค่าเดินทาง, ค่าที่พัก, ค่าอุปกรณ์) เข้าไปในเอกสารเบิกเงินสดย่อยที่สร้างไว้แล้ว รองรับการระบุจำนวนเงิน หมวดหมู่การเบิก และการอัปโหลดไฟล์แนบ (Receipt) โดยทุกครั้งที่เพิ่มรายการ ระบบจะคำนวณยอดเงินรวมของเอกสารหลักใหม่โดยอัตโนมัติ
Endpoint
POST /api/v1/open-apis/petty-cash/add-itemRequest Body
รองรับ Content-Type: multipart/form-data (แนะนำ) หรือ application/json
Required Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
petty_cash_id | string (base64) | Yes | รหัสเอกสารหลักที่จะเพิ่มรายการเข้าไป | "MjAy..." |
petty_cash_item_name | string | Yes | ชื่อรายการค่าใช้จ่าย | "ค่าน้ำมันรถยนต์" |
req_amt | number | Yes | จำนวนเงินที่เบิก (ทศนิยม 2 ตำแหน่ง) | 500.00 |
petty_cash_type_id | string (base64) | Yes | รหัสประเภทรายการ (ดู API List Types) | "MjAy..." |
authorize_id | string (base64) | Yes | ID ผู้ทำรายการ | "MjAy..." |
Optional Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
attach_files | file / array | No | ไฟล์รูปใบเสร็จหรือหลักฐาน (JPG, PNG, PDF) | [Binary Data] |
Response Format
Success Response
{
"code": 200,
"message": "เพิ่มรายการสำเร็จ",
"payload": {
"petty_cash_id": "20260325PCD00000001",
"petty_cash_item_name": "ค่าที่พักโรงแรม",
"req_amt": 1200.0,
"petty_cash_type_id": "20260303OPTYX0001",
"petty_cash_item_id": "123"
}
}Response Fields
| Field | Type | Nullable | Description |
|---|---|---|---|
petty_cash_id | string | No | รหัสเอกสารหลัก |
petty_cash_item_name | string | No | ชื่อรายการค่าใช้จ่ายที่เพิ่ม |
req_amt | number | No | จำนวนเงินที่เบิก |
petty_cash_type_id | string | No | รหัสประเภทรายการ |
petty_cash_item_id | string | No | รหัสรายการย่อยที่ถูกสร้างขึ้น |
Error Response
{
"code": 422,
"message": "Validation failed",
"errors": ["'req_amt' is required"]
}{
"code": 404,
"message": "ไม่พบเอกสารที่ระบุ"
}Code Examples
cURL
curl -X POST "https://openapi.humansoft.co.th/api/v1/open-apis/petty-cash/add-item" \
-H "Ocp-Apim-Subscription-Key: YOUR_API_KEY" \
-F "petty_cash_id=MjAyNjAzMjVQQ0QwMDAwMDAwMQ==" \
-F "petty_cash_item_name=ค่าที่พักโรงแรม" \
-F "req_amt=1200.00" \
-F "petty_cash_type_id=MjAyNjAzMDNPUFRZWDAwMDE=" \
-F "authorize_id=MjAyNTAzMDM1MUIwQTJDQ0JEOUM=" \
-F "attach_files=@/path/to/receipt.pdf"Notes
ขนาดไฟล์แนบแนะนำไม่เกิน 5MB ต่อไฟล์ รองรับไฟล์ประเภท JPG, PNG และ PDF
พารามิเตอร์ petty_cash_id, petty_cash_type_id และ authorize_id ต้องส่งเป็น Base64-encoded
Related APIs
- Submit - สร้างเอกสารคำขอเบิกเงินสดย่อย
- List Types - ดูรายการประเภทค่าใช้จ่าย
- Delete Item - ลบรายการค่าใช้จ่าย
- Get Detail - ดูรายละเอียดเอกสาร
Last updated on