Search in sources :

Example 16 with SaleOrder

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());
    }
}
Also used : Context(com.axelor.rpc.Context) SaleOrderLineService(com.axelor.apps.sale.service.saleorder.SaleOrderLineService) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) SaleOrder(com.axelor.apps.sale.db.SaleOrder) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException)

Example 17 with SaleOrder

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);
    }
}
Also used : Context(com.axelor.rpc.Context) SaleOrderLineService(com.axelor.apps.sale.service.saleorder.SaleOrderLineService) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) SaleOrder(com.axelor.apps.sale.db.SaleOrder) AxelorException(com.axelor.exception.AxelorException)

Example 18 with SaleOrder

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()));
}
Also used : Context(com.axelor.rpc.Context) SaleOrderLineService(com.axelor.apps.sale.service.saleorder.SaleOrderLineService) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Example 19 with SaleOrder

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);
    }
}
Also used : ProductionOrderSaleOrderService(com.axelor.apps.production.service.productionorder.ProductionOrderSaleOrderService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) AxelorException(com.axelor.exception.AxelorException)

Example 20 with SaleOrder

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;
}
Also used : SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Aggregations

SaleOrder (com.axelor.apps.sale.db.SaleOrder)129 AxelorException (com.axelor.exception.AxelorException)53 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)35 BigDecimal (java.math.BigDecimal)24 Context (com.axelor.rpc.Context)20 Transactional (com.google.inject.persist.Transactional)19 ArrayList (java.util.ArrayList)19 SaleOrderRepository (com.axelor.apps.sale.db.repo.SaleOrderRepository)18 Company (com.axelor.apps.base.db.Company)16 Partner (com.axelor.apps.base.db.Partner)15 IOException (java.io.IOException)13 BirtException (org.eclipse.birt.core.exception.BirtException)13 Invoice (com.axelor.apps.account.db.Invoice)12 List (java.util.List)12 Currency (com.axelor.apps.base.db.Currency)11 SaleOrderLineService (com.axelor.apps.sale.service.saleorder.SaleOrderLineService)10 LinkedHashMap (java.util.LinkedHashMap)10 Map (java.util.Map)9 Product (com.axelor.apps.base.db.Product)8 StockMove (com.axelor.apps.stock.db.StockMove)8