Sale Invoice Service
API ใบขายสินค้า (ใบส่งของ/ใบกำกับภาษี)
- ดึงเอกสารใบขายสินค้า ทั้งหมด
- ดึงเอกสารใบขายสินค้า ตามเอกสาร
- สร้างเอกสารใบขายสินค้า
- Sale Invoice Attribute
- Sale Invoice Detail Attribute
- Payment Attribute
- Payment Detail Attribute
Header Request
| Field | Value |
|---|---|
| GUID | GUID สำหรับการเชื่อมต่อ (smlx เสมอ) |
| provider | ชื่อผู้ใช้บริการ |
| databaseName | ชื่อฐานข้อมูล |
| configFileName | ชื่อไฟล์ตั้งค่า — รูปแบบ SMLConfig<provider>.xml |
| Content-Type | application/json; charset=utf-8 |
Header Example
{
"GUID": "smlx",
"provider": "DATA",
"databaseName": "data1",
"configFileName": "SMLConfigDATA.xml",
"Content-Type": "application/json; charset=utf-8"
}HTTP Response
| Status | ความหมาย |
|---|---|
200 | สำเร็จ — กรณี list ที่ไม่พบเอกสารก็ได้ 200 เช่นกัน โดย data เป็น [] และ pages.total_record เป็น 0 |
400 | ข้อมูลผิดพลาด (code = 99) เช่น เลขที่เอกสารซ้ำ / ข้อมูลไม่ถูกต้อง หรือไม่ผ่าน การตรวจสอบข้อมูลก่อนบันทึก (code = 400) — ดูสาเหตุจริงใน message |
404 | ไม่พบเอกสาร (code = 404) กรณี GET ตามเลขที่เอกสาร หรือเรียก URL / path ไม่ถูกต้อง |
405 | ใช้ HTTP method ไม่ถูกต้อง |
500 | payload ผิดรูป หรือข้อผิดพลาดภายในระบบ |
SaleInvoice List
แสดงข้อมูลเอกสารใบขายสินค้า ทั้งหมด
EndPoint
GET /SMLJavaRESTService/saleinvoice/v4
ขอบเขตข้อมูล: คืนเฉพาะใบขาย (
trans_flag= 44,is_pos= 0) ที่ยังไม่ถูกยกเลิก (last_status= 0)
บิลขาย POS อยู่ที่ Sale Invoice POS Service คนละเส้นกัน
Query Request
| Field | Description | Example |
|---|---|---|
| date | กรองเฉพาะวันเดียว | 2024-11-15 |
| from_date | ตั้งแต่วันที่ (≥) — ใช้คู่กับ to_date ได้ | 2024-01-01 |
| to_date | จนถึงวันที่ (≤) — ใช้คู่กับ from_date ได้ | 2024-12-31 |
| cust_code | รหัสลูกหนี้/เจ้าหนี้ | AR00016 |
| sale_code | รหัสพนักงานขาย | S001 |
| pay_type | ประเภทการชำระ (cash หรือ credit) | cash |
| doc_no | เลขที่เอกสาร (ค้นแบบตรงตัว) | IV67110001 |
| last_update_date_time | วันที่แก้ไขล่าสุดตั้งแต่ (≥) | 2024-11-01 |
| page | หน้าที่ (เริ่ม 1) | 1 |
| size | จำนวนต่อหน้า | 10 |
หมายเหตุ:
- ถ้าส่ง
dateมาแล้ว ระบบจะใช้dateก่อน (ไม่สนใจfrom_date/to_date)- วันที่ทุกตัวใช้รูปแบบ
yyyy-MM-ddsizeคือจำนวนเอกสารต่อหน้า แต่ละเอกสารจะมีรายการสินค้า (details) ครบทุกบรรทัดเสมอtotal_recordคือจำนวนเอกสารทั้งหมดที่ตรงเงื่อนไข และmax_pageคือจำนวนหน้าทั้งหมด
Example:
GET localhost:8084/SMLJavaRESTService/saleinvoice/v4?page=1&size=10
GET localhost:8084/SMLJavaRESTService/saleinvoice/v4?from_date=2024-01-01&to_date=2024-12-31&page=1&size=10
GET localhost:8084/SMLJavaRESTService/saleinvoice/v4?cust_code=AR00016&page=1&size=10Response Success
ตัวอย่างจริงจากคำสั่ง
GET /SMLJavaRESTService/saleinvoice/v4?page=1&size=1&cust_code=AR20-00001
{
"success": true,
"data": [
{
"trans_type": 2,
"trans_flag": 44,
"doc_group": "",
"doc_date": "2021-06-17",
"doc_no": "INV2106-0001",
"doc_ref": "",
"tax_doc_no": "INV2106-0001",
"tax_doc_date": "2021-06-17",
"inquiry_type": 1,
"vat_type": 1,
"cust_code": "AR20-00001",
"contactor": "",
"branch_code": "001",
"project_code": "",
"side_code": "",
"department_code": "",
"sale_area_code": "",
"sale_code": "",
"send_type": 0,
"send_day": 0,
"send_date": "2021-06-17",
"credit_day": 0,
"due_date": null,
"answer_type": 0,
"transport_value": 0,
"discount_word": "",
"vat_rate": 0,
"currency_code": "",
"exchange_rate": 0,
"total_cost": 0,
"total_value": 5040,
"total_discount": 0,
"total_vat_value": 0,
"total_after_vat": 5040,
"total_except_vat": 0,
"total_amount": 5040,
"balance_amount": 0,
"adjust_reason": "",
"approve_code": "",
"remark": "",
"status": 0,
"user_request": "",
"expire_day": 0,
"send_mail": 0,
"send_sms": 0,
"doc_ref_trans": "",
"credit_date": "2021-06-17",
"total_before_vat": 5040,
"doc_time": "10:15",
"allocate_code": "",
"job_code": "",
"pay_amount": 0,
"money": 0,
"sum_pay_money_diff": 0,
"currency_money": 0,
"total_debt_amount": 0,
"cancel_type": 0,
"last_status": 0,
"used_status": 0,
"doc_success": 0,
"total_manual": 0,
"on_hold": 0,
"extra_word": "",
"transport_code": "",
"want_day": 0,
"deposit_day": 0,
"sale_group": "",
"not_approve_1": 0,
"user_approve": "",
"approve_status": 0,
"expire_status": 0,
"advance_amount": 0,
"doc_format_code": "INV",
"used_status_2": 0,
"remark_2": "",
"remark_3": "",
"ref_amount": 0,
"ref_new_amount": 0,
"ref_diff": 0,
"sum_point": 0,
"cashier_code": "SUPERADMIN",
"is_pos": 0,
"pos_id": "",
"member_code": "",
"doc_no_guid": "",
"pos_bill_type": 0,
"pos_bill_change": 0,
"doc_type": 0,
"recheck_count_day": 0,
"recheck_count": 0,
"wh_from": "",
"location_from": "",
"wh_to": "",
"location_to": "",
"auto_create": 0,
"send_to_pick_and_pack": 0,
"service_charge_word": "",
"total_service_charge": 0,
"sale_shift_id": "",
"creator_code": "SUPERADMIN",
"last_editor_code": "",
"create_datetime": "2021-06-17 10:15:50",
"table_number": "",
"period_guid": "",
"branch_code_to": "",
"allocate_code_to": "",
"project_code_to": "",
"job_code_to": "",
"side_code_to": "",
"department_code_to": "",
"point_telephone": "",
"sum_point_2": 0,
"remark_4": "",
"remark_5": "",
"is_manual_vat": 0,
"pass_book_code": "",
"total_amount_2": 0,
"sender_code": "",
"is_cancel": 0,
"cancel_code": "",
"is_hold": 0,
"auto_approved": 0,
"pos_transfer": 0,
"doc_close": 0,
"ref_doc_type": "",
"is_doc_copy": 0,
"doc_reason": "",
"discount_word_2": "",
"total_discount_2": 0,
"total_value_2": 0,
"total_amout_old": 0,
"lost_profit_exchange_amount": 0,
"details": [
{
"trans_type": 2,
"trans_flag": 44,
"doc_group": "",
"doc_date": "2021-06-17",
"doc_no": "INV2106-0001",
"doc_ref": "",
"cust_code": "AR20-00001",
"inquiry_type": 1,
"item_code": "AGPAN15B001",
"item_name": "ใบตัดท้าย 15 นิ้ว",
"unit_code": "แผ่น",
"qty": 2,
"price": 300,
"discount": "",
"sum_of_cost": 616.9,
"sum_amount": 600,
"remark": "",
"status": 0,
"line_number": 0,
"ref_doc_no": "",
"ref_line_number": 0,
"ref_cust_code": "",
"branch_code": "001",
"wh_code": "01",
"shelf_code": "A",
"wh_code_2": "",
"shelf_code_2": "",
"department_code": "",
"total_vat_value": 0,
"cancel_qty": 0,
"total_qty": 0,
"stand_value": 1,
"divide_value": 1,
"ratio": 0,
"ic_pattern": "",
"ic_color": "",
"ic_size": "",
"priority_level": 0,
"calc_flag": -1,
"last_status": 0,
"set_ref_line": "",
"set_ref_price": 300,
"set_ref_qty": 0,
"item_type": 0,
"vat_type": 1,
"doc_ref_type": 0,
"item_code_main": "",
"ref_row": 0,
"ref_guid": "",
"doc_time": "10:15",
"is_permium": 0,
"is_get_price": 1,
"average_cost": 308.45,
"sum_amount_exclude_vat": 600,
"doc_date_calc": "2021-06-17",
"doc_time_calc": "10:15",
"discount_amount": 0,
"price_exclude_vat": 300,
"user_approve": "",
"price_type": 6,
"price_mode": 6,
"temp_float_1": 0,
"temp_float_2": 0,
"temp_string_1": "",
"is_serial_number": 0,
"bank_name": "",
"bank_branch": "",
"chq_number": "",
"barcode": "",
"discount_number": 0,
"price_changed": 0,
"discount_changed": 0,
"price_default": 0,
"tax_type": 0,
"is_pos": 0,
"auto_create": 0,
"hidden_cost_1": 0,
"hidden_cost_1_exclude_vat": 0,
"hidden_cost_2": 0,
"hidden_cost_2_exclude_vat": 0,
"sum_of_cost_1": 616.9,
"average_cost_1": 308.45,
"sale_code": "",
"sale_group": "",
"lot_number_1": "",
"item_code_2": "",
"bank_name_2": "",
"bank_branch_2": "",
"sale_shift_id": "",
"price_base": 0,
"creator_code": "",
"last_editor_code": "",
"fee_amount": 0,
"transfer_amount": 0,
"price_set_ratio": 0,
"mfn_code": "",
"mfn_name": "",
"price_2": 0,
"sum_amount_2": 0,
"price_guid": "",
"discount_amount_2": 0,
"is_lock_cost": 0,
"sum_of_cost_fix": 0,
"profit_lost_cost_amount": 0,
"is_doc_copy": 0,
"bat_number": "",
"product_year": "",
"product_week": "",
"currency_code": "",
"exchange_rate": 0,
"qty_2": 0,
"unit_code_2": "",
"total_size": 0,
"unit_size": 0,
"exchange_rate_old": 0,
"promotion_code": "",
"item_brand": "SCG",
"item_brand_name": "ກາຊ້າງ",
"group_main": "A",
"group_main_name": "ຊີມັງ",
"group_sub": "AA",
"group_sub_name": "ປູນເທົາ"
},
{
"trans_type": 2,
"trans_flag": 44,
"doc_group": "",
"doc_date": "2021-06-17",
"doc_no": "INV2106-0001",
"doc_ref": "",
"cust_code": "AR20-00001",
"inquiry_type": 1,
"item_code": "A-1100-98",
"item_name": "ใบตัดท้าย 18 นิ้ว",
"unit_code": "แผ่น",
"qty": 5,
"price": 600,
"discount": "",
"sum_of_cost": 3000,
"sum_amount": 3000,
"remark": "",
"status": 0,
"line_number": 1,
"ref_doc_no": "",
"ref_line_number": 0,
"ref_cust_code": "",
"branch_code": "001",
"wh_code": "01",
"shelf_code": "A",
"wh_code_2": "",
"shelf_code_2": "",
"department_code": "",
"total_vat_value": 0,
"cancel_qty": 0,
"total_qty": 0,
"stand_value": 1,
"divide_value": 1,
"ratio": 0,
"ic_pattern": "",
"ic_color": "",
"ic_size": "",
"priority_level": 0,
"calc_flag": -1,
"last_status": 0,
"set_ref_line": "",
"set_ref_price": 600,
"set_ref_qty": 0,
"item_type": 0,
"vat_type": 1,
"doc_ref_type": 0,
"item_code_main": "",
"ref_row": 0,
"ref_guid": "",
"doc_time": "10:15",
"is_permium": 0,
"is_get_price": 1,
"average_cost": 600,
"sum_amount_exclude_vat": 3000,
"doc_date_calc": "2021-06-17",
"doc_time_calc": "10:15",
"discount_amount": 0,
"price_exclude_vat": 600,
"user_approve": "",
"price_type": 6,
"price_mode": 6,
"temp_float_1": 0,
"temp_float_2": 0,
"temp_string_1": "",
"is_serial_number": 0,
"bank_name": "",
"bank_branch": "",
"chq_number": "",
"barcode": "",
"discount_number": 0,
"price_changed": 0,
"discount_changed": 0,
"price_default": 0,
"tax_type": 0,
"is_pos": 0,
"auto_create": 0,
"hidden_cost_1": 0,
"hidden_cost_1_exclude_vat": 0,
"hidden_cost_2": 0,
"hidden_cost_2_exclude_vat": 0,
"sum_of_cost_1": 3000,
"average_cost_1": 600,
"sale_code": "",
"sale_group": "",
"lot_number_1": "",
"item_code_2": "",
"bank_name_2": "",
"bank_branch_2": "",
"sale_shift_id": "",
"price_base": 0,
"creator_code": "",
"last_editor_code": "",
"fee_amount": 0,
"transfer_amount": 0,
"price_set_ratio": 0,
"mfn_code": "",
"mfn_name": "",
"price_2": 0,
"sum_amount_2": 0,
"price_guid": "",
"discount_amount_2": 0,
"is_lock_cost": 0,
"sum_of_cost_fix": 0,
"profit_lost_cost_amount": 0,
"is_doc_copy": 0,
"bat_number": "",
"product_year": "",
"product_week": "",
"currency_code": "",
"exchange_rate": 0,
"qty_2": 0,
"unit_code_2": "",
"total_size": 0,
"unit_size": 0,
"exchange_rate_old": 0,
"promotion_code": "",
"item_brand": "CLOCK",
"item_brand_name": "นาฬิกา",
"group_main": "A",
"group_main_name": "ຊີມັງ",
"group_sub": "AA",
"group_sub_name": "ປູນເທົາ"
},
{
"trans_type": 2,
"trans_flag": 44,
"doc_group": "",
"doc_date": "2021-06-17",
"doc_no": "INV2106-0001",
"doc_ref": "",
"cust_code": "AR20-00001",
"inquiry_type": 1,
"item_code": "AGPAN18A001",
"item_name": "ใบผาน 18",
"unit_code": "ใบ",
"qty": 3,
"price": 480,
"discount": "",
"sum_of_cost": 1500,
"sum_amount": 1440,
"remark": "",
"status": 0,
"line_number": 2,
"ref_doc_no": "",
"ref_line_number": 0,
"ref_cust_code": "",
"branch_code": "001",
"wh_code": "01",
"shelf_code": "A",
"wh_code_2": "",
"shelf_code_2": "",
"department_code": "",
"total_vat_value": 0,
"cancel_qty": 0,
"total_qty": 0,
"stand_value": 1,
"divide_value": 1,
"ratio": 0,
"ic_pattern": "",
"ic_color": "",
"ic_size": "",
"priority_level": 0,
"calc_flag": -1,
"last_status": 0,
"set_ref_line": "",
"set_ref_price": 480,
"set_ref_qty": 0,
"item_type": 0,
"vat_type": 1,
"doc_ref_type": 0,
"item_code_main": "",
"ref_row": 0,
"ref_guid": "",
"doc_time": "10:15",
"is_permium": 0,
"is_get_price": 1,
"average_cost": 500,
"sum_amount_exclude_vat": 1440,
"doc_date_calc": "2021-06-17",
"doc_time_calc": "10:15",
"discount_amount": 0,
"price_exclude_vat": 480,
"user_approve": "",
"price_type": 6,
"price_mode": 6,
"temp_float_1": 0,
"temp_float_2": 0,
"temp_string_1": "",
"is_serial_number": 0,
"bank_name": "",
"bank_branch": "",
"chq_number": "",
"barcode": "",
"discount_number": 0,
"price_changed": 0,
"discount_changed": 0,
"price_default": 0,
"tax_type": 0,
"is_pos": 0,
"auto_create": 0,
"hidden_cost_1": 0,
"hidden_cost_1_exclude_vat": 0,
"hidden_cost_2": 0,
"hidden_cost_2_exclude_vat": 0,
"sum_of_cost_1": 1500,
"average_cost_1": 500,
"sale_code": "",
"sale_group": "",
"lot_number_1": "",
"item_code_2": "",
"bank_name_2": "",
"bank_branch_2": "",
"sale_shift_id": "",
"price_base": 0,
"creator_code": "",
"last_editor_code": "",
"fee_amount": 0,
"transfer_amount": 0,
"price_set_ratio": 0,
"mfn_code": "",
"mfn_name": "",
"price_2": 0,
"sum_amount_2": 0,
"price_guid": "",
"discount_amount_2": 0,
"is_lock_cost": 0,
"sum_of_cost_fix": 0,
"profit_lost_cost_amount": 0,
"is_doc_copy": 0,
"bat_number": "",
"product_year": "",
"product_week": "",
"currency_code": "",
"exchange_rate": 0,
"qty_2": 0,
"unit_code_2": "",
"total_size": 0,
"unit_size": 0,
"exchange_rate_old": 0,
"promotion_code": "",
"item_brand": "",
"item_brand_name": null,
"group_main": "D",
"group_main_name": "ເຫຼັກ",
"group_sub": "DG",
"group_sub_name": "ອຸປະກອນເຫຼັກຊັ້ນເກັບຂອງ"
}
],
"cust_name": "บริษัท ออนเวิร์ด",
"transport_name": "999",
"transport_address": "dd",
"transport_remark": "",
"transport_remark_2": "",
"latitude": 0,
"longitude": 0,
"billing_status": true,
"value_balance": 5040,
"total_cost_calc": 5116.9
}
],
"pages": {
"size": 1,
"page": 1,
"total_record": 36,
"max_page": 36
}
}Response Error
{
"success": false,
"error": true,
"message": "error message",
"code": "99"
}SaleInvoice Information
ดึงข้อมูลเอกสารใบขายสินค้า ทีละ 1 เอกสาร พร้อมรายละเอียดสินค้า, ข้อมูลขนส่ง และรายการชำระเงิน
EndPoint
GET /SMLJavaRESTService/saleinvoice/v4/{doc_no}
Path Parameter
| Name | Description | Example |
|---|---|---|
| doc_no | เลขที่เอกสาร (ต้องเป็นใบขาย is_pos = 0 — ถ้าส่งเลขที่บิล POS จะได้ 404) | INV2106-0001 |
Example:
GET localhost:8084/SMLJavaRESTService/saleinvoice/v4/INV2106-0001Response Success
ตัวอย่างจริงจากคำสั่ง
GET /SMLJavaRESTService/saleinvoice/v4/INV2106-0001
เอกสารนี้ไม่มีการรับชำระ (cb_trans) จึงไม่มี keypayment— ฟิลด์ที่เป็นnullจะไม่ถูกส่งออก ยกเว้นdue_dateและฟิลด์ยี่ห้อ/กลุ่มสินค้าที่ส่งเป็นnullเสมอ
{
"success": true,
"data": {
"trans_type": 2,
"trans_flag": 44,
"doc_group": "",
"doc_date": "2021-06-17",
"doc_no": "INV2106-0001",
"doc_ref": "",
"tax_doc_no": "INV2106-0001",
"tax_doc_date": "2021-06-17",
"inquiry_type": 1,
"vat_type": 1,
"cust_code": "AR20-00001",
"contactor": "",
"branch_code": "001",
"project_code": "",
"side_code": "",
"department_code": "",
"sale_area_code": "",
"sale_code": "",
"send_type": 0,
"send_day": 0,
"send_date": "2021-06-17",
"credit_day": 0,
"due_date": null,
"answer_type": 0,
"transport_value": 0,
"discount_word": "",
"vat_rate": 0,
"currency_code": "",
"exchange_rate": 0,
"total_cost": 0,
"total_value": 5040,
"total_discount": 0,
"total_vat_value": 0,
"total_after_vat": 5040,
"total_except_vat": 0,
"total_amount": 5040,
"balance_amount": 0,
"adjust_reason": "",
"approve_code": "",
"remark": "",
"status": 0,
"user_request": "",
"expire_day": 0,
"send_mail": 0,
"send_sms": 0,
"doc_ref_trans": "",
"credit_date": "2021-06-17",
"total_before_vat": 5040,
"doc_time": "10:15",
"allocate_code": "",
"job_code": "",
"pay_amount": 0,
"money": 0,
"sum_pay_money_diff": 0,
"currency_money": 0,
"total_debt_amount": 0,
"cancel_type": 0,
"last_status": 0,
"used_status": 0,
"doc_success": 0,
"total_manual": 0,
"on_hold": 0,
"extra_word": "",
"transport_code": "",
"want_day": 0,
"deposit_day": 0,
"sale_group": "",
"not_approve_1": 0,
"user_approve": "",
"approve_status": 0,
"expire_status": 0,
"advance_amount": 0,
"doc_format_code": "INV",
"used_status_2": 0,
"remark_2": "",
"remark_3": "",
"ref_amount": 0,
"ref_new_amount": 0,
"ref_diff": 0,
"sum_point": 0,
"cashier_code": "SUPERADMIN",
"is_pos": 0,
"pos_id": "",
"member_code": "",
"doc_no_guid": "",
"pos_bill_type": 0,
"pos_bill_change": 0,
"doc_type": 0,
"recheck_count_day": 0,
"recheck_count": 0,
"wh_from": "",
"location_from": "",
"wh_to": "",
"location_to": "",
"auto_create": 0,
"send_to_pick_and_pack": 0,
"service_charge_word": "",
"total_service_charge": 0,
"sale_shift_id": "",
"creator_code": "SUPERADMIN",
"last_editor_code": "",
"create_datetime": "2021-06-17 10:15:50",
"table_number": "",
"period_guid": "",
"branch_code_to": "",
"allocate_code_to": "",
"project_code_to": "",
"job_code_to": "",
"side_code_to": "",
"department_code_to": "",
"point_telephone": "",
"sum_point_2": 0,
"remark_4": "",
"remark_5": "",
"is_manual_vat": 0,
"pass_book_code": "",
"total_amount_2": 0,
"sender_code": "",
"is_cancel": 0,
"cancel_code": "",
"is_hold": 0,
"auto_approved": 0,
"pos_transfer": 0,
"doc_close": 0,
"ref_doc_type": "",
"is_doc_copy": 0,
"doc_reason": "",
"discount_word_2": "",
"total_discount_2": 0,
"total_value_2": 0,
"total_amout_old": 0,
"lost_profit_exchange_amount": 0,
"details": [
{
"trans_type": 2,
"trans_flag": 44,
"doc_group": "",
"doc_date": "2021-06-17",
"doc_no": "INV2106-0001",
"doc_ref": "",
"cust_code": "AR20-00001",
"inquiry_type": 1,
"item_code": "AGPAN15B001",
"item_name": "ใบตัดท้าย 15 นิ้ว",
"unit_code": "แผ่น",
"qty": 2,
"price": 300,
"discount": "",
"sum_of_cost": 616.9,
"sum_amount": 600,
"remark": "",
"status": 0,
"line_number": 0,
"ref_doc_no": "",
"ref_line_number": 0,
"ref_cust_code": "",
"branch_code": "001",
"wh_code": "01",
"shelf_code": "A",
"wh_code_2": "",
"shelf_code_2": "",
"department_code": "",
"total_vat_value": 0,
"cancel_qty": 0,
"total_qty": 0,
"stand_value": 1,
"divide_value": 1,
"ratio": 0,
"ic_pattern": "",
"ic_color": "",
"ic_size": "",
"priority_level": 0,
"calc_flag": -1,
"last_status": 0,
"set_ref_line": "",
"set_ref_price": 300,
"set_ref_qty": 0,
"item_type": 0,
"vat_type": 1,
"doc_ref_type": 0,
"item_code_main": "",
"ref_row": 0,
"ref_guid": "",
"doc_time": "10:15",
"is_permium": 0,
"is_get_price": 1,
"average_cost": 308.45,
"sum_amount_exclude_vat": 600,
"doc_date_calc": "2021-06-17",
"doc_time_calc": "10:15",
"discount_amount": 0,
"price_exclude_vat": 300,
"user_approve": "",
"price_type": 6,
"price_mode": 6,
"temp_float_1": 0,
"temp_float_2": 0,
"temp_string_1": "",
"is_serial_number": 0,
"bank_name": "",
"bank_branch": "",
"chq_number": "",
"barcode": "",
"discount_number": 0,
"price_changed": 0,
"discount_changed": 0,
"price_default": 0,
"tax_type": 0,
"is_pos": 0,
"auto_create": 0,
"hidden_cost_1": 0,
"hidden_cost_1_exclude_vat": 0,
"hidden_cost_2": 0,
"hidden_cost_2_exclude_vat": 0,
"sum_of_cost_1": 616.9,
"average_cost_1": 308.45,
"sale_code": "",
"sale_group": "",
"lot_number_1": "",
"item_code_2": "",
"bank_name_2": "",
"bank_branch_2": "",
"sale_shift_id": "",
"price_base": 0,
"creator_code": "",
"last_editor_code": "",
"fee_amount": 0,
"transfer_amount": 0,
"price_set_ratio": 0,
"mfn_code": "",
"mfn_name": "",
"price_2": 0,
"sum_amount_2": 0,
"price_guid": "",
"discount_amount_2": 0,
"is_lock_cost": 0,
"sum_of_cost_fix": 0,
"profit_lost_cost_amount": 0,
"is_doc_copy": 0,
"bat_number": "",
"product_year": "",
"product_week": "",
"currency_code": "",
"exchange_rate": 0,
"qty_2": 0,
"unit_code_2": "",
"total_size": 0,
"unit_size": 0,
"exchange_rate_old": 0,
"promotion_code": "",
"item_brand": "SCG",
"item_brand_name": "ກາຊ້າງ",
"group_main": "A",
"group_main_name": "ຊີມັງ",
"group_sub": "AA",
"group_sub_name": "ປູນເທົາ"
},
{
"trans_type": 2,
"trans_flag": 44,
"doc_group": "",
"doc_date": "2021-06-17",
"doc_no": "INV2106-0001",
"doc_ref": "",
"cust_code": "AR20-00001",
"inquiry_type": 1,
"item_code": "A-1100-98",
"item_name": "ใบตัดท้าย 18 นิ้ว",
"unit_code": "แผ่น",
"qty": 5,
"price": 600,
"discount": "",
"sum_of_cost": 3000,
"sum_amount": 3000,
"remark": "",
"status": 0,
"line_number": 1,
"ref_doc_no": "",
"ref_line_number": 0,
"ref_cust_code": "",
"branch_code": "001",
"wh_code": "01",
"shelf_code": "A",
"wh_code_2": "",
"shelf_code_2": "",
"department_code": "",
"total_vat_value": 0,
"cancel_qty": 0,
"total_qty": 0,
"stand_value": 1,
"divide_value": 1,
"ratio": 0,
"ic_pattern": "",
"ic_color": "",
"ic_size": "",
"priority_level": 0,
"calc_flag": -1,
"last_status": 0,
"set_ref_line": "",
"set_ref_price": 600,
"set_ref_qty": 0,
"item_type": 0,
"vat_type": 1,
"doc_ref_type": 0,
"item_code_main": "",
"ref_row": 0,
"ref_guid": "",
"doc_time": "10:15",
"is_permium": 0,
"is_get_price": 1,
"average_cost": 600,
"sum_amount_exclude_vat": 3000,
"doc_date_calc": "2021-06-17",
"doc_time_calc": "10:15",
"discount_amount": 0,
"price_exclude_vat": 600,
"user_approve": "",
"price_type": 6,
"price_mode": 6,
"temp_float_1": 0,
"temp_float_2": 0,
"temp_string_1": "",
"is_serial_number": 0,
"bank_name": "",
"bank_branch": "",
"chq_number": "",
"barcode": "",
"discount_number": 0,
"price_changed": 0,
"discount_changed": 0,
"price_default": 0,
"tax_type": 0,
"is_pos": 0,
"auto_create": 0,
"hidden_cost_1": 0,
"hidden_cost_1_exclude_vat": 0,
"hidden_cost_2": 0,
"hidden_cost_2_exclude_vat": 0,
"sum_of_cost_1": 3000,
"average_cost_1": 600,
"sale_code": "",
"sale_group": "",
"lot_number_1": "",
"item_code_2": "",
"bank_name_2": "",
"bank_branch_2": "",
"sale_shift_id": "",
"price_base": 0,
"creator_code": "",
"last_editor_code": "",
"fee_amount": 0,
"transfer_amount": 0,
"price_set_ratio": 0,
"mfn_code": "",
"mfn_name": "",
"price_2": 0,
"sum_amount_2": 0,
"price_guid": "",
"discount_amount_2": 0,
"is_lock_cost": 0,
"sum_of_cost_fix": 0,
"profit_lost_cost_amount": 0,
"is_doc_copy": 0,
"bat_number": "",
"product_year": "",
"product_week": "",
"currency_code": "",
"exchange_rate": 0,
"qty_2": 0,
"unit_code_2": "",
"total_size": 0,
"unit_size": 0,
"exchange_rate_old": 0,
"promotion_code": "",
"item_brand": "CLOCK",
"item_brand_name": "นาฬิกา",
"group_main": "A",
"group_main_name": "ຊີມັງ",
"group_sub": "AA",
"group_sub_name": "ປູນເທົາ"
},
{
"trans_type": 2,
"trans_flag": 44,
"doc_group": "",
"doc_date": "2021-06-17",
"doc_no": "INV2106-0001",
"doc_ref": "",
"cust_code": "AR20-00001",
"inquiry_type": 1,
"item_code": "AGPAN18A001",
"item_name": "ใบผาน 18",
"unit_code": "ใบ",
"qty": 3,
"price": 480,
"discount": "",
"sum_of_cost": 1500,
"sum_amount": 1440,
"remark": "",
"status": 0,
"line_number": 2,
"ref_doc_no": "",
"ref_line_number": 0,
"ref_cust_code": "",
"branch_code": "001",
"wh_code": "01",
"shelf_code": "A",
"wh_code_2": "",
"shelf_code_2": "",
"department_code": "",
"total_vat_value": 0,
"cancel_qty": 0,
"total_qty": 0,
"stand_value": 1,
"divide_value": 1,
"ratio": 0,
"ic_pattern": "",
"ic_color": "",
"ic_size": "",
"priority_level": 0,
"calc_flag": -1,
"last_status": 0,
"set_ref_line": "",
"set_ref_price": 480,
"set_ref_qty": 0,
"item_type": 0,
"vat_type": 1,
"doc_ref_type": 0,
"item_code_main": "",
"ref_row": 0,
"ref_guid": "",
"doc_time": "10:15",
"is_permium": 0,
"is_get_price": 1,
"average_cost": 500,
"sum_amount_exclude_vat": 1440,
"doc_date_calc": "2021-06-17",
"doc_time_calc": "10:15",
"discount_amount": 0,
"price_exclude_vat": 480,
"user_approve": "",
"price_type": 6,
"price_mode": 6,
"temp_float_1": 0,
"temp_float_2": 0,
"temp_string_1": "",
"is_serial_number": 0,
"bank_name": "",
"bank_branch": "",
"chq_number": "",
"barcode": "",
"discount_number": 0,
"price_changed": 0,
"discount_changed": 0,
"price_default": 0,
"tax_type": 0,
"is_pos": 0,
"auto_create": 0,
"hidden_cost_1": 0,
"hidden_cost_1_exclude_vat": 0,
"hidden_cost_2": 0,
"hidden_cost_2_exclude_vat": 0,
"sum_of_cost_1": 1500,
"average_cost_1": 500,
"sale_code": "",
"sale_group": "",
"lot_number_1": "",
"item_code_2": "",
"bank_name_2": "",
"bank_branch_2": "",
"sale_shift_id": "",
"price_base": 0,
"creator_code": "",
"last_editor_code": "",
"fee_amount": 0,
"transfer_amount": 0,
"price_set_ratio": 0,
"mfn_code": "",
"mfn_name": "",
"price_2": 0,
"sum_amount_2": 0,
"price_guid": "",
"discount_amount_2": 0,
"is_lock_cost": 0,
"sum_of_cost_fix": 0,
"profit_lost_cost_amount": 0,
"is_doc_copy": 0,
"bat_number": "",
"product_year": "",
"product_week": "",
"currency_code": "",
"exchange_rate": 0,
"qty_2": 0,
"unit_code_2": "",
"total_size": 0,
"unit_size": 0,
"exchange_rate_old": 0,
"promotion_code": "",
"item_brand": "",
"item_brand_name": null,
"group_main": "D",
"group_main_name": "ເຫຼັກ",
"group_sub": "DG",
"group_sub_name": "ອຸປະກອນເຫຼັກຊັ້ນເກັບຂອງ"
}
],
"cust_name": "บริษัท ออนเวิร์ด",
"transport_name": "999",
"transport_address": "dd",
"transport_remark": "",
"transport_remark_2": "",
"latitude": 0,
"longitude": 0,
"billing_status": true,
"value_balance": 5040,
"total_cost_calc": 5116.9
}
}Response Error
ไม่พบเอกสาร (รวมถึงกรณีส่งเลขที่บิลขาย POS มา) → HTTP
404
{
"success": false,
"error": true,
"message": "SaleInvoice not found: IV67110001",
"code": "404"
}Add SaleInvoice
สร้างเอกสารใบขายสินค้า
ถ้าส่ง field ขนส่งใดๆ มา ระบบจะ INSERT record ใน
ic_trans_shipment
ถ้าส่งpaymentobject มา ระบบจะ INSERT record ในcb_trans+cb_trans_detail
ออกใบขายอ้างอิงใบสั่งขาย (ได้หลายใบ) ส่งtransaction_refและref_doc_noใน details — ดู อ้างอิงใบสั่งขาย
ส่งtax_doc_noมา ระบบจะบันทึกภาษีขายให้ เอกสารจะแสดงใน รายงานภาษีขาย ของ SML (งวดภาษีตามเดือนของtax_doc_date) — ถ้าไม่ส่งtax_doc_dateระบบใช้doc_dateแทน
ระบบเติมstand_value/divide_value(อัตราส่วนหน่วยนับ) จากic_unit_useตามitem_code+unit_codeให้อัตโนมัติ — ดู การตรวจสอบข้อมูลก่อนบันทึก
หลังบันทึก ระบบส่งรหัสสินค้าเข้าคิวประมวลผลสต็อก (ตารางprocess) ให้อัตโนมัติ ยอดคงเหลือจะอัปเดตเมื่อ SML ประมวลผลคิว
EndPoint
POST /SMLJavaRESTService/saleinvoice/v4
Body Data:
JSON body with SaleInvoice Request Attribute
example:
{
"doc_no": "IV67110001",
"doc_date": "2024-11-15",
"doc_time": "14:30",
"doc_format_code": "IV",
"doc_ref": "",
"doc_ref_date": null,
"doc_group": "",
"cust_code": "AR00016",
"cust_name": "",
"contactor": "คุณสมชาย",
"tax_doc_no": "IV67110001",
"tax_doc_date": "2024-11-15",
"inquiry_type": 0,
"vat_type": 1,
"vat_rate": 7,
"sale_code": "S001",
"sale_group": "",
"branch_code": "001",
"department_code": "",
"allocate_code": "",
"project_code": "",
"job_code": "",
"side_code": "",
"send_type": 0,
"send_day": 0,
"send_date": null,
"credit_day": 30,
"credit_date": "2024-12-15",
"expire_day": 0,
"expire_date": null,
"on_hold": 0,
"approve_code": "",
"user_request": "",
"cashier_code": "",
"discount_word": "",
"total_value": 8450.86,
"total_discount": 0,
"total_before_vat": 7898,
"total_vat_value": 552.86,
"total_after_vat": 8450.86,
"total_except_vat": 0,
"total_amount": 8450.86,
"remark": "",
"remark_2": "",
"remark_3": "",
"remark_4": "",
"remark_5": "",
"transport_code": "TR01",
"transport_name": "บริษัท บลู ซิสเต็ม เทคโนโลยี จำกัด",
"transport_address": "33/4 เดอะไนน์ ทาวเวอร์ฯ",
"transport_remark": "ส่งช่วงเช้า",
"transport_remark_2": "",
"latitude": 13.7563,
"longitude": 100.5018,
"details": [
{
"line_number": 0,
"item_code": "AC-00014",
"barcode": "",
"unit_code": "อัน",
"qty": 4,
"price": 1974.5,
"discount": "",
"discount_amount": 0,
"sum_amount": 7898,
"sum_amount_exclude_vat": 7898,
"price_exclude_vat": 1974.5,
"total_vat_value": 552.86,
"tax_type": 0,
"wh_code": "CENTER",
"shelf_code": "CENTER",
"ref_doc_no": "SO67110005",
"ref_row": 0,
"doc_ref_type": 3,
"due_date": null,
"lot_number_1": "",
"remark": "",
"is_permium": 0,
"is_get_price": 1
}
],
"payment": {
"doc_no": "RC67110001",
"doc_date": "2024-11-15",
"doc_time": "14:30",
"doc_ref": "IV67110001",
"trans_type": 1,
"trans_flag": 12,
"doc_format_code": "RC",
"book_code": "CASH01",
"ap_ar_code": "AR00016",
"currency_code": "THB",
"exchange_rate": 1,
"pay_type": 1,
"cash_amount": 5000,
"tranfer_amount": 3450.86,
"card_amount": 0,
"chq_amount": 0,
"wallet_amount": 0,
"coupon_amount": 0,
"point_amount": 0,
"point_qty": 0,
"money_change": 0,
"deposit_amount": 0,
"advance_amount": 0,
"total_amount": 8450.86,
"total_amount_pay": 8450.86,
"total_net_amount": 8450.86,
"branch_code": "001",
"cashier_code": "CASH01",
"status": 0,
"detail": [
{
"line_number": 1,
"doc_type": 1,
"trans_number": "TR2024111501",
"bank_code": "SCB",
"bank_branch": "สาขาสีลม",
"amount": 3450.86,
"sum_amount": 3450.86,
"fee_amount": 0,
"chq_date": null,
"chq_due_date": null,
"no_approved": "",
"credit_card_type": "",
"remark": "โอนผ่าน SCB",
"status": 0,
"currency_code": "THB"
}
]
}
}Response Success
{
"success": true,
"data": {
"code": "IV67110001"
}
}Response Error
{
"error": true,
"code": "99",
"message": "error message"
}อ้างอิงใบสั่งขาย (Sale Order)
ใบขาย 1 ใบอ้างอิงใบสั่งขาย (SO) ได้ หลายใบ — ส่งข้อมูลอ้างอิงได้ 2 จุด ซึ่งมีผลต่างกัน
| ส่งที่ | ใช้ทำอะไร | ผลบนหน้าจอ SML |
|---|---|---|
transaction_ref (ระดับเอกสาร) | รายการเอกสารที่ใบขายนี้อ้างอิง | แสดงในส่วน เอกสารอ้างอิง ของใบขาย |
ref_doc_no ใน details (ระดับบรรทัด) | บอกว่าสินค้าบรรทัดนี้มาจาก SO ใบไหน บรรทัดไหน | ตัด ยอดค้างส่ง ของ SO รายสินค้า |
1. เอกสารอ้างอิง — transaction_ref
ส่งเป็น array — 1 รายการต่อ SO 1 ใบ (รายละเอียดทุก field ดู Transaction Ref Attribute)
| Field Name | Field Type | Length | Description |
|---|---|---|---|
| bill_type | String | ประเภทเอกสารอ้างอิง — 1 = ใบเสนอราคา, 2 = ใบสั่งซื้อ/ใบสั่งจอง, 3 = ใบสั่งขาย (ไม่ส่งมา ระบบใช้ 3 ให้) ดู ตาราง bill_type | |
| billing_date | Date | วันที่ของ SO (ไม่ส่งมา ระบบดึงจาก SO ให้) | |
| billing_no | String | 25 | เลขที่ SO (required) |
2. อ้างอิงรายบรรทัด — field ใน details
ใส่ในแต่ละบรรทัดสินค้าที่มาจาก SO
| Field Name | Field Type | Length | Description |
|---|---|---|---|
| doc_ref_type | Integer | ประเภทเอกสารอ้างอิง — 1 = ใบเสนอราคา, 2 = ใบสั่งซื้อ/ใบสั่งจอง, 3 = ใบสั่งขาย (ไม่ส่งมา ระบบใช้ 3 ให้) | |
| ref_doc_no | String | 25 | เลขที่ SO ที่สินค้าบรรทัดนี้มาจาก |
| ref_row | Integer | line_number ของบรรทัดใน SO (เริ่มที่ 0) |
ไม่ได้ส่ง SO ใน transaction_ref ก็ได้
SO ทุกใบที่มี ref_doc_no ใน details ระบบจะเพิ่มเข้า เอกสารอ้างอิง ให้อัตโนมัติ ถ้ายังไม่มีใน transaction_ref
SO ใบเดียวกันที่ส่งซ้ำ (ทั้งใน transaction_ref และ details) จะแสดงเพียงครั้งเดียว
example: ใบขาย 1 ใบ อ้างอิง SO 2 ใบ (SO67110005 2 บรรทัด และ SO67110006 1 บรรทัด)
{
"doc_no": "IV67110002",
"doc_date": "2024-11-16",
"doc_time": "10:00",
"doc_format_code": "IV",
"cust_code": "AR00016",
"vat_type": 1,
"vat_rate": 7,
"total_amount": 267,
"transaction_ref": [
{ "bill_type": "3", "billing_no": "SO67110005" },
{ "bill_type": "3", "billing_no": "SO67110006", "billing_date": "2024-11-10" }
],
"details": [
{
"line_number": 0,
"item_code": "AC-00014",
"unit_code": "อัน",
"qty": 3,
"price": 39,
"sum_amount": 117,
"wh_code": "CENTER",
"shelf_code": "CENTER",
"ref_doc_no": "SO67110005",
"ref_row": 0
},
{
"line_number": 1,
"item_code": "AC-00015",
"unit_code": "อัน",
"qty": 2,
"price": 25,
"sum_amount": 50,
"wh_code": "CENTER",
"shelf_code": "CENTER",
"ref_doc_no": "SO67110005",
"ref_row": 1
},
{
"line_number": 2,
"item_code": "AC-00020",
"unit_code": "อัน",
"qty": 1,
"price": 100,
"sum_amount": 100,
"wh_code": "CENTER",
"shelf_code": "CENTER",
"ref_doc_no": "SO67110006",
"ref_row": 0
}
]
}ผลบนหน้าจอ SML: เอกสารอ้างอิงแสดง SO67110005, SO67110006 และยอดค้างส่งของทั้ง 2 ใบถูกตัดตามสินค้าแต่ละบรรทัด
ยอดค้างส่ง
ยอดค้างส่งจะอัปเดตเมื่อ SML ประมวลผลคิวสต็อก ไม่ได้เปลี่ยนทันทีหลัง POST
WARNING
- ออกใบขายบางส่วนได้ (ส่ง
qtyน้อยกว่าใน SO) ยอดที่เหลือยังค้างส่งอยู่ - ระบบ ไม่ได้ ตรวจว่า
qtyเกินยอดค้างส่ง หรือref_rowตรงกับสินค้าใน SO — client ต้องส่งให้ถูกต้องเอง - ถ้าส่ง SO ไว้แค่ใน
transaction_refแต่ไม่ใส่ref_doc_noในบรรทัดสินค้า → SO จะแสดงเป็นเอกสารอ้างอิง แต่ ยอดค้างส่งจะไม่ถูกตัด
ปิดใบสั่งขาย
หลังบันทึกใบขาย ระบบอัปเดตสถานะของ SO ที่อ้างอิงใน ref_doc_no ทันที
used_status = 1— SO ถูกอ้างอิงแล้วdoc_success = 1— SO ปิด เมื่อยอดที่เปิดบิลรวมกับยอดที่ยกเลิกบางรายการ (SSC) ครบยอดใน SO (คิดเป็นหน่วยนับหลัก)
ตัวอย่าง: SO สั่ง 5 ลัง → ยกเลิกบางรายการ 2 ลัง → ออกใบขาย 3 ลัง → SO ปิด
สินค้าชุด
ส่งบรรทัดตัวชุด (สินค้าที่ item_type = 3 ในทะเบียนสินค้า) ตามด้วยบรรทัดสินค้าในชุด โดยใส่ item_code_main = รหัสสินค้าของตัวชุด
| Field | ส่งในบรรทัด | คำอธิบาย |
|---|---|---|
| ref_guid | ตัวชุด | ไม่ส่งมา → ระบบสร้าง GUID ให้ |
| item_code_main | สินค้าในชุด | รหัสสินค้าของบรรทัดตัวชุด |
| set_ref_line | สินค้าในชุด | ไม่ส่งมา → ระบบใช้ ref_guid ของบรรทัดตัวชุดที่อยู่ก่อนหน้าล่าสุดซึ่ง item_code = item_code_main |
| set_ref_qty | สินค้าในชุด | จำนวนต่อ 1 ชุด |
| set_ref_price | สินค้าในชุด | ราคาต่อชุด |
example: ขายสินค้าชุด G10-0038 จำนวน 2 ชุด (ในชุดมี G03-0001 และ G03-0004 อย่างละ 1)
{
"doc_no": "IV6910-0001",
"doc_date": "2026-10-15",
"doc_time": "13:55",
"doc_format_code": "INV",
"cust_code": "A00003",
"tax_doc_no": "IV6910-0001",
"vat_type": 1,
"vat_rate": 7,
"total_value": 1000,
"total_before_vat": 1000,
"total_vat_value": 70,
"total_after_vat": 1070,
"total_except_vat": 0,
"total_amount": 1070,
"details": [
{
"line_number": 0,
"item_code": "G10-0038",
"unit_code": "ชุด",
"wh_code": "ST01",
"shelf_code": "LC01",
"qty": 2,
"price": 500,
"sum_amount": 1000
},
{
"line_number": 1,
"item_code": "G03-0001",
"unit_code": "ถุง",
"wh_code": "ST01",
"shelf_code": "LC01",
"qty": 2,
"price": 0,
"sum_amount": 0,
"item_code_main": "G10-0038",
"set_ref_qty": 1
},
{
"line_number": 2,
"item_code": "G03-0004",
"unit_code": "ถุง",
"wh_code": "ST01",
"shelf_code": "LC01",
"qty": 2,
"price": 0,
"sum_amount": 0,
"item_code_main": "G10-0038",
"set_ref_qty": 1
}
]
}ผลที่บันทึกลง ic_trans_detail:
| line_number | item_code | item_code_main | ref_guid | set_ref_line |
|---|---|---|---|---|
| 0 | G10-0038 | ec1ab0c8-... (ระบบสร้าง) | ||
| 1 | G03-0001 | G10-0038 | ec1ab0c8-... | |
| 2 | G03-0004 | G10-0038 | ec1ab0c8-... |
TIP
ถ้าในบิลเดียวมีตัวชุดรหัสเดียวกันหลายบรรทัด บรรทัดในชุดจะผูกกับตัวชุดที่อยู่ก่อนหน้าล่าสุด — ให้เรียงบรรทัดตัวชุดแล้วตามด้วยสินค้าในชุดของมันเสมอ หรือส่ง ref_guid / set_ref_line มาเอง
การตรวจสอบข้อมูลก่อนบันทึก
ระบบตรวจข้อมูลก่อนบันทึก ถ้าไม่ผ่านจะตอบ HTTP 400 (code = "400") และ ไม่บันทึกเอกสาร
| เงื่อนไข | message |
|---|---|
unit_code ไม่ใช่หน่วยนับของสินค้านั้น | line_number {n}: unit_code '{unit}' not found for item_code '{item}' |
doc_ref_type ในบรรทัด ไม่ใช่ 1, 2, 3 | line_number {n}: reference type '{type}' is not supported (...) |
ref_doc_no ในบรรทัด ไม่พบเอกสาร หรือเอกสารถูกยกเลิก | line_number {n}: {ประเภท} '{doc_no}' not found or cancelled |
transaction_ref ไม่ได้ส่ง billing_no | transaction_ref[{i}]: billing_no is required |
transaction_ref ส่ง bill_type ที่ไม่ใช่ตัวเลข | transaction_ref[{i}]: bill_type '{type}' is not a number |
transaction_ref ส่ง bill_type ที่ไม่ใช่ 1, 2, 3 | transaction_ref[{i}]: reference type '{type}' is not supported (...) |
transaction_ref ไม่พบเอกสาร หรือเอกสารถูกยกเลิก | transaction_ref[{i}]: {ประเภท} '{doc_no}' not found or cancelled |
{i}= ลำดับในtransaction_refเริ่มที่ 0 /{ประเภท}=quotation(1),sale reserve(2),sale order(3)
example:
{
"success": false,
"error": true,
"code": "400",
"message": "line_number 0: sale order 'SO67110099' not found or cancelled"
}SaleInvoice Attribute
เรื่องต้นทุน
- ต้นทุนต่อรายการสินค้าอยู่ที่
sum_of_costในdetailsแต่ละบรรทัด- ต้นทุนรวมของเอกสารอยู่ที่
total_cost_calcซึ่งระบบคำนวณให้จากผลรวมsum_of_costของรายการสินค้า (ไม่นับบรรทัดที่ถูกยกเลิก)- ฟิลด์
total_costเป็นค่าที่ SML เก็บไว้ในเอกสาร ซึ่งปกติเป็น0จึงไม่ควรนำไปใช้- บันทึกผ่าน API โดยไม่ส่ง
average_cost/sum_of_costมา → ระบบเติมให้จากทุนเฉลี่ยของสินค้า ณ เวลาที่บันทึก (average_cost= ทุนเฉลี่ยต่อหน่วยนับหลัก,sum_of_cost=average_cost×qty×stand_value/divide_value) แล้ว SML จะคำนวณต้นทุนจริงทับเมื่อประมวลผลคิวสต็อก- เอกสารที่บันทึกผ่าน API ก่อน version 3.3.80 อาจมีต้นทุนเป็น
nullฟิลด์ read-only — ฟิลด์ที่ระบบ JOIN มาจากตารางอื่น (cust_name,sale_name,total_cost_calc,item_brand,item_brand_name,group_main,group_main_name,group_sub,group_sub_name) เป็นข้อมูลสำหรับอ่านเท่านั้น ถ้าส่งมาใน POST ระบบจะไม่นำไปบันทึก
ฟิลด์ที่ระบุ (required) คือฟิลด์ที่ต้องส่งใน POST request
ฟิลด์ที่ระบุ (read-only) คือฟิลด์ที่คืนเฉพาะตอน GET เท่านั้น
| Field Name | Field Type | Length | Description |
|---|---|---|---|
| adjust_reason | String | 25 | เหตุผลการปรับปรุง |
| advance_amount | Float | ตัดเงินมัดจำ | |
| allocate_code | String | 25 | การจัดสรร |
| answer_type | Integer | ลูกค้าตอบกลับ | |
| approve_code | String | 25 | กลุ่มผู้อนุมัติ |
| approve_date | Date | วันที่อนุมัติ | |
| approve_status | Integer | สถานะการอนุมัติ | |
| auto_approved | Integer | อนุมัติโดยอัตโนมัติ | |
| auto_create | Integer | สร้างโดยโปรแกรม | |
| balance_amount | Float | ยอดเงินคงเหลือ | |
| billing_status | Boolean | สถานะวางบิล (true = ชำระครบ) (read-only) | |
| branch_code | String | 25 | สาขา |
| branch_code_to | String | 25 | ถึงสาขา |
| cancel_code | String | 255 | ผู้ยกเลิกเอกสาร |
| cancel_datetime | Date | เวลายกเลิกเอกสาร | |
| cancel_type | Integer | ประเภทการยกเลิก | |
| cashier_code | String | 25 | Cashier |
| contactor | String | 25 | ผู้ติดต่อ |
| create_datetime | Date | วันที่สร้างเอกสาร | |
| creator_code | String | 255 | ผู้สร้างเอกสาร (ระบบบันทึกเป็น RESTAPI เสมอ ไม่รับจาก body) |
| credit_date | Date | วันที่ครบกำหนด | |
| credit_day | Integer | วันเครดิต | |
| currency_code | String | 25 | รหัสสกุลเงิน |
| currency_money | Float | ยอดคงเหลือ (ตามสกุลเงิน) | |
| cust_code | String | 25 | ลูกหนี้/เจ้าหนี้ |
| cust_name | String | ชื่อลูกค้า (จาก ar_customer) (read-only) | |
| delivery_date | Date | วันที่ส่งของ | |
| department_code | String | 25 | แผนก |
| department_code_to | String | 25 | ถึงแผนก |
| deposit_date | Date | ระยะเวลาภายใน (วันที่) | |
| deposit_day | Integer | ระยะเวลาภายใน (วัน) | |
| details | ArrayObject | รายละเอียดสินค้า | |
| discount_word | String | 25 | ส่วนลด |
| discount_word_2 | String | 25 | ส่วนลด (สกุลเงิน) |
| doc_close | Integer | ปิดเอกสาร | |
| doc_date | Date | เอกสารวันที่ (required) | |
| doc_format_code | String | 25 | รหัสเอกสาร |
| doc_group | String | 25 | กลุ่มเอกสาร |
| doc_no | String | 25 | เอกสารเลขที่ (required) |
| doc_no_guid | String | 25 | เลขที่เอกสารเปรียบเทียบ |
| doc_reason | String | เหตุผล | |
| doc_ref | String | 255 | เอกสารอ้างอิง (ไม่ส่งมา = ค่าว่าง) |
| doc_ref_date | Date | เอกสารอ้างอิงวันที่ | |
| doc_ref_trans | String | อ้างอิงเอกสาร | |
| doc_success | Integer | สิ้นสุด | |
| doc_time | String | 5 | เวลา (HH:mm) |
| doc_type | Integer | ประเภทเอกสาร | |
| due_date | Date | วันที่ครบกำหนด | |
| exchange_rate | Float | อัตราแลกเปลี่ยน | |
| expire_date | Date | วันที่หมดอายุ | |
| expire_day | Integer | จำนวนวันหมดอายุ | |
| expire_status | Integer | สถานะหมดอายุ | |
| extra_word | String | ข้อความเพิ่มเติม | |
| guid_code | String | GUID | |
| inquiry_type | Integer | ประเภทรายการ | |
| is_cancel | Integer | เอกสารยกเลิก (บันทึกใหม่ = 0) | |
| is_doc_copy | Integer | เป็นเอกสารที่ออกแทน | |
| is_hold | Integer | ระงับเอกสาร | |
| is_manual_vat | Integer | บันทึกรายการภาษีเอง (บันทึกใหม่ = 0) | |
| is_pos | Integer | จากระบบ POS (default: 0) | |
| job_code | String | 25 | งาน |
| job_code_to | String | 25 | ถึงงาน |
| last_editor_code | String | 255 | ผู้แก้ไขเอกสารล่าสุด |
| last_status | Integer | สถานะล่าสุด (บันทึกใหม่ = 0) | |
| lastedit_datetime | Date | วันที่แก้ไขล่าสุด | |
| latitude | Float | ละติจูด (เก็บใน ic_trans_shipment) | |
| location_from | String | พื้นที่เก็บ (ต้นทาง) | |
| location_to | String | พื้นที่เก็บ (ปลายทาง) | |
| longitude | Float | ลองจิจูด (เก็บใน ic_trans_shipment) | |
| lost_profit_exchange_amount | Float | ผลต่างจากอัตราแลกเปลี่ยน | |
| member_code | String | 25 | รหัสสมาชิก |
| money | Float | จำนวนเงินคืน | |
| not_approve_1 | Integer | ไม่อนุมัติ | |
| on_hold | Integer | ระงับชั่วคราว | |
| pass_book_code | String | สมุดเงินฝาก | |
| pay_amount | Float | เงินชำระ | |
| payment | Object | ข้อมูลชำระเงิน | |
| period_guid | String | GUID กะ | |
| point_telephone | String | หมายเลขโทรศัพท์ | |
| pos_bill_change | Integer | 0=ปรกติ, 1=ใบแทน | |
| pos_bill_type | Integer | 0=อย่างย่อ, 1=อย่างเต็ม | |
| pos_id | String | หมายเลขเครื่อง POS | |
| pos_transfer | Integer | โอนมาจาก POS | |
| project_code | String | 25 | โครงการ |
| project_code_to | String | 25 | ถึงโครงการ |
| recheck_count | Integer | เปิดระบบเตือนตรวจนับซ้ำ | |
| recheck_count_day | Float | เตือนย้อนหลัง (วัน) | |
| ref_amount | Float | มูลค่าเอกสารเดิม | |
| ref_diff | Float | ผลต่าง | |
| ref_new_amount | Float | มูลค่าที่ถูกต้อง | |
| remark | String | 255 | หมายเหตุ |
| remark_2 | String | 255 | หมายเหตุ 2 |
| remark_3 | String | 255 | หมายเหตุ 3 |
| remark_4 | String | 255 | หมายเหตุ 4 |
| remark_5 | String | 255 | หมายเหตุ 5 |
| sale_area_code | String | 25 | เขตการขาย |
| sale_code | String | 25 | พนักงานขาย |
| sale_group | String | 25 | กลุ่มพนักงานขาย |
| sale_name | String | ชื่อพนักงานขาย (จาก erp_user) (read-only) | |
| sale_shift_id | String | รอบการขาย | |
| send_date | Date | วันที่รับ/ส่งสินค้า | |
| send_day | Integer | รับ/ส่ง ภายใน (วัน) | |
| send_mail | Integer | แจ้งส่งทางอีเมล์ | |
| send_sms | Integer | แจ้งส่งทาง SMS | |
| send_to_pick_and_pack | Integer | สั่งจัดสินค้า | |
| send_type | Integer | ประเภทการส่ง | |
| sender_code | String | พนักงานขนส่ง | |
| service_charge_word | String | Service Charge | |
| side_code | String | 25 | ฝ่าย |
| side_code_to | String | 25 | ถึงฝ่าย |
| status | Integer | สถานะ | |
| sum_pay_money_diff | Float | ผลต่างยอดชำระ | |
| sum_point | Float | แต้ม | |
| sum_point_2 | Float | ยอดแต้มสะสมระบบกลาง | |
| table_number | String | หมายเลขโต๊ะ | |
| tax_doc_date | Date | วันที่ใบกำกับ (ไม่ส่งมา ระบบใช้ doc_date เมื่อมี tax_doc_no) | |
| tax_doc_no | String | 25 | เลขที่ใบกำกับ — ส่งมาแล้วเอกสารจะเข้ารายงานภาษีขาย |
| total_after_vat | Float | มูลค่าหลังคิดภาษี | |
| total_amount | Float | มูลค่าสุทธิ | |
| total_amount_2 | Float | มูลค่าสุทธิ (สกุลเงิน) | |
| total_amout_old | Float | มูลค่าสุทธิเดิม | |
| total_before_vat | Float | ยอดก่อนภาษี | |
| total_cost_calc | Float | ต้นทุนรวมของเอกสาร คำนวณจากผลรวม sum_of_cost ของรายการสินค้า (read-only) | |
| total_cost | Float | ต้นทุนสินค้า | |
| total_debt_amount | Float | ยอดหนี้รวมภาษี | |
| total_discount | Float | มูลค่าส่วนลด | |
| total_discount_2 | Float | มูลค่าส่วนลด (สกุลเงิน) | |
| total_except_vat | Float | มูลค่ายกเว้นภาษี | |
| total_manual | Integer | บันทึกยอดรวมเอง | |
| total_service_charge | Float | มูลค่า Service Charge | |
| total_vat_value | Float | ภาษีมูลค่าเพิ่ม | |
| total_value | Float | มูลค่าสินค้า | |
| total_value_2 | Float | มูลค่าสินค้า (สกุลเงิน) | |
| trans_flag | Integer | รายวันระบบ (44 = ใบขายสินค้า, auto) | |
| trans_type | Integer | ประเภทรายวัน (2 = ขาย, auto) | |
| transaction_ref | Array | เอกสารอ้างอิง (POST) — ดู Transaction Ref Attribute | |
| transport_address | String | 1000 | ที่อยู่จัดส่ง (เก็บใน ic_trans_shipment) |
| transport_code | String | 25 | ขนส่งโดย |
| transport_name | String | 255 | ชื่อผู้รับ (เก็บใน ic_trans_shipment) |
| transport_remark | String | 255 | หมายเหตุจัดส่ง (เก็บใน ic_trans_shipment.remark) |
| transport_remark_2 | String | 255 | หมายเหตุจัดส่ง 2 (เก็บใน ic_trans_shipment.remark_2) |
| transport_value | Float | ค่าขนส่ง | |
| used_status | Integer | มีการอ้างอิงแล้ว | |
| used_status_2 | Integer | สถานะ 2 | |
| user_approve | String | ผู้อนุมัติ | |
| user_request | String | ผู้ขออนุมัติ | |
| value_balance | Float | ยอดคงค้าง (total_amount − ยอดรับชำระ) (read-only) | |
| vat_rate | Float | อัตราภาษี | |
| vat_type | Integer | ประเภทภาษี (0=แยกนอก, 1=รวมใน, 2=ยกเว้นภาษี, 3=ไม่กระทบภาษี) — หมายเหตุ: ค่าคนละชุดกับ detail | |
| want_date | Date | ต้องการภายใน (วันที่) | |
| want_day | Integer | ต้องการภายใน (วัน) | |
| wh_from | String | คลัง (ต้นทาง) | |
| wh_to | String | คลัง (ปลายทาง) |
SaleInvoice Detail
ฟิลด์ที่ระบุ (required) คือฟิลด์ที่ต้องส่งใน POST request
| Field Name | Field Type | Length | Description |
|---|---|---|---|
| auto_create | Integer | สร้างโดยโปรแกรม | |
| average_cost | Float | ราคาทุนเฉลี่ยต่อหน่วยนับหลัก (ไม่ส่งมา = ทุนเฉลี่ยของสินค้า ณ เวลาที่บันทึก) | |
| average_cost_1 | Float | ราคาทุนเฉลี่ยแฝง | |
| bank_branch | String | สาขาธนาคาร | |
| bank_branch_2 | String | สาขาธนาคาร 2 | |
| bank_name | String | ธนาคาร | |
| bank_name_2 | String | ธนาคาร 2 | |
| barcode | String | 25 | Barcode |
| bat_date | Date | bat date | |
| bat_number | String | bat number | |
| branch_code | String | 25 | สาขา |
| calc_flag | Integer | บวกหรือลบ (1=บวก, -1=ลบ, default: -1) | |
| cancel_qty | Float | จำนวนยกเลิก | |
| chq_number | String | เลขที่เช็ค | |
| create_datetime | Date | วันที่สร้างเอกสาร | |
| creator_code | String | ผู้สร้างเอกสาร (ระบบบันทึกเป็น RESTAPI เสมอ) | |
| currency_code | String | 25 | สกุลเงิน |
| cust_code | String | 25 | ลูกหนี้/เจ้าหนี้ |
| date_due | Date | วันครบกำหนด | |
| date_expire | Date | หมดอายุ | |
| department_code | String | 25 | แผนก |
| discount | String | 25 | ส่วนลด |
| discount_amount | Float | มูลค่าส่วนลด | |
| discount_amount_2 | Float | มูลค่าส่วนลด (สกุลเงิน) | |
| discount_changed | Integer | มีการแก้ไขส่วนลด | |
| discount_number | Integer | หมายเลขส่วนลด | |
| divide_value | Float | ตัวหาร (ไม่ส่งมา ระบบเติมจาก ic_unit_use) | |
| doc_date | Date | เอกสารวันที่ | |
| doc_date_calc | Date | วันที่สำหรับคำนวณ | |
| doc_group | String | กลุ่มเอกสาร | |
| doc_no | String | 25 | เอกสารเลขที่ |
| doc_ref | String | เอกสารอ้างอิง | |
| doc_ref_type | Integer | ประเภทเอกสารอ้างอิง (1=ใบเสนอราคา, 2=ใบสั่งซื้อ/ใบสั่งจอง, 3=ใบสั่งขาย — default 3 เมื่อส่ง ref_doc_no มา) | |
| doc_time | String | เวลา | |
| doc_time_calc | String | เวลาสำหรับคำนวณ | |
| due_date | Date | วันที่ต้องการ | |
| exchange_rate | Float | อัตราแลกเปลี่ยน | |
| exchange_rate_old | Float | อัตราแลกเปลี่ยนเดิม | |
| fee_amount | Float | ค่าธรรมเนียม | |
| group_main | String | 25 | รหัสกลุ่มสินค้าหลัก (จากทะเบียนสินค้า) (read-only) |
| group_main_name | String | 255 | ชื่อกลุ่มสินค้าหลัก (read-only) |
| group_sub | String | 25 | รหัสกลุ่มสินค้าย่อย (จากทะเบียนสินค้า) (read-only) |
| group_sub_name | String | 255 | ชื่อกลุ่มสินค้าย่อย (read-only) |
| hidden_cost_1 | Float | ต้นทุนแฝงบริหาร | |
| hidden_cost_1_exclude_vat | Float | ต้นทุนแฝงบริหารไม่รวมภาษี | |
| hidden_cost_2 | Float | ต้นทุนแฝงบัญชี | |
| hidden_cost_2_exclude_vat | Float | ต้นทุนแฝงบัญชีไม่รวมภาษี | |
| ic_color | String | สีสินค้า | |
| ic_pattern | String | รูปแบบสินค้า | |
| ic_size | String | ขนาดสินค้า | |
| inquiry_type | Integer | ประเภทการซื้อ | |
| is_doc_copy | Integer | เป็นเอกสารที่ออกแทน | |
| is_get_price | Integer | ให้ดึงราคาขาย (1=ดึง) | |
| is_lock_cost | Integer | กำหนดต้นทุนเอง | |
| is_permium | Integer | 1=ของแถม | |
| is_pos | Integer | จาก POS | |
| is_serial_number | Integer | มีหมายเลขเครื่อง | |
| item_brand | String | 25 | รหัสยี่ห้อสินค้า (จากทะเบียนสินค้า) (read-only) |
| item_brand_name | String | 255 | ชื่อยี่ห้อสินค้า (read-only) |
| item_code | String | 25 | รหัสสินค้า |
| item_code_2 | String | 25 | รหัสสินค้า 2 |
| item_code_main | String | 25 | สินค้าชุด: รหัสสินค้าของบรรทัดตัวชุด (ส่งในบรรทัดสินค้าในชุด) |
| item_name | String | 255 | ชื่อสินค้า |
| item_type | Integer | ประเภทสินค้า | |
| last_editor_code | String | ผู้แก้ไขเอกสารล่าสุด | |
| last_status | Integer | สถานะล่าสุด (0=Normal, 1=ยกเลิก) | |
| lastedit_datetime | Date | วันที่แก้ไขล่าสุด | |
| line_number | Integer | บรรทัด | |
| lot_number_1 | String | เลข LOT | |
| mfd_date | Date | วันที่ผลิต | |
| mfn_code | String | รหัสผู้ผลิต | |
| mfn_name | String | ผู้ผลิต | |
| price | Float | ราคา | |
| price_2 | Float | ราคา (สกุลเงิน) | |
| price_base | Float | ราคากลาง | |
| price_changed | Integer | มีการแก้ไขราคา | |
| price_default | Float | ราคาเริ่มต้น | |
| price_exclude_vat | Float | ราคาไม่รวมภาษี | |
| price_guid | String | Price Guid | |
| price_mode | Integer | กลุ่มราคา | |
| price_set_ratio | Float | อัตราส่วนราคาสินค้าชุด | |
| price_type | Integer | ประเภทราคา | |
| priority_level | Integer | ความสำคัญ | |
| product_week | String | สัปดาห์ที่ผลิต | |
| product_year | String | ปีที่ผลิต | |
| profit_lost_cost_amount | Float | กำไรขาดทุน | |
| promotion_code | String | รหัสโปรโมชั่น | |
| qty | Float | จำนวน | |
| qty_2 | Float | จำนวนขาย | |
| ratio | Float | อัตราส่วน | |
| ref_cust_code | String | 25 | อ้างอิง เจ้าหนี้/ลูกหนี้ |
| ref_doc_date | Date | อ้างอิง วันที่ | |
| ref_doc_no | String | 25 | เลขที่เอกสารที่อ้างอิง (เช่น เลขที่ใบสั่งขาย) |
| ref_guid | String | สินค้าชุด: GUID ของบรรทัดตัวชุด (ไม่ส่งมา ระบบสร้างให้) | |
| ref_line_number | Integer | อ้างอิง บรรทัด | |
| ref_row | Integer | บรรทัดของเอกสารที่อ้างอิง (line_number ในใบสั่งขาย) | |
| remark | String | 255 | หมายเหตุ |
| sale_code | String | 25 | รหัสพนักงานขาย |
| sale_group | String | 25 | กลุ่มพนักงานขาย |
| sale_shift_id | String | รอบการขาย | |
| set_ref_line | String | สินค้าชุด: ref_guid ของบรรทัดตัวชุด (ไม่ส่งมา ระบบผูกให้) | |
| set_ref_price | Float | สินค้าชุด: ราคาต่อชุด | |
| set_ref_qty | Float | สินค้าชุด: จำนวนต่อ 1 ชุด | |
| shelf_code | String | 25 | พื้นที่เก็บ |
| shelf_code_2 | String | 25 | พื้นที่เก็บ 2 |
| stand_value | Float | ตัวตั้ง (ไม่ส่งมา ระบบเติมจาก ic_unit_use) | |
| status | Integer | สถานะ | |
| sum_amount | Float | รวมมูลค่า | |
| sum_amount_2 | Float | รวมมูลค่า (สกุลเงิน) | |
| sum_amount_exclude_vat | Float | รวมมูลค่าไม่รวมภาษี | |
| sum_of_cost | Float | รวมต้นทุน (ไม่ส่งมา = average_cost × qty × stand_value / divide_value) | |
| sum_of_cost_1 | Float | ต้นทุนรวมต้นทุนแฝงบริหาร | |
| sum_of_cost_fix | Float | ต้นทุน (กำหนดเอง) | |
| tax_type | Integer | ประเภทภาษี (0=มีภาษี, 1=ยกเว้น) | |
| temp_float_1 | Float | ตัวเลข 1 | |
| temp_float_2 | Float | ตัวเลข 2 | |
| temp_string_1 | String | ตัวอักษร 1 | |
| total_qty | Float | จำนวนคงเหลือ | |
| total_size | Float | รวมหน่วยนับ 2 | |
| total_vat_value | Float | ภาษีมูลค่าเพิ่มรายบรรทัด — ส่งตอน POST ได้ (ส่งในชื่อ vat_amount แทนก็ได้ ถ้าส่งทั้งคู่ใช้ total_vat_value) | |
| trans_flag | Integer | รายวันระบบ (44 = ใบขายสินค้า, auto) | |
| trans_type | Integer | ประเภทรายวัน (2 = ขาย, auto) | |
| transfer_amount | Float | ยอดโอนเงิน | |
| unit_code | String | 25 | หน่วยนับ (ต้องมีใน ic_unit_use ของสินค้านั้น) (required) |
| unit_code_2 | String | 25 | หน่วยช่วยขาย |
| unit_size | Float | ขนาดสินค้า | |
| user_approve | String | รหัสผู้อนุมัติ | |
| vat_type | Integer | ประเภทภาษี (0=แยกนอก, 1=รวมใน, 2=อัตรา 0) | |
| wh_code | String | 25 | คลัง |
| wh_code_2 | String | 25 | คลัง 2 |
Transaction Ref Attribute
โครงสร้างแต่ละรายการใน transaction_ref (เอกสารอ้างอิง) — ส่งเป็น array 1 รายการต่อเอกสาร 1 ใบ ใช้ตอน POST
วิธีใช้และตัวอย่างเต็ม ดู อ้างอิงใบสั่งขาย
| Field Name | Field Type | Length | Description |
|---|---|---|---|
| bill_type | String | ประเภทเอกสารที่อ้างอิง (ดูตาราง bill_type ด้านล่าง) — ไม่ส่งมา ระบบใช้ 3 (ใบสั่งขาย) | |
| billing_date | Date | วันที่ของเอกสารที่อ้างอิง (yyyy-MM-dd) — ไม่ส่งมา ระบบดึงวันที่จากเอกสารนั้นให้ | |
| billing_no | String | 25 | เลขที่เอกสารที่อ้างอิง เช่น เลขที่ใบสั่งขาย (required) |
bill_type — ประเภทเอกสารที่ใบขายอ้างอิงได้
| ค่า | เอกสารที่อ้างอิง | ผลเมื่อใส่ ref_doc_no ในบรรทัดสินค้าด้วย |
|---|---|---|
1 | ใบเสนอราคา | — |
2 | ใบสั่งซื้อ/ใบสั่งจอง | ตัดยอดค้างจองของใบสั่งจอง |
3 | ใบสั่งขาย (Sale Order) | ตัดยอดค้างส่งของใบสั่งขาย |
ระบบตรวจว่าเอกสารตาม
bill_typeมีอยู่จริงและไม่ถูกยกเลิก — ค่าอื่นนอกจาก 1, 2, 3 จะตอบ error
ค่าเดียวกันนี้ใช้กับ
doc_ref_typeในdetails— ควรส่งให้ตรงกัน
example:
"transaction_ref": [
{ "bill_type": "3", "billing_no": "SO67110005" },
{ "billing_no": "SO67110006", "billing_date": "2024-11-10" }
]Payment Attribute
โครงสร้าง payment object (เก็บใน cb_trans)
ส่ง
paymentมาตอน POST → ระบบจะ INSERT record ในcb_trans+cb_trans_detail
ตอน GET ระบบจะค้น cb_trans ด้วยcb_trans.doc_ref = ic_trans.doc_no
| Field Name | Field Type | Length | Description |
|---|---|---|---|
| advance_amount | Float | ตัดเงินมัดจำ | |
| ap_ar_code | String | 25 | รหัสเจ้าหนี้/ลูกหนี้ (default = cust_code ของเอกสาร) |
| book_code | String | 25 | สมุดรายวัน |
| branch_code | String | 25 | รหัสสาขา |
| card_amount | Float | ยอดบัตรเครดิต | |
| cash_amount | Float | ยอดเงินสด | |
| cashier_code | String | 25 | Cashier |
| chq_amount | Float | ยอดเช็ค | |
| coupon_amount | Float | ยอดชำระด้วยคูปอง | |
| currency_code | String | 25 | รหัสสกุลเงิน |
| deposit_amount | Float | ยอดตัดเงินล่วงหน้า | |
| description | String | รายละเอียด | |
| detail | ArrayObject | รายละเอียดการชำระ | |
| discount_amount | Float | ส่วนลดชำระเงิน | |
| doc_date | Date | เอกสารวันที่ (default = doc_date ของใบขาย) | |
| doc_format_code | String | 25 | รหัสรูปแบบเอกสาร |
| doc_group | String | กลุ่มเอกสาร | |
| doc_no | String | 25 | เอกสารเลขที่ของใบรับเงิน (required ใน payment) |
| doc_ref | String | เอกสารอ้างอิง (default = doc_no ของใบขาย) | |
| doc_time | String | 5 | เวลา |
| exchange_rate | Float | อัตราแลกเปลี่ยน | |
| guid_code | String | GUID | |
| is_doc_copy | Integer | เป็นเอกสารออกแทน | |
| money_change | Float | เงินทอน | |
| pay_cash_amount | Float | จ่ายเงิน | |
| pay_type | Integer | 1=รับ, 2=จ่าย | |
| petty_cash_amount | Float | เงินสดย่อย | |
| point_amount | Float | ยอดชำระด้วยแต้ม | |
| point_qty | Float | จำนวนแต้มที่ใช้ | |
| point_rate | Float | แต้มต่อบาท | |
| remark | String | หมายเหตุ | |
| sale_shift_id | String | รอบการขาย | |
| status | Integer | สถานะ | |
| total_amount | Float | รวมยอดเงิน | |
| total_amount_pay | Float | รวมจ่าย | |
| total_credit_charge | Float | ค่า Charge บัตรเครดิต | |
| total_expense_other | Float | รายจ่ายอื่น | |
| total_fee_amount | Float | ค่าธรรมเนียม | |
| total_income_amount | Float | ปัดเศษ | |
| total_income_other | Float | รายได้อื่น | |
| total_net_amount | Float | ยอดรวมทั้งสิ้น | |
| total_other_amount | Float | ปัดเศษ (ลด) | |
| total_other_currency | Float | สกุลเงินอื่นๆ | |
| total_tax_at_pay | Float | ภาษีหัก ณ ที่จ่าย | |
| tranfer_amount | Float | ยอดเงินโอน (สะกดตามฐานข้อมูล) | |
| trans_flag | Integer | รายวันระบบ | |
| trans_type | Integer | ประเภทรายวัน (1=รับเงิน, 2=จ่ายเงิน) | |
| wallet_amount | Float | Wallet Payment |
Payment Detail
โครงสร้าง payment.detail[] (เก็บใน cb_trans_detail) — รายการย่อยของการชำระเงินแยกตามวิธี (เช่น แต่ละใบเช็ค, แต่ละบัตรเครดิต, แต่ละการโอน)
| Field Name | Field Type | Length | Description |
|---|---|---|---|
| amount | Float | จำนวนเงิน | |
| ap_ar_code | String | 25 | รหัสเจ้าหนี้/ลูกหนี้ (default = cust_code ของเอกสาร) |
| ap_ar_type | Integer | 1=ลูกหนี้, 2=เจ้าหนี้ | |
| approve_code | String | 25 | กลุ่มผู้อนุมัติ |
| approve_date | Date | วันที่อนุมัติ | |
| balance_amount | Float | ยอดคงเหลือ | |
| bank_branch | String | สาขาธนาคาร | |
| bank_code | String | รหัสธนาคาร | |
| charge | Float | ยอด Charge | |
| chq_date | Date | วันที่ออกเช็ค/รับเช็ค | |
| chq_due_date | Date | วันที่บนเช็ค | |
| chq_on_hand | Integer | ประเภทเช็ค | |
| chq_ref | String | อ้างอิงเช็คเลขที่ | |
| credit_card_type | String | ประเภทบัตรเครดิต | |
| currency_code | String | รหัสสกุลเงิน | |
| doc_date | Date | เอกสารวันที่ (default = doc_date ของ payment header) | |
| doc_date_ref | Date | วันที่อ้างอิง | |
| doc_group | String | กลุ่มเอกสาร | |
| doc_no | String | 25 | เอกสารเลขที่ (auto fill = payment.doc_no) |
| doc_ref | String | เอกสารอ้างอิง | |
| doc_time | String | เวลา | |
| doc_type | Integer | 1=เงินโอน, 2=เช็ค, 3=บัตรเครดิต, 4=เงินสดย่อย, 5=เงินล่วงหน้า, 9=คูปอง, 11=จ่ายอื่น, 12=รับอื่น, 19=สกุลเงินอื่น, 21=eWallet | |
| exchange_rate | Float | อัตราแลกเปลี่ยน | |
| external_chq | Integer | การเรียกเก็บ | |
| fee_amount | Float | ค่าธรรมเนียม | |
| is_doc_copy | Integer | เอกสารออกแทน | |
| last_status | Integer | สถานะล่าสุด | |
| line_number | Integer | บรรทัด (auto +1 ถ้าไม่ส่ง) | |
| no_approved | String | เลขที่อนุมัติ | |
| other_amount | Float | ค่าใช้จ่ายอื่นๆ | |
| pass_book_code | String | สมุดเงินฝาก | |
| period_number | Integer | งวดที่ | |
| ref1 | String | เลขที่อ้างอิง 1 | |
| ref2 | String | เลขที่อ้างอิง 2 | |
| remark | String | หมายเหตุ | |
| sale_shift_id | String | รอบการขาย | |
| status | Integer | สถานะ | |
| sum_amount | Float | ยอดเงินรวม | |
| sum_amount_2 | Float | รวมจำนวนเงิน (สกุลเงิน) | |
| tax_at_pay | Float | ภาษีหัก ณ ที่จ่าย | |
| trans_flag | Integer | รายวันระบบ | |
| trans_number | String | เลขที่เช็ค/เลขที่อนุมัติ | |
| trans_number_type | Integer | ประเภท (1=รับ, 2=จ่าย) | |
| trans_type | Integer | ประเภทรายวัน |