Search in sources :

Example 26 with StockMove

use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.

the class AccountingCutOffServiceImpl method getStockMoveLines.

public List<Long> getStockMoveLines(Batch batch) {
    int offset = 0;
    Boolean includeNotStockManagedProduct = batch.getSupplychainBatch().getIncludeNotStockManagedProduct();
    List<StockMoveLine> stockMoveLineList;
    List<Long> stockMoveLineIdList = new ArrayList<>();
    Query<StockMove> stockMoveQuery = stockMoverepository.all().filter(":batch MEMBER OF self.batchSet").bind("batch", batch);
    List<Long> stockMoveIdList = stockMoveQuery.select("id").fetch(0, 0).stream().map(m -> (Long) m.get("id")).collect(Collectors.toList());
    if (stockMoveIdList.isEmpty()) {
        stockMoveLineIdList.add(0L);
    } else {
        Query<StockMoveLine> stockMoveLineQuery = stockMoveLineRepository.all().filter("self.stockMove.id IN :stockMoveIdList").bind("stockMoveIdList", stockMoveIdList).order("id");
        while (!(stockMoveLineList = stockMoveLineQuery.fetch(FETCH_LIMIT, offset)).isEmpty()) {
            offset += stockMoveLineList.size();
            for (StockMoveLine stockMoveLine : stockMoveLineList) {
                Product product = stockMoveLine.getProduct();
                if (!checkStockMoveLine(stockMoveLine, product, includeNotStockManagedProduct)) {
                    stockMoveLineIdList.add(stockMoveLine.getId());
                }
            }
            JPA.clear();
        }
    }
    return stockMoveLineIdList;
}
Also used : TaxAccountService(com.axelor.apps.account.service.TaxAccountService) AppAccountService(com.axelor.apps.account.service.app.AppAccountService) Move(com.axelor.apps.account.db.Move) Inject(com.google.inject.Inject) Transactional(com.google.inject.persist.Transactional) BigDecimal(java.math.BigDecimal) SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) TaxLine(com.axelor.apps.account.db.TaxLine) MoveCreateService(com.axelor.apps.account.service.move.MoveCreateService) MoveToolService(com.axelor.apps.account.service.move.MoveToolService) MoveValidateService(com.axelor.apps.account.service.move.MoveValidateService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) RoundingMode(java.math.RoundingMode) AnalyticMoveLineRepository(com.axelor.apps.account.db.repo.AnalyticMoveLineRepository) AccountManagementAccountService(com.axelor.apps.account.service.AccountManagementAccountService) InvoiceLineManagement(com.axelor.apps.account.service.invoice.generator.line.InvoiceLineManagement) FETCH_LIMIT(com.axelor.apps.base.service.administration.AbstractBatch.FETCH_LIMIT) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveRepository(com.axelor.apps.stock.db.repo.StockMoveRepository) Collectors(java.util.stream.Collectors) Currency(com.axelor.apps.base.db.Currency) List(java.util.List) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) Product(com.axelor.apps.base.db.Product) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) AccountConfigSupplychainService(com.axelor.apps.supplychain.service.config.AccountConfigSupplychainService) LocalDate(java.time.LocalDate) Partner(com.axelor.apps.base.db.Partner) Company(com.axelor.apps.base.db.Company) Query(com.axelor.db.Query) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) StockMoveLineRepository(com.axelor.apps.stock.db.repo.StockMoveLineRepository) AccountConfig(com.axelor.apps.account.db.AccountConfig) PurchaseOrderRepository(com.axelor.apps.purchase.db.repo.PurchaseOrderRepository) AnalyticMoveLineService(com.axelor.apps.account.service.AnalyticMoveLineService) ArrayList(java.util.ArrayList) AxelorException(com.axelor.exception.AxelorException) MoveLine(com.axelor.apps.account.db.MoveLine) UnitConversionService(com.axelor.apps.base.service.UnitConversionService) Batch(com.axelor.apps.base.db.Batch) AppAccountRepository(com.axelor.apps.base.db.repo.AppAccountRepository) MoveLineService(com.axelor.apps.account.service.move.MoveLineService) JPA(com.axelor.db.JPA) Iterator(java.util.Iterator) SupplychainBatchRepository(com.axelor.apps.supplychain.db.repo.SupplychainBatchRepository) ReconcileService(com.axelor.apps.account.service.ReconcileService) AnalyticDistributionTemplate(com.axelor.apps.account.db.AnalyticDistributionTemplate) Account(com.axelor.apps.account.db.Account) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Comparator(java.util.Comparator) Collections(java.util.Collections) MoveRepository(com.axelor.apps.account.db.repo.MoveRepository) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Tax(com.axelor.apps.account.db.Tax) StockMove(com.axelor.apps.stock.db.StockMove) ArrayList(java.util.ArrayList) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Product(com.axelor.apps.base.db.Product)

Example 27 with StockMove

use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.

the class ClientViewServiceImpl method getNextDeliveryIndicator.

protected String getNextDeliveryIndicator(User user) {
    List<Filter> filters = getNextDeliveryOfUser(user);
    StockMove stockMove = Filter.and(filters).build(StockMove.class).order("estimatedDate").fetchOne();
    if (stockMove == null) {
        return I18n.get(CLIENT_PORTAL_NO_DATE);
    }
    return stockMove.getEstimatedDate() != null ? stockMove.getEstimatedDate().format(DATE_FORMATTER) : I18n.get(CLIENT_PORTAL_NO_DATE);
}
Also used : StockMove(com.axelor.apps.stock.db.StockMove) Filter(com.axelor.rpc.filter.Filter) JPQLFilter(com.axelor.rpc.filter.JPQLFilter)

Example 28 with StockMove

use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.

the class StockMoveController method allocateAll.

/**
 * Called from stock move form view, on available qty boolean change. Only called if the user
 * accepted to allocate everything. Call {@link
 * StockMoveReservedQtyService#allocateAll(StockMove)}.
 *
 * @param request
 * @param response
 */
public void allocateAll(ActionRequest request, ActionResponse response) {
    try {
        StockMove stockMove = request.getContext().asType(StockMove.class);
        Company company = stockMove.getCompany();
        if (company == null) {
            return;
        }
        SupplyChainConfig supplyChainConfig = Beans.get(SupplyChainConfigService.class).getSupplyChainConfig(company);
        if (!Beans.get(AppSupplychainService.class).getAppSupplychain().getManageStockReservation() || !stockMove.getAvailabilityRequest() || !supplyChainConfig.getAutoAllocateOnAvailabilityRequest()) {
            return;
        }
        Beans.get(StockMoveReservedQtyService.class).allocateAll(stockMove);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : Company(com.axelor.apps.base.db.Company) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveReservedQtyService(com.axelor.apps.supplychain.service.StockMoveReservedQtyService) SupplyChainConfigService(com.axelor.apps.supplychain.service.config.SupplyChainConfigService) SupplyChainConfig(com.axelor.apps.supplychain.db.SupplyChainConfig) AppSupplychainService(com.axelor.apps.supplychain.service.app.AppSupplychainService)

Example 29 with StockMove

use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.

the class StockMoveController method isAllocatedStockMoveLineRemoved.

public void isAllocatedStockMoveLineRemoved(ActionRequest request, ActionResponse response) {
    StockMove stockMove = request.getContext().asType(StockMove.class);
    if (stockMove.getId() != null && Beans.get(StockMoveServiceSupplychain.class).isAllocatedStockMoveLineRemoved(stockMove)) {
        response.setValue("stockMoveLineList", stockMove.getStockMoveLineList());
        response.setFlash(I18n.get(IExceptionMessage.ALLOCATED_STOCK_MOVE_LINE_DELETED_ERROR));
    }
}
Also used : StockMove(com.axelor.apps.stock.db.StockMove)

Example 30 with StockMove

use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.

the class StockMoveController method setInvoicedPartnerDomain.

/**
 * Called from stock move form view, on delivered partner select. Call {@link
 * PartnerSupplychainLinkService#computePartnerFilter}
 *
 * @param request
 * @param response
 */
public void setInvoicedPartnerDomain(ActionRequest request, ActionResponse response) {
    try {
        StockMove stockMove = request.getContext().asType(StockMove.class);
        String strFilter = Beans.get(PartnerSupplychainLinkService.class).computePartnerFilter(stockMove.getPartner(), PartnerSupplychainLinkTypeRepository.TYPE_SELECT_INVOICED_BY);
        response.setAttr("invoicedPartner", "domain", strFilter);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : StockMove(com.axelor.apps.stock.db.StockMove) PartnerSupplychainLinkService(com.axelor.apps.supplychain.service.PartnerSupplychainLinkService)

Aggregations

StockMove (com.axelor.apps.stock.db.StockMove)129 AxelorException (com.axelor.exception.AxelorException)57 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)50 ArrayList (java.util.ArrayList)36 StockMoveRepository (com.axelor.apps.stock.db.repo.StockMoveRepository)33 Transactional (com.google.inject.persist.Transactional)32 StockMoveService (com.axelor.apps.stock.service.StockMoveService)31 BigDecimal (java.math.BigDecimal)30 List (java.util.List)25 Company (com.axelor.apps.base.db.Company)23 Map (java.util.Map)21 Product (com.axelor.apps.base.db.Product)19 Invoice (com.axelor.apps.account.db.Invoice)18 StockLocation (com.axelor.apps.stock.db.StockLocation)18 Beans (com.axelor.inject.Beans)17 Optional (java.util.Optional)16 StockMoveLineService (com.axelor.apps.stock.service.StockMoveLineService)15 I18n (com.axelor.i18n.I18n)15 Inject (com.google.inject.Inject)14 HashMap (java.util.HashMap)14