public void GetByDescription() { string code1 = Guid.NewGuid().ToString().Substring(0, 10); string code2 = Guid.NewGuid().ToString().Substring(0, 10); string description1 = Guid.NewGuid().ToString().Substring(0, 20); string description2 = description1 + "bar"; InventoryItemProxy proxy = new InventoryItemProxy(); InventoryItemDto dto = new InventoryItemDto(); dto.Code = code1; dto.Description = description1; proxy.Insert(dto); dto = new InventoryItemDto(); dto.Code = code2; dto.Description = description2; proxy.Insert(dto); List <InventoryItemDto> list = proxy.FindList <InventoryItemDto>(InventoryItemProxy.ResponseXPath, "DescriptionBeginsWith", description1); Assert.AreEqual(2, list.Count, string.Format("Incorrect number of items returned for code {0}", description1)); }
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); }
public void CheckQuantityOnOrderAndQuantityCommitted() { CrudProxy proxy = new InventoryItemProxy(); InventoryItemDto dto1 = this.GetInventoryItem(); dto1.RrpInclTax = 7.75M; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto saleOrder = this.GetSaleOrder(dto1); CrudProxy invoice = new InvoiceProxy(); invoice.Insert(saleOrder); dto1 = (InventoryItemDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual(5, dto1.QuantityCommitted, "Incorrect # of stocks committed (used by sale orders)"); InvoiceDto po = this.GetPurchaseOrder(dto1); po.PurchaseOrderNumber = "<Auto Number>"; invoice.Insert(po); dto1 = (InventoryItemDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual(5, dto1.QuantityCommitted, "Incorrect # of stocks committed (used by sale orders)"); dto1 = (InventoryItemDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual(20, dto1.QuantityOnOrder, "Incorrect # of stocks on order(used by purchase orders)"); }
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."); }
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)); }
public void InsertAndGet() { CrudProxy proxy = new InventoryItemProxy(); InventoryItemDto dto1 = this.GetInventoryItem(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InventoryItemDto dto2 = (InventoryItemDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void InsertWithDefaultBuyingPrice() { CrudProxy proxy = new InventoryItemProxy(); InventoryItemDto dto1 = this.GetInventoryItem(); dto1.BuyingPrice = 250M; dto1.IsBuyingPriceIncTax = true; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InventoryItemDto dto2 = (InventoryItemDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void InsertVirtualItem() { CrudProxy proxy = new InventoryItemProxy(); InventoryItemDto dto1 = this.GetInventoryItem(); dto1.IsVirtual = true; dto1.VType = "Plan"; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InventoryItemDto dto2 = (InventoryItemDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void InsertUsingDeprecatedRrpInclTax() { CrudProxy proxy = new InventoryItemProxy(); InventoryItemDto dto1 = this.GetInventoryItem(); dto1.RrpInclTax = 7.75M; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InventoryItemDto dto2 = (InventoryItemDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual(7.75M, dto2.RrpInclTax, "Diff. rrp. incl. tax."); Assert.AreEqual(7.75M, dto2.SellingPrice, "Diff. selling price."); Assert.AreEqual(true, dto2.IsSellingPriceIncTax, "Is selling price exc tax should be true."); }
public void InsertSellPriceIncTax() { CrudProxy proxy = new InventoryItemProxy(); InventoryItemDto dto1 = this.GetInventoryItem(); dto1.SellingPrice = 7.75M; dto1.IsSellingPriceIncTax = true; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InventoryItemDto dto2 = (InventoryItemDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual(7.75M, dto1.SellingPrice, "Diff. selling price"); Assert.AreEqual(true, dto1.IsSellingPriceIncTax, "Is selling price exc tax should be true."); }
public void InsertVoucherItem() { CrudProxy proxy = new InventoryItemProxy(); InventoryItemDto dto1 = this.GetInventoryItem(); dto1.IsVoucher = true; dto1.ValidFrom = DateTime.Now.Date; dto1.ValidTo = dto1.ValidFrom.AddMonths(3); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InventoryItemDto dto2 = (InventoryItemDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void Delete() { CrudProxy proxy = new InventoryItemProxy(); InventoryItemDto dto1 = this.GetInventoryItem(); proxy.Insert(dto1); proxy.DeleteByUid(dto1.Uid); try { proxy.GetByUid(dto1.Uid); } catch (RestException ex) { Assert.AreEqual("RecordNotFoundException", ex.Type); } }
public void Update() { CrudProxy proxy = new InventoryItemProxy(); InventoryItemDto dto1 = this.GetInventoryItem(); proxy.Insert(dto1); string lastUpdatedUid = dto1.LastUpdatedUid; dto1.Description = this.TestUid + "For Test Update - Updated"; dto1.Notes = "Updated ...."; dto1.AssetAccountUid = this.AssetInventory2.Uid; dto1.SaleTaxCode = TaxCode.SaleExports; proxy.Update(dto1); Assert.IsTrue(dto1.LastUpdatedUid != lastUpdatedUid); InventoryItemDto dto2 = (InventoryItemDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void UpdateDeleted() { CrudProxy proxy = new InventoryItemProxy(); InventoryItemDto dto1 = this.GetInventoryItem(); proxy.Insert(dto1); proxy.DeleteByUid(dto1.Uid); dto1.Description = "Try updating deleted item"; try { proxy.Update(dto1); throw new Exception("Expected exception not thrown."); } catch (RestException rex) { if (!rex.Message.Contains("Unable to find inventory item uid")) { throw new Exception("Possibly incorrect error thrown."); } } }
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; } }