Filtro por rango de fechas en facturas

This commit is contained in:
Mauricio Baeza 2017-10-28 22:21:39 -05:00
parent 2f62a2debe
commit 63c7b4e458
4 changed files with 17 additions and 8 deletions

View File

@ -1036,6 +1036,13 @@ def get_path_temp():
return tempfile.mkstemp()[1]
def get_date(value, next_day=False):
d = parser.parse(value)
if next_day:
return d + datetime.timedelta(days=1)
return d
class ImportFacturaLibre(object):
def __init__(self, path):

View File

@ -1187,10 +1187,11 @@ class Facturas(BaseModel):
@classmethod
def get_(cls, values):
print (values)
if 'dates' in values:
print (values)
if 'start' in values:
filters = Facturas.fecha.between(
util.get_date(values['start']),
util.get_date(values['end'], True)
)
else:
if values['year'] == '-1':
fy = (Facturas.fecha.year > 0)
@ -1200,8 +1201,7 @@ class Facturas(BaseModel):
fm = (Facturas.fecha.month > 0)
else:
fm = (Facturas.fecha.month == int(values['month']))
filters = (fy & fm)
filters = (fy & fm)
rows = tuple(Facturas
.select(Facturas.id, Facturas.serie, Facturas.folio, Facturas.uuid,

View File

@ -771,5 +771,7 @@ function filter_month_change(nv, ov){
function filter_dates_change(range){
show(range)
if(range.start != null && range.end != null){
get_invoices(range)
}
}

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, hidden: true},
labelAlign: 'right', width: 300},
]