コード例 #1
0
 public Guid AddInventory(Inventory inventory)
 {
     ValidationResultInfo vri=Validate(inventory);
     if (!vri.IsValid)
     {
         
         throw new DomainValidationException(vri,"Failed to validate Inventory");
     }
     tblInventory tblInv = _ctx.tblInventory.FirstOrDefault(n => n.id == inventory.Id); ;
     DateTime dt = DateTime.Now;
     if (tblInv == null)
     {
         tblInv = new tblInventory();
         tblInv.id = inventory.Id;
         tblInv.IM_DateCreated = dt;
         tblInv.IM_Status = (int)EntityStatus.Active;// true;
         _ctx.tblInventory.AddObject(tblInv);
     }
     var entityStatus = (inventory._Status == EntityStatus.New) ? EntityStatus.Active : inventory._Status;
     if (tblInv.IM_Status != (int)entityStatus)
         tblInv.IM_Status = (int)inventory._Status;
     tblInv.IM_DateLastUpdated = dt;
     tblInv.ProductId = inventory.Product.Id;
     tblInv.WareHouseId = inventory.Warehouse.Id;
     tblInv.Balance = inventory.Balance;
     tblInv.UnavailableBalance = inventory.UnavailableBalance;
     tblInv.Value = inventory.Value;
     _ctx.SaveChanges();
     return tblInv.id;
 }
コード例 #2
0
 private void AssertInventory(Inventory infection, Inventory savedInfection)
 {
     Assert.AreEqual(infection.Warehouse, savedInfection.Warehouse);
     Assert.AreEqual(infection.Product, savedInfection.Product);
     Assert.AreEqual(infection.Balance, savedInfection.Balance);
     Assert.AreEqual(infection.Value, savedInfection.Value);
     Assert.AreEqual(infection._Status, savedInfection._Status);
 }
コード例 #3
0
ファイル: ProductTest.cs プロジェクト: asanyaga/BuildTest
        private void InsertProduct(string description, decimal inventoryBalance = 0)
        {
            var saleProduct = new SaleProduct(Guid.NewGuid());
            saleProduct.Description = description;

            var inventoryProduct = new Inventory(Guid.NewGuid());
            inventoryProduct.Balance = inventoryBalance;
            inventoryProduct.ProductMasterID = saleProduct.Id;

            Database.InsertWithChildren(saleProduct, recursive: true);
            Database.InsertWithChildren(inventoryProduct, recursive:true);
        }
コード例 #4
0
        void AddBasicProduct(Inventory inv)
        {
            InventorySummaryItem isi = new InventorySummaryItem
            {
                ProductId = inv.Product.Id,
                Description = inv.Product.Description,
                Product = inv.Product,
                Warehouse = inv.Warehouse,
                Qty = inv.Balance,
                IsConsolidatedProductChild = false,
                ProductType = GetProductType(inv.Product)

            };
            Items.Add(isi);
        }
コード例 #5
0
        public void InventoryAdjust(Guid costCentreId, Guid productId, decimal qty, DocumentType docType, Guid documentId, DateTime date, InventoryAdjustmentNoteType inventoryAdjustmentNoteType)
        {
           // _log.InfoFormat("Inventory Adjust costcentreid : {0} - productid : {1} - qty : {2} - doctype : {3} - docid : {4}", costCentreId, productId, qty, docType, documentId);
            try
            {
                Product p = _productRepository.GetById(productId);
                CostCentre cc = _costCentreRepository.GetById(costCentreId);
                if (!(cc is Warehouse))
                    throw new Exception("Can only have inventory in a cost centre that is a warehouse");
                //does inventory item exist for costcentre
                if (!_inventoryRepository.GetByProductId(productId).Any(n => n.Warehouse.Id == costCentreId))
                {
                    var inv = new Inventory(Guid.NewGuid())
                    {
                        Balance = 0,
                        Value = 0,
                        Product = p,
                        Warehouse = (Warehouse)cc
                    };
                    _inventoryRepository.AddInventory(inv);
                }

                Inventory inv1 = _inventoryRepository.GetByProductId(productId).First(n => n.Warehouse.Id == costCentreId);
                var it = new InventoryTransaction(Guid.NewGuid())
                {
                    DateInserted = DateTime.Now,
                    DocumentId = documentId,
                    DocumentType = docType,
                    Inventory = inv1,
                    NoItems = qty,

                };
                _inventoryTransactionRepository.Add(it);

                _inventoryRepository.AdjustInventoryBalance(inv1.Id, qty, (int)inventoryAdjustmentNoteType);

            }
            catch (Exception)
            {
                //_log.Error(ex);
            }
        }
コード例 #6
0
 void AddConsolidatedProduct(Inventory inv)
 {
     ConsolidatedProduct cp = inv.Product as ConsolidatedProduct;
     InventorySummaryItem isi = new InventorySummaryItem
     {
         ProductId = cp.Id,
         Description = cp.Description,
         ProductType = DomainProductType.Consolidated,
         Product = inv.Product,
         Warehouse = inv.Warehouse,
         Qty = inv.Balance,
         IsConsolidatedProductChild = false,
         HomeConsolidatedProductId = cp.Id,
         Level = 0,
         HomeConsolidatedProduct = cp,
         ParentConsolidatedProduct = null,
         QuantityPerConsolidatedProduct = 1,
         TotalProductsForHomeConsolidatedProduct = inv.Balance
     };
     Items.Add(isi);
     var fps = cp.GetFlattenedProducts();
     foreach (var fp in fps)
     {
         var isic = new InventorySummaryItem
         {
             ProductId = fp.Product.Id,
             Description = fp.Product.Description,
             ProductType = GetProductType(fp.Product),
             Warehouse = inv.Warehouse,
             IsConsolidatedProductChild = true,
             HomeConsolidatedProductId = cp.Id,
             Level = fp.Level,
             HomeConsolidatedProduct = cp,
             ParentConsolidatedProduct = fp.DirectParent,
             QuantityPerConsolidatedProduct = fp.QuantityPerConsolidatedProduct,
             TotalProductsForHomeConsolidatedProduct = fp.TotalProductsForHomeConsolidatedProduct,
             Qty = inv.Balance * fp.TotalProductsForHomeConsolidatedProduct
         };
         Items.Add(isic);
     }
 }
コード例 #7
0
 public InventoryDTO Map(Inventory inventory)
 {
     if (inventory == null) return null;
     return Mapper.Map<Inventory, InventoryDTO>(inventory);
 }
コード例 #8
0
        public List<InventoryTransaction> GetByWarehouse(Guid wareHouseId, Inventory inventory, DocumentType? documentType, DateTime startDate, DateTime endDate)
        {
            List<InventoryTransaction> qry = null;
            if (documentType == null)
            {
                qry = _ctx.tblInventoryTransaction.Where(n => n.tblInventory.WareHouseId == wareHouseId && n.tblInventory.id == inventory.Id
                                            && n.DateInserted >= startDate && n.IM_DateLastUpdated <= endDate).ToList().Select(n => Map(n)).ToList();
            }
            else
            {
                int docType = (int)documentType;
                qry = _ctx.tblInventoryTransaction.Where(n => n.tblInventory.WareHouseId == wareHouseId && n.tblInventory.id == inventory.Id
                                             && n.DateInserted >= startDate && n.IM_DateLastUpdated <= endDate).ToList().Select(n => Map(n)).ToList();
            }

            return qry;
        }
コード例 #9
0
        public List<InventoryTransaction> GetByWarehouse(Guid wareHouseId, Inventory inventory, DocumentType? documentType)
        {
            List<InventoryTransaction> qry = null;
            if (documentType == null)
            {
                qry = _ctx.tblInventoryTransaction
                    .Where(n => n.tblInventory.WareHouseId == wareHouseId && n.tblInventory.id == inventory.Id
                                            )
                                            .ToList().Select(n => Map(n)).ToList();
            }
            else
            {
                int docType = (int)documentType;
                qry = _ctx.tblInventoryTransaction
                    .Where(n => n.tblInventory.WareHouseId == wareHouseId && n.tblInventory.id == inventory.Id)
                                            .ToList().Select(n => Map(n)).ToList();
            }

            return qry;
        }
コード例 #10
0
 protected Guid AddInventory(Guid wareHouseId, decimal Val, int Bal, Guid ProductId)
 {
     Inventory inv = new Inventory(Guid.NewGuid())
     {
         Warehouse = _costCentreRepository.GetById(wareHouseId) as Warehouse,
         Value = Val,
         Balance = Bal,
         Product = _productRepository.GetById(ProductId)
     };
     inv._SetStatus(EntityStatus.Active);
     return _inventoryRepository.AddInventory(inv);
 }
コード例 #11
0
 public ValidationResultInfo Validate(Inventory itemToValidate)
 {
     ValidationResultInfo vri = itemToValidate.BasicValidation();
     if (itemToValidate._Status == EntityStatus.Inactive || itemToValidate._Status == EntityStatus.Deleted)
         return vri;
     if (itemToValidate.Id == Guid.Empty)
         vri.Results.Add(new ValidationResult("Enter Valid  Guid ID"));
     return vri;
 }
コード例 #12
0
 protected Inventory Map(tblInventory tblInv)
 {
     Inventory inv = new Inventory(tblInv.id)
                         {
                             Warehouse = _costCentreRepository.GetById(tblInv.tblCostCentre.Id) as Warehouse,
                             Product = _productRepository.GetById(tblInv.ProductId),
                             Balance = tblInv.Balance.Value,
                             Value = (decimal) tblInv.Value,
                             UnavailableBalance = tblInv.UnavailableBalance,
                         };
     return inv;
 }