Пример #1
0
 public IntegrationItemsStockApp(IFactoryConnection efc)
 {
     _epr = new IntegrationItemsStockRepo(efc);
     _itemInputStockApp  = new ItemInputStockApp(efc);
     _itemOutputStockApp = new ItemOutputStockApp(efc);
     _stockMapper        = new StockMapper();
     _conn = efc;
 }
Пример #2
0
        /// <summary>
        /// Verifica as configurações do item para Saída.
        /// </summary>
        /// <param name="stockItemId">ID item de estoque.</param>
        /// <param name="localStockId">ID do local de estoque.</param>
        /// <param name="Qtd">Quantidade que saiara do estoque.</param>
        /// <param name="itemOutputStockId">ID do item do movimento de estoque, calculo do estoque irá desconsiderar saída existente no saldo. Parametro não obrigatório.</param>
        /// <returns></returns>
        public bool ValidItem(int stockItemId, int localStockId, int unitMeasurId, decimal qtd, int itemOutputStockId = 0)
        {
            _itemInputStockApp        = new ItemInputStockApp(connection);
            _itemOutputStockApp       = new ItemOutputStockApp(connection);
            _unitMeasureConversionApp = new UnitMeasureConversionApp(connection);
            _stockItemApp             = new StockItemApp(connection);
            _localStockApp            = new LocalStockApp(connection);

            var stockItem  = _stockItemApp.FindId(stockItemId);
            var localStock = _localStockApp.FindId(localStockId);

            var qtdOldOutput = _unitMeasureConversionApp
                               .Convert(
                stockItem.UnitMeasureId,
                unitMeasurId,
                stockItemId,
                stockItem.FamilyId,
                _itemOutputStockApp
                .FindId(itemOutputStockId)?.StandardQuantity ?? 0);

            if (stockItem.AllowsUnavaliableMovement)
            {
                return(true);
            }

            var balance = BalanceAvailable(stockItemId, localStockId, unitMeasurId) + qtdOldOutput;

            if (stockItem.EvaluateAvailability)
            {
                if (balance < qtd)
                {
                    Logs.Add(new Log
                    {
                        Description    = "Não é permitido movimentar item sem disponibilidade.",
                        ProcessStatus  = ProcessStatus.Alert,
                        Identification = stockItem.Code + " - " + stockItem.Description
                    });
                    return(false);
                }
            }

            if (stockItem.NotNegativeBalance && balance < 0)
            {
                Logs.Add(new Log
                {
                    Description    = "Não é permitido movimentar item com saldo negativo.",
                    ProcessStatus  = ProcessStatus.Alert,
                    Identification = stockItem.Code + " - " + stockItem.Description
                });
                return(false);
            }

            return(true);
        }
Пример #3
0
        /// <summary>
        /// Saldo Disponível
        /// </summary>
        /// <param name="stockItemId">ID do item de estoque.</param>
        /// <param name="localStockId">ID do local de estoque.</param>
        /// <returns></returns>
        public decimal BalanceAvailable(int stockItemId, int localStockId, int unitMeasurId)
        {
            _itemInputStockApp        = new ItemInputStockApp(connection);
            _itemOutputStockApp       = new ItemOutputStockApp(connection);
            _stockItemApp             = new StockItemApp(connection);
            _localStockApp            = new LocalStockApp(connection);
            _unitMeasureConversionApp = new UnitMeasureConversionApp(connection);

            var qtdInput  = _itemInputStockApp.GetQuantityTotal(stockItemId, localStockId);
            var qtdOutput = _itemOutputStockApp.GetQuantityTotal(stockItemId, localStockId);
            var stockItem = _stockItemApp.FindId(stockItemId);

            return(_unitMeasureConversionApp.Convert(stockItem.UnitMeasureId, unitMeasurId, stockItemId, stockItem.FamilyId, qtdInput - qtdOutput));
        }
Пример #4
0
 public ItemOutputStockController(IFactoryConnection connection)
 {
     _connection         = connection;
     _ItemOutputStockApp = new ItemOutputStockApp(connection);
 }