diff --git a/source/app/controllers/util.py b/source/app/controllers/util.py index 2b4fea4..0d72190 100644 --- a/source/app/controllers/util.py +++ b/source/app/controllers/util.py @@ -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): diff --git a/source/app/models/main.py b/source/app/models/main.py index c0b0291..370269e 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -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, diff --git a/source/static/js/controller/invoices.js b/source/static/js/controller/invoices.js index f29bff5..0fdba87 100644 --- a/source/static/js/controller/invoices.js +++ b/source/static/js/controller/invoices.js @@ -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) + } } diff --git a/source/static/js/ui/invoices.js b/source/static/js/ui/invoices.js index 6092c15..687a644 100644 --- a/source/static/js/ui/invoices.js +++ b/source/static/js/ui/invoices.js @@ -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}, ]