Search in sources :

Example 16 with ProjectTask

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

the class ProjectTaskServiceImpl method updateNextTask.

@Override
@Transactional
public void updateNextTask(ProjectTask projectTask) {
    ProjectTask nextProjectTask = projectTask.getNextProjectTask();
    if (nextProjectTask != null) {
        updateModuleFields(projectTask, nextProjectTask);
        projectTaskRepo.save(nextProjectTask);
        updateNextTask(nextProjectTask);
    }
}
Also used : ProjectTask(com.axelor.apps.project.db.ProjectTask) Transactional(com.google.inject.persist.Transactional)

Example 17 with ProjectTask

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

the class ProjectTaskServiceImpl method create.

@Override
@Transactional
public ProjectTask create(String subject, Project project, User assignedTo) {
    ProjectTask task = new ProjectTask();
    task.setName(subject);
    task.setAssignedTo(assignedTo);
    task.setTaskDate(appBaseService.getTodayDate(project.getCompany()));
    task.setStatus(ProjectTaskRepository.STATUS_NEW);
    task.setPriority(ProjectTaskRepository.PRIORITY_NORMAL);
    project.addProjectTaskListItem(task);
    projectTaskRepo.save(task);
    return task;
}
Also used : ProjectTask(com.axelor.apps.project.db.ProjectTask) Transactional(com.google.inject.persist.Transactional)

Example 18 with ProjectTask

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

the class ProjectTaskBusinessProjectServiceImpl method createInvoiceLines.

@Override
public List<InvoiceLine> createInvoiceLines(Invoice invoice, List<ProjectTask> projectTaskList, int priority) throws AxelorException {
    List<InvoiceLine> invoiceLineList = new ArrayList<>();
    int count = 0;
    for (ProjectTask projectTask : projectTaskList) {
        invoiceLineList.addAll(this.createInvoiceLine(invoice, projectTask, priority * 100 + count));
        count++;
    }
    return invoiceLineList;
}
Also used : InvoiceLine(com.axelor.apps.account.db.InvoiceLine) ArrayList(java.util.ArrayList) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 19 with ProjectTask

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

the class InvoicingProjectService method populate.

public List<InvoiceLine> populate(Invoice invoice, InvoicingProject folder) throws AxelorException {
    List<SaleOrderLine> saleOrderLineList = new ArrayList<SaleOrderLine>(folder.getSaleOrderLineSet());
    List<PurchaseOrderLine> purchaseOrderLineList = new ArrayList<PurchaseOrderLine>(folder.getPurchaseOrderLineSet());
    List<TimesheetLine> timesheetLineList = new ArrayList<TimesheetLine>(folder.getLogTimesSet());
    List<ExpenseLine> expenseLineList = new ArrayList<ExpenseLine>(folder.getExpenseLineSet());
    List<ProjectTask> projectTaskList = new ArrayList<ProjectTask>(folder.getProjectTaskSet());
    List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>();
    invoiceLineList.addAll(this.createSaleOrderInvoiceLines(invoice, saleOrderLineList, folder.getSaleOrderLineSetPrioritySelect()));
    invoiceLineList.addAll(this.createPurchaseOrderInvoiceLines(invoice, purchaseOrderLineList, folder.getPurchaseOrderLineSetPrioritySelect()));
    invoiceLineList.addAll(timesheetService.createInvoiceLines(invoice, timesheetLineList, folder.getLogTimesSetPrioritySelect()));
    invoiceLineList.addAll(expenseService.createInvoiceLines(invoice, expenseLineList, folder.getExpenseLineSetPrioritySelect()));
    invoiceLineList.addAll(projectTaskBusinessProjectService.createInvoiceLines(invoice, projectTaskList, folder.getProjectTaskSetPrioritySelect()));
    Collections.sort(invoiceLineList, new InvoiceLineComparator());
    for (InvoiceLine invoiceLine : invoiceLineList) {
        invoiceLine.setSequence(sequence);
        sequence++;
    }
    return invoiceLineList;
}
Also used : InvoiceLineComparator(com.axelor.apps.account.util.InvoiceLineComparator) TimesheetLine(com.axelor.apps.hr.db.TimesheetLine) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) ArrayList(java.util.ArrayList) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) ExpenseLine(com.axelor.apps.hr.db.ExpenseLine) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 20 with ProjectTask

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

the class ProjectPlanningTimeServiceImpl method addMultipleProjectPlanningTime.

@Override
@Transactional(rollbackOn = { Exception.class })
public void addMultipleProjectPlanningTime(Map<String, Object> datas) throws AxelorException {
    if (datas.get("project") == null || datas.get("user") == null || datas.get("fromDate") == null || datas.get("toDate") == null) {
        return;
    }
    DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
    LocalDateTime fromDate = LocalDateTime.parse(datas.get("fromDate").toString(), formatter);
    LocalDateTime toDate = LocalDateTime.parse(datas.get("toDate").toString(), formatter);
    ProjectTask projectTask = null;
    Map<String, Object> objMap = (Map) datas.get("project");
    Project project = projectRepo.find(Long.parseLong(objMap.get("id").toString()));
    Integer timePercent = 0;
    if (datas.get("timepercent") != null) {
        timePercent = Integer.parseInt(datas.get("timepercent").toString());
    }
    objMap = (Map) datas.get("user");
    User user = userRepo.find(Long.parseLong(objMap.get("id").toString()));
    if (user.getEmployee() == null) {
        return;
    }
    if (datas.get("task") != null) {
        objMap = (Map) datas.get("task");
        projectTask = projectTaskRepo.find(Long.valueOf(objMap.get("id").toString()));
    }
    Product activity = null;
    if (datas.get("product") != null) {
        objMap = (Map) datas.get("product");
        activity = productRepo.find(Long.valueOf(objMap.get("id").toString()));
    }
    Employee employee = user.getEmployee();
    BigDecimal dailyWorkHrs = employee.getDailyWorkHours();
    while (fromDate.isBefore(toDate)) {
        LocalDate date = fromDate.toLocalDate();
        LOG.debug("Create Planning for the date: {}", date);
        double dayHrs = 0;
        if (employee.getWeeklyPlanning() != null) {
            dayHrs = weeklyPlanningService.getWorkingDayValueInDays(employee.getWeeklyPlanning(), date);
        }
        if (dayHrs > 0 && !holidayService.checkPublicHolidayDay(date, employee)) {
            ProjectPlanningTime planningTime = new ProjectPlanningTime();
            planningTime.setProjectTask(projectTask);
            planningTime.setProduct(activity);
            planningTime.setTimepercent(timePercent);
            planningTime.setUser(user);
            planningTime.setDate(date);
            planningTime.setProject(project);
            planningTime.setIsIncludeInTurnoverForecast((Boolean) datas.get("isIncludeInTurnoverForecast"));
            BigDecimal totalHours = BigDecimal.ZERO;
            if (timePercent > 0) {
                totalHours = dailyWorkHrs.multiply(new BigDecimal(timePercent)).divide(new BigDecimal(100));
            }
            planningTime.setPlannedHours(totalHours);
            planningTimeRepo.save(planningTime);
        }
        fromDate = fromDate.plusDays(1);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) User(com.axelor.auth.db.User) Product(com.axelor.apps.base.db.Product) ProjectPlanningTime(com.axelor.apps.project.db.ProjectPlanningTime) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) Project(com.axelor.apps.project.db.Project) Employee(com.axelor.apps.hr.db.Employee) ProjectTask(com.axelor.apps.project.db.ProjectTask) DateTimeFormatter(java.time.format.DateTimeFormatter) Map(java.util.Map) 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