PCE 交易建立 API
對象:外部系統/廠商
用途:只建立 NetSuite 交易。不建立、不更新進項憑證。
腳本:
呼叫紀錄:
用途:只建立 NetSuite 交易。不建立、不更新進項憑證。
腳本:
customscript_pce_rl_tx_create 呼叫紀錄:
customrecord_pce_tx_create_log(與進項 customrecord_pce_ap_write_log 分開)OAuth 2.0 取 token 的方式與 AP Write 介接手冊 §1 相同。External URL 是這支腳本自己的部署,不是 AP Write。
請求
只接受 POST。GET 回 1011 / PCE_METHOD_NOT_ALLOWED。
不要帶 action、apInvoices、invoices,也不要帶 transaction.id 或任何 custbody_pce_/custcol_pce_ 欄位。
{
"requestId": "a1b2c3d4-e5f6-4789-a012-3456789abcde",
"transaction": {
"clientRef": "vb-001",
"type": "vendorbill",
"fields": {
"entity": "123",
"subsidiary": "1",
"account": "220",
"memo": "Vendor bill"
},
"expenseLines": [
{ "account": "610", "amount": 1050 }
]
},
"options": { "validateOnly": false }
}transaction 可以是物件或陣列,最多 10 筆。type 只接受:
| type | NetSuite 交易 |
|---|---|
vendorbill | Vendor Bill |
expensereport | Expense Report |
vendorcredit | Vendor Credit |
vendorprepayment | Vendor Prepayment |
requestId 為 8–64 碼英數、減號或底線。同一 requestId 與相同內容重送時回先前結果(returnCode 0002)。內容不同則回 1005。
options.validateOnly: true 只檢查格式,不存檔,回 0001。
Vendor Bill 可帶 purchaseOrderId,並用 itemLines[].orderline 與 quantity 指定要收的採購明細。
回應
成功:
{
"success": true,
"returnCode": "0000",
"returnMessage": "OK",
"requestId": "a1b2c3d4-e5f6-4789-a012-3456789abcde",
"results": [{
"index": 0,
"returnCode": "0000",
"returnMessage": "OK",
"clientRef": "vb-001",
"transactionId": "789",
"transactionType": "vendorbill",
"transactionCreated": true
}]
}同一請求有成功也有失敗時,success 為 false、partialSuccess 為 true、returnCode 為 0004。已建立的交易不會還原。
形狀錯誤的代碼:1001 body、1002 帶了 action、1003/1004 requestId、1006 帶了進項憑證、1007 沒有 transaction、1008 type、1009 超過 10 筆、1012 帶了 id、1013 帶了 PCE 欄位、1014–1017 採購單收貨格式。執行期錯誤多為 4000,採購單轉換失敗為 4002/4003。