use of com.axelor.apps.base.service.PartnerPriceListService in project axelor-open-suite by axelor.
the class SaleOrderController method fillPriceList.
/**
* Called from sale order form view on partner change. Get the default price list for the sale
* order. Call {@link PartnerPriceListService#getDefaultPriceList(Partner, int)}.
*
* @param request
* @param response
*/
@SuppressWarnings("unchecked")
public void fillPriceList(ActionRequest request, ActionResponse response) {
SaleOrder saleOrder;
if (request.getContext().get("_saleOrderTemplate") != null) {
LinkedHashMap<String, Object> saleOrderTemplateContext = (LinkedHashMap<String, Object>) request.getContext().get("_saleOrderTemplate");
Integer saleOrderId = (Integer) saleOrderTemplateContext.get("id");
saleOrder = Beans.get(SaleOrderRepository.class).find(Long.valueOf(saleOrderId));
} else {
saleOrder = request.getContext().asType(SaleOrder.class);
}
response.setValue("priceList", saleOrder.getClientPartner() != null ? Beans.get(PartnerPriceListService.class).getDefaultPriceList(saleOrder.getClientPartner(), PriceListRepository.TYPE_SALE) : null);
}
use of com.axelor.apps.base.service.PartnerPriceListService in project axelor-open-suite by axelor.
the class InvoiceController method changePriceListDomain.
/**
* Called from invoice view on price list select. Call {@link
* PartnerPriceListService#getPriceListDomain(Partner, int)}.
*
* @param request
* @param response
*/
public void changePriceListDomain(ActionRequest request, ActionResponse response) {
try {
Invoice invoice = request.getContext().asType(Invoice.class);
int priceListTypeSelect = Beans.get(InvoiceService.class).getPurchaseTypeOrSaleType(invoice);
String domain = Beans.get(PartnerPriceListService.class).getPriceListDomain(invoice.getPartner(), priceListTypeSelect);
response.setAttr("priceList", "domain", domain);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.service.PartnerPriceListService in project axelor-open-suite by axelor.
the class PartnerPriceListController method checkDates.
/**
* Called from partner price list form view call {@link
* PartnerPriceListService#checkDates(PartnerPriceList)} return a warning with the response if
* dates validation fails for the price list set.
*
* @param request
* @param response
*/
public void checkDates(ActionRequest request, ActionResponse response) {
PartnerPriceList partnerPriceList;
Class partnerOrPriceLists = request.getContext().getContextClass();
if (partnerOrPriceLists.equals(Partner.class)) {
partnerPriceList = request.getContext().asType(Partner.class).getSalePartnerPriceList();
} else if (partnerOrPriceLists.equals(PartnerPriceList.class)) {
partnerPriceList = request.getContext().asType(PartnerPriceList.class);
} else {
return;
}
try {
Beans.get(PartnerPriceListService.class).checkDates(partnerPriceList);
} catch (Exception e) {
response.setAlert(e.getMessage());
}
}
use of com.axelor.apps.base.service.PartnerPriceListService in project axelor-open-suite by axelor.
the class SaleOrderController method changePriceListDomain.
/**
* Called from sale order view on price list select. Call {@link
* PartnerPriceListService#getPriceListDomain(Partner, int)}.
*
* @param request
* @param response
*/
@SuppressWarnings("unchecked")
public void changePriceListDomain(ActionRequest request, ActionResponse response) {
SaleOrder saleOrder;
if (request.getContext().get("_saleOrderTemplate") != null) {
LinkedHashMap<String, Object> saleOrderTemplateContext = (LinkedHashMap<String, Object>) request.getContext().get("_saleOrderTemplate");
Integer saleOrderId = (Integer) saleOrderTemplateContext.get("id");
saleOrder = Beans.get(SaleOrderRepository.class).find(Long.valueOf(saleOrderId));
} else {
saleOrder = request.getContext().asType(SaleOrder.class);
}
String domain = Beans.get(PartnerPriceListService.class).getPriceListDomain(saleOrder.getClientPartner(), PriceListRepository.TYPE_SALE);
response.setAttr("priceList", "domain", domain);
}
Aggregations