Search in sources :

Example 21 with OperationOrder

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

the class ManufOrderServiceBusinessImpl method propagateIsToInvoice.

@Transactional
public void propagateIsToInvoice(ManufOrder manufOrder) {
    logger.debug("{} is to invoice ? {}", manufOrder.getManufOrderSeq(), manufOrder.getIsToInvoice());
    boolean isToInvoice = manufOrder.getIsToInvoice();
    if (manufOrder.getOperationOrderList() != null) {
        for (OperationOrder operationOrder : manufOrder.getOperationOrderList()) {
            operationOrder.setIsToInvoice(isToInvoice);
        }
    }
    manufOrderRepo.save(manufOrder);
}
Also used : OperationOrder(com.axelor.apps.production.db.OperationOrder) Transactional(com.google.inject.persist.Transactional)

Example 22 with OperationOrder

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

the class OperationOrderServiceBusinessImpl method createOperationOrder.

@Transactional
public OperationOrder createOperationOrder(ManufOrder manufOrder, int priority, boolean isToInvoice, WorkCenter workCenter, Machine machine, MachineTool machineTool, ProdProcessLine prodProcessLine) throws AxelorException {
    logger.debug("Création d'une opération {} pour l'OF {}", priority, manufOrder.getManufOrderSeq());
    String operationName = prodProcessLine.getName();
    OperationOrder operationOrder = new OperationOrder(priority, this.computeName(manufOrder, priority, operationName), operationName, manufOrder, workCenter, machine, OperationOrderRepository.STATUS_DRAFT, prodProcessLine, machineTool);
    operationOrder.setIsToInvoice(isToInvoice);
    this._createHumanResourceList(operationOrder, workCenter);
    return Beans.get(OperationOrderRepository.class).save(operationOrder);
}
Also used : OperationOrderRepository(com.axelor.apps.production.db.repo.OperationOrderRepository) OperationOrder(com.axelor.apps.production.db.OperationOrder) Transactional(com.google.inject.persist.Transactional)

Example 23 with OperationOrder

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

the class OperationOrderServiceBusinessImpl method createOperationOrder.

@Override
@Transactional(rollbackOn = { Exception.class })
public OperationOrder createOperationOrder(ManufOrder manufOrder, ProdProcessLine prodProcessLine) throws AxelorException {
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
        return super.createOperationOrder(manufOrder, prodProcessLine);
    }
    if (prodProcessLine.getWorkCenter() == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.PROD_PROCESS_LINE_MISSING_WORK_CENTER), prodProcessLine.getProdProcess() != null ? prodProcessLine.getProdProcess().getCode() : "null", prodProcessLine.getName());
    }
    OperationOrder operationOrder = this.createOperationOrder(manufOrder, prodProcessLine.getPriority(), manufOrder.getIsToInvoice(), prodProcessLine.getWorkCenter(), prodProcessLine.getWorkCenter().getMachine(), prodProcessLine.getMachineTool(), prodProcessLine);
    return Beans.get(OperationOrderRepository.class).save(operationOrder);
}
Also used : AxelorException(com.axelor.exception.AxelorException) OperationOrderRepository(com.axelor.apps.production.db.repo.OperationOrderRepository) OperationOrder(com.axelor.apps.production.db.OperationOrder) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) Transactional(com.google.inject.persist.Transactional)

Example 24 with OperationOrder

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

the class OperationOrderTimesheetServiceImpl method updateOperationOrders.

@Override
@Transactional(rollbackOn = { Exception.class })
public void updateOperationOrders(Timesheet timesheet) throws AxelorException {
    if (timesheet.getTimesheetLineList() == null) {
        return;
    }
    // ensure that correct hoursDuration is filled
    TimesheetLineService timesheetLineService = Beans.get(TimesheetLineService.class);
    for (TimesheetLine timesheetLine : timesheet.getTimesheetLineList()) {
        BigDecimal hoursDuration = timesheetLineService.computeHoursDuration(timesheet, timesheetLine.getDuration(), true);
        timesheetLine.setHoursDuration(hoursDuration);
    }
    if (!Beans.get(AppProductionService.class).getAppProduction().getEnableTimesheetOnManufOrder()) {
        return;
    }
    List<TimesheetLine> oldTimesheetLineList = Beans.get(TimesheetLineRepository.class).all().filter("self.timesheet.id = :timesheetId").bind("timesheetId", timesheet.getId()).fetch();
    List<TimesheetLine> newTimesheetLineList = timesheet.getTimesheetLineList();
    List<TimesheetLine> allTimesheetLineList = new ArrayList<>(oldTimesheetLineList);
    allTimesheetLineList.addAll(newTimesheetLineList);
    List<OperationOrder> operationOrdersToUpdate = allTimesheetLineList.stream().map(TimesheetLine::getOperationOrder).filter(Objects::nonNull).distinct().collect(Collectors.toList());
    operationOrdersToUpdate.forEach(operationOrder -> updateOperationOrder(operationOrder, oldTimesheetLineList, newTimesheetLineList));
}
Also used : TimesheetLine(com.axelor.apps.hr.db.TimesheetLine) TimesheetLineService(com.axelor.apps.hr.service.timesheet.TimesheetLineService) ArrayList(java.util.ArrayList) Objects(java.util.Objects) OperationOrder(com.axelor.apps.production.db.OperationOrder) BigDecimal(java.math.BigDecimal) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) Transactional(com.google.inject.persist.Transactional)

Example 25 with OperationOrder

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

the class OperationOrderController method computeDuration.

public void computeDuration(ActionRequest request, ActionResponse response) {
    OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
    operationOrder = Beans.get(OperationOrderRepository.class).find(operationOrder.getId());
    Beans.get(OperationOrderWorkflowService.class).computeDuration(operationOrder);
    response.setReload(true);
}
Also used : OperationOrderWorkflowService(com.axelor.apps.production.service.operationorder.OperationOrderWorkflowService) OperationOrder(com.axelor.apps.production.db.OperationOrder)

Aggregations

OperationOrder (com.axelor.apps.production.db.OperationOrder)44 Transactional (com.google.inject.persist.Transactional)24 IOException (java.io.IOException)12 BirtException (org.eclipse.birt.core.exception.BirtException)11 OperationOrderWorkflowService (com.axelor.apps.production.service.operationorder.OperationOrderWorkflowService)10 AxelorException (com.axelor.exception.AxelorException)9 BigDecimal (java.math.BigDecimal)9 OperationOrderRepository (com.axelor.apps.production.db.repo.OperationOrderRepository)8 AppProductionService (com.axelor.apps.production.service.app.AppProductionService)7 LocalDateTime (java.time.LocalDateTime)7 ArrayList (java.util.ArrayList)6 ManufOrder (com.axelor.apps.production.db.ManufOrder)5 Company (com.axelor.apps.base.db.Company)4 ProdProduct (com.axelor.apps.production.db.ProdProduct)4 StockMove (com.axelor.apps.stock.db.StockMove)4 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)4 DayPlanning (com.axelor.apps.base.db.DayPlanning)3 ProdProcessLine (com.axelor.apps.production.db.ProdProcessLine)3 ManufOrderStockMoveService (com.axelor.apps.production.service.manuforder.ManufOrderStockMoveService)3 ProductionOrderService (com.axelor.apps.production.service.productionorder.ProductionOrderService)3