diff --git a/source/app/models/main.py b/source/app/models/main.py index 235bd3c..ae9b24d 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -1686,6 +1686,10 @@ class CuentasBanco(BaseModel): @classmethod def get_(cls, values): + opt = values.pop('opt', '') + if opt: + return getattr(cls, '_get_{}'.format(opt))(cls, values) + if values['tipo'] == '1': rows = (CuentasBanco .select() @@ -1705,7 +1709,12 @@ class CuentasBanco(BaseModel): } return data - return + return {'ok': False} + + def _get_currency(self, values): + id = int(values['id']) + account = CuentasBanco.get(CuentasBanco.id==id) + return {'ok': True, 'currency': account.moneda.name} @classmethod def emisor(cls): diff --git a/source/static/js/controller/bancos.js b/source/static/js/controller/bancos.js index 05e1efa..87e3670 100644 --- a/source/static/js/controller/bancos.js +++ b/source/static/js/controller/bancos.js @@ -145,8 +145,27 @@ function get_saldo_cuenta(){ } +function get_account_currency(){ + var id = $$('lst_cuentas_banco').getValue() + webix.ajax().get('/cuentasbanco', {'id': id, 'opt': 'currency'}, { + error:function(text, data, XmlHttpRequest){ + msg = 'Ocurrio un error, consulta a soporte técnico' + msg_error(msg) + }, + success:function(text, data, XmlHttpRequest){ + var values = data.json() + if(values.ok){ + $$('txt_cuenta_moneda').setValue(values.currency) + } + } + }) +} + + function lst_cuentas_banco_change(nv, ov){ + get_saldo_cuenta() get_estado_cuenta() + get_account_currency() }