Search in sources :

Example 1 with ProjectTaskCategory

use of com.axelor.apps.project.db.ProjectTaskCategory in project axelor-open-suite by axelor.

the class ProjectTaskBusinessProjectServiceImpl method computeDefaultInformation.

@Override
public ProjectTask computeDefaultInformation(ProjectTask projectTask) throws AxelorException {
    Product product = projectTask.getProduct();
    if (product != null) {
        projectTask.setInvoicingType(ProjectTaskRepository.INVOICING_TYPE_PACKAGE);
        if (projectTask.getUnitPrice() == null || projectTask.getUnitPrice().compareTo(BigDecimal.ZERO) == 0) {
            projectTask.setUnitPrice(this.computeUnitPrice(projectTask));
        }
    } else {
        ProjectTaskCategory projectTaskCategory = projectTask.getProjectTaskCategory();
        if (projectTaskCategory == null) {
            return projectTask;
        }
        projectTask.setInvoicingType(projectTaskCategory.getDefaultInvoicingType());
        projectTask.setProduct(projectTaskCategory.getDefaultProduct());
        product = projectTask.getProduct();
        if (product == null) {
            return projectTask;
        }
        projectTask.setUnitPrice(this.computeUnitPrice(projectTask));
    }
    Company company = projectTask.getProject() != null ? projectTask.getProject().getCompany() : null;
    Unit salesUnit = (Unit) productCompanyService.get(product, "salesUnit", company);
    projectTask.setUnit(salesUnit != null ? salesUnit : (Unit) productCompanyService.get(product, "unit", company));
    projectTask.setCurrency((Currency) productCompanyService.get(product, "saleCurrency", company));
    projectTask.setQuantity(projectTask.getBudgetedTime());
    projectTask.setQuantity(projectTask.getBudgetedTime() == null || projectTask.getBudgetedTime().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ONE : projectTask.getBudgetedTime());
    projectTask = this.updateDiscount(projectTask);
    projectTask = this.compute(projectTask);
    return projectTask;
}
Also used : ProjectTaskCategory(com.axelor.apps.project.db.ProjectTaskCategory) Company(com.axelor.apps.base.db.Company) Product(com.axelor.apps.base.db.Product) Unit(com.axelor.apps.base.db.Unit)

Example 2 with ProjectTaskCategory

use of com.axelor.apps.project.db.ProjectTaskCategory in project axelor-open-suite by axelor.

the class ProjectServiceImpl method createTask.

public ProjectTask createTask(TaskTemplate taskTemplate, Project project, Set<TaskTemplate> taskTemplateSet) {
    if (!ObjectUtils.isEmpty(project.getProjectTaskList())) {
        for (ProjectTask projectTask : project.getProjectTaskList()) {
            if (projectTask.getName().equals(taskTemplate.getName())) {
                return projectTask;
            }
        }
    }
    ProjectTask task = projectTaskService.create(taskTemplate.getName(), project, taskTemplate.getAssignedTo());
    task.setDescription(taskTemplate.getDescription());
    ProjectTaskCategory projectTaskCategory = taskTemplate.getProjectTaskCategory();
    if (projectTaskCategory != null) {
        task.setProjectTaskCategory(projectTaskCategory);
        project.addProjectTaskCategorySetItem(projectTaskCategory);
    }
    TaskTemplate parentTaskTemplate = taskTemplate.getParentTaskTemplate();
    if (parentTaskTemplate != null && taskTemplateSet.contains(parentTaskTemplate)) {
        task.setParentTask(this.createTask(parentTaskTemplate, project, taskTemplateSet));
        return task;
    }
    return task;
}
Also used : TaskTemplate(com.axelor.apps.project.db.TaskTemplate) ProjectTaskCategory(com.axelor.apps.project.db.ProjectTaskCategory) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 3 with ProjectTaskCategory

use of com.axelor.apps.project.db.ProjectTaskCategory in project axelor-open-suite by axelor.

the class ProjectTaskController method onChangeCategory.

public void onChangeCategory(ActionRequest request, ActionResponse response) {
    ProjectTask task = request.getContext().asType(ProjectTask.class);
    ProjectTaskCategory projectTaskCategory = task.getProjectTaskCategory();
    try {
        task = businessProjectService.resetProjectTaskValues(task);
        if (projectTaskCategory != null) {
            task = businessProjectService.computeDefaultInformation(task);
        }
        if (task.getInvoicingType() == ProjectTaskRepository.INVOICING_TYPE_TIME_SPENT) {
            task.setToInvoice(true);
        }
        response.setValues(task);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ProjectTaskCategory(com.axelor.apps.project.db.ProjectTaskCategory) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Aggregations

ProjectTaskCategory (com.axelor.apps.project.db.ProjectTaskCategory)3 ProjectTask (com.axelor.apps.project.db.ProjectTask)2 Company (com.axelor.apps.base.db.Company)1 Product (com.axelor.apps.base.db.Product)1 Unit (com.axelor.apps.base.db.Unit)1 TaskTemplate (com.axelor.apps.project.db.TaskTemplate)1