use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderLineController method convertUnitPrice.
public void convertUnitPrice(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrder saleOrder = Beans.get(SaleOrderLineService.class).getSaleOrder(context);
if (saleOrder == null || saleOrderLine.getProduct() == null || saleOrderLine.getPrice() == null || saleOrderLine.getInTaxPrice() == null) {
return;
}
try {
BigDecimal price = saleOrderLine.getPrice();
BigDecimal inTaxPrice = price.add(price.multiply(saleOrderLine.getTaxLine().getValue()));
response.setValue("inTaxPrice", inTaxPrice);
} catch (Exception e) {
response.setFlash(e.getMessage());
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderLineController method updateInTaxPrice.
/**
* Update the in. tax unit price of an invoice line from its ex. tax unit price.
*
* @param request
* @param response
*/
public void updateInTaxPrice(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
try {
BigDecimal exTaxPrice = saleOrderLine.getPrice();
TaxLine taxLine = saleOrderLine.getTaxLine();
response.setValue("inTaxPrice", Beans.get(SaleOrderLineService.class).convertUnitPrice(false, taxLine, exTaxPrice));
} catch (Exception e) {
response.setFlash(e.getMessage());
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderLineController method computeProductDomain.
/**
* Called from sale order line form view, on product selection. Call {@link
* SaleOrderLineService#computeProductDomain(SaleOrderLine, SaleOrder)}.
*
* @param request
* @param response
*/
public void computeProductDomain(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);
response.setAttr("product", "domain", saleOrderLineService.computeProductDomain(saleOrderLine, saleOrder));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderLineController method getTaxEquiv.
public void getTaxEquiv(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrder saleOrder = Beans.get(SaleOrderLineService.class).getSaleOrder(context);
response.setValue("taxEquiv", null);
if (saleOrder == null || saleOrderLine == null || saleOrder.getClientPartner() == null || saleOrderLine.getTaxLine() == null)
return;
response.setValue("taxEquiv", Beans.get(FiscalPositionService.class).getTaxEquiv(saleOrder.getClientPartner().getFiscalPosition(), saleOrderLine.getTaxLine().getTax()));
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class BatchJob method applyBeanPropertiesWithScriptHelper.
private Map<String, Object> applyBeanPropertiesWithScriptHelper(Object bean, Map<String, Object> properties) {
Context scriptContext = new Context(Mapper.toMap(bean), bean.getClass());
ScriptHelper scriptHelper = new GroovyScriptHelper(scriptContext);
return applyBeanProperties(bean, properties, value -> scriptHelper.eval(value.toString()));
}
Aggregations