Ejemplo n.º 1
0
    def report_week(self, _num_week=None):
        """
        :param num_week:
        :return:
        """
        if _num_week is None: _num_week = this_week()
        wn = WeekNumber()
        ext = Extract()
        act = Activity()
        _pla = Planned()
        _week = wn.get_or_create(_num_week, True)
        gap_week = wn.get_gap_week(_week.date_init)

        import ipdb; ipdb.set_trace()
        if _num_week == this_week():
            _pla.get_tasks_week()
            wn.import_extract_itau()
            wn.import_extract_mycap()

        m_summary_ext = self.get_matrix(gap_week, _week, Extract.__name__, None)
        m_summary_activ = self.get_matrix(gap_week, _week, Activity.__name__, None)
        m_details_ext = self.get_matrix(gap_week, _week, None, Extract.__name__)
        m_details_activ = self.get_matrix(gap_week, _week, None, Activity.__name__)

        for day in gap_week:
            cost_week = ext.get_cost_week(m_details_ext, day)
            try:
                activ_week = act.report_activity(m_details_activ, day)
            except Exception:
                print("trello unauthorized permission requested.")
                pass
Ejemplo n.º 2
0
    def report_month(self, num_week):
        """
        :param num_week:
        :return:
        """
        month = month.get([datetime.today().month])
        type_launch = TypeLaunch.objects.filter().order_by('-cost_fixo')
        _line = type_launch.count()
        matrix = [['' for coll in range(0)] for row in range(_line + 1)]

        line = 0
        matrix[line].append('cost month %s' %month)
        line += 1
        for tl in type_launch:
            matrix[line].append(tl.type_name)
            line += 1

        line = 0
        matrix[line].append('prevision')
        line += 1
        for tl in type_launch:
            matrix[line].append(tl.value_fixed)
            line += 1

        line = 0
        matrix[line].append('fixo prevision')
        line += 1
        for tl in type_launch:
            if tl.cost_fixo:
                matrix[line].append(tl.value_fixed)
            else:
                matrix[line].append('')
            line += 1

        dif_week = 3  #4 week report_month
        wn = WeekNumber()
        ext = Extract()
        while dif_week >= 0:
            _num_week = (num_week - dif_week)
            _week = wn.get_or_create(_num_week)
            matrix = ext.get_cost_month(matrix, _week, type_launch)
            dif_week -= 1

        worksheet = get_worksheet(num_week, month)
        _range = get_range(matrix)
        send_week(worksheet, _range, matrix)
Ejemplo n.º 3
0
    def get_summary_week(self, _week, summary, tp_launch, tot_week_before):
        """
        :param _week:
        :param summary:
        :param tp_launch:
        :param tot_week_before:
        :return:
        """
        first_day = name_day(_week.date_init)
        last_day = name_day(_week.date_final)
        ext = Extract()
        act = Activity()
        value_week = ext.get_total_week(_week, _type=None)
        line = 0
        summary[line].append(first_day)
        summary[line].append("TO")
        summary[line].append(last_day)
        _today = datetime.today()
        summary[line].append("Account Itau day %s %s:%s" %(_today.day, str(_today.hour), str(_today.minute)))
        if value_week.__len__() > 1:
            line = 1
            value_debit = value_week[0]
            value_credit = value_week[1]
            total_week = value_week[2]
            # tot_week_before = value_week[3]
            total_week = tot_week_before - value_debit + value_credit
            if value_credit > value_debit:
                summary[line].append("Result Positive")
            else:
                summary[line].append("Result Negative")
            summary[line].append(str(value_debit).replace('.',','))
            summary[line].append(str(value_credit).replace('.',','))
            summary[line].append(str(total_week).replace('.',','))

            line = 2
            _local = 'local'
            if not settings.DATABASE_LOCAL: _local = 'heroku'
            summary[line].append("Cost Week")
            summary[line].append("Debit" + _local)
            summary[line].append("Credit")
            summary[line].append("Total")
            summary[line].append("Time")
            summary[line].append("Cost per time")
            summary[line].append("Recipe per time")

            line = 3
            for tp in tp_launch:
                tot_week_type = ext.get_total_week(_week, tp.id)
                if tot_week_type.__len__() > 1:
                    value_debit = str(tot_week_type[0]).replace('.',',')
                    value_credit = str(tot_week_type[1]).replace('.',',')
                    value_total = str(tot_week_type[2]).replace('.',',')
                    summary[line].append(tp.type_name)
                    summary[line].append(value_debit)
                    summary[line].append(value_credit)
                    summary[line].append(value_total)

                    time_cost = act.get_time_type_launch(_week, tp.id)
                    if time_cost is None:
                        time_cost = ''
                        cost_per_time = ''
                        receit_per_time = ''
                    else:
                        _cost_type = str_to_float(value_debit)
                        cost_per_time = round(_cost_type / float(time_cost), 2)
                        _receit_type = str_to_float(value_credit)
                        receit_per_time = round(_receit_type / float(time_cost), 2)

                        time_cost = str(time_cost).replace('.',',')
                        cost_per_time = str(cost_per_time).replace('.',',')
                        receit_per_time = str(receit_per_time).replace('.',',')
                    summary[line].append(time_cost)
                    summary[line].append(cost_per_time)
                    summary[line].append(receit_per_time)
                    line += 1
        return summary