use of com.axelor.apps.sale.db.SaleOrder 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.SaleOrder 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.apps.sale.db.SaleOrder 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.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class ProductionOrderSaleOrderController method createProductionOrders.
public void createProductionOrders(ActionRequest request, ActionResponse response) throws AxelorException {
try {
SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
saleOrder = Beans.get(SaleOrderRepository.class).find(saleOrder.getId());
List<Long> productionOrderIdList = Beans.get(ProductionOrderSaleOrderService.class).generateProductionOrder(saleOrder);
if (productionOrderIdList != null && productionOrderIdList.size() == 1) {
response.setView(ActionView.define(I18n.get("Production order")).model(ProductionOrder.class.getName()).add("form", "production-order-form").add("grid", "production-order-grid").param("search-filters", "production-order-filters").param("forceEdit", "true").context("_showRecord", String.valueOf(productionOrderIdList.get(0))).map());
} else if (productionOrderIdList != null && productionOrderIdList.size() > 1) {
response.setView(ActionView.define(I18n.get("Production order")).model(ProductionOrder.class.getName()).add("grid", "production-order-grid").add("form", "production-order-form").param("search-filters", "production-order-filters").domain("self.id in (" + Joiner.on(",").join(productionOrderIdList) + ")").map());
} else {
response.setFlash(I18n.get(IExceptionMessage.PRODUCTION_ORDER_NO_GENERATION));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderCreateServiceSupplychainImpl method createSaleOrder.
public SaleOrder createSaleOrder(User salespersonUser, Company company, Partner contactPartner, Currency currency, LocalDate deliveryDate, String internalReference, String externalReference, StockLocation stockLocation, PriceList priceList, Partner clientPartner, Team team, TradingName tradingName) throws AxelorException {
logger.debug("Création d'une commande fournisseur : Société = {}, Reference externe = {}, Client = {}", company.getName(), externalReference, clientPartner.getFullName());
SaleOrder saleOrder = super.createSaleOrder(salespersonUser, company, contactPartner, currency, deliveryDate, internalReference, externalReference, priceList, clientPartner, team, tradingName);
if (stockLocation == null) {
stockLocation = Beans.get(StockLocationService.class).getPickupDefaultStockLocation(company);
}
saleOrder.setStockLocation(stockLocation);
saleOrder.setPaymentMode(clientPartner.getInPaymentMode());
saleOrder.setPaymentCondition(clientPartner.getPaymentCondition());
if (saleOrder.getPaymentMode() == null) {
saleOrder.setPaymentMode(this.accountConfigService.getAccountConfig(company).getInPaymentMode());
}
if (saleOrder.getPaymentCondition() == null) {
saleOrder.setPaymentCondition(this.accountConfigService.getAccountConfig(company).getDefPaymentCondition());
}
saleOrder.setShipmentMode(clientPartner.getShipmentMode());
saleOrder.setFreightCarrierMode(clientPartner.getFreightCarrierMode());
return saleOrder;
}
Aggregations