예제 #1
0
    def get_data_range(self, condominio):
        '''
        This method checks condominium bills to
        establish a valid data range for income and expenses
        '''
        queryset = self.filter(condominio=condominio)
        if queryset.exists():
            earliest = queryset.earliest('created').created.replace(
                day=1, hour=0, minute=0, second=0, microsecond=0)
            latest = queryset.latest('created').created
            latest = latest.replace(day=last_day_of_month(latest),
                                    hour=23,
                                    minute=59,
                                    second=59,
                                    microsecond=999999)

        else:
            earliest = condominio.user.date_joined.replace(day=1,
                                                           hour=0,
                                                           minute=0,
                                                           second=0,
                                                           microsecond=0)
            latest = earliest.replace(day=last_day_of_month(earliest),
                                      hour=23,
                                      minute=59,
                                      second=59,
                                      microsecond=999999)
        return (
            earliest,
            latest,
        )
예제 #2
0
 def getMonth(self, messages, name, value):
     maxDate = datetime.datetime(value.year,
                                 value.month,
                                 last_day_of_month(value),
                                 tzinfo=pytz.utc)
     minDate = datetime.datetime(value.year,
                                 value.month,
                                 1,
                                 tzinfo=pytz.utc)
     return messages.filter(mes__range=(minDate, maxDate))
예제 #3
0
 def get_month_query(self, month):
     minDate = month.replace(day=1,
                             hour=0,
                             minute=0,
                             second=0,
                             microsecond=0)
     maxDate = month.replace(day=last_day_of_month(month),
                             hour=23,
                             minute=59,
                             second=59,
                             microsecond=999999)
     queryset = self.filter(mes__range=(minDate, maxDate))
     return queryset
예제 #4
0
 def get_month(self, queryset, name, value):
     minDate = value.replace(month=1,
                             day=1,
                             hour=0,
                             minute=0,
                             second=0,
                             microsecond=0)
     maxDate = value.replace(day=last_day_of_month(value),
                             hour=23,
                             minute=59,
                             second=59,
                             microsecond=999999)
     return queryset.filter(mes__range=(minDate, maxDate))
예제 #5
0
 def getMonth(self, ingresos, name, value):
     maxDate = datetime.datetime(value.year,
                                 value.month,
                                 last_day_of_month(value),
                                 tzinfo=pytz.utc)
     minDate = datetime.datetime(value.year,
                                 value.month,
                                 1,
                                 0,
                                 0,
                                 0,
                                 0,
                                 tzinfo=pytz.utc)
     return ingresos.filter(created__range=(minDate, maxDate))
예제 #6
0
    def get_data_range(self, condominio):
        '''
        This method checks condominium bills to
        establish a valid data range for income and expenses
        '''
        from condominioaldia_app.models import Factura_Condominio
        queryset = Factura_Condominio.objects.filter(condominio=condominio)

        #queryset = self.filter(condominio=condominio)
        if queryset.exists():
            earliest = queryset.earliest('mes').mes.replace(day=1,
                                                            hour=0,
                                                            minute=0,
                                                            second=0,
                                                            microsecond=0)
            latest = queryset.latest('mes').mes
            latest = latest.replace(day=last_day_of_month(latest),
                                    hour=23,
                                    minute=59,
                                    second=59,
                                    microsecond=999999)

        else:
            earliest = condominio.user.date_joined.replace(day=1,
                                                           hour=0,
                                                           minute=0,
                                                           second=0,
                                                           microsecond=0)
            latest = earliest.replace(day=last_day_of_month(earliest),
                                      hour=23,
                                      minute=59,
                                      second=59,
                                      microsecond=999999)
        return (
            earliest,
            latest,
        )
예제 #7
0
 def getLatest(self, ingresos, name, value):
     if ingresos.exists():
         latest = ingresos.latest('created').created
         minDate = latest.replace(day=1,
                                  hour=0,
                                  minute=0,
                                  second=0,
                                  microsecond=0)
         maxDate = minDate.replace(day=last_day_of_month(minDate),
                                   hour=23,
                                   minute=59,
                                   second=59,
                                   microsecond=999999)
         return ingresos.filter(created__range=(minDate, maxDate))
     return []
예제 #8
0
 def get_egresos(self, month):
     minDate = month.replace(day=1,
                             hour=0,
                             minute=0,
                             second=0,
                             microsecond=0)
     maxDate = month.replace(day=last_day_of_month(minDate),
                             hour=23,
                             minute=59,
                             second=59,
                             microsecond=999999)
     egresos = Egreso_Condominio.objects.filter(
         condominio=self.request.user.condominio).filter(
             mes__range=(minDate, maxDate))
     return egresos
예제 #9
0
 def getMonth(self, ingresos, name, value):
     maxDate = datetime.datetime(value.year,
                                 value.month,
                                 last_day_of_month(value),
                                 tzinfo=pytz.utc).replace(
                                     hour=23,
                                     minute=59,
                                     second=59,
                                     microsecond=999999)
     minDate = datetime.datetime(value.year,
                                 value.month,
                                 1,
                                 tzinfo=pytz.utc).replace(hour=0,
                                                          minute=0,
                                                          second=0,
                                                          microsecond=0)
     return ingresos.filter(created__range=(minDate, maxDate))