Filtro por año y mes en facturas

This commit is contained in:
Mauricio Baeza 2017-10-28 21:58:18 -05:00
parent 14ccf4fe1f
commit 2f62a2debe
4 changed files with 47 additions and 28 deletions

View File

@ -1187,11 +1187,27 @@ class Facturas(BaseModel):
@classmethod
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
.select(Facturas.id, Facturas.serie, Facturas.folio, Facturas.uuid,
Facturas.fecha, Facturas.tipo_comprobante, Facturas.estatus,
Facturas.total_mn, Socios.nombre.alias('cliente'))
.where(filters)
.join(Socios)
.switch(Facturas).dicts()
)

View File

@ -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){
show(nv)
get_invoices()
}
function filter_month_change(nv, ov){
show(nv)
get_invoices()
}

View File

@ -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){
if (id == 1){
window.location = '/logout';

View File

@ -43,7 +43,7 @@ var toolbar_invoices_filter = [
{view: 'richselect', id: 'filter_month', label: 'Mes', labelAlign: 'right',
labelWidth: 50, width: 200, options: months},
{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",
sort:"string", hidden:true},
{id: "fecha", header: ["Fecha y Hora"],
adjust: "data", sort:"date"},
adjust: "data", sort: "date"},
{id: "tipo_comprobante", header: ["Tipo", {content: "selectFilter"}],
adjust: 'header', sort: 'string'},
{id: "estatus", header: ["Estatus", {content: "selectFilter"}],