Search in sources :

Example 1 with SaleOrder

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

the class OpportunitySaleOrderController method cancelSaleOrders.

public void cancelSaleOrders(ActionRequest request, ActionResponse response) {
    Opportunity opportunity = request.getContext().asType(Opportunity.class);
    SaleOrderWorkflowService saleOrderWorkflowService = Beans.get(SaleOrderWorkflowService.class);
    if (opportunity.getSalesStageSelect() == OpportunityRepository.SALES_STAGE_CLOSED_LOST) {
        List<SaleOrder> saleOrderList = opportunity.getSaleOrderList();
        if (saleOrderList != null && !saleOrderList.isEmpty()) {
            for (SaleOrder saleOrder : saleOrderList) {
                if (saleOrder.getStatusSelect() == SaleOrderRepository.STATUS_DRAFT_QUOTATION || saleOrder.getStatusSelect() == SaleOrderRepository.STATUS_FINALIZED_QUOTATION) {
                    saleOrderWorkflowService.cancelSaleOrder(saleOrder, null, opportunity.getName());
                }
            }
        }
    }
}
Also used : SaleOrderWorkflowService(com.axelor.apps.sale.service.saleorder.SaleOrderWorkflowService) Opportunity(com.axelor.apps.crm.db.Opportunity) SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Example 2 with SaleOrder

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

the class SaleOrderController method compute.

public void compute(ActionRequest request, ActionResponse response) {
    SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
    try {
        saleOrder = Beans.get(SaleOrderComputeService.class).computeSaleOrder(saleOrder);
        response.setValues(saleOrder);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : SaleOrder(com.axelor.apps.sale.db.SaleOrder) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Example 3 with SaleOrder

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

the class SaleOrderController method updateSaleOrderLineTax.

public void updateSaleOrderLineTax(ActionRequest request, ActionResponse response) throws AxelorException {
    SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
    Beans.get(SaleOrderCreateService.class).updateSaleOrderLineList(saleOrder);
    response.setValue("saleOrderLineList", saleOrder.getSaleOrderLineList());
}
Also used : SaleOrderCreateService(com.axelor.apps.sale.service.saleorder.SaleOrderCreateService) SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Example 4 with SaleOrder

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

the class SaleOrderController method fillPriceList.

/**
 * Called from sale order form view on partner change. Get the default price list for the sale
 * order. Call {@link PartnerPriceListService#getDefaultPriceList(Partner, int)}.
 *
 * @param request
 * @param response
 */
@SuppressWarnings("unchecked")
public void fillPriceList(ActionRequest request, ActionResponse response) {
    SaleOrder saleOrder;
    if (request.getContext().get("_saleOrderTemplate") != null) {
        LinkedHashMap<String, Object> saleOrderTemplateContext = (LinkedHashMap<String, Object>) request.getContext().get("_saleOrderTemplate");
        Integer saleOrderId = (Integer) saleOrderTemplateContext.get("id");
        saleOrder = Beans.get(SaleOrderRepository.class).find(Long.valueOf(saleOrderId));
    } else {
        saleOrder = request.getContext().asType(SaleOrder.class);
    }
    response.setValue("priceList", saleOrder.getClientPartner() != null ? Beans.get(PartnerPriceListService.class).getDefaultPriceList(saleOrder.getClientPartner(), PriceListRepository.TYPE_SALE) : null);
}
Also used : PartnerPriceListService(com.axelor.apps.base.service.PartnerPriceListService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with SaleOrder

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

the class SaleOrderController method createTemplate.

public void createTemplate(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    if (context.get("_idCopy") != null) {
        String idCopy = context.get("_idCopy").toString();
        SaleOrder origin = Beans.get(SaleOrderRepository.class).find(Long.parseLong(idCopy));
        SaleOrder copy = Beans.get(SaleOrderCreateService.class).createTemplate(origin);
        response.setValues(Mapper.toMap(copy));
    }
}
Also used : Context(com.axelor.rpc.Context) SaleOrderCreateService(com.axelor.apps.sale.service.saleorder.SaleOrderCreateService) SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) 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