Untitled
unknown
plain_text
2 years ago
44 kB
6
Indexable
var paymentCode = 2; // Код вида оплаты var keyMacros = "{F3}"; //Клавиша для запуска макроса var keyPayment = "{F7}"; //Клавиша для перехода в расчет var del = "{DELETE}"; var ent = "{ENTER}"; var esc = "{ESC}"; ////////////////////////////////////////////////////////// var CryptoJS=CryptoJS||function(q,r){var k={},g=k.lib={},p=function(){},t=g.Base={extend:function(b){p.prototype=this;var j=new p;b&&j.mixIn(b);j.hasOwnProperty("init")||(j.init=function(){j.$super.init.apply(this,arguments)});j.init.prototype=j;j.$super=this;return j},create:function(){var b=this.extend();b.init.apply(b,arguments);return b},init:function(){},mixIn:function(b){for(var j in b)b.hasOwnProperty(j)&&(this[j]=b[j]);b.hasOwnProperty("toString")&&(this.toString=b.toString)},clone:function(){return this.init.prototype.extend(this)}}, n=g.WordArray=t.extend({init:function(b,j){b=this.words=b||[];this.sigBytes=j!=r?j:4*b.length},toString:function(b){return(b||u).stringify(this)},concat:function(b){var j=this.words,a=b.words,l=this.sigBytes;b=b.sigBytes;this.clamp();if(l%4)for(var h=0;h<b;h++)j[l+h>>>2]|=(a[h>>>2]>>>24-8*(h%4)&255)<<24-8*((l+h)%4);else if(65535<a.length)for(h=0;h<b;h+=4)j[l+h>>>2]=a[h>>>2];else j.push.apply(j,a);this.sigBytes+=b;return this},clamp:function(){var b=this.words,j=this.sigBytes;b[j>>>2]&=4294967295<< 32-8*(j%4);b.length=q.ceil(j/4)},clone:function(){var b=t.clone.call(this);b.words=this.words.slice(0);return b},random:function(b){for(var j=[],a=0;a<b;a+=4)j.push(4294967296*q.random()|0);return new n.init(j,b)}}),v=k.enc={},u=v.Hex={stringify:function(b){var a=b.words;b=b.sigBytes;for(var h=[],l=0;l<b;l++){var m=a[l>>>2]>>>24-8*(l%4)&255;h.push((m>>>4).toString(16));h.push((m&15).toString(16))}return h.join("")},parse:function(b){for(var a=b.length,h=[],l=0;l<a;l+=2)h[l>>>3]|=parseInt(b.substr(l, 2),16)<<24-4*(l%8);return new n.init(h,a/2)}},a=v.Latin1={stringify:function(b){var a=b.words;b=b.sigBytes;for(var h=[],l=0;l<b;l++)h.push(String.fromCharCode(a[l>>>2]>>>24-8*(l%4)&255));return h.join("")},parse:function(b){for(var a=b.length,h=[],l=0;l<a;l++)h[l>>>2]|=(b.charCodeAt(l)&255)<<24-8*(l%4);return new n.init(h,a)}},s=v.Utf8={stringify:function(b){try{return decodeURIComponent(escape(a.stringify(b)))}catch(h){throw Error("Malformed UTF-8 data");}},parse:function(b){return a.parse(unescape(encodeURIComponent(b)))}}, h=g.BufferedBlockAlgorithm=t.extend({reset:function(){this._data=new n.init;this._nDataBytes=0},_append:function(b){"string"==typeof b&&(b=s.parse(b));this._data.concat(b);this._nDataBytes+=b.sigBytes},_process:function(b){var a=this._data,h=a.words,l=a.sigBytes,m=this.blockSize,k=l/(4*m),k=b?q.ceil(k):q.max((k|0)-this._minBufferSize,0);b=k*m;l=q.min(4*b,l);if(b){for(var g=0;g<b;g+=m)this._doProcessBlock(h,g);g=h.splice(0,b);a.sigBytes-=l}return new n.init(g,l)},clone:function(){var b=t.clone.call(this); b._data=this._data.clone();return b},_minBufferSize:0});g.Hasher=h.extend({cfg:t.extend(),init:function(b){this.cfg=this.cfg.extend(b);this.reset()},reset:function(){h.reset.call(this);this._doReset()},update:function(b){this._append(b);this._process();return this},finalize:function(b){b&&this._append(b);return this._doFinalize()},blockSize:16,_createHelper:function(b){return function(a,h){return(new b.init(h)).finalize(a)}},_createHmacHelper:function(b){return function(a,h){return(new m.HMAC.init(b, h)).finalize(a)}}});var m=k.algo={};return k}(Math); (function(q){function r(a,m,b,j,g,l,k){a=a+(m&b|~m&j)+g+k;return(a<<l|a>>>32-l)+m}function k(a,m,b,j,g,l,k){a=a+(m&j|b&~j)+g+k;return(a<<l|a>>>32-l)+m}function g(a,m,b,j,g,l,k){a=a+(m^b^j)+g+k;return(a<<l|a>>>32-l)+m}function p(a,g,b,j,k,l,p){a=a+(b^(g|~j))+k+p;return(a<<l|a>>>32-l)+g}for(var t=CryptoJS,n=t.lib,v=n.WordArray,u=n.Hasher,n=t.algo,a=[],s=0;64>s;s++)a[s]=4294967296*q.abs(q.sin(s+1))|0;n=n.MD5=u.extend({_doReset:function(){this._hash=new v.init([1732584193,4023233417,2562383102,271733878])}, _doProcessBlock:function(h,m){for(var b=0;16>b;b++){var j=m+b,n=h[j];h[j]=(n<<8|n>>>24)&16711935|(n<<24|n>>>8)&4278255360}var b=this._hash.words,j=h[m+0],n=h[m+1],l=h[m+2],q=h[m+3],t=h[m+4],s=h[m+5],u=h[m+6],v=h[m+7],w=h[m+8],x=h[m+9],y=h[m+10],z=h[m+11],A=h[m+12],B=h[m+13],C=h[m+14],D=h[m+15],c=b[0],d=b[1],e=b[2],f=b[3],c=r(c,d,e,f,j,7,a[0]),f=r(f,c,d,e,n,12,a[1]),e=r(e,f,c,d,l,17,a[2]),d=r(d,e,f,c,q,22,a[3]),c=r(c,d,e,f,t,7,a[4]),f=r(f,c,d,e,s,12,a[5]),e=r(e,f,c,d,u,17,a[6]),d=r(d,e,f,c,v,22,a[7]), c=r(c,d,e,f,w,7,a[8]),f=r(f,c,d,e,x,12,a[9]),e=r(e,f,c,d,y,17,a[10]),d=r(d,e,f,c,z,22,a[11]),c=r(c,d,e,f,A,7,a[12]),f=r(f,c,d,e,B,12,a[13]),e=r(e,f,c,d,C,17,a[14]),d=r(d,e,f,c,D,22,a[15]),c=k(c,d,e,f,n,5,a[16]),f=k(f,c,d,e,u,9,a[17]),e=k(e,f,c,d,z,14,a[18]),d=k(d,e,f,c,j,20,a[19]),c=k(c,d,e,f,s,5,a[20]),f=k(f,c,d,e,y,9,a[21]),e=k(e,f,c,d,D,14,a[22]),d=k(d,e,f,c,t,20,a[23]),c=k(c,d,e,f,x,5,a[24]),f=k(f,c,d,e,C,9,a[25]),e=k(e,f,c,d,q,14,a[26]),d=k(d,e,f,c,w,20,a[27]),c=k(c,d,e,f,B,5,a[28]),f=k(f,c, d,e,l,9,a[29]),e=k(e,f,c,d,v,14,a[30]),d=k(d,e,f,c,A,20,a[31]),c=g(c,d,e,f,s,4,a[32]),f=g(f,c,d,e,w,11,a[33]),e=g(e,f,c,d,z,16,a[34]),d=g(d,e,f,c,C,23,a[35]),c=g(c,d,e,f,n,4,a[36]),f=g(f,c,d,e,t,11,a[37]),e=g(e,f,c,d,v,16,a[38]),d=g(d,e,f,c,y,23,a[39]),c=g(c,d,e,f,B,4,a[40]),f=g(f,c,d,e,j,11,a[41]),e=g(e,f,c,d,q,16,a[42]),d=g(d,e,f,c,u,23,a[43]),c=g(c,d,e,f,x,4,a[44]),f=g(f,c,d,e,A,11,a[45]),e=g(e,f,c,d,D,16,a[46]),d=g(d,e,f,c,l,23,a[47]),c=p(c,d,e,f,j,6,a[48]),f=p(f,c,d,e,v,10,a[49]),e=p(e,f,c,d, C,15,a[50]),d=p(d,e,f,c,s,21,a[51]),c=p(c,d,e,f,A,6,a[52]),f=p(f,c,d,e,q,10,a[53]),e=p(e,f,c,d,y,15,a[54]),d=p(d,e,f,c,n,21,a[55]),c=p(c,d,e,f,w,6,a[56]),f=p(f,c,d,e,D,10,a[57]),e=p(e,f,c,d,u,15,a[58]),d=p(d,e,f,c,B,21,a[59]),c=p(c,d,e,f,t,6,a[60]),f=p(f,c,d,e,z,10,a[61]),e=p(e,f,c,d,l,15,a[62]),d=p(d,e,f,c,x,21,a[63]);b[0]=b[0]+c|0;b[1]=b[1]+d|0;b[2]=b[2]+e|0;b[3]=b[3]+f|0},_doFinalize:function(){var a=this._data,g=a.words,b=8*this._nDataBytes,j=8*a.sigBytes;g[j>>>5]|=128<<24-j%32;var k=q.floor(b/ 4294967296);g[(j+64>>>9<<4)+15]=(k<<8|k>>>24)&16711935|(k<<24|k>>>8)&4278255360;g[(j+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;a.sigBytes=4*(g.length+1);this._process();a=this._hash;g=a.words;for(b=0;4>b;b++)j=g[b],g[b]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=u.clone.call(this);a._hash=this._hash.clone();return a}});t.MD5=u._createHelper(n);t.HmacMD5=u._createHmacHelper(n)})(Math); (function(){var q=CryptoJS,r=q.enc.Utf8;q.algo.HMAC=q.lib.Base.extend({init:function(k,g){k=this._hasher=new k.init;"string"==typeof g&&(g=r.parse(g));var p=k.blockSize,q=4*p;g.sigBytes>q&&(g=k.finalize(g));g.clamp();for(var n=this._oKey=g.clone(),v=this._iKey=g.clone(),u=n.words,a=v.words,s=0;s<p;s++)u[s]^=1549556828,a[s]^=909522486;n.sigBytes=v.sigBytes=q;this.reset()},reset:function(){var k=this._hasher;k.reset();k.update(this._iKey)},update:function(k){this._hasher.update(k);return this},finalize:function(k){var g= this._hasher;k=g.finalize(k);g.reset();return g.finalize(this._oKey.clone().concat(k))}})})(); ///////////////////////////////////////////////////////////// var FileNameCounter = "D:\vidoplaty.txt"; //Установить в путь файла с безналичной оплатой var baseAddress = "http://localhost:4447/fiscal/"; // Установить в адрес фискального сервиса var calcType = 0; //Установить в предмет расчета, 0 - товар, 1 - услуга итп. var vatRates = [0, 12]; var stRates = [0, 1, 2, 3, 5, 0.5, 1.5]; function makeFiscalCall(path, data) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") try { xmlhttp.open("POST", baseAddress + path, false); } catch (E) { throw new Error("Невозможно установить связь с фискальным ядром"); } xmlhttp.setRequestHeader("Content-Type", "application/json;charset=utf-8") try { xmlhttp.send(JSON.stringify(data)); } catch (e) { throw new Error("Нет связи с фискальным ядром"); } if(xmlhttp.status != 200) { throw new Error("Нет связи с фискальным ядром, ошибка " + xmlhttp.status); } response = JSON.parse(xmlhttp.responseText); if (response.status != 0) { throw new Error(response.errorMessage); } return response; } function init() { frontol.addEventListener("closeDocument", "callReceipt", true); frontol.addEventListener("addPayment", "Odengi", true); frontol.addEventListener("addPosition", "proverkaOpt", false); frontol.addEventListener("changePosition", "proverkaOpt", false); //frontol.addEventListener("stornoPayment", "afterStornoPayment", false); } function callReceipt() { if (frontol.currentDocument.type.operation == 1) { if (frontol.actions.showMessage("Возврат документа" + "\r\Номер ФД чека-основания:" + frontol.currentDocument.baseDocument.userValues.get("_1063")+ "\r\nНомер ФМ чека-основания:" + frontol.currentDocument.baseDocument.userValues.get("_1064") + "\r\n\r\nВыполнить возврат?", Button.OkCancel + Icon.Exclamation ) == DialogResult.Cancel) { frontol.actions.cancel(); } } try { if (makeFiscalCall("shifts/getDayState/", {}).dayState != 1) { result = makeFiscalCall("shifts/openDay/", {"cashierName": frontol.currentUser.text}); } params = {}; if (frontol.currentDocument.type.operation == 0) { params.recType = 1; } if (frontol.currentDocument.type.operation == 1) { params.sourceFMNumber = frontol.currentDocument.baseDocument.userValues.get("_1064"); params.sourceFDNumber = frontol.currentDocument.baseDocument.userValues.get("_1063"); params.recType = 2; } var goods = []; var payItems = []; var i = 0; var resetNsp = false; for (frontol.currentDocument.payment.index = 1; frontol.currentDocument.payment.index <= frontol.currentDocument.payment.count; frontol.currentDocument.payment.index++) { var found = false; var payType = 0; if (frontol.currentDocument.payment.type.code != 1) { payType = 1; resetNsp = true; } for (j = 0; j < payItems.length; j++) { if (payItems[j].payType == payType) { found = true; payItems[j].total = payItems[j].total + Math.ceil(frontol.currentDocument.payment.sumInBaseCurrency * 100); } } if (!found) { payItems[i] = {"payType": payType, "total": Math.ceil(frontol.currentDocument.payment.sumInBaseCurrency * 100)}; i++; } } for (j = 0; j < payItems.length; j++) { payItems[j].total = payItems[j].total / 100; } i = 0; for (frontol.currentDocument.position.index = 1; frontol.currentDocument.position.index <= frontol.currentDocument.position.count; frontol.currentDocument.position.index++) { if (frontol.currentDocument.position.storno == 0) { goods[i] = { "count": frontol.currentDocument.position.quantity, "price": frontol.currentDocument.position.price, "itemName": frontol.currentDocument.position.ware.name, "article": frontol.currentDocument.position.ware.mark, "calcType": calcType, "total": frontol.currentDocument.position.sumWithDiscs }; for (frontol.currentDocument.position.tax.index = 1; frontol.currentDocument.position.tax.index <= frontol.currentDocument.position.tax.count; frontol.currentDocument.position.tax.index++) { if (frontol.currentDocument.position.tax.taxRateText.indexOf("НДС") >= 0) { goods[i].vatNum = getVatNum(frontol.currentDocument.position.tax.taxRateValue); } else { // if (resetNsp) //{ //goods[i].stNum = 0; //} //else //{ goods[i].stNum = 1;//getStNum(frontol.currentDocument.position.tax.taxRateValue); //} } } i++; } } params.goods = goods; params.payItems = payItems; //--------------АТОЛ открыть ящик ---------------------- fptr = new ActiveXObject('AddIn.Fptr10'); fptr.setSingleSetting(fptr.LIBFPTR_SETTING_MODEL, fptr.LIBFPTR_MODEL_ATOL_AUTO); fptr.setSingleSetting(fptr.LIBFPTR_SETTING_PORT, fptr.LIBFPTR_PORT_USB); fptr.setSingleSetting(fptr.LIBFPTR_SETTING_OFD_CHANNEL, fptr.LIBFPTR_OFD_CHANNEL_AUTO); fptr.applySingleSettings(); fptr.open(); fptr.openDrawer(); fptr.close(); fptr = 0; //--------------------- result = makeFiscalCall("bills/openAndCloseRec/", params); if (frontol.currentDocument.type.operation == 0) { frontol.currentDocument.userValues.set("_1063", result.fdNumber); frontol.currentDocument.userValues.set("_1064", result.fmNumber); } } catch (e) { frontol.actions.showError(e.message); } /////////// for ( frontol.currentDocument.payment.index = 1; frontol.currentDocument.payment.index <= frontol.currentDocument.payment.count; frontol.currentDocument.payment.index++ ) var typepay= frontol.currentDocument.payment.type.code; frontol.actions.showMessage(typepay); if (typepay == 4) { try { makeFiscalCall("commons/printLastDocument/", {}); } catch (e) { frontol.actions.showError (e.message); } } } function getVatNum(rate) { result = 0; for(i=0; i < vatRates.length; i++) { if (vatRates[i] == rate) { result = i; } } return result; } function getStNum(rate) { result = 0; for(i=0; i < stRates.length; i++) { if (stRates[i] == rate) { result = i; } } return result; } function reportX() { try { frontol.actions.showError (e.message); makeFiscalCall("shifts/printXReport/", {}); } catch (e) { frontol.actions.showError (e.message); } } function reportZ () { try { makeFiscalCall("shifts/closeDay/", {"cashierName": frontol.currentUser.text}); } catch (e) { frontol.actions.showError (e.message); } } //wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww function vvodnomera() { inputText = frontol.actions.inputString("Введите номер машины!","",100,0) try { frontol.currentDocument.userValues.set("number",inputText); } catch(e) { } } /////////Оденьги function Odengi(Payment) { if (Payment.type.code == 4) { // var sum = ( frontol.currentDocument.sumWithDiscs/1.13*0.01); // var allsum = (frontol.currentDocument.sumWithDiscs -sum).toFixed(2); var allsum = (frontol.currentDocument.sumWithDiscs ).toFixed(2); if (frontol.actions.showMessage("Оплата через О! Деньги состовляет " +allsum + " сом",Button.OkCancel, Icon.Information ) ==DialogResult.Cancel) { frontol.actions.cancel(); cancel(); } token = "5442855099:AAHHVzDluRYfPOeByg4cr6mtOTp2GZFl7GQ"; // полученный токен ID = "468378164"; // req = new ActiveXObject('Microsoft.XMLHTTP'); test = new ActiveXObject('Microsoft.XMLHTTP'); var currentDateTime = new Date(); var currentTime = currentDateTime.getTime(); var passw = '@9@UW#O|2S!Y&2X'; var order_id= frontol.currentDocument.number; var sums =(allsum *100).toFixed() ; var sum =parseInt(sums) ; var time =String(currentTime) ; var order_idd = String(order_id); var passww = String(passw); var json = {"cmd":"createInvoice","version":1005,"sid":"6134805825","mktime":time,"lang":"ru","data":{"order_id":order_idd,"desc":"Шекер, Айни","amount":sum,"currency":"KGS","test":0,"transtype":null,"long_term":0,"user_to":null,"date_life":null,"date_start_push":null,"count_push":null,"send_push":1,"send_sms":1,"result_url":null,"success_url":null,"fail_url":null,"fields_other":""}} ; var test = JSON.stringify(json); var finalData = test.replace(/\\/g, ""); var hash = CryptoJS.HmacMD5(finalData, passww).toString(); xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); req = new ActiveXObject('Microsoft.XMLHTTP'); xmlhttp.open("POST",'https://api.dengi.kg/api/json/json.php'); // переменные: адрес, пользователь, пароль xmlhttp.setRequestHeader('Content-type', 'application/json'); var obj = {"cmd":"createInvoice","version":1005,"sid":"6134805825","mktime":time,"lang":"ru","data":{"order_id":order_idd,"desc":"Шекер, Айни","amount":sum,"currency":"KGS","test":0,"transtype":null,"long_term":0,"user_to":null,"date_life":null,"date_start_push":null,"count_push":null,"send_push":1,"send_sms":1,"result_url":null,"success_url":null,"fail_url":null,"fields_other":""},"hash":hash} var jsons = JSON.stringify(obj); req.open("POST", "https://api.telegram.org/bot" + token + "/sendMessage?chat_id=" + ID + "&text=" + encodeURI(jsons), false); req.send(null); ///frontol.actions.showMessage(json); try { xmlhttp.send(jsons); //переменная - текст запроса } catch (e) { frontol.actions.showMessage("ошибка",e); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { var obj= JSON.parse(xmlhttp.responseText) var obj2=obj.data.emv_qr; invoice_id=obj.data.invoice_id; var finalData = obj2.replace(/\\/g, ""); var image = String(finalData); test = new ActiveXObject('Microsoft.XMLHTTP'); test.open("POST", "https://api.telegram.org/bot" + token + "/sendMessage?chat_id=" + ID + "&text=" +encodeURI(finalData), false); test.send(null); var WShell = new ActiveXObject("WScript.Shell"); var i = 0; WShell.Run ("msedge.exe "+ image+ " --start-fullscreen ", 6, false); var i = "processing"; do { WShell.AppActivate("Edge"); if( frontol.actions.showMessage("Ожидание оплаты через О!Деньги",Button.OkCancel,5)==DialogResult.Cancel) { WShell.Run ("taskkill /f /im msedge.exe") ; /////отмена неоплаченного платежа var currentDateTime = new Date(); var currentTime = currentDateTime.getTime(); var order_id= frontol.currentDocument.number; var time =String(currentTime) ; var json = {"cmd":"invoiceCancel","version":1005,"sid":"6134805825","mktime":time,"lang":"ru","data":{"invoice_id":invoice_id}} ; var test = JSON.stringify(json); var finalData = test.replace(/\\/g, ""); var hash = CryptoJS.HmacMD5(finalData, passww).toString(); xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); req = new ActiveXObject('Microsoft.XMLHTTP'); xmlhttp.open("POST",'https://api.dengi.kg/api/json/json.php'); // переменные: адрес, пользователь, пароль xmlhttp.setRequestHeader('Content-type', 'application/json'); var obj ={"cmd":"invoiceCancel","version":1005,"sid":"6134805825","mktime":time,"lang":"ru","data":{"invoice_id":invoice_id},"hash":hash} var jsons = JSON.stringify(obj); req = new ActiveXObject('Microsoft.XMLHTTP'); req.open("POST", "https://api.telegram.org/bot" + token + "/sendMessage?chat_id=" + ID + "&text=" + encodeURI(jsons), false); req.send(null); try { xmlhttp.send(jsons); } catch (e) { frontol.actions.showMessage("ошибка",e); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { var obj= JSON.parse(xmlhttp.responseText) var obj2=obj.data; var jsons = JSON.stringify(obj2); var das = String(jsons); test = new ActiveXObject('Microsoft.XMLHTTP'); test.open("POST", "https://api.telegram.org/bot" + token + "/sendMessage?chat_id=" + ID + "&text=" +encodeURI(das), false); test.send(null); var sts=obj.data.success; var jsonss = JSON.stringify(sts); if (sts == true) { if ( frontol.actions.showMessage("Оплата через О! Деньги Успешно отменена", Icon.Information)==DialogResult.Ok) { WShell.Run ("taskkill /f /im msedge.exe") ; WShell.SendKeys(del); WShell.SendKeys(esc); frontol.actions.cancel(); cancel(); } } // else { // frontol.actions.showMessage("**",xmlhttp.status); // } test = new ActiveXObject('Microsoft.XMLHTTP'); test.open("POST", "https://api.telegram.org/bot" + token + "/sendMessage?chat_id=" + ID + "&text=" +encodeURI(jsonss), false); test.send(null); } else { frontol.actions.showMessage("Нет соединения с сервером, проверьте интернет",xmlhttp.status); } } } ///// frontol.actions.cancel(); cancel(); break; } WShell.AppActivate("Edge"); var currentDateTime = new Date(); var currentTime = currentDateTime.getTime(); var order_id= frontol.currentDocument.number; var time =String(currentTime) ; var json = {"cmd":"statusPayment","version":1005,"sid":"6134805825","mktime":time,"lang":"ru","data":{"order_id":order_idd,"invoice_id":invoice_id,"mark":null}} ; var test = JSON.stringify(json); var finalData = test.replace(/\\/g, ""); var hash = CryptoJS.HmacMD5(finalData, passww).toString(); xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); req = new ActiveXObject('Microsoft.XMLHTTP'); xmlhttp.open("POST",'https://api.dengi.kg/api/json/json.php'); // переменные: адрес, пользователь, пароль xmlhttp.setRequestHeader('Content-type', 'application/json'); var obj ={"cmd":"statusPayment","version":1005,"sid":"6134805825","mktime":time,"lang":"ru","data":{"order_id":order_idd,"invoice_id":invoice_id,"mark":null},"hash":hash} var jsons = JSON.stringify(obj); req = new ActiveXObject('Microsoft.XMLHTTP'); req.open("POST", "https://api.telegram.org/bot" + token + "/sendMessage?chat_id=" + ID + "&text=" + encodeURI(jsons), false); req.send(null); try { xmlhttp.send(jsons); } catch (e) { frontol.actions.showMessage("ошибка",e); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { var obj= JSON.parse(xmlhttp.responseText) var obj2=obj.data; var jsons = JSON.stringify(obj2); var das = String(jsons); test = new ActiveXObject('Microsoft.XMLHTTP'); test.open("POST", "https://api.telegram.org/bot" + token + "/sendMessage?chat_id=" + ID + "&text=" +encodeURI(das), false); test.send(null); var sts=obj.data.payments[0].status; var jsonss = JSON.stringify(sts); if (sts == "approved") { if ( frontol.actions.showMessage("Оплата через О! Деньги Успешно прошла", Icon.Information)==DialogResult.Ok) { WShell.Run ("taskkill /f /im msedge.exe") ; WShell.SendKeys(ent); i="approved"; } } // else { // frontol.actions.showMessage("**",xmlhttp.status); // } test = new ActiveXObject('Microsoft.XMLHTTP'); test.open("POST", "https://api.telegram.org/bot" + token + "/sendMessage?chat_id=" + ID + "&text=" +encodeURI(jsonss), false); test.send(null); } else { frontol.actions.showMessage("Нет соединения с сервером, проверьте интернет",xmlhttp.status); } } } } while (i=="processing") } else { frontol.actions.showMessage("Нет соединения с сервером, проверьте интернет",xmlhttp.status); } } else { frontol.actions.showMessage("Нет соединения с сервером, проверьте интернет",xmlhttp.status); } } /////////Оденьги } } /////////Оденьги/////////Оденьги/////////Оденьги/////////Оденьги/////////Оденьги/////////Оденьги/////////Оденьги/////////Оденьги function afterStornoPayment(Payment) { if (frontol.currentDocument.type.name != "ВОЗВРАТ") { saveCounterToFile(Payment.type.code); if (Payment.type.code != 1) { frontol.currentDocument.userValues.set("uBankDiscount", "2") runMacros(); } } } function FuncAct() { if (frontol.currentDocument.type.name != "ВОЗВРАТ") { needCalc = frontol.currentDocument.userValues.get("uBankDiscount"); if (needCalc == 1) { receiptSum = 0; for (frontol.currentDocument.position.index = 1; frontol.currentDocument.position.index <= frontol.currentDocument.position.count; frontol.currentDocument.position.index++) { if (frontol.currentDocument.position.storno == 0) { if (frontol.currentDocument.position.ware.maxDiscount != 0) { if (frontol.currentDocument.position.price > 0){ frontol.currentDocument.position.setSpecialPrice(frontol.currentDocument.position.ware.price - (frontol.currentDocument.position.ware.price / 1.13 * 0.01), 1);} } else { if (frontol.currentDocument.position.price > 0){ frontol.currentDocument.position.setSpecialPrice(frontol.currentDocument.position.ware.price - (frontol.currentDocument.position.ware.price / 1.13 * 0.01), 0); } } receiptSum = receiptSum + frontol.currentDocument.position.sum; } } oplata = loadCounterFromFile(); frontol.currentDocument.addPayment(oplata, 0); //RO.RecalcAllDiscounts(); } if (needCalc == 2) { for (frontol.currentDocument.position.index = 1; frontol.currentDocument.position.index <= frontol.currentDocument.position.count; frontol.currentDocument.position.index++) { if (frontol.currentDocument.position.storno == 0) { if (frontol.currentDocument.position.ware.maxDiscount != 0) { if (frontol.currentDocument.position.price > 0){ frontol.currentDocument.position.setSpecialPrice(frontol.currentDocument.position.ware.price, 1);} } else { if (frontol.currentDocument.position.price > 0){ frontol.currentDocument.position.setSpecialPrice(rontol.currentDocument.position.ware.price, 0); } } } } goIntoPayment(); } } } function NoAction() {} function goIntoPayment() { if (frontol.currentDocument.type.name != "ВОЗВРАТ") { var WShell = new ActiveXObject("WScript.Shell"); WShell.SendKeys(keyPayment); } } function runMacros() { if (frontol.currentDocument.type.name != "ВОЗВРАТ") { var WShell = new ActiveXObject("WScript.Shell"); WShell.SendKeys(keyMacros); } } function loadCounterFromFile() { fso = new ActiveXObject("Scripting.FileSystemObject"); try { file = fso.OpenTextFile(FileNameCounter, 1, false); } catch (e) { return { value: 1 }; } while (!file.AtEndOfStream) { var line = file.ReadLine(); text = line; } obj = JSON.parse(text); return obj; } function saveCounterToFile(Obj) { var ForWriting = 2; var fso = new ActiveXObject("Scripting.FileSystemObject"); //jsontxt = fso.OpenTextFile(FileNameCounter, ForWriting, true); // UString = JSON.stringify(Obj); // jsontxt.Write(UString); //jsontxt.Close(); } /** **JSON **/ if (typeof JSON !== 'object') { JSON = {} }(function() { 'use strict'; var rx_one = /^[\],:{}\s]*$/, rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, rx_four = /(?:^|:|,)(?:\s*\[)+/g, rx_escapable = /[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; function f(n) { return n < 10 ? '0' + n : n } function this_value() { return this.valueOf() } var gap, indent, meta, rep; function quote(string) { rx_escapable.lastIndex = 0; return rx_escapable.test(string) ? '"' + string.replace(rx_escapable, function(a) { var c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4) }) + '"' : '"' + string + '"' } function str(key, holder) { var i, k, v, length, mind = gap, partial, value = holder[key]; if (value && typeof value === 'object' && typeof value.toJSON === 'function') { value = value.toJSON(key) } if (typeof rep === 'function') { value = rep.call(holder, key, value) } switch (typeof value) { case 'string': return quote(value); case 'number': return isFinite(value) ? String(value) : 'null'; case 'boolean': case 'null': return String(value); case 'object': if (!value) { return 'null' } gap += indent; partial = []; if (Object.prototype.toString.apply(value) === '[object Array]') { length = value.length; for (i = 0; i < length; i += 1) { partial[i] = str(i, value) || 'null' } v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']'; gap = mind; return v } if (rep && typeof rep === 'object') { length = rep.length; for (i = 0; i < length; i += 1) { if (typeof rep[i] === 'string') { k = rep[i]; v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v) } } } } else { for (k in value) { if (Object.prototype.hasOwnProperty.call(value, k)) { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v) } } } } v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}'; gap = mind; return v } } if (typeof JSON.stringify !== 'function') { meta = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }; JSON.stringify = function(value, replacer, space) { var i; gap = ''; indent = ''; if (typeof space === 'number') { for (i = 0; i < space; i += 1) { indent += ' ' } } else if (typeof space === 'string') { indent = space } rep = replacer; if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { throw new Error('JSON.stringify'); } return str('', { '': value }) } } if (typeof JSON.parse !== 'function') { JSON.parse = function(text, reviver) { var j; function walk(holder, key) { var k, v, value = holder[key]; if (value && typeof value === 'object') { for (k in value) { if (Object.prototype.hasOwnProperty.call(value, k)) { v = walk(value, k); if (v !== undefined) { value[k] = v } else { delete value[k] } } } } return reviver.call(holder, key, value) } text = String(text); rx_dangerous.lastIndex = 0; if (rx_dangerous.test(text)) { text = text.replace(rx_dangerous, function(a) { return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4) }) } if (rx_one.test(text.replace(rx_two, '@').replace(rx_three, ']').replace(rx_four, ''))) { j = eval('(' + text + ')'); return typeof reviver === 'function' ? walk({ '': j }, '') : j } throw new SyntaxError('JSON.parse'); } } }()); // WEEWEE WEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEEWEE function PriceOPT() { for (frontol.currentDocument.position.index = 1; frontol.currentDocument.position.index <= frontol.currentDocument.position.count; frontol.currentDocument.position.index++) { if (frontol.currentDocument.position.storno == 0) { //if (frontol.currentDocument.position.ware.maxDiscount != 0) { pricevalue = getDiscountFromDescription(frontol.currentDocument.position); // frontol.actions.showMessage("Клиент: " + frontol.currentDocument.position.ware.maxDiscount); try{ if (pricevalue != 0) { //если есть ограничение скидки if (frontol.currentDocument.position.ware.maxDiscount != 0) { frontol.currentDocument.position.setSpecialPrice(pricevalue,1); } else ///если нет ограничений скидки { frontol.currentDocument.position.setSpecialPrice(pricevalue,0); } } } catch(e) { } } } } function proverkaOpt() { if (frontol.currentDocument.type.code != 1) return; //реализация //if (frontol.currentDocument.client==0) return; //выбран покупатель for (frontol.currentDocument.position.index = 1; //перебираем позиции документа frontol.currentDocument.position.index <= frontol.currentDocument.position.count; frontol.currentDocument.position.index++) { if (frontol.currentDocument.position.storno == 0) { pricevalue = parseFloat(frontol.currentDocument.position.ware.price);//frontol.currentDocument.position.specialPrice.originalPrice(position); quantityOpt = parseInt(frontol.currentDocument.position.ware.GTD); //здесь у меня хранится количество от которого начинается опт PriceOptovka = parseFloat(frontol.currentDocument.position.ware.series); // в серии хранится оптовая цена quantity = frontol.currentDocument.position.quantity; if (quantityOpt!=0 && PriceOptovka!=0) { //если выполняется условия получения оптовой цены if (quantity>= quantityOpt) { frontol.currentDocument.position.setSpecialPrice(PriceOptovka,0); //то цена меняется на оптовую } else if (frontol.currentDocument.position.specialPrice != undefined) // frontol.currentDocument.position.setStorno=1; frontol.currentDocument.position.setSpecialPrice(pricevalue,0); } } } } function getDiscountFromDescription(currentPosition) { var flagDebug = 0; function isInteger(x) { return x % 1 === 0; } function isIsoDateTime(dateTime) { var resultDateTime = false; if( dateTime.search(/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}/) === -1 ) { if(flagDebug) frontol.actions.showMessage("Неверный формат даты!"); return false; } try { resultDateTime = new Date( dateTime.substr(0, 4), // year dateTime.substr(5, 2) - 1, // month dateTime.substr(8, 2), // day dateTime.substr(11, 2),// hours dateTime.substr(14, 2),// minutes dateTime.substr(17, 2) // seconds ); } catch (e) { if(flagDebug) frontol.actions.showMessage(dateTime + " не дата!"); return false; } if( isNaN(resultDateTime.getTime()) ) { if(flagDebug) frontol.actions.showMessage(dateTime + " не дата!"); return false; } return resultDateTime.getTime(); } function checkDiscountParam(index, value) { switch (index) { case 0: case 1: case 2: if( isNaN(value) ) { if(flagDebug) frontol.actions.showMessage("Некорректное значение '" + value.toString() + "'параметра " + (index + 1) + " скидки, должно быть число!"); // return false; } if( !isInteger( arrDescription[i] ) ) { if(flagDebug) frontol.actions.showMessage("Некорректное значение ''" + value + "'' параметра " + (index + 1) + "скидки, должно быть целое число!"); // return false; } if( Number(value) < 0) { if(flagDebug) frontol.actions.showMessage("Некорректное значение '" + value + "' параметра " + (index + 1) + " скидки, должно быть положительное число!"); // return false; } break; case 3: case 4: if( !isIsoDateTime(value) ) { if(flagDebug) frontol.actions.showMessage("Некорректное значение '" + value + "' параметра " + (index + 1) + " скидки, должна быть дата в ISO-формате!"); // return false; } break; } switch (index) { case 0: if( value <= 0 ) { if(flagDebug) frontol.actions.showMessage("Некорректное значение '" + value + "' параметра " + (index + 1) + " 'количество', должно быть больше нуля!"); // return false; } break; case 1: if( value > 100 ) { // if(flagDebug) frontol.actions.showMessage("Некорректное значение '" + value + "' параметра " + (index + 1) + " 'процент скидки', должно быть от 1 до 100!"); // return false; } break; } return true; } if(flagDebug) frontol.actions.showMessage("Функция расчета скидки по кратности кол-ва позиции запущена и работает!"); if (currentPosition.ware.description) { var arrDescription = currentPosition.ware.description.split("&"); if (arrDescription.length != 5 ) { if(flagDebug) frontol.actions.showMessage("Некорректное описание параметров скидки"); return 0; } for (var i = 0; i < arrDescription.length; i++) { if( !checkDiscountParam(i, arrDescription[i]) ) return 0; } var arrDiscount = { Frequency: arrDescription[0], Discount: arrDescription[1], Maximum: arrDescription[2], startDate: arrDescription[3], endDate: arrDescription[4] }; var currentDateTime = new Date(); var currentTime = currentDateTime.getTime(); if(currentTime < isIsoDateTime(arrDiscount.startDate) || currentTime > isIsoDateTime(arrDiscount.endDate)) { // текущая дата не попадает в период действия акции return 0; } var countForDiscount = currentPosition.quantity; if( currentPosition.quantity > arrDiscount.Maximum && arrDiscount.Maximum > 0) countForDiscount = arrDiscount.Maximum; var countWithDiscount = (countForDiscount - countForDiscount % arrDiscount.Frequency) / arrDiscount.Frequency; var finalDiscount = Number( (countWithDiscount * arrDiscount.Discount) / currentPosition.quantity); if(flagDebug) frontol.actions.showMessage( "Общее кол-во товара: " + currentPosition.quantity + "\n" + "Скидка " + arrDiscount.Discount + "% на каждую " + arrDiscount.Frequency + " единицу товара\n" + "Акция действует с " + arrDiscount.startDate + " по " + arrDiscount.endDate + "\n" + "Кол-во единиц товара, для которого возможна скидка: " + countForDiscount + "\n" + "Кол-во единиц товара со скидкой: " + countWithDiscount + "\n" + "Итоговая скидка: " + finalDiscount + "%\n" ); //устанавливаем наше условие if (countForDiscount >= arrDiscount.Frequency) { return arrDiscount.Discount; } else { return currentPosition.ware.price; } ////////////////////// } else { if(flagDebug) frontol.actions.showMessage("Отсутствует описание товара"); } return 0; }
Editor is loading...