use of com.axelor.apps.project.db.ProjectTask 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);
}
}
use of com.axelor.apps.project.db.ProjectTask in project axelor-open-suite by axelor.
the class ProjectTaskController method updateDiscount.
public void updateDiscount(ActionRequest request, ActionResponse response) {
ProjectTask projectTask = request.getContext().asType(ProjectTask.class);
if (projectTask.getProduct() == null || projectTask.getProject() == null) {
return;
}
try {
projectTask = Beans.get(ProjectTaskBusinessProjectService.class).updateDiscount(projectTask);
response.setValue("discountTypeSelect", projectTask.getDiscountTypeSelect());
response.setValue("discountAmount", projectTask.getDiscountAmount());
response.setValue("priceDiscounted", projectTask.getPriceDiscounted());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.project.db.ProjectTask in project axelor-open-suite by axelor.
the class ProductTaskTemplateServiceImpl method convert.
@Override
@Transactional
public List<ProjectTask> convert(List<? extends TaskTemplate> templates, Project project, ProjectTask parent, LocalDateTime startDate, BigDecimal qty, SaleOrderLine saleOrderLine) throws AxelorException {
List<ProjectTask> tasks = new ArrayList<>();
Product product = saleOrderLine.getProduct();
for (TaskTemplate template : templates) {
BigDecimal qtyTmp = (template.getIsUniqueTaskForMultipleQuantity() ? BigDecimal.ONE : qty);
while (qtyTmp.signum() > 0) {
LocalDateTime dateWithDelay = startDate.plusHours(template.getDelayToStart().longValue());
ProjectTask task = projectTaskBusinessProjectService.create(template, project, dateWithDelay, qty);
task.setParentTask(parent);
task.setProduct(product);
task.setQuantity(!template.getIsUniqueTaskForMultipleQuantity() ? BigDecimal.ONE : qty);
task.setUnit(product.getUnit());
task.setUnitPrice((BigDecimal) productCompanyService.get(product, "salePrice", project.getCompany()));
task.setExTaxTotal(task.getUnitPrice().multiply(task.getQuantity()));
if (saleOrderLine.getSaleOrder().getToInvoiceViaTask()) {
task.setToInvoice(true);
task.setInvoicingType(ProjectTaskRepository.INVOICING_TYPE_PACKAGE);
}
tasks.add(projectTaskRepo.save(task));
// Only parent task can have multiple quantities
List<ProjectTask> children = convert(template.getTaskTemplateList(), project, task, dateWithDelay, BigDecimal.ONE, saleOrderLine);
tasks.addAll(children);
qtyTmp = qtyTmp.subtract(BigDecimal.ONE);
}
}
return tasks;
}
Aggregations