use of com.axelor.apps.supplychain.db.MrpLine in project axelor-open-suite by axelor.
the class MrpLineController method generateProposal.
public void generateProposal(ActionRequest request, ActionResponse response) throws AxelorException {
MrpLine mrpLine = request.getContext().asType(MrpLine.class);
Beans.get(MrpLineService.class).generateProposal(Beans.get(MrpLineRepository.class).find(mrpLine.getId()));
response.setFlash(I18n.get("The proposal has been successfully generated."));
response.setReload(true);
}
use of com.axelor.apps.supplychain.db.MrpLine in project axelor-open-suite by axelor.
the class MrpLineServiceImpl method updateProposalToProcess.
@Override
public void updateProposalToProcess(List<Integer> mrpLineIds, boolean proposalToProcess) {
MrpLine mrpLine;
for (Integer mrpId : mrpLineIds) {
mrpLine = mrpLineRepo.find(Long.valueOf(mrpId));
updateProposalToProcess(mrpLine, proposalToProcess);
}
}
use of com.axelor.apps.supplychain.db.MrpLine in project axelor-open-suite by axelor.
the class MrpServiceImpl method createSaleForecastMrpLines.
@Transactional(rollbackOn = { Exception.class })
protected void createSaleForecastMrpLines(Mrp mrp, MrpForecast mrpForecast, MrpLineType saleForecastMrpLineType) throws AxelorException {
LocalDate maturityDate = mrpForecast.getForecastDate();
if (maturityDate != null && !maturityDate.isBefore(today) && this.isBeforeEndDate(maturityDate)) {
Unit unit = mrpForecast.getProduct().getUnit();
BigDecimal qty = mrpForecast.getQty();
if (!unit.equals(mrpForecast.getUnit())) {
qty = Beans.get(UnitConversionService.class).convert(mrpForecast.getUnit(), unit, qty, qty.scale(), mrpForecast.getProduct());
}
MrpLine mrpLine = this.createMrpLine(mrp, mrpForecast.getProduct(), saleForecastMrpLineType, qty, maturityDate, BigDecimal.ZERO, mrpForecast.getStockLocation(), mrpForecast);
if (mrpLine != null) {
mrpLineRepository.save(mrpLine);
}
}
}
use of com.axelor.apps.supplychain.db.MrpLine in project axelor-open-suite by axelor.
the class MrpServiceImpl method generateProposals.
@Override
@Transactional(rollbackOn = { Exception.class })
public void generateProposals(Mrp mrp, boolean isProposalPerSupplier) throws AxelorException {
Map<Pair<Partner, LocalDate>, PurchaseOrder> purchaseOrders = new HashMap<>();
Map<Partner, PurchaseOrder> purchaseOrdersPerSupplier = new HashMap<>();
List<MrpLine> mrpLineList = mrpLineRepository.all().filter("self.mrp.id = ?1 AND self.proposalToProcess = true", mrp.getId()).order("maturityDate").fetch();
for (MrpLine mrpLine : mrpLineList) {
if (!mrpLine.getProposalGenerated()) {
mrpLineService.generateProposal(mrpLine, purchaseOrders, purchaseOrdersPerSupplier, isProposalPerSupplier);
mrpLine.setProposalToProcess(false);
mrpLineRepository.save(mrpLine);
}
}
}
use of com.axelor.apps.supplychain.db.MrpLine in project axelor-open-suite by axelor.
the class MrpServiceImpl method massUpdateProposalToProcess.
@Override
@Transactional(rollbackOn = { Exception.class })
public void massUpdateProposalToProcess(Mrp mrp, boolean proposalToProcess) {
Query<MrpLine> mrpLineQuery = mrpLineRepository.all().filter("self.mrp.id = :mrpId AND self.mrpLineType.elementSelect in (:purchaseProposal, :manufProposal)").bind("mrpId", mrp.getId()).bind("purchaseProposal", MrpLineTypeRepository.ELEMENT_PURCHASE_PROPOSAL).bind("manufProposal", MrpLineTypeRepository.ELEMENT_MANUFACTURING_PROPOSAL).order("id");
int offset = 0;
List<MrpLine> mrpLineList;
while (!(mrpLineList = mrpLineQuery.fetch(AbstractBatch.FETCH_LIMIT, offset)).isEmpty()) {
for (MrpLine mrpLine : mrpLineList) {
offset++;
mrpLineService.updateProposalToProcess(mrpLine, true);
}
JPA.clear();
}
}
Aggregations