日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

航天信息金税盘接口 js 调用

發(fā)布時(shí)間:2024/8/1 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 航天信息金税盘接口 js 调用 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

航天信息金稅盤接口 js 調(diào)用

個(gè)人博客: https://blog.joden123.top
原文地址: https://blog.joden123.top/2018/12/02/essay/gold-tax-js/

背景

最近項(xiàng)目要求與單機(jī)版的金稅盤接口進(jìn)行對(duì)接,在這里簡(jiǎn)單記錄一下自己的開發(fā)經(jīng)驗(yàn),希望可以幫助到有需要的人

PS:接口使用 js 對(duì)接,僅支持 ie 瀏覽器。

前置條件

在進(jìn)行開發(fā)時(shí)候需要有一些前置條件

  • ie 瀏覽器
    • 開啟 activeX 控件

      設(shè)置 --> Internet 選項(xiàng) --> 安全 --> 自定義級(jí)別

      把 activeX 相關(guān)設(shè)置勾上

      可參考:

    • 管理員身份運(yùn)行調(diào)試

      如果開票軟件安裝到本地 C盤 需要使用管理員打開 ie 瀏覽器,然后再進(jìn)行調(diào)試

  • 金稅盤安裝

    • 要確保金稅盤安裝準(zhǔn)確安裝了TaxCardX.dll
  • 通用 js代碼

    /** 航信金稅盤相關(guān)function */ var goldTax = {/*** 使用前先判斷是否是ie瀏覽器* @return true/false*/isIE: function () {if(!!window.ActiveXObject || "ActiveXObject" in window)return true;elsereturn false;},/*** 開啟金稅盤* @param certPassword 單機(jī)版為證書口令 服務(wù)器版為地址 留空則讀取開票BIN文件下cert.txt* @return * <pre>* {* 'success': true/false, // 成功或者失敗* 'code': -1/其他, // 錯(cuò)誤碼,-1 為系統(tǒng)錯(cuò)誤* 'msg': 'xxx', // 錯(cuò)誤信息* 'data': {} // 接口返回相關(guān)數(shù)據(jù)* }* </pre>*/openCard: function (certPassword) {var result = {'success': false,'code': -1,'msg': '','data': {}};try {goldTax.card = new ActiveXObject("TaxCardX.GoldTax");// 單機(jī)版為證書口令 服務(wù)器版為地址 留空則讀取開票BIN文件下cert.txtif(typeof certPassword != 'undefined') {goldTax.card.CertPassword = certPassword;}// 開啟金稅盤goldTax.card.OpenCard();result.code = goldTax.card.RetCode;result.msg = goldTax.card.RetMsg;// 1011 開啟成功if (result.code == 1011) {result.success = true;result.data = {RetCode: goldTax.card.RetCode, /* RetCode - 狀態(tài)碼, 1011 開啟成功 */RetMsg: goldTax.card.RetMsg, /* RetMsg 狀態(tài)信息 */InvLimit: goldTax.card.InvLimit, /* InvLimit – 開票限額, 金稅卡發(fā)票開具價(jià)稅合計(jì)限額 */TaxCode: goldTax.card.TaxCode, /* TaxCode 本單位稅號(hào) */TaxClock: goldTax.card.TaxClock, /* TaxClock – 金稅卡時(shí)鐘 */MachineNo: goldTax.card.MachineNo, /* MachineNo – 開票機(jī)號(hào)碼,主開票機(jī)為 0 */IsInvEmpty: goldTax.card.IsInvEmpty, /* IsInvEmpty – 有票標(biāo)志,0為金稅卡中無(wú)可開發(fā)票,1為有票 */IsRepReached: goldTax.card.IsRepReached, /* IsRepReached – 抄稅標(biāo)志,0為未到抄稅期,1為已到抄稅期 */IsLockReached: goldTax.card.IsLockReached, /* IsLockReached – 鎖死標(biāo)志,0為未到鎖死期,1為已到鎖死期 */};} else {result.success = false;}} catch (e) {result.success = false;result.code = -1;result.msg = 'ActiveX Error, ' + e.description;}return result;},/*** 關(guān)閉金稅盤* @return* <pre>* {* 'success': true/false, // 成功或者失敗* 'code': -1/其他, // 錯(cuò)誤碼,-1 為系統(tǒng)錯(cuò)誤* 'msg': 'xxx' // 錯(cuò)誤信息* }* </pre>*/closeCard: function() {var result = {'success': false,'code': -1,'msg': ''};if (typeof goldTax.card != 'undefined') {try {goldTax.card.closeCard();result.code = goldTax.card.RetCode;result.msg = goldTax.card.RetMsg;// RetCode 9000 調(diào)用成功,其他失敗if (result.code == 9000) {result.success = true;} else {result.success = false;}} catch (e) {result.success = false;result.code = -1;result.msg = 'ActiveX Error, ' + e.description;}return result;}},/*** 查詢庫(kù)存發(fā)票* @param invKind 發(fā)票種類* @return * <pre>* {* 'success': true/false, // 成功或者失敗* 'code': -1/其他, // 錯(cuò)誤碼,-1 為系統(tǒng)錯(cuò)誤* 'msg': 'xxx', // 錯(cuò)誤信息* 'data': {} // 接口返回相關(guān)數(shù)據(jù)* }* </pre>*/invoiceInventory: function(invKind) {var result = {'success': false,'code': -1,'msg': '','data': {}};try {if (typeof goldTax.card != 'undefined') {goldTax.card.InfoKind = invKind;goldTax.card.GetInfo();result.code = goldTax.card.RetCode;result.msg = goldTax.card.RetMsg;// RetCode 3011 讀取成功,其他失敗if (result.code == 3011) {result.success = true;result.data = {RetCode: goldTax.card.RetCode, /* RetCode - 狀態(tài)碼, 3011 讀取成功,其他失敗 */RetMsg: goldTax.card.RetMsg, /* RetMsg 狀態(tài)信息 */InfoTypeCode: goldTax.card.InfoTypeCode, /* 要開具發(fā)票的十位代碼。為空或全為0時(shí),表示無(wú)可用發(fā)票 */InfoNumber: goldTax.card.InfoNumber, /* 要開具發(fā)票的號(hào)碼 */InvStock: goldTax.card.InvStock, /* 剩余的可用發(fā)票份數(shù) */TaxClock: goldTax.card.TaxClock /* 金稅盤時(shí)鐘 */};} else {result.success = false;}} else {result.success = false;result.code = -1;result.msg = 'Please Open Card First';}} catch (e) {result.success = false;result.code = -1;result.msg = 'ActiveX Error, ' + e.description;}return result;},/*** 發(fā)票校驗(yàn)* @param o 傳入發(fā)票信息* @return * <pre>* {* 'success': true/false, // 成功或者失敗* 'code': -1/其他, // 錯(cuò)誤碼,-1 為系統(tǒng)錯(cuò)誤* 'msg': 'xxx', // 錯(cuò)誤信息* 'data': {} // 接口返回相關(guān)數(shù)據(jù)* }* </pre>*/invoiceVeriferify: function(o) {return goldTax.inner.invoice(1, o);},/*** 發(fā)票開具* @param o 傳入發(fā)票信息* @return * <pre>* {* 'success': true/false, // 成功或者失敗* 'code': -1/其他, // 錯(cuò)誤碼,-1 為系統(tǒng)錯(cuò)誤* 'msg': 'xxx', // 錯(cuò)誤信息* 'data': {} // 接口返回相關(guān)數(shù)據(jù)* }* </pre>*/invoicing: function(o) {return goldTax.inner.invoice(0, o);},/*** 發(fā)票打印* @param o 傳入發(fā)票信息* @return * <pre>* {* 'success': true/false, // 成功或者失敗* 'code': -1/其他, // 錯(cuò)誤碼,-1 為系統(tǒng)錯(cuò)誤* 'msg': 'xxx' // 錯(cuò)誤信息* }* </pre>*/printInv: function(o) {var result = {'success': false,'code': -1,'msg': ''};try {if (typeof goldTax.card != 'undefined') {goldTax.card.InfoKind = o.InfoKind; /* 發(fā)票種類(0:專用發(fā)票 2:普通發(fā)票 11:貨物運(yùn)輸業(yè)增值稅專用發(fā)票 12:機(jī)動(dòng)車銷售統(tǒng)一發(fā)票) */goldTax.card.InfoTypeCode = o.InfoTypeCode; /* 要打印發(fā)票的十位代碼 */goldTax.card.InfoNumber = o.InfoNumber; /* 要打印發(fā)票的號(hào)碼 */goldTax.card.GoodsListFlag = o.GoodsListFlag; /* 銷貨清單標(biāo)志,0 – 打印發(fā)票,1 – 打印銷貨清單 */goldTax.card.InfoShowPrtDlg = o.InfoShowPrtDlg; /* 打印時(shí)是否顯示邊距確認(rèn)對(duì)話框,0 – 不出現(xiàn),1 – 出現(xiàn) */// 調(diào)用接口goldTax.card.PrintInv();result.code = goldTax.card.RetCode;result.msg = goldTax.card.RetMsg;// RetCode 5011 打印成功,5001 – 未找到發(fā)票或清單,5012 – 未打印,5013 – 打印失敗if (result.code == 5011) {result.success = true;} else {result.success = false;}} else {result.success = false;result.code = -1;result.msg = 'Please Open Card First';}} catch (e) {result.success = false;result.code = -1;result.msg = 'ActiveX Error, ' + e.description;}return result;},/*** 已開發(fā)票作廢* @param o 傳入發(fā)票信息* @return * <pre>* {* 'success': true/false, // 成功或者失敗* 'code': -1/其他, // 錯(cuò)誤碼,-1 為系統(tǒng)錯(cuò)誤* 'msg': 'xxx' // 錯(cuò)誤信息* }* </pre>*/cancelInv: function(o) {var result = {'success': false,'code': -1,'msg': ''};try {if (typeof goldTax.card != 'undefined') {goldTax.card.InfoKind = o.InfoKind; /* 發(fā)票種類(0:專用發(fā)票 2:普通發(fā)票 11:貨物運(yùn)輸業(yè)增值稅專用發(fā)票 12:機(jī)動(dòng)車銷售統(tǒng)一發(fā)票) */goldTax.card.InfoTypeCode = o.InfoTypeCode; /* 要作廢發(fā)票的十位或十二位代碼 */goldTax.card.InfoNumber = o.InfoNumber; /* 要作廢發(fā)票的號(hào)碼 */// 調(diào)用接口goldTax.card.CancelInv();result.code = goldTax.card.RetCode;result.msg = goldTax.card.RetMsg;// RetCode 6011 打印成功,6001 – 當(dāng)月發(fā)票庫(kù)未找到該發(fā)票,6002 – 該發(fā)票已經(jīng)作廢,6012 – 作廢失敗,6013 – 作廢失敗(異常)if (result.code == 6011) {result.success = true;} else {result.success = false;}} else {result.success = false;result.code = -1;result.msg = 'Please Open Card First';}} catch (e) {result.success = false;result.code = -1;result.msg = 'ActiveX Error, ' + e.description;}return result;},// 內(nèi)部方法inner: {/*** invoice 接口* @param checkEWM 默認(rèn)為0(0: 發(fā)票開具, 1: 發(fā)票校驗(yàn), 2: 空白作廢)* @param o 傳入發(fā)票信息* @return * <pre>* {* 'success': true/false, // 成功或者失敗* 'code': -1/其他, // 錯(cuò)誤碼,-1 為系統(tǒng)錯(cuò)誤* 'msg': 'xxx', // 錯(cuò)誤信息* 'data': {} // 接口返回相關(guān)數(shù)據(jù)* }* </pre>*/invoice: function(checkEWM, o) {var result = {'success': false,'code': -1,'msg': '','data': {}};try {if (typeof goldTax.card != 'undefined') {// CheckEWM值默認(rèn)為0(為1時(shí)用于發(fā)票校驗(yàn)。// 注意:一旦CheckEWM值置1用于發(fā)票校驗(yàn)之后,//如果要再進(jìn)行發(fā)票開具必須手動(dòng)將CheckEWM值置為0,否則Invoice()方法的功能將一直處于發(fā)票校驗(yàn)狀態(tài))goldTax.card.CheckEWM = checkEWM; goldTax.card.InvInfoInit(); /* 初始化發(fā)票抬頭信息 */goldTax.card.InfoKind = o.InfoKind; /* 增值稅普通發(fā)票2 專票0 */goldTax.card.InfoClientName = o.InfoClientName; /* 購(gòu)方名稱 */goldTax.card.InfoClientTaxCode = o.InfoClientTaxCode; /* 購(gòu)方稅號(hào) */goldTax.card.InfoClientBankAccount = o.InfoClientBankAccount; /* 購(gòu)方開戶行及賬號(hào) */goldTax.card.InfoClientAddressPhone = o.InfoClientAddressPhone; /* 購(gòu)方地址電話 */goldTax.card.InfoSellerBankAccount = o.InfoSellerBankAccount; /* 銷方開戶行及賬號(hào) */goldTax.card.InfoSellerAddressPhone = o.InfoSellerAddressPhone; /* 銷方地址電話 */// 如果是多商品多稅率 稅率應(yīng)該放到下面商品信息循環(huán)里if (typeof o.InfoTaxRate != 'undefined' && o.InfoTaxRate) { goldTax.card.InfoTaxRate = o.InfoTaxRate; /* 稅率,(已授權(quán)的稅率, 17% 傳17) */}goldTax.card.InfoNotes = o.InfoNotes; /* 備注 */goldTax.card.InfoInvoicer = o.InfoInvoicer; /* 開票人 */// 復(fù)核人,可為空if (typeof o.InfoChecker != 'undefined' && o.InfoChecker) {goldTax.card.InfoChecker = o.InfoChecker;}// 收款人,可為空if (typeof o.InfoCashier != 'undefined' && o.InfoCashier) {goldTax.card.InfoCashier = o.InfoCashier;}// 如不為空,則開具銷貨清單,此為發(fā)票上商品名稱欄的清單信息,應(yīng)為“(詳見銷貨清單)”字樣if (typeof o.InfoListName != 'undefined' && o.InfoListName) { goldTax.card.InfoListName = o.InfoListName;}// 清空商品明細(xì)列表goldTax.card.ClearInvList(); // 遍歷行$.each(o.InvList, function(i, v) {goldTax.card.InvListInit(); /* 初始化發(fā)票明細(xì)信息各項(xiàng)屬性 */goldTax.card.ListGoodsName = v.ListGoodsName; /* 商品或勞務(wù)名稱 */goldTax.card.ListTaxItem = v.ListTaxItem; /* 稅目,4位數(shù)字,商品所屬類別 */goldTax.card.ListStandard = v.ListStandard; /* 規(guī)格型號(hào) */// 計(jì)量單位,如計(jì)量單位為空,則忽略數(shù)量和單價(jià)if (typeof v.ListUnit != 'undefined' && v.ListUnit) {goldTax.card.ListUnit = v.ListUnit;}// 建議傳入數(shù)量和含稅單價(jià)或含稅金額 由接口計(jì)算帶小數(shù)的稅額 規(guī)避誤差goldTax.card.ListNumber = v.ListNumber; // 數(shù)量goldTax.card.ListPrice = v.ListPrice; // 單價(jià)// 金額,可以不傳(為0),由接口軟件計(jì)算,如傳入則應(yīng)符合計(jì)算關(guān)系if (typeof v.ListAmount != 'undefined' && v.ListAmount ) {goldTax.card.ListAmount = v.ListAmount;}goldTax.card.ListPriceKind = v.ListPriceKind; /* 含稅價(jià)標(biāo)志,單價(jià)和金額的種類, 0為不含稅價(jià),1為含稅價(jià) */// 稅額可以不傳(為0),由接口軟件計(jì)算,如傳入則應(yīng)符合計(jì)算關(guān)系if (typeof v.ListTaxAmount != 'undefined' && v.ListTaxAmount) {goldTax.card.ListTaxAmount = v.ListTaxAmount;}// 添加一行goldTax.card.AddInvList();});// 調(diào)用接口goldTax.card.Invoice();result.code = goldTax.card.RetCode;result.msg = goldTax.card.RetMsg;// RetCode 4011 開票成功,其他失敗if (result.code == 4011) {result.success = true;result.data = {RetCode: goldTax.card.RetCode, /* RetCode - 狀態(tài)碼, 3011 讀取成功,其他失敗 */RetMsg: goldTax.card.RetMsg, /* RetMsg 狀態(tài)信息 */InfoAmount: goldTax.card.InfoAmount , /* 合計(jì)不含稅金額 */InfoTaxAmount: goldTax.card.InfoTaxAmount, /* 合計(jì)稅額 */InfoInvDate: goldTax.card.InfoInvDate, /* 開票日期 */InfMonth: goldTax.card.InfMonth, /* 所屬月份 */InfoTypeCode: goldTax.card.InfoTypeCode, /* 發(fā)票十位代碼 */InfoNumber: goldTax.card.InfoNumber, /* 發(fā)票號(hào)碼 */GoodsListFlag: goldTax.card.GoodsListFlag /* 銷貨清單標(biāo)志,0 – 無(wú)銷貨清單,1 – 有銷貨清單 */};} else {result.success = false;}} else {result.success = false;result.code = -1;result.msg = 'Please Open Card First';}} catch (e) {result.success = false;result.code = -1;result.msg = 'ActiveX Error, ' + e.description;}return result;}} };

    相關(guān)資料

    CSDN 需要積分下載 金稅 防偽稅控 組件接口 開發(fā)文檔 代碼案例

    沒(méi)有積分的 戳這里

    總結(jié)

    以上是生活随笔為你收集整理的航天信息金税盘接口 js 调用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

    如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。