use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class StockMoveLineController method compute.
public void compute(ActionRequest request, ActionResponse response) throws AxelorException {
StockMoveLine stockMoveLine = request.getContext().asType(StockMoveLine.class);
Optional<StockMove> stockMove = Optional.ofNullable(stockMoveLine.getStockMove());
if (!stockMove.isPresent()) {
Context parentContext = request.getContext().getParent();
if (parentContext.getContextClass().equals(StockMove.class)) {
stockMove = Optional.ofNullable(parentContext.asType(StockMove.class));
} else if (parentContext.getContextClass().equals(ManufOrder.class)) {
ManufOrder manufOrder = parentContext.asType(ManufOrder.class);
ManufOrderStockMoveService manufOrderStockMoveService = Beans.get(ManufOrderStockMoveService.class);
stockMove = manufOrderStockMoveService.getPlannedStockMove(manufOrder.getInStockMoveList());
}
if (!stockMove.isPresent()) {
return;
}
}
stockMoveLine = Beans.get(StockMoveLineService.class).compute(stockMoveLine, stockMove.get());
response.setValue("companyPurchasePrice", stockMoveLine.getCompanyPurchasePrice());
response.setValue("unitPriceUntaxed", stockMoveLine.getUnitPriceUntaxed());
response.setValue("unitPriceTaxed", stockMoveLine.getUnitPriceTaxed());
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class StockMoveLineController method setProductInfo.
/**
* Called from stock move line form. Fill product info using the company either from the stock
* move line, from the parent stock move or the parent manuf order.
*
* @param request
* @param response
*/
public void setProductInfo(ActionRequest request, ActionResponse response) {
StockMoveLine stockMoveLine;
try {
stockMoveLine = request.getContext().asType(StockMoveLine.class);
Company company;
StockMove stockMove = stockMoveLine.getStockMove();
if (stockMove == null) {
Context parentContext = request.getContext().getParent();
if (parentContext.getContextClass().equals(StockMove.class)) {
stockMove = parentContext.asType(StockMove.class);
company = stockMove.getCompany();
} else if (parentContext.getContextClass().equals(ManufOrder.class)) {
ManufOrder manufOrder = parentContext.asType(ManufOrder.class);
company = manufOrder.getCompany();
} else if (parentContext.getContextClass().equals(OperationOrder.class)) {
OperationOrder operationOrder = parentContext.asType(OperationOrder.class);
if (operationOrder.getManufOrder() == null) {
return;
}
company = operationOrder.getManufOrder().getCompany();
} else {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, IExceptionMessage.STOCK_MOVE_LINE_UNKNOWN_PARENT_CONTEXT);
}
} else {
company = stockMove.getCompany();
}
if (stockMoveLine.getProduct() == null) {
stockMoveLine = new StockMoveLine();
response.setValues(Mapper.toMap(stockMoveLine));
return;
}
Beans.get(StockMoveLineService.class).setProductInfo(stockMove, stockMoveLine, company);
response.setValues(stockMoveLine);
} catch (Exception e) {
stockMoveLine = new StockMoveLine();
response.setValues(Mapper.toMap(stockMoveLine));
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ManufOrderServiceBusinessImpl method createManufOrder.
@Override
public ManufOrder createManufOrder(Product product, BigDecimal qty, int priority, boolean isToInvoice, Company company, BillOfMaterial billOfMaterial, LocalDateTime plannedStartDateT, LocalDateTime plannedEndDateT) throws AxelorException {
ManufOrder manufOrder = super.createManufOrder(product, qty, priority, isToInvoice, company, billOfMaterial, plannedStartDateT, plannedEndDateT);
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
return manufOrder;
}
manufOrder.setIsToInvoice(isToInvoice);
return manufOrder;
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class ManufOrderBusinessController method propagateIsToInvoice.
public void propagateIsToInvoice(ActionRequest request, ActionResponse response) {
ManufOrderServiceBusinessImpl manufOrderService = Beans.get(ManufOrderServiceBusinessImpl.class);
ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
manufOrderService.propagateIsToInvoice(Beans.get(ManufOrderRepository.class).find(manufOrder.getId()));
response.setReload(true);
}
use of com.axelor.apps.production.db.ManufOrder in project axelor-open-suite by axelor.
the class BatchComputeWorkInProgressValuation method process.
@Override
protected void process() {
ProductionBatch productionBatch = batch.getProductionBatch();
Company company = productionBatch.getCompany();
StockLocation workshopStockLocation = productionBatch.getWorkshopStockLocation();
if (productionBatch.getValuationDate() == null) {
productionBatch.setValuationDate(Beans.get(AppBaseService.class).getTodayDate(company));
}
LocalDate valuationDate = productionBatch.getValuationDate();
List<ManufOrder> manufOrderList;
Map<String, Object> bindValues = new HashMap<>();
String domain = "(self.statusSelect = :statusSelectInProgress or self.statusSelect = :statusSelectStandBy " + "or (self.statusSelect = :statusSelectFinished " + "AND self.realEndDateT BETWEEN :valuationDateT AND :todayDateT))";
bindValues.put("statusSelectInProgress", ManufOrderRepository.STATUS_IN_PROGRESS);
bindValues.put("statusSelectStandBy", ManufOrderRepository.STATUS_STANDBY);
bindValues.put("statusSelectFinished", ManufOrderRepository.STATUS_FINISHED);
bindValues.put("valuationDateT", valuationDate.atStartOfDay());
bindValues.put("todayDateT", appBaseService.getTodayDateTime().toLocalDateTime());
if (company != null) {
domain += " and self.company.id = :companyId";
bindValues.put("companyId", company.getId());
}
if (workshopStockLocation != null) {
domain += " and self.workshopStockLocation.id = :stockLocationId";
bindValues.put("stockLocationId", workshopStockLocation.getId());
}
Query<ManufOrder> manufOrderQuery = Beans.get(ManufOrderRepository.class).all().filter(domain).bind(bindValues);
int offset = 0;
while (!(manufOrderList = manufOrderQuery.order("id").fetch(FETCH_LIMIT, offset)).isEmpty()) {
for (ManufOrder manufOrder : manufOrderList) {
++offset;
try {
costSheetService.computeCostPrice(manufOrder, CostSheetRepository.CALCULATION_WORK_IN_PROGRESS, valuationDate);
incrementDone();
} catch (Exception e) {
incrementAnomaly();
TraceBackService.trace(e, ExceptionOriginRepository.COST_SHEET, batch.getId());
}
}
JPA.clear();
}
}
Aggregations