Skip to content

Sale Invoice Service ​

API ใบขายสินค้า (ใบส่งของ/ใบกำกับภาษี)


Header Request ​

FieldValue
GUIDGUID สำหรับการเชื่อมต่อ (smlx เสมอ)
providerชื่อผู้ใช้บริการ
databaseNameชื่อฐานข้อมูล
configFileNameชื่อไฟล์ตั้งค่า — รูปแบบ SMLConfig<provider>.xml
Content-Typeapplication/json; charset=utf-8

Header Example ​

json
{
  "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 ไม่ถูกต้อง
500payload ผิดรูป หรือข้อผิดพลาดภายในระบบ

SaleInvoice List ​

แสดงข้อมูลเอกสารใบขายสินค้า ทั้งหมด

EndPoint ​

GET /SMLJavaRESTService/saleinvoice/v4

ขอบเขตข้อมูล: คืนเฉพาะใบขาย (trans_flag = 44, is_pos = 0) ที่ยังไม่ถูกยกเลิก (last_status = 0)
บิลขาย POS อยู่ที่ Sale Invoice POS Service คนละเส้นกัน

Query Request ​

FieldDescriptionExample
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-dd
  • size คือจำนวนเอกสารต่อหน้า แต่ละเอกสารจะมีรายการสินค้า (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=10

Response Success ​

ตัวอย่างจริงจากคำสั่ง GET /SMLJavaRESTService/saleinvoice/v4?page=1&size=1&cust_code=AR20-00001

json
{
    "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 ​

json
{
    "success": false,
    "error": true,
    "message": "error message",
    "code": "99"
}

SaleInvoice Information ​

ดึงข้อมูลเอกสารใบขายสินค้า ทีละ 1 เอกสาร พร้อมรายละเอียดสินค้า, ข้อมูลขนส่ง และรายการชำระเงิน

EndPoint ​

GET /SMLJavaRESTService/saleinvoice/v4/{doc_no}

Path Parameter ​

NameDescriptionExample
doc_noเลขที่เอกสาร (ต้องเป็นใบขาย is_pos = 0 — ถ้าส่งเลขที่บิล POS จะได้ 404)INV2106-0001

Example: ​

GET localhost:8084/SMLJavaRESTService/saleinvoice/v4/INV2106-0001

Response Success ​

ตัวอย่างจริงจากคำสั่ง GET /SMLJavaRESTService/saleinvoice/v4/INV2106-0001
เอกสารนี้ไม่มีการรับชำระ (cb_trans) จึงไม่มี key payment — ฟิลด์ที่เป็น null จะไม่ถูกส่งออก ยกเว้น due_date และฟิลด์ยี่ห้อ/กลุ่มสินค้าที่ส่งเป็น null เสมอ

json
{
    "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

json
{
    "success": false,
    "error": true,
    "message": "SaleInvoice not found: IV67110001",
    "code": "404"
}

Add SaleInvoice ​

สร้างเอกสารใบขายสินค้า

ถ้าส่ง field ขนส่งใดๆ มา ระบบจะ INSERT record ใน ic_trans_shipment
ถ้าส่ง payment object มา ระบบจะ 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:

json
{
    "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 ​

json
{
    "success": true,
    "data": {
        "code": "IV67110001"
    }
}

Response Error ​

json
{
    "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 NameField TypeLengthDescription
bill_typeStringประเภทเอกสารอ้างอิง — 1 = ใบเสนอราคา, 2 = ใบสั่งซื้อ/ใบสั่งจอง, 3 = ใบสั่งขาย (ไม่ส่งมา ระบบใช้ 3 ให้) ดู ตาราง bill_type
billing_dateDateวันที่ของ SO (ไม่ส่งมา ระบบดึงจาก SO ให้)
billing_noString25เลขที่ SO (required)

2. อ้างอิงรายบรรทัด — field ใน details ​

ใส่ในแต่ละบรรทัดสินค้าที่มาจาก SO

Field NameField TypeLengthDescription
doc_ref_typeIntegerประเภทเอกสารอ้างอิง — 1 = ใบเสนอราคา, 2 = ใบสั่งซื้อ/ใบสั่งจอง, 3 = ใบสั่งขาย (ไม่ส่งมา ระบบใช้ 3 ให้)
ref_doc_noString25เลขที่ SO ที่สินค้าบรรทัดนี้มาจาก
ref_rowIntegerline_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 บรรทัด)

json
{
    "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)

json
{
    "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_numberitem_codeitem_code_mainref_guidset_ref_line
0G10-0038ec1ab0c8-... (ระบบสร้าง)
1G03-0001G10-0038ec1ab0c8-...
2G03-0004G10-0038ec1ab0c8-...

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, 3line_number {n}: reference type '{type}' is not supported (...)
ref_doc_no ในบรรทัด ไม่พบเอกสาร หรือเอกสารถูกยกเลิกline_number {n}: {ประเภท} '{doc_no}' not found or cancelled
transaction_ref ไม่ได้ส่ง billing_notransaction_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, 3transaction_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:

json
{
    "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 NameField TypeLengthDescription
adjust_reasonString25เหตุผลการปรับปรุง
advance_amountFloatตัดเงินมัดจำ
allocate_codeString25การจัดสรร
answer_typeIntegerลูกค้าตอบกลับ
approve_codeString25กลุ่มผู้อนุมัติ
approve_dateDateวันที่อนุมัติ
approve_statusIntegerสถานะการอนุมัติ
auto_approvedIntegerอนุมัติโดยอัตโนมัติ
auto_createIntegerสร้างโดยโปรแกรม
balance_amountFloatยอดเงินคงเหลือ
billing_statusBooleanสถานะวางบิล (true = ชำระครบ) (read-only)
branch_codeString25สาขา
branch_code_toString25ถึงสาขา
cancel_codeString255ผู้ยกเลิกเอกสาร
cancel_datetimeDateเวลายกเลิกเอกสาร
cancel_typeIntegerประเภทการยกเลิก
cashier_codeString25Cashier
contactorString25ผู้ติดต่อ
create_datetimeDateวันที่สร้างเอกสาร
creator_codeString255ผู้สร้างเอกสาร (ระบบบันทึกเป็น RESTAPI เสมอ ไม่รับจาก body)
credit_dateDateวันที่ครบกำหนด
credit_dayIntegerวันเครดิต
currency_codeString25รหัสสกุลเงิน
currency_moneyFloatยอดคงเหลือ (ตามสกุลเงิน)
cust_codeString25ลูกหนี้/เจ้าหนี้
cust_nameStringชื่อลูกค้า (จาก ar_customer) (read-only)
delivery_dateDateวันที่ส่งของ
department_codeString25แผนก
department_code_toString25ถึงแผนก
deposit_dateDateระยะเวลาภายใน (วันที่)
deposit_dayIntegerระยะเวลาภายใน (วัน)
detailsArrayObjectรายละเอียดสินค้า
discount_wordString25ส่วนลด
discount_word_2String25ส่วนลด (สกุลเงิน)
doc_closeIntegerปิดเอกสาร
doc_dateDateเอกสารวันที่ (required)
doc_format_codeString25รหัสเอกสาร
doc_groupString25กลุ่มเอกสาร
doc_noString25เอกสารเลขที่ (required)
doc_no_guidString25เลขที่เอกสารเปรียบเทียบ
doc_reasonStringเหตุผล
doc_refString255เอกสารอ้างอิง (ไม่ส่งมา = ค่าว่าง)
doc_ref_dateDateเอกสารอ้างอิงวันที่
doc_ref_transStringอ้างอิงเอกสาร
doc_successIntegerสิ้นสุด
doc_timeString5เวลา (HH:mm)
doc_typeIntegerประเภทเอกสาร
due_dateDateวันที่ครบกำหนด
exchange_rateFloatอัตราแลกเปลี่ยน
expire_dateDateวันที่หมดอายุ
expire_dayIntegerจำนวนวันหมดอายุ
expire_statusIntegerสถานะหมดอายุ
extra_wordStringข้อความเพิ่มเติม
guid_codeStringGUID
inquiry_typeIntegerประเภทรายการ
is_cancelIntegerเอกสารยกเลิก (บันทึกใหม่ = 0)
is_doc_copyIntegerเป็นเอกสารที่ออกแทน
is_holdIntegerระงับเอกสาร
is_manual_vatIntegerบันทึกรายการภาษีเอง (บันทึกใหม่ = 0)
is_posIntegerจากระบบ POS (default: 0)
job_codeString25งาน
job_code_toString25ถึงงาน
last_editor_codeString255ผู้แก้ไขเอกสารล่าสุด
last_statusIntegerสถานะล่าสุด (บันทึกใหม่ = 0)
lastedit_datetimeDateวันที่แก้ไขล่าสุด
latitudeFloatละติจูด (เก็บใน ic_trans_shipment)
location_fromStringพื้นที่เก็บ (ต้นทาง)
location_toStringพื้นที่เก็บ (ปลายทาง)
longitudeFloatลองจิจูด (เก็บใน ic_trans_shipment)
lost_profit_exchange_amountFloatผลต่างจากอัตราแลกเปลี่ยน
member_codeString25รหัสสมาชิก
moneyFloatจำนวนเงินคืน
not_approve_1Integerไม่อนุมัติ
on_holdIntegerระงับชั่วคราว
pass_book_codeStringสมุดเงินฝาก
pay_amountFloatเงินชำระ
paymentObjectข้อมูลชำระเงิน
period_guidStringGUID กะ
point_telephoneStringหมายเลขโทรศัพท์
pos_bill_changeInteger0=ปรกติ, 1=ใบแทน
pos_bill_typeInteger0=อย่างย่อ, 1=อย่างเต็ม
pos_idStringหมายเลขเครื่อง POS
pos_transferIntegerโอนมาจาก POS
project_codeString25โครงการ
project_code_toString25ถึงโครงการ
recheck_countIntegerเปิดระบบเตือนตรวจนับซ้ำ
recheck_count_dayFloatเตือนย้อนหลัง (วัน)
ref_amountFloatมูลค่าเอกสารเดิม
ref_diffFloatผลต่าง
ref_new_amountFloatมูลค่าที่ถูกต้อง
remarkString255หมายเหตุ
remark_2String255หมายเหตุ 2
remark_3String255หมายเหตุ 3
remark_4String255หมายเหตุ 4
remark_5String255หมายเหตุ 5
sale_area_codeString25เขตการขาย
sale_codeString25พนักงานขาย
sale_groupString25กลุ่มพนักงานขาย
sale_nameStringชื่อพนักงานขาย (จาก erp_user) (read-only)
sale_shift_idStringรอบการขาย
send_dateDateวันที่รับ/ส่งสินค้า
send_dayIntegerรับ/ส่ง ภายใน (วัน)
send_mailIntegerแจ้งส่งทางอีเมล์
send_smsIntegerแจ้งส่งทาง SMS
send_to_pick_and_packIntegerสั่งจัดสินค้า
send_typeIntegerประเภทการส่ง
sender_codeStringพนักงานขนส่ง
service_charge_wordStringService Charge
side_codeString25ฝ่าย
side_code_toString25ถึงฝ่าย
statusIntegerสถานะ
sum_pay_money_diffFloatผลต่างยอดชำระ
sum_pointFloatแต้ม
sum_point_2Floatยอดแต้มสะสมระบบกลาง
table_numberStringหมายเลขโต๊ะ
tax_doc_dateDateวันที่ใบกำกับ (ไม่ส่งมา ระบบใช้ doc_date เมื่อมี tax_doc_no)
tax_doc_noString25เลขที่ใบกำกับ — ส่งมาแล้วเอกสารจะเข้ารายงานภาษีขาย
total_after_vatFloatมูลค่าหลังคิดภาษี
total_amountFloatมูลค่าสุทธิ
total_amount_2Floatมูลค่าสุทธิ (สกุลเงิน)
total_amout_oldFloatมูลค่าสุทธิเดิม
total_before_vatFloatยอดก่อนภาษี
total_cost_calcFloatต้นทุนรวมของเอกสาร คำนวณจากผลรวม sum_of_cost ของรายการสินค้า (read-only)
total_costFloatต้นทุนสินค้า
total_debt_amountFloatยอดหนี้รวมภาษี
total_discountFloatมูลค่าส่วนลด
total_discount_2Floatมูลค่าส่วนลด (สกุลเงิน)
total_except_vatFloatมูลค่ายกเว้นภาษี
total_manualIntegerบันทึกยอดรวมเอง
total_service_chargeFloatมูลค่า Service Charge
total_vat_valueFloatภาษีมูลค่าเพิ่ม
total_valueFloatมูลค่าสินค้า
total_value_2Floatมูลค่าสินค้า (สกุลเงิน)
trans_flagIntegerรายวันระบบ (44 = ใบขายสินค้า, auto)
trans_typeIntegerประเภทรายวัน (2 = ขาย, auto)
transaction_refArrayเอกสารอ้างอิง (POST) — ดู Transaction Ref Attribute
transport_addressString1000ที่อยู่จัดส่ง (เก็บใน ic_trans_shipment)
transport_codeString25ขนส่งโดย
transport_nameString255ชื่อผู้รับ (เก็บใน ic_trans_shipment)
transport_remarkString255หมายเหตุจัดส่ง (เก็บใน ic_trans_shipment.remark)
transport_remark_2String255หมายเหตุจัดส่ง 2 (เก็บใน ic_trans_shipment.remark_2)
transport_valueFloatค่าขนส่ง
used_statusIntegerมีการอ้างอิงแล้ว
used_status_2Integerสถานะ 2
user_approveStringผู้อนุมัติ
user_requestStringผู้ขออนุมัติ
value_balanceFloatยอดคงค้าง (total_amount − ยอดรับชำระ) (read-only)
vat_rateFloatอัตราภาษี
vat_typeIntegerประเภทภาษี (0=แยกนอก, 1=รวมใน, 2=ยกเว้นภาษี, 3=ไม่กระทบภาษี) — หมายเหตุ: ค่าคนละชุดกับ detail
want_dateDateต้องการภายใน (วันที่)
want_dayIntegerต้องการภายใน (วัน)
wh_fromStringคลัง (ต้นทาง)
wh_toStringคลัง (ปลายทาง)

SaleInvoice Detail ​

ฟิลด์ที่ระบุ (required) คือฟิลด์ที่ต้องส่งใน POST request

Field NameField TypeLengthDescription
auto_createIntegerสร้างโดยโปรแกรม
average_costFloatราคาทุนเฉลี่ยต่อหน่วยนับหลัก (ไม่ส่งมา = ทุนเฉลี่ยของสินค้า ณ เวลาที่บันทึก)
average_cost_1Floatราคาทุนเฉลี่ยแฝง
bank_branchStringสาขาธนาคาร
bank_branch_2Stringสาขาธนาคาร 2
bank_nameStringธนาคาร
bank_name_2Stringธนาคาร 2
barcodeString25Barcode
bat_dateDatebat date
bat_numberStringbat number
branch_codeString25สาขา
calc_flagIntegerบวกหรือลบ (1=บวก, -1=ลบ, default: -1)
cancel_qtyFloatจำนวนยกเลิก
chq_numberStringเลขที่เช็ค
create_datetimeDateวันที่สร้างเอกสาร
creator_codeStringผู้สร้างเอกสาร (ระบบบันทึกเป็น RESTAPI เสมอ)
currency_codeString25สกุลเงิน
cust_codeString25ลูกหนี้/เจ้าหนี้
date_dueDateวันครบกำหนด
date_expireDateหมดอายุ
department_codeString25แผนก
discountString25ส่วนลด
discount_amountFloatมูลค่าส่วนลด
discount_amount_2Floatมูลค่าส่วนลด (สกุลเงิน)
discount_changedIntegerมีการแก้ไขส่วนลด
discount_numberIntegerหมายเลขส่วนลด
divide_valueFloatตัวหาร (ไม่ส่งมา ระบบเติมจาก ic_unit_use)
doc_dateDateเอกสารวันที่
doc_date_calcDateวันที่สำหรับคำนวณ
doc_groupStringกลุ่มเอกสาร
doc_noString25เอกสารเลขที่
doc_refStringเอกสารอ้างอิง
doc_ref_typeIntegerประเภทเอกสารอ้างอิง (1=ใบเสนอราคา, 2=ใบสั่งซื้อ/ใบสั่งจอง, 3=ใบสั่งขาย — default 3 เมื่อส่ง ref_doc_no มา)
doc_timeStringเวลา
doc_time_calcStringเวลาสำหรับคำนวณ
due_dateDateวันที่ต้องการ
exchange_rateFloatอัตราแลกเปลี่ยน
exchange_rate_oldFloatอัตราแลกเปลี่ยนเดิม
fee_amountFloatค่าธรรมเนียม
group_mainString25รหัสกลุ่มสินค้าหลัก (จากทะเบียนสินค้า) (read-only)
group_main_nameString255ชื่อกลุ่มสินค้าหลัก (read-only)
group_subString25รหัสกลุ่มสินค้าย่อย (จากทะเบียนสินค้า) (read-only)
group_sub_nameString255ชื่อกลุ่มสินค้าย่อย (read-only)
hidden_cost_1Floatต้นทุนแฝงบริหาร
hidden_cost_1_exclude_vatFloatต้นทุนแฝงบริหารไม่รวมภาษี
hidden_cost_2Floatต้นทุนแฝงบัญชี
hidden_cost_2_exclude_vatFloatต้นทุนแฝงบัญชีไม่รวมภาษี
ic_colorStringสีสินค้า
ic_patternStringรูปแบบสินค้า
ic_sizeStringขนาดสินค้า
inquiry_typeIntegerประเภทการซื้อ
is_doc_copyIntegerเป็นเอกสารที่ออกแทน
is_get_priceIntegerให้ดึงราคาขาย (1=ดึง)
is_lock_costIntegerกำหนดต้นทุนเอง
is_permiumInteger1=ของแถม
is_posIntegerจาก POS
is_serial_numberIntegerมีหมายเลขเครื่อง
item_brandString25รหัสยี่ห้อสินค้า (จากทะเบียนสินค้า) (read-only)
item_brand_nameString255ชื่อยี่ห้อสินค้า (read-only)
item_codeString25รหัสสินค้า
item_code_2String25รหัสสินค้า 2
item_code_mainString25สินค้าชุด: รหัสสินค้าของบรรทัดตัวชุด (ส่งในบรรทัดสินค้าในชุด)
item_nameString255ชื่อสินค้า
item_typeIntegerประเภทสินค้า
last_editor_codeStringผู้แก้ไขเอกสารล่าสุด
last_statusIntegerสถานะล่าสุด (0=Normal, 1=ยกเลิก)
lastedit_datetimeDateวันที่แก้ไขล่าสุด
line_numberIntegerบรรทัด
lot_number_1Stringเลข LOT
mfd_dateDateวันที่ผลิต
mfn_codeStringรหัสผู้ผลิต
mfn_nameStringผู้ผลิต
priceFloatราคา
price_2Floatราคา (สกุลเงิน)
price_baseFloatราคากลาง
price_changedIntegerมีการแก้ไขราคา
price_defaultFloatราคาเริ่มต้น
price_exclude_vatFloatราคาไม่รวมภาษี
price_guidStringPrice Guid
price_modeIntegerกลุ่มราคา
price_set_ratioFloatอัตราส่วนราคาสินค้าชุด
price_typeIntegerประเภทราคา
priority_levelIntegerความสำคัญ
product_weekStringสัปดาห์ที่ผลิต
product_yearStringปีที่ผลิต
profit_lost_cost_amountFloatกำไรขาดทุน
promotion_codeStringรหัสโปรโมชั่น
qtyFloatจำนวน
qty_2Floatจำนวนขาย
ratioFloatอัตราส่วน
ref_cust_codeString25อ้างอิง เจ้าหนี้/ลูกหนี้
ref_doc_dateDateอ้างอิง วันที่
ref_doc_noString25เลขที่เอกสารที่อ้างอิง (เช่น เลขที่ใบสั่งขาย)
ref_guidStringสินค้าชุด: GUID ของบรรทัดตัวชุด (ไม่ส่งมา ระบบสร้างให้)
ref_line_numberIntegerอ้างอิง บรรทัด
ref_rowIntegerบรรทัดของเอกสารที่อ้างอิง (line_number ในใบสั่งขาย)
remarkString255หมายเหตุ
sale_codeString25รหัสพนักงานขาย
sale_groupString25กลุ่มพนักงานขาย
sale_shift_idStringรอบการขาย
set_ref_lineStringสินค้าชุด: ref_guid ของบรรทัดตัวชุด (ไม่ส่งมา ระบบผูกให้)
set_ref_priceFloatสินค้าชุด: ราคาต่อชุด
set_ref_qtyFloatสินค้าชุด: จำนวนต่อ 1 ชุด
shelf_codeString25พื้นที่เก็บ
shelf_code_2String25พื้นที่เก็บ 2
stand_valueFloatตัวตั้ง (ไม่ส่งมา ระบบเติมจาก ic_unit_use)
statusIntegerสถานะ
sum_amountFloatรวมมูลค่า
sum_amount_2Floatรวมมูลค่า (สกุลเงิน)
sum_amount_exclude_vatFloatรวมมูลค่าไม่รวมภาษี
sum_of_costFloatรวมต้นทุน (ไม่ส่งมา = average_cost × qty × stand_value / divide_value)
sum_of_cost_1Floatต้นทุนรวมต้นทุนแฝงบริหาร
sum_of_cost_fixFloatต้นทุน (กำหนดเอง)
tax_typeIntegerประเภทภาษี (0=มีภาษี, 1=ยกเว้น)
temp_float_1Floatตัวเลข 1
temp_float_2Floatตัวเลข 2
temp_string_1Stringตัวอักษร 1
total_qtyFloatจำนวนคงเหลือ
total_sizeFloatรวมหน่วยนับ 2
total_vat_valueFloatภาษีมูลค่าเพิ่มรายบรรทัด — ส่งตอน POST ได้ (ส่งในชื่อ vat_amount แทนก็ได้ ถ้าส่งทั้งคู่ใช้ total_vat_value)
trans_flagIntegerรายวันระบบ (44 = ใบขายสินค้า, auto)
trans_typeIntegerประเภทรายวัน (2 = ขาย, auto)
transfer_amountFloatยอดโอนเงิน
unit_codeString25หน่วยนับ (ต้องมีใน ic_unit_use ของสินค้านั้น) (required)
unit_code_2String25หน่วยช่วยขาย
unit_sizeFloatขนาดสินค้า
user_approveStringรหัสผู้อนุมัติ
vat_typeIntegerประเภทภาษี (0=แยกนอก, 1=รวมใน, 2=อัตรา 0)
wh_codeString25คลัง
wh_code_2String25คลัง 2

Transaction Ref Attribute ​

โครงสร้างแต่ละรายการใน transaction_ref (เอกสารอ้างอิง) — ส่งเป็น array 1 รายการต่อเอกสาร 1 ใบ ใช้ตอน POST
วิธีใช้และตัวอย่างเต็ม ดู อ้างอิงใบสั่งขาย

Field NameField TypeLengthDescription
bill_typeStringประเภทเอกสารที่อ้างอิง (ดูตาราง bill_type ด้านล่าง) — ไม่ส่งมา ระบบใช้ 3 (ใบสั่งขาย)
billing_dateDateวันที่ของเอกสารที่อ้างอิง (yyyy-MM-dd) — ไม่ส่งมา ระบบดึงวันที่จากเอกสารนั้นให้
billing_noString25เลขที่เอกสารที่อ้างอิง เช่น เลขที่ใบสั่งขาย (required)

bill_type — ประเภทเอกสารที่ใบขายอ้างอิงได้

ค่าเอกสารที่อ้างอิงผลเมื่อใส่ ref_doc_no ในบรรทัดสินค้าด้วย
1ใบเสนอราคา—
2ใบสั่งซื้อ/ใบสั่งจองตัดยอดค้างจองของใบสั่งจอง
3ใบสั่งขาย (Sale Order)ตัดยอดค้างส่งของใบสั่งขาย

ระบบตรวจว่าเอกสารตาม bill_type มีอยู่จริงและไม่ถูกยกเลิก — ค่าอื่นนอกจาก 1, 2, 3 จะตอบ error

ค่าเดียวกันนี้ใช้กับ doc_ref_type ใน details — ควรส่งให้ตรงกัน

example:

json
"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 NameField TypeLengthDescription
advance_amountFloatตัดเงินมัดจำ
ap_ar_codeString25รหัสเจ้าหนี้/ลูกหนี้ (default = cust_code ของเอกสาร)
book_codeString25สมุดรายวัน
branch_codeString25รหัสสาขา
card_amountFloatยอดบัตรเครดิต
cash_amountFloatยอดเงินสด
cashier_codeString25Cashier
chq_amountFloatยอดเช็ค
coupon_amountFloatยอดชำระด้วยคูปอง
currency_codeString25รหัสสกุลเงิน
deposit_amountFloatยอดตัดเงินล่วงหน้า
descriptionStringรายละเอียด
detailArrayObjectรายละเอียดการชำระ
discount_amountFloatส่วนลดชำระเงิน
doc_dateDateเอกสารวันที่ (default = doc_date ของใบขาย)
doc_format_codeString25รหัสรูปแบบเอกสาร
doc_groupStringกลุ่มเอกสาร
doc_noString25เอกสารเลขที่ของใบรับเงิน (required ใน payment)
doc_refStringเอกสารอ้างอิง (default = doc_no ของใบขาย)
doc_timeString5เวลา
exchange_rateFloatอัตราแลกเปลี่ยน
guid_codeStringGUID
is_doc_copyIntegerเป็นเอกสารออกแทน
money_changeFloatเงินทอน
pay_cash_amountFloatจ่ายเงิน
pay_typeInteger1=รับ, 2=จ่าย
petty_cash_amountFloatเงินสดย่อย
point_amountFloatยอดชำระด้วยแต้ม
point_qtyFloatจำนวนแต้มที่ใช้
point_rateFloatแต้มต่อบาท
remarkStringหมายเหตุ
sale_shift_idStringรอบการขาย
statusIntegerสถานะ
total_amountFloatรวมยอดเงิน
total_amount_payFloatรวมจ่าย
total_credit_chargeFloatค่า Charge บัตรเครดิต
total_expense_otherFloatรายจ่ายอื่น
total_fee_amountFloatค่าธรรมเนียม
total_income_amountFloatปัดเศษ
total_income_otherFloatรายได้อื่น
total_net_amountFloatยอดรวมทั้งสิ้น
total_other_amountFloatปัดเศษ (ลด)
total_other_currencyFloatสกุลเงินอื่นๆ
total_tax_at_payFloatภาษีหัก ณ ที่จ่าย
tranfer_amountFloatยอดเงินโอน (สะกดตามฐานข้อมูล)
trans_flagIntegerรายวันระบบ
trans_typeIntegerประเภทรายวัน (1=รับเงิน, 2=จ่ายเงิน)
wallet_amountFloatWallet Payment

Payment Detail ​

โครงสร้าง payment.detail[] (เก็บใน cb_trans_detail) — รายการย่อยของการชำระเงินแยกตามวิธี (เช่น แต่ละใบเช็ค, แต่ละบัตรเครดิต, แต่ละการโอน)

Field NameField TypeLengthDescription
amountFloatจำนวนเงิน
ap_ar_codeString25รหัสเจ้าหนี้/ลูกหนี้ (default = cust_code ของเอกสาร)
ap_ar_typeInteger1=ลูกหนี้, 2=เจ้าหนี้
approve_codeString25กลุ่มผู้อนุมัติ
approve_dateDateวันที่อนุมัติ
balance_amountFloatยอดคงเหลือ
bank_branchStringสาขาธนาคาร
bank_codeStringรหัสธนาคาร
chargeFloatยอด Charge
chq_dateDateวันที่ออกเช็ค/รับเช็ค
chq_due_dateDateวันที่บนเช็ค
chq_on_handIntegerประเภทเช็ค
chq_refStringอ้างอิงเช็คเลขที่
credit_card_typeStringประเภทบัตรเครดิต
currency_codeStringรหัสสกุลเงิน
doc_dateDateเอกสารวันที่ (default = doc_date ของ payment header)
doc_date_refDateวันที่อ้างอิง
doc_groupStringกลุ่มเอกสาร
doc_noString25เอกสารเลขที่ (auto fill = payment.doc_no)
doc_refStringเอกสารอ้างอิง
doc_timeStringเวลา
doc_typeInteger1=เงินโอน, 2=เช็ค, 3=บัตรเครดิต, 4=เงินสดย่อย, 5=เงินล่วงหน้า, 9=คูปอง, 11=จ่ายอื่น, 12=รับอื่น, 19=สกุลเงินอื่น, 21=eWallet
exchange_rateFloatอัตราแลกเปลี่ยน
external_chqIntegerการเรียกเก็บ
fee_amountFloatค่าธรรมเนียม
is_doc_copyIntegerเอกสารออกแทน
last_statusIntegerสถานะล่าสุด
line_numberIntegerบรรทัด (auto +1 ถ้าไม่ส่ง)
no_approvedStringเลขที่อนุมัติ
other_amountFloatค่าใช้จ่ายอื่นๆ
pass_book_codeStringสมุดเงินฝาก
period_numberIntegerงวดที่
ref1Stringเลขที่อ้างอิง 1
ref2Stringเลขที่อ้างอิง 2
remarkStringหมายเหตุ
sale_shift_idStringรอบการขาย
statusIntegerสถานะ
sum_amountFloatยอดเงินรวม
sum_amount_2Floatรวมจำนวนเงิน (สกุลเงิน)
tax_at_payFloatภาษีหัก ณ ที่จ่าย
trans_flagIntegerรายวันระบบ
trans_numberStringเลขที่เช็ค/เลขที่อนุมัติ
trans_number_typeIntegerประเภท (1=รับ, 2=จ่าย)
trans_typeIntegerประเภทรายวัน