Search in sources :

Example 41 with ProjectTask

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);
    }
}
Also used : ProjectTaskCategory(com.axelor.apps.project.db.ProjectTaskCategory) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 42 with ProjectTask

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);
    }
}
Also used : ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 43 with ProjectTask

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;
}
Also used : TaskTemplate(com.axelor.apps.project.db.TaskTemplate) LocalDateTime(java.time.LocalDateTime) ArrayList(java.util.ArrayList) Product(com.axelor.apps.base.db.Product) ProjectTask(com.axelor.apps.project.db.ProjectTask) BigDecimal(java.math.BigDecimal) Transactional(com.google.inject.persist.Transactional)

Aggregations

ProjectTask (com.axelor.apps.project.db.ProjectTask)43 Transactional (com.google.inject.persist.Transactional)14 ArrayList (java.util.ArrayList)7 Project (com.axelor.apps.project.db.Project)6 TimerProjectTaskService (com.axelor.apps.project.service.TimerProjectTaskService)6 BigDecimal (java.math.BigDecimal)5 Product (com.axelor.apps.base.db.Product)4 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)4 InvoicingProject (com.axelor.apps.businessproject.db.InvoicingProject)3 TimesheetLine (com.axelor.apps.hr.db.TimesheetLine)3 ProjectTaskRepository (com.axelor.apps.project.db.repo.ProjectTaskRepository)3 AxelorException (com.axelor.exception.AxelorException)3 LocalDateTime (java.time.LocalDateTime)3 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)2 Timer (com.axelor.apps.base.db.Timer)2 TimerHistory (com.axelor.apps.base.db.TimerHistory)2 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)2 ExpenseLine (com.axelor.apps.hr.db.ExpenseLine)2 ProjectPlanningTime (com.axelor.apps.project.db.ProjectPlanningTime)2 ProjectTaskCategory (com.axelor.apps.project.db.ProjectTaskCategory)2