Exemple #1
0
 def update_work(self, request):
     from koalixcrm.crm.reporting.work import Work
     if self.has_changed():
         if self.cleaned_data['work_id']:
             work = Work.objects.get(id=self.cleaned_data['work_id'])
         else:
             work = Work()
         if self.cleaned_data['DELETE']:
             work.delete()
         else:
             work.task = self.cleaned_data['task']
             work.reporting_period = ReportingPeriod.get_reporting_period(project=self.cleaned_data['task'].project,
                                                                          search_date=self.cleaned_data['date'])
             work.employee = UserExtension.get_user_extension(request.user)
             work.date = self.cleaned_data['date']
             if bool(self.cleaned_data['start_time']) & bool(self.cleaned_data['stop_time']):
                 work.start_time = datetime.datetime.combine(self.cleaned_data['date'],
                                                             self.cleaned_data['start_time'])
                 work.stop_time = datetime.datetime.combine(self.cleaned_data['date'],
                                                            self.cleaned_data['stop_time'])
             else:
                 work.worked_hours = self.cleaned_data['worked_hours']
             work.description = self.cleaned_data['description']
             work.short_description = limit_string_length(work.description, 100)
             work.save()
 def update_work(self, request):
     from koalixcrm.crm.reporting.work import Work
     if self.has_changed():
         if self.cleaned_data['work_id']:
             work = Work.objects.get(id=self.cleaned_data['work_id'])
         else:
             work = Work()
         if self.cleaned_data['DELETE']:
             work.delete()
         else:
             work.task = self.cleaned_data['task']
             work.reporting_period = ReportingPeriod.get_reporting_period(project=self.cleaned_data['task'].project,
                                                                          search_date=self.cleaned_data['date'])
             work.human_resource = HumanResource.objects.get(user=UserExtension.get_user_extension(request.user))
             work.date = self.cleaned_data['date']
             if bool(self.cleaned_data['start_time']) & bool(self.cleaned_data['stop_time']):
                 work.start_time = datetime.datetime.combine(self.cleaned_data['date'],
                                                             self.cleaned_data['start_time'])
                 work.stop_time = datetime.datetime.combine(self.cleaned_data['date'],
                                                            self.cleaned_data['stop_time'])
             else:
                 work.worked_hours = self.cleaned_data['worked_hours']
             work.description = self.cleaned_data['description']
             work.short_description = limit_string_length(work.description, 100)
             work.save()
Exemple #3
0
    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_reporting_period(
                    self.project, global_support_functions.get_today_date())

            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 as e:
            effort = 0
        return effort
Exemple #4
0
    def get_reporting_period(self, search_date):
        from koalixcrm.crm.reporting.reporting_period import ReportingPeriod
        """Returns the reporting period that is valid. Valid is a reporting period when the provided date
          lies between begin and end of the reporting period

        Args:
          no arguments

        Returns:
          accounting_period (ReportPeriod)

        Raises:
          ReportPeriodNotFound when there is no valid reporting Period"""
        return ReportingPeriod.get_reporting_period(self, search_date)
Exemple #5
0
    def get_reporting_period(self, search_date):
        from koalixcrm.crm.reporting.reporting_period import ReportingPeriod
        """Returns the reporting period that is valid. Valid is a reporting period when the provided date
          lies between begin and end of the reporting period

        Args:
          no arguments

        Returns:
          accounting_period (ReportPeriod)

        Raises:
          ReportPeriodNotFound when there is no valid reporting Period"""
        return ReportingPeriod.get_reporting_period(self, search_date)
Exemple #6
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_reporting_period(
                    self.project, global_support_functions.get_today_date())

            else:
                reporting_period_internal = reporting_period
            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()
            for predecessor_reporting_period in predecessor_reporting_periods:
                sum_costs += self.effective_costs(
                    reporting_period=predecessor_reporting_period)
        except ReportingPeriodNotFound as e:
            sum_costs = 0
        return sum_costs