public static void AssertEqual(InventoryItemDto expected, InventoryItemDto actual)
 {
     Assert.AreEqual(expected.Code, actual.Code, "Incorrect Code.");
     Assert.AreEqual(expected.Description, actual.Description, "Incorrect description.");
     Assert.AreEqual(expected.Notes, actual.Notes, "Incorrect Notes.");
     Assert.AreEqual(expected.IsActive, actual.IsActive, "Incorrect IsActive.");
     Assert.AreEqual(expected.MinimumStockLevel, actual.MinimumStockLevel, "Incorrect MinimumStockLevel");
     Assert.AreEqual(expected.StockOnHand, actual.StockOnHand, "Incorrect StockOnHand");
     Assert.AreEqual(expected.IsInventoried, actual.IsInventoried, "Incorrect IsInventoried.");
     Assert.AreEqual(expected.AssetAccountUid, actual.AssetAccountUid, "Incorrect AssetAccountUid.");
     Assert.AreEqual(expected.IsSold, actual.IsSold, "Incorrect IsSold.");
     Assert.AreEqual(expected.SaleIncomeAccountUid, actual.SaleIncomeAccountUid, "Incorrect SaleIncomeAccountUid.");
     Assert.AreEqual(expected.SaleTaxCode, actual.SaleTaxCode, "Incorrect SaleTaxCode.");
     Assert.AreEqual(expected.SaleCoSAccountUid, actual.SaleCoSAccountUid, "Incorrect SaleCoSAccountUid.");
     Assert.AreEqual(expected.RrpInclTax, actual.RrpInclTax, "Incorrect RrpInclTax.");
     Assert.AreEqual(expected.IsBought, actual.IsBought, "Incorrect IsBought.");
     Assert.AreEqual(expected.PurchaseExpenseAccountUid, actual.PurchaseExpenseAccountUid, "Incorrect PurchaseExpenseAccountUid.");
     Assert.AreEqual(expected.PurchaseTaxCode, actual.PurchaseTaxCode, "Incorrect PurchaseTaxType.");
     Assert.AreEqual(expected.PrimarySupplierContactUid, actual.PrimarySupplierContactUid, "Incorrect PrimarySupplierContactUid.");
     Assert.AreEqual(expected.PrimarySupplierItemCode, actual.PrimarySupplierItemCode, "Incorrect PrimarySupplierItemCode.");
     Assert.AreEqual(expected.DefaultReOrderQuantity, actual.DefaultReOrderQuantity, "Incorrect DefaultReOrderQuantity.");
     Assert.AreEqual(expected.BuyingPrice, actual.BuyingPrice, "Incorrect BuyingPrice");
     Assert.AreEqual(expected.IsBuyingPriceIncTax, actual.IsBuyingPriceIncTax, "Incorrect IsBuyingPriceIncTax.");
     Assert.AreEqual(expected.IsVoucher, actual.IsVoucher, "Incorrect IsVoucher.");
     Assert.AreEqual(expected.ValidFrom, actual.ValidFrom, "Incorrect ValidFrom.");
     Assert.AreEqual(expected.ValidTo, actual.ValidTo, "Incorrect ValidTo.");
 }
        public void GetByCode()
        {
            string code1 =  Guid.NewGuid().ToString().Substring(0, 10);
            string code2 = code1 + "foo";
            InventoryItemProxy proxy = new InventoryItemProxy();

            InventoryItemDto dto = new InventoryItemDto();
            dto.Code = code1;
            dto.Description = "New Inventory Item";
            proxy.Insert(dto);

            dto = new InventoryItemDto();
            dto.Code = code2;
            dto.Description = "New Inventory Item";
            proxy.Insert(dto);

            List<InventoryItemDto> list = proxy.FindList<InventoryItemDto>(InventoryItemProxy.ResponseXPath,
                                                                          "CodeBeginsWith", code1);
            Assert.AreEqual(2, list.Count, string.Format("Incorrect number of items returned for code {0}",code1));
        }
        public void GetByUtcLastModified()
        {
            string code1 = Guid.NewGuid().ToString().Substring(0, 10);
            string code2 = code1 + "foo";
            InventoryItemProxy proxy = new InventoryItemProxy();

            Thread.Sleep(10000); //Wait for ten seconds. Avoid retreiving items from text fixture setup.

            InventoryItemDto dto = new InventoryItemDto();
            dto.Code = code1;
            dto.Description = "New Inventory Item";
            proxy.Insert(dto);

            DateTime lastModifiedFrom = ((InventoryItemDto)proxy.GetByUid(dto.Uid)).UtcLastModified;
            Thread.Sleep(10000); //Wait for ten seconds.

            dto = new InventoryItemDto();
            dto.Code = code2;
            dto.Description = "New Inventory Item";
            proxy.Insert(dto);

            DateTime lastModifiedTo = ((InventoryItemDto)proxy.GetByUid(dto.Uid)).UtcLastModified.AddSeconds(1);

            System.Console.WriteLine("Utc last modified: {0}", lastModifiedFrom.ToString());

            string utcFrom = SqlStrPrep.ToDateTime(lastModifiedFrom).ToString();
            string utcTo   = SqlStrPrep.ToDateTime(lastModifiedTo).ToString();

            utcFrom = utcFrom.Replace('/', '-');
            utcFrom = utcFrom.Replace(' ', 'T');

            utcTo = utcTo.Replace('/', '-');
            utcTo = utcTo.Replace(' ', 'T');

            List<InventoryItemDto> list = proxy.FindList<InventoryItemDto>(InventoryItemProxy.ResponseXPath,
                                                                           "UtcLastModifiedFrom", utcFrom, "UtcLastModifiedTo", utcTo);
            Assert.AreEqual(2, list.Count, string.Format("Incorrect number of items returned for UtcLastModifiedFrom {0} and UtcLastModifiedTo{1}", utcFrom, utcTo));
        }
        private void SetupInventoryItems()
        {
            CrudProxy inventoryItem = new InventoryItemProxy();

            string guid = Guid.NewGuid().ToString().Remove(0, 20);

            this.AsusLaptop = new InventoryItemDto();
            this.AsusLaptop.Code = "ASUS-" + guid;
            this.AsusLaptop.Description = "Asus Laptop";
            this.AsusLaptop.IsInventoried = true;
            this.AsusLaptop.AssetAccountUid = this.AssetInventory.Uid;
            this.AsusLaptop.IsBought = true;
            this.AsusLaptop.PurchaseTaxCode = TaxCode.ExpInclGst;
            this.AsusLaptop.IsSold = true;
            this.AsusLaptop.SaleIncomeAccountUid = this.IncomeHardwareSales.Uid;
            this.AsusLaptop.SaleTaxCode = TaxCode.SaleInclGst;
            this.AsusLaptop.RrpInclTax = 1111.11M;
            this.AsusLaptop.SaleCoSAccountUid = this.CoSHardware.Uid;
            inventoryItem.Insert(this.AsusLaptop);

            this.Cat5Cable = new InventoryItemDto();
            this.Cat5Cable.Code = "Cat5-" + guid;
            this.Cat5Cable.Description = "Cat 5 Cable (in meter)";
            this.Cat5Cable.IsInventoried = true;
            this.Cat5Cable.AssetAccountUid = this.AssetInventory.Uid;
            this.Cat5Cable.IsBought = true;
            this.Cat5Cable.PurchaseTaxCode = TaxCode.ExpInclGst;
            this.Cat5Cable.IsSold = true;
            this.Cat5Cable.SaleIncomeAccountUid = this.IncomeHardwareSales.Uid;
            this.Cat5Cable.SaleTaxCode = TaxCode.SaleInclGst;
            this.Cat5Cable.RrpInclTax = 2.55M;
            this.Cat5Cable.SaleCoSAccountUid = this.CoSHardware.Uid;
            inventoryItem.Insert(this.Cat5Cable);

            this.HardDisk = new InventoryItemDto();
            this.HardDisk.Code = "Seagate-" + guid;
            this.HardDisk.Description = "Seagate HDD - 300G";
            this.HardDisk.IsInventoried = true;
            this.HardDisk.AssetAccountUid = this.AssetInventory.Uid;
            this.HardDisk.IsBought = true;
            this.HardDisk.PurchaseTaxCode = TaxCode.ExpInclGst;
            this.HardDisk.IsSold = true;
            this.HardDisk.SaleIncomeAccountUid = this.IncomeHardwareSales.Uid;
            this.HardDisk.SaleTaxCode = TaxCode.SaleInclGst;
            this.HardDisk.RrpInclTax = 110.95M;
            this.HardDisk.SaleCoSAccountUid = this.CoSHardware.Uid;
            inventoryItem.Insert(this.HardDisk);

            this.Shipping1 = new InventoryItemDto();
            this.Shipping1.Code = "Shipping1-" + guid;
            this.Shipping1.Description = "Shipping - 1";
            this.Shipping1.IsBought = true;
            this.Shipping1.PurchaseExpenseAccountUid = this.ExpenseMisc.Uid;
            this.Shipping1.PurchaseTaxCode = TaxCode.ExpInclGst;
            this.Shipping1.IsSold = true;
            this.Shipping1.SaleIncomeAccountUid = this.IncomeShipping.Uid;
            this.Shipping1.SaleTaxCode = TaxCode.SaleInclGst;
            this.Shipping1.RrpInclTax = 59.95M;
            inventoryItem.Insert(this.Shipping1);
        }
Esempio n. 5
0
        private void CreateTestInventoryItems()
        {
            var proxy = new InventoryItemProxy();

            //sale items.
            if (_InventorySaleItemId == 0)
            {
                var dto = new InventoryItemDto
                {
                    AssetAccountUid = _AssetAccountId,
                    AverageCost = new decimal(5.00),
                    BuyingPrice = new decimal(4.00),
                    Code = string.Format("Inv{0}", Guid.NewGuid().ToString().Substring(0, 20)),
                    CurrentValue = new decimal(6.00),
                    DefaultReOrderQuantity = 2,
                    Description = "Test inventory sale item",
                    IsActive = true,
                    IsBought = false,
                    IsBuyingPriceIncTax = false,
                    IsSold = true,
                    SaleIncomeAccountUid = _IncomeAccountId
                };

                proxy.Insert(dto);
                _InventorySaleItemId = dto.Uid;
            }

            if (_InventorySaleItemId2 == 0)
            {
                var dto = new InventoryItemDto
                {
                    AssetAccountUid = _AssetAccountId,
                    AverageCost = new decimal(25.00),
                    BuyingPrice = new decimal(40.00),
                    Code = string.Format("Inv{0}", Guid.NewGuid().ToString().Substring(0, 20)),
                    CurrentValue = new decimal(16.00),
                    DefaultReOrderQuantity = 20,
                    Description = "updated Test inventory sale item",
                    IsActive = true,
                    IsBought = false,
                    IsBuyingPriceIncTax = false,
                    IsSold = true,
                    SaleIncomeAccountUid = _IncomeAccountId2
                };

                proxy.Insert(dto);
                _InventorySaleItemId2 = dto.Uid;
            }

            //purchase items.
            if (_InventoryPurchaseItemId == 0)
            {
                var dto = new InventoryItemDto
                {
                    AssetAccountUid = _AssetAccountId,
                    AverageCost = new decimal(5.00),
                    BuyingPrice = new decimal(4.00),
                    Code = string.Format("Inv{0}", Guid.NewGuid().ToString().Substring(0, 20)),
                    CurrentValue = new decimal(6.00),
                    DefaultReOrderQuantity = 2,
                    Description = "Test inventory purchase item",
                    IsActive = true,
                    IsBought = true,
                    IsBuyingPriceIncTax = true,
                    PurchaseExpenseAccountUid = _ExpenseAccountId
                };

                proxy.Insert(dto);
                _InventoryPurchaseItemId = dto.Uid;
            }

            if (_InventoryPurchaseItemId2 == 0)
            {
                var dto = new InventoryItemDto
                {
                    AssetAccountUid = _AssetAccountId,
                    AverageCost = new decimal(50.00),
                    BuyingPrice = new decimal(40.00),
                    Code = string.Format("Inv{0}", Guid.NewGuid().ToString().Substring(0, 20)),
                    CurrentValue = new decimal(60.00),
                    DefaultReOrderQuantity = 20,
                    Description = "Updated test inventory purchase item",
                    IsActive = true,
                    IsBought = true,
                    IsBuyingPriceIncTax = true,
                    PurchaseExpenseAccountUid = _ExpenseAccountId2
                };

                proxy.Insert(dto);
                _InventoryPurchaseItemId2 = dto.Uid;
            }
        }
        private InvoiceDto GetSaleOrder(InventoryItemDto itemDto)
        {
            InvoiceDto dto = new InvoiceDto(TransactionType.Sale, InvoiceLayout.Item);

            dto.Date = DateTime.Parse("6-Oct-05");
            dto.ContactUid = this.MrSmith.Uid;
            dto.Summary = "Test Insert Item Sale";
            dto.Notes = "From REST";
            dto.DueOrExpiryDate = DateTime.Parse("6-Nov-05");
            dto.Layout = InvoiceLayout.Item;
            dto.Status = InvoiceStatus.Order;
            dto.InvoiceNumber = "<Auto Number>";
            dto.PurchaseOrderNumber = "PO333";

            ItemInvoiceItemDto item = null;

            item = new ItemInvoiceItemDto();
            item.Quantity = 5;
            item.InventoryItemUid = itemDto.Uid;
            item.Description = "Asus Laptop";
            item.TaxCode = TaxCode.SaleInclGst;
            item.UnitPriceInclTax = 1200.75M;
            item.PercentageDiscount = 12.50M;

            dto.Items.Add(item);

            return dto;
        }
        private InventoryItemDto GetInventoryItem()
        {
            string code = "CODE_" + System.Guid.NewGuid().ToString().Remove(0, 10);

            InventoryItemDto info	= new InventoryItemDto();
            info.Code				= code;
            info.Description		= "Description for " + code;
            info.Notes				= "Notes for " + code;
            info.IsActive			= true;
            info.MinimumStockLevel	= 99;

            info.IsInventoried		= true;
            info.AssetAccountUid	= this.AssetInventory.Uid;

            info.IsSold					= true;
            info.SaleIncomeAccountUid	= this.IncomeHardwareSales.Uid;
            info.SaleTaxCode			= TaxCode.SaleInclGst;
            info.SaleCoSAccountUid		= this.CoSHardware.Uid;
            info.RrpInclTax				= 19.95M;

            info.IsBought							= true;
            info.PurchaseTaxCode					= TaxCode.ExpInclGst;
            info.PrimarySupplierContactUid			= this.MrsSmith.Uid;
            info.PrimarySupplierItemCode			= "S_CODE";
            info.DefaultReOrderQuantity	= 20;

            return info;
        }
 private void SetupInventoryItems()
 {
     this.Item1 = this.GetItem1();
     CrudProxy proxy = new InventoryItemProxy();
     proxy.Insert(this.Item1);
     Assert.IsTrue(this.Item1.Uid > 0, "Uid must be > 0 after save.");
 }
        private InventoryItemDto GetItem1()
        {
            string code = "CODE_" + System.Guid.NewGuid().ToString().Remove(0, 10);

            InventoryItemDto info = new InventoryItemDto();
            info.Code = code;
            info.Description = "BOOKING FOR STUFF";
            info.IsActive = true;

            info.IsSold = true;
            info.SaleIncomeAccountUid = this.IncomeSubscription.Uid;
            info.SaleTaxCode = TaxCode.SaleInclGst;
            info.RrpInclTax = 1500M;

            return info;
        }