Search in sources :

Example 96 with SaleOrder

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

the class SaleOrderCreateServiceImpl method createTemplate.

@Override
@Transactional
public SaleOrder createTemplate(SaleOrder context) {
    SaleOrder copy = saleOrderRepo.copy(context, true);
    copy.setTemplate(true);
    copy.setTemplateUser(AuthUtils.getUser());
    return copy;
}
Also used : SaleOrder(com.axelor.apps.sale.db.SaleOrder) Transactional(com.google.inject.persist.Transactional)

Example 97 with SaleOrder

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

the class SaleOrderCreateServiceImpl method createSaleOrder.

@Override
@Transactional(rollbackOn = { Exception.class })
public SaleOrder createSaleOrder(SaleOrder context, Currency wizardCurrency, PriceList wizardPriceList) throws AxelorException {
    SaleOrder copy = saleOrderRepo.copy(context, true);
    copy.setCreationDate(appSaleService.getTodayDate(context.getCompany()));
    copy.setCurrency(wizardCurrency);
    copy.setPriceList(wizardPriceList);
    saleOrderService.computeEndOfValidityDate(copy);
    this.updateSaleOrderLineList(copy);
    saleOrderComputeService.computeSaleOrder(copy);
    copy.setTemplate(false);
    copy.setTemplateUser(null);
    return copy;
}
Also used : SaleOrder(com.axelor.apps.sale.db.SaleOrder) Transactional(com.google.inject.persist.Transactional)

Example 98 with SaleOrder

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

the class SaleOrderController method fillSaleOrderLinesEstimatedDate.

public void fillSaleOrderLinesEstimatedDate(ActionRequest request, ActionResponse response) {
    SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
    List<SaleOrderLine> saleOrderLineList = saleOrder.getSaleOrderLineList();
    if (saleOrderLineList != null) {
        for (SaleOrderLine saleOrderLine : saleOrderLineList) {
            Integer deliveryState = saleOrderLine.getDeliveryState();
            if (!deliveryState.equals(SaleOrderLineRepository.DELIVERY_STATE_DELIVERED) && !deliveryState.equals(SaleOrderLineRepository.DELIVERY_STATE_PARTIALLY_DELIVERED)) {
                saleOrderLine.setEstimatedDelivDate(saleOrder.getDeliveryDate());
            }
        }
    }
    response.setValue("saleOrderLineList", saleOrderLineList);
}
Also used : SaleOrder(com.axelor.apps.sale.db.SaleOrder) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine)

Example 99 with SaleOrder

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

the class SaleOrderController method deallocateAll.

/**
 * Called from the toolbar in sale order form view. Call {@link
 * com.axelor.apps.supplychain.service.SaleOrderReservedQtyService#deallocateAll(SaleOrder)}.
 *
 * @param request
 * @param response
 */
public void deallocateAll(ActionRequest request, ActionResponse response) {
    try {
        SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
        saleOrder = Beans.get(SaleOrderRepository.class).find(saleOrder.getId());
        Beans.get(SaleOrderReservedQtyService.class).deallocateAll(saleOrder);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : SaleOrderReservedQtyService(com.axelor.apps.supplychain.service.SaleOrderReservedQtyService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) AxelorException(com.axelor.exception.AxelorException)

Example 100 with SaleOrder

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

the class SaleOrderController method cancelReservation.

/**
 * Called from the toolbar in sale order form view. Call {@link
 * com.axelor.apps.supplychain.service.SaleOrderReservedQtyService#cancelReservation(SaleOrder)}.
 *
 * @param request
 * @param response
 */
public void cancelReservation(ActionRequest request, ActionResponse response) {
    try {
        SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
        saleOrder = Beans.get(SaleOrderRepository.class).find(saleOrder.getId());
        Beans.get(SaleOrderReservedQtyService.class).cancelReservation(saleOrder);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : SaleOrderReservedQtyService(com.axelor.apps.supplychain.service.SaleOrderReservedQtyService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) AxelorException(com.axelor.exception.AxelorException)

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