示例#1
0
  def getAllReports(self, id):
    reports = {'current' : Report(), 'last' : Report(), 'global' : Report()}
    #get_current_month() and get_current_year
    #get_last_month() and get_last_year
    reports['global'].shipments_count =  ShipmentDao.count_by_customer(id)
    reports['global'].shipments_sum =  ShipmentDao.sum_by_customer(id)
    reports['global'].canceled_count = ShipmentDao.count_canceled_by_customer(id)
    reports['global'].canceled_sum =  ShipmentDao.sum_canceled_by_customer(id)
    reports['global'].paid_count = ShipmentDao.count_paid_by_customer(id)
    reports['global'].paid_sum =  ShipmentDao.sum_paid_by_customer(id)
    reports['global'].effective_count = ShipmentDao.count_effective_by_customer(id)
    reports['global'].effective_sum =  ShipmentDao.sum_effective_by_customer(id)
    reports['global'].in_sub_count = ShipmentDao.count_in_sub_by_customer(id)
    reports['global'].in_sub_sum =  ShipmentDao.sum_in_sub_by_customer(id)
    reports['global'].out_sub_count = ShipmentDao.count_out_sub_by_customer(id)
    reports['global'].out_sub_sum =  ShipmentDao.sum_out_sub_by_customer(id)
    
    start,end = dates_range(period='month')
    reports['current'].shipments_count =  ShipmentDao.count_by_customer(id, start=start, end=end)
    reports['current'].shipments_sum =  ShipmentDao.sum_by_customer(id, start=start, end=end)
    reports['current'].canceled_count =  ShipmentDao.count_canceled_by_customer(id, start=start, end=end)
    reports['current'].canceled_sum =  ShipmentDao.sum_canceled_by_customer(id, start=start, end=end)
    reports['current'].paid_count =  ShipmentDao.count_paid_by_customer(id, start=start, end=end)
    reports['current'].paid_sum =  ShipmentDao.sum_paid_by_customer(id, start=start, end=end)
    reports['current'].effective_count =  ShipmentDao.count_effective_by_customer(id, start=start, end=end)
    reports['current'].effective_sum =  ShipmentDao.sum_effective_by_customer(id, start=start, end=end)
    reports['current'].in_sub_count = ShipmentDao.count_in_sub_by_customer(id, start=start, end=end)
    reports['current'].in_sub_sum =  ShipmentDao.sum_in_sub_by_customer(id, start=start, end=end)
    reports['current'].out_sub_count = ShipmentDao.count_out_sub_by_customer(id, start=start, end=end)
    reports['current'].out_sub_sum =  ShipmentDao.sum_out_sub_by_customer(id, start=start, end=end)

    
    start,end = dates_range(period='month', before=1)
    reports['last'].shipments_count =  ShipmentDao.count_by_customer(id, start=start, end=end)
    reports['last'].shipments_sum =  ShipmentDao.sum_by_customer(id, start=start, end=end)
    reports['last'].canceled_count =  ShipmentDao.count_canceled_by_customer(id, start=start, end=end)
    reports['last'].canceled_sum =  ShipmentDao.sum_canceled_by_customer(id, start=start, end=end)
    reports['last'].paid_count =  ShipmentDao.count_paid_by_customer(id, start=start, end=end)
    reports['last'].paid_sum =  ShipmentDao.sum_paid_by_customer(id, start=start, end=end)
    reports['last'].effective_count =  ShipmentDao.count_effective_by_customer(id, start=start, end=end)
    reports['last'].effective_sum =  ShipmentDao.sum_effective_by_customer(id, start=start, end=end)
    reports['last'].in_sub_count = ShipmentDao.count_in_sub_by_customer(id, start=start, end=end)
    reports['last'].in_sub_sum =  ShipmentDao.sum_in_sub_by_customer(id, start=start, end=end)
    reports['last'].out_sub_count = ShipmentDao.count_out_sub_by_customer(id, start=start, end=end)
    reports['last'].out_sub_sum =  ShipmentDao.sum_out_sub_by_customer(id, start=start, end=end)
    
    return reports
示例#2
0
    def get_main_amounts_by_seller(self, seller_id, customer_id, period, day):
        days = []
        datetime_day = datetime.strptime(day, '%d%m%Y')
        start, end = dates_range(period, datetime_day)

        orders = self.orderServices.get_all_by_seller_customer_period_valid(
            seller_id, customer_id, start, end)

        return self.prepareAmount(orders)
示例#3
0
 def get_some_valid(self,
                    customer_id=0,
                    day=datetime.utcnow,
                    period=Period_Enum.ALL.value):
     datetime_day = datetime.strptime(day, '%d%m%Y')
     start, end = dates_range(period, datetime_day)
     return ShipmentDao.read_some_valid(customer_id=customer_id,
                                        start=start,
                                        end=end)
示例#4
0
 def get_by_customer_by_period(self,
                               customer_id=0,
                               day=datetime.utcnow,
                               period=Period_Enum.ALL.value,
                               nocanceled=False,
                               nopaid=False):
     datetime_day = datetime.strptime(day, '%d%m%Y')
     start, end = dates_range(period, datetime_day)
     return ShipmentDao.read_by_customer_by_period(customer_id,
                                                   start=start,
                                                   end=end,
                                                   nocanceled=nocanceled,
                                                   nopaid=nopaid)
示例#5
0
 def get_some_pagination(self,
                         customer_id=0,
                         day=datetime.utcnow,
                         period=Period_Enum.ALL.value,
                         page=1,
                         per_page=30,
                         nocanceled=False,
                         nopaid=False):
     datetime_day = datetime.strptime(day, '%d%m%Y')
     start, end = dates_range(period, datetime_day)
     return ShipmentDao.read_some_pagination(customer_id=customer_id,
                                             start=start,
                                             end=end,
                                             page=page,
                                             per_page=per_page,
                                             nocanceled=nocanceled,
                                             nopaid=nopaid)
示例#6
0
    def get_reports_by_seller(self, seller_id, customer_id, period, day):
        days = []
        datetime_day = datetime.strptime(day, '%d%m%Y')
        start, end = dates_range(period, datetime_day)

        if period == Period_Enum.DAY.value:
            start = start + timedelta(seconds=1)

        while start <= end:
            end_day = start + timedelta(days=1)

            day = {}
            orders = self.orderServices.get_all_by_seller_customer_period_valid(
                seller_id, customer_id, start, end_day)

            start = start + timedelta(seconds=1)
            day['date'] = start

            day = self.prepareDay(day, orders, start)
            days.append(day)
            start = end_day
        return days
 def get_some_pagination(self,  customer_id=0, day=datetime.utcnow, period=Period_Enum.ALL.value, page=1, per_page=10):
     datetime_day = datetime.strptime(day, '%d%m%Y')
     start, end = dates_range(period, datetime_day)
     return SubscriptionDao.read_some_pagination(customer_id=customer_id, start=start, end=end, page=page, per_page=per_page)