use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderLinePurchaseRepository method populate.
@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
if (context.get("_model") != null && context.get("_model").toString().contains("PurchaseOrder") && context.get("id") != null) {
Long id = (Long) json.get("id");
if (id != null) {
PurchaseOrderLine purchaseOrderLine = find(id);
PurchaseOrder purchaseOrder = purchaseOrderLine.getPurchaseOrder();
Product product = purchaseOrderLine.getProduct();
json.put("$hasWarning", purchaseOrder != null && product != null && product.getDefaultSupplierPartner() != null && purchaseOrder.getSupplierPartner() != null && product.getDefaultSupplierPartner() != purchaseOrder.getSupplierPartner());
}
}
return super.populate(json, context);
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderServiceImpl method createPurchaseOrder.
@Override
public PurchaseOrder createPurchaseOrder(User buyerUser, Company company, Partner contactPartner, Currency currency, LocalDate deliveryDate, String internalReference, String externalReference, LocalDate orderDate, PriceList priceList, Partner supplierPartner, TradingName tradingName) throws AxelorException {
logger.debug("Création d'une commande fournisseur : Société = {}, Reference externe = {}, Fournisseur = {}", new Object[] { company.getName(), externalReference, supplierPartner.getFullName() });
PurchaseOrder purchaseOrder = new PurchaseOrder();
purchaseOrder.setBuyerUser(buyerUser);
purchaseOrder.setCompany(company);
purchaseOrder.setContactPartner(contactPartner);
purchaseOrder.setCurrency(currency);
purchaseOrder.setDeliveryDate(deliveryDate);
purchaseOrder.setInternalReference(internalReference);
purchaseOrder.setExternalReference(externalReference);
purchaseOrder.setOrderDate(orderDate);
purchaseOrder.setPriceList(priceList);
purchaseOrder.setTradingName(tradingName);
purchaseOrder.setPurchaseOrderLineList(new ArrayList<>());
purchaseOrder.setPrintingSettings(Beans.get(TradingNameService.class).getDefaultPrintingSettings(null, company));
purchaseOrder.setPurchaseOrderSeq(this.getSequence(company));
purchaseOrder.setStatusSelect(PurchaseOrderRepository.STATUS_DRAFT);
purchaseOrder.setSupplierPartner(supplierPartner);
return purchaseOrder;
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderManagementRepository method copy.
@Override
public PurchaseOrder copy(PurchaseOrder entity, boolean deep) {
PurchaseOrder copy = super.copy(entity, deep);
copy.setStatusSelect(PurchaseOrderRepository.STATUS_DRAFT);
copy.setPurchaseOrderSeq(null);
copy.setVersionNumber(1);
copy.setDeliveryDate(null);
copy.setValidatedByUser(null);
copy.setValidationDate(null);
if (copy.getPurchaseOrderLineList() != null) {
for (PurchaseOrderLine purchaseOrderLine : copy.getPurchaseOrderLineList()) {
purchaseOrderLine.setDesiredDelivDate(null);
purchaseOrderLine.setEstimatedDelivDate(null);
}
}
return copy;
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method generateSuppliersRequests.
public void generateSuppliersRequests(ActionRequest request, ActionResponse response) {
PurchaseOrderLine purchaseOrderLine = Beans.get(PurchaseOrderLineRepository.class).find(request.getContext().asType(PurchaseOrderLine.class).getId());
try {
if (purchaseOrderLine.getPurchaseOrder() == null) {
PurchaseOrder purchaseOrder = request.getContext().getParent().asType(PurchaseOrder.class);
Beans.get(PurchaseOrderSupplierService.class).generateSuppliersRequests(purchaseOrderLine, purchaseOrder);
} else {
Beans.get(PurchaseOrderSupplierService.class).generateSuppliersRequests(purchaseOrderLine);
}
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class MrpLineManagementRepository method populate.
/**
* set alert if purchase delivery date is to far from proposal
*/
@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
Long mrpLineId = (Long) json.get("id");
MrpLine mrpLine = find(mrpLineId);
Map<String, Object> mrpLineMap = super.populate(json, context);
if (PurchaseOrder.class.getName().equals(mrpLine.getProposalSelect())) {
PurchaseOrder purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(mrpLine.getProposalSelectId());
mrpLine.setIsOutDayNbBetweenPurchaseAndProposal(mrpLine.getProduct() != null && mrpLine.getMaturityDate() != null && (purchaseOrder.getDeliveryDate() == null || mrpLine.getProduct().getMrpFamily() == null || Math.abs(mrpLine.getMaturityDate().toEpochDay() - purchaseOrder.getDeliveryDate().toEpochDay()) > mrpLine.getProduct().getMrpFamily().getDayNbBetweenPurchaseAndProposal()));
json.put("isOutDayNbBetweenPurchaseAndProposal", mrpLine.getIsOutDayNbBetweenPurchaseAndProposal());
}
return mrpLineMap;
}
Aggregations