Best JavaScript code snippet using fast-check-monorepo
javascript.js
Source:javascript.js
1window.onload = function () {2 clickScreen();3};4//----------------------input from keyboard----//5window.addEventListener('keydown', function (e) {6 var key = e.key;7 var keyboardNumbers = "0123456789/*-+";8 var equal = "Enter";9 if (keyboardNumbers.includes(key)) {10 screen(key);11 } else if (key == equal) {12 document.getElementById("equal").click();13 } else if (key == ".") {14 document.getElementById("dot").click();15 } else if (key == "Escape") {16 document.getElementById("C").click();17 } else if (key == "Backspace") {18 document.getElementById("backspace").click();19 }20});21//----------------------input from screen----//22function clickScreen() {23 var button = document.querySelectorAll("#bottom span");24 var expression = document.getElementById("expression");25 var res = document.getElementById("res");26 var aux = document.getElementById("aux");27 var mc = document.getElementById("mc");28 var mr = document.getElementById("mr");29 var mplus = document.getElementById("mplus");30 var mminus = document.getElementById("mminus");31 var mstore = document.getElementById("ms");32 var m = document.getElementById("m");33 var mwindow = document.getElementById("m");34 for (let i = 0; i < button.length; i++) {35 var keyboard = button[i];36 keyboard.onclick = function () {37 var number = this.dataset["number"];38 screen(number);39 }40 }41}42function screen(number) {43 var remove = document.getElementById("backspace");44 var c = document.getElementById("C");45 var ce = document.getElementById("CE");46 var equal = document.getElementById("equal");47 var dot = document.getElementById("dot");48 var neg = document.getElementById("neg");49 var inverseMult = document.getElementById("inverseMult");50 var pow = document.getElementById("pow");51 var sqrt = document.getElementById("sqrt");52 var porcentage = document.getElementById("porcentage");53 var oldVal = aux.innerHTML;54 /* Sobre a variavel oldVal55 0 - para quando a última entrada é um numero;56 1 - para a última entrada sendo um sÃmbolo de operador;57 2 - para última entrada o botão equal;58 3 - sendo uma das funções;59 4 - para a função de porcentagem.60 */61 var expreVal = expression.innerHTML;62 var resVal = cleanComma(verifyScreen(res.innerHTML));63 var symbol = { "+": "+", "-": "-", "*": "*", "/": "/" };64 var lastSymbol = expreVal.substring(expreVal.length - 1, expreVal.length);65 //--------------------Add number on screen--------------------------//66 if (parseInt(number) > -1 && parseInt(number) < 10) {67 if (oldVal == "2" || oldVal == "4") {68 aux.innerHTML = "1";69 expression.innerHTML = "";70 expreVal = expression.innerHTML;71 oldVal = aux.innerHTML;72 }73 if (resVal === "0" || oldVal === "1" || oldVal === "3") {74 res.innerHTML = number;75 aux.innerHTML = "0";76 } else if (resVal === "-0") {77 res.innerHTML = "-" + number;78 aux.innerHTML = "0";79 } else {80 res.innerHTML = verifyScreen(resVal + number);81 }82 }83 oldVal = aux.innerHTML;84 //--------------------Add expression on screen--------------------------//85 if (number in symbol) {86 let temp;87 if (oldVal == "2") {88 aux.innerHTML = "1";89 expression.innerHTML = "";90 oldVal = aux.innerHTML;91 }92 expreVal = expression.innerHTML;93 if (lastSymbol in symbol && oldVal == "1") {94 expreVal = expreVal.substring(0, expreVal.length - 1);95 temp = lastIsDot(expreVal);96 temp = temp + symbol[number];97 oldVal = "0";98 } else if (oldVal == "3") {99 temp = lastIsDot(expreVal + resVal);100 temp = temp + symbol[number];101 aux.innerHTML = "1";102 } else if (oldVal == "4") {103 expreVal += number;104 temp = expreVal;105 } else {106 temp = lastIsDot(expreVal + resVal);107 temp = temp + symbol[number];108 }109 expression.innerHTML = temp;110 aux.innerHTML = "1";111 }112 //--------Current values ââin variables------------//113 resVal = getRes();114 expreVal = expression.innerHTML;115 function getRes() {116 return cleanComma(res.innerHTML);117 }118 //--------------------Remove number--------------------------//119 remove.onclick = function () {120 let temp = getRes();121 if (temp.length > 1) {122 temp = temp.slice(0, -1);123 res.innerHTML = verifyScreen(temp);124 } else {125 res.innerHTML = 0;126 }127 }128 //--------------------Clean screen number and expression--------------------------//129 c.onclick = function () {130 res.innerHTML = 0;131 expression.innerHTML = "";132 res.style.fontSize = "33pt";133 }134 //--------------------Clean screen number only--------------------------//135 ce.onclick = function () {136 res.innerHTML = 0;137 res.style.fontSize = "33pt";138 }139 //--------------------Does the calculations and show on the expression screen--------------------------//140 equal.onclick = function () {141 resVal = cleanComma(verifyScreen(res.innerHTML));142 var result;143 var tempExpre144 oldVal = aux.innerHTML;145 lastSymbol = expreVal.substring(expreVal.length - 1, expreVal.length);146 if (oldVal == "2") {147 tempExpre = expression.innerHTML;148 var index = tempExpre.lastIndexOf(lastSymbol);149 if (index !== -1) {150 if (tempExpre[index - 1] == "e" || tempExpre[index - 1] == "(") {151 let tempExpreAux = tempExpre.substring(0, index);152 var index = tempExpreAux.lastIndexOf(lastSymbol);153 }154 tempExpre = tempExpre.substring(index, tempExpre.length - 2);155 }156 tempExpre = resVal + tempExpre;157 if (tempExpre.includes("=")) {158 aux.innerHTML = "2";159 return;160 }161 } else if (oldVal == "4") {162 tempExpre = expression.innerHTML;163 } else {164 var firstSymbol = resVal.toString().substring(0, 1);165 if (firstSymbol == "-") {166 resVal = "(" + resVal + ")";167 }168 expreVal = expression.innerHTML;169 tempExpre = expreVal + resVal;170 }171 result = operation(tempExpre).toString();172 var firstSymbol = result.substring(0, 1);173 var length = firstSymbol == "-" ? result.length - 1 : result.length;174 if (length > 14) {175 expression.innerHTML = "";176 res.innerHTML = "Overflow";177 } else {178 res.innerHTML = verifyScreen(result);179 expression.innerHTML = lastIsDot(tempExpre) + " =";180 aux.innerHTML = "2";181 }182 }183 function operation(expre) {184 let result = eval(expre).toString();185 let length = getBigger(getRes(), result);186 if (length > 12) {187 result = Number(result).toPrecision(8);188 }189 result = removeZerosAtRight(result);190 return result;191 }192 dot.onclick = function () {193 resVal = res.innerHTML;194 lastSymbol = expreVal.substring(expreVal.length - 1, expreVal.length);195 console.log(resVal);196 if (lastSymbol in symbol && resVal == "0") {197 res.innerHTML = "0";198 resVal = getRes();199 }200 var indexDot = resVal.indexOf(".");201 if (indexDot !== -1) {202 return;203 }204 resVal = resVal + ".";205 res.innerHTML = verifyScreen(resVal);206 }207 neg.onclick = function () {208 resVal = res.innerHTML;209 var indexNeg = resVal.indexOf("-");210 if (indexNeg === 0) {211 res.innerHTML = verifyScreen(resVal.substring(1, resVal.length));212 } else if (indexNeg === -1) {213 res.innerHTML = verifyScreen("-" + resVal);214 }215 }216 //--------------------Functions--------------------------//217 inverseMult.onclick = function () {218 let value = res.innerHTML;219 let result = 0;220 verifyEqual();221 result = 1 / parseFloat(value);222 result = operation(result);223 result = result.toString();224 res.innerHTML = verifyScreen(result);225 aux.innerHTML = "1";226 if (value === "0") {227 res.innerHTML = "Cannot divide by zero";228 res.style.fontSize = "20pt";229 }230 aux.innerHTML = "3";231 }232 pow.onclick = function () {233 verifyEqual();234 let value = getRes();235 let result = Math.pow(value, 2);236 result = operation(result);237 res.innerHTML = verifyScreen(result);238 aux.innerHTML = "3";239 }240 sqrt.onclick = function () {241 verifyEqual();242 let value = getRes();243 let result = Math.sqrt(value);244 result = operation(result);245 result = result.toString();246 res.innerHTML = verifyScreen(result);247 aux.innerHTML = "3";248 }249 function verifyEqual() {250 expreVal = expression.innerHTML;251 lastSymbol = expreVal.substring(expreVal.length - 1, expreVal.length);252 if (lastSymbol == "=") {253 expression.innerHTML = "";254 }255 }256 porcentage.onclick = function () {257 let valuePrcentg = verifyScreen(res.innerHTML);258 if (valuePrcentg == "0") {259 res.innerHTML = "0";260 return;261 }262 if (expreVal == "") {263 res.innerHTML = "0";264 } else {265 let valueAmount = eval(expreVal.substring(0, expreVal.length - 1));266 valuePrcentg = eval(valueAmount + "*" + valuePrcentg + "/100");267 valuePrcentg = operation(valuePrcentg);268 expression.innerHTML = expreVal + valuePrcentg;269 res.innerHTML = verifyScreen(valuePrcentg);270 }271 aux.innerHTML = "4";272 }273 //---------Memory functions----------------------//274 m.onclick = function () {275 mwindow.style.display = mwindow.style.display === 'block' ? 'none' : 'block';276 textSize();277 }278 ms.onclick = function () {279 if (res.innerHTML.includes("er")) {280 return281 } else {282 mwindow.innerHTML = res.innerHTML;283 }284 aux.innerHTML = "3";285 }286 mr.onclick = function () {287 res.innerHTML = verifyScreen(verifyIfIsText(mwindow.innerHTML));288 aux.innerHTML = "3";289 }290 mc.onclick = function () {291 mwindow.innerHTML = "There's nothing saved in your memory.";292 textSize();293 aux.innerHTML = "3";294 }295 mplus.onclick = function () {296 if (res.innerHTML.includes("er")) {297 return298 } else {299 let result = (Number(getMwindow()) + Number(getRes()));300 setMwindow(result);301 }302 }303 mminus.onclick = function () {304 if (res.innerHTML.includes("er")) {305 return306 } else {307 let result = (Number(getMwindow()) - Number(getRes()));308 setMwindow(result);309 }310 }311 function getMwindow() {312 return cleanComma(verifyIfIsText(mwindow.innerHTML));313 }314 function setMwindow(value) {315 mwindow.innerHTML = verifyMemoryScreen(value);316 textSize();317 aux.innerHTML = "3";318 }319 function textSize() {320 mwindow.style.fontSize = mwindow.innerHTML.includes('er') ? '11pt' : '20pt';321 }322 function verifyIfIsText(value) {323 value = value.toString();324 return value.includes("er") ? "0" : value;325 }326 function verifyMemoryScreen(result) {327 result = result.toString();328 let firstSymbol = result.substring(0, 1);329 let negative = firstSymbol == "-" ? true : false;330 if (negative) {331 result = mwindow.innerHTML.includes('There') ? getRes() : formatMemory(result.substring(1, result.length));332 return "-" + result;333 } else {334 return mwindow.innerHTML.includes('There') ? getRes() : formatMemory(result);335 }336 }337 function formatMemory(value) {338 let length = getBigger(getRes(), getMwindow());339 value = Number(value).toPrecision(length);340 value = removeZerosAtRight(value);341 return value = addComma(value.toString());342 }343 function getBigger(value1, value2) {344 let length1 = value1.length + 1;345 let length2 = value2.length + 1;346 let value = length1 > length2 ? length1 : length2;347 return value > 13 ? 13 : value;348 }349 function removeZerosAtRight(result) {350 let cond = result.includes(".") ? true : false;351 let indexOfe = result.indexOf("e");352 let resultAux;353 if (indexOfe !== -1) {354 resultAux = result.split("e");355 result = resultAux[0];356 }357 while (cond == true) {358 let lastSymbol = result.substring(result.length - 1, result.length);359 if (lastSymbol == "0") {360 result = result.substring(0, result.length - 1);361 cond = true;362 } else if (lastSymbol == ".") {363 result = result.substring(0, result.length - 1);364 cond = false;365 } else {366 cond = false;367 }368 }369 if (indexOfe !== -1) {370 let resultAux2 = result + "e" + resultAux[1].toString();371 return resultAux2.includes(".") ? result + "e" + resultAux[1].toString() : result + ".e" + resultAux[1].toString(); //2.e+11 and not 2e+11372 } else {373 return result;374 }375 }376}377//-----Verifications on screen value, length, dot, comma---//378function cleanComma(value) {379 var index = value.indexOf(",");380 while (index != -1) {381 index = value.indexOf(",");382 value = value.substring(0, index) + value.substring(index + 1, value.length);383 }384 return value;385}386function addComma(value) {387 value += '';388 var valueParts = value.split('.');389 var firstPart = valueParts[0];390 var secondPart = valueParts.length > 1 ? '.' + valueParts[1] : '';391 var rgx = /(\d+)(\d{3})/;392 while (rgx.test(firstPart)) {393 firstPart = firstPart.replace(rgx, '$1' + ',' + '$2');394 }395 return firstPart + secondPart;396}397function verifyScreen(valueScreen) {398 valueScreen = valueScreen.toString();399 var firstSymbol = valueScreen.substring(0, 1);400 var isNegative = false;401 if (valueScreen == "NaN" || valueScreen.includes("O") || valueScreen.includes("nn")) {402 res.innerHTML = "0";403 return "0";404 }405 if (firstSymbol === "-") {406 isNegative = true;407 valueScreen = valueScreen.substring(1, valueScreen.length);408 }409 valueScreen = cleanComma(valueScreen);410 valueScreen = addComma(valueScreen);411 if (fontSize(valueScreen.length) == 0) {412 if (isNegative == true) {413 valueScreen = "-" + valueScreen;414 }415 return valueScreen;416 } else {417 return verifyScreen(valueScreen.substring(0, valueScreen.length - 1));418 }419}420function fontSize(length) {421 if (length < 11) {422 res.style.fontSize = "33pt";423 } else if (length > 10 && length < 12) {424 res.style.fontSize = "28pt";425 } else if (length > 11 && length < 15) {426 res.style.fontSize = "24pt";427 } else if (length > 14) {428 res.style.fontSize = "24pt";429 return 1;430 }431 return 0;432}433function lastIsDot(valueExpre) {434 let lastSymbol = valueExpre.substring(valueExpre.length - 1, valueExpre.length);435 if (lastSymbol == ".") {436 valueExpre = valueExpre.substring(0, valueExpre.length - 1);437 }438 return valueExpre;...
QueryPrinter.controller.js
Source:QueryPrinter.controller.js
1sap.ui.define([2 "./BaseController",3 "sap/ui/model/json/JSONModel",4 "sap/ui/core/routing/History",5 "../model/formatter",6 "sap/m/Dialog",7 "sap/ui/core/Fragment",8 "sap/ui/model/Filter",9 "sap/ui/model/FilterOperator"10], function (BaseController, JSONModel, History, formatter, Dialog, Fragment, Filter, FilterOperator) {11 "use strict"12 return BaseController.extend("GASS.zcashqmovements.controller.QueryPrinter", {13 formatter: formatter,14 onInit : function () {15 // Model used to manipulate control states. The chosen values make sure,16 // detail page shows busy indication immediately so there is no break in17 // between the busy indication for loading the view's meta data18 var oViewModel = new JSONModel({19 busy : true,20 delay : 021 });22 this.getRouter().getRoute("queryprinter").attachPatternMatched(this._onObjectMatched, this);23 },24 /**25 * Event handler for navigating back.26 * It there is a history entry we go one step back in the browser history27 * If not, it will replace the current entry of the browser history with the worklist route.28 * @public29 */30 onNavBack : function() {31 var sPreviousHash = History.getInstance().getPreviousHash();32 if (sPreviousHash !== undefined && sPreviousHash !== "") {33 // eslint-disable-next-line sap-no-history-manipulation34 history.go(-1);35 } else {36 37 this.getRouter().navTo("object", {38 objectId: new Date().getMilliseconds().toString() + this.create_UUID().toString() + new Date().getMilliseconds().toString()39 }, true);40 }41 },42 /* =========================================================== */43 /* internal methods */44 /* =========================================================== */45 /**46 * Binds the view to the object path.47 * @function48 * @param {sap.ui.base.Event} oEvent pattern match event in route 'object'49 * @private50 */51 _onObjectMatched : function (oEvent) {52 this.loadQuery();53 },54 _bindView : function (sObjectPath) {55 //var oViewModel = this.getModel("objectView");56 },57 loadQuery: async function(){58 var that = this;59 var userdata = sessionStorage.getItem("UserItems") ? JSON.parse(sessionStorage.getItem("UserItems")) : [];60 var url = "/sap/opu/odata/sap/Z_CASHBOX_SRV/";61 var oModel = new sap.ui.model.odata.v2.ODataModel(url, {62 json: true,63 loadMetadataAsync: true64 });65 var entity="ImpresionQuerySet"66 var filters=[];67 filters.push({name:"Segmento", values:[userdata.Segmento]});68 filters.push({name:"Sociedad", values:[userdata.Sociedad]});69 filters.push({name:"Caja", values:[userdata.Caja]});70 filters.push({name:"Usuario", values:[userdata.Usuario]});71 filters.push({name:"Fecha", values:[userdata.Fecha.replace(/-/g,"")]});72 var vexpand = "NavQueryMovs"73 var data = await this._GEToDataV2ajaxComp(oModel,entity, filters, vexpand,"")74 if(data.d.results[0].NavQueryMovs.results.length > 0){75 76 for (var i=0; i < data.d.results[0].NavQueryMovs.results.length; i++){77 var year = data.d.results[0].NavQueryMovs.results[i].FechaContabillizacion.substring(0,4);78 var month = data.d.results[0].NavQueryMovs.results[i].FechaContabillizacion.substring(4,6);79 var day = data.d.results[0].NavQueryMovs.results[i].FechaContabillizacion.substring(6,8);80 var fecConta = day +"-"+ month +"-" + year;81 data.d.results[0].NavQueryMovs.results[i].FechaConta = fecConta;82 year = data.d.results[0].NavQueryMovs.results[i].FechaDocumento.substring(0,4);83 month = data.d.results[0].NavQueryMovs.results[i].FechaDocumento.substring(4,6);84 day = data.d.results[0].NavQueryMovs.results[i].FechaDocumento.substring(6,8);85 var fecDoc = day +"-"+ month +"-" + year;86 var HH = data.d.results[0].NavQueryMovs.results[i].HoraDocumento.substring(0,2);87 var mm = data.d.results[0].NavQueryMovs.results[i].HoraDocumento.substring(2,4);88 var ss = data.d.results[0].NavQueryMovs.results[i].HoraDocumento.substring(4,6);89 var horaDoc = HH +":"+mm+":"+ss;90 data.d.results[0].NavQueryMovs.results[i].HoraDocumento = horaDoc;91 var indexNeg = data.d.results[0].NavQueryMovs.results[i].Importe.indexOf("-")92 if(indexNeg > 0) {93 data.d.results[0].NavQueryMovs.results[i].Importe = (-1 * (data.d.results[0].NavQueryMovs.results[i].Importe.replace("-",""))).toString();94 }95 if(data.d.results[0].NavQueryMovs.results[i].Operacion === "CHECK IN"){96 data.d.results[0].NavQueryMovs.results[i].Importe = "0"97 }98 }99 100 var newData = this.generatePrintQuery(data.d.results[0].NavQueryMovs.results);101 var movModel = new sap.ui.model.json.JSONModel(newData);102 this.getView().setModel(movModel,"MovimientosModel");103 }104 },105 _onSearchFieldLiveChange: function (oEvent) {106 var sQuery = oEvent.getParameter("query");107 this._oGlobalFilter = null;108 if (sQuery) {109 this._oGlobalFilter = new Filter([110 new Filter("CajeroSecuencia", FilterOperator.Contains, sQuery),111 new Filter("Operacion", FilterOperator.Contains, sQuery),112 new Filter("Cliente", FilterOperator.Contains, sQuery),113 new Filter("CuentaBancaria", FilterOperator.Contains, sQuery),114 new Filter("Documento", FilterOperator.Contains, sQuery),115 new Filter("Importe", FilterOperator.Contains, sQuery),116 new Filter("ImporteMoneda", FilterOperator.Contains, sQuery),117 new Filter("Pagador", FilterOperator.Contains, sQuery),118 new Filter("ReferenciaPago", FilterOperator.Contains, sQuery),119 new Filter("ViaPago", FilterOperator.Contains, sQuery),120 new Filter("BancoCajero", FilterOperator.Contains, sQuery),121 new Filter("ClaveAutorizacion", FilterOperator.Contains, sQuery),122 new Filter("FechaDoc", FilterOperator.Contains, sQuery),123 new Filter("FechaConta", FilterOperator.Contains, sQuery)124 ], false);125 }126 this._filter();127 },128 _filter: function () {129 var oFilter = null;130 if (this._oGlobalFilter) {131 oFilter = new sap.ui.model.Filter([this._oGlobalFilter], true);132 } else {133 oFilter = this._oGlobalFilter;134 }135 this.byId("tblMovimientos").getBinding("rows").filter(oFilter, "Application");136 },137 downloadExcel: async function () {138 sap.ui.core.BusyIndicator.show();139 var that = this;140 var userdata = sessionStorage.getItem("UserItems") ? JSON.parse(sessionStorage.getItem("UserItems")) : [];141 var url = "/sap/opu/odata/sap/Z_CASHBOX_SRV/";142 var oModel = new sap.ui.model.odata.v2.ODataModel(url, {143 json: true,144 loadMetadataAsync: true145 });146 var entity="ImpresionQuerySet"147 var filters=[];148 filters.push({name:"Segmento", values:[userdata.Segmento]});149 filters.push({name:"Sociedad", values:[userdata.Sociedad]});150 filters.push({name:"Caja", values:[userdata.Caja]});151 filters.push({name:"Usuario", values:[userdata.Usuario]});152 filters.push({name:"Fecha", values:[userdata.Fecha.replace(/-/g,"")]});153 var vexpand = "NavQueryMovs"154 var data = await this._GEToDataV2ajaxComp(oModel,entity, filters, vexpand,"")155 if(data.d.results[0].NavQueryMovs.results.length > 0){156 157 for (var i=0; i < data.d.results[0].NavQueryMovs.results.length; i++){158 var year = data.d.results[0].NavQueryMovs.results[i].FechaContabillizacion.substring(0,4);159 var month = data.d.results[0].NavQueryMovs.results[i].FechaContabillizacion.substring(4,6);160 var day = data.d.results[0].NavQueryMovs.results[i].FechaContabillizacion.substring(6,8);161 var fecConta = day +"-"+ month +"-" + year;162 data.d.results[0].NavQueryMovs.results[i].FechaConta = fecConta;163 year = data.d.results[0].NavQueryMovs.results[i].FechaDocumento.substring(0,4);164 month = data.d.results[0].NavQueryMovs.results[i].FechaDocumento.substring(4,6);165 day = data.d.results[0].NavQueryMovs.results[i].FechaDocumento.substring(6,8);166 var fecDoc = day +"-"+ month +"-" + year;167 data.d.results[0].NavQueryMovs.results[i].FechaDoc = fecDoc;168 var HH = data.d.results[0].NavQueryMovs.results[i].HoraDocumento.substring(0,2);169 var mm = data.d.results[0].NavQueryMovs.results[i].HoraDocumento.substring(2,4);170 var ss = data.d.results[0].NavQueryMovs.results[i].HoraDocumento.substring(4,6);171 var horaDoc = HH +":"+mm+":"+ss;172 data.d.results[0].NavQueryMovs.results[i].HoraDocumento = horaDoc;173 var indexNeg = data.d.results[0].NavQueryMovs.results[i].Importe.indexOf("-")174 if(indexNeg > 0) {175 data.d.results[0].NavQueryMovs.results[i].Importe = (-1 * (data.d.results[0].NavQueryMovs.results[i].Importe.replace("-",""))).toString();176 }177 if(data.d.results[0].NavQueryMovs.results[i].Operacion === "CHECK IN"){178 data.d.results[0].NavQueryMovs.results[i].Importe = "0"179 }180 }181 var newData = this.generatePrintQuery(data.d.results[0].NavQueryMovs.results);182 this._onGetExcel(newData);183 sap.ui.core.BusyIndicator.hide();184 }else{185 sap.ui.core.BusyIndicator.hide();186 }187 },188 headRows: function() {189 return [190 { 191 caja: 'Caja', 192 cliente: 'Cliente', 193 vp: 'VÃa Pago', 194 refpago: 'Ref Pago', 195 moneda: 'Moneda',196 importe: 'Importe',197 importeCheckIn: 'Importe Check In',198 estatusCheckIn: 'Estatus Check In',199 noSeguimiento: 'Nro. Seguimiento',200 Documento: 'Documento',201 fechaConta: 'Fecha Contab',202 banco: 'Banco',203 cuentaBanc: 'Cta. Banc',204 clave: 'Cve. Autorizacion',205 pagador: 'Pagador' 206 }207 ]208 209 },210 onDataExportPDF:function(oEvent){ 211 212 var userdata = sessionStorage.getItem("UserItems") ? JSON.parse(sessionStorage.getItem("UserItems")) : [];213 var ModelData = this.getView().getModel("MovimientosModel").getData();214 var doc = new jsPDF({215 orientation: "landscape"216 }); 217 218 doc.setFontSize(18)219 doc.text(220 'REPORTE DE MOVIMIENTOS', 100, 18)221 doc.setFontSize(11)222 doc.setTextColor(80)223 doc.text("CAJA: " + userdata.Caja, 70, 28)224 doc.text("USUARIO: " + userdata.Usuario, 120, 28)225 doc.text("FECHA: " + userdata.Fecha, 180, 28)226 var data = []; 227 for(var i=0;i<ModelData.length;i++) 228 { 229 var importe = ModelData[i].Importe.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");230 importe = importe.split(" ").join(""); 231 data[i]=[232 ModelData[i].CajeroSecuencia,233 ModelData[i].Cliente,234 ModelData[i].ViaPago,235 ModelData[i].ReferenciaPago,236 ModelData[i].ImporteMoneda,237 importe,238 ModelData[i].ImporteCheckIn,239 ModelData[i].EstatusCheckIn,240 ModelData[i].Seguimiento,241 ModelData[i].Documento,242 ModelData[i].FechaConta,243 ModelData[i].BancoCajero,244 ModelData[i].CuentaBancaria,245 ModelData[i].ClaveAutorizacion,246 ModelData[i].Pagador247 ]; 248 }249 var lastRow = ModelData.length + 1;250 data[ModelData.length] = ["","","","", "","","","","","","", "", "", "", ""] ; 251 var importeTotal = ModelData[0].SumTotal.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");252 importeTotal = importeTotal.split(" ").join(""); 253 data[lastRow] = ["Totales","","","", "",importeTotal,"","","","","","", ""] ; 254 doc.autoTable({255 head: this.headRows(),256 body: data,257 theme: 'grid',258 startY: 35,259 showHead: 'firstPage',260 headStyles: { fillColor: [0, 93, 169] },261 styles: { cellPadding: 0.5, fontSize: 8 },262 columnStyles: {263 importe: { halign: 'right'},264 vp: {halign: 'center'}265 } 266 }); 267 268 var dtValue = new Date();269 var fileName = "RptMovimientos_" + String(dtValue.getDate()) + String(dtValue.getMonth()+1) + String(dtValue.getFullYear()) + String(dtValue.getHours()) + String(dtValue.getMinutes());270 doc.save(fileName); 271 272 273 } 274 });...
DiagonalDifference.js
Source:DiagonalDifference.js
1'use strict'2const fs = require('fs')3process.stdin.resume()4process.stdin.setEncoding('utf-8')5let inputString = ''6let currentLine = 07process.stdin.on('data', function (inputStdin) {8 inputString += inputStdin9})10process.stdin.on('end', function () {11 inputString = inputString.split('\n')12 main()13})14function readLine() {15 return inputString[currentLine++]16}17/*18 * Complete the 'diagonalDifference' function below.19 *20 * The function is expected to return an INTEGER.21 * The function accepts 2D_INTEGER_ARRAY arr as parameter.22 */23function diagonalDifference(arr) {24 let diE = 025 let diD = 026 let indexNeg = arr.length - 127 arr.forEach((value, index) => {28 diE += value[index]29 diD += value[indexNeg]30 indexNeg--31 })32 let res = diE - diD33 return res < 0 ? res * -1 : res34}35function main() {36 const ws = fs.createWriteStream(process.env.OUTPUT_PATH)37 const n = parseInt(readLine().trim(), 10)38 let arr = Array(n)39 for (let i = 0; i < n; i++) {40 arr[i] = readLine()41 .replace(/\s+$/g, '')42 .split(' ')43 .map(arrTemp => parseInt(arrTemp, 10))44 }45 const result = diagonalDifference(arr)46 ws.write(result + '\n')47 ws.end()...
Using AI Code Generation
1const fc = require('fast-check');2const indexNeg = require('fast-check-monorepo/indexNeg');3fc.assert(4 fc.property(fc.integer(), fc.integer(), (a, b) => {5 return indexNeg(a, b) === -a - b;6 })7);
Using AI Code Generation
1const fc = require("fast-check");2const indexNeg = require("fast-check-monorepo").indexNeg;3fc.assert(4 fc.property(fc.array(fc.integer()), fc.nat(), (array, index) => {5 return array[indexNeg(index, array)] === array[indexNeg(index, array)];6 })7);8const fc = require("fast-check");9const indexNeg = require("fast-check-monorepo").indexNeg;10fc.assert(11 fc.property(fc.array(fc.integer()), fc.nat(), (array, index) => {12 return array[indexNeg(index, array)] === array[indexNeg(index, array)];13 })14);15const fc = require("fast-check");16const indexNeg = require("fast-check-monorepo").indexNeg;17fc.assert(18 fc.property(fc.array(fc.integer()), fc.nat(), (array, index) => {19 return array[indexNeg(index, array)] === array[indexNeg(index, array)];20 })21);22const fc = require("fast-check");23const indexNeg = require("fast-check-monorepo").indexNeg;24fc.assert(25 fc.property(fc.array(fc.integer()), fc.nat(), (array, index) => {26 return array[indexNeg(index, array)] === array[indexNeg(index, array)];27 })28);29const fc = require("fast-check");30const indexNeg = require("fast-check-monorepo").indexNeg;31fc.assert(32 fc.property(fc.array(fc.integer()), fc.nat(), (array, index) => {33 return array[indexNeg(index, array)] === array[indexNeg(index, array)];34 })35);36const fc = require("fast-check");37const indexNeg = require("fast-check-monorepo").indexNeg;38fc.assert(39 fc.property(fc.array(fc.integer()), fc.nat(), (array, index) => {40 return array[indexNeg(index, array)] === array[indexNeg(index, array)];41 })42);
Using AI Code Generation
1const indexNeg = require('fast-check-monorepo').indexNeg;2const fc = require('fast-check');3const arb = fc.array(fc.integer(), { minLength: 1 });4fc.assert(fc.property(arb, (arr) => {5 const index = indexNeg(arr.length);6 return index < 0;7}));8const indexNeg = require('fast-check-monorepo').indexNeg;9const fc = require('fast-check');10const arb = fc.array(fc.integer(), { minLength: 1 });11fc.assert(fc.property(arb, (arr) => {12 const index = indexNeg(arr.length);13 return index < 0;14}));15const indexNeg = require('fast-check-monorepo').indexNeg;16const fc = require('fast-check');17const arb = fc.array(fc.integer(), { minLength: 1 });18fc.assert(fc.property(arb, (arr) => {19 const index = indexNeg(arr.length);20 return index < 0;21}));
Using AI Code Generation
1import { indexNeg } from 'fast-check-monorepo';2indexNeg(3);3import { indexNeg } from 'fast-check-monorepo';4indexNeg(3);5import { indexNeg } from 'fast-check-monorepo';6indexNeg(3);7import { indexNeg } from 'fast-check-monorepo';8indexNeg(3);9import { indexNeg } from 'fast-check-monorepo';10indexNeg(3);11import { indexNeg } from 'fast-check-monorepo';12indexNeg(3);13import { indexNeg } from 'fast-check-monorepo';14indexNeg(3);15import { indexNeg } from 'fast-check-monorepo';16indexNeg(3);17import { indexNeg } from 'fast-check-monorepo';18indexNeg(3);19import { indexNeg } from 'fast-check-monorepo';20indexNeg(3);21import { indexNeg } from 'fast-check-monorepo';22indexNeg(3);23import { indexNeg } from 'fast-check-monorepo';
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!