Exemplo n.º 1
0
        internal static LotProductionResultItem SetToInventory(this LotProductionResultItem item, IInventoryKey inventoryKey)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (inventoryKey == null)
            {
                throw new ArgumentNullException("inventoryKey");
            }

            item.ProductionResults = null;
            item.LotDateCreated    = inventoryKey.LotKey_DateCreated;
            item.LotDateSequence   = inventoryKey.LotKey_DateSequence;
            item.LotTypeId         = inventoryKey.LotKey_LotTypeId;

            item.Location   = null;
            item.LocationId = inventoryKey.LocationKey_Id;

            item.PackagingProduct   = null;
            item.PackagingProductId = inventoryKey.PackagingProductKey_ProductId;

            item.Treatment   = null;
            item.TreatmentId = inventoryKey.InventoryTreatmentKey_Id;

            return(item);
        }
        public IEnumerable <ProductionResultItemResult> CreateNewProductionResultItems(ILotKey lotKey, ProductionBatchEntityObjectMother.tblLotResultDTO outputLot)
        {
            var sequence          = 1;
            var productionResults = outputLot.tblIncomings.Where(i => i.TTypeID == (int?)TransType.Production).ToList();

            foreach (var item in productionResults)
            {
                var result = CreateNewProductionResultItemResult.Success;
                LotProductionResultItem resultItem = null;

                var packagingProduct = _newContextHelper.GetPackagingProduct(item.PkgID);
                if (packagingProduct == null)
                {
                    result = CreateNewProductionResultItemResult.PackagingProductNotFound;
                    goto result;
                }

                var warehouseLocation = _newContextHelper.GetLocation(item.LocID);
                if (warehouseLocation == null)
                {
                    result = CreateNewProductionResultItemResult.WarehouseLocationNotFound;
                    goto result;
                }

                var treatment = _newContextHelper.GetInventoryTreatment(item.TrtmtID);
                if (treatment == null)
                {
                    result = CreateNewProductionResultItemResult.InventoryTreatmentNotFound;
                    goto result;
                }

                resultItem = new LotProductionResultItem
                {
                    LotDateCreated     = lotKey.LotKey_DateCreated,
                    LotDateSequence    = lotKey.LotKey_DateSequence,
                    LotTypeId          = lotKey.LotKey_LotTypeId,
                    ResultItemSequence = sequence++,

                    PackagingProductId = packagingProduct.Id,
                    LocationId         = warehouseLocation.Id,
                    TreatmentId        = treatment.Id,
                    Quantity           = (int)(item.Quantity ?? 0)
                };

result:
                yield return(new ProductionResultItemResult
                {
                    Result = result,
                    Source = item,
                    ResultItem = resultItem
                });
            }
        }
Exemplo n.º 3
0
        internal static void AssertEqual(this LotProductionResultItem item, IProductionResultItemReturn itemReturn)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (itemReturn == null)
            {
                throw new ArgumentNullException("itemReturn");
            }

            Assert.AreEqual(new LotProductionResultItemKey(item).KeyValue, itemReturn.ProductionResultItemKey);
            Assert.AreEqual(item.Quantity, itemReturn.Quantity);
            item.PackagingProduct.AssertEqual(itemReturn.PackagingProduct);
            item.Location.AssertEqual(itemReturn.Location);
            item.Treatment.AssertEqual(itemReturn.Treatment);
        }
Exemplo n.º 4
0
        internal static LotProductionResultItem ConstrainByKeys(this LotProductionResultItem item, ILotKey lotKey, IPackagingProductKey packagingProductKey = null)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            item.ProductionResults = null;
            item.LotDateCreated    = lotKey.LotKey_DateCreated;
            item.LotDateSequence   = lotKey.LotKey_DateSequence;
            item.LotTypeId         = lotKey.LotKey_LotTypeId;

            if (packagingProductKey != null)
            {
                item.PackagingProduct   = null;
                item.PackagingProductId = packagingProductKey.PackagingProductKey_ProductId;
            }

            return(item);
        }
        private tblIncoming CreateIncoming(LotProductionResultItem resultItem)
        {
            var entryDate = resultItem.ProductionResults.DateTimeEntered.ConvertUTCToLocal().RoundMillisecondsForSQL();
            var packaging = _oldContextHelper.GetPackaging(resultItem.PackagingProduct);
            var location  = _oldContextHelper.GetLocation(resultItem.Location);

            return(new tblIncoming
            {
                EntryDate = entryDate,
                Lot = LotNumberBuilder.BuildLotNumber(resultItem),
                TTypeID = (int?)TransType.Production,
                PkgID = packaging.PkgID,
                VarietyID = 0,
                Quantity = resultItem.Quantity,
                NetWgt = packaging.NetWgt,
                TtlWgt = packaging.NetWgt * resultItem.Quantity,
                LocID = location.LocID,
                TrtmtID = resultItem.TreatmentId,
                EmployeeID = resultItem.ProductionResults.EmployeeId
            });
        }