use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderLineController method getProductInformation.
/**
* Called by the sale order line form. Update all fields when the product is changed.
*
* @param request
* @param response
*/
public void getProductInformation(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrderLineService saleOrderLineService = Beans.get(SaleOrderLineService.class);
SaleOrder saleOrder = saleOrderLineService.getSaleOrder(context);
Product product = saleOrderLine.getProduct();
if (saleOrder == null || product == null) {
resetProductInformation(response, saleOrderLine);
return;
}
try {
product = Beans.get(ProductRepository.class).find(product.getId());
saleOrderLineService.computeProductInformation(saleOrderLine, saleOrder);
response.setValue("saleSupplySelect", product.getSaleSupplySelect());
response.setValues(saleOrderLine);
} catch (Exception e) {
resetProductInformation(response, saleOrderLine);
TraceBackService.trace(response, e);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderLineController method fillMaxDiscount.
/**
* Called from sale order line form view on load and on discount type select change. Call {@link
* SaleOrderLineService#computeMaxDiscount} and set the message to the view.
*
* @param request
* @param response
*/
public void fillMaxDiscount(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrderLineService saleOrderLineService = Beans.get(SaleOrderLineService.class);
SaleOrder saleOrder = saleOrderLineService.getSaleOrder(context);
BigDecimal maxDiscount = saleOrderLineService.computeMaxDiscount(saleOrder, saleOrderLine);
response.setValue("$maxDiscount", maxDiscount);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderLineController method computeSubMargin.
public void computeSubMargin(ActionRequest request, ActionResponse response) throws AxelorException {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrderLineService saleOrderLineService = Beans.get(SaleOrderLineService.class);
SaleOrder saleOrder = saleOrderLineService.getSaleOrder(context);
saleOrderLine.setSaleOrder(saleOrder);
Map<String, BigDecimal> map = saleOrderLineService.computeSubMargin(saleOrder, saleOrderLine);
response.setValues(map);
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderLineController method updatePrice.
/**
* Update the ex. tax unit price of an invoice line from its in. tax unit price.
*
* @param request
* @param response
*/
public void updatePrice(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
try {
BigDecimal inTaxPrice = saleOrderLine.getInTaxPrice();
TaxLine taxLine = saleOrderLine.getTaxLine();
response.setValue("price", Beans.get(SaleOrderLineService.class).convertUnitPrice(true, taxLine, inTaxPrice));
} catch (Exception e) {
response.setFlash(e.getMessage());
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class PackLineController method getProductInformation.
public void getProductInformation(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
PackLine packLine = context.asType(PackLine.class);
Pack pack = this.getPack(context);
Product product = packLine.getProduct();
PackLineService packLineService = Beans.get(PackLineService.class);
if (product == null) {
packLine = packLineService.resetProductInformation(packLine);
response.setValues(packLine);
return;
}
try {
packLine = packLineService.computeProductInformation(pack, packLine);
response.setValues(packLine);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations