forked from elmau/empresa-libre
Refactorizar socios de negocio
This commit is contained in:
parent
009c6de608
commit
37b5b48e5b
|
@ -18,3 +18,5 @@ docs/
|
||||||
credenciales.conf
|
credenciales.conf
|
||||||
*.sqlite
|
*.sqlite
|
||||||
*.sql
|
*.sql
|
||||||
|
rfc.db
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,17 @@ class AppMain(object):
|
||||||
resp.status = falcon.HTTP_200
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
|
|
||||||
|
class AppValues(object):
|
||||||
|
|
||||||
|
def __init__(self, db):
|
||||||
|
self._db = db
|
||||||
|
|
||||||
|
def on_get(self, req, resp, table):
|
||||||
|
values = req.params
|
||||||
|
req.context['result'] = self._db.get_values(table, values)
|
||||||
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
|
|
||||||
class AppPartners(object):
|
class AppPartners(object):
|
||||||
|
|
||||||
def __init__(self, db):
|
def __init__(self, db):
|
||||||
|
|
|
@ -10,7 +10,7 @@ import uuid
|
||||||
|
|
||||||
import bcrypt
|
import bcrypt
|
||||||
|
|
||||||
from settings import log, template_lookup, PATH_CP, COMPANIES
|
from settings import log, template_lookup, COMPANIES
|
||||||
|
|
||||||
|
|
||||||
def _get_hash(password):
|
def _get_hash(password):
|
||||||
|
|
|
@ -12,7 +12,7 @@ from middleware import (
|
||||||
)
|
)
|
||||||
from models.db import StorageEngine
|
from models.db import StorageEngine
|
||||||
from controllers.main import (
|
from controllers.main import (
|
||||||
AppLogin, AppLogout, AppAdmin, AppMain,
|
AppLogin, AppLogout, AppAdmin, AppMain, AppValues
|
||||||
)
|
)
|
||||||
from settings import DEBUG
|
from settings import DEBUG
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ api.add_route('/', AppLogin(db))
|
||||||
api.add_route('/logout', AppLogout(db))
|
api.add_route('/logout', AppLogout(db))
|
||||||
api.add_route('/admin', AppAdmin(db))
|
api.add_route('/admin', AppAdmin(db))
|
||||||
api.add_route('/main', AppMain(db))
|
api.add_route('/main', AppMain(db))
|
||||||
|
api.add_route('/values/{table}', AppValues(db))
|
||||||
|
|
||||||
#~ api.add_route('/partners', partners)
|
#~ api.add_route('/partners', partners)
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,20 @@ from . import main
|
||||||
class StorageEngine(object):
|
class StorageEngine(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#~ main.conectar()
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def authenticate(self, args):
|
def authenticate(self, args):
|
||||||
#~ return main.authenticate(args['usuario'], args['contra'])
|
|
||||||
return main.authenticate(args)
|
return main.authenticate(args)
|
||||||
|
|
||||||
|
def get_values(self, table, values=None):
|
||||||
|
return getattr(self, '_get_{}'.format(table))(values)
|
||||||
|
|
||||||
|
def _get_cp(self, values):
|
||||||
|
return main.get_cp(values['cp'])
|
||||||
|
|
||||||
|
def _get_formapago(self, values):
|
||||||
|
return main.SATFormaPago.get_activos()
|
||||||
|
|
||||||
def get_partners(self, values):
|
def get_partners(self, values):
|
||||||
return main.get_partners(values)
|
return main.get_partners(values)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
||||||
from controllers import util
|
from controllers import util
|
||||||
from settings import log, VERSION, PATH_CP, COMPANIES
|
from settings import log, VERSION, PATH_CP
|
||||||
|
|
||||||
|
|
||||||
database_proxy = Proxy()
|
database_proxy = Proxy()
|
||||||
|
@ -212,6 +212,17 @@ class SATFormaPago(BaseModel):
|
||||||
(('key', 'name'), True),
|
(('key', 'name'), True),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_activos(cls):
|
||||||
|
rows = (SATFormaPago
|
||||||
|
.select(
|
||||||
|
SATFormaPago.key.alias('id'),
|
||||||
|
SATFormaPago.name.alias('value'))
|
||||||
|
.where(SATFormaPago.activo==True)
|
||||||
|
.dicts()
|
||||||
|
)
|
||||||
|
return tuple(rows)
|
||||||
|
|
||||||
|
|
||||||
class SATAduanas(BaseModel):
|
class SATAduanas(BaseModel):
|
||||||
key = TextField(unique=True, index=True)
|
key = TextField(unique=True, index=True)
|
||||||
|
@ -305,6 +316,7 @@ class Socios(BaseModel):
|
||||||
cuenta_proveedor = TextField(default='')
|
cuenta_proveedor = TextField(default='')
|
||||||
web = TextField(default='')
|
web = TextField(default='')
|
||||||
correo_facturas = TextField(default='')
|
correo_facturas = TextField(default='')
|
||||||
|
forma_pago = ForeignKeyField(SATFormaPago, null=True)
|
||||||
condicion_pago = ForeignKeyField(CondicionesPago, null=True)
|
condicion_pago = ForeignKeyField(CondicionesPago, null=True)
|
||||||
addenda = ForeignKeyField(Addendas, null=True)
|
addenda = ForeignKeyField(Addendas, null=True)
|
||||||
tags = ManyToManyField(Tags, related_name='socios_tags')
|
tags = ManyToManyField(Tags, related_name='socios_tags')
|
||||||
|
@ -605,6 +617,25 @@ def _add_emisor(rfc, args):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def _iniciar_bd():
|
||||||
|
rfc = input('Introduce el RFC: ').strip().upper()
|
||||||
|
if not rfc:
|
||||||
|
msg = 'El RFC es requerido'
|
||||||
|
log.error(msg)
|
||||||
|
return
|
||||||
|
|
||||||
|
args = util.get_con(rfc)
|
||||||
|
if not args:
|
||||||
|
return
|
||||||
|
|
||||||
|
conectar(args)
|
||||||
|
if _crear_tablas():
|
||||||
|
return
|
||||||
|
|
||||||
|
log.error('No se pudieron crear las tablas')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def _agregar_rfc():
|
def _agregar_rfc():
|
||||||
rfc = input('Introduce el nuevo RFC: ').strip().upper()
|
rfc = input('Introduce el nuevo RFC: ').strip().upper()
|
||||||
if not rfc:
|
if not rfc:
|
||||||
|
@ -641,6 +672,43 @@ def _listar_rfc():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def _importar_valores(archivo):
|
||||||
|
rfc = input('Introduce el RFC: ').strip().upper()
|
||||||
|
if not rfc:
|
||||||
|
msg = 'El RFC es requerido'
|
||||||
|
log.error(msg)
|
||||||
|
return
|
||||||
|
|
||||||
|
args = util.get_con(rfc)
|
||||||
|
if not args:
|
||||||
|
return
|
||||||
|
|
||||||
|
conectar(args)
|
||||||
|
|
||||||
|
log.info('Importando datos...')
|
||||||
|
regimen = ''
|
||||||
|
rows = util.loads(open(archivo, 'r').read())
|
||||||
|
for row in rows:
|
||||||
|
log.info('\tImportando tabla: {}'.format(row['tabla']))
|
||||||
|
if row['tabla'] == 'Emisor' and 'regimen' in row:
|
||||||
|
regimen = row['regimen']
|
||||||
|
table = globals()[row['tabla']]
|
||||||
|
for r in row['datos']:
|
||||||
|
try:
|
||||||
|
table.create(**r)
|
||||||
|
except IntegrityError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if regimen:
|
||||||
|
emisor = Emisor.select()[0]
|
||||||
|
regimen = SATRegimenes.get(SATRegimenes.key == regimen)
|
||||||
|
emisor.regimenes.clear()
|
||||||
|
emisor.regimenes.add(regimen)
|
||||||
|
|
||||||
|
log.info('Importación terminada...')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
||||||
help_create_tables = 'Crea las tablas en la base de datos'
|
help_create_tables = 'Crea las tablas en la base de datos'
|
||||||
help_migrate_db = 'Migra las tablas en la base de datos'
|
help_migrate_db = 'Migra las tablas en la base de datos'
|
||||||
|
@ -651,8 +719,8 @@ help_br = 'Elimina un RFC'
|
||||||
help_lr = 'Listar RFCs'
|
help_lr = 'Listar RFCs'
|
||||||
|
|
||||||
@click.command(context_settings=CONTEXT_SETTINGS)
|
@click.command(context_settings=CONTEXT_SETTINGS)
|
||||||
#~ @click.option('-bd', '--iniciar-bd',help=help_create_tables,
|
@click.option('-bd', '--iniciar-bd',help=help_create_tables,
|
||||||
#~ is_flag=True, default=False)
|
is_flag=True, default=False)
|
||||||
@click.option('-m', '--migrar-bd', help=help_migrate_db,
|
@click.option('-m', '--migrar-bd', help=help_migrate_db,
|
||||||
is_flag=True, default=False)
|
is_flag=True, default=False)
|
||||||
@click.option('-ns', '--nuevo-superusuario', help=help_superuser,
|
@click.option('-ns', '--nuevo-superusuario', help=help_superuser,
|
||||||
|
@ -662,13 +730,15 @@ help_lr = 'Listar RFCs'
|
||||||
@click.option('-rfc', '--rfc', help=help_rfc, is_flag=True, default=False)
|
@click.option('-rfc', '--rfc', help=help_rfc, is_flag=True, default=False)
|
||||||
@click.option('-br', '--borrar-rfc', help=help_br, is_flag=True, default=False)
|
@click.option('-br', '--borrar-rfc', help=help_br, is_flag=True, default=False)
|
||||||
@click.option('-lr', '--listar-rfc', help=help_lr, is_flag=True, default=False)
|
@click.option('-lr', '--listar-rfc', help=help_lr, is_flag=True, default=False)
|
||||||
def main(migrar_bd, nuevo_superusuario, cambiar_contraseña, rfc, borrar_rfc,
|
@click.option('-i', '--importar_valores', is_flag=True, default=False)
|
||||||
listar_rfc):
|
@click.option('-a', '--archivo')
|
||||||
|
def main(iniciar_bd, migrar_bd, nuevo_superusuario, cambiar_contraseña, rfc,
|
||||||
|
borrar_rfc, listar_rfc, importar_valores, archivo):
|
||||||
opt = locals()
|
opt = locals()
|
||||||
|
|
||||||
#~ if opt['iniciar_bd']:
|
if opt['iniciar_bd']:
|
||||||
#~ _crear_tablas()
|
_iniciar_bd()
|
||||||
#~ sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if opt['migrar_bd']:
|
if opt['migrar_bd']:
|
||||||
migrate_tables()
|
migrate_tables()
|
||||||
|
@ -694,6 +764,17 @@ def main(migrar_bd, nuevo_superusuario, cambiar_contraseña, rfc, borrar_rfc,
|
||||||
_listar_rfc()
|
_listar_rfc()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
if opt['importar_valores']:
|
||||||
|
if not opt['archivo']:
|
||||||
|
msg = 'Falta la ruta del archivo importar'
|
||||||
|
raise click.ClickException(msg)
|
||||||
|
if not util.is_file(opt['archivo']):
|
||||||
|
msg = 'No es un archivo'
|
||||||
|
raise click.ClickException(msg)
|
||||||
|
|
||||||
|
_importar_valores(opt['archivo'])
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"tabla": "Emisor",
|
||||||
|
"datos": [
|
||||||
|
{"rfc": "LAN7008173R5", "nombre": "Empresa Libre AC",
|
||||||
|
"codigo_postal": "06850", "moral": true}
|
||||||
|
],
|
||||||
|
"regimen": "603"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tabla": "SATImpuestos",
|
||||||
|
"datos": [
|
||||||
|
{"key": "002", "name": "IVA", "tasa": 0.16, "activo": true, "default": true},
|
||||||
|
{"key": "001", "name": "ISR", "tasa": 0.10, "tipo": "R", "activo": false},
|
||||||
|
{"key": "002", "name": "IVA", "tasa": 0.0, "activo": false},
|
||||||
|
{"key": "002", "name": "IVA", "tasa": 0.10, "tipo": "R", "activo": false},
|
||||||
|
{"key": "002", "name": "IVA", "tasa": 0.666667, "tipo": "R", "activo": false},
|
||||||
|
{"key": "000", "name": "Exento", "tipo": "E", "factor": "E", "activo": false}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tabla": "SATUnidades",
|
||||||
|
"datos": [
|
||||||
|
{"key": "HUR", "name": "Hora", "activo": true},
|
||||||
|
{"key": "H87", "name": "Pieza", "activo": true},
|
||||||
|
{"key": "E48", "name": "Servicio", "activo": true},
|
||||||
|
{"key": "E51", "name": "Trabajo", "activo": false}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tabla": "SATMonedas",
|
||||||
|
"datos": [
|
||||||
|
{"key": "MXN", "name": "Peso Mexicano", "activo": true, "default": true},
|
||||||
|
{"key": "USD", "name": "Dólar americano", "activo": false},
|
||||||
|
{"key": "EUR", "name": "Euro", "activo": false}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tabla": "Folios",
|
||||||
|
"datos": [
|
||||||
|
{"serie": "F", "inicio": 1, "default": true}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tabla": "SATFormaPago",
|
||||||
|
"datos": [
|
||||||
|
{"key": "01", "name": "Efectivo", "activo": true},
|
||||||
|
{"key": "02", "name": "Cheque nominativo", "activo": true},
|
||||||
|
{"key": "03", "name": "Transferencia electrónica de fondos", "activo": true, "default": true},
|
||||||
|
{"key": "04", "name": "Tarjeta de crédito", "activo": true},
|
||||||
|
{"key": "05", "name": "Monedero electrónico", "activo": false},
|
||||||
|
{"key": "06", "name": "Dinero electrónico", "activo": false},
|
||||||
|
{"key": "08", "name": "Vales de despensa", "activo": false},
|
||||||
|
{"key": "12", "name": "Dación en pago", "activo": false},
|
||||||
|
{"key": "13", "name": "Pago por subrogación", "activo": false},
|
||||||
|
{"key": "14", "name": "Pago por consignación", "activo": false},
|
||||||
|
{"key": "15", "name": "Condonación", "activo": false},
|
||||||
|
{"key": "17", "name": "Compensación", "activo": false},
|
||||||
|
{"key": "23", "name": "Novación", "activo": false},
|
||||||
|
{"key": "24", "name": "Confusión", "activo": false},
|
||||||
|
{"key": "25", "name": "Remisión de deuda", "activo": false},
|
||||||
|
{"key": "26", "name": "Prescripción o caducidad", "activo": false},
|
||||||
|
{"key": "27", "name": "A satisfacción del acreedor", "activo": false},
|
||||||
|
{"key": "28", "name": "Tarjeta de débito", "activo": true},
|
||||||
|
{"key": "29", "name": "Tarjeta de servicios", "activo": false},
|
||||||
|
{"key": "30", "name": "Aplicación de anticipos", "activo": false},
|
||||||
|
{"key": "99", "name": "Por definir", "activo": true}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tabla": "SATRegimenes",
|
||||||
|
"datos": [
|
||||||
|
{"key": "601", "name": "General de Ley Personas Morales", "moral": true, "activo": true},
|
||||||
|
{"key": "603", "name": "Personas Morales con Fines no Lucrativos", "moral": true, "activo": true},
|
||||||
|
{"key": "605", "name": "Sueldos y Salarios e Ingresos Asimilados a Salarios", "fisica": true, "activo": true},
|
||||||
|
{"key": "606", "name": "Arrendamiento", "fisica": true, "activo": true},
|
||||||
|
{"key": "608", "name": "Demás ingresos", "fisica": true, "activo": false},
|
||||||
|
{"key": "609", "name": "Consolidación", "moral": true, "activo": false},
|
||||||
|
{"key": "610", "name": "Residentes en el Extranjero sin Establecimiento Permanente en México", "fisica": true, "moral": true, "activo": false},
|
||||||
|
{"key": "611", "name": "Ingresos por Dividendos (socios y accionistas)", "fisica": true, "activo": false},
|
||||||
|
{"key": "612", "name": "Personas Físicas con Actividades Empresariales y Profesionales", "fisica": true, "activo": true},
|
||||||
|
{"key": "614", "name": "Ingresos por intereses", "fisica": true, "activo": false},
|
||||||
|
{"key": "616", "name": "Sin obligaciones fiscales", "fisica": true, "activo": false},
|
||||||
|
{"key": "620", "name": "Sociedades Cooperativas de Producción que optan por diferir sus ingresos", "moral": true, "activo": false},
|
||||||
|
{"key": "621", "name": "Incorporación Fiscal", "fisica": true, "activo": true},
|
||||||
|
{"key": "622", "name": "Actividades Agrícolas, Ganaderas, Silvícolas y Pesqueras", "fisica": true, "moral": true, "activo": false},
|
||||||
|
{"key": "623", "name": "Opcional para Grupos de Sociedades", "moral": true, "activo": false},
|
||||||
|
{"key": "624", "name": "Coordinados", "moral": true, "activo": false},
|
||||||
|
{"key": "628", "name": "Hidrocarburos", "moral": true, "activo": false},
|
||||||
|
{"key": "607", "name": "Régimen de Enajenación o Adquisición de Bienes", "moral": true, "activo": false},
|
||||||
|
{"key": "629", "name": "De los Regímenes Fiscales Preferentes y de las Empresas Multinacionales", "fisica": true, "activo": false},
|
||||||
|
{"key": "630", "name": "Enajenación de acciones en bolsa de valores", "fisica": true, "activo": false},
|
||||||
|
{"key": "615", "name": "Régimen de los ingresos por obtención de premios", "fisica": true, "activo": false}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tabla": "SATUsoCfdi",
|
||||||
|
"datos": [
|
||||||
|
{"key": "G01", "name": "Adquisición de mercancias", "moral": true, "activo": true},
|
||||||
|
{"key": "G02", "name": "Devoluciones, descuentos o bonificaciones", "moral": true, "activo": true},
|
||||||
|
{"key": "G03", "name": "Gastos en general", "moral": true, "activo": true, "default": true},
|
||||||
|
{"key": "I01", "name": "Construcciones", "moral": true, "activo": false},
|
||||||
|
{"key": "I02", "name": "Mobilario y equipo de oficina por inversiones", "moral": true, "activo": false},
|
||||||
|
{"key": "I03", "name": "Equipo de transporte", "moral": true, "activo": false},
|
||||||
|
{"key": "I04", "name": "Equipo de computo y accesorios", "moral": true, "activo": false},
|
||||||
|
{"key": "I05", "name": "Dados, troqueles, moldes, matrices y herramental", "moral": true, "activo": false},
|
||||||
|
{"key": "I06", "name": "Comunicaciones telefónicas", "moral": true, "activo": false},
|
||||||
|
{"key": "I07", "name": "Comunicaciones satelitales", "moral": true, "activo": false},
|
||||||
|
{"key": "I08", "name": "Otra maquinaria y equipo", "moral": true, "activo": false},
|
||||||
|
{"key": "D01", "name": "Honorarios médicos, dentales y gastos hospitalarios.", "activo": false},
|
||||||
|
{"key": "D02", "name": "Gastos médicos por incapacidad o discapacidad", "activo": false},
|
||||||
|
{"key": "D03", "name": "Gastos funerales.", "activo": false},
|
||||||
|
{"key": "D04", "name": "Donativos.", "activo": true},
|
||||||
|
{"key": "D05", "name": "Intereses reales efectivamente pagados por créditos hipotecarios (casa habitación).", "activo": false},
|
||||||
|
{"key": "D06", "name": "Aportaciones voluntarias al SAR.", "activo": false},
|
||||||
|
{"key": "D07", "name": "Primas por seguros de gastos médicos.", "activo": false},
|
||||||
|
{"key": "D08", "name": "Gastos de transportación escolar obligatoria.", "activo": false},
|
||||||
|
{"key": "D09", "name": "Depósitos en cuentas para el ahorro, primas que tengan como base planes de pensiones.", "activo": false},
|
||||||
|
{"key": "D10", "name": "Pagos por servicios educativos (colegiaturas)", "activo": true},
|
||||||
|
{"key": "P01", "name": "Por definir", "moral": true, "activo": true}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
|
@ -1,3 +1,7 @@
|
||||||
|
var PUBLICO = "Público en general";
|
||||||
|
var RFC_PUBLICO = "XAXX010101000";
|
||||||
|
var RFC_EXTRANJERO = "XEXX010101000";
|
||||||
|
var PAIS = "México";
|
||||||
|
|
||||||
|
|
||||||
var controllers = {
|
var controllers = {
|
||||||
|
@ -12,10 +16,13 @@ var controllers = {
|
||||||
$$('cmd_save_partner').attachEvent('onItemClick', cmd_save_partner_click);
|
$$('cmd_save_partner').attachEvent('onItemClick', cmd_save_partner_click);
|
||||||
$$('cmd_cancel_partner').attachEvent('onItemClick', cmd_cancel_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);
|
||||||
//~ $$('grid_partners').attachEvent('onItemClick', grid_partners_click);
|
$$('codigo_postal').attachEvent('onKeyPress', postal_code_key_press);
|
||||||
$$('postal_code').attachEvent('onKeyPress', postal_code_key_press);
|
$$('codigo_postal').attachEvent('onTimedKeyPress', postal_code_key_up);
|
||||||
$$('postal_code').attachEvent('onTimedKeyPress', postal_code_key_up);
|
|
||||||
$$('colonia').attachEvent('onFocus', colonia_on_focus)
|
$$('colonia').attachEvent('onFocus', colonia_on_focus)
|
||||||
|
$$("tipo_persona").attachEvent( "onChange", opt_tipo_change)
|
||||||
|
$$("es_cliente").attachEvent( "onChange", is_client_change)
|
||||||
|
$$("es_proveedor").attachEvent( "onChange", is_supplier_change)
|
||||||
|
$$("rfc").attachEvent( "onBlur", rfc_lost_focus)
|
||||||
//~ Products
|
//~ Products
|
||||||
$$("cmd_new_product").attachEvent("onItemClick", cmd_new_product_click);
|
$$("cmd_new_product").attachEvent("onItemClick", cmd_new_product_click);
|
||||||
$$("cmd_edit_product").attachEvent("onItemClick", cmd_edit_product_click);
|
$$("cmd_edit_product").attachEvent("onItemClick", cmd_edit_product_click);
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
function cmd_new_partner_click(id, e, node){
|
function cmd_new_partner_click(id, e, node){
|
||||||
$$('form_partner').setValues({
|
$$('form_partner').setValues({
|
||||||
id: 0, country: 'México', person_type: 1, is_active: true})
|
id: 0, pais: 'México', tipo_persona: 1, es_activo: true})
|
||||||
|
$$('forma_pago').getList().load('/values/formapago')
|
||||||
$$('grid_partners').clearSelection()
|
$$('grid_partners').clearSelection()
|
||||||
$$('multi_partners').setValue('partners_new')
|
$$('multi_partners').setValue('partners_new')
|
||||||
};
|
};
|
||||||
|
@ -129,7 +130,7 @@ function postal_code_key_up(){
|
||||||
var value = this.getValue()
|
var value = this.getValue()
|
||||||
var msg = ''
|
var msg = ''
|
||||||
if( value.length == 5 ){
|
if( value.length == 5 ){
|
||||||
webix.ajax().get('/pc', {cp:value}, {
|
webix.ajax().get('/values/cp', {cp: value}, {
|
||||||
error: function(text, data, xhr) {
|
error: function(text, data, xhr) {
|
||||||
webix.message({type:'error', text:'Error al consultar el C.P.'})
|
webix.message({type:'error', text:'Error al consultar el C.P.'})
|
||||||
},
|
},
|
||||||
|
@ -140,14 +141,14 @@ function postal_code_key_up(){
|
||||||
webix.message({type:'error', text:msg})
|
webix.message({type:'error', text:msg})
|
||||||
} else {
|
} else {
|
||||||
$$('form_partner').setValues({
|
$$('form_partner').setValues({
|
||||||
state:values.estado,
|
estado: values.estado,
|
||||||
municipio: values.municipio,
|
municipio: values.municipio,
|
||||||
colonia:''}, true)
|
colonia: ''}, true)
|
||||||
$$('colonia').define('suggest', [])
|
$$('colonia').define('suggest', [])
|
||||||
if (webix.isArray(values.colonia)){
|
if (webix.isArray(values.colonia)){
|
||||||
$$('colonia').define('suggest', values.colonia)
|
$$('colonia').define('suggest', values.colonia)
|
||||||
}else{
|
}else{
|
||||||
$$('form_partner').setValues({colonia:values.colonia}, true)
|
$$('form_partner').setValues({colonia: values.colonia}, true)
|
||||||
}
|
}
|
||||||
$$('colonia').refresh()
|
$$('colonia').refresh()
|
||||||
$$('form_partner').focus('colonia')
|
$$('form_partner').focus('colonia')
|
||||||
|
@ -175,3 +176,90 @@ function colonia_on_focus(){
|
||||||
$$(this.config.suggest).show(this.getInputNode())
|
$$(this.config.suggest).show(this.getInputNode())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function opt_tipo_change(new_value, old_value){
|
||||||
|
|
||||||
|
$$("nombre").define("value", "")
|
||||||
|
$$("pais").define("readonly", true)
|
||||||
|
$$("pais").define("value", PAIS)
|
||||||
|
|
||||||
|
if (new_value == 1 || new_value == 2){
|
||||||
|
$$("rfc").define("value", "");
|
||||||
|
$$("rfc").define("readonly", false);
|
||||||
|
} else if (new_value == 3) {
|
||||||
|
$$("rfc").define("value", RFC_PUBLICO);
|
||||||
|
$$("nombre").define("value", PUBLICO);
|
||||||
|
$$("rfc").define("readonly", true);
|
||||||
|
} else if (new_value == 4) {
|
||||||
|
$$("rfc").define("value", RFC_EXTRANJERO);
|
||||||
|
$$("rfc").define("readonly", true);
|
||||||
|
$$("pais").define("readonly", false);
|
||||||
|
$$("pais").define("value", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
$$("nombre").refresh();
|
||||||
|
$$("rfc").refresh();
|
||||||
|
$$("pais").refresh();
|
||||||
|
if (new_value == 3) {
|
||||||
|
$$("calle").focus();
|
||||||
|
} else {
|
||||||
|
$$("rfc").focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function is_client_change(new_value, old_value){
|
||||||
|
var value = Boolean(new_value)
|
||||||
|
if (value){
|
||||||
|
$$("cuenta_cliente").enable();
|
||||||
|
} else {
|
||||||
|
$$("cuenta_cliente").disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function is_supplier_change(new_value, old_value){
|
||||||
|
var value = Boolean(new_value)
|
||||||
|
if (value){
|
||||||
|
$$("cuenta_proveedor").enable();
|
||||||
|
} else {
|
||||||
|
$$("cuenta_proveedor").disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rfc_lost_focus(prev_view){
|
||||||
|
//~ var form = this.getFormView()
|
||||||
|
//~ var values = form.getValues()
|
||||||
|
|
||||||
|
//~ if (values.rfc.trim() == ""){
|
||||||
|
//~ return
|
||||||
|
//~ }
|
||||||
|
|
||||||
|
//~ if (values.id == undefined){
|
||||||
|
//~ exclude = ''
|
||||||
|
//~ } else {
|
||||||
|
//~ exclude = {'id': values.id}
|
||||||
|
//~ }
|
||||||
|
|
||||||
|
//~ values = {
|
||||||
|
//~ 'table': 'partner',
|
||||||
|
//~ 'filter': {'rfc': values.rfc.trim().toUpperCase()},
|
||||||
|
//~ 'exclude': exclude,
|
||||||
|
//~ }
|
||||||
|
//~ webix.message(values)
|
||||||
|
//~ webix.ajax().get("/values/validate", values, {
|
||||||
|
//~ error:function(text, data, XmlHttpRequest){
|
||||||
|
//~ msg = "No se pudo validar el RFC"
|
||||||
|
//~ webix.message({ type:"error", text: msg });
|
||||||
|
//~ },
|
||||||
|
//~ success:function(text, data, XmlHttpRequest){
|
||||||
|
//~ var values = data.json();
|
||||||
|
//~ if (values.exists) {
|
||||||
|
//~ msg = "El RFC ya existe"
|
||||||
|
//~ webix.message({ type:"error", text: msg });
|
||||||
|
//~ }
|
||||||
|
//~ }
|
||||||
|
//~ })
|
||||||
|
}
|
||||||
|
|
|
@ -14,29 +14,22 @@ function validate_rfc(value){
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rfc.length < 12 || rfc.length > 13){
|
var tipo_persona = $$('tipo_persona').getValue()
|
||||||
|
var length = 13
|
||||||
|
var start = 4
|
||||||
|
if(tipo_persona==2){
|
||||||
|
length = 12
|
||||||
|
start = 2
|
||||||
|
}
|
||||||
|
if (rfc.length != length){
|
||||||
webix.message({ type:"error", text:"Longitud incorrecta del RFC" });
|
webix.message({ type:"error", text:"Longitud incorrecta del RFC" });
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if (tipo_persona < 3 && (rfc == RFC_PUBLICO || rfc == RFC_EXTRANJERO)){
|
||||||
var start = 4;
|
webix.message({ type:"error", text:"RFC incorrecto" });
|
||||||
//~ var tipo = $$("opt_tipo").getValue();
|
return false
|
||||||
//~ if (tipo == 1 && value.length != 13){
|
|
||||||
//~ webix.message({ type:"error", text:"RFC debe ser de 13 caracteres" });
|
|
||||||
//~ return false
|
|
||||||
//~ }
|
|
||||||
//~ if (tipo == 2 && value.length != 12){
|
|
||||||
//~ webix.message({ type:"error", text:"RFC debe ser de 12 caracteres" });
|
|
||||||
//~ return false
|
|
||||||
//~ }
|
|
||||||
//~ var tipo = 1;
|
|
||||||
//~ if (tipo == 2){
|
|
||||||
//~ start = 3;
|
|
||||||
//~ }
|
|
||||||
//~ var rfc = value.toUpperCase();
|
|
||||||
if (rfc.length == 12){
|
|
||||||
start = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var part = rfc.slice(0, start);
|
var part = rfc.slice(0, start);
|
||||||
var re = new RegExp('[a-z&Ñ]{' + start + '}', 'i');
|
var re = new RegExp('[a-z&Ñ]{' + start + '}', 'i');
|
||||||
if (!part.match(re)){
|
if (!part.match(re)){
|
||||||
|
|
|
@ -54,65 +54,69 @@ var persons_type = [
|
||||||
|
|
||||||
var controls_fiscales = [
|
var controls_fiscales = [
|
||||||
{template: 'Tipo de Persona', type: 'section'},
|
{template: 'Tipo de Persona', type: 'section'},
|
||||||
{view: 'radio', name: 'person_type', label: 'Tipos: ',
|
{view: 'radio', id: 'tipo_persona', name: 'tipo_persona', label: 'Tipos: ',
|
||||||
labelWidth: 150, value: 1, options: persons_type, required: true,
|
labelWidth: 150, value: 1, options: persons_type, required: true,
|
||||||
invalidMessage: 'El Tipo de Persona es requerido'},
|
invalidMessage: 'El Tipo de Persona es requerido'},
|
||||||
{template: 'Dirección Fiscal', type: 'section'},
|
{template: 'Dirección Fiscal', type: 'section'},
|
||||||
{cols: [{view: 'text', id: 'rfc', name: 'rfc', label: 'RFC: ', width: 300,
|
{cols: [{view: 'text', id: 'rfc', name: 'rfc', label: 'RFC: ', width: 300,
|
||||||
required: true, invalidMessage: 'RFC inválido', attributes: {maxlength: 13}},{}]},
|
required: true, invalidMessage: 'RFC inválido', attributes: {maxlength: 13}},{}]},
|
||||||
{view: 'text', id: 'name', name: 'name', label: 'Razón Social: ', required: true,
|
{view: 'text', id: 'nombre', name: 'nombre', label: 'Razón Social: ', required: true,
|
||||||
invalidMessage: 'La Razón Social es requerida'},
|
invalidMessage: 'La Razón Social es requerida'},
|
||||||
{view: 'text', id: 'street', name: 'street', label: 'Calle: '},
|
{view: 'text', id: 'calle', name: 'calle', label: 'Calle: '},
|
||||||
{cols: [{view: 'text', id: 'num_ext', name: 'num_ext', width: 300,
|
{cols: [{view: 'text', id: 'no_exterior', name: 'no_exterior', width: 300,
|
||||||
label: 'No Exterior: '},{}]},
|
label: 'No Exterior: '},{}]},
|
||||||
{cols: [{view: 'text', id: 'num_int', name: 'num_int', width: 300,
|
{cols: [{view: 'text', id: 'no_interior', name: 'no_interior', width: 300,
|
||||||
label: 'No Interior: '},{}]},
|
label: 'No Interior: '},{}]},
|
||||||
{cols: [{view: 'search', id: 'postal_code', name: 'postal_code', width: 300,
|
{cols: [{view: 'search', id: 'codigo_postal', name: 'codigo_postal',
|
||||||
label: 'C.P.: ', attributes: {maxlength: 5}},{}]},
|
width: 300, label: 'C.P.: ', attributes: {maxlength: 5}},{}]},
|
||||||
{view: 'text', id: 'colonia', name: 'colonia', label: 'Colonia: '},
|
{view: 'text', id: 'colonia', name: 'colonia', label: 'Colonia: '},
|
||||||
{view: 'text', id: 'municipio', name: 'municipio', label: 'Municipio: '},
|
{view: 'text', id: 'municipio', name: 'municipio', label: 'Municipio: '},
|
||||||
{view: 'text', id: 'state', name: 'state', label: 'Estado: '},
|
{view: 'text', id: 'estado', name: 'estado', label: 'Estado: '},
|
||||||
{view: 'text', id: 'country', name: 'country', label: 'País: ',
|
{view: 'text', id: 'pais', name: 'pais', label: 'País: ',
|
||||||
value: 'México', readonly: true},
|
value: 'México', readonly: true},
|
||||||
{template: 'Condiciones Comerciales', type: 'section'},
|
{template: 'Condiciones Comerciales', type: 'section'},
|
||||||
{cols: [
|
{cols: [
|
||||||
{view: 'combo', id: 'form_pay', name: 'form_pay',
|
{view: 'richselect', id: 'forma_pago', name: 'forma_pago',
|
||||||
label: 'Forma de Pago: ', editable: false, required: true},
|
label: 'Forma de Pago: ', required: true, options: [],
|
||||||
{view: 'combo', id: 'conditions_pay', name: 'conditions_pay',
|
invalidMessage: 'La Forma de pago es requerida'},
|
||||||
|
{view: 'text', id: 'condicion_pago', name: 'condicion_pago',
|
||||||
label: 'Condiciones de Pago: '},
|
label: 'Condiciones de Pago: '},
|
||||||
]},
|
]},
|
||||||
{cols: [
|
{cols: [
|
||||||
{view: 'counter', name: 'days_pay', label: 'Días de pago', step:5, value: 0, min: 0,
|
{view: 'counter', name: 'dias_pago', label: 'Días de pago', step:5,
|
||||||
max: 365, tooltip: 'Permite calcular las fechas de pago'},
|
value: 0, min: 0, max: 365, tooltip: 'Permite calcular las fechas de pago'},
|
||||||
{view: 'checkbox', id: 'business_days', name: 'business_days',
|
{view: 'checkbox', id: 'chk_business_days', name: 'dias_habiles',
|
||||||
label: 'Hábiles: ', value: false},
|
label: 'Hábiles: ', value: false},
|
||||||
]}
|
]}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
var controls_others = [
|
var controls_others = [
|
||||||
{view: 'checkbox', id: 'is_active', name: 'is_active', label: 'Activo: ',
|
{view: 'checkbox', id: 'es_activo', name: 'es_activo', label: 'Activo: ',
|
||||||
value: true, bottomLabel: ' Se recomienda solo desactivar y no eliminar'},
|
value: true, bottomLabel: ' Se recomienda solo desactivar y no eliminar'},
|
||||||
{view: 'text', id: 'commercial_name', name: 'commercial_name', label: 'Nombre Comercial: '},
|
{view: 'text', id: 'commercial_name', name: 'nombre_comercial',
|
||||||
{view: 'text', id: 'phones', name: 'phones', label: 'Teléfonos: '},
|
label: 'Nombre Comercial: '},
|
||||||
{view: 'text', id: 'web_page', name: 'web_page', label: 'Página Web: '},
|
{view: 'text', id: 'telefonos', name: 'telefonos', label: 'Teléfonos: '},
|
||||||
{view: 'text', id: 'invoice_email', name: 'invoice_email',
|
{view: 'text', id: 'web', name: 'web', label: 'Página Web: '},
|
||||||
label: 'Correos para Facturas: ', tooltip: 'Separados por comas'},
|
{view: 'text', id: 'correo_facturas', name: 'correo_facturas',
|
||||||
|
label: 'Correos para Facturas: ', tooltip: 'Separados por comas',
|
||||||
|
bottomLabel: 'Uno o más correos electrónicos separados por comas'},
|
||||||
{cols: [
|
{cols: [
|
||||||
{view: 'checkbox', id: 'is_client', name: 'is_client',
|
{view: 'checkbox', id: 'es_cliente', name: 'es_cliente',
|
||||||
label: 'Es Cliente: ', value: true, width: 180},
|
label: 'Es Cliente: ', value: true, width: 180},
|
||||||
{view: 'text', id: 'account_client', name: 'account_client',
|
{view: 'text', id: 'cuenta_cliente', name: 'cuenta_cliente',
|
||||||
label: 'Cuenta Cliente: ', disabled: true}, {}]
|
label: 'Cuenta Cliente: ', disabled: true}, {}]
|
||||||
},
|
},
|
||||||
{cols: [
|
{cols: [
|
||||||
{view: 'checkbox', id: 'is_supplier', name: 'is_supplier',
|
{view: 'checkbox', id: 'es_proveedor', name: 'es_proveedor',
|
||||||
label: 'Es Proveedor: ', value: false, width: 180},
|
label: 'Es Proveedor: ', value: false, width: 180},
|
||||||
{view: 'text', id: 'account_supplier', name: 'account_supplier',
|
{view: 'text', id: 'cuenta_proveedor', name: 'cuenta_proveedor',
|
||||||
label: 'Cuenta Proveedor: ', disabled: true}, {}]
|
label: 'Cuenta Proveedor: ', disabled: true}, {}]
|
||||||
},
|
},
|
||||||
{view: 'checkbox', name: 'is_ong', label: 'Es ONG: ', value: false},
|
{view: 'checkbox', name: 'es_ong', label: 'Es ONG: ', value: false},
|
||||||
{view: 'text', name: 'tags', label: 'Etiquetas', tooltip: 'Utiles para filtrados rápidos. Separa por comas.'},
|
{view: 'text', name: 'tags', label: 'Etiquetas',
|
||||||
{view: 'textarea' , height: 200, name: 'notes', label: 'Notas'},
|
tooltip: 'Utiles para filtrados rápidos. Separa por comas.'},
|
||||||
|
{view: 'textarea' , height: 200, name: 'notas', label: 'Notas'},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,7 +287,7 @@ var form_partner = {
|
||||||
},
|
},
|
||||||
autoheight: true,
|
autoheight: true,
|
||||||
rules: {
|
rules: {
|
||||||
name: function(value){ return value.trim() != '';},
|
nombre: function(value){ return value.trim() != '';},
|
||||||
rfc: validate_rfc,
|
rfc: validate_rfc,
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
Loading…
Reference in New Issue