Exemple #1
0
        public Task <Int64> Create(MoveQueuesPost movequeuesPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._movequeuesRepository.RegisterCreate(movequeuesPost);
            try
            {
                this._movequeuesRepository.Commit();
            }
            catch (Exception ex)
            {
                this._movequeuesRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process

            //Custom Code Start | Added Code Block
            //We update the queued utilization if necesary
            if (movequeuesPost.ixMoveQueueType == _commonLookUps.getMoveQueueTypes().Where(x => x.sMoveQueueType == "Consolidated Pickup - Consolidated Drop").Select(x => x.ixMoveQueueType).FirstOrDefault()
                //&& movequeuesPost.ixMoveQueueContext == _commonLookUps.getMoveQueueContexts().Where(x => x.sMoveQueueContext == "Putaway").Select(x => x.ixMoveQueueContext).FirstOrDefault()
                &&
                movequeuesPost.ixSourceInventoryLocation != movequeuesPost.ixTargetInventoryLocation
                )
            {
                var targetInventoryLocation      = _inventorylocationsService.GetPost(movequeuesPost.ixTargetInventoryLocation ?? 0);
                var inventoryUnitsOnHandlingUnit = _inventoryunitsService.IndexDb().Where(x => x.ixHandlingUnit == movequeuesPost.ixTargetHandlingUnit).ToList();
                targetInventoryLocation.nQueuedUtilisationPercent = _volumeAndWeight.getNewLocationQueuedUtilisationPercent(movequeuesPost.ixTargetHandlingUnit ?? 0, inventoryUnitsOnHandlingUnit, targetInventoryLocation, true);
                targetInventoryLocation.UserName = movequeuesPost.UserName;
                _inventorylocationsService.Edit(targetInventoryLocation);
            }

            if (movequeuesPost.ixMoveQueueType == _commonLookUps.getMoveQueueTypes().Where(x => x.sMoveQueueType == "Unit Pickup - Consolidated Drop").Select(x => x.ixMoveQueueType).FirstOrDefault()
                //&& movequeuesPost.ixMoveQueueContext == _commonLookUps.getMoveQueueContexts().Where(x => x.sMoveQueueContext == "Picking").Select(x => x.ixMoveQueueContext).FirstOrDefault()
                &&
                movequeuesPost.ixSourceInventoryLocation != movequeuesPost.ixTargetInventoryLocation
                )
            {
                var targetInventoryLocation = _inventorylocationsService.GetPost(movequeuesPost.ixTargetInventoryLocation ?? 0);
                var targetInventoryUnit     = _inventoryunitsService.GetPost(movequeuesPost.ixTargetInventoryUnit ?? 0);
                targetInventoryLocation.nQueuedUtilisationPercent = _volumeAndWeight.getNewLocationQueuedUtilisationPercent(targetInventoryUnit, targetInventoryLocation, true);
                targetInventoryLocation.UserName = movequeuesPost.UserName;
                _inventorylocationsService.Edit(targetInventoryLocation);
            }



            //Custom Code End

            return(Task.FromResult(movequeuesPost.ixMoveQueue));
        }
Exemple #2
0
        public ActionResult Edit(long id)
        {
            InventoryUnitsPost inventoryunits = _inventoryunitsService.GetPost(id);

            if (inventoryunits == null)
            {
                return(NotFound());
            }
            ViewBag.ixCompany           = new SelectList(_inventoryunitsService.selectCompanies().Select(x => new { x.ixCompany, x.sCompany }), "ixCompany", "sCompany", inventoryunits.ixCompany);
            ViewBag.ixFacility          = new SelectList(_inventoryunitsService.selectFacilities().Select(x => new { x.ixFacility, x.sFacility }), "ixFacility", "sFacility", inventoryunits.ixFacility);
            ViewBag.ixHandlingUnit      = new SelectList(_inventoryunitsService.selectHandlingUnitsNullable().Select(x => new { ixHandlingUnit = x.Key, sHandlingUnit = x.Value }), "ixHandlingUnit", "sHandlingUnit", inventoryunits.ixHandlingUnit);
            ViewBag.ixInventoryLocation = new SelectList(_inventoryunitsService.selectInventoryLocations().Select(x => new { x.ixInventoryLocation, x.sInventoryLocation }), "ixInventoryLocation", "sInventoryLocation", inventoryunits.ixInventoryLocation);
            ViewBag.ixInventoryState    = new SelectList(_inventoryunitsService.selectInventoryStates().Select(x => new { x.ixInventoryState, x.sInventoryState }), "ixInventoryState", "sInventoryState", inventoryunits.ixInventoryState);
            ViewBag.ixMaterial          = new SelectList(_inventoryunitsService.selectMaterials().Select(x => new { x.ixMaterial, x.sMaterial }), "ixMaterial", "sMaterial", inventoryunits.ixMaterial);
            ViewBag.ixStatus            = new SelectList(_inventoryunitsService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus", inventoryunits.ixStatus);

            return(View(inventoryunits));
        }
        private async Task <DialogTurnResult> BaseUnitQuantityPickedPrompt(
            WaterfallStepContext step,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            //Custom Code Start | Removed Block
            //FoundChoice _InventoryUnit = (FoundChoice)step.Result;
            //var ixInventoryUnit = _pickbatchpickingService.selectInventoryUnits().Where(ct => ct.sInventoryUnit == _InventoryUnit.Value).Select(ct => ct.ixInventoryUnit).First();
            //((PickBatchPickingPost)step.Values[DialogKey]).ixInventoryUnit = ixInventoryUnit;
            //Custom Code End

            //if (!(((PickBatchPickingPost)step.Options).ixPickBatch > 0))
            //{
            //    return await step.BeginDialogAsync(CreateGetPickBatchesDialogId, null, cancellationToken);
            //    //var sPickBatchPick = (string)step.Result;
            //    //((PickBatchPickingPost)step.Values[DialogKey]).sPickBatchPick = sPickBatchPick;
            //}
            //else
            //{
            step.Values[DialogKey] = new PickBatchPickingPost();
            ((PickBatchPickingPost)step.Values[DialogKey]).sPickBatchPick = ((PickBatchPickingPost)step.Options).sPickBatchPick;
            //}

            //Custom Code Start | Added Code Block
            var sPickBatchPick = ((PickBatchPickingPost)step.Options).sPickBatchPick;
            //((PickBatchPickingPost)step.Values[DialogKey]).sPickBatchPick = sPickBatchPick;

            var ixPickBatch = _pickbatchesService.IndexDb().Where(x => x.sPickBatch.Trim().ToLower() == sPickBatchPick.Trim().ToLower()).Select(x => x.ixPickBatch).FirstOrDefault();

            ((PickBatchPickingPost)step.Values[DialogKey]).ixPickBatch = ixPickBatch;
            //Now we get the pick suggestion
            var currentBotUserData = await _botSpielUserStateAccessors.BotUserDataAccessor.GetAsync(step.Context, () => _botUserData);

            var pickSuggestion = _picking.getPickSuggestion(ixPickBatch, currentBotUserData);

            currentBotUserData.pickSuggestion = pickSuggestion;
            await _botSpielUserStateAccessors.BotUserDataAccessor.SetAsync(step.Context, currentBotUserData, cancellationToken);

            await _botSpielUserStateAccessors.UserState.SaveChangesAsync(step.Context);

            var pickSuggestionText = "";

            if (pickSuggestion.Item1 > 0 && pickSuggestion.Item2 > 0)
            {
                var inventoryUnit = _inventoryunitsService.Get(pickSuggestion.Item1);
                pickSuggestionText = $@"Please pick inventory unit:
Inventory Location: {inventoryUnit.InventoryLocations.sInventoryLocation}
Handling Unit: {inventoryUnit.HandlingUnits.sHandlingUnit}
Material: {inventoryUnit.Materials.sMaterial}
Pick Quantity: {pickSuggestion.Item2}
and confirm the quantity picked.
";
                ((PickBatchPickingPost)step.Values[DialogKey]).ixInventoryUnit = inventoryUnit.ixInventoryUnit;
                step.Values[PickSuggestionKey]    = inventoryUnit;
                step.Values[PickSuggestionQtyKey] = pickSuggestion.Item2;
                //We update the queued qty on the iu
                var inventoryUnitPickedFrom = _inventoryunitsService.GetPost(inventoryUnit.ixInventoryUnit);
                inventoryUnitPickedFrom.nBaseUnitQuantityQueued += pickSuggestion.Item2;
                inventoryUnitPickedFrom.UserName = step.Context.Activity.Conversation.Id;
                await _inventoryunitsService.Edit(inventoryUnitPickedFrom, _commonLookUps.getInventoryUnitTransactionContext().Where(x => x.sInventoryUnitTransactionContext == "Inventory Adjustment").Select(x => x.ixInventoryUnitTransactionContext).FirstOrDefault());
            }
            else
            {
                pickSuggestionText = "I cannot find an inventory unit to pick, please exit and choose a different batch or correct the inventory.";
            }

            //Custom Code End

            return(await step.PromptAsync(
                       BaseUnitQuantityPickedPromptId,
                       new PromptOptions
            {
                //Custom Code Start | Replaced Code Block
                //Replaced Code Block Start
                //Prompt = MessageFactory.Text($"Please enter a BaseUnitQuantityPicked:"),
                //Replaced Code Block End
                Prompt = MessageFactory.Text($"{pickSuggestionText}"),
                //Custom Code End
                RetryPrompt = MessageFactory.Text("Please enter a number."),
            },
                       cancellationToken));
        }
        public Task <Int64> Create(ReceivingPost receivingPost)
        {
            // Additional validations

            // Pre-process

            //Custom Code Start | Added Code Block
            //If the handling unit does not exist we create it
            if (!HandlingUnitsDb().Where(x => x.sHandlingUnit == receivingPost.sReceipt.Trim()).Any())
            {
                HandlingUnitsPost handlingUnitsPost = new HandlingUnitsPost();
                handlingUnitsPost.sHandlingUnit      = receivingPost.sReceipt;
                handlingUnitsPost.ixHandlingUnitType = receivingPost.ixHandlingUnitType ?? 0;
                handlingUnitsPost.UserName           = receivingPost.UserName;
                receivingPost.ixHandlingUnit         = _handlingunitsService.Create(handlingUnitsPost).Result;
            }
            else
            {
                receivingPost.ixHandlingUnit = HandlingUnitsDb().Where(x => x.sHandlingUnit == receivingPost.sReceipt.Trim()).Select(x => x.ixHandlingUnit).FirstOrDefault();
            }

            InventoryUnitsPost inventoryUnit = new InventoryUnitsPost();
            var inboundOrder = _inboundordersService.GetPost(receivingPost.ixInboundOrder);

            inventoryUnit.ixFacility          = inboundOrder.ixFacility;
            inventoryUnit.ixCompany           = inboundOrder.ixCompany;
            inventoryUnit.ixMaterial          = receivingPost.ixMaterial;
            inventoryUnit.ixInventoryState    = receivingPost.ixInventoryState;
            inventoryUnit.ixHandlingUnit      = receivingPost.ixHandlingUnit;
            inventoryUnit.ixInventoryLocation = receivingPost.ixInventoryLocation;
            inventoryUnit.sSerialNumber       = receivingPost.sSerialNumber;
            inventoryUnit.sBatchNumber        = receivingPost.sBatchNumber;
            inventoryUnit.dtExpireAt          = receivingPost.dtExpireAt;
            inventoryUnit.UserName            = receivingPost.UserName;

            if ((inventoryUnit.sSerialNumber ?? "").Trim() != "")
            {
                //We create an iu
                inventoryUnit.nBaseUnitQuantity = receivingPost.nBaseUnitQuantityReceived;
                _inventoryunitsService.Create(inventoryUnit, _ixInventoryUnitTransactionContext);
            }
            else if (_inventoryunitsService.IndexDb().Where(x =>
                                                            x.ixFacility == inventoryUnit.ixFacility &&
                                                            x.ixCompany == inventoryUnit.ixCompany &&
                                                            x.ixMaterial == inventoryUnit.ixMaterial &&
                                                            x.ixInventoryState == inventoryUnit.ixInventoryState &&
                                                            x.ixHandlingUnit == inventoryUnit.ixHandlingUnit &&
                                                            x.ixInventoryLocation == inventoryUnit.ixInventoryLocation &&
                                                            x.sBatchNumber == inventoryUnit.sBatchNumber &&
                                                            x.dtExpireAt == inventoryUnit.dtExpireAt && x.ixStatus == 5
                                                            ).Select(x => x.ixInventoryUnit).Any()
                     )
            {
                //We edit the iu
                inventoryUnit.ixInventoryUnit = _inventoryunitsService.IndexDb().Where(x =>
                                                                                       x.ixFacility == inventoryUnit.ixFacility &&
                                                                                       x.ixCompany == inventoryUnit.ixCompany &&
                                                                                       x.ixMaterial == inventoryUnit.ixMaterial &&
                                                                                       x.ixInventoryState == inventoryUnit.ixInventoryState &&
                                                                                       x.ixHandlingUnit == inventoryUnit.ixHandlingUnit &&
                                                                                       x.ixInventoryLocation == inventoryUnit.ixInventoryLocation &&
                                                                                       x.sBatchNumber == inventoryUnit.sBatchNumber &&
                                                                                       x.dtExpireAt == inventoryUnit.dtExpireAt && x.ixStatus == 5
                                                                                       ).Select(x => x.ixInventoryUnit).FirstOrDefault();
                inventoryUnit.nBaseUnitQuantity = _inventoryunitsService.GetPost(inventoryUnit.ixInventoryUnit).nBaseUnitQuantity + receivingPost.nBaseUnitQuantityReceived;
                _inventoryunitsService.Edit(inventoryUnit, _ixInventoryUnitTransactionContext);
            }
            else
            {
                //We create an iu
                inventoryUnit.nBaseUnitQuantity = receivingPost.nBaseUnitQuantityReceived;
                _inventoryunitsService.Create(inventoryUnit, _ixInventoryUnitTransactionContext);
            }


            //Custom Code End

            // Process
            this._receivingRepository.RegisterCreate(receivingPost);
            try
            {
                this._receivingRepository.Commit();
            }
            catch (Exception ex)
            {
                this._receivingRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process

            //Custom Code Start | Added Code Block
            //Now we update the inbound order lines - for now we apply entire qty to the matching line
            var _ixInboundOrderLine = _inboundorderlinesService.IndexDb().Where(x => x.ixInboundOrder == receivingPost.ixInboundOrder && x.ixMaterial == receivingPost.ixMaterial).Select(x => x.ixInboundOrderLine).FirstOrDefault();
            var inboundOrderLine    = _inboundorderlinesService.GetPost(_ixInboundOrderLine);

            inboundOrderLine.nBaseUnitQuantityReceived += receivingPost.nBaseUnitQuantityReceived;
            inboundOrderLine.UserName = receivingPost.UserName;
            if ((inboundOrderLine.nBaseUnitQuantityExpected - inboundOrderLine.nBaseUnitQuantityReceived) == 0)
            {
                inboundOrderLine.ixStatus = _commonLookUps.getStatuses().Where(x => x.sStatus == "Complete").Select(x => x.ixStatus).FirstOrDefault();
            }
            _inboundorderlinesService.Edit(inboundOrderLine);

            //If there are no open qtys we set the inbound order/line status to complete
            if (_inboundorderlinesService.IndexDb().Where(x => x.ixInboundOrder == receivingPost.ixInboundOrder).Select(x => x.nBaseUnitQuantityExpected - x.nBaseUnitQuantityReceived).Sum() == 0)
            {
                var inboundorder = _inboundordersService.GetPost(receivingPost.ixInboundOrder);
                inboundorder.ixStatus = _commonLookUps.getStatuses().Where(x => x.sStatus == "Complete").Select(x => x.ixStatus).FirstOrDefault();
                _inboundordersService.Edit(inboundorder);
            }

            //Custom Code End

            return(Task.FromResult(receivingPost.ixReceipt));
        }
Exemple #5
0
        public void shipInventoryForManifest(Int64 ixOutboundCarrierManifest, string UserName)
        {
            var ixStatusActive   = _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault();
            var ixStatusInactive = _commonLookUps.getStatuses().Where(s => s.sStatus == "Inactive").Select(s => s.ixStatus).FirstOrDefault();
            var ixStatusComplete = _commonLookUps.getStatuses().Where(s => s.sStatus == "Complete").Select(s => s.ixStatus).FirstOrDefault();
            var ixInventoryUnitTransactionContext = _commonLookUps.getInventoryUnitTransactionContext().Where(c => c.sInventoryUnitTransactionContext == "Handling Units Shipping").Select(c => c.ixInventoryUnitTransactionContext).FirstOrDefault();

            var outboundshipments = _outboundshipmentsService.IndexDb().Where(sh => sh.ixOutboundCarrierManifest == ixOutboundCarrierManifest && sh.ixStatus == ixStatusActive)
                                    .Select(sh => sh.ixOutboundShipment).ToList();

            var outboundorders = _outboundordersRepository.IndexDb().Where(o => o.ixStatus == ixStatusActive)
                                 .Join(outboundshipments, o => o.ixOutboundShipment, sh => sh, (o, sh) => new { O = o, Sh = sh })
                                 .Select(x => x.O.ixOutboundOrder).ToList();

            var outboundorderlines = _outboundorderlinesService.IndexDb()
                                     .Join(outboundorders, ol => ol.ixOutboundOrder, o => o, (ol, o) => new { Ol = ol, O = o })
                                     .Select(x => x.Ol.ixOutboundOrderLine).ToList();

            var outboundorderlinesinventoryallocation = _outboundorderlinesinventoryallocationService.IndexDb()
                                                        .Join(outboundorderlines, ola => ola.ixOutboundOrderLine, ol => ol, (ola, ol) => new { Ola = ola, Ol = ol })
                                                        .Where(x => x.Ola.nBaseUnitQuantityPicked == x.Ola.nBaseUnitQuantityAllocated).Select(x => x.Ola.ixOutboundOrderLineInventoryAllocation).ToList();

            var outboundorderlinepacking = _outboundorderlinepackingService.IndexDb().Where(x => x.ixStatus == ixStatusActive)
                                           .Join(outboundorderlines, p => p.ixOutboundOrderLine, ol => ol, (p, ol) => new { P = p, Ol = ol })
                                           .Select(x => x.P.ixOutboundOrderLinePack).ToList();

            var outboundorderlinesshipped = _outboundorderlinepackingService.IndexDb().Where(x => x.ixStatus == ixStatusActive)
                                            .Join(outboundorderlines, p => p.ixOutboundOrderLine, ol => ol, (p, ol) => new { P = p, Ol = ol })
                                            .Select(x => new { ixOutboundOrderLine = x.P.ixOutboundOrderLine, nBaseUnitQuantityPacked = x.P.nBaseUnitQuantityPacked }).ToList();

            var handlingunitsToShip = _outboundorderlinepackingService.IndexDb().Where(x => x.ixStatus == ixStatusActive)
                                      .Join(outboundorderlines, p => p.ixOutboundOrderLine, ol => ol, (p, ol) => new { P = p, Ol = ol })
                                      .Select(x => x.P.ixHandlingUnit).Distinct().ToList();

            var inventoryunitsToShip = _inventoryunitsService.IndexDbPost().Where(x => x.nBaseUnitQuantity > 0)
                                       .Join(handlingunitsToShip, iu => iu.ixHandlingUnit, hu => hu, (iu, hu) => new { Iu = iu, Hu = hu })
                                       .Select(x => x.Iu.ixInventoryUnit).Distinct().ToList();

            inventoryunitsToShip.ForEach(x =>
            {
                var inventoryunit = _inventoryunitsService.GetPost(x);
                inventoryunit.nBaseUnitQuantity = 0;
                inventoryunit.ixStatus          = ixStatusInactive;
                inventoryunit.UserName          = UserName;
                _inventoryunitsService.Edit(inventoryunit, ixInventoryUnitTransactionContext);
            }
                                         );

            handlingunitsToShip.ForEach(x =>
            {
                var handlingunit      = _handlingunitsService.GetPost(x);
                handlingunit.ixStatus = ixStatusInactive;
                handlingunit.UserName = UserName;
                _handlingunitsService.Edit(handlingunit);
            }
                                        );

            //Now we set the statuses to complete
            var outboundcarriermanifest = _outboundcarriermanifestsService.GetPost(ixOutboundCarrierManifest);

            outboundcarriermanifest.ixStatus = ixStatusComplete;
            outboundcarriermanifest.UserName = UserName;
            _outboundcarriermanifestsService.Edit(outboundcarriermanifest);

            outboundshipments.ForEach(x =>
            {
                var outboundshipment      = _outboundshipmentsService.GetPost(x);
                outboundshipment.ixStatus = ixStatusComplete;
                outboundshipment.UserName = UserName;
                _outboundshipmentsService.Edit(outboundshipment);
            }
                                      );

            outboundorders.ForEach(x =>
            {
                var outboundorder      = _outboundordersRepository.GetPost(x);
                outboundorder.ixStatus = ixStatusComplete;
                outboundorder.UserName = UserName;
                _outboundordersRepository.RegisterEdit(outboundorder);
                _outboundordersRepository.Commit();
            }
                                   );

            outboundorderlines
            .Join(outboundorderlinesshipped, ol => ol, ols => ols.ixOutboundOrderLine, (ol, ols) => new { OL = ol, Ols = ols })
            .Select(o => new { ixOutboundOrderLine = o.Ols.ixOutboundOrderLine, nBaseUnitQuantityPacked = o.Ols.nBaseUnitQuantityPacked }).ToList()
            .ForEach(x =>
            {
                var outboundorderline = _outboundorderlinesService.GetPost(x.ixOutboundOrderLine);
                outboundorderline.nBaseUnitQuantityShipped += x.nBaseUnitQuantityPacked;
                outboundorderline.ixStatus = ixStatusComplete;
                outboundorderline.UserName = UserName;
                _outboundorderlinesService.Edit(outboundorderline);
            }
                     );

            outboundorderlinesinventoryallocation.ForEach(x =>
            {
                var outboundorderlineinventoryallocation      = _outboundorderlinesinventoryallocationService.GetPost(x);
                outboundorderlineinventoryallocation.ixStatus = ixStatusComplete;
                outboundorderlineinventoryallocation.UserName = UserName;
                _outboundorderlinesinventoryallocationService.Edit(outboundorderlineinventoryallocation);
            }
                                                          );

            outboundorderlinepacking.ForEach(x =>
            {
                var outboundorderlinepack      = _outboundorderlinepackingService.GetPost(x);
                outboundorderlinepack.ixStatus = ixStatusComplete;
                outboundorderlinepack.UserName = UserName;
                _outboundorderlinepackingService.Edit(outboundorderlinepack);
            }
                                             );
        }