Search in sources :

Example 71 with SaleOrder

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

the class SaleOrderLineServiceSupplyChainImpl method updateStockMoveReservationDateTime.

@Transactional(rollbackOn = { Exception.class })
public void updateStockMoveReservationDateTime(SaleOrderLine saleOrderLine) throws AxelorException {
    SaleOrder saleOrder = saleOrderLine.getSaleOrder();
    if (saleOrder == null) {
        return;
    }
    if (SupplyChainConfigRepository.SALE_ORDER_SHIPPING_DATE != Beans.get(SupplyChainConfigService.class).getSupplyChainConfig(saleOrder.getCompany()).getSaleOrderReservationDateSelect()) {
        return;
    }
    Beans.get(StockMoveLineRepository.class).all().filter("self.saleOrderLine = :saleOrderLineId").bind("saleOrderLineId", saleOrderLine.getId()).fetchStream().filter(stockMoveLine -> stockMoveLine.getStockMove() != null && stockMoveLine.getStockMove().getStatusSelect() == StockMoveRepository.STATUS_PLANNED).forEach(stockMoveLine -> stockMoveLine.setReservationDateTime(saleOrderLine.getEstimatedDelivDate().atStartOfDay()));
}
Also used : StockLocationRepository(com.axelor.apps.stock.db.repo.StockLocationRepository) AppAccountService(com.axelor.apps.account.service.app.AppAccountService) AppPurchaseService(com.axelor.apps.purchase.service.app.AppPurchaseService) Inject(com.google.inject.Inject) PriceListService(com.axelor.apps.base.service.PriceListService) CurrencyService(com.axelor.apps.base.service.CurrencyService) Transactional(com.google.inject.persist.Transactional) SaleOrderLineRepository(com.axelor.apps.sale.db.repo.SaleOrderLineRepository) BigDecimal(java.math.BigDecimal) SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) SaleOrder(com.axelor.apps.sale.db.SaleOrder) StockLocationService(com.axelor.apps.stock.service.StockLocationService) RoundingMode(java.math.RoundingMode) AnalyticMoveLineRepository(com.axelor.apps.account.db.repo.AnalyticMoveLineRepository) AppSaleService(com.axelor.apps.sale.service.app.AppSaleService) StockMoveRepository(com.axelor.apps.stock.db.repo.StockMoveRepository) PackLine(com.axelor.apps.sale.db.PackLine) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) SupplierCatalog(com.axelor.apps.purchase.db.SupplierCatalog) StringUtils(com.axelor.common.StringUtils) Collectors(java.util.stream.Collectors) SupplyChainConfig(com.axelor.apps.supplychain.db.SupplyChainConfig) Objects(java.util.Objects) List(java.util.List) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) Product(com.axelor.apps.base.db.Product) SaleOrderLineServiceImpl(com.axelor.apps.sale.service.saleorder.SaleOrderLineServiceImpl) LocalDate(java.time.LocalDate) ObjectUtils(com.axelor.common.ObjectUtils) Optional(java.util.Optional) Partner(com.axelor.apps.base.db.Partner) SupplyChainConfigService(com.axelor.apps.supplychain.service.config.SupplyChainConfigService) StockMoveLineRepository(com.axelor.apps.stock.db.repo.StockMoveLineRepository) TypedQuery(javax.persistence.TypedQuery) AnalyticMoveLineService(com.axelor.apps.account.service.AnalyticMoveLineService) ArrayList(java.util.ArrayList) AxelorException(com.axelor.exception.AxelorException) StockLocation(com.axelor.apps.stock.db.StockLocation) AppAccountRepository(com.axelor.apps.base.db.repo.AppAccountRepository) StockLocationLineService(com.axelor.apps.stock.service.StockLocationLineService) StringTool(com.axelor.apps.tool.StringTool) AccountManagementService(com.axelor.apps.base.service.tax.AccountManagementService) JPA(com.axelor.db.JPA) AnalyticDistributionTemplate(com.axelor.apps.account.db.AnalyticDistributionTemplate) TraceBackService(com.axelor.exception.service.TraceBackService) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) StockLocationLine(com.axelor.apps.stock.db.StockLocationLine) Beans(com.axelor.inject.Beans) ProductMultipleQtyService(com.axelor.apps.base.service.ProductMultipleQtyService) SupplyChainConfigRepository(com.axelor.apps.supplychain.db.repo.SupplyChainConfigRepository) Preconditions(com.google.common.base.Preconditions) AppSupplychainService(com.axelor.apps.supplychain.service.app.AppSupplychainService) AuthUtils(com.axelor.auth.AuthUtils) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) User(com.axelor.auth.db.User) SupplyChainConfigService(com.axelor.apps.supplychain.service.config.SupplyChainConfigService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) Transactional(com.google.inject.persist.Transactional)

Example 72 with SaleOrder

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

the class SaleOrderSupplychainRepository method copy.

@Override
public SaleOrder copy(SaleOrder entity, boolean deep) {
    SaleOrder copy = super.copy(entity, deep);
    if (!Beans.get(AppService.class).isApp("supplychain")) {
        return copy;
    }
    copy.setShipmentDate(null);
    copy.setDeliveryState(DELIVERY_STATE_NOT_DELIVERED);
    copy.setAmountInvoiced(null);
    copy.setStockMoveList(null);
    if (copy.getSaleOrderLineList() != null) {
        for (SaleOrderLine saleOrderLine : copy.getSaleOrderLineList()) {
            saleOrderLine.setDeliveryState(null);
            saleOrderLine.setDeliveredQty(null);
            saleOrderLine.setAmountInvoiced(null);
            saleOrderLine.setInvoiced(null);
            saleOrderLine.setInvoicingDate(null);
            saleOrderLine.setIsInvoiceControlled(null);
            saleOrderLine.setReservedQty(BigDecimal.ZERO);
        }
    }
    return copy;
}
Also used : SaleOrder(com.axelor.apps.sale.db.SaleOrder) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine)

Example 73 with SaleOrder

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

the class SaleOrderController method createSaleOrder.

@SuppressWarnings("unchecked")
public void createSaleOrder(ActionRequest request, ActionResponse response) throws AxelorException {
    SaleOrder origin = Beans.get(SaleOrderRepository.class).find(Long.parseLong(request.getContext().get("_idCopy").toString()));
    if (origin != null) {
        LinkedHashMap<String, Object> wizardCurrencyContext = (LinkedHashMap<String, Object>) request.getContext().get("_wizardCurrency");
        Integer wizardCurrencyId = (Integer) wizardCurrencyContext.get("id");
        Currency wizardCurrency = Beans.get(CurrencyRepository.class).find(Long.valueOf(wizardCurrencyId));
        PriceList wizardPriceList = null;
        if (request.getContext().get("_wizardPriceList") != null) {
            LinkedHashMap<String, Object> wizardPriceListContext = (LinkedHashMap<String, Object>) request.getContext().get("_wizardPriceList");
            Integer wizardPriceListId = (Integer) wizardPriceListContext.get("id");
            wizardPriceList = Beans.get(PriceListRepository.class).find(Long.valueOf(wizardPriceListId));
        }
        SaleOrder copy = Beans.get(SaleOrderCreateService.class).createSaleOrder(origin, wizardCurrency, wizardPriceList);
        response.setValues(Mapper.toMap(copy));
    }
}
Also used : SaleOrderCreateService(com.axelor.apps.sale.service.saleorder.SaleOrderCreateService) Currency(com.axelor.apps.base.db.Currency) CurrencyRepository(com.axelor.apps.base.db.repo.CurrencyRepository) SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) SaleOrder(com.axelor.apps.sale.db.SaleOrder) PriceList(com.axelor.apps.base.db.PriceList) LinkedHashMap(java.util.LinkedHashMap)

Example 74 with SaleOrder

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

the class SaleOrderController method generateViewTemplate.

public void generateViewTemplate(ActionRequest request, ActionResponse response) {
    SaleOrder context = request.getContext().asType(SaleOrder.class);
    response.setView(ActionView.define("Template").model(SaleOrder.class.getName()).add("form", "sale-order-template-form-wizard").context("_idCopy", context.getId().toString()).map());
}
Also used : SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Example 75 with SaleOrder

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

the class SaleOrderController method changePriceListDomain.

/**
 * Called from sale order view on price list select. Call {@link
 * PartnerPriceListService#getPriceListDomain(Partner, int)}.
 *
 * @param request
 * @param response
 */
@SuppressWarnings("unchecked")
public void changePriceListDomain(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);
    }
    String domain = Beans.get(PartnerPriceListService.class).getPriceListDomain(saleOrder.getClientPartner(), PriceListRepository.TYPE_SALE);
    response.setAttr("priceList", "domain", domain);
}
Also used : PartnerPriceListService(com.axelor.apps.base.service.PartnerPriceListService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) LinkedHashMap(java.util.LinkedHashMap)

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