Validar y filtrar CFDI de anticipo
This commit is contained in:
parent
582e318dae
commit
ff5f98f187
|
@ -1599,12 +1599,14 @@ class Facturas(BaseModel):
|
|||
else:
|
||||
f_ids = (Facturas.id > 0)
|
||||
|
||||
filters = (fy & fm & cliente & f_ids)
|
||||
if folios:
|
||||
filters = (fy & fm & folios & cliente & f_ids)
|
||||
filters = filters & folios
|
||||
elif uuid:
|
||||
filters = (fy & fm & f_uuid & cliente & f_ids)
|
||||
else:
|
||||
filters = (fy & fm & cliente & f_ids)
|
||||
filters = filters & f_uuid
|
||||
|
||||
if values['anticipo'] == '1':
|
||||
filters = filters & (Facturas.anticipo == True)
|
||||
|
||||
rows = tuple(Facturas
|
||||
.select(Facturas.id, Facturas.serie, Facturas.folio,
|
||||
|
@ -1770,6 +1772,7 @@ class Facturas(BaseModel):
|
|||
values['folio'] = cls._get_folio(cls, values['serie'])
|
||||
values['tipo_cambio'] = float(values['tipo_cambio'])
|
||||
values['lugar_expedicion'] = emisor.cp_expedicion or emisor.codigo_postal
|
||||
values['anticipo'] = util.get_bool(values['anticipo'])
|
||||
|
||||
with database_proxy.atomic() as txn:
|
||||
obj = Facturas.create(**values)
|
||||
|
|
|
@ -3,6 +3,7 @@ var grid = null
|
|||
var msg = ''
|
||||
var result = false
|
||||
var tipo_relacion = ''
|
||||
var anticipo = false
|
||||
|
||||
|
||||
function get_condicion_pago(){
|
||||
|
@ -244,6 +245,29 @@ function validate_invoice(values){
|
|||
return false
|
||||
}
|
||||
|
||||
anticipo = $$('chk_cfdi_anticipo').getValue()
|
||||
if(anticipo){
|
||||
var mp = $$('lst_metodo_pago').getValue()
|
||||
if(mp != 'PUE'){
|
||||
msg = 'En anticipos, el método de pago debe ser: Pago en una sola exhibición'
|
||||
msg_error(msg)
|
||||
return false
|
||||
}
|
||||
|
||||
if(grid.count() != 1){
|
||||
msg = 'Los anticipos solo llevan un concepto'
|
||||
msg_error(msg)
|
||||
return false
|
||||
}
|
||||
|
||||
query = table_relaciones.chain().data()
|
||||
if(query.length > 0){
|
||||
msg = 'Los anticipos no deben llevar CFDI relacionados'
|
||||
msg_error(msg)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -373,6 +397,7 @@ function guardar_y_timbrar(values){
|
|||
data['regimen_fiscal'] = $$('lst_regimen_fiscal').getValue()
|
||||
data['relacionados'] = ids
|
||||
data['tipo_relacion'] = tipo_relacion
|
||||
data['anticipo'] = anticipo
|
||||
|
||||
if(!save_invoice(data)){
|
||||
return
|
||||
|
@ -380,6 +405,7 @@ function guardar_y_timbrar(values){
|
|||
|
||||
table_relaciones.clear()
|
||||
tipo_relacion = ''
|
||||
anticipo = false
|
||||
$$('form_invoice').setValues({id_partner: 0, lbl_partner: 'Ninguno'})
|
||||
$$('multi_invoices').setValue('invoices_home')
|
||||
|
||||
|
@ -404,6 +430,9 @@ function cmd_timbrar_click(id, e, node){
|
|||
if(query.length > 0){
|
||||
msg += 'La factura tiene CFDI relacionados<BR><BR>'
|
||||
}
|
||||
if(anticipo){
|
||||
msg += 'La factura es Anticipo<BR><BR>'
|
||||
}
|
||||
msg += '¿Estás seguro de timbrar esta factura?'
|
||||
|
||||
webix.confirm({
|
||||
|
@ -1201,6 +1230,7 @@ function get_facturas_por_cliente(){
|
|||
'month': m,
|
||||
'id_cliente': id,
|
||||
'cfdis': ids,
|
||||
'anticipo': $$('chk_relacionados_anticipo').getValue(),
|
||||
'folio': $$('filter_cfdi_folio').getValue(),
|
||||
'uuid': $$('filter_cfdi_uuid').getValue(),
|
||||
'opt': 'relacionados'
|
||||
|
@ -1320,3 +1350,15 @@ function filter_cfdi_month_change(nv, ov){
|
|||
cmd_filter_relacionados_click()
|
||||
}
|
||||
|
||||
|
||||
function lst_tipo_relacion_change(nv, ov){
|
||||
$$('chk_relacionados_anticipo').setValue(0)
|
||||
$$('chk_relacionados_anticipo').disable()
|
||||
if(nv=='07'){
|
||||
$$('chk_relacionados_anticipo').enable()
|
||||
$$('chk_relacionados_anticipo').setValue(1)
|
||||
cmd_filter_relacionados_click()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ var emisor_cuentas_banco = [
|
|||
{view: 'currency', type: 'text', id: 'emisor_cuenta_saldo_inicial',
|
||||
name: 'emisor_cuenta_saldo_inicial', label: 'Saldo inicial',
|
||||
required: true, invalidMessage: 'Captura un valor númerico',
|
||||
inputAlign: 'right', value: 0},
|
||||
inputAlign: 'right', value: ''},
|
||||
]},
|
||||
{minHeight: 10},
|
||||
{cols: [{}, {view: 'button', id: 'cmd_emisor_agregar_cuenta',
|
||||
|
|
|
@ -97,8 +97,11 @@ var body_cfdi_relacionados = {rows: [
|
|||
{view: 'label', id: 'lbl_cfdi_title', label: 'Cliente: ',
|
||||
autowidth: true},
|
||||
{view: 'label', id: 'lbl_cfdi_cliente', label: '', align: 'left'}]},
|
||||
{view: 'richselect', id: 'lst_tipo_relacion', label: 'Tipo de Relación',
|
||||
labelWidth: 150, required: true, options: []},
|
||||
{cols: [
|
||||
{view: 'richselect', id: 'lst_tipo_relacion', label: 'Tipo de Relación',
|
||||
labelWidth: 140, required: true, options: []},
|
||||
{view: 'checkbox', id: 'chk_relacionados_anticipo',
|
||||
labelRight: 'Solo Anticipos', width: 200, disabled: true}]},
|
||||
{minHeight: 10, maxHeight: 10},
|
||||
{cols: [
|
||||
{view: 'richselect', id: 'filter_cfdi_year', label: 'Año', width: 100,
|
||||
|
@ -145,7 +148,8 @@ var ui_invoice = {
|
|||
$$('cmd_guardar_relacionados').attachEvent('onItemClick', cmd_guardar_relacionados_click)
|
||||
$$('cmd_limpiar_relacionados').attachEvent('onItemClick', cmd_limpiar_relacionados_click)
|
||||
$$('cmd_filter_relacionados').attachEvent('onItemClick', cmd_filter_relacionados_click)
|
||||
$$('filter_cfdi_year').attachEvent('onChange', filter_cfdi_year_change)
|
||||
$$('lst_tipo_relacion').attachEvent('onChange', lst_tipo_relacion_change)
|
||||
$$('filter_cfdi_month').attachEvent('onChange', filter_cfdi_month_change)
|
||||
$$('filter_cfdi_month').attachEvent('onChange', filter_cfdi_month_change)
|
||||
}}
|
||||
|
||||
|
@ -175,6 +179,7 @@ var toolbar_invoices_util = [
|
|||
var toolbar_invoices_generate = {view: 'toolbar', elements: [{},
|
||||
{view: 'button', id: 'cmd_cfdi_relacionados', label: 'CFDI Relacionados',
|
||||
type: 'iconButton', autowidth: true, icon: 'file-o'},
|
||||
{view: 'checkbox', id: 'chk_cfdi_anticipo', label: 'Es Anticipo', width: 100},
|
||||
]}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue