**API OTHER RECEIVE**
Request API
---
```javascript
{
"Code" : "Test",
"SubDocTypeId" : 1,
"ExtOrgTaxId" : 1542154354845
"ExtOrgCode" : "Test0001",
"OrgCode" : "OrgTest0001",
"Date" : "2023-07-04",
"Currency" : "THB",
"CurrencyRate" : 1
"Remark" : "RemarkOnDocument",
"VatType" : "ExcludeVat", //IncludeVat,Novat (คิดอยู่ว่ามันตาม ExtOrg ดีไหม)
"Taxinvoice" : true, //ติ๊กแล้วจะสร้าง TaxInvoice
"Receipt" : {
"UseReceipt" : true,
"SubdoctypeId" : 3
},
"LinesDetail" : [
"LineNumber" : 1,
"OrgCode" : "OrgTest0001",
"Description" : "TestJa",
"AccountCode" : "114200",
"Amount" : 1000
],
"WHT" : {
"WHTNumber" : "WHT0001",
"Date" : "2023-04-07",
"Type" : "-", //(คิดว่าตาม ExtOrg ดีสุด)
"Representative" {
"Substitution" : "นายรัฐภูมิ", //การทำการแทนโดย
"IdentificationNumber" : "115018421621", //เลขประจำตัวผู้เสียภาษี
"Address" : "101 ห้วยขวาง" //ที่อยู่
},
"Cumulative" : {
"EmployerAccount" : "151513854", //เลขที่บัญชีนายจ้าง
"SocialSecurityNumber" : "23232152", //เลขที่บัตรประกันสังคม
"Contribution" : 0, //เงินสบทบ
"LicenseNumber" : "4343433", //ใบอนุญาตเลขที่
"Savings" : 100 //เงินสะสม
}
"Filing" : {
"Type" : "Normal", //Additional
"Number" : 0
}
"Details" : [
{
"Type" : K,
"Ariticle" : 5,
"Description" : "testJa"
}
]
},
"Receive" {
"ReceiveType" : "AccountReceivable", //ReceiveMethod
"ReceiveDetail" : [
{
"ReceiveMethodType" : "BankAccount", //Deduct,CheckReceive
"ReceiveAccount" : "015-7874-125", //ผังบัญชี
"CheckNumber" : "111111", //เลขที่ Check
"Bank" : "TMB", //รหัสธนาคาร
"Date" : "2023-07-04" //วันที่จ่าย
"AccountCode" : "112100",
"Amount" : 1070
}
]
}
}
```
Response CASE Success
---
```javascript
{
"ResponseStatus" : 200,
"ResponseMsg" : 'Success',
"RespnseSuccess" : [
{
"DocId" : 1,
"DocCode" : "Test", //ถ้าเป็น Rekey มันจะได้โค้ดเดียวกับด้านบน แต่ถ้า RunCode ก็จะได้ตาม RunCode บนระบบ
"Link" : "https://www.staging.com/AR/OtherReceive/Form?id=1"
}
]
"ResponseError" : []
}
```
Response CASE Error
---
```javascript
{
"ResponseStatus" : 400,
"ResponseMsg" : 'Error',
"RespnseSuccess" : [],
"ResponseError" : [
{
"ErrorType" : "RequireField",
"ErrorMsg" : "Receive.ReceiveType"
},
{
"ErrorType" : "NotFoundOnPJM",
"ErrorMsg" : "SubDocTypeId"
}
]
}
{
"ResponseStatus" : 400,
"ResponseMsg" : 'Error', //throw err ตาม ex ได้เลย
"RespnseSuccess" : [],
"ResponseError" : [
{
"ErrorType" : "NoContent",
"ErrorMsg" : "NoContent"
}
]
}
{
"ResponseStatus" : 500,
"ResponseMsg" : 'Exceptiopn Error ex.', //throw err ตาม ex ได้เลย
"RespnseSuccess" : [],
"ResponseError" : []
}
```
:::info
:warning: ประเภทของ Error
:::
400 => เมื่อติด Validate บน PJM ด้วยเรื่องต่างๆ
500 => มี Error จาก C# ฝั่งเรา ให้ใส่ไว้ใน try catch (สิ่งนี้เราคงควบคุมไม่ได้ ต้อง error แบบบ้วนด้วย c# เอา)
**DOC**
---
:::info
:warning: สิ่งที่ต้องรู้ซักนิดนึง
:::
ประเภทของ VAT
1.) หากเป็น ExcludeVat => ยอดใน ReceiveDetail จะต้อง + Vat ไปด้วย เช่นในรายการมียอดรวมกัน 1000 ตอนจ่ายต้องเป็น 1070
2.) หากเป็น IncludeVat หรือ Novat => ยอดใน ReceiveDetail จะต้องเท่ากับรายการเอกสาร
---
| Field | Detail | Description | Ex.|
| -------- | -------- | -------- |-------- |
| Code | Require | แล้วแต่เคส | จะ Require ก็ต่อเมื่อ Subdoctype ที่ส่งมาเป็น rekey ส่วนไม่ใช่ Rekey ก็จะรันตาม Runnumber และ Pattern ตาม Subdoctype |
|| DataType | String ||
|| Example | TestJa ||
| SubDocTypeId | Require | บังคับใส่ | เนื่องด้วยต้อง Mapping กับฝั่ง PJM |
|| DataType |int | PJM มันไม่มีอย่างอื่นที่ Unique เลย|
|| Example | 1 ||
| ExtOrgType | Require | บังคับใส่ | เนื่องด้วยต้อง Mapping กับฝั่ง PJM |
|| DataType |string | |
|| Example | Customer | จะใส่ได้แค่ Customer หรือ Employee เท่านั้น |
| ExtOrgTaxId | Require | - | หากใส่มา แล้วบน PJM ไม่มีจะ Auto สร้าง ExtOrg ให้ |
|| DataType |string | |
|| Example | 0125452456 | จำเป็นต้องใส่ให้ครบ 13 หลัก |
| ExtOrgCode | Require | บังคับใส่ | เนื่องด้วยต้อง Mapping กับฝั่ง PJM |
|| DataType |string | |
|| Example | Test0001 | หากหาในระบบ PJM ไม่เจอจะต้อง Error |
| OrgCode | Require | บังคับใส่ | เนื่องด้วยต้อง Mapping กับฝั่ง PJM |
|| DataType |string | |
|| Example | OrgTest0001 | หากหาในระบบ PJM ไม่เจอจะต้อง Error |
| Date | Require | บังคับใส่ | เอกสารจะต้องมีวันที่ |
|| DataType |Date | |
|| Example | 2023-07-04 | ไม่ใส่มาก็ควรจะ Error ? |
| Currency | Require | - | ตอนนี้ไม่ใส่มา ระบบจะบังคับให้เป็น THB |
|| DataType |string | |
|| Example | THB | เริ่มแรกจะให้ทำได้แค่ค่าเงินบาทอย่างเดียว |
| Remark | Require | - | |
|| DataType |string | |
|| Example | RemarkOnDocument | Remark ของเอกสาร |
| VatType | Require | บังคับใส่ | เอกสาร PJM ต้องรู้ว่าประเภท VAT คืออะไร (ลังเลอยู่ว่าให้ดึงตาม ExtOrg ดีไหม) |
|| DataType |string | |
|| Example | ExcludeVat | ใส่ได้แค่ ExcludeVat,IncludeVat,Novat
| Taxinvoice | Require | - | หากจะสร้าง Subdoctype ของ OR จะต้องทำ parallel Subdoctype เอาไว้ |
|| DataType | bool | |
|| Example | true | หากส่ง true จะสร้าง Taxinvoice ตามจำนวนรายการเอกสารแบบ Auto |
| Receipt | Require | - | |
|| DataType | object | |
|| Example | {usereceipt:true,subdoctypeId:3} | usereceipt จะบอกว่าจะให้สร้าง receipt ไหม แต่ต้องใส่ subdoctype มาด้วยเพื่อให้ runningcode ได้ และจะสร้างตามจำนวนของ line ในเอกสารแบบ Auto |
| LinesDetail | Require | บังคับใส่ | |
|| DataType | object | |
|| Example | อธิบายด้านล่าง | อธิบายในด้านล่างของ LineDetial |
| WHT | Require | - | |
|| DataType | object | |
|| Example | อธิบายด้านล่าง | อธิบายในด้านล่างของ WHT |
| Receive | Require | บังคับใส่ | |
|| DataType | object | |
|| Example | อธิบายด้านล่าง | อธิบายในด้านล่างของ Receive |
LineDetial
| Field | Detail | Description | Ex.|
| -------- | -------- | -------- |-------- |
| LineNumber | Require | บังคับใส่ | |
|| DataType | int | |
|| Example | 1 | ไว้บอกว่าบรรทัดไหน + ไว้แจ้ง error ได้ด้วย |
| OrgCode | Require | บังคับใส่ | |
|| DataType | string | |
|| Example | OrgTest0001 | ต้องมีตัวตนจริงๆ บน PJM |
| Description | Require | - | |
|| DataType | string | |
|| Example | DescriptionOnLine | |
| AccountCode | Require | บังคับใส่ | |
|| DataType | string | |
|| Example | 114200 | ผังบัญชีนี้ต้องมีตัวตนจริงๆ บน PJM และ ต้องเป็นผังบัญชีที่ควรเลือกได้เท่ากับหน้าโปรแกรมด้วย |
| Amount | Require | บังคับใส่ | |
|| DataType | decimal | |
|| Example | 1000 | ยอดเงิน (ตอนนี้ยังไม่รองรับให้ติดลบได้) |
WHT
| Field | Detail | Description | Ex.|
| -------- | -------- | -------- |-------- |
| WHTNumber | Require | - | |
|| DataType | string | |
|| Example | WHTTest | มีก็ได้ไม่มีก็ได้ |
| Date | Require | แล้วแต่เคส | ถ้าไม่ใส่มาจะใช้วันที่ของเอกสาร |
|| DataType | Date | |
|| Example | 2023-04-08 | |
| Type | Require | - | มัน Control ยากคิดว่าจะให้ตาม ExtOrg |
|| DataType | - | |
|| Example | - | |
| Representative | Require | - | |
|| DataType | object | |
|| Example | ดูตาม API ด้านบนเลย | ส่วนนี้ไม่มีผลเท่าไร มีหรือไม่มีก็ได้ |
| Cumulative | Require | - | |
|| DataType | object | |
|| Example | ดูตาม API ด้านบนเลย | ส่วนนี้ไม่มีผลเท่าไร มีหรือไม่มีก็ได้ |
| Filing | Require | บังคับใส่ | |
|| DataType | object | |
|| Example | ดูตาม API ด้านบนเลย | ตรง Type ใส่ได้แค่ Normal กับ Additional เท่านั้น ถ้าใส่ Normal จะไม่สนใจ Number แต่ถ้าเป็น Additional จะต้องใส่ค่า Number มาด้วย |
| Details | Require | แล้วแต่เคส | ถ้าจะสร้าง WHT อย่างน้อยสิ่งนี้ต้องมี |
|| DataType | object | |
|| Example | ดูตาม API ด้านบนเลย | มีแค่ Description จะใส่หรือไม่ใส่ก็ได้ แต่ส่วนของ Type และ Ariticle จะต้องใส่มา และมีในระบบ PJM ด้วย |
**ReceiveDetail**
---
:::info
:warning: สิ่งที่ต้องรู้ซักนิดนึง
:::
1.) ReceiveMethodType หากด้านบนไม่ได้เลือก ReceiveMethod ไม่จำเป็นต้องใส่ค่ามาก็ได้
2.) ReceiveAccount หากด้านบนไม่ได้เลือก ReceiveMethod ไม่จำเป็นต้องใส่ค่ามาก็ได้
3.) CheckNumber สิ่งนี้หากไม่ได้เลือกเป็น ReceiveMethodType เป็น Check ฟิลด์นี้จะไม่มีความสำคัญ
4.) Bank หากด้านบนไม่ได้เลือก ReceiveMethod ไม่จำเป็นต้องใส่ค่ามาก็ได้
5.) Date หากด้านบนไม่ได้เลือก ReceiveMethod ไม่จำเป็นต้องใส่ค่ามาก็ได้
---
Receive
| Field | Detail | Description | Ex.|
| -------- | -------- | -------- |-------- |
| ReceiveType | Require | บังคับใส่ | |
|| DataType | string | |
|| Example | AccountReceivable | ใส่ได้แค่ AccountReceivable และ ReceiveMethod แต่ว่าหากเป็น AccountReceivable จะไม่สามารถทำ WHT ได้ |
| ReceiveDetail | Require | บังคับใส่ | |
|| DataType | arrayObject | |
|| Example | ตาม API แต่เดี๋ยวอธิบายด้านล่าง | อธิบายด้านล่างตรง ReceiveDetail |
ReceiveDetail
| Field | Detail | Description | Ex.|
| -------- | -------- | -------- |-------- |
| ReceiveMethodType | Require | แล้วแต่เคส | หากเป็น Accountreceivable สิ่งนี้ไม่ต้องมี |
|| DataType | string | |
|| Example | BankAccount | ใส่ได้แค่ BankAccount,Deduct,CheckReceive |
| ReceiveAccount | Require | แล้วแต่เคส | หากเป็น Accountreceivable หรือ Deduct สิ่งนี้ไม่ต้องมี |
|| DataType | string | |
|| Example | 015-7874-125 | |
| CheckNumber | Require | แล้วแต่เคส | หากเป็น Accountreceivable หรือ Deduct สิ่งนี้ไม่ต้องมี |
|| DataType | string | |
|| Example | 111111 | ไม่อ้างอิงกับใครสร้างได้เลยเลขอะไรก็ได้ |
| Bank | Require | แล้วแต่เคส | หากเป็น Accountreceivable หรือ Deduct สิ่งนี้ไม่ต้องมี |
|| DataType | string | |
|| Example | TMB | ต้องมีตัวตนจริงๆ บน PJM |
| AccountCode | Require | บังคับใส่ | |
|| DataType | string | |
|| Example | 112100 | ต้องมีตัวตนจริงๆ บน PJM และต้องเป็นผังที่ควรเลือกได้ในหมวดนั้นๆ |
| Amount | Require | บังคับใส่ | |
|| DataType | decimal | |
|| Example | 1070 | ยอดเงินรวม |
**LOG Tracking**
---
ไม่ชัวร์ว่าใจเรายังอยากใช้ S3 กันอยู่ไหม เพราะ S3 มันดูเข้าถึงยาก
ถ้าให้เก็บ JSON ตรงๆ ใน Column input หรือ output มันก็จะก็อปปี้ง่าย แต่มันก็จะดูเก็บเยอะ ถ้าทำเป็นไฟล์แต่โยนไว้ใน Folder NotPublish สร้างใหม่เป็น API คิดว่ามันเอามาดูใช้ง่ายกว่า S3
**Flow**
---
