Search in sources :

Example 6 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine 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 7 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine 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 8 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class ImportSaleOrderLine method importSaleOrderLine.

public Object importSaleOrderLine(Object bean, Map<String, Object> values) throws AxelorException {
    assert bean instanceof SaleOrderLine;
    SaleOrderLine saleOrderLine = (SaleOrderLine) bean;
    SaleOrderLineService saleOrderLineService = Beans.get(SaleOrderLineService.class);
    saleOrderLine.setTaxLine(saleOrderLineService.getTaxLine(saleOrderLine.getSaleOrder(), saleOrderLine));
    saleOrderLineService.computeValues(saleOrderLine.getSaleOrder(), saleOrderLine);
    return saleOrderLine;
}
Also used : SaleOrderLineService(com.axelor.apps.sale.service.saleorder.SaleOrderLineService) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine)

Example 9 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class ProductionOrderSaleOrderServiceImpl method generateProductionOrder.

@Override
@Transactional(rollbackOn = { AxelorException.class })
public List<Long> generateProductionOrder(SaleOrder saleOrder) throws AxelorException {
    boolean oneProdOrderPerSO = appProductionService.getAppProduction().getOneProdOrderPerSO();
    List<Long> productionOrderIdList = new ArrayList<>();
    if (saleOrder.getSaleOrderLineList() == null) {
        return productionOrderIdList;
    }
    ProductionOrder productionOrder = null;
    for (SaleOrderLine saleOrderLine : saleOrder.getSaleOrderLineList()) {
        if (productionOrder == null || !oneProdOrderPerSO) {
            productionOrder = this.createProductionOrder(saleOrder);
        }
        productionOrder = this.generateManufOrders(productionOrder, saleOrderLine);
        if (productionOrder != null && !productionOrderIdList.contains(productionOrder.getId())) {
            productionOrderIdList.add(productionOrder.getId());
        }
    }
    return productionOrderIdList;
}
Also used : ArrayList(java.util.ArrayList) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) ProductionOrder(com.axelor.apps.production.db.ProductionOrder) Transactional(com.google.inject.persist.Transactional)

Example 10 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class SaleOrderLineController method customizeBillOfMaterial.

public void customizeBillOfMaterial(ActionRequest request, ActionResponse response) {
    try {
        SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);
        BillOfMaterial copyBillOfMaterial = Beans.get(BillOfMaterialService.class).customizeBillOfMaterial(saleOrderLine);
        if (copyBillOfMaterial != null) {
            response.setValue("billOfMaterial", copyBillOfMaterial);
            response.setFlash(I18n.get(IExceptionMessage.SALE_ORDER_LINE_1));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : BillOfMaterial(com.axelor.apps.production.db.BillOfMaterial) BillOfMaterialService(com.axelor.apps.production.service.BillOfMaterialService) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine)

Aggregations

SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)116 AxelorException (com.axelor.exception.AxelorException)41 BigDecimal (java.math.BigDecimal)39 SaleOrder (com.axelor.apps.sale.db.SaleOrder)33 ArrayList (java.util.ArrayList)24 Transactional (com.google.inject.persist.Transactional)23 Product (com.axelor.apps.base.db.Product)21 Context (com.axelor.rpc.Context)16 SaleOrderLineService (com.axelor.apps.sale.service.saleorder.SaleOrderLineService)14 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)9 Partner (com.axelor.apps.base.db.Partner)8 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)8 TaxLine (com.axelor.apps.account.db.TaxLine)7 Unit (com.axelor.apps.base.db.Unit)7 HashMap (java.util.HashMap)7 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)6 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)6 SaleOrderLineRepository (com.axelor.apps.sale.db.repo.SaleOrderLineRepository)6 ReservedQtyService (com.axelor.apps.supplychain.service.ReservedQtyService)6 List (java.util.List)6