use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderController method validateSupplier.
public void validateSupplier(ActionRequest request, ActionResponse response) {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
response.setValue("supplierPartner", Beans.get(PurchaseOrderService.class).validateSupplier(purchaseOrder));
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderController method validate.
public void validate(ActionRequest request, ActionResponse response) {
try {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
Beans.get(PurchaseOrderWorkflowService.class).validatePurchaseOrder(purchaseOrder);
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 PurchaseOrderController method filterPrintingSettings.
/**
* Called on printing settings select. Set the domain for {@link PurchaseOrder#printingSettings}
*
* @param request
* @param response
*/
public void filterPrintingSettings(ActionRequest request, ActionResponse response) {
try {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
List<PrintingSettings> printingSettingsList = Beans.get(TradingNameService.class).getPrintingSettingsList(purchaseOrder.getTradingName(), purchaseOrder.getCompany());
String domain = String.format("self.id IN (%s)", !printingSettingsList.isEmpty() ? StringTool.getIdListString(printingSettingsList) : "0");
response.setAttr("printingSettings", "domain", domain);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method compute.
public void compute(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
PurchaseOrderLine purchaseOrderLine = context.asType(PurchaseOrderLine.class);
PurchaseOrder purchaseOrder = this.getPurchaseOrder(context);
Map<String, BigDecimal> map = Beans.get(PurchaseOrderLineService.class).compute(purchaseOrderLine, purchaseOrder);
response.setValues(map);
response.setAttr("priceDiscounted", "hidden", map.getOrDefault("priceDiscounted", BigDecimal.ZERO).compareTo(purchaseOrder.getInAti() ? purchaseOrderLine.getInTaxPrice() : purchaseOrderLine.getPrice()) == 0);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.purchase.db.PurchaseOrder in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method supplierPartnerDomain.
/**
* Called on supplier partner select. Set the domain for the field supplierPartner
*
* @param request
* @param response
*/
public void supplierPartnerDomain(ActionRequest request, ActionResponse response) {
PurchaseOrderLine purchaseOrderLine = request.getContext().asType(PurchaseOrderLine.class);
PurchaseOrder purchaseOrder = request.getContext().getParent().asType(PurchaseOrder.class);
if (purchaseOrder.getId() != null) {
purchaseOrder = purchaseOrderLine.getPurchaseOrder();
}
Company company = purchaseOrder.getCompany();
String domain = "";
if (Beans.get(AppPurchaseService.class).getAppPurchase().getManageSupplierCatalog() && purchaseOrderLine.getProduct() != null && !purchaseOrderLine.getProduct().getSupplierCatalogList().isEmpty()) {
domain += "self.id != " + company.getPartner().getId() + " AND self.id IN " + purchaseOrderLine.getProduct().getSupplierCatalogList().stream().map(s -> s.getSupplierPartner().getId()).collect(Collectors.toList()).toString().replace('[', '(').replace(']', ')');
String blockedPartnerQuery = Beans.get(BlockingService.class).listOfBlockedPartner(company, BlockingRepository.PURCHASE_BLOCKING);
if (!Strings.isNullOrEmpty(blockedPartnerQuery)) {
domain += String.format(" AND self.id NOT in (%s)", blockedPartnerQuery);
}
} else {
domain += "self.id = 0";
}
domain += " AND " + company.getId() + " in (SELECT id FROM self.companySet)";
response.setAttr("supplierPartner", "domain", domain);
}
Aggregations