예제 #1
0
    def get_task_manager_cost(self, project_id):
        """
        计算所有任务负责人平均工资
        """

        if project_id is not None:
            duration = 0

            project = Project.objects.get(id=project_id)
            if project is not None:
                duration = BusinessPublic.Caltime(project.end_time, project.begin_time)

            from business.models.task import Task
            tasks = Task.objects.filter(project_id=project_id, is_active=1)
            all_total_fee = 0
            salary = 0

            for task in tasks:
                if task:
                    if task.receiver:
                        receiver_id = task.receiver.id
                        user = UserProfile.objects.get(id=receiver_id)
                        if user:
                            salary = user.base_salary
                    else:
                        task_type = TaskType.objects.get(id=task.task_type.id)
                        salary = task_type.average_salary

                    aveage_fee = salary / 21.75
                    aveage_fee = round(aveage_fee, 2)

                    total_fee = duration * aveage_fee
                    total_fee = round(total_fee, 2)

                    salary_obj = {}
                    salary_obj["person_nums"] = 1
                    if task.receiver:
                        salary_obj["user"] = task.receiver.name
                    else:
                        salary_obj["user"] = ''
                    salary_obj["duration"] = duration
                    salary_obj["name"] = '平均工资'
                    salary_obj["fee"] = int(aveage_fee)
                    salary_obj["total_fee"] = int(total_fee)

                    salary_obj["task"] = {}
                    salary_obj["type"] = 1
                    salary_obj["role"] = "任务负责人"

                    list_project_person_objects.append(salary_obj)

                    all_total_fee = all_total_fee + int(total_fee)

            return all_total_fee
예제 #2
0
    def get_projectfee_cost(self, project_id):
        if project_id is not None:
            project = Project.objects.get(id=project_id)
            if project:
                duration = BusinessPublic.Caltime(project.end_time, project.begin_time)

                all_total_fee = 0
                tasks = Task.objects.filter(project_id=project_id, is_active=1)
                if tasks:
                    # 项目总人数 = 任务总人数 + 项目负责人 + 商务人员
                    project_person_nums = tasks.count() + 2

                    # 公司总人数
                    users = UserProfile.objects.filter(base_salary__gt=0)
                    if users:
                        company_person_nums = users.count()

                        fees = ProjectFee.objects.filter(project_id=project.id)
                        if fees:
                            for fee in fees:
                                aveage_fee = fee.value / company_person_nums
                                aveage_fee = aveage_fee / 30
                                aveage_fee = round(aveage_fee, 2)

                                total_fee = aveage_fee * project_person_nums * duration
                                total_fee = round(total_fee, 2)

                                fee_obj = {}
                                fee_obj["id"] = ''
                                fee_obj["person_nums"] = project_person_nums
                                fee_obj["duration"] = duration
                                fee_obj["name"] = fee.name
                                fee_obj["fee"] = int(aveage_fee)
                                fee_obj["total_fee"] = int(total_fee)
                                fee_obj["type"] = 1
                                list_project_fee_objects.append(fee_obj)

                                all_total_fee = all_total_fee + int(total_fee)

                return all_total_fee
예제 #3
0
    def get_market_manager_cost(self, project_id):
        """
        计算商务人员平均工资
        """

        if project_id is not None:
            project = Project.objects.get(id=project_id)
            if project is not None:
                if project.sender:

                    duration = BusinessPublic.Caltime(project.end_time, project.begin_time)
                    sender_id = project.sender.id

                    user = UserProfile.objects.get(id=sender_id)
                    if user:
                        salary = user.base_salary

                        aveage_fee = salary / 21.75
                        aveage_fee = round(aveage_fee, 2)

                        total_fee = duration * aveage_fee
                        total_fee = round(total_fee, 2)

                        salary_obj = {}
                        salary_obj["person_nums"] = 1
                        salary_obj["user"] = user.name
                        salary_obj["duration"] = duration
                        salary_obj["name"] = '平均工资'
                        salary_obj["fee"] = int(aveage_fee)
                        salary_obj["total_fee"] = int(total_fee)

                        salary_obj["project"] = {}
                        salary_obj["type"] = 0
                        salary_obj["role"] = "商务人员"

                        list_project_person_objects.append(salary_obj)

                        return int(total_fee)