วิธีใช้ Postman สร้างเอกสารใบส่งของ ผ่าน Leceipt API
หากท่านต้องการที่จะสร้างเอกสาร etax ผ่านระบบของท่าน คู่มือนี้จะสอนวิธีการสร้างเอกสาร etax ผ่าน Postman แบบง่ายๆพร้อมตัวอย่างโค้ดเพื่อให้ท่านได้เข้าใจได้อย่างง่าย
ท่านสามารถ import collection ได้ด้วย Link ด้านล่าง
https://www.getpostman.com/collections/e42fe4deea6b7517f7ab
การสร้างเอกสารจะมีตามขั้นตอนต่อไปนี้
1. สร้าง API Key
API key นี้จะใช้ในการเชื่อมต่อ API กับระบบ Leceipt โดยวิธีการสร้างจะอยู่ใน link ด้านล่าง
วิธีสร้าง API Key: https://www.leceipt.com/docs/etax/api-key
2. ระบุข้อมูล
ระบุข้อมูลที่สำคัญเพื่อที่จะสร้างเอกสารต่างๆบน Leceipt ท่านสามารถดูตัวอย่างข้อมูลได้ที่ Github
customer (ผู้ซื้อ)
แบบมีโครงสร้าง
| Parameters | Require | Type | Meaning | 
|---|---|---|---|
| name | yes | string | ชื่อผู้ขาย | 
| buildingNumber | yes | string | บ้านเลขที่ | 
| address | yes | string | ที่อยู่ | 
| streetPrefix | no | string | คำนำหน้าชื่อถนน เช่น ถ. ถนน | 
| streetName | no | string | ชื่อถนน | 
| subDistrictPrefix | no | string | คำนำหน้าชื่อตำบล เช่น ตำบล ต. แขวง | 
| subDistrictCode | yes | string | รหัสตำบล | 
| districtPrefix | no | string | คำนำหน้าชื่ออำเภอ เช่น อำเภอ อ. เขต | 
| districtCode | yes | string | รหัสอำเภอ | 
| provincePrefix | no | string | คำนำหน้าชื่อจังหวัด เช่น จังหวัด | 
| provinceCode | yes | string | รหัสจังหวัด | 
| postcode | yes | string | รหัสไปรษณีย์ | 
| branchNumber | yes | string | เลขที่สาขา | 
| taxNumberType | yes | string | ประเภทผู้เสียภาษี | 
| taxId | yes | string | เลขประจำตัวผู้เสียภาษี | 
| phone | no | string | เบอร์โทรศัพท์ | 
| no | string | อีเมล | |
| unstructure | yes | boolean | ระบุเป็น false หากเป็นที่อยู่แบบมีโครงสร้าง | 
ตัวอย่าง
{ 
    "customer": { 
        "name": "บริษัท ลูกค้าทดสอบ จำกัด", 
        "buildingNumber": "99", 
        "address": "หมู่ที่ 99", 
        "streetName": "สาทร 99", 
        "branchNumber": "00000", 
        "subDistrictCode": "100402", 
        "districtCode": "1004", 
        "provinceCode": "10", 
        "postcode": "10500", 
        "taxNumberType": "TXID", 
        "taxId": "1234567890123", 
        "contactName": "ผู้ติดต่อ", 
        "phone": "0812345678", 
        "email": "test@test.com", 
        "unstructure": false 
    } 
} แบบไม่มีโครงสร้าง
| Parameters | Require | Type | Meaning | 
|---|---|---|---|
| name | yes | string | ชื่อผู้ขาย | 
| addressLineOne | yes | string | ที่อยู่ | 
| addressLineTwo | no | string | ที่อยู่บรรทัดที่ 2 | 
| postcode | yes | string | รหัสไปรษณีย์ | 
| countryName | no | string | ประเทศ | 
| branchNumber | yes | string | เลขที่สาขา | 
| taxNumberType | yes | string | ประเภทผู้เสียภาษี | 
| taxId | yes | string | เลขประจำตัวผู้เสียภาษี | 
| phone | no | string | เบอร์โทรศัพท์ | 
| no | string | อีเมล | |
| unstructure | no | string | ระบุเป็น true หากเป็นที่อยู่แบบไม่มีโครงสร้าง | 
ตัวอย่าง
{ 
    "customer": { 
        "name": "บริษัท ลูกค้าทดสอบ จำกัด", 
        "addressLineOne": "999 หมู่ 999 ถ.สาทร 99", 
        "addressLineTwo": "แขวงสีลม เขตบางรัก กรุงเทพมหานคร", 
        "countryName": "ไทย", 
        "postcode": "10500", 
        "branchNumber": "00000", 
        "taxNumberType": "TXID", 
        "taxId": "1234567890123", 
        "contactName": "ผู้ติดต่อ", 
        "phone": "0812345678", 
        "email": "test@test.com", 
        "unstructure": true 
    } 
} items (รายการสินค้า)
parameter นี้เป็น array หากในเอกสารมีหลายรายการสินค้าหรือบริการ ให้เพิ่ม object ลงใน array นี้เพิ่มเอง
| Parameters | Require | Type | Meaning | 
|---|---|---|---|
| number | yes | number | ลำดับรายการสินค้าหรือบริการ | 
| description | yes | string | รายละเอียดสินค้าหรือบริการ | 
| quantity | yes | number | จำนวนสินค้า | 
| unitName | no | string | หน่วยสินค้า | 
| price | yes | number | ราคาสินค้าหรือบริการ | 
| discount | no | number | ส่วนลดสินค้าหรือบริการ | 
| percentVat | yes | number | เปอร์เซ็นภาษีของรายการ ประกอบด้วย หากเป็นรายการยกเว้นภาษี ระบุเป็น -1 หากเป็นรายการภาษี 0% ระบุเป็น 0 หากเป็นรายการภาษี 7% ระบุเป็น 7 | 
ตัวอย่าง
{ 
    "items": [ 
        { 
            "number": 1, 
            "description": "ค่าอาหารและเครื่องดื่ม", 
            "quantity": 1, 
            "unitName": "ชิ้น/อัน", 
            "price": 1500, 
            "discount": 0, 
            "percentVat": 0 
        }, 
        { 
            "number": 2, 
            "description": "ค่าอาหารและเครื่องดื่ม", 
            "quantity": 1, 
            "unitName": "", 
            "price": 1000, 
            "discount": 0, 
            "percentVat": 7 
        } 
    ] 
} data
| Parameters | Require | Type | Meaning | 
|---|---|---|---|
| number | yes | string | เลขที่ ใบส่งของ/ใบกำกับภาษี | 
| reference | no | string | เลขที่อ้างอิง | 
| dateBE | yes | string | วัน เดือน ปี (พ.ศ.) ที่ออกใบส่งของ/ใบกำกับภาษี | 
| dueDateBE | no | string | วัน เดือน ปี (พ.ศ.) ครบกำหนดใบส่งของ/ใบกำกับภาษี | 
| includeVat | no | boolean | ราคาสินค้าหรือบริการรวม Vat แล้ว includeVat=true, ราคาสินค้าหรือบริการยังไม่รวม Vat includeVat=false (default) | 
| customer | yes | object | รายละเอียดผู้ซื้อสินค้าหรือบริการ | 
| items | yes | array | รายละเอียดสินค้าหรือบริการ | 
| language | no | string | ภาษา (ประกอบด้วย th (ภาษาไทย) (default) กับ en (ภาษาอังกฤษ) | 
| discount | no | number | ส่วนลดรวม | 
| note | no | string | หมายเหตุ ที่ต้องการแสดงในใบส่งของ/ใบกำกับภาษี | 
| createdBy | no | string | ชื่อผู้จัดทำ | 
| reIssue | no | boolean | หากออกเอกสารแทนใบเดิม ให้ระบุเป็น true หากไม่ ให้ระบุเป็น false (default) | 
| refer | yes (ถ้า reIssue เป็น true) | object | เอกสารอ้างถึง | 
ตัวอย่าง
{ 
    "number": "TIV20210300001", 
    "dateBE": "23/03/2564", 
    "includeVat": false, 
    "items": [ 
        { 
            "number": 1, 
            "description": "ค่าอาหารและเครื่องดื่ม", 
            "quantity": 1, 
            "unitName": "ชิ้น/อัน", 
            "price": 1500, 
            "discount": 0, 
            "percentVat": 0 
        }, 
        { 
            "number": 2, 
            "description": "ค่าอาหารและเครื่องดื่ม", 
            "quantity": 1, 
            "unitName": "", 
            "price": 1000, 
            "discount": 0, 
            "percentVat": 7 
        } 
    ], 
    "discount": 0, 
    "language": "th", 
    "customer": { 
        "name": "บริษัท ลูกค้าทดสอบ จำกัด", 
        "buildingNumber": "99", 
        "address": "หมู่ที่ 99", 
        "streetName": "สาทร 99", 
        "branchNumber": "00000", 
        "subDistrictCode": "100402", 
        "districtCode": "1004", 
        "provinceCode": "10", 
        "postcode": "10500", 
        "taxNumberType": "TXID", 
        "taxId": "1234567890123", 
        "contactName": "ผู้ติดต่อ", 
        "phone": "0812345678", 
        "email": "test@test.com", 
        "unstructure": false 
    }, 
    "note": "ทดสอบหมายเหตุ", 
    "createdBy": "สมชาย", 
    "reference": "" 
} 3. ใช้ Postman ส่ง Request
Endpoint: https://api.leceipt.com/documents/deliveryorders
Method: Post
copy Endpoint ด้านบนไปใส่ใน Postman ใส่ API-Key ไว้ที่ Headers และ data ที่อยู่ในข้อ 2. ไปใส่ใน Body แล้วเลือก raw


Response:

เมื่อทำการส่ง request เรียบร้อยแล้ว ระบบ Leceipt จะทำการสร้างเอกสาร ถือว่าเป็นอันเสร็จสิ้น
แต่หากท่านต้องการ download ไฟล์ pdf ให้ดูขั้นตอนต่อไป
4. เก็บ FileId เพื่อทำการ Download
Endpoint: https://api.leceipt.com/etax/jobs/{id}
Method: Get
ส่ง get request ไปที่ endpoint ด้านบนโดย id เอามาจาก response ในข้อ 3.

ตัวอย่าง

นำ id นี้ไปไว้ด้านท้ายของ endpoint (ไม่ต้องเอา ” รอบ id)
Response:

เมื่อได้ response มา ให้นำ fileId ไปใช้ในขั้นตอนถัดไป
5. Download ไฟล์ PDF
Endpoint: https://api.leceipt.com/etax/files/{fileId}/?api-version=2022-07-12
Method: Get
fileId เอามาจาก response ในข้อ 4.

ตัวอย่าง

Response:



