use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderController method createTemplate.
public void createTemplate(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
if (context.get("_idCopy") != null) {
String idCopy = context.get("_idCopy").toString();
SaleOrder origin = Beans.get(SaleOrderRepository.class).find(Long.parseLong(idCopy));
SaleOrder copy = Beans.get(SaleOrderCreateService.class).createTemplate(origin);
response.setValues(Mapper.toMap(copy));
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderController method addPack.
public void addPack(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
String saleOrderId = context.get("_id").toString();
SaleOrder saleOrder = Beans.get(SaleOrderRepository.class).find(Long.parseLong(saleOrderId));
@SuppressWarnings("unchecked") LinkedHashMap<String, Object> packMap = (LinkedHashMap<String, Object>) request.getContext().get("pack");
String packId = packMap.get("id").toString();
Pack pack = Beans.get(PackRepository.class).find(Long.parseLong(packId));
String qty = context.get("qty").toString();
BigDecimal packQty = new BigDecimal(qty);
saleOrder = Beans.get(SaleOrderService.class).addPack(saleOrder, pack, packQty);
response.setCanClose(true);
}
use of com.axelor.rpc.Context 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.rpc.Context 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.rpc.Context 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);
}
}
Aggregations