Exemplo n.º 1
0
        internal static void AssertEqual(this InventoryAdjustmentItem inventoryAdjustmentItem, IInventoryAdjustmentItemReturn inventoryAdjustmentItemReturn, List <dynamic> derivedLots = null)
        {
            if (inventoryAdjustmentItem == null)
            {
                throw new ArgumentNullException("inventoryAdjustmentItem");
            }
            if (inventoryAdjustmentItemReturn == null)
            {
                throw new ArgumentNullException("inventoryAdjustmentItemReturn");
            }

            Assert.AreEqual(new InventoryAdjustmentItemKey(inventoryAdjustmentItem).KeyValue, inventoryAdjustmentItemReturn.InventoryAdjustmentItemKey);
            Assert.AreEqual(inventoryAdjustmentItem.QuantityAdjustment, inventoryAdjustmentItemReturn.AdjustmentQuantity);

            var lotKey = new LotKey(inventoryAdjustmentItem);

            Assert.AreEqual(lotKey.KeyValue, inventoryAdjustmentItemReturn.LotKey);
            Assert.AreEqual(inventoryAdjustmentItem.ToteKey, inventoryAdjustmentItemReturn.ToteKey);

            inventoryAdjustmentItem.Location.AssertEqual(inventoryAdjustmentItemReturn.Location);
            inventoryAdjustmentItem.PackagingProduct.AssertEqual(inventoryAdjustmentItemReturn.PackagingProduct);
            inventoryAdjustmentItem.Treatment.AssertEqual(inventoryAdjustmentItemReturn.InventoryTreatment);

            if (inventoryAdjustmentItem.Lot.ChileLot != null)
            {
                inventoryAdjustmentItem.Lot.ChileLot.ChileProduct.AssertEqual(inventoryAdjustmentItemReturn.InventoryProduct);
            }
            else if (inventoryAdjustmentItem.Lot.AdditiveLot != null)
            {
                inventoryAdjustmentItem.Lot.AdditiveLot.AdditiveProduct.AssertEqual(inventoryAdjustmentItemReturn.InventoryProduct);
            }
            else if (inventoryAdjustmentItem.Lot.PackagingLot != null)
            {
                inventoryAdjustmentItem.Lot.PackagingLot.PackagingProduct.AssertEqual(inventoryAdjustmentItemReturn.InventoryProduct);
            }
            else
            {
                Assert.IsNull(inventoryAdjustmentItemReturn.InventoryProduct);
            }
        }
Exemplo n.º 2
0
        internal static InventoryAdjustmentItem ConstrainByKeys(this InventoryAdjustmentItem item, IInventoryAdjustmentKey adjustmentKey, ILotKey lotKey = null)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (adjustmentKey != null)
            {
                item.InventoryAdjustment = null;
                item.AdjustmentDate      = adjustmentKey.InventoryAdjustmentKey_AdjustmentDate;
                item.Sequence            = adjustmentKey.InventoryAdjustmentKey_Sequence;
            }

            if (lotKey != null)
            {
                item.Lot             = null;
                item.LotDateCreated  = lotKey.LotKey_DateCreated;
                item.LotDateSequence = lotKey.LotKey_DateSequence;
                item.LotTypeId       = lotKey.LotKey_LotTypeId;
            }

            return(item);
        }
        private IEnumerable <InventoryAdjustmentItem> GetAdjustmentItems(InventoryAdjustment newAdjustment, IEnumerable <OutgoingDTO> outgoings)
        {
            var adjustmentSequence = 1;

            foreach (var outgoing in outgoings)
            {
                _loadCount.AddRead(EntityTypes.InventoryAdjustmentItem);

                LotKey lotKey;
                if (!LotNumberParser.ParseLotNumber(outgoing.Lot, out lotKey))
                {
                    Log(new CallbackParameters(CallbackReason.InvalidLotNumber)
                    {
                        Outgoing = outgoing
                    });
                    continue;
                }

                if (!_newContextHelper.LotLoaded(lotKey))
                {
                    Log(new CallbackParameters(CallbackReason.LotNotLoaded)
                    {
                        Outgoing = outgoing
                    });
                    continue;
                }

                var packagingProduct = _newContextHelper.GetPackagingProduct(outgoing.PkgID);
                if (packagingProduct == null)
                {
                    Log(new CallbackParameters(CallbackReason.PackagingNotLoaded)
                    {
                        Outgoing = outgoing
                    });
                    continue;
                }

                var warehouseLocation = _newContextHelper.GetLocation(outgoing.LocID);
                if (warehouseLocation == null)
                {
                    Log(new CallbackParameters(CallbackReason.WarehouseLocationNotLoaded)
                    {
                        Outgoing = outgoing
                    });
                    continue;
                }

                var inventoryTreatment = _newContextHelper.GetInventoryTreatment(outgoing.TrtmtID);
                if (inventoryTreatment == null)
                {
                    Log(new CallbackParameters(CallbackReason.TreatmentNotLoaded)
                    {
                        Outgoing = outgoing
                    });
                    continue;
                }

                var adjustmentItem = new InventoryAdjustmentItem
                {
                    AdjustmentDate = newAdjustment.AdjustmentDate,
                    Sequence       = newAdjustment.Sequence,
                    ItemSequence   = adjustmentSequence++,

                    TimeStamp  = newAdjustment.TimeStamp,
                    EmployeeId = newAdjustment.EmployeeId,

                    QuantityAdjustment = (int)-outgoing.Quantity,
                    LotDateCreated     = lotKey.LotKey_DateCreated,
                    LotDateSequence    = lotKey.LotKey_DateSequence,
                    LotTypeId          = lotKey.LotKey_LotTypeId,
                    PackagingProductId = packagingProduct.Id,
                    LocationId         = warehouseLocation.Id,
                    TreatmentId        = inventoryTreatment.Id,
                    ToteKey            = outgoing.Tote ?? " "
                };

                yield return(adjustmentItem);
            }
        }