diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f22756..99dbb19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +v 1.18.0 [27-sep-2018] +---------------------- + - Fix #282 Factura de pago en otras monedas + + v 1.17.0 [25-sep-2018] ---------------------- - Fix - Al generar factura de pago con documentos relacionados en otras monedas diff --git a/VERSION b/VERSION index 092afa1..84cc529 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.0 +1.18.0 diff --git a/docs/empresalibre/docs/bancos.md b/docs/empresalibre/docs/bancos.md index 0ef2057..bd1299b 100644 --- a/docs/empresalibre/docs/bancos.md +++ b/docs/empresalibre/docs/bancos.md @@ -231,7 +231,7 @@ personalizar completamente esta plantilla. ### Facturas de pago con facturas en otras monedas Cuando el sistema detecta que se están usando más de una moneda, automáticamente -te mostrarás las columnas del ***Total*** y la ***Moneda*** respectiva. +te mostrará las columnas del ***Total*** y la ***Moneda*** respectiva. ![Factura de pago](img/03/bancos_023.png) diff --git a/docs/empresalibre/docs/notas.md b/docs/empresalibre/docs/notas.md index 8555b8c..d6b2965 100644 --- a/docs/empresalibre/docs/notas.md +++ b/docs/empresalibre/docs/notas.md @@ -6,8 +6,11 @@ siempre actualizado.** Solo se da soporte sobre la ultima versión de **Empresa Libre**. +### 1.18.0 [27-sep-2018] +- Fix [#282](https://gitlab.com/mauriciobaeza/empresa-libre/issues/282) Factura de pago en otras monedas + + ### 1.17.0 [25-sep-2018] ----------------------- - Fix - Al generar factura de pago con documentos relacionados en otras monedas - Fix - Al generar factura de pago sin serie en documentos relacionados - Fix [#278](https://gitlab.com/mauriciobaeza/empresa-libre/issues/278) diff --git a/source/app/models/main.py b/source/app/models/main.py index 8cb10b0..3754f9a 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -35,7 +35,7 @@ from settings import log, DEBUG, VERSION, PATH_CP, COMPANIES, PRE, CURRENT_CFDI, INIT_VALUES, DEFAULT_PASSWORD, DECIMALES, IMPUESTOS, DEFAULT_SAT_PRODUCTO, \ CANCEL_SIGNATURE, PUBLIC, DEFAULT_SERIE_TICKET, CURRENT_CFDI_NOMINA, \ DEFAULT_SAT_NOMINA, DECIMALES_TAX, TITLE_APP, MV, DECIMALES_PRECIOS, \ - DEFAULT_CFDIPAY + DEFAULT_CFDIPAY, CURRENCY_MN FORMAT = '{0:.2f}' @@ -1921,6 +1921,7 @@ class MovimientosBanco(BaseModel): values['cuenta'] = int(values['cuenta']) values['retiro'] = util.get_float(values['retiro']) values['deposito'] = util.get_float(values['deposito']) + values['tipo_cambio'] = util.get_float(values['tipo_cambio']) values['forma_pago'] = int(values['forma_pago']) ultimo_saldo = self._ultimo_saldo( @@ -5688,6 +5689,8 @@ class CfdiPagos(BaseModel): 'Monto': FORMAT.format(mov.deposito), 'relacionados': related_docs, } + if currency != CURRENCY_MN: + pagos['TipoCambioP'] = FORMAT_TAX.format(mov.tipo_cambio) complementos = {'pagos': pagos} data = { diff --git a/source/app/settings.py b/source/app/settings.py index 4f92a3e..fba1be3 100644 --- a/source/app/settings.py +++ b/source/app/settings.py @@ -47,7 +47,7 @@ except ImportError: DEBUG = DEBUG -VERSION = '1.17.0' +VERSION = '1.18.0' EMAIL_SUPPORT = ('soporte@empresalibre.net',) TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION) @@ -181,3 +181,4 @@ DEFAULT_SAT_NOMINA = { API = 'https://api.empresalibre.net{}' +CURRENCY_MN = 'MXN' diff --git a/source/static/js/controller/bancos.js b/source/static/js/controller/bancos.js index a33fe7d..6c490aa 100644 --- a/source/static/js/controller/bancos.js +++ b/source/static/js/controller/bancos.js @@ -17,7 +17,6 @@ var msg = '' var msg_importe = '' -//~ var is_mn = true var current_currency = '' var current_way_payment = '' @@ -36,6 +35,7 @@ function init_config_bank(){ g2.showColumn('type_change') } show('cmd_complemento_pago', get_config('used_cfdi_pays')) + //~ show('cmd_show_invoice_pay', get_config('used_cfdi_pays')) set_year_month() } @@ -237,6 +237,8 @@ function get_facturas_por_pagar(){ function cmd_agregar_retiro_click(){ get_bancos_forma_pago(true) + var title = 'Agregar retiro de banco a la cuenta ' + $$('lst_cuentas_banco').getText() + ' en ' + $$('txt_cuenta_moneda').getValue() + $$('title_bank_retiro').setValue(title) $$('multi_bancos').setValue('banco_retiro') } @@ -248,6 +250,9 @@ function cmd_agregar_deposito_click(){ var g = $$('grid_cfdi_este_deposito') g.config.columns[g.getColumnIndex('importe')].header = 'Este Pago ' + current_currency g.refreshColumns() + show('deposit_type_change', current_currency!=CURRENCY_MN) + var title = 'Agregar depósito de banco a la cuenta ' + $$('lst_cuentas_banco').getText() + ' en ' + $$('txt_cuenta_moneda').getValue() + $$('title_bank_deposit').setValue(title) $$('multi_bancos').setValue('banco_deposito') } @@ -401,20 +406,14 @@ function actualizar_deposito(grid){ descripcion += 'Pago de la factura: ' + obj.serie + obj.folio + ' del ' descripcion += 'cliente: ' + obj.cliente + '\n' if(obj.importe == undefined){ - //~ if(is_mn){ - //~ obj.importe = obj.total_mn - //~ }else{ obj.importe = obj.saldo obj.this_pay = obj.saldo } suma += obj.importe.to_float() if(obj.type_change == undefined){ - if(obj.currency==CURRENCY_MN){ + if(obj.currency==CURRENCY_MN || obj.currency==current_currency){ obj.type_change = 1.00 } - //~ else{ - //~ obj.type_change = get_type_change(obj.currency) - //~ } } }) @@ -526,6 +525,7 @@ function grid_cfdi_este_deposito_before_edit_stop(state, editor){ function validate_deposito(values){ var grid = $$('grid_cfdi_este_deposito') var importe = values.deposito_importe.to_float() + var type_change = values.deposit_type_change.to_float() var msg_tc = '' if(!importe){ @@ -546,6 +546,14 @@ function validate_deposito(values){ return false } + if(grid.count() && current_currency!=CURRENCY_MN){ + if(type_change <= 1.0){ + msg = 'El Tipo de Cambio debe ser mayor a 1.00' + msg_error(msg) + return false + } + } + var today = new Date() if(values.deposito_fecha > today){ msg = 'Fecha inválida, es una fecha futura' @@ -588,7 +596,7 @@ function validate_deposito(values){ } suma += tmp - if(obj.currency!='MXN'){ + if(obj.currency!=CURRENCY_MN && obj.currency!=current_currency){ if(obj.type_change==undefined){ msg_tc = 'Captura el Tipo de Cambio' }else{ @@ -634,6 +642,7 @@ function guardar_deposito(values){ data['numero_operacion'] = values.deposito_referencia.trim() data['forma_pago'] = $$('lst_deposito_forma_pago').getValue() data['deposito'] = values.deposito_importe.to_float() + data['tipo_cambio'] = values.deposit_type_change.to_float() data['retiro'] = 0.0 data['descripcion'] = values.deposito_descripcion @@ -642,7 +651,6 @@ function guardar_deposito(values){ if(grid.count()){ var ids = new Object() grid.data.each(function(obj){ - //~ ids[obj.id] = obj.importe.to_float() ids[obj.id] = { 'this_pay': obj.this_pay.to_float(), 'importe': obj.importe.to_float(), @@ -650,7 +658,6 @@ function guardar_deposito(values){ } }) data['ids'] = ids - //~ showvar(data['ids']) } webix.ajax().post('/movbanco', data, { diff --git a/source/static/js/controller/util.js b/source/static/js/controller/util.js index c1f66a2..9ad7812 100644 --- a/source/static/js/controller/util.js +++ b/source/static/js/controller/util.js @@ -145,8 +145,6 @@ Number.prototype.round = function(decimals){ String.prototype.is_number = function(){ return /^\d+$/.test(this) } - - String.prototype.to_float = function(){ return get_float(this) } @@ -212,7 +210,6 @@ webix.protoUI({ $setValue:function(value, raw){ this.config.raw = value if(!raw){ - //~ value = webix.i18n.priceFormat(value) value = format_currency(value) } this.getInputNode().value = value @@ -220,6 +217,31 @@ webix.protoUI({ }, webix.ui.text) +webix.protoUI({ + $cssName: "text", + name: "currency4", + $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_currency4(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 9620d4d..4d94adc 100644 --- a/source/static/js/ui/bancos.js +++ b/source/static/js/ui/bancos.js @@ -43,6 +43,8 @@ var toolbar_movimientos_banco = [ {}, {view: 'button', id: 'cmd_complemento_pago', label: 'Factura de Pago', type: 'iconButton', autowidth: true, icon: 'file-code-o'}, + {view: 'button', id: 'cmd_show_invoice_pay', label: 'Ver Facturas de Pago', + type: 'iconButton', autowidth: true, icon: 'table', hidden: true}, {}, {view: 'button', id: 'cmd_cancelar_movimiento', label: 'Cancelar', type: 'iconButton', autowidth: true, icon: 'ban'}, @@ -257,8 +259,7 @@ var grid_pay_related = { var toolbar_banco_retiro = [ - {view: 'label', label: 'Agregar retiro de banco'}, - {}, + {view: 'label', label: 'Agregar retiro de banco', id: 'title_bank_retiro'}, {view: 'button', id: 'cmd_guardar_retiro', label: 'Guardar Retiro', type: 'iconButton', autowidth: true, icon: 'minus'}, {view: 'icon', click: '$$("multi_bancos").setValue("banco_home")', @@ -267,8 +268,7 @@ var toolbar_banco_retiro = [ var toolbar_banco_deposito = [ - {view: 'label', label: 'Agregar depósito de banco'}, - {}, + {view: 'label', label: 'Agregar depósito de banco', id: 'title_bank_deposit'}, {view: 'button', id: 'cmd_guardar_deposito', label: 'Guardar Depósito', type: 'iconButton', autowidth: true, icon: 'plus'}, {view: 'icon', click: '$$("multi_bancos").setValue("banco_home")', @@ -343,7 +343,11 @@ var controls_banco_deposito = [ {view: 'currency', type: 'text', id: 'txt_deposito_importe', name: 'deposito_importe', label: 'Importe', labelAlign: 'right', required: true, invalidMessage: 'Captura un valor númerico', - inputAlign: 'right', value: ''} + inputAlign: 'right', value: ''}, + {view: 'currency4', type: 'text', id: 'deposit_type_change', + name: 'deposit_type_change', label: 'T.C.', labelAlign: 'right', + required: false, invalidMessage: 'Captura un valor númerico', + inputAlign: 'right', value: '1.0000', width: 175, hidden: true} ]}, {cols: [ {view: 'textarea', id: 'deposito_descripcion', label: 'Descripción',