Search in sources :

Example 11 with AppProductionService

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

the class TimesheetBusinessProductionServiceImpl method draft.

@Override
@Transactional
public void draft(Timesheet timesheet) {
    super.draft(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 12 with AppProductionService

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

the class CostSheetServiceBusinessImpl method _computeHumanResourceCost.

@Override
protected void _computeHumanResourceCost(ProdHumanResource prodHumanResource, int priority, int bomLevel, CostSheetLine parentCostSheetLine) throws AxelorException {
    Employee employee = prodHumanResource.getEmployee();
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (appProductionService.isApp("production") && appProductionService.getAppProduction().getManageBusinessProduction() && employee != null && !EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
        BigDecimal durationHours = new BigDecimal(prodHumanResource.getDuration()).divide(BigDecimal.valueOf(3600), appProductionService.getNbDecimalDigitForUnitPrice(), BigDecimal.ROUND_HALF_UP);
        costSheet.addCostSheetLineListItem(costSheetLineService.createWorkCenterHRCostSheetLine(prodHumanResource.getWorkCenter(), prodHumanResource, priority, bomLevel, parentCostSheetLine, durationHours, employee.getHourlyRate().multiply(durationHours), hourUnit));
    } else {
        super._computeHumanResourceCost(prodHumanResource, priority, bomLevel, parentCostSheetLine);
    }
}
Also used : Employee(com.axelor.apps.hr.db.Employee) BigDecimal(java.math.BigDecimal) AppProductionService(com.axelor.apps.production.service.app.AppProductionService)

Example 13 with AppProductionService

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

the class InvoicingProjectServiceBusinessProdImpl method fillLines.

@Override
public void fillLines(InvoicingProject invoicingProject, Project project) {
    super.fillLines(invoicingProject, project);
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
        return;
    }
    if (invoicingProject.getManufOrderSet() == null) {
        invoicingProject.setManufOrderSet(new HashSet<ManufOrder>());
    }
    if (invoicingProject.getDeadlineDate() != null) {
        LocalDateTime deadlineDateToDateTime = invoicingProject.getDeadlineDate().atStartOfDay();
        invoicingProject.getManufOrderSet().addAll(Beans.get(ManufOrderRepository.class).all().filter("self.productionOrderSet.project = ?1 AND (self.realStartDateT < ?2)", project, deadlineDateToDateTime).fetch());
    } else {
        invoicingProject.getManufOrderSet().addAll(Beans.get(ManufOrderRepository.class).all().filter("self.productionOrderSet.project = ?1", project).fetch());
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 14 with AppProductionService

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

the class InvoicingProjectServiceBusinessProdImpl method countToInvoice.

@Override
public int countToInvoice(Project project) {
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    int toInvoiceCount = super.countToInvoice(project);
    if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
        return toInvoiceCount;
    }
    int productionOrderCount = (int) Beans.get(ManufOrderRepository.class).all().filter("self.productionOrderSet.project = ?1", project).count();
    toInvoiceCount += productionOrderCount;
    return toInvoiceCount;
}
Also used : AppProductionService(com.axelor.apps.production.service.app.AppProductionService)

Example 15 with AppProductionService

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

the class InvoicingProjectServiceBusinessProdImpl method clearLines.

@Override
public void clearLines(InvoicingProject invoicingProject) {
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    super.clearLines(invoicingProject);
    if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
        return;
    }
    invoicingProject.setManufOrderSet(new HashSet<ManufOrder>());
}
Also used : AppProductionService(com.axelor.apps.production.service.app.AppProductionService) ManufOrder(com.axelor.apps.production.db.ManufOrder)

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