From 23055b9af5b4d127dd0ece4bc4e83de27b03d1fa Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Fri, 28 Sep 2018 23:01:04 -0500 Subject: [PATCH] Error #291 --- source/static/js/controller/admin.js | 5 +--- source/static/js/controller/util.js | 36 +++++++++++++++++++++++++--- source/static/js/ui/bancos.js | 4 ++-- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/source/static/js/controller/admin.js b/source/static/js/controller/admin.js index 04e4bed..8e45c41 100644 --- a/source/static/js/controller/admin.js +++ b/source/static/js/controller/admin.js @@ -1262,8 +1262,6 @@ function cmd_emisor_agregar_cuenta_click(){ } var values = form.getValues() - - var saldo_inicial = parseFloat(values.emisor_cuenta_saldo_inicial.replace('$', '').replace(',', '')) var cuenta = { de_emisor: true, activa: true, @@ -1274,7 +1272,7 @@ function cmd_emisor_agregar_cuenta_click(){ cuenta: values.emisor_cuenta.trim(), clabe: values.emisor_clabe.trim(), moneda: values.emisor_cuenta_moneda, - saldo_inicial: saldo_inicial + saldo_inicial: values.emisor_cuenta_saldo_inicial.to_float() } if(!cuenta.nombre){ @@ -1319,7 +1317,6 @@ function cmd_emisor_agregar_cuenta_click(){ return } - //~ if(!isFinite(cuenta.saldo_inicial)){ if(cuenta.saldo_inicial <= 0){ msg = 'El saldo inicial no puede ser negativo o cero' msg_error(msg) diff --git a/source/static/js/controller/util.js b/source/static/js/controller/util.js index 2d31f05..ea175fc 100644 --- a/source/static/js/controller/util.js +++ b/source/static/js/controller/util.js @@ -154,7 +154,7 @@ String.prototype.to_float4 = function(){ function get_float(value){ - var f = parseFloat(value.replace('$', '').replace(',', '').trim()).round(DECIMALES) + var f = parseFloat(value.replace('$', '').replace(/,/g, '').trim()).round(DECIMALES) if(!f){ f = 0.00 } @@ -163,7 +163,7 @@ function get_float(value){ function get_float4(value){ - var f = parseFloat(value.replace('$', '').replace(',', '').trim()).round(DECIMALES_TAX) + var f = parseFloat(value.replace('$', '').replace(/,/g, '').trim()).round(DECIMALES_TAX) if(!f){ f = 0.00 } @@ -197,8 +197,13 @@ function format_currency(value){ } +function format_currency2(value){ + return '$ ' + format_decimal_2(value) +} + + function format_currency4(value){ - return '$ ' + format_decimal_4(value) + return '$ ' + format_decimal_2(value) } @@ -252,6 +257,31 @@ webix.protoUI({ }, webix.ui.text) +webix.protoUI({ + $cssName: "text", + name: "currency2", + $init:function(){ + this.attachEvent("onItemClick", function(){ + this.$setValue(this.config.raw, true) + this.getInputNode().select() + }) + this.attachEvent("onBlur", function(){ + this.$setValue(this.config.value) + }) + }, + $render:function(){ + this.$setValue(this.config.value) + }, + $setValue:function(value, raw){ + this.config.raw = value + if(!raw){ + value = format_currency2(value) + } + this.getInputNode().value = value + } +}, webix.ui.text) + + webix.ui.datafilter.countRows = webix.extend({ refresh:function(master, node, value){ node.firstChild.innerHTML = master.count(); diff --git a/source/static/js/ui/bancos.js b/source/static/js/ui/bancos.js index a88099b..1116c27 100644 --- a/source/static/js/ui/bancos.js +++ b/source/static/js/ui/bancos.js @@ -391,7 +391,7 @@ var controls_banco_retiro = [ {view: 'richselect', id: 'lst_retiro_forma_pago', name: 'retiro_forma_pago', label: 'Forma de Pago', required: true, options: [], labelWidth: 125, labelAlign: 'right'}, - {view: 'currency', type: 'text', id: 'txt_retiro_importe', + {view: 'currency2', type: 'text', id: 'txt_retiro_importe', name: 'retiro_importe', label: 'Importe', labelAlign: 'right', required: true, invalidMessage: 'Captura un valor nĂºmerico', inputAlign: 'right', value: ''} @@ -422,7 +422,7 @@ var controls_banco_deposito = [ {view: 'richselect', id: 'lst_deposito_forma_pago', name: 'deposito_forma_pago', label: 'Forma de Pago', required: true, options: [], labelWidth: 125, labelAlign: 'right'}, - {view: 'currency', type: 'text', id: 'txt_deposito_importe', + {view: 'currency2', type: 'text', id: 'txt_deposito_importe', name: 'deposito_importe', label: 'Importe', labelAlign: 'right', required: true, invalidMessage: 'Captura un valor nĂºmerico', inputAlign: 'right', value: ''},