發票開立 /Invoice/InvoiceAdd
Request 請求內容
根節點
參數 | 名稱 | 型態 | 必要性 | 說明 |
ProNum | 廠商代號 | S(10) | M | |
Option | 設定檔 | 組合 | M | |
Main | 主檔 | 組合 | M | |
Details | 明細檔 | 組合 | M |
設定檔(Option)
參數 | 名稱 | 型態 | 必要性 | 說明 |
SelectInvoiceAuto | 發票自動配號 | S(1) | M | 0:不自動配號 1:自動配號 |
SelectInvoiceCompany | 發票公司 | S(6) | M | 選擇發票公司的代號, 可於TMS發票系統的 J-銷項發票設定作業查看 |
SelectInvoiceYmon | 發票期別 | S(5) | 可不填,預設會根據發票開立日期自動產生, 格式範例ex.10805 | |
SelectInvoiceDay | 發票開立日期 | S(30) | M | 必填,格式為西元日期, yyyy/MM/dd 請輸入ex. 2024/11/24, 也可以加上時間 yyyy/MM/dd HH:mm:ss ex. 2024/11/24 18:03:06 |
SelectInvoiceWord | 指定發票字軌 | S(2) | OM | 當你使用自動配號為1時不必填 |
SelectInvoiceNoP | 指定發票號碼 | S(50) | 當你使用自動配號為1時不必填 | |
SelectInvoiceTaxMode | 發票明細稅別取得方式 | S(1) | 1:一率應稅 2:一率零稅 3:一率免稅 8:根據明細指定稅別(預設) 9:根據TMS獲利王產品設定 |
|
SelectProductSaleWithTax | 你在產品明細指定的金額為稅前還是稅後 | S(1) | 0:稅前 1:稅後 |
|
Recalculate | 主檔總計是否由系統自動計算 | S(1) | 0:發票主檔的銷售額總計不重新計算,由客戶自行指定 1:發票主檔的銷售額由系統根據明細小計進行計算 有時根據不同系統會產生不同的計算方式, 為了保持一致性需要將此設定值設為0 舉例來說 明細產品A 稅後銷售 10.5, 明細產品B 稅後銷售 10.5 , 有些系統算出來總計會是21,有些算出來是22 另外根據情況稅額也可能不同, 部分系統的稅差也可能會有1元的差異 如有此狀況的則請採用自行指定銷售額與稅額 |
|
SelectMSPaperCodeCheck | 檢查主檔單據編號是否重複,重複則不匯入 | S(1) | 0:不檢查(預設) 1:檢查 |
|
SCODE | 操作員代號 | S(4) | M | 請指定業務代號做為系統紀錄 |
主檔(Main)
參數 | 名稱 | 型態 | 必要性 | 說明 |
Ccode | 客戶代號 | S(6) | 請輸入TMS客戶代號,如果沒使用到可不填 | |
Cnam2 | 客戶簡稱 | S(12) | ||
Cnam1 | 發票抬頭 | S(100) | ||
CTCOD | 統一編號 | S(8) | ||
Cadd2 | 發票地址 | S(50) | ||
Back | 電話 | S(50) | ||
CarrierType | 載具類別 | S(6) | ||
CarrierId1 | 載具號碼 | S(64) | ||
CardNo4 | 刷卡後4碼 | S(4) | ||
NPOBAN | 愛心碼 | S(10) | ||
RandomNumber | 隨機碼 | S(4) | 空白則系統自動產生 | |
MSPaperCode | 主檔單據編號 | S(40) | 可用來避免重複匯入的判斷號碼 | |
BuyerEmail | 買方電子郵件地址 | S(80) | ||
SalesAmount | 應稅銷售額(稅前) | Int | OM | 當你選擇計算自行指定主檔金額則此欄位必填 |
ZeroTaxSalesAmount | 零稅銷售額 | Int | OM | 當你選擇計算自行指定主檔金額則此欄位必填 |
FreeTaxSalesAmount | 免稅銷售額 | Int | OM | 當你選擇計算自行指定主檔金額則此欄位必填 |
Taxs | 銷售稅額 | Int | OM | 當你選擇計算自行指定主檔金額則此欄位必填 |
發票明細(Details)
參數 | 名稱 | 型態 | 必要性 | 說明 |
Sinvod_Hicod | 產品代號 | S(17) | O | |
Sinvod_Hinam | 產品名稱 | S(40) | M | 必填 |
Sinvod_Qty | 數量 | D(28,7) | M | |
Sinvod_Hpoin | 單位 | S(6) | O | |
Sinvod_Price | 單價 | D(28,7) | M | |
Sinvod_Total | 單價 | D(28,7) | M | |
Sinvod_TaxType | 稅別 | S(1) | M | 1:應稅 2:零稅 3:免稅 |
Sinvod_DBAK1 | 明細備註 | S(100) |
回覆結果(Response)
參數 | 名稱 | 型態 | 說明 |
Status | 處理狀態 | S(1) | S:正確 E:錯誤 |
InvoiceNo | 發票號碼 | S(10) | 正確才會回傳 |
InvoiceDate | 發票日期 | S(20) | 格式為 yyyy-MM-dd HH:mm:ss |
MSPaperCode | 主檔單據編號 | S(40) | |
ErrorCode | 錯誤碼 | S(4) | |
ErrorMessage | 主要錯誤訊息 | S(300) | |
ErrorDetail | 錯誤明細 | 陣列:S(MAX) | 初步建置時可用來參考 |
Request範例
//請求Header內容
api-pno:TMSDEMOWEB
api-timestamp:1560765920
api-ClientSign:9415B9D2BF785962730DFBF21866AE9ACCC5BCA90F60CA7B322949CBF954C64BFA7213A60E35A1BBF2308DB2D9FA7A86DB6CB4739B45B33A78A8D52301D8B1B6
//請求Body內容-常用範例1-自行填入主檔銷售額與稅額
{
"Option": {
"SelectInvoiceAuto": "1",
"SelectInvoiceCompany": "1",
"SelectInvoiceTaxMode": "8",
"SelectProductSaleWithTax": "1",
"SelectMSPaperCodeCheck": "0",
"Recalculate": "0",
"SCODE":"TMS"
},
"Main": {
"CNAM1": "廣鐸企業有限公司",
"CTCOD": "11111117",
"CADD2": "台中市北屯區大大路999號",
"CarrierType": "3J0002",
"CarrierId1": "/123456",
"NPOBAN": "123",
"RandomNumber": "1234",
"MSPaperCode": "10806170001",
"BuyerEmail": "test@test.com.tw",
"SalesAmount": 100,
"ZeroTaxSalesAmount": 200,
"FreeTaxSalesAmount": 50,
"Taxs": 5
},
"Details": [
{
"Sinvod_hinam": "AAAAAAAAA","Sinvod_TaxType": "1","Sinvod_Qty": 1,"Sinvod_price": 65,"Sinvod_Total": 65
},
{
"Sinvod_hinam": "BBBBBBBBB","Sinvod_TaxType": "1","Sinvod_Qty": 2,"Sinvod_price": 20,"Sinvod_Total": 40
},
{
"Sinvod_hinam": "CCCCCCCCC","Sinvod_TaxType": "2","Sinvod_Qty": 1,"Sinvod_price": 100,"Sinvod_Total": 200
},
{
"Sinvod_hinam": "DDDDDDDDD","Sinvod_TaxType": "3","Sinvod_Qty": 1,"Sinvod_price": 100,"Sinvod_Total": 50
}
]
}
//請求Header內容
api-pno:TMSDEMOWEB
api-timestamp:1560765920
api-ClientSign:9415B9D2BF785962730DFBF21866AE9ACCC5BCA90F60CA7B322949CBF954C64BFA7213A60E35A1BBF2308DB2D9FA7A86DB6CB4739B45B33A78A8D52301D8B1B6
//請求Body內容-範例2-由系統計算主檔銷售額與稅額
{
"Option": {
"SelectInvoiceAuto": "1",
"SelectInvoiceCompany": "1",
"SelectInvoiceTaxMode": "8",
"SelectProductSaleWithTax": "1",
"SelectMSPaperCodeCheck": "0",
"Recalculate": "1",
"SCODE":"TMS"
},
"Main": {
"CNAM1": "廣鐸企業有限公司",
"CTCOD": "11111117",
"CADD2": "台中市北屯區大大路999號",
"CarrierType": "3J0002",
"CarrierId1": "/123456",
"NPOBAN": "123",
"RandomNumber": "1234",
"MSPaperCode": "10806170001",
"BuyerEmail": "test@test.com.tw"
},
"Details": [
{
"Sinvod_hinam": "AAAAAAAAA","Sinvod_TaxType": "1","Sinvod_Qty": 1,"Sinvod_price": 65,"Sinvod_Total": 65
},
{
"Sinvod_hinam": "BBBBBBBBB","Sinvod_TaxType": "1","Sinvod_Qty": 2,"Sinvod_price": 20,"Sinvod_Total": 40
},
{
"Sinvod_hinam": "CCCCCCCCC","Sinvod_TaxType": "2","Sinvod_Qty": 1,"Sinvod_price": 100,"Sinvod_Total": 200
},
{
"Sinvod_hinam": "DDDDDDDDD","Sinvod_TaxType": "3","Sinvod_Qty": 1,"Sinvod_price": 100,"Sinvod_Total": 50
}
]
}
//請求Header內容
api-pno:TMSDEMOWEB
api-timestamp:1560765920
api-ClientSign:9415B9D2BF785962730DFBF21866AE9ACCC5BCA90F60CA7B322949CBF954C64BFA7213A60E35A1BBF2308DB2D9FA7A86DB6CB4739B45B33A78A8D52301D8B1B6
//請求Body內容-範例3-進階範例
{
"Option":{
"SelectInvoiceAuto":"1",
"SelectInvoiceCompany":"1",
"SelectInvoiceYmon":"",
"SelectInvoiceDay":"",
"SelectInvoiceWord":"",
"SelectInvoiceNoS":"",
"SelectInvoiceNoE":"",
"SelectInvoiceNoP":"",
"SelectInvoiceTaxMode":"8",
"SelectProductSaleWithTax":"1",
"SelectMSPaperCodeCheck":"1",
"Recalculate":"1",
"SCODE":"TMS"
},
"Main":{
"CNAM1": "廣鐸企業有限公司",
"CTCOD": "11111117",
"CADD2": "台中市北屯區大大路999號",
"CarrierType": "3J0002",
"CarrierId1": "/123456",
"NPOBAN": "123",
"RandomNumber": "1234",
"MSPaperCode": "10806170001",
"BuyerEmail": "test@test.com.tw",
"SalesAmount": 100,
"ZeroTaxSalesAmount": 200,
"FreeTaxSalesAmount": 50,
"Taxs": 5,
},
"Details":[
{ "Sinvod_hinam": "AAAAAAAAA", "Sinvod_TaxType": "1", Sinvod_Qty:1, Sinvod_price: 65, Sinvod_Total: 65},
{ "Sinvod_hinam": "BBBBBBBBB", "Sinvod_TaxType": "1", Sinvod_Qty:2, Sinvod_price: 20, Sinvod_Total: 40},
{ "Sinvod_hinam": "CCCCCCCCC", "Sinvod_TaxType": "2", Sinvod_Qty:1, Sinvod_price: 100, Sinvod_Total: 200},
{ "Sinvod_hinam": "DDDDDDDDD", "Sinvod_TaxType": "3", Sinvod_Qty:1, Sinvod_price: 100, Sinvod_Total: 50},
]
,
}
Response 回覆結果
Response範例
成功
{
"Status": "S",
"InvoiceNo": "QD10000249",
"InvoiceDate": "108-06-19 13:50:00",
"MSPaperCode": "10806190001",
"ErrorCode": "0000",
"ErrorMessage": "",
"ErrorDetail": []
}
失敗
{
"Status": "E",
"InvoiceNo": "",
"MSPaperCode": "",
"ErrorCode": "9003",
"ErrorMessage": "Timestamp已過期",
"ErrorDetail": []
}
失敗
{
"Status": "E",
"InvoiceNo": "",
"MSPaperCode": "",
"ErrorCode": "2006",
"ErrorMessage": "單號重複:XX10609270010",
"ErrorDetail": []
}