Fix global invoice
This commit is contained in:
commit
bd7a31ea8a
|
@ -1106,3 +1106,11 @@ def get_qr(data, kind='svg', in_base64=False):
|
|||
if in_base64:
|
||||
qr = base64.b64encode(qr.getvalue()).decode()
|
||||
return qr
|
||||
|
||||
|
||||
def to_date(value):
|
||||
t = now().time()
|
||||
d = datetime.datetime.strptime(value.split(' ')[0], '%Y-%m-%d')
|
||||
dt = datetime.datetime.combine(d, t)
|
||||
return dt
|
||||
|
||||
|
|
|
@ -324,7 +324,7 @@ def config_main(user):
|
|||
'timbres': 0,
|
||||
'decimales_precios': DECIMALES,
|
||||
'pagos': Configuracion.get_bool('chk_config_pagos'),
|
||||
'pays_data_bank': Configuracion.get_bool('chk_cfg_pays_data_bank')
|
||||
'pays_data_bank': Configuracion.get_bool('chk_cfg_pays_data_bank'),
|
||||
}
|
||||
dp = Configuracion.get_bool('chk_config_decimales_precios')
|
||||
if dp:
|
||||
|
@ -366,6 +366,7 @@ def config_timbrar():
|
|||
'cfdi_folio_custom': Configuracion.get_bool('chk_folio_custom'),
|
||||
'cfdi_leyendasfiscales': Configuracion.get_bool('chk_config_leyendas_fiscales'),
|
||||
'cfdi_show_total_cant': Configuracion.get_bool('chk_config_show_total_cant'),
|
||||
'cfdi_change_date_invoice': Configuracion.get_bool('chk_config_change_date_invoice'),
|
||||
}
|
||||
|
||||
return conf
|
||||
|
@ -678,6 +679,7 @@ class Configuracion(BaseModel):
|
|||
'chk_config_invoice_by_ticket',
|
||||
'chk_config_show_total_cant',
|
||||
'chk_cancel_invoices_by_admin',
|
||||
'chk_config_change_date_invoice',
|
||||
'chk_cancel_tickets_by_admin',
|
||||
)
|
||||
data = (Configuracion
|
||||
|
@ -5604,6 +5606,15 @@ class Facturas(BaseModel):
|
|||
|
||||
leyendas_fiscales = utils.loads(values.pop('leyendas_fiscales', '[]'))
|
||||
|
||||
date_invoice = values.pop('date')
|
||||
if Configuracion.get_bool('chk_config_change_date_invoice'):
|
||||
values['fecha'] = utils.to_date(date_invoice)
|
||||
days = (utils.now() - values['fecha']).days
|
||||
if days > 2:
|
||||
msg = 'Fecha inválida'
|
||||
data = {'ok': False, 'row': {}, 'new': True, 'msg': msg}
|
||||
return data
|
||||
|
||||
emisor = Emisor.select()[0]
|
||||
values['serie'] = cls._get_serie(cls, user, values['serie'])
|
||||
if Configuracion.get_bool('chk_folio_custom') and folio_custom:
|
||||
|
@ -5778,8 +5789,18 @@ class Facturas(BaseModel):
|
|||
|
||||
rows = FacturasDetalle.select().where(FacturasDetalle.factura==invoice)
|
||||
for row in rows:
|
||||
object_tax = '02'
|
||||
if not row.producto is None:
|
||||
object_tax = row.producto.objeto_impuesto
|
||||
|
||||
object_tax = row.producto.objeto_impuesto
|
||||
# cfdi4
|
||||
# ~ if not is_global:
|
||||
# ~ concepto['ObjetoImp'] = row.producto.objeto_impuesto
|
||||
# ~ else:
|
||||
# ~ if taxes:
|
||||
# ~ concepto['ObjetoImp'] = '02'
|
||||
# ~ else:
|
||||
# ~ concepto['ObjetoImp'] = '01'
|
||||
|
||||
if is_global:
|
||||
key_sat = row.clave_sat
|
||||
|
@ -5795,6 +5816,7 @@ class Facturas(BaseModel):
|
|||
'Descripcion': row.descripcion,
|
||||
'ValorUnitario': frm_vu.format(row.valor_unitario),
|
||||
'Importe': FORMAT.format(row.importe),
|
||||
'ObjetoImp': object_tax,
|
||||
}
|
||||
if not is_global:
|
||||
concepto['Unidad'] = SATUnidades.get(SATUnidades.key==row.unidad).name[:20]
|
||||
|
@ -5886,15 +5908,6 @@ class Facturas(BaseModel):
|
|||
|
||||
concepto['impuestos'] = taxes
|
||||
|
||||
# cfdi4
|
||||
if not is_global:
|
||||
concepto['ObjetoImp'] = row.producto.objeto_impuesto
|
||||
else:
|
||||
if taxes:
|
||||
concepto['ObjetoImp'] = '02'
|
||||
else:
|
||||
concepto['ObjetoImp'] = '01'
|
||||
|
||||
conceptos.append(concepto)
|
||||
|
||||
impuestos = {}
|
||||
|
@ -8460,7 +8473,6 @@ class Tickets(BaseModel):
|
|||
|
||||
descuento_cfdi += details['descuento']
|
||||
subtotal += details['importe']
|
||||
|
||||
FacturasDetalle.create(**details)
|
||||
|
||||
taxes = (TicketsImpuestos
|
||||
|
@ -10830,7 +10842,8 @@ def get_title_app(by=1):
|
|||
2: '<font color="#610B0B">Bienvenido a {}</font>',
|
||||
3: '<font color="#000000">{}</font>',
|
||||
}
|
||||
return html[by].format(TITLE_APP)
|
||||
# ~ return html[by].format(TITLE_APP)
|
||||
return html[by].format('Empresa Libre')
|
||||
|
||||
|
||||
def test_correo(values):
|
||||
|
|
|
@ -135,6 +135,7 @@ var controllers = {
|
|||
$$('chk_config_invoice_by_ticket').attachEvent('onItemClick', chk_config_item_click)
|
||||
$$('chk_config_show_total_cant').attachEvent('onItemClick', chk_config_item_click)
|
||||
$$('chk_cancel_invoices_by_admin').attachEvent('onItemClick', chk_config_item_click)
|
||||
$$('chk_config_change_date_invoice').attachEvent('onItemClick', chk_config_item_click)
|
||||
|
||||
$$('chk_config_anticipo').attachEvent('onItemClick', chk_config_item_click)
|
||||
|
||||
|
|
|
@ -254,6 +254,7 @@ function default_config(){
|
|||
show('fs_divisas', values.cfdi_divisas)
|
||||
show('txt_folio_custom', values.cfdi_folio_custom)
|
||||
show('txt_total_cant', values.cfdi_show_total_cant)
|
||||
show('date_invoice', values.cfdi_change_date_invoice)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,7 @@ function cmd_new_invoice_click(){
|
|||
lst.setValue('')
|
||||
lst.getList().clearAll()
|
||||
|
||||
$$('date_invoice').setValue(Date())
|
||||
$$('date_invoice').setValue(new Date())
|
||||
|
||||
form.focus('search_client_name')
|
||||
}
|
||||
|
@ -370,6 +371,13 @@ function validate_invoice(values){
|
|||
return false
|
||||
}
|
||||
|
||||
var now = new Date()
|
||||
var difference = (now.getTime() - date_invoice.getTime()) / (1000 * 3600 * 24)
|
||||
if(difference > 3){
|
||||
msg_error('Fecha inválida')
|
||||
return false
|
||||
}
|
||||
|
||||
var usar_cartaporte = $$('chk_cfdi_usar_cartaporte').getValue()
|
||||
if(usar_cartaporte){
|
||||
value = $$('lst_carta_UnidadPeso').getValue()
|
||||
|
@ -697,6 +705,7 @@ function guardar_y_timbrar(values){
|
|||
data['id'] = values.id
|
||||
data['cliente'] = values.id_partner
|
||||
data['productos'] = rows
|
||||
data['date'] = $$('date_invoice').getValue()
|
||||
data['serie'] = $$('lst_serie').getText()
|
||||
data['forma_pago'] = $$('lst_forma_pago').getValue()
|
||||
data['condiciones_pago'] = $$('txt_condicion_pago').getValue().trim()
|
||||
|
|
|
@ -694,6 +694,11 @@ var options_admin_otros = [
|
|||
labelRight: 'Solo admins pueden cancelar'},
|
||||
{}
|
||||
]},
|
||||
{cols: [{maxWidth: 15},
|
||||
{view: 'checkbox', id: 'chk_config_change_date_invoice', labelWidth: 0,
|
||||
labelRight: 'Permitir cambiar fecha al facturar [No recomendable]'},
|
||||
{}
|
||||
]},
|
||||
{maxHeight: 15},
|
||||
|
||||
{template: 'Timbrado', type: 'section'},
|
||||
|
|
Loading…
Reference in New Issue