Search in sources :

Example 41 with SaleOrder

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

the class SaleOrderController method setDefaultInvoicedAndDeliveredPartnersAndAddresses.

public void setDefaultInvoicedAndDeliveredPartnersAndAddresses(ActionRequest request, ActionResponse response) {
    try {
        SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
        Beans.get(SaleOrderSupplychainService.class).setDefaultInvoicedAndDeliveredPartnersAndAddresses(saleOrder);
        response.setValues(saleOrder);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : SaleOrderSupplychainService(com.axelor.apps.supplychain.service.SaleOrderSupplychainService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) AxelorException(com.axelor.exception.AxelorException)

Example 42 with SaleOrder

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

the class SaleOrderController method changeWizardOperationDomain.

/**
 * Called on sale order invoicing wizard form. Call {@link
 * SaleOrderInvoiceService#getInvoicingWizardOperationDomain(SaleOrder)}
 *
 * @param request
 * @param response
 */
public void changeWizardOperationDomain(ActionRequest request, ActionResponse response) {
    SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
    List<Integer> operationSelectValues = Beans.get(SaleOrderInvoiceService.class).getInvoicingWizardOperationDomain(saleOrder);
    response.setAttr("operationSelect", "value", operationSelectValues.stream().min(Integer::compareTo).orElse(null));
    response.setAttr("operationSelect", "selection-in", operationSelectValues);
}
Also used : SaleOrderInvoiceService(com.axelor.apps.supplychain.service.SaleOrderInvoiceService) SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Example 43 with SaleOrder

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

the class SaleOrderController method setDeliveredPartnerDomain.

/**
 * Called from sale order form view, on delivered partner select. Call {@link
 * PartnerSupplychainLinkService#computePartnerFilter}
 *
 * @param request
 * @param response
 */
public void setDeliveredPartnerDomain(ActionRequest request, ActionResponse response) {
    try {
        SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
        String strFilter = Beans.get(PartnerSupplychainLinkService.class).computePartnerFilter(saleOrder.getClientPartner(), PartnerSupplychainLinkTypeRepository.TYPE_SELECT_DELIVERED_BY);
        response.setAttr("deliveredPartner", "domain", strFilter);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PartnerSupplychainLinkService(com.axelor.apps.supplychain.service.PartnerSupplychainLinkService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) AxelorException(com.axelor.exception.AxelorException)

Example 44 with SaleOrder

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

the class SaleOrderController method updateAmountToBeSpreadOverTheTimetable.

public void updateAmountToBeSpreadOverTheTimetable(ActionRequest request, ActionResponse response) {
    SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
    Beans.get(SaleOrderServiceSupplychainImpl.class).updateAmountToBeSpreadOverTheTimetable(saleOrder);
    response.setValue("amountToBeSpreadOverTheTimetable", saleOrder.getAmountToBeSpreadOverTheTimetable());
}
Also used : SaleOrder(com.axelor.apps.sale.db.SaleOrder) SaleOrderServiceSupplychainImpl(com.axelor.apps.supplychain.service.SaleOrderServiceSupplychainImpl)

Example 45 with SaleOrder

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

the class SaleOrderController method supplierPartnerSelectDomain.

/**
 * Called from sale order generate purchase order form. Set domain for supplier partner.
 *
 * @param request
 * @param response
 */
public void supplierPartnerSelectDomain(ActionRequest request, ActionResponse response) {
    SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
    String domain = "self.isContact = false AND self.isSupplier = true";
    String blockedPartnerQuery = Beans.get(BlockingService.class).listOfBlockedPartner(saleOrder.getCompany(), BlockingRepository.PURCHASE_BLOCKING);
    if (!Strings.isNullOrEmpty(blockedPartnerQuery)) {
        domain += String.format(" AND self.id NOT in (%s)", blockedPartnerQuery);
    }
    if (saleOrder.getCompany() != null) {
        domain += " AND " + saleOrder.getCompany().getId() + " in (SELECT id FROM self.companySet)";
    }
    response.setAttr("supplierPartnerSelect", "domain", domain);
}
Also used : BlockingService(com.axelor.apps.base.service.BlockingService) 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