forked from elmau/empresa-libre
Filtro por año y mes en facturas
This commit is contained in:
parent
14ccf4fe1f
commit
2f62a2debe
|
@ -1187,11 +1187,27 @@ class Facturas(BaseModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_(cls, values):
|
def get_(cls, values):
|
||||||
#~ print (values)
|
print (values)
|
||||||
|
|
||||||
|
if 'dates' in values:
|
||||||
|
print (values)
|
||||||
|
else:
|
||||||
|
if values['year'] == '-1':
|
||||||
|
fy = (Facturas.fecha.year > 0)
|
||||||
|
else:
|
||||||
|
fy = (Facturas.fecha.year == int(values['year']))
|
||||||
|
if values['month'] == '-1':
|
||||||
|
fm = (Facturas.fecha.month > 0)
|
||||||
|
else:
|
||||||
|
fm = (Facturas.fecha.month == int(values['month']))
|
||||||
|
|
||||||
|
filters = (fy & fm)
|
||||||
|
|
||||||
rows = tuple(Facturas
|
rows = tuple(Facturas
|
||||||
.select(Facturas.id, Facturas.serie, Facturas.folio, Facturas.uuid,
|
.select(Facturas.id, Facturas.serie, Facturas.folio, Facturas.uuid,
|
||||||
Facturas.fecha, Facturas.tipo_comprobante, Facturas.estatus,
|
Facturas.fecha, Facturas.tipo_comprobante, Facturas.estatus,
|
||||||
Facturas.total_mn, Socios.nombre.alias('cliente'))
|
Facturas.total_mn, Socios.nombre.alias('cliente'))
|
||||||
|
.where(filters)
|
||||||
.join(Socios)
|
.join(Socios)
|
||||||
.switch(Facturas).dicts()
|
.switch(Facturas).dicts()
|
||||||
)
|
)
|
||||||
|
|
|
@ -734,13 +734,39 @@ function cmd_invoice_cancelar_click(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_invoices(rango){
|
||||||
|
if(rango == undefined){
|
||||||
|
var fy = $$('filter_year')
|
||||||
|
var fm = $$('filter_month')
|
||||||
|
|
||||||
|
var y = fy.getValue()
|
||||||
|
var m = fm.getValue()
|
||||||
|
rango = {'year': y, 'month': m}
|
||||||
|
}
|
||||||
|
|
||||||
|
var grid = $$('grid_invoices')
|
||||||
|
webix.ajax().get('/invoices', rango, {
|
||||||
|
error: function(text, data, xhr) {
|
||||||
|
webix.message({type: 'error', text: 'Error al consultar'})
|
||||||
|
},
|
||||||
|
success: function(text, data, xhr) {
|
||||||
|
var values = data.json();
|
||||||
|
grid.clearAll();
|
||||||
|
if (values.ok){
|
||||||
|
grid.parse(values.rows, 'json');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function filter_year_change(nv, ov){
|
function filter_year_change(nv, ov){
|
||||||
show(nv)
|
get_invoices()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function filter_month_change(nv, ov){
|
function filter_month_change(nv, ov){
|
||||||
show(nv)
|
get_invoices()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,29 +95,6 @@ function get_products(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_invoices(){
|
|
||||||
var fy = $$('filter_year')
|
|
||||||
var fm = $$('filter_month')
|
|
||||||
|
|
||||||
var y = fy.getValue()
|
|
||||||
var m = fm.getValue()
|
|
||||||
|
|
||||||
var grid = $$('grid_invoices')
|
|
||||||
webix.ajax().get('/invoices', {'year': y, 'month': m}, {
|
|
||||||
error: function(text, data, xhr) {
|
|
||||||
webix.message({type: 'error', text: 'Error al consultar'})
|
|
||||||
},
|
|
||||||
success: function(text, data, xhr) {
|
|
||||||
var values = data.json();
|
|
||||||
grid.clearAll();
|
|
||||||
if (values.ok){
|
|
||||||
grid.parse(values.rows, 'json');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function menu_user_click(id, e, node){
|
function menu_user_click(id, e, node){
|
||||||
if (id == 1){
|
if (id == 1){
|
||||||
window.location = '/logout';
|
window.location = '/logout';
|
||||||
|
|
|
@ -43,7 +43,7 @@ var toolbar_invoices_filter = [
|
||||||
{view: 'richselect', id: 'filter_month', label: 'Mes', labelAlign: 'right',
|
{view: 'richselect', id: 'filter_month', label: 'Mes', labelAlign: 'right',
|
||||||
labelWidth: 50, width: 200, options: months},
|
labelWidth: 50, width: 200, options: months},
|
||||||
{view: 'daterangepicker', id: 'filter_dates', label: 'Fechas',
|
{view: 'daterangepicker', id: 'filter_dates', label: 'Fechas',
|
||||||
labelAlign: 'right', width: 300},
|
labelAlign: 'right', width: 300, hidden: true},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ var grid_invoices_cols = [
|
||||||
{id: "uuid", header: ["UUID", {content: "textFilter"}], adjust: "data",
|
{id: "uuid", header: ["UUID", {content: "textFilter"}], adjust: "data",
|
||||||
sort:"string", hidden:true},
|
sort:"string", hidden:true},
|
||||||
{id: "fecha", header: ["Fecha y Hora"],
|
{id: "fecha", header: ["Fecha y Hora"],
|
||||||
adjust: "data", sort:"date"},
|
adjust: "data", sort: "date"},
|
||||||
{id: "tipo_comprobante", header: ["Tipo", {content: "selectFilter"}],
|
{id: "tipo_comprobante", header: ["Tipo", {content: "selectFilter"}],
|
||||||
adjust: 'header', sort: 'string'},
|
adjust: 'header', sort: 'string'},
|
||||||
{id: "estatus", header: ["Estatus", {content: "selectFilter"}],
|
{id: "estatus", header: ["Estatus", {content: "selectFilter"}],
|
||||||
|
|
Loading…
Reference in New Issue