Exemple #1
0
    def planned_costs(self, reporting_period=None):
        """The function returns the planned costs of resources which have been estimated for this task
         at a specific reporting period plus the costs of the effective effort before the provided reporting_period
         When no reporting_period is provided, the last reporting period

        is selected.

        Args:
        no arguments

        Returns:
        planned costs (Decimal), 0 if when no estimation or no reporting period is present

        Raises:
        No exceptions planned"""
        try:
            if not reporting_period:
                reporting_period_internal = ReportingPeriod.get_latest_reporting_period(self.project)

            else:
                reporting_period_internal = ReportingPeriod.objects.get(id=reporting_period.id)
            predecessor_reporting_periods = ReportingPeriod.get_all_predecessors(reporting_period_internal,
                                                                                 self.project)
            estimations_to_this_task = Estimation.objects.filter(task=self.id,
                                                                 reporting_period=reporting_period_internal)
            sum_costs = 0
            if len(estimations_to_this_task) != 0:
                for estimation_to_this_task in estimations_to_this_task:
                    sum_costs += estimation_to_this_task.calculated_costs()
            if len(predecessor_reporting_periods) != 0:
                for predecessor_reporting_period in predecessor_reporting_periods:
                    sum_costs += self.effective_costs(reporting_period=predecessor_reporting_period)
        except ReportingPeriodNotFound:
            sum_costs = 0
        return sum_costs
Exemple #2
0
 def effective_accumulated_costs(self, reporting_period=None):
     if reporting_period:
         reporting_periods = ReportingPeriod.get_all_predecessors(target_reporting_period=reporting_period,
                                                                  project=self)
     else:
         reporting_periods = ReportingPeriod.objects.filter(project=self.id)
     effective_accumulated_costs = 0
     for single_reporting_period in reporting_periods:
         all_project_tasks = Task.objects.filter(project=self.id)
         for task in all_project_tasks:
             effective_accumulated_costs += float(task.effective_costs(reporting_period=single_reporting_period))
     return effective_accumulated_costs
Exemple #3
0
 def effective_accumulated_costs(self, reporting_period=None):
     if reporting_period:
         reporting_periods = ReportingPeriod.get_all_predecessors(target_reporting_period=reporting_period,
                                                                  project=self)
     else:
         reporting_periods = ReportingPeriod.objects.filter(project=self.id)
     effective_accumulated_costs = 0
     for single_reporting_period in reporting_periods:
         all_project_tasks = Task.objects.filter(project=self.id)
         for task in all_project_tasks:
             effective_accumulated_costs += float(task.effective_costs(reporting_period=single_reporting_period))
     getcontext().prec = 5
     effective_accumulated_costs = Decimal(effective_accumulated_costs)
     self.default_currency.round(effective_accumulated_costs)
     return effective_accumulated_costs
Exemple #4
0
 def effective_accumulated_costs(self, reporting_period=None):
     if reporting_period:
         reporting_periods = ReportingPeriod.get_all_predecessors(target_reporting_period=reporting_period,
                                                                  project=self)
     else:
         reporting_periods = ReportingPeriod.objects.filter(project=self.id)
     effective_accumulated_costs = 0
     for single_reporting_period in reporting_periods:
         all_project_tasks = Task.objects.filter(project=self.id)
         for task in all_project_tasks:
             effective_accumulated_costs += float(task.effective_costs(reporting_period=single_reporting_period))
     getcontext().prec = 5
     effective_accumulated_costs = Decimal(effective_accumulated_costs)
     self.default_currency.round(effective_accumulated_costs)
     return effective_accumulated_costs
Exemple #5
0
    def planned_costs(self, reporting_period=None):
        """The function returns the planned costs of resources which have been estimated for this task
         at a specific reporting period plus the costs of the effective effort before the provided reporting_period
         When no reporting_period is provided, the last reporting period

        is selected.

        Args:
        no arguments

        Returns:
        planned costs (Decimal), 0 if when no estimation or no reporting period is present

        Raises:
        No exceptions planned"""
        try:
            if not reporting_period:
                reporting_period_internal = ReportingPeriod.get_latest_reporting_period(
                    self.project)

            else:
                reporting_period_internal = ReportingPeriod.objects.get(
                    id=reporting_period.id)
            predecessor_reporting_periods = ReportingPeriod.get_all_predecessors(
                reporting_period_internal, self.project)
            estimations_to_this_task = Estimation.objects.filter(
                task=self.id, reporting_period=reporting_period_internal)
            sum_costs = 0
            if len(estimations_to_this_task) != 0:
                for estimation_to_this_task in estimations_to_this_task:
                    sum_costs += estimation_to_this_task.calculated_costs()
            if len(predecessor_reporting_periods) != 0:
                for predecessor_reporting_period in predecessor_reporting_periods:
                    sum_costs += self.effective_costs(
                        reporting_period=predecessor_reporting_period)
        except ReportingPeriodNotFound:
            sum_costs = 0
        return sum_costs