## **Request API Create ProductInvoiceAR PJM**
> รายละเอียดของ API ดังต่อไปนี้จะเป็นข้อมูลที่ทาง OtherPlatfrom จะจัดส่งให้ PJM เพื่อที่จะทำข้อมูลเบื้องต้นมาสร้างเอกสารบนโปรแกรม PJM และส่งข้อมูลคืนกลับไปยัง OtherPlatfrom
---
### **POST /{PATH}/API/ProductInvoiceAR/CreateDocument**
> API นี้จะทำการบันทึกเอกสาร ProductInvoiceAR ที่ระบบ PJM จากข้อมูลที่รับมาจาก OtherPlatfrom
### **Header**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-------|
| AccessId ==(Require)== | รหัสการเข้าถึง | String |QzczMEExNUQtNEU1NS00Qjc2LTlFMkMtQUM3N0E1MDc3MzhB|
| AccessToken ==(Require)== | โทเค็นการเข้าถึง | String |EAAAAJA7iGNkKjEM7M5EoplQr3MYUZAQLXM656MAOslsOONsjIoe3bqGvjUJioCNka7TgQQl16WM4B0R121gY5uKB/0=|
---
> Example Request
```json
{
"AccessId": "QzczMEExNUQtNEU1NS00Qjc2LTlFMkMtQUM3N0E1MDc3MzhB",
"AccessToken": "EAAAAJA7iGNkKjEM7M5EoplQr3MYUZAQLXM656MAOslsOONsjIoe3bqGvjUJioCNka7TgQQl16WM4B0R121gY5uKB/0=",
}
```
---
### **Body**
### **ProductInvoiceAR**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-------|
| Code | รหัสเอกสาร | String |PDIV-001|
| DocumentSubDocTypeId ==(Require)== | รหัสประเภทเอกสาร | Int |1|
| OrgCode ==(Require)== | รหัสโครงการ | String |HO|
| Date ==(Require)== | วันที่ออกเอกสาร | DateTime |2023-01-01|
| Currency | สกุลเงิน | String |THB|
| CurrencyRate | ค่าเงิน |Number |1.00|
| Remarks | หมายเหตุ | String |text|
| Deposit | มัดจำ |Object ||
| VatType | ประเภทของภาษี | String |ExcludeVat|
| TaxInvoice | ใบกำกับของภาษี |Object |true|
| SendEtaxAuto | ส่งภาษีออนไลน์ |Bool |false|
| ExtOrg ==(Require)== | ลูกค้า |Object ||
| Receipt | ใบเสร็จ |Object ||
| ProductInvoiceARItem ==(Require)== | รายการ ProductInvoiceAR | Array of objects ||
| Receive ==(Require)== | รับเงิน/รับหนี้ |Object ||
| WHT | ภาษีหัก ณ ที่จ่าย | Object ||
:::info
:bulb: **รายละเอียดเพิ่มเติมของ ProductInvoiceAR**
1. LocationCode,SubDocTypeId จะต้องเป็นข้อมูลที่มีอยู่ในโปรแกรมพจมาน
2. VatType จะ auto กรณีไม่ได้ใส่ (ถ้าต้องสร้าง extorg จะยึดตาม vattype ที่ส่งมา)
3. TaxInoice ถ้าข้อมูลที่ส่งมาเป็น True ทางโปรแกรมพจมานจะ Auto สร้างเอกสาร TaxInvoice ให้เอกโดยอ้างอิงข้อมูลจากตัวเอกสาร ProductInvoiceAR (ไม่สร้างถ้าเป็น novat)
4. DepositAmount จะถูกนำไปหักมัดจำได้กรณีมีการสร้าง deposit ไว้แล้วที่ pjm
5. sendtaxauto จะทำการ Ready เอกสาร ProductInvoiceAR และส่ง ETAX ให้เลย
6. ExtOrgObj กรณีไม่พบข้อมูลที่ pjm จะทำการสร้างใหม่ให้
7. Receipt กรณีใส่ true มาเอกสารจะต้องใส่ recieve method มาด้วย
:::
---
### **ExtOrgObj**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-----|
| ExtOrgSubDocTypeId ==(conditional field)== | ประเภทลูกค้า | Int |1|
| ExtOrgCode| รหัสลูกค้า | String |CUS001|
| ExtOrgName ==(Require)==| ชื่อลูกค้า | String |CUS|
| ExtOrgTaxId | รหัสผู้เสียภาษี | String |123456789101234|
| PostCode | รหัสไปรษณีย์ | String |12345|
| WHTType | ประเภทภาษีหัก ณ ที่จ่าย | String |53|
| VatType |ประภาทของภาษี|String|ExcludeVat,IncludeVat,NoVat|
| Address ==(conditional field)== | ที่อยู่ |String |xxx|
| TagType | ประเภทของ Tagtype |Array | [1,2] |
| APAccount ==(conditional field)== | ข้อมูลของบัญชีฝั่งจ่าย | Object ||
| ARAccount ==(Require)== | ข้อมูลของบัญชีฝั่งรับ | Object ||
:::info
:bulb: **รายละเอียดเพิ่มเติมของ ExtOrgObj**
1. ถ้า ExtOrgCode,ExtOrgTaxId ไม่มีในระบบจะทำการสร้างใหม่ **แต่ต้องกรอก conditional field**
2. ExtOrgSubDocTypeId จะต้องเป็นข้อมูลที่มีอยู่ในโปรแกรม pjm
3. ExtOrgCode จะมีผลถ้าเป็น rekey
:::
:::info
:bulb: **รายละเอียดเพิ่มเติมของ TagType**
1. 1 คือ Supplier
2. 2 คือ Customer
:::
---
### **APAccount**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-----|
| APAccountCode | เลขบัญชีของฝั่งจ่าย | String | 2-01-0100-001 |
| DepositAPAccountCode| เลขบัญชีของDeposit | String | 1-01-0206-001 |
| SupplierPaymentGroup| ผูู้ขายลูกค้าอยุ่ในการจ่ายแบบไหน | String |Supplier|
| PaymentCondition| รายละเอียดเงื่อนไขการจ่าย | Object ||
| PaymentConditionReceive| เงื่อนไขการจ่าย | String |After Receive from Supplier|
---
### **ARAccount**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-----|
| ARAccountCode | เลขบัญชีของฝั่งรับ | String | 2-01-0100-001 |
| DepositARAccountCode| เลขบัญชีของDeposit | String | 1-01-0206-001 |
| PaymentCondition| รายละเอียดเงื่อนไขการรับ | Object ||
| PaymentConditionReceive| เงื่อนไขการรับ | String |After Receive from Supplier|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ APAccount,ARAccount**
รายละเอียดต่างๆจะถูกนำไปใช้ในการสร้าง ExtOrg ใหม่ในกรณีที่ไม่เจอ ExtOrg ในระบบ
:::
---
---
### **PaymentCondition**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-----|
| Type | ประเภทเงื่อนไขการรับ | String |CreditTerm|
| Days| วัน | Number |15|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ PaymentCondition**
1.ถ้าเลือก type เป็น CreditTerm ต้องใส่ day ด้วย
:bulb: **รายละเอียดเพิ่มเติมของ PaymentConditionReceive**
"After Receive from Supplier"
"After Receive Invoice"
"After Receive Bill"
"Receive from Supplier (Post Dated Cheque)"
"After Supplier Invoice Date"
:::
---
### **Receipt**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-----|
| UseReceipt | เพิ่มใบเสร็จ | Bool |true|
| SubdoctypeId ==(Require)==| ประเภทใบเสร็จ | Int |1|
| ReceiptCode | รหัส Code | String |RE-0001|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ Receipt**
1.UseReceipt ต้องเลือกรับแบบ paymentmethod
2.SubdoctypeId ต้องมีในระบบ pjm
3.ถ้ามี vat จะ auto สร้าง taxinvoice
:::
---
---
### **TaxInvoice**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-----|
| UseTaxInvoice | เพิ่มใบกำกับภาษี | Bool |true|
| TaxInvoiceCode | รหัส Code | String |123456789|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ Receipt**
1.UseTaxInvoice ต้องเลือกรับแบบมี vat
:::
---
### **Deposit**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-----|
| DepositCode | รหัสมัดจำ | String |Fis-0001|
| DepositAmount ==(Require)==| ยอดมันจำ | Number |150.00|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ PaymentCondition**
1.ถ้าเลือก type เป็น CreditTerm ต้องใส่ day ด้วย
:::
---
### **ProductInvoiceARItem**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-----|
| LineNumber ==(Require)== | ลำดับรายการ | Int |1|
| ItemCateCode| รหัส ItemCate | String |Cate001|
| ItemMetaCode | รหัส ItemMeta | String |Meta001|
| Serial | รหัส Serial | String |x-xxxx-01|
| AccountCode ==(Require)== | รหัสผังบัญชี | String |4-01-0000-001|
| Descreption | รายละเอียด | String |xxx|
| Qty ==(Require)== | จำนวนสินค้า |Number |1.00|
| UnitName ==(Require)== | หน่วย | String |ea|
| UnitPrice ==(Require)== | ราคาต่อหน่วย |Number |1000|
| Discount | ส่วนลด | Number |50.00|
| Free | ของแถม |Bool |False|
| Remark | หมายเหตุ |Bool |False|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ ProductInvoiceARItem**
1. ItemCateCode, AccountCode , UnitCode จะต้องเป็นข้อมูลที่มีอยู่ในโปรแกรมพจมาน
2. ถ้าเป็น dummy บังคับใส่ catecode ส่วน metacode ใส่อะไรก็ได้
3. กรณีเลือกรายการ free จะไม่สามารใส่ยอดเงินได้
4. กรณีเลือกรายการ Remark จะใส่ข้อมูลได้แค่ field Descreption
:::
---
### **Receive**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-------|
| ReceiveType ==(Require)== | ประเภทของรายการรับ | String |AccountReceivable,ReceiveMethod|
| ReceiveDetail ==(Require)== | รายละเอียดของรายการรับ | Array of objects ||
:::info
:bulb: **รายละเอียดเพิ่มเติมของ Reciept**
กรณีส่งข้อมูล ReceiveType และ ReceiveItem จำเป็นต้องใส่ข้อมูลทั้ง 2 field
ถ้าใส่มาไม่ครบหรือไม่ใส่มาจะไม่สามารถสร้างเอกสารได้
:::
---
### **ReceiveDetail**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-------|
| ReceiveMethodType ==(Require)== | ชนิดของรายการรับ | String |BankAccount,Deduct,CheckReceive|
| ReceiveAccount ==(Require)== | เลขบัญชีธนาคาร | String |015-7874-125|
| CheckNumber ==(Require)== | รหัสเช็ค | String |111111|
| Bank ==(Require)== | ธนาคาร | String |TTB|
| Date ==(Require)== | วันที่รับ | DateTime |2023-01-01|
| AccountCode ==(Require)== | ผังบัญชี | String |112100|
| Amount ==(Require)== | เงิน | Number |1000.00|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ ReceiveItem**
1.ReceiveMethodType ใส่ได้ 3 ชนิด BankAccount,Deduct,CheckReceive
2.ถ้าเลือก ReceiveMethodType เป็น BankAccount จะต้องใส่ ReceiveAccount,Bank,Amount
3.ถ้าเลือก ReceiveMethodType เป็น CheckReceive จะต้องใส่ ReceiveAccount,CheckNumber,Bank,Amount
4.ถ้าเลือก ReceiveMethodType เป็น Deduct จะต้องใส่ AccountCode,Amount
5.ยอดรวมของ Amount ทุกรายการรวมกันจะต้องไม่เกิน GrandTotal ของเอกสาร
:::
---
### **WHT**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-------|
| WHTNumber | รหัสของภาษีหัก ณ ที่จ่าย | String |WHT0001|
| Date ==(Require)== | วันที่ | DateTime |2023-01-01|
| Type | ประเภท | String |K|
| PayerName | - | String |-|
| PayerSignatures | - | String |-|
| Representative | - | Object ||
| Cumulative | - | Object ||
| Filing | ลักษณะการยื่น | Object ||
| WHTDetails ==(Require)== | รายการ | Array of objects ||
:::info
:bulb: **รายละเอียดเพิ่มเติมของ WHT**
1.WHTNumber จะถูกรันเมื่อเลือกทำ recieve method
:::
---
### **Representative**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-------|
| Substitution | - | String |mr.builkone|
| IdentificationNumber | - | String |1111111111111|
| Address | - | String |bangkok|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ Representative**
:::
---
### **Cumulative**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-------|
| EmployerAccount | - | String |151513854|
| SocialSecurityNumber | - | String |23232152|
| Contribution | - |Number |0.00|
| LicenseNumber | - | String |4343433|
| Savings | - | Number |100.00|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ Cumulative**
:::
---
### **Filing**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-------|
| Type | ลักษณะการยื่น | String |Normal|
| Number | ครั้งที่ | Number |1|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ Filing**
:::
---
### **WHTDetails**
| Parameter | Description | Schema |Example|
| ----------------- | ---------------- | -------- |-------|
| Type ==(Require)== | - | String |K|
| Ariticle | - | String |5|
| Description | - | String |xxx|
| Amount ==(require)== | - | Number |100.00|
| Percent | - | Number |1|
| WHTAmount | - | Number |10.00|
:::info
:bulb: **รายละเอียดเพิ่มเติมของ WHT**
การคำนวณ WHTAmount จะคำนวณจาก % ของ Type * Amount
แต่หากใส่ WHTAmount มา จะใช้ WHTAmount ที่ใส่มาเลย
:::
---
> ### **Example Request**
```json
[
{
"Code": "TEST-001" // กรณี Rekey ถ้าไม่ใช่ Rekey จะรันตาม SubDocType
"SubDocTypeId" : 1,
"OrgCode": "HO",
"Date": "2023-06-28T00:00:00.0000000Z",
"Currency": "THB",
"CurrencyRate": 1.00,
"Remarks": "Test Create Document",
"SpecialDiscount": "200",
"DepositAmount": 200.00,
"VatType": "ExcludeVat" //จะ default ตาม ExtOrg กรณีมี ExtOrg ในระบบ
"Taxinvoice" : {
"UseTaxInvoice" : true,
"TaxInvoiceCode" : "123456789"
}, // auto TaxInvoice
"SendEtaxAuto" : false,
"ExtOrgObj" : {
"SubDocTypeId" : 10,
"ExtOrgCode" : "Test0001",
"ExtOrgName" : "Test0002",
"ExtOrgTaxId" : 1542154354845,
"PostCode" : "12345",
"WHTType" : "53", //1,2,3,53,54
"Address" : "-",
"ARAccount" : "112200",
"DepositAccount" : "213500",
"PaymentCondition" : {
"Type" : "CreditTerm", //Immediate
"Days" : 13
}
},
"Receipt" : {
"UseReceipt" : true, // auto สร้าง taxinvoice ถ้าไม่ใช่ novat
"SubdoctypeId" : 3,
"ReceiptCode" : ""
},
"ProductInvoiceARItem" :
[
{
"LineNumber":1,
"ItemCateCode":2,
"ItemMetaCode":2,
"AccountCode":"4-01-554215-1"
"Serial":"XXX-001-XXX"
"Descreption":"Item No. 1",
"Qty":10,
"UnitId":1,
"UnitPrice":1000,
"Discount":5000.00,
"Free": "False",
"Remark": "False",
},
{
"LineNumber":2,
"ItemCateCode":2,
"ItemMetaCode":3,
"AccountCode":"4-01-554215-1"
"Serial":"XXX-001-XXX"
"Descreption":"Item No. 2",
"Qty":5,
"UnitId":2,
"UnitPrice":1000,
"Discount":0.00,
"Free": "False",
"Remark": "False",
},
{
"LineNumber":3,
"ItemCateCode":2,
"ItemMetaCode":4,
"AccountCode":""
"Serial":""
"Descreption":"Item No. 3",
"Qty":0.00,
"UnitId":0,
"UnitPrice":0.00,
"Discount":0.00,
"Free": "True",
"Remark": "False",
},
{
"LineNumber":4,
"ItemCateCode":0,
"ItemMetaCode":0,
"AccountCode":""
"Serial":""
"Descreption":"Remark.....",
"Qty":0.00,
"UnitId":0,
"UnitPrice":0.00,
"Discount":0.00,
"Free": "False",
"Remark": "True",
}
],
"Receive" {
"ReceiveType" : "ReceiveMethod", //AccountReceivable
"ReceiveDetail" : [
{
"ReceiveMethodType" : "BankAccount",
"ReceiveAccount" : "507-6-02639-0",
"CheckNumber" : "111111",
"Bank" : "TMB",
"Date" : "2023-07-04"
"AccountCode" : "1-01-0102-001",
"Amount" : 10000.00
},
{
"ReceiveMethodType" : "BankAccount",
"ReceiveAccount" : "507-6-02639-0",
"CheckNumber" : "111111",
"Bank" : "TMB",
"Date" : "2023-07-04"
"AccountCode" : "1-01-0102-001",
"Amount" : 10000.00
},
{
"ReceiveMethodType" : "BankAccount",
"ReceiveAccount" : "507-6-02639-0",
"CheckNumber" : "111111",
"Bank" : "TMB",
"Date" : "2023-07-04"
"AccountCode" : "1-01-0102-001",
"Amount" : 10000.00
}
]
},
"WHT" : {
"WHTNumber" : "WHT0001",
"Date" : "2023-04-07",
"Type":"53"
"PayerName":"test"
"PayerSignature":""
"Representative": {
"Substitution" : "นายรัฐภูมิ",
"IdentificationNumber" : "115018421621",
"Address" : "101 ห้วยขวาง"
},
"Cumulative" : {
"EmployerAccount" : "151513854",
"SocialSecurityNumber" : "23232152",
"Contribution" : 0,
"LicenseNumber" : "4343433",
"Savings" : 100
}
"Filing" : {
"Type" : "Normal",
"Number" : 0
}
"WHTItem" : [
{
"Type" : "K",
"Ariticle" : "5",
"Description" : "testJa"
"Amount": 10000.00,
"Percent" : 3,
"WHTAmount" : 30
}
]
}
}
]
```
> ### **Example Response Case Success**
```json
{
"ResponseStatus" : 200,
"ResponseMsg" : "Success",
"ResponseSuccess" : [
{
"DocId" : 1,
"DocCode" : "TEST-001",
"Link" : "https://www.pjm.com/AR/ProductInvoiceAR/Form?id=1"
}
]
"ResponseError" : []
}
```
> ### **Example Response Case Error RequireField**
```json
{
"ResponseStatus" : 400,
"ResponseMsg" : "Error",
"RespnseSuccess" : [],
"ResponseError" : [
{
"ErrorType" : "RequireField",
"ErrorMsg" : "Receive.ReceiveType"
},
{
"ErrorType" : "NotFoundOnPJM",
"ErrorMsg" : "SubDocTypeId"
}
]
}
```
> ### **Example Response Case Error Not Sent Data**
```json
{
"ResponseStatus" : 400,
"ResponseMsg" : "Error",
"RespnseSuccess" : [],
"ResponseError" : [
{
"ErrorType" : "NoContent",
"ErrorMsg" : "NoContent"
}
]
}
```
> ### **Example Response Case Error Exception**
```json
{
"ResponseStatus" : 500,
"ResponseMsg" : "Exceptiopn Error ex.",
"RespnseSuccess" : [],
"ResponseError" : []
}
```
---