Search in sources :

Example 36 with ProjectTask

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

the class WorkflowVentilationProjectServiceImpl method afterVentilation.

@Override
@Transactional(rollbackOn = { Exception.class })
public void afterVentilation(Invoice invoice) throws AxelorException {
    super.afterVentilation(invoice);
    if (!Beans.get(AppBusinessProjectService.class).isApp("business-project")) {
        return;
    }
    InvoicingProject invoicingProject = invoicingProjectRepo.all().filter("self.invoice.id = ?", invoice.getId()).fetchOne();
    if (invoicingProject != null) {
        for (SaleOrderLine saleOrderLine : invoicingProject.getSaleOrderLineSet()) {
            saleOrderLine.setInvoiced(true);
        }
        for (PurchaseOrderLine purchaseOrderLine : invoicingProject.getPurchaseOrderLineSet()) {
            purchaseOrderLine.setInvoiced(true);
        }
        for (TimesheetLine timesheetLine : invoicingProject.getLogTimesSet()) {
            timesheetLine.setInvoiced(true);
            if (timesheetLine.getProjectTask() == null) {
                continue;
            }
            timesheetLine.getProjectTask().setInvoiced(this.checkInvoicedTimesheetLines(timesheetLine.getProjectTask()));
        }
        for (ExpenseLine expenseLine : invoicingProject.getExpenseLineSet()) {
            expenseLine.setInvoiced(true);
        }
        for (ProjectTask projectTask : invoicingProject.getProjectTaskSet()) {
            projectTask.setInvoiced(true);
        }
        for (Project project : invoicingProject.getProjectSet()) {
            project.setInvoiced(true);
        }
        invoicingProject.setStatusSelect(InvoicingProjectRepository.STATUS_VENTILATED);
        invoicingProjectRepo.save(invoicingProject);
    }
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) InvoicingProject(com.axelor.apps.businessproject.db.InvoicingProject) Project(com.axelor.apps.project.db.Project) TimesheetLine(com.axelor.apps.hr.db.TimesheetLine) ExpenseLine(com.axelor.apps.hr.db.ExpenseLine) ProjectTask(com.axelor.apps.project.db.ProjectTask) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) InvoicingProject(com.axelor.apps.businessproject.db.InvoicingProject) Transactional(com.google.inject.persist.Transactional)

Example 37 with ProjectTask

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

the class ProjectTaskBusinessProjectServiceImpl method create.

@Override
public ProjectTask create(TaskTemplate template, Project project, LocalDateTime date, BigDecimal qty) {
    ProjectTask task = create(template.getName(), project, template.getAssignedTo());
    task.setTaskDate(date.toLocalDate());
    task.setTaskEndDate(date.plusHours(template.getDuration().longValue()).toLocalDate());
    BigDecimal plannedHrs = template.getTotalPlannedHrs();
    if (template.getIsUniqueTaskForMultipleQuantity() && qty.compareTo(BigDecimal.ONE) > 0) {
        plannedHrs = plannedHrs.multiply(qty);
        task.setName(task.getName() + " x" + qty.intValue());
    }
    task.setTotalPlannedHrs(plannedHrs);
    return task;
}
Also used : ProjectTask(com.axelor.apps.project.db.ProjectTask) BigDecimal(java.math.BigDecimal)

Example 38 with ProjectTask

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

the class ProjectTaskBusinessProjectServiceImpl method create.

@Override
public ProjectTask create(SaleOrderLine saleOrderLine, Project project, User assignedTo) throws AxelorException {
    ProjectTask task = create(saleOrderLine.getFullName() + "_task", project, assignedTo);
    task.setProduct(saleOrderLine.getProduct());
    task.setUnit(saleOrderLine.getUnit());
    task.setCurrency(project.getClientPartner().getCurrency());
    if (project.getPriceList() != null) {
        PriceListLine line = priceListLineRepo.findByPriceListAndProduct(project.getPriceList(), saleOrderLine.getProduct());
        if (line != null) {
            task.setUnitPrice(line.getAmount());
        }
    }
    if (task.getUnitPrice() == null) {
        Company company = saleOrderLine.getSaleOrder() != null ? saleOrderLine.getSaleOrder().getCompany() : null;
        task.setUnitPrice((BigDecimal) productCompanyService.get(saleOrderLine.getProduct(), "salePrice", company));
    }
    task.setDescription(saleOrderLine.getDescription());
    task.setQuantity(saleOrderLine.getQty());
    task.setSaleOrderLine(saleOrderLine);
    task.setToInvoice(saleOrderLine.getSaleOrder() != null ? saleOrderLine.getSaleOrder().getToInvoiceViaTask() : false);
    return task;
}
Also used : Company(com.axelor.apps.base.db.Company) PriceListLine(com.axelor.apps.base.db.PriceListLine) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 39 with ProjectTask

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

the class ProjectTaskBusinessSupportRepository method copy.

@Override
public ProjectTask copy(ProjectTask entity, boolean deep) {
    ProjectTask task = super.copy(entity, deep);
    task.setTargetVersion(null);
    return task;
}
Also used : ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 40 with ProjectTask

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

the class ProjectBusinessSupportServiceImpl method createTask.

@Override
public ProjectTask createTask(TaskTemplate taskTemplate, Project project, Set<TaskTemplate> taskTemplateSet) {
    ProjectTask task = super.createTask(taskTemplate, project, taskTemplateSet);
    task.setInternalDescription(taskTemplate.getInternalDescription());
    return task;
}
Also used : ProjectTask(com.axelor.apps.project.db.ProjectTask)

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