Search in sources :

Example 1 with AppProductionService

use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.

the class ProductionOrderSaleOrderServiceBusinessImpl method createProductionOrder.

@Override
protected ProductionOrder createProductionOrder(SaleOrder saleOrder) throws AxelorException {
    ProductionOrder productionOrder = super.createProductionOrder(saleOrder);
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (appProductionService.isApp("production") && appProductionService.getAppProduction().getManageBusinessProduction()) {
        productionOrder.setProject(saleOrder.getProject());
    }
    return productionOrder;
}
Also used : ProductionOrder(com.axelor.apps.production.db.ProductionOrder) AppProductionService(com.axelor.apps.production.service.app.AppProductionService)

Example 2 with AppProductionService

use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.

the class ProductionOrderWizardServiceBusinessImpl method validate.

@Override
@SuppressWarnings("unchecked")
public Long validate(Context context) throws AxelorException {
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
        return super.validate(context);
    }
    Map<String, Object> bomContext = (Map<String, Object>) context.get("billOfMaterial");
    BillOfMaterial billOfMaterial = billOfMaterialRepo.find(((Integer) bomContext.get("id")).longValue());
    BigDecimal qty = new BigDecimal((String) context.get("qty"));
    Product product = null;
    if (context.get("product") != null) {
        Map<String, Object> productContext = (Map<String, Object>) context.get("product");
        product = productRepo.find(((Integer) productContext.get("id")).longValue());
    } else {
        product = billOfMaterial.getProduct();
    }
    ZonedDateTime startDateT, endDateT = null;
    if (context.containsKey("_startDate") && context.get("_startDate") != null) {
        startDateT = ZonedDateTime.parse(context.get("_startDate").toString(), DateTimeFormatter.ISO_INSTANT.withZone(ZoneId.systemDefault()));
    } else {
        startDateT = appProductionService.getTodayDateTime();
    }
    if (context.containsKey("_endDate") && context.get("_endDate") != null) {
        endDateT = ZonedDateTime.parse(context.get("_endDate").toString(), DateTimeFormatter.ISO_INSTANT.withZone(ZoneId.systemDefault()));
    }
    Project project = null;
    if (context.get("business_id") != null) {
        project = Beans.get(ProjectRepository.class).find(((Integer) context.get("business_id")).longValue());
    }
    ProductionOrder productionOrder = productionOrderServiceBusinessImpl.generateProductionOrder(product, billOfMaterial, qty, project, startDateT.toLocalDateTime(), endDateT != null ? endDateT.toLocalDateTime() : null, null);
    if (productionOrder != null) {
        return productionOrder.getId();
    } else {
        throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PRODUCTION_ORDER_2));
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) Product(com.axelor.apps.base.db.Product) BigDecimal(java.math.BigDecimal) BillOfMaterial(com.axelor.apps.production.db.BillOfMaterial) Project(com.axelor.apps.project.db.Project) ZonedDateTime(java.time.ZonedDateTime) Map(java.util.Map) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) ProductionOrder(com.axelor.apps.production.db.ProductionOrder)

Example 3 with AppProductionService

use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.

the class TimesheetBusinessProductionServiceImpl method cancel.

@Override
@Transactional
public void cancel(Timesheet timesheet) {
    super.cancel(timesheet);
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (appProductionService.isApp("production") && appProductionService.getAppProduction().getManageBusinessProduction()) {
        Beans.get(OperationOrderTimesheetServiceImpl.class).updateAllRealDuration(timesheet.getTimesheetLineList());
    }
}
Also used : AppProductionService(com.axelor.apps.production.service.app.AppProductionService) Transactional(com.google.inject.persist.Transactional)

Example 4 with AppProductionService

use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.

the class CostSheetServiceBusinessImpl method computeRealHumanResourceCost.

@Override
protected void computeRealHumanResourceCost(OperationOrder operationOrder, int priority, int bomLevel, CostSheetLine parentCostSheetLine, LocalDate previousCostSheetDate) throws AxelorException {
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
        super.computeRealHumanResourceCost(operationOrder, priority, bomLevel, parentCostSheetLine, previousCostSheetDate);
        return;
    }
    if (operationOrder.getTimesheetLineList() != null) {
        Long duration = 0L;
        if (parentCostSheetLine.getCostSheet().getCalculationTypeSelect() == CostSheetRepository.CALCULATION_END_OF_PRODUCTION || parentCostSheetLine.getCostSheet().getCalculationTypeSelect() == CostSheetRepository.CALCULATION_PARTIAL_END_OF_PRODUCTION) {
            Period period = previousCostSheetDate != null ? Period.between(parentCostSheetLine.getCostSheet().getCalculationDate(), previousCostSheetDate) : null;
            duration = period != null ? Long.valueOf(period.getDays() * 24) : operationOrder.getRealDuration();
        } else if (parentCostSheetLine.getCostSheet().getCalculationTypeSelect() == CostSheetRepository.CALCULATION_WORK_IN_PROGRESS) {
            duration = operationOrder.getRealDuration() - (operationOrder.getPlannedDuration() * costSheet.getManufOrderProducedRatio().longValue());
        }
        // TODO get the timesheet Line done when we run the calculation.
        this.computeRealHumanResourceCost(null, operationOrder.getWorkCenter(), priority, bomLevel, parentCostSheetLine, duration);
    }
}
Also used : Period(java.time.Period) AppProductionService(com.axelor.apps.production.service.app.AppProductionService)

Example 5 with AppProductionService

use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.

the class InvoicingProjectServiceBusinessProdImpl method setLines.

@Override
public void setLines(InvoicingProject invoicingProject, Project project, int counter) {
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
        super.setLines(invoicingProject, project, counter);
        return;
    }
    if (counter > ProjectServiceImpl.MAX_LEVEL_OF_PROJECT) {
        return;
    }
    counter++;
    this.fillLines(invoicingProject, project);
    if (!invoicingProject.getConsolidatePhaseWhenInvoicing()) {
        return;
    }
    List<Project> projectChildrenList = Beans.get(ProjectRepository.class).all().filter("self.parentProject = ?1", project).fetch();
    for (Project projectChild : projectChildrenList) {
        this.setLines(invoicingProject, projectChild, counter);
    }
    return;
}
Also used : InvoicingProject(com.axelor.apps.businessproject.db.InvoicingProject) Project(com.axelor.apps.project.db.Project) ProjectRepository(com.axelor.apps.project.db.repo.ProjectRepository) AppProductionService(com.axelor.apps.production.service.app.AppProductionService)

Aggregations

AppProductionService (com.axelor.apps.production.service.app.AppProductionService)18 Transactional (com.google.inject.persist.Transactional)6 ManufOrder (com.axelor.apps.production.db.ManufOrder)4 AxelorException (com.axelor.exception.AxelorException)3 ProductionOrder (com.axelor.apps.production.db.ProductionOrder)2 Project (com.axelor.apps.project.db.Project)2 BigDecimal (java.math.BigDecimal)2 PriceList (com.axelor.apps.base.db.PriceList)1 Product (com.axelor.apps.base.db.Product)1 Sequence (com.axelor.apps.base.db.Sequence)1 InvoicingProject (com.axelor.apps.businessproject.db.InvoicingProject)1 Employee (com.axelor.apps.hr.db.Employee)1 BillOfMaterial (com.axelor.apps.production.db.BillOfMaterial)1 OperationOrder (com.axelor.apps.production.db.OperationOrder)1 ProdHumanResource (com.axelor.apps.production.db.ProdHumanResource)1 ManufOrderRepository (com.axelor.apps.production.db.repo.ManufOrderRepository)1 OperationOrderRepository (com.axelor.apps.production.db.repo.OperationOrderRepository)1 ProjectRepository (com.axelor.apps.project.db.repo.ProjectRepository)1 PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)1 LocalDateTime (java.time.LocalDateTime)1