public void SetUp()
        {
            this.storesPackResult = new RequisitionProcessResult {
                Success = false
            };
            this.From = "P1000";
            this.To   = "P2000";

            this.StoresPack.CreateMoveReq(this.UserNumber)
            .Returns(this.storesPackResult);

            this.action = () => this.Sut.MoveStock(
                null,
                this.PartNumber,
                this.Quantity,
                this.From,
                null,
                null,
                null,
                null,
                null,
                this.To,
                null,
                null,
                null,
                null,
                this.UserNumber);
        }
Example #2
0
        public void SetUp()
        {
            this.moveResult = new RequisitionProcessResult {
                Message = "not ok", Success = false
            };
            this.resource = new MoveStockRequestResource
            {
                PartNumber = "P1",
                Quantity   = 2,
                From       = "L1",
                To         = "L2",
                UserNumber = 32432
            };
            this.MoveStockService.MoveStock(
                this.resource.ReqNumber,
                this.resource.PartNumber,
                this.resource.Quantity,
                this.resource.From,
                this.resource.FromLocationId,
                this.resource.FromPalletNumber,
                null,
                null,
                null,
                this.resource.To,
                this.resource.ToLocationId,
                this.resource.ToPalletNumber,
                null,
                null,
                this.resource.UserNumber)
            .Returns(this.moveResult);

            this.result = this.Sut.MoveStock(this.resource);
        }
        public void SetUp()
        {
            this.fromLocationId = 23;
            this.toLocationId   = 34;
            this.From           = "E-LOC-1";
            this.To             = "E-LOC-2";

            this.StoresPack.CheckStockAtFromLocation(
                this.PartNumber,
                this.Quantity,
                this.From,
                this.fromLocationId,
                null,
                this.FromStockDate)
            .Returns(new RequisitionProcessResult(true, "ok"));

            this.StorageLocationRepository.FindBy(Arg.Any <Expression <Func <StorageLocation, bool> > >())
            .Returns(
                new StorageLocation {
                LocationId = this.fromLocationId
            },
                new StorageLocation {
                LocationId = this.toLocationId
            });

            this.StoresPack.MoveStock(
                this.ReqNumber,
                3,
                this.PartNumber,
                this.Quantity,
                this.fromLocationId,
                null,
                this.FromStockDate,
                this.toLocationId,
                null,
                null,
                null,
                null).Returns(new ProcessResult(true, "ok"));
            this.result = this.Sut.MoveStock(
                this.ReqNumber,
                this.PartNumber,
                this.Quantity,
                this.From,
                null,
                null,
                this.FromStockDate,
                null,
                null,
                this.To,
                null,
                null,
                null,
                null,
                this.UserNumber);
        }
Example #4
0
        public void SetUp()
        {
            this.existingReqNumber = null;
            this.storesPackResult  =
                new RequisitionProcessResult {
                Success = true, Message = "ok", ReqNumber = this.ReqNumber
            };
            this.From = "P1000";
            this.To   = "P2000";

            this.StoresPack.CreateMoveReq(this.UserNumber)
            .Returns(this.storesPackResult);
            this.StoresPack.CheckStockAtFromLocation(this.PartNumber, this.Quantity, this.From, null, 1000, null)
            .Returns(new RequisitionProcessResult(true, "ok"));
            this.StoresPack.MoveStock(
                this.ReqNumber,
                3,
                this.PartNumber,
                this.Quantity,
                null,
                1000,
                null,
                null,
                2000,
                null,
                null,
                null).Returns(new ProcessResult(true, "ok"));
            this.result = this.Sut.MoveStock(
                this.existingReqNumber,
                this.PartNumber,
                this.Quantity,
                this.From,
                null,
                null,
                null,
                null,
                null,
                this.To,
                null,
                null,
                null,
                null,
                this.UserNumber);
        }
        public void SetUp()
        {
            this.From = "P1000";
            this.To   = "P2000";

            this.StoresPack.CheckStockAtFromLocation(
                this.PartNumber,
                this.Quantity,
                this.From,
                null,
                1000,
                this.FromStockDate)
            .Returns(new RequisitionProcessResult(true, "ok"));
            this.StoresPack.MoveStock(
                this.ReqNumber,
                3,
                this.PartNumber,
                this.Quantity,
                null,
                1000,
                this.FromStockDate,
                null,
                2000,
                null,
                null,
                null).Returns(new ProcessResult(true, "ok"));
            this.result = this.Sut.MoveStock(
                this.ReqNumber,
                this.PartNumber,
                this.Quantity,
                this.From,
                null,
                null,
                this.FromStockDate,
                null,
                null,
                this.To,
                null,
                null,
                null,
                null,
                this.UserNumber);
        }
Example #6
0
        public void SetUp()
        {
            this.moveResult = new RequisitionProcessResult {
                Message = "ok", Success = true
            };
            this.resource = new MoveStockRequestResource
            {
                PartNumber            = "P1",
                Quantity              = 2,
                From                  = "L1",
                FromLocationId        = 3,
                FromPalletNumber      = 34,
                FromStockRotationDate = 21.March(2022).ToString("O"),
                FromState             = "good",
                FromStockPoolCode     = "pool 1",
                To                  = "L2",
                ToLocationId        = 536,
                ToPalletNumber      = 8000,
                ToStockRotationDate = 2.April(2024).ToString("O"),
                UserNumber          = 909,
                StorageType         = "type"
            };
            this.MoveStockService.MoveStock(
                this.resource.ReqNumber,
                this.resource.PartNumber,
                this.resource.Quantity,
                this.resource.From,
                this.resource.FromLocationId,
                this.resource.FromPalletNumber,
                21.March(2022),
                this.resource.FromState,
                this.resource.FromStockPoolCode,
                this.resource.To,
                this.resource.ToLocationId,
                this.resource.ToPalletNumber,
                2.April(2024),
                this.resource.StorageType,
                this.resource.UserNumber)
            .Returns(this.moveResult);

            this.result = this.Sut.MoveStock(this.resource);
        }
Example #7
0
        public void SetUp()
        {
            this.resource = new MoveStockRequestResource {
                From = "Loc1", To = "Loc2"
            };
            this.processResult = new RequisitionProcessResult {
                Success = true, Message = "ok", ReqNumber = 23
            };
            this.MoveStockFacadeService.MoveStock(Arg.Is <MoveStockRequestResource>(
                                                      a => a.From == this.resource.From && a.To == this.resource.To))
            .Returns(new SuccessResult <RequisitionProcessResult>(this.processResult));

            this.Response = this.Browser.Post(
                "/inventory/move-stock",
                with =>
            {
                with.Header("Accept", "application/json");
                with.JsonBody(this.resource);
            }).Result;
        }
Example #8
0
        public void SetUp()
        {
            this.From = "P1000";

            this.result = this.Sut.MoveStock(
                this.ReqNumber,
                this.PartNumber,
                this.Quantity,
                this.From,
                null,
                null,
                null,
                null,
                null,
                string.Empty,
                null,
                null,
                null,
                null,
                this.UserNumber);
        }
Example #9
0
        public void SetUp()
        {
            this.From = "E-K1-34-34";
            this.To   = "K2";

            this.result = this.Sut.MoveStock(
                this.ReqNumber,
                this.PartNumber,
                this.Quantity,
                this.From,
                null,
                null,
                null,
                null,
                null,
                this.To,
                null,
                null,
                null,
                null,
                this.UserNumber);
        }
Example #10
0
        public RequisitionProcessResult MoveStock(
            int?reqNumber,
            string partNumber,
            decimal quantity,
            string from,
            int?fromLocationId,
            int?fromPalletNumber,
            DateTime?fromStockRotationDate,
            string fromState,
            string fromStockPool,
            string to,
            int?toLocationId,
            int?toPalletNumber,
            DateTime?toStockRotationDate,
            string storageType,
            int userNumber)
        {
            if (quantity <= 0)
            {
                return(new RequisitionProcessResult(false, "You must have a valid quantity."));
            }

            if (string.IsNullOrEmpty(from) || string.IsNullOrEmpty(to))
            {
                return(new RequisitionProcessResult(false, "A from and to location must be specified."));
            }

            if (this.IsKardexLocation(from) && this.IsKardexLocation(to))
            {
                return(new RequisitionProcessResult(false, "You cannot move between two Kardex locations."));
            }

            var result = new RequisitionProcessResult();

            if (!reqNumber.HasValue)
            {
                var createResult = this.storesPack.CreateMoveReq(userNumber);
                if (!createResult.Success)
                {
                    throw new CreateReqFailureException("Failed to create move req");
                }

                result.ReqNumber = createResult.ReqNumber;
            }
            else
            {
                result.ReqNumber = reqNumber.Value;
            }

            var req = this.requisitionRepository.FindById(result.ReqNumber);

            if (!this.IsKardexLocation(from) && !fromLocationId.HasValue && !fromPalletNumber.HasValue)
            {
                this.GetLocationDetails(from, out fromLocationId, out fromPalletNumber);
            }

            if (!this.IsKardexLocation(to) && !toLocationId.HasValue && !toPalletNumber.HasValue)
            {
                this.GetLocationDetails(to, out toLocationId, out toPalletNumber);
            }

            this.CheckPallet(fromPalletNumber);
            this.CheckPallet(toPalletNumber);

            var nextLineNumber = req.Lines.Count() + 1;

            var checkFromLocation = this.storesPack.CheckStockAtFromLocation(
                partNumber,
                quantity,
                from,
                fromLocationId,
                fromPalletNumber,
                fromStockRotationDate);

            if (!checkFromLocation.Success)
            {
                throw new MoveInvalidException("The required stock doesn't exist at that from location.");
            }

            ProcessResult moveResult;

            if (this.IsKardexLocation(from))
            {
                moveResult = this.kardexPack.MoveStockFromKardex(
                    result.ReqNumber,
                    nextLineNumber,
                    from,
                    partNumber,
                    quantity,
                    storageType,
                    toLocationId,
                    toPalletNumber);
            }
            else if (this.IsKardexLocation(to))
            {
                if (!fromStockRotationDate.HasValue && !toStockRotationDate.HasValue)
                {
                    moveResult = new ProcessResult
                    {
                        Message = "You must provide either a from or to stock rotation date",
                        Success = false
                    };
                }
                else
                {
                    moveResult = this.kardexPack.MoveStockToKardex(
                        result.ReqNumber,
                        nextLineNumber,
                        to,
                        partNumber,
                        quantity,
                        fromStockRotationDate,
                        storageType,
                        fromLocationId,
                        fromPalletNumber,
                        toStockRotationDate,
                        null);
                }
            }
            else
            {
                moveResult = this.storesPack.MoveStock(
                    result.ReqNumber,
                    nextLineNumber,
                    partNumber,
                    quantity,
                    fromLocationId,
                    fromPalletNumber,
                    fromStockRotationDate,
                    toLocationId,
                    toPalletNumber,
                    toStockRotationDate,
                    !string.IsNullOrEmpty(fromState) ? fromState : checkFromLocation.State,
                    fromStockPool);
            }

            result.Success = moveResult.Success;
            result.Message = moveResult.Message;
            return(result);
        }