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;
}
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;
}
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);
}
}
Aggregations