use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineController method checkQty.
public void checkQty(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
Beans.get(SaleOrderLineService.class).checkMultipleQty(saleOrderLine, response);
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineController method getDiscount.
public void getDiscount(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrderLineService saleOrderLineService = Beans.get(SaleOrderLineService.class);
SaleOrder saleOrder = saleOrderLineService.getSaleOrder(context);
if (saleOrder == null || saleOrderLine.getProduct() == null) {
return;
}
try {
Map<String, Object> discounts;
if (saleOrderLine.getProduct().getInAti()) {
discounts = saleOrderLineService.getDiscountsFromPriceLists(saleOrder, saleOrderLine, saleOrderLineService.getInTaxUnitPrice(saleOrder, saleOrderLine, saleOrderLine.getTaxLine()));
} else {
discounts = saleOrderLineService.getDiscountsFromPriceLists(saleOrder, saleOrderLine, saleOrderLineService.getExTaxUnitPrice(saleOrder, saleOrderLine, saleOrderLine.getTaxLine()));
}
if (discounts != null) {
BigDecimal price = (BigDecimal) discounts.get("price");
if (price != null && price.compareTo(saleOrderLine.getProduct().getInAti() ? saleOrderLine.getInTaxPrice() : saleOrderLine.getPrice()) != 0) {
if (saleOrderLine.getProduct().getInAti()) {
response.setValue("inTaxPrice", price);
response.setValue("price", saleOrderLineService.convertUnitPrice(true, saleOrderLine.getTaxLine(), price));
} else {
response.setValue("price", price);
response.setValue("inTaxPrice", saleOrderLineService.convertUnitPrice(false, saleOrderLine.getTaxLine(), price));
}
}
if (saleOrderLine.getProduct().getInAti() != saleOrder.getInAti() && (Integer) discounts.get("discountTypeSelect") != PriceListLineRepository.AMOUNT_TYPE_PERCENT) {
response.setValue("discountAmount", saleOrderLineService.convertUnitPrice(saleOrderLine.getProduct().getInAti(), saleOrderLine.getTaxLine(), (BigDecimal) discounts.get("discountAmount")));
} else {
response.setValue("discountAmount", discounts.get("discountAmount"));
}
response.setValue("discountTypeSelect", discounts.get("discountTypeSelect"));
}
} catch (Exception e) {
response.setFlash(e.getMessage());
}
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineController method compute.
public void compute(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrder saleOrder = Beans.get(SaleOrderLineService.class).getSaleOrder(context);
try {
compute(response, saleOrder, saleOrderLine);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.sale.db.SaleOrderLine 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.apps.sale.db.SaleOrderLine 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());
}
}
Aggregations