use of com.axelor.apps.sale.db.SaleOrder 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.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method generateSaleOrderWizard.
public void generateSaleOrderWizard(ActionRequest request, ActionResponse response) {
SaleOrder saleOrderTemplate = request.getContext().asType(SaleOrder.class);
Partner clientPartner = saleOrderTemplate.getClientPartner();
response.setView(ActionView.define("Create the quotation").model(Wizard.class.getName()).add("form", "sale-order-template-wizard-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("width", "large").param("popup-save", "false").context("_saleOrderTemplate", saleOrderTemplate).context("_clientPartnerCurrency", clientPartner.getCurrency()).map());
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method fillDefaultPrintingSettings.
/**
* Called on trading name change. Set the default value for {@link SaleOrder#printingSettings}
*
* @param request
* @param response
*/
public void fillDefaultPrintingSettings(ActionRequest request, ActionResponse response) {
try {
SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
response.setValue("printingSettings", Beans.get(TradingNameService.class).getDefaultPrintingSettings(saleOrder.getTradingName(), saleOrder.getCompany()));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.sale.db.SaleOrder 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.SaleOrder 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