Esempio n. 1
0
 public InventoryMovementReportController(IIdentityService identityService, IValidateService validateService, IInventoryMovementService service)
 {
     IdentityService = identityService;
     ValidateService = validateService;
     Service         = service;
     ApiVersion      = "1.0.0";
 }
Esempio n. 2
0
        public static SelectList GetReversalInventoryMovementData(string plant, string facode)
        {
            IInventoryMovementService inventoryMovementBll = MvcApplication.GetInstance <InventoryMovementService>();
            var inventoryMovementList = inventoryMovementBll.GetReversalData(plant, facode);
            var selectItemSource      = Mapper.Map <List <SelectItemModel> >(inventoryMovementList);

            return(new SelectList(selectItemSource, "ValueField", "TextField"));
        }
Esempio n. 3
0
        public ReversalBLL(ILogger logger, IUnitOfWork uow)
        {
            _logger         = logger;
            _uow            = uow;
            _repository     = _uow.GetGenericRepository <REVERSAL>();
            _repositoryCk4c = _uow.GetGenericRepository <CK4C>();
            _repositoryProd = _uow.GetGenericRepository <PRODUCTION>();

            _zaapShiftRptService      = new ZaapShiftRptService(_uow, _logger);
            _inventoryMovementService = new InventoryMovementService(_uow, _logger);
            _userPlantBll             = new UserPlantMapBLL(_uow, _logger);
            _poaMapBll = new POAMapBLL(_uow, _logger);
            _plantBll  = new PlantBLL(_uow, _logger);
        }
        public async Task <int> Create(InventoryDocument model)
        {
            int Created             = 0;
            var internalTransaction = DbContext.Database.CurrentTransaction == null;
            var transaction         = !internalTransaction ? DbContext.Database.CurrentTransaction : DbContext.Database.BeginTransaction();

            try
            {
                IInventoryMovementService movement = ServiceProvider.GetService <IInventoryMovementService>();

                model.No = GenerateNo(model);
                model.FlagForCreate(IdentityService.Username, UserAgent);
                model.FlagForUpdate(IdentityService.Username, UserAgent);

                foreach (var item in model.Items)
                {
                    item.FlagForCreate(IdentityService.Username, UserAgent);
                    item.FlagForUpdate(IdentityService.Username, UserAgent);
                }

                DbSet.Add(model);
                Created = await DbContext.SaveChangesAsync();

                foreach (var item in model.Items)
                {
                    var qty = item.Quantity;
                    if (model.Type == "OUT")
                    {
                        qty = item.Quantity * -1;
                    }
                    var SumQty = DbContext.InventoryMovements.Where(a => a._IsDeleted == false && a.StorageId == model.StorageId && a.ProductId == item.ProductId && a.UomId == item.UomId).Sum(a => a.Quantity);

                    InventoryMovement movementModel = new InventoryMovement
                    {
                        ProductCode   = item.ProductCode,
                        ProductId     = item.ProductId,
                        ProductName   = item.ProductName,
                        StorageCode   = model.StorageCode,
                        StorageId     = model.StorageId,
                        StorageName   = model.StorageName,
                        Before        = SumQty,
                        Quantity      = qty,
                        After         = SumQty + qty,
                        ReferenceNo   = model.ReferenceNo,
                        ReferenceType = model.ReferenceType,
                        Type          = model.Type,
                        Date          = model.Date,
                        UomId         = item.UomId,
                        UomUnit       = item.UomUnit,
                        Remark        = item.ProductRemark
                    };
                    await movement.Create(movementModel);
                }
                if (internalTransaction)
                {
                    transaction.Commit();
                }

                return(Created);
            }
            catch (Exception e)
            {
                if (internalTransaction)
                {
                    transaction.Rollback();
                }
                throw new Exception(e.Message);
            }
        }