Пример #1
0
        public void DeleteStockLocator(StockLocator toDelete, IEnumerable <string> privileges)
        {
            if (!this.authService.HasPermissionFor(AuthorisedAction.CreateStockLocator, privileges))
            {
                throw new StockLocatorException("You are not authorised to delete.");
            }

            if (this.reqMoveRepository.FindBy(m => m.StockLocatorId == toDelete.Id) != null)
            {
                throw new StockLocatorException("Cannot Delete Stock Locators When Dependent Req Move exists");
            }

            this.stockLocatorRepository.Remove(toDelete);

            toDelete.Part = this.partRepository.FindBy(p => p.PartNumber == toDelete.PartNumber);

            if (!this.stockLocatorRepository.FilterBy(l => l.PalletNumber == toDelete.PalletNumber && l.Quantity > 0)
                .Any())
            {
                foreach (var storesPallet in this.palletRepository.FilterBy(
                             p => p.PalletNumber == toDelete.PalletNumber))
                {
                    this.palletRepository.UpdatePallet(storesPallet.PalletNumber, null, null);
                }
            }
        }
Пример #2
0
        public void UpdateStockLocator(StockLocator from, StockLocator to, IEnumerable <string> privileges)
        {
            if (!this.authService.HasPermissionFor(AuthorisedAction.UpdateStockLocator, privileges))
            {
                throw new StockLocatorException("You are not authorised to update.");
            }

            from.Part = this.partRepository.FindBy(p => p.PartNumber == from.PartNumber);

            from.BatchRef          = to.BatchRef;
            from.StockRotationDate = to.StockRotationDate;
            from.Quantity          = to.Quantity;
            from.Remarks           = to.Remarks;
            from.PalletNumber      = to.PalletNumber;
            from.LocationId        = to.LocationId;
        }
Пример #3
0
        public StockLocator CreateStockLocator(
            StockLocator toCreate,
            string auditDepartmentCode,
            IEnumerable <string> privileges)
        {
            if (!this.authService.HasPermissionFor(AuthorisedAction.CreateStockLocator, privileges))
            {
                throw new StockLocatorException("You are not authorised to create.");
            }

            if (toCreate.LocationId.HasValue == toCreate.PalletNumber.HasValue)
            {
                throw new StockLocatorException("Must Supply EITHER Location Id OR Pallet Number");
            }

            if (toCreate.PalletNumber != null)
            {
                var pallets = this.palletRepository.FilterBy(p => p.PalletNumber == toCreate.PalletNumber);
                foreach (var storesPallet in pallets)
                {
                    if (storesPallet.AuditedByDepartmentCode == null && auditDepartmentCode == null)
                    {
                        throw new StockLocatorException("Audit department must be entered");
                    }

                    if (auditDepartmentCode != null)
                    {
                        storesPallet.AuditFrequencyWeeks     = 26;
                        storesPallet.AuditedByDepartmentCode = auditDepartmentCode;
                    }
                }
            }

            toCreate.StockPoolCode = "LINN DEPT";
            toCreate.State         = "STORES";
            toCreate.Category      = "FREE";

            if (!toCreate.Quantity.HasValue || toCreate.Quantity == 0)
            {
                toCreate.Quantity = 1;
            }

            toCreate.Part = this.partRepository.FindBy(p => p.PartNumber == toCreate.PartNumber);

            return(toCreate);
        }