UI - Prefacturas
This commit is contained in:
parent
8a06e3f4bb
commit
4f26f820cc
|
@ -1257,6 +1257,8 @@ class Facturas(BaseModel):
|
|||
q.execute()
|
||||
q = FacturasImpuestos.delete().where(FacturasImpuestos.factura==obj)
|
||||
q.execute()
|
||||
q = FacturasRelacionadas.delete().where(FacturasRelacionadas.factura==obj)
|
||||
q.execute()
|
||||
return bool(obj.delete_instance())
|
||||
|
||||
def _get_folio(self, serie):
|
||||
|
@ -1543,15 +1545,54 @@ class Facturas(BaseModel):
|
|||
return {'ok': result['ok'], 'msg': msg, 'row': row}
|
||||
|
||||
|
||||
class PreFacturas(BaseModel):
|
||||
cliente = ForeignKeyField(Socios)
|
||||
serie = TextField(default='PRE')
|
||||
folio = IntegerField(default=0)
|
||||
fecha = DateTimeField(default=util.now, formats=['%Y-%m-%d %H:%M:%S'])
|
||||
forma_pago = TextField(default='')
|
||||
condiciones_pago = TextField(default='')
|
||||
subtotal = DecimalField(default=0.0, max_digits=20, decimal_places=6,
|
||||
auto_round=True)
|
||||
descuento = DecimalField(default=0.0, max_digits=20, decimal_places=6,
|
||||
auto_round=True)
|
||||
moneda = TextField(default='MXN')
|
||||
tipo_cambio = DecimalField(default=1.0, decimal_places=6, auto_round=True)
|
||||
total = DecimalField(default=0.0, max_digits=20, decimal_places=6,
|
||||
auto_round=True)
|
||||
total_mn = DecimalField(default=0.0, max_digits=20, decimal_places=6,
|
||||
auto_round=True)
|
||||
tipo_comprobante = TextField(default='I')
|
||||
metodo_pago = TextField(default='PUE')
|
||||
lugar_expedicion = TextField(default='')
|
||||
uso_cfdi = TextField(default='')
|
||||
total_retenciones = DecimalField(
|
||||
max_digits=20, decimal_places=6, auto_round=True, null=True)
|
||||
total_trasladados = DecimalField(
|
||||
max_digits=20, decimal_places=6, auto_round=True, null=True)
|
||||
estatus = TextField(default='Generada')
|
||||
regimen_fiscal = TextField(default='')
|
||||
notas = TextField(default='')
|
||||
donativo = BooleanField(default=False)
|
||||
tipo_relacion = TextField(default='')
|
||||
|
||||
class Meta:
|
||||
order_by = ('fecha',)
|
||||
|
||||
|
||||
class FacturasRelacionadas(BaseModel):
|
||||
factura = ForeignKeyField(Facturas, related_name='original')
|
||||
factura_origen = ForeignKeyField(Facturas, related_name='relacion')
|
||||
|
||||
class Meta:
|
||||
order_by = ('factura',)
|
||||
indexes = (
|
||||
(('factura', 'factura_origen'), True),
|
||||
)
|
||||
|
||||
class PreFacturasRelacionadas(BaseModel):
|
||||
factura = ForeignKeyField(PreFacturas, related_name='original')
|
||||
factura_origen = ForeignKeyField(PreFacturas, related_name='relacion')
|
||||
|
||||
class Meta:
|
||||
order_by = ('factura',)
|
||||
|
||||
|
||||
class FacturasDetalle(BaseModel):
|
||||
|
@ -1585,6 +1626,32 @@ class FacturasDetalle(BaseModel):
|
|||
order_by = ('factura',)
|
||||
|
||||
|
||||
class PreFacturasDetalle(BaseModel):
|
||||
factura = ForeignKeyField(PreFacturas)
|
||||
producto = ForeignKeyField(Productos, null=True)
|
||||
cantidad = DecimalField(default=0.0, max_digits=18, decimal_places=6,
|
||||
auto_round=True)
|
||||
valor_unitario = DecimalField(default=0.0, max_digits=18, decimal_places=6,
|
||||
auto_round=True)
|
||||
descuento = DecimalField(default=0.0, max_digits=18, decimal_places=6,
|
||||
auto_round=True)
|
||||
precio_final = DecimalField(default=0.0, max_digits=18, decimal_places=6,
|
||||
auto_round=True)
|
||||
importe = DecimalField(default=0.0, max_digits=20, decimal_places=6,
|
||||
auto_round=True)
|
||||
aduana = TextField(default='')
|
||||
pedimento = TextField(default='')
|
||||
fecha_pedimento = DateField(null=True)
|
||||
alumno = TextField(default='')
|
||||
curp = TextField(default='')
|
||||
nivel = TextField(default='')
|
||||
autorizacion = TextField(default='')
|
||||
cuenta_predial = TextField(default='')
|
||||
|
||||
class Meta:
|
||||
order_by = ('factura',)
|
||||
|
||||
|
||||
class FacturasImpuestos(BaseModel):
|
||||
factura = ForeignKeyField(Facturas)
|
||||
impuesto = ForeignKeyField(SATImpuestos)
|
||||
|
@ -1600,6 +1667,21 @@ class FacturasImpuestos(BaseModel):
|
|||
)
|
||||
|
||||
|
||||
class PreFacturasImpuestos(BaseModel):
|
||||
factura = ForeignKeyField(PreFacturas)
|
||||
impuesto = ForeignKeyField(SATImpuestos)
|
||||
base = DecimalField(default=0.0, max_digits=20, decimal_places=6,
|
||||
auto_round=True)
|
||||
importe = DecimalField(default=0.0, max_digits=18, decimal_places=6,
|
||||
auto_round=True)
|
||||
|
||||
class Meta:
|
||||
order_by = ('factura',)
|
||||
indexes = (
|
||||
(('factura', 'impuesto'), True),
|
||||
)
|
||||
|
||||
|
||||
def authenticate(args):
|
||||
respuesta = {'login': False, 'msg': 'No Autorizado', 'user': ''}
|
||||
values = util.get_con(args['rfc'])
|
||||
|
@ -1700,6 +1782,8 @@ def _crear_tablas(rfc):
|
|||
tablas = [Addendas, Categorias, Certificado, CondicionesPago, Configuracion,
|
||||
Emisor, Facturas, FacturasDetalle, FacturasImpuestos, Folios,
|
||||
FacturasRelacionadas, Productos,
|
||||
PreFacturas, PreFacturasDetalle, PreFacturasImpuestos,
|
||||
PreFacturasRelacionadas,
|
||||
SATAduanas, SATFormaPago, SATImpuestos, SATMonedas, SATRegimenes,
|
||||
SATTipoRelacion, SATUnidades, SATUsoCfdi,
|
||||
Socios, Tags, Usuarios,
|
||||
|
|
|
@ -815,3 +815,19 @@ function cmd_invoice_sat_click(){
|
|||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
function cmd_prefactura_click(){
|
||||
var form = this.getFormView()
|
||||
|
||||
if(!form.validate()) {
|
||||
msg_error('Valores inválidos')
|
||||
return
|
||||
}
|
||||
|
||||
var values = form.getValues()
|
||||
if(!validate_invoice(values)){
|
||||
return
|
||||
}
|
||||
show('PreFactura')
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ var controllers = {
|
|||
$$('filter_year').attachEvent('onChange', filter_year_change)
|
||||
$$('filter_month').attachEvent('onChange', filter_month_change)
|
||||
$$('filter_dates').attachEvent('onChange', filter_dates_change)
|
||||
$$('cmd_prefactura').attachEvent('onItemClick', cmd_prefactura_click)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -258,6 +258,7 @@ var body_regimen_fiscal = {
|
|||
|
||||
|
||||
var controls_generate = [
|
||||
{minHeight: 15, maxHeight: 15},
|
||||
{cols: [ {rows:[
|
||||
{view: 'fieldset', label: 'Buscar Cliente', body: {rows: [
|
||||
{cols: [
|
||||
|
@ -302,26 +303,86 @@ var controls_generate = [
|
|||
{view: 'label', label: 'Detalle', height: 30, align: 'left'},
|
||||
grid_details,
|
||||
{minHeight: 15, maxHeight: 15},
|
||||
{cols: [{}, grid_totals]}
|
||||
{cols: [{}, grid_totals]},
|
||||
{minHeight: 15, maxHeight: 15},
|
||||
{margin: 20, cols: [{},
|
||||
{view: "button", id: "cmd_timbrar", label: "Timbrar",
|
||||
type: "form", autowidth: true, align:"center"},
|
||||
{view: "button", id: 'cmd_prefactura', label: "PreFactura",
|
||||
type: "form", autowidth: true, align:"center"},
|
||||
{}]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
var toolbar_preinvoices = [
|
||||
{view: 'button', id: 'cmd_facturar_preinvoice', label: 'Facturar',
|
||||
type: 'iconButton', autowidth: true, icon: 'pencil'},
|
||||
{},
|
||||
{view: "button", id: "cmd_delete_preinvoice", label: "Eliminar",
|
||||
type: "iconButton", autowidth: true, icon: "minus"},
|
||||
]
|
||||
|
||||
|
||||
var toolbar_prefilter = [
|
||||
{view: 'richselect', id: 'prefilter_year', label: 'Año', labelAlign: 'right',
|
||||
labelWidth: 50, width: 150, options: []},
|
||||
{view: 'richselect', id: 'prefilter_month', label: 'Mes', labelAlign: 'right',
|
||||
labelWidth: 50, width: 200, options: months},
|
||||
]
|
||||
|
||||
|
||||
var grid_preinvoices_cols = [
|
||||
{id: "id", header:"ID", hidden:true},
|
||||
{id: "folio", header: ["Folio", {content: "numberFilter"}], adjust: "data",
|
||||
sort:"int", css: "cell_right"},
|
||||
{id: "fecha", header: ["Fecha y Hora"],
|
||||
adjust: "data", sort: "date"},
|
||||
{id: "tipo_comprobante", header: ["Tipo", {content: "selectFilter"}],
|
||||
adjust: 'header', sort: 'string'},
|
||||
{id: 'total_mn', header: ['Total M.N.'], width: 150,
|
||||
sort: 'int', format: webix.i18n.priceFormat, css: 'right'},
|
||||
{id: "cliente", header: ["Razón Social", {content: "selectFilter"}],
|
||||
fillspace:true, sort:"string"},
|
||||
{id: 'pdf', header: 'PDF', adjust: 'data', template: get_icon('pdf')},
|
||||
{id: 'email', header: '', adjust: 'data', template: get_icon('email')}
|
||||
]
|
||||
|
||||
|
||||
var grid_preinvoices = {
|
||||
view: 'datatable',
|
||||
id: 'grid_preinvoices',
|
||||
select: 'row',
|
||||
adjust: true,
|
||||
footer: true,
|
||||
resizeColumn: true,
|
||||
headermenu: true,
|
||||
columns: grid_preinvoices_cols,
|
||||
}
|
||||
|
||||
|
||||
var controls_prefactura = [
|
||||
{view: 'toolbar', elements: toolbar_preinvoices},
|
||||
{view: 'toolbar', elements: toolbar_prefilter},
|
||||
grid_preinvoices,
|
||||
]
|
||||
|
||||
|
||||
var controls_invoices = [
|
||||
{
|
||||
view: "tabview",
|
||||
tabbar: {options: ["Generar"]}, animate: true,
|
||||
view: 'tabview',
|
||||
tabbar: {options: ['Generar', 'PreFacturas']}, animate: true,
|
||||
cells: [
|
||||
{id: "Generar", rows: controls_generate},
|
||||
{id: 'Generar', rows: controls_generate},
|
||||
{id: 'PreFacturas', rows: controls_prefactura},
|
||||
]
|
||||
},
|
||||
{rows: [
|
||||
{template:"", type: "section" },
|
||||
{margin: 10, cols: [{},
|
||||
{view: "button", id: "cmd_timbrar", label: "Timbrar",
|
||||
type: "form", autowidth: true, align:"center"},
|
||||
{view: 'button', id: 'cmd_close_invoice', label: 'Cancelar',
|
||||
type: 'danger', autowidth: true, align: 'center'},
|
||||
{}]
|
||||
type: 'danger', autowidth: true, align: 'center'}
|
||||
]
|
||||
},
|
||||
]}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue