forked from elmau/empresa-libre
commit
63fc8e9a78
|
@ -1,3 +1,11 @@
|
|||
v 1.20.0 [08-oct-2018]
|
||||
----------------------
|
||||
- Error #295
|
||||
- Mejora: Cuentas de banco para clientes
|
||||
|
||||
* IMPORTANTE: Es necesario realizar una migración, despues de actualizar la rama principal.
|
||||
|
||||
|
||||
v 1.19.1 [03-oct-2018]
|
||||
----------------------
|
||||
- Error #291
|
||||
|
|
|
@ -6,6 +6,13 @@ siempre actualizado.** Solo se da soporte sobre la ultima versión de **Empresa
|
|||
Libre**.
|
||||
|
||||
|
||||
### 1.20.0 [08-oct-2018]
|
||||
- Error [#295](https://gitlab.com/mauriciobaeza/empresa-libre/issues/295)
|
||||
- Mejora - Cuentas de banco para clientes
|
||||
|
||||
* IMPORTANTE: Es necesario realizar una migración, despues de actualizar la rama principal.
|
||||
|
||||
|
||||
### 1.19.1 [03-oct-2018]
|
||||
- Error [#291](https://gitlab.com/mauriciobaeza/empresa-libre/issues/291)
|
||||
- Error al generar PDF de factura de pago con relacionados sin serie
|
||||
|
|
|
@ -543,3 +543,36 @@ class AppCfdiPay(object):
|
|||
values = req.params
|
||||
req.context['result'] = self._db.cfdipay(values)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
class AppSATBancos(object):
|
||||
|
||||
def __init__(self, db):
|
||||
self._db = db
|
||||
|
||||
def on_get(self, req, resp):
|
||||
values = req.params
|
||||
req.context['result'] = self._db.get_satbancos(values)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
def on_post(self, req, resp):
|
||||
values = req.params
|
||||
req.context['result'] = self._db.satbancos(values)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
class AppSociosCuentasBanco(object):
|
||||
|
||||
def __init__(self, db):
|
||||
self._db = db
|
||||
|
||||
def on_get(self, req, resp):
|
||||
values = req.params
|
||||
req.context['result'] = self._db.get_partners_accounts_bank(values)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
def on_post(self, req, resp):
|
||||
values = req.params
|
||||
req.context['result'] = self._db.partners_accounts_bank(values)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
|
|
@ -3618,3 +3618,32 @@ def respaldar_db(values, path_bk):
|
|||
args = 'pg_dump -U postgres -Fc {} > "{}"'.format(db, path)
|
||||
_call(args)
|
||||
return
|
||||
|
||||
|
||||
def validate_rfc(value):
|
||||
msg = ''
|
||||
if len(value) < 12:
|
||||
msg = 'Longitud inválida del RFC'
|
||||
return msg
|
||||
l = 4
|
||||
if len(value)==12:
|
||||
l = 3
|
||||
s = value[0:l]
|
||||
r = re.match('[A-ZÑ&]{%s}' % l, s)
|
||||
msg = 'Caracteres inválidos al {} del RFC'
|
||||
if not r:
|
||||
return msg.format('inicio')
|
||||
s = value[-3:]
|
||||
r = re.match('[A-Z0-9]{3}', s)
|
||||
if not r:
|
||||
return msg.format('final')
|
||||
s = value[l:l+6]
|
||||
r = re.match('[0-9]{6}', s)
|
||||
msg = 'Fecha inválida en el RFC'
|
||||
if not r:
|
||||
return msg
|
||||
try:
|
||||
datetime.datetime.strptime(s, '%y%m%d')
|
||||
return ''
|
||||
except:
|
||||
return msg
|
||||
|
|
|
@ -17,7 +17,7 @@ from controllers.main import (AppEmpresas,
|
|||
AppMain, AppValues, AppPartners, AppProducts, AppInvoices, AppFolios,
|
||||
AppDocumentos, AppFiles, AppPreInvoices, AppCuentasBanco,
|
||||
AppMovimientosBanco, AppTickets, AppStudents, AppEmployees, AppNomina,
|
||||
AppInvoicePay, AppCfdiPay
|
||||
AppInvoicePay, AppCfdiPay, AppSATBancos, AppSociosCuentasBanco
|
||||
)
|
||||
|
||||
|
||||
|
@ -58,6 +58,8 @@ api.add_route('/employees', AppEmployees(db))
|
|||
api.add_route('/nomina', AppNomina(db))
|
||||
api.add_route('/invoicepay', AppInvoicePay(db))
|
||||
api.add_route('/cfdipay', AppCfdiPay(db))
|
||||
api.add_route('/satbancos', AppSATBancos(db))
|
||||
api.add_route('/socioscb', AppSociosCuentasBanco(db))
|
||||
|
||||
|
||||
# ~ Activa si usas waitress y NO estas usando servidor web
|
||||
|
|
|
@ -436,8 +436,20 @@ class StorageEngine(object):
|
|||
def get_cfdipay(self, values):
|
||||
return main.CfdiPagos.get_values(values)
|
||||
|
||||
def get_satbancos(self, values):
|
||||
return main.SATBancos.get_values(values)
|
||||
|
||||
def get_partners_accounts_bank(self, values):
|
||||
return main.SociosCuentasBanco.get_values(values)
|
||||
|
||||
def cfdipay(self, values):
|
||||
return main.CfdiPagos.post(values)
|
||||
|
||||
def bankmovement(self, values):
|
||||
return main.MovimientosBanco.post(values)
|
||||
|
||||
def satbancos(self, values):
|
||||
return main.SATBancos.post(values)
|
||||
|
||||
def partners_accounts_bank(self, values):
|
||||
return main.SociosCuentasBanco.post(values)
|
||||
|
|
|
@ -40,8 +40,10 @@ from settings import log, DEBUG, VERSION, PATH_CP, COMPANIES, PRE, CURRENT_CFDI,
|
|||
|
||||
FORMAT = '{0:.2f}'
|
||||
FORMAT3 = '{0:.3f}'
|
||||
FORMAT_TAX = '{0:.4f}'
|
||||
FORMAT_PRECIO = '{0:.4f}'
|
||||
FORMAT4 = '{0:.4f}'
|
||||
FORMAT6 = '{0:.6f}'
|
||||
FORMAT_TAX = FORMAT4
|
||||
FORMAT_PRECIO = FORMAT4
|
||||
RFC_PUBLICO = 'XAXX010101000'
|
||||
|
||||
|
||||
|
@ -1515,6 +1517,40 @@ class SATBancos(BaseModel):
|
|||
def __str__(self):
|
||||
return 'Banco: {} ({})'.format(self.name, self.key)
|
||||
|
||||
def _updaterfc(self, args):
|
||||
id = int(args['id'])
|
||||
values = util.loads(args['values'])
|
||||
msg = util.validate_rfc(values['rfc'])
|
||||
if msg:
|
||||
return {'ok': False, 'msg': msg}
|
||||
|
||||
q = (SATBancos
|
||||
.update(**values)
|
||||
.where(SATBancos.id==id))
|
||||
result = bool(q.execute())
|
||||
msg = 'RFC actualizado correctamente'
|
||||
return {'ok': result, 'msg': msg}
|
||||
|
||||
@classmethod
|
||||
def post(cls, values):
|
||||
opt = values.pop('opt')
|
||||
return getattr(cls, '_{}'.format(opt))(cls, values)
|
||||
|
||||
@classmethod
|
||||
def get_values(cls, values):
|
||||
opt = values.pop('opt')
|
||||
return getattr(cls, '_get_{}'.format(opt))(cls, values)
|
||||
|
||||
def _get_active(cls, values):
|
||||
rows = (SATBancos
|
||||
.select(
|
||||
SATBancos.id,
|
||||
SATBancos.name.alias('value'))
|
||||
.where(SATBancos.activo==True)
|
||||
.dicts()
|
||||
)
|
||||
return tuple(rows)
|
||||
|
||||
@classmethod
|
||||
def get_(cls):
|
||||
rows = SATBancos.select().dicts()
|
||||
|
@ -1554,6 +1590,16 @@ class SATBancos(BaseModel):
|
|||
log.error(msg)
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def get_by_name(cls, name):
|
||||
try:
|
||||
obj = SATBancos.get(SATBancos.name==name)
|
||||
return obj
|
||||
except SATBancos.DoesNotExist:
|
||||
msg = 'SATBancos no existe: {}'.format(key)
|
||||
log.error(msg)
|
||||
return
|
||||
|
||||
|
||||
class SATNivelesEducativos(BaseModel):
|
||||
name = TextField(index=True)
|
||||
|
@ -2676,6 +2722,73 @@ class Socios(BaseModel):
|
|||
return {'ok': False}
|
||||
|
||||
|
||||
class SociosCuentasBanco(BaseModel):
|
||||
socio = ForeignKeyField(Socios)
|
||||
banco = ForeignKeyField(SATBancos)
|
||||
cuenta = TextField(default='')
|
||||
clabe = TextField(default='')
|
||||
moneda = ForeignKeyField(SATMonedas, null=True)
|
||||
|
||||
class Meta:
|
||||
order_by = ('socio', 'banco', 'cuenta')
|
||||
indexes = (
|
||||
(('socio', 'banco', 'cuenta'), True),
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return '{} ({})'.format(self.banco.name, self.cuenta[-4:])
|
||||
|
||||
@classmethod
|
||||
def get_values(cls, values):
|
||||
opt = values.pop('opt')
|
||||
return getattr(cls, '_get_{}'.format(opt))(cls, values)
|
||||
|
||||
def _get_by_partner(self, values):
|
||||
id = int(values['id_partner'])
|
||||
rows = (SociosCuentasBanco.select(
|
||||
SociosCuentasBanco.id,
|
||||
SQL(" '-' AS delete"),
|
||||
SATBancos.name.alias('banco'),
|
||||
SociosCuentasBanco.cuenta,
|
||||
SociosCuentasBanco.clabe)
|
||||
.join(SATBancos).switch(SociosCuentasBanco)
|
||||
.where(SociosCuentasBanco.socio==id)
|
||||
.dicts())
|
||||
return tuple(rows)
|
||||
|
||||
@classmethod
|
||||
def post(cls, values):
|
||||
opt = values.pop('opt')
|
||||
return getattr(cls, '_{}'.format(opt))(cls, values)
|
||||
|
||||
def _new(self, values):
|
||||
values = util.loads(values['values'])
|
||||
bank = SATBancos.get_by_name(values['banco'])
|
||||
fields = {
|
||||
'socio': values['id_partner'],
|
||||
'banco': bank,
|
||||
'cuenta': values['cuenta'],
|
||||
'clabe': values['clabe'],
|
||||
}
|
||||
try:
|
||||
obj = SociosCuentasBanco.create(**fields)
|
||||
except IntegrityError as e:
|
||||
msg = 'Ya existe esta cuenta'
|
||||
data = {'ok': False, 'msg': msg}
|
||||
return data
|
||||
|
||||
msg = 'Cuenta de banco agregada correctamente'
|
||||
data = {'ok': True, 'id': obj.id, 'msg': msg}
|
||||
return data
|
||||
|
||||
def _delete(self, values):
|
||||
values = util.loads(values['values'])
|
||||
id = int(values['id'])
|
||||
q = SociosCuentasBanco.delete().where(SociosCuentasBanco.id==id)
|
||||
result = bool(q.execute())
|
||||
msg = 'Cuenta borrada correctamente'
|
||||
return {'ok': result, 'msg': msg}
|
||||
|
||||
|
||||
class Contactos(BaseModel):
|
||||
socio = ForeignKeyField(Socios)
|
||||
|
@ -5348,13 +5461,20 @@ class FacturasPagos(BaseModel):
|
|||
fac = Facturas.get(Facturas.id==int(i))
|
||||
this_pay = values['this_pay']
|
||||
importe = values['importe']
|
||||
type_change = values['type_change']
|
||||
type_change = round(1 / values['type_change'], 6)
|
||||
|
||||
validate = round(this_pay / type_change, 2)
|
||||
while validate > importe:
|
||||
type_change += 0.000001
|
||||
validate = round(this_pay / type_change, 2)
|
||||
|
||||
mov_ant, numero = cls._movimiento_anterior(cls, mov, fac)
|
||||
nuevo = {
|
||||
'movimiento': mov,
|
||||
'factura': fac,
|
||||
'numero': numero,
|
||||
'importe': importe,
|
||||
'tipo_cambio': type_change,
|
||||
}
|
||||
if mov_ant is None:
|
||||
nuevo['saldo_anterior'] = float(fac.saldo)
|
||||
|
@ -5365,8 +5485,8 @@ class FacturasPagos(BaseModel):
|
|||
nuevo['saldo'] = nuevo['saldo_anterior'] - importe
|
||||
else:
|
||||
nuevo['importe'] = this_pay
|
||||
nuevo['tipo_cambio'] = type_change
|
||||
nuevo['saldo'] = nuevo['saldo_anterior'] - this_pay
|
||||
|
||||
FacturasPagos.create(**nuevo)
|
||||
|
||||
fac.saldo = nuevo['saldo']
|
||||
|
@ -5610,7 +5730,7 @@ class CfdiPagos(BaseModel):
|
|||
Facturas.serie.alias('Serie'),
|
||||
Facturas.folio.alias('Folio'),
|
||||
Facturas.moneda.alias('MonedaDR'),
|
||||
Facturas.tipo_cambio.alias('TipoCambioDR'),
|
||||
FacturasPagos.tipo_cambio.alias('TipoCambioDR'),
|
||||
# ~ Facturas.metodo_pago.alias('MetodoDePagoDR'),
|
||||
FacturasPagos.numero.alias('NumParcialidad'),
|
||||
FacturasPagos.saldo_anterior.alias('ImpSaldoAnt'),
|
||||
|
@ -5625,7 +5745,7 @@ class CfdiPagos(BaseModel):
|
|||
r['IdDocumento'] = str(r['IdDocumento'])
|
||||
r['Folio'] = str(r['Folio'])
|
||||
r['NumParcialidad'] = str(r['NumParcialidad'])
|
||||
r['TipoCambioDR'] = FORMAT.format(r['TipoCambioDR'])
|
||||
r['TipoCambioDR'] = FORMAT6.format(r['TipoCambioDR'])
|
||||
r['MetodoDePagoDR'] = DEFAULT_CFDIPAY['WAYPAY']
|
||||
r['ImpSaldoAnt'] = FORMAT.format(r['ImpSaldoAnt'])
|
||||
r['ImpPagado'] = FORMAT.format(r['ImpPagado'])
|
||||
|
@ -8095,8 +8215,9 @@ def _crear_tablas(rfc):
|
|||
SATOrigenRecurso, SATTipoContrato, SATTipoDeduccion, SATTipoHoras,
|
||||
SATTipoIncapacidad, SATTipoJornada, SATTipoNomina, SATTipoOtroPago,
|
||||
SATTipoPercepcion, SATTipoRegimen,
|
||||
Socios, Contactos, ContactoCorreos, ContactoDirecciones, Empleados,
|
||||
ContactoTelefonos, Departamentos, Puestos,
|
||||
Socios, SociosCuentasBanco, Contactos, ContactoCorreos,
|
||||
ContactoDirecciones, Empleados, ContactoTelefonos, Departamentos,
|
||||
Puestos,
|
||||
Tags, Roles, Usuarios, CuentasBanco, TipoCambio, MovimientosBanco,
|
||||
TipoCorreo, TipoDireccion, TipoPariente, TipoResponsable, TipoTelefono,
|
||||
TipoTitulo, TipoMovimientoAlumno, TipoMovimientoAlmacen,
|
||||
|
@ -8162,7 +8283,8 @@ def _migrate_tables(rfc=''):
|
|||
CfdiNominaHorasExtra, CfdiNominaIncapacidad, CfdiNominaJubilacion,
|
||||
CfdiNominaOtroPago, CfdiNominaOtros, CfdiNominaPercepciones,
|
||||
CfdiNominaRelacionados, CfdiNominaSeparacion, CfdiNominaSubcontratos,
|
||||
CfdiNominaTotales, SATNivelesEducativos, Roles, Permisos
|
||||
CfdiNominaTotales, SATNivelesEducativos, Roles, Permisos,
|
||||
SociosCuentasBanco
|
||||
]
|
||||
log.info('Creando tablas nuevas...')
|
||||
database_proxy.create_tables(tablas, True)
|
||||
|
|
|
@ -47,7 +47,7 @@ except ImportError:
|
|||
|
||||
|
||||
DEBUG = DEBUG
|
||||
VERSION = '1.19.1'
|
||||
VERSION = '1.20.0'
|
||||
EMAIL_SUPPORT = ('soporte@empresalibre.net',)
|
||||
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
||||
|
||||
|
|
|
@ -112,6 +112,11 @@ var controllers = {
|
|||
$$('cmd_subir_cfdixml').attachEvent('onItemClick', cmd_subir_cfdixml_click)
|
||||
$$('up_bdfl').attachEvent('onUploadComplete', up_bdfl_upload_complete)
|
||||
$$('up_cfdixml').attachEvent('onUploadComplete', up_cfdixml_upload_complete)
|
||||
|
||||
$$('grid_admin_bancos').attachEvent('onAfterEditStart', grid_admin_bancos_after_edit_start)
|
||||
$$('grid_admin_bancos').attachEvent('onBeforeEditStop', grid_admin_bancos_before_edit_stop)
|
||||
//~ $$('grid_admin_bancos').attachEvent('onAfterEditStop', grid_admin_bancos_after_edit_stop)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2276,3 +2281,64 @@ function grid_emisor_cuentas_banco_on_check(row, column, state){
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function admin_sat_bank_update_rfc(id, rfc){
|
||||
var data = {opt: 'updaterfc', id: id, values: {rfc: rfc}}
|
||||
webix.ajax().post('/satbancos', data, {
|
||||
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){
|
||||
msg_ok(values.msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function grid_admin_bancos_after_edit_start(id){
|
||||
var grid = $$('grid_admin_bancos')
|
||||
|
||||
if(id['column']=='rfc'){
|
||||
var row = grid.getItem(id)
|
||||
if(row['key']=='999'){
|
||||
grid.editCancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function grid_admin_bancos_before_edit_stop(state, editor){
|
||||
var grid = $$('grid_admin_bancos')
|
||||
var row = grid.getItem(editor.row)
|
||||
|
||||
if(editor.column == 'rfc' && row['key']!='999'){
|
||||
var rfc = state.value
|
||||
if (rfc.length != 12){
|
||||
msg_error('Longitud incorrecta del RFC')
|
||||
grid.blockEvent()
|
||||
state.value = state.old
|
||||
grid.editCancel()
|
||||
grid.unblockEvent()
|
||||
return true
|
||||
}
|
||||
if(!validar_rfc(rfc)){
|
||||
grid.blockEvent()
|
||||
state.value = state.old
|
||||
grid.editCancel()
|
||||
grid.unblockEvent()
|
||||
return true
|
||||
}
|
||||
grid.blockEvent()
|
||||
state.value = state.value.trim().toUpperCase()
|
||||
grid.editCancel()
|
||||
grid.unblockEvent()
|
||||
admin_sat_bank_update_rfc(row.id, state.value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -432,9 +432,9 @@ function actualizar_deposito(grid){
|
|||
}
|
||||
suma += obj.importe.to_float()
|
||||
if(obj.type_change == undefined){
|
||||
if(obj.currency==CURRENCY_MN || obj.currency==current_currency){
|
||||
obj.type_change = 1.00
|
||||
}
|
||||
//~ if(obj.currency==CURRENCY_MN || obj.currency==current_currency){
|
||||
obj.type_change = 1.00
|
||||
//~ }
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ var cfg_partners = new Object()
|
|||
var partners_controllers = {
|
||||
init: function(){
|
||||
$$('cmd_new_partner').attachEvent('onItemClick', cmd_new_partner_click);
|
||||
$$('cmd_new_contact').attachEvent('onItemClick', cmd_new_contact_click);
|
||||
//~ $$('cmd_new_contact').attachEvent('onItemClick', cmd_new_contact_click);
|
||||
$$('cmd_edit_partner').attachEvent('onItemClick', cmd_edit_partner_click);
|
||||
$$('cmd_delete_partner').attachEvent('onItemClick', cmd_delete_partner_click);
|
||||
$$('cmd_save_partner').attachEvent('onItemClick', cmd_save_partner_click);
|
||||
$$('cmd_cancel_partner').attachEvent('onItemClick', cmd_cancel_partner_click);
|
||||
$$('cmd_cancel_contact').attachEvent('onItemClick', cmd_cancel_contact_click);
|
||||
//~ $$('cmd_cancel_contact').attachEvent('onItemClick', cmd_cancel_contact_click);
|
||||
//~ $$('cmd_partner_zero').attachEvent('onItemClick', cmd_partner_zero_click);
|
||||
$$('codigo_postal').attachEvent('onKeyPress', postal_code_key_press);
|
||||
$$('codigo_postal').attachEvent('onTimedKeyPress', postal_code_key_up);
|
||||
|
@ -40,6 +40,8 @@ var partners_controllers = {
|
|||
//~ $$('grid_partners').attachEvent('onSelectChange', grid_partners_on_select_change)
|
||||
|
||||
$$('partner_balance').attachEvent('onChange', partner_balance_on_change)
|
||||
$$('cmd_partner_add_account_bank').attachEvent('onItemClick', cmd_partner_add_account_bank_click)
|
||||
$$('grid_partner_account_bank').attachEvent('onItemClick', grid_partner_account_bank_click)
|
||||
default_config_partners()
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +91,8 @@ function cmd_new_partner_click(id, e, node){
|
|||
query = table_usocfdi.chain().find({fisica: true}).data()
|
||||
$$('lst_uso_cfdi_socio').getList().parse(query)
|
||||
$$('partner_balance').define('readonly', !cfg_partners['chk_config_change_balance_partner'])
|
||||
get_partner_banks()
|
||||
get_partner_accounts_bank(0)
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,12 +140,14 @@ function cmd_edit_partner_click(){
|
|||
if(values.es_proveedor){
|
||||
$$('cuenta_proveedor').enable()
|
||||
}
|
||||
get_partner_accounts_bank(row['id'])
|
||||
}
|
||||
})
|
||||
|
||||
$$('multi_partners').setValue('partners_new')
|
||||
$$('tab_partner').setValue('Datos Fiscales')
|
||||
};
|
||||
get_partner_banks()
|
||||
}
|
||||
|
||||
|
||||
function cmd_delete_partner_click(id, e, node){
|
||||
|
@ -387,57 +393,6 @@ function is_supplier_change(new_value, old_value){
|
|||
}
|
||||
|
||||
|
||||
//~ function partner_reset_saldo(id){
|
||||
//~ webix.ajax().post('/partners', {opt: 'reset', id: id}, {
|
||||
//~ 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){
|
||||
//~ msg = 'Saldo actualizado correctamente'
|
||||
//~ $$('grid_partners').updateItem(id, {saldo_cliente: 0.0})
|
||||
//~ $$('cmd_partner_zero').disable()
|
||||
//~ msg_ok(msg)
|
||||
//~ }
|
||||
//~ }
|
||||
//~ })
|
||||
//~ }
|
||||
|
||||
|
||||
//~ function cmd_partner_zero_click(){
|
||||
//~ var g = $$('grid_partners')
|
||||
//~ var row = g.getSelectedItem()
|
||||
//~ var saldo = row.saldo_cliente.to_float()
|
||||
|
||||
//~ if(saldo){
|
||||
//~ msg = '¿Estas seguro de poner en cero el saldo del cliente?<BR><BR>'
|
||||
//~ msg += 'ESTA ACCIÓN NO SE PUEDE DESHACER'
|
||||
//~ webix.confirm({
|
||||
//~ title: 'Saldo Cliente',
|
||||
//~ ok: 'Si',
|
||||
//~ cancel: 'No',
|
||||
//~ type: 'confirm-error',
|
||||
//~ text: msg,
|
||||
//~ callback:function(result){
|
||||
//~ if (result){
|
||||
//~ partner_reset_saldo(row.id)
|
||||
//~ }
|
||||
//~ }
|
||||
//~ })
|
||||
//~ }else{
|
||||
//~ $$('cmd_partner_zero').disable()
|
||||
//~ }
|
||||
//~ }
|
||||
|
||||
|
||||
//~ function grid_partners_on_select_change(){
|
||||
//~ $$('cmd_partner_zero').enable()
|
||||
//~ }
|
||||
|
||||
|
||||
|
||||
function rfc_lost_focus(prev_view){
|
||||
//~ var form = this.getFormView()
|
||||
//~ var values = form.getValues()
|
||||
|
@ -493,3 +448,162 @@ function partner_balance_on_change(new_value, old_value){
|
|||
this.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function cmd_partner_add_account_bank_click(){
|
||||
var form = $$('form_partner_account_bank')
|
||||
|
||||
if (!form.validate()){
|
||||
msg = 'Valores inválidos'
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
|
||||
var values = form.getValues()
|
||||
var id_partner = $$('form_partner').getValues().id
|
||||
|
||||
var account = {
|
||||
id_partner: id_partner,
|
||||
delete: '-',
|
||||
banco: $$('lst_partner_bank').getText(),
|
||||
cuenta: values.partner_account.trim(),
|
||||
clabe: values.partner_clabe.trim(),
|
||||
}
|
||||
|
||||
if(!account.cuenta){
|
||||
msg = 'La cuenta es requerida'
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
|
||||
if(!account.cuenta.is_number()){
|
||||
msg = 'Solo digitos en la cuenta'
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
|
||||
if(account.cuenta.length < 9){
|
||||
msg = 'Longitud incorrecta de la cuenta'
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
|
||||
if(!account.clabe){
|
||||
msg = 'La CLABE es requerida'
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
|
||||
if(account.clabe.length != 18){
|
||||
msg = 'La CLABE debe ser de 18 digitos'
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
|
||||
if(!account.clabe.is_number()){
|
||||
msg = 'Solo digitos en la CLABE'
|
||||
msg_error(msg)
|
||||
return
|
||||
}
|
||||
|
||||
var grid = $$('grid_partner_account_bank')
|
||||
|
||||
if(id_partner){
|
||||
partner_new_account_bank(account, grid)
|
||||
}else{
|
||||
grid.add(account)
|
||||
}
|
||||
|
||||
form.setValues({})
|
||||
}
|
||||
|
||||
|
||||
function get_partner_banks(){
|
||||
webix.ajax().get('/satbancos', {opt: 'active'}, function(text, data){
|
||||
var values = data.json()
|
||||
$$('lst_partner_bank').getList().parse(values)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function partner_new_account_bank(account, grid){
|
||||
webix.ajax().post('/socioscb', {opt: 'new', values: account}, {
|
||||
error: function(text, data, xhr) {
|
||||
msg = 'Error al guardar'
|
||||
msg_error(msg)
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json()
|
||||
if(values.ok){
|
||||
account['id'] = values.id
|
||||
grid.add(account)
|
||||
msg_ok(values.msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function get_partner_accounts_bank(id_partner){
|
||||
var grid = $$('grid_partner_account_bank')
|
||||
grid.clearAll()
|
||||
|
||||
if(id_partner){
|
||||
var data = {opt: 'by_partner', id_partner: id_partner}
|
||||
webix.ajax().get('/socioscb', data, {
|
||||
error: function(text, data, xhr) {
|
||||
msg = 'Error al consultar'
|
||||
msg_error(msg)
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json()
|
||||
grid.parse(values)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function grid_partner_account_bank_click(id, e, node){
|
||||
if(id.column != 'delete'){
|
||||
return
|
||||
}
|
||||
|
||||
var msg = '¿Estás seguro de eliminar la cuenta de banco seleccionada?<BR><BR>'
|
||||
msg += 'ESTA ACCION NO SE PUEDE DESHACER'
|
||||
webix.confirm({
|
||||
title: 'Eliminar cuenta de banco',
|
||||
ok: 'Si',
|
||||
cancel: 'No',
|
||||
type: 'confirm-error',
|
||||
text: msg,
|
||||
callback:function(result){
|
||||
if (result){
|
||||
partner_delete_account_bank(id.row)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function partner_delete_account_bank(row){
|
||||
var grid = $$('grid_partner_account_bank')
|
||||
|
||||
webix.ajax().post('/socioscb', {opt: 'delete', values: {id: row}}, {
|
||||
error: function(text, data, xhr) {
|
||||
msg = 'Error al eliminar'
|
||||
msg_error(msg)
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json()
|
||||
if(values.ok){
|
||||
grid.remove(row)
|
||||
msg_ok(values.msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ function format_currency2(value){
|
|||
|
||||
|
||||
function format_currency4(value){
|
||||
return '$ ' + format_decimal_2(value)
|
||||
return '$ ' + format_decimal_4(value)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -804,7 +804,9 @@ var grid_admin_monedas_cols = [
|
|||
var grid_admin_bancos_cols = [
|
||||
{id: 'id', header: 'ID', hidden: true},
|
||||
{id: 'key', header: 'Clave', footer: {content: 'countRows', css: 'right'}},
|
||||
{id: 'name', header: 'Nombre', adjust: 'data', footer: 'Bancos'},
|
||||
{id: 'name', header: 'Nombre', footer: 'Bancos', fillspace: true},
|
||||
{id: 'razon_social', header: 'Razón Social', fillspace: true},
|
||||
{id: 'rfc', header: 'RFC', width: 125, editor: 'text'},
|
||||
{id: 'activo', header: 'Activo', template: '{common.checkbox()}',
|
||||
editor: 'checkbox'},
|
||||
]
|
||||
|
@ -851,7 +853,7 @@ var grid_admin_bancos = {
|
|||
id: 'grid_admin_bancos',
|
||||
select: 'cell',
|
||||
adjust: true,
|
||||
autowidth: true,
|
||||
editable: true,
|
||||
headermenu: true,
|
||||
footer: true,
|
||||
columns: grid_admin_bancos_cols,
|
||||
|
@ -1027,7 +1029,7 @@ var sat_bancos = [
|
|||
{maxHeight: 20},
|
||||
{cols: [{maxWidth: 15}, {view: 'label', label: msg_bancos}, {}]},
|
||||
{maxHeight: 20},
|
||||
{cols: [{maxWidth: 15}, grid_admin_bancos, {}]},
|
||||
{cols: [{maxWidth: 15}, grid_admin_bancos]},
|
||||
{maxHeight: 20},
|
||||
]
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ var grid_cfdi_este_deposito_cols = [
|
|||
{id: 'importe', header: ['Este pago'], width: 125, sort: 'int',
|
||||
format: webix.i18n.priceFormat, css: 'right', editor: 'text'},
|
||||
{id: 'type_change', header: ['T.C.'], width: 75, hidden: true,
|
||||
format: format_currency4, css: 'right', editor: 'text'},
|
||||
format: format_currency4, css: 'right'},
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -165,6 +165,50 @@ var controls_others = [
|
|||
]
|
||||
|
||||
|
||||
var grid_partner_account_bank_cols = [
|
||||
{id: 'id', header: 'ID', hidden: true},
|
||||
{id: 'delete', header: '', width: 30, css: 'delete'},
|
||||
{id: 'banco', header: 'Banco', fillspace: 1},
|
||||
{id: 'cuenta', header: 'Cuenta', fillspace: 1},
|
||||
{id: 'clabe', header: 'CLABE', fillspace: 1},
|
||||
//~ {id: 'moneda', header: 'Moneda', fillspace: 1},
|
||||
]
|
||||
|
||||
|
||||
var grid_partner_account_bank = {
|
||||
view: 'datatable',
|
||||
id: 'grid_partner_account_bank',
|
||||
select: 'row',
|
||||
adjust: true,
|
||||
autoheight: true,
|
||||
columns: grid_partner_account_bank_cols,
|
||||
}
|
||||
|
||||
|
||||
var controls_partner_bank = [
|
||||
{template: 'Agregar cuenta de banco', type: 'section'},
|
||||
{view: 'form', id: 'form_partner_account_bank', rows: [
|
||||
{cols: [
|
||||
{view: 'richselect', id: 'lst_partner_bank', name: 'partner_bank',
|
||||
label: 'Banco: ', required: true, options: []},
|
||||
{view: 'text', id: 'partner_account', name: 'partner_account',
|
||||
label: 'Cuenta: ', required: true},
|
||||
{view: 'text', id: 'partner_clabe', name: 'partner_clabe',
|
||||
label: 'CLABE: ', required: true},
|
||||
]},
|
||||
{minHeight: 10},
|
||||
{cols: [{},
|
||||
{view: 'button', id: 'cmd_partner_add_account_bank', maxWidth: 200,
|
||||
label: 'Agregar cuenta'},
|
||||
{}]},
|
||||
],
|
||||
},
|
||||
{minHeight: 20, maxHeight: 20},
|
||||
{template: 'Cuentas de banco existentes', type: 'section'},
|
||||
grid_partner_account_bank,
|
||||
{minHeight: 50},
|
||||
]
|
||||
|
||||
|
||||
var toolbar_contacts = [
|
||||
{view: 'button', id: 'cmd_new_contact', label: 'Nuevo', type: 'iconButton',
|
||||
|
@ -302,11 +346,12 @@ var controls_partner = [
|
|||
{
|
||||
view: 'tabview',
|
||||
id: 'tab_partner',
|
||||
tabbar: {options: ['Datos Fiscales', 'Otros Datos', 'Contactos']}, animate: true,
|
||||
tabbar: {ptions: ['Datos Fiscales', 'Otros Datos', 'Cuentas de Banco']},
|
||||
animate: true,
|
||||
cells: [
|
||||
{id: 'Datos Fiscales', rows: controls_fiscales},
|
||||
{id: 'Otros Datos', rows: controls_others},
|
||||
{id: 'Contactos', rows: [multi_contacts]},
|
||||
{id: 'Cuentas de Banco', rows: controls_partner_bank}
|
||||
]
|
||||
},
|
||||
{rows: [
|
||||
|
|
Loading…
Reference in New Issue