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
def planned_effort(self, reporting_period=None): """The function return the planned effort of resources which have been estimated for this task at a specific reporting period. When no reporting_period is provided, the last reporting period is selected Args: no arguments Returns: planned effort (Decimal) [hrs], 0 if when no estimation are present Raises: no exceptions expected""" try: if not reporting_period: reporting_period_internal = ReportingPeriod.get_latest_reporting_period( self.project) else: reporting_period_internal = reporting_period estimations_to_this_task = Estimation.objects.filter(task=self.id, reporting_period=reporting_period_internal) effort = 0 for estimation_to_this_task in estimations_to_this_task: effort += estimation_to_this_task.amount except ReportingPeriodNotFound: effort = 0 return effort
def planned_effort(self, reporting_period=None): """The function return the planned effort of resources which have been estimated for this task at a specific reporting period. When no reporting_period is provided, the last reporting period is selected Args: no arguments Returns: planned effort (Decimal) [hrs], 0 if when no estimation are present Raises: no exceptions expected""" try: if not reporting_period: reporting_period_internal = ReportingPeriod.get_latest_reporting_period( self.project) else: reporting_period_internal = reporting_period estimations_to_this_task = Estimation.objects.filter( task=self.id, reporting_period=reporting_period_internal) effort = 0 for estimation_to_this_task in estimations_to_this_task: effort += estimation_to_this_task.amount except ReportingPeriodNotFound: effort = 0 return effort
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