Search in sources :

Example 1 with StockConfigService

use of com.axelor.apps.stock.service.config.StockConfigService in project axelor-open-suite by axelor.

the class PurchaseOrderStockServiceImpl method getStartStockLocation.

protected StockLocation getStartStockLocation(PurchaseOrder purchaseOrder) throws AxelorException {
    Company company = purchaseOrder.getCompany();
    StockLocation startLocation = purchaseOrder.getFromStockLocation();
    if (startLocation == null) {
        startLocation = partnerStockSettingsService.getDefaultExternalStockLocation(purchaseOrder.getSupplierPartner(), company);
    }
    if (startLocation == null) {
        StockConfigService stockConfigService = Beans.get(StockConfigService.class);
        StockConfig stockConfig = stockConfigService.getStockConfig(company);
        startLocation = stockConfigService.getSupplierVirtualStockLocation(stockConfig);
    }
    if (startLocation == null) {
        throw new AxelorException(purchaseOrder, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PURCHASE_ORDER_1), company.getName());
    }
    return startLocation;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) StockConfig(com.axelor.apps.stock.db.StockConfig) StockLocation(com.axelor.apps.stock.db.StockLocation) StockConfigService(com.axelor.apps.stock.service.config.StockConfigService)

Example 2 with StockConfigService

use of com.axelor.apps.stock.service.config.StockConfigService in project axelor-open-suite by axelor.

the class LogisticalFormServiceImpl method processCollected.

@Override
@Transactional(rollbackOn = { Exception.class })
public void processCollected(LogisticalForm logisticalForm) throws AxelorException {
    if (logisticalForm.getLogisticalFormLineList() == null) {
        return;
    }
    Set<StockMove> stockMoveSet = new HashSet<>();
    logisticalForm.getLogisticalFormLineList().stream().filter(logisticalFormLine -> logisticalFormLine.getTypeSelect() == LogisticalFormLineRepository.TYPE_DETAIL && logisticalFormLine.getStockMoveLine() != null && logisticalFormLine.getStockMoveLine().getStockMove() != null).forEach(logisticalFormLine -> stockMoveSet.add(logisticalFormLine.getStockMoveLine().getStockMove()));
    StockMoveService stockMoveService = Beans.get(StockMoveService.class);
    stockMoveSet.forEach(stockMoveService::updateFullySpreadOverLogisticalFormsFlag);
    StockConfigService stockConfigService = Beans.get(StockConfigService.class);
    StockConfig stockConfig = stockConfigService.getStockConfig(logisticalForm.getCompany());
    if (stockConfig.getRealizeStockMovesUponParcelPalletCollection()) {
        for (StockMove stockMove : stockMoveSet) {
            if (stockMove.getFullySpreadOverLogisticalFormsFlag()) {
                stockMoveService.realize(stockMove);
            }
        }
    }
    logisticalForm.setStatusSelect(LogisticalFormRepository.STATUS_COLLECTED);
}
Also used : Inject(com.google.inject.Inject) GroovyScriptHelper(com.axelor.script.GroovyScriptHelper) Mapper(com.axelor.db.mapper.Mapper) Transactional(com.google.inject.persist.Transactional) BigDecimal(java.math.BigDecimal) Pair(org.apache.commons.lang3.tuple.Pair) Locale(java.util.Locale) Map(java.util.Map) FreightCarrierCustomerAccountNumber(com.axelor.apps.stock.db.FreightCarrierCustomerAccountNumber) RoundingMode(java.math.RoundingMode) LogisticalForm(com.axelor.apps.stock.db.LogisticalForm) StockConfig(com.axelor.apps.stock.db.StockConfig) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveRepository(com.axelor.apps.stock.db.repo.StockMoveRepository) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) LogisticalFormLineRepository(com.axelor.apps.stock.db.repo.LogisticalFormLineRepository) List(java.util.List) Product(com.axelor.apps.base.db.Product) ScriptHelper(com.axelor.script.ScriptHelper) Entry(java.util.Map.Entry) Optional(java.util.Optional) AppFilter(com.axelor.app.internal.AppFilter) LogisticalFormError(com.axelor.apps.stock.exception.LogisticalFormError) IExceptionMessage(com.axelor.apps.stock.exception.IExceptionMessage) ProductRepository(com.axelor.apps.base.db.repo.ProductRepository) HashMap(java.util.HashMap) OptionalInt(java.util.OptionalInt) TypedQuery(javax.persistence.TypedQuery) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Lists(com.google.common.collect.Lists) AxelorException(com.axelor.exception.AxelorException) ContextEntity(com.axelor.rpc.ContextEntity) I18n(com.axelor.i18n.I18n) LogisticalFormRepository(com.axelor.apps.stock.db.repo.LogisticalFormRepository) LinkedHashSet(java.util.LinkedHashSet) StringTool(com.axelor.apps.tool.StringTool) JPA(com.axelor.db.JPA) LogisticalFormLine(com.axelor.apps.stock.db.LogisticalFormLine) TraceBackRepository(com.axelor.exception.db.repo.TraceBackRepository) LogisticalFormWarning(com.axelor.apps.stock.exception.LogisticalFormWarning) QueryBuilder(com.axelor.apps.tool.QueryBuilder) StockConfigService(com.axelor.apps.stock.service.config.StockConfigService) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Beans(com.axelor.inject.Beans) Preconditions(com.google.common.base.Preconditions) Comparator(java.util.Comparator) Context(com.axelor.rpc.Context) StockMove(com.axelor.apps.stock.db.StockMove) StockConfig(com.axelor.apps.stock.db.StockConfig) StockConfigService(com.axelor.apps.stock.service.config.StockConfigService) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Transactional(com.google.inject.persist.Transactional)

Example 3 with StockConfigService

use of com.axelor.apps.stock.service.config.StockConfigService in project axelor-open-suite by axelor.

the class StockLocationServiceImpl method getDefaultReceiptStockLocation.

@Override
public StockLocation getDefaultReceiptStockLocation(Company company) {
    try {
        StockConfigService stockConfigService = Beans.get(StockConfigService.class);
        StockConfig stockConfig = stockConfigService.getStockConfig(company);
        return stockConfigService.getReceiptDefaultStockLocation(stockConfig);
    } catch (Exception e) {
        return null;
    }
}
Also used : StockConfig(com.axelor.apps.stock.db.StockConfig) StockConfigService(com.axelor.apps.stock.service.config.StockConfigService) AxelorException(com.axelor.exception.AxelorException)

Example 4 with StockConfigService

use of com.axelor.apps.stock.service.config.StockConfigService in project axelor-open-suite by axelor.

the class StockLocationServiceImpl method getPickupDefaultStockLocation.

@Override
public StockLocation getPickupDefaultStockLocation(Company company) {
    try {
        StockConfigService stockConfigService = Beans.get(StockConfigService.class);
        StockConfig stockConfig = stockConfigService.getStockConfig(company);
        return stockConfigService.getPickupDefaultStockLocation(stockConfig);
    } catch (Exception e) {
        return null;
    }
}
Also used : StockConfig(com.axelor.apps.stock.db.StockConfig) StockConfigService(com.axelor.apps.stock.service.config.StockConfigService) AxelorException(com.axelor.exception.AxelorException)

Aggregations

StockConfig (com.axelor.apps.stock.db.StockConfig)4 StockConfigService (com.axelor.apps.stock.service.config.StockConfigService)4 AxelorException (com.axelor.exception.AxelorException)4 AppFilter (com.axelor.app.internal.AppFilter)1 Company (com.axelor.apps.base.db.Company)1 Product (com.axelor.apps.base.db.Product)1 ProductRepository (com.axelor.apps.base.db.repo.ProductRepository)1 FreightCarrierCustomerAccountNumber (com.axelor.apps.stock.db.FreightCarrierCustomerAccountNumber)1 LogisticalForm (com.axelor.apps.stock.db.LogisticalForm)1 LogisticalFormLine (com.axelor.apps.stock.db.LogisticalFormLine)1 StockLocation (com.axelor.apps.stock.db.StockLocation)1 StockMove (com.axelor.apps.stock.db.StockMove)1 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)1 LogisticalFormLineRepository (com.axelor.apps.stock.db.repo.LogisticalFormLineRepository)1 LogisticalFormRepository (com.axelor.apps.stock.db.repo.LogisticalFormRepository)1 StockMoveRepository (com.axelor.apps.stock.db.repo.StockMoveRepository)1 IExceptionMessage (com.axelor.apps.stock.exception.IExceptionMessage)1 LogisticalFormError (com.axelor.apps.stock.exception.LogisticalFormError)1 LogisticalFormWarning (com.axelor.apps.stock.exception.LogisticalFormWarning)1 QueryBuilder (com.axelor.apps.tool.QueryBuilder)1