private void SetupComboItems() { string guid = Guid.NewGuid().ToString().Remove(0, 20); ComboItemProxy comboItem = new ComboItemProxy(); this.CPU = new ComboItemDto(); this.CPU.Code = "DESKTOP " + guid; this.CPU.Description = "Desktop PC"; this.CPU.IsInventoried = true; this.CPU.AssetAccountUid = this.AssetInventory.Uid; this.CPU.IsSold = true; this.CPU.SaleCoSAccountUid = this.CoSHardware.Uid; this.CPU.SaleIncomeAccountUid = this.IncomeHardwareSales.Uid; this.CPU.RrpInclTax = 575.00M; this.CPU.Items = new System.Collections.Generic.List <ComboItemLineItemDto>(); ComboItemLineItemDto lineItem = new ComboItemLineItemDto(); lineItem.Uid = this.HardDisk.Uid; lineItem.Code = this.HardDisk.Code; lineItem.Quantity = 1; this.CPU.Items.Add(lineItem); lineItem = new ComboItemLineItemDto(); lineItem.Uid = this.Cat5Cable.Uid; lineItem.Code = this.Cat5Cable.Code; lineItem.Quantity = 1; this.CPU.Items.Add(lineItem); comboItem.Insert(this.CPU); }
protected ComboItemDto GetComboItem02() { ComboItemDto comboItemDto = new ComboItemDto(); comboItemDto.Code = "C - " + System.Guid.NewGuid().ToString().Substring(0, 10); comboItemDto.Description = "Insert Combo Item Test"; comboItemDto.Items = new List <ComboItemLineItemDto>(); ComboItemLineItemDto lineItem = new ComboItemLineItemDto(); lineItem.Uid = this.Shipping1.Uid; lineItem.Code = this.Shipping1.Code; lineItem.Quantity = 1; comboItemDto.Items.Add(lineItem); lineItem = new ComboItemLineItemDto(); lineItem.Uid = this.AsusLaptop.Uid; lineItem.Code = this.AsusLaptop.Code; lineItem.Quantity = 1; comboItemDto.Items.Add(lineItem); comboItemDto.IsInventoried = true; comboItemDto.AssetAccountUid = this.AssetInventory.Uid; comboItemDto.IsSold = true; comboItemDto.SaleIncomeAccountUid = this.IncomeHardwareSales.Uid; comboItemDto.SaleCoSAccountUid = this.CoSHardware.Uid; comboItemDto.SaleTaxCode = "G1"; comboItemDto.SellingPrice = 350.00M; comboItemDto.RrpInclTax = 350.00M; return(comboItemDto); }
protected ComboItemDto GetComboItem01() { ComboItemDto comboItemDto = new ComboItemDto(); comboItemDto.Code = "C - " + System.Guid.NewGuid().ToString().Substring(0, 10); comboItemDto.Description = "Insert Combo Item Test"; comboItemDto.Items = new List <ComboItemLineItemDto>(); ComboItemLineItemDto lineItem = new ComboItemLineItemDto(); lineItem.Uid = this.AsusLaptop.Uid; lineItem.Code = this.AsusLaptop.Code; lineItem.Quantity = 1; comboItemDto.Items.Add(lineItem); lineItem = new ComboItemLineItemDto(); lineItem.Uid = this.Cat5Cable.Uid; lineItem.Code = this.Cat5Cable.Code; lineItem.Quantity = 1; comboItemDto.Items.Add(lineItem); comboItemDto.IsInventoried = true; comboItemDto.AssetAccountUid = this.AssetInventory.Uid; comboItemDto.IsSold = true; comboItemDto.SaleIncomeAccountUid = this.IncomeHardwareSales.Uid; comboItemDto.SaleCoSAccountUid = this.CoSHardware.Uid; comboItemDto.SaleTaxCode = "G1"; comboItemDto.SellingPrice = 350.00M; comboItemDto.RrpInclTax = 350.00M; comboItemDto.IsBought = true; comboItemDto.PurchaseTaxCode = "G10"; comboItemDto.PrimarySupplierContactUid = this.MrSmith.Uid; comboItemDto.BuyingPrice = 175.00M; comboItemDto.PrimarySupplierItemCode = "ITOP090"; comboItemDto.DefaultReOrderQuantity = 10; comboItemDto.IsVoucher = true; comboItemDto.ValidFrom = DateTime.Parse("28-May-2010"); comboItemDto.ValidTo = DateTime.Parse("28-Dec-2010"); comboItemDto.IsVirtual = true; comboItemDto.VType = "Virtual Voucher"; comboItemDto.Notes = "Combo item notes."; comboItemDto.IsVisible = true; return(comboItemDto); }
public void InsertWithComboItemAsItem() { ComboItemProxy proxy = new ComboItemProxy(); ComboItemDto comboItemDto = this.GetComboItem01(); ComboItemLineItemDto lineItemComboItem = new ComboItemLineItemDto(); lineItemComboItem.Uid = this.CPU.Uid; lineItemComboItem.Code = this.CPU.Code; lineItemComboItem.Quantity = 1; comboItemDto.Items.Add(lineItemComboItem); proxy.Insert(comboItemDto); ComboItemDto fromDB = (ComboItemDto)proxy.GetByUid(comboItemDto.Uid); this.AssertEqual(comboItemDto, fromDB); }
public void Update() { ComboItemDto comboItemDto = this.GetComboItem01(); ComboItemProxy proxy = new ComboItemProxy(); proxy.Insert(comboItemDto); ComboItemLineItemDto lineItemDto = new ComboItemLineItemDto(); lineItemDto.Uid = this.HardDisk.Uid; lineItemDto.Code = this.HardDisk.Code; lineItemDto.Quantity = 1; comboItemDto.Items.Add(lineItemDto); proxy.Update(comboItemDto); ComboItemDto fromDB = (ComboItemDto)proxy.GetByUid(comboItemDto.Uid); this.AssertEqual(comboItemDto, fromDB); }
public void InsertWithItemsFromDifferentFile() { ComboItemDto comboItemDto = this.GetComboItem01(); ComboItemProxy proxy = new ComboItemProxy(); ComboItemLineItemDto lineItem = new ComboItemLineItemDto(); lineItem.Uid = 14605; lineItem.Code = "100"; lineItem.Quantity = 2; comboItemDto.Items.Add(lineItem); try { proxy.Insert(comboItemDto); Assert.Fail("Expected exception not thrown."); } catch (RestException ex) { Assert.AreEqual("One or more line items of the Combo Item was not found. Please make sure correct items are selected for creating the Combo Item.", ex.Message.Substring(0, 128)); } }
public void BuildComboItem() { ComboItemProxy proxy = new ComboItemProxy(); ComboItemDto comboItemDto = this.GetComboItem01(); proxy.Insert(comboItemDto); ComboItemDto comboItem = (ComboItemDto)proxy.GetByUid(comboItemDto.Uid); // We need to insert stock first using a purchase CrudProxy invoiceProxy = new InvoiceProxy(); InvoiceDto dto = new InvoiceDto(TransactionType.Purchase, InvoiceLayout.Item); dto.Date = DateTime.Today.Date; dto.ContactUid = this.MrSmith.Uid; dto.Summary = "Add stock do we can build ComboItems"; dto.Notes = "From REST"; dto.DueOrExpiryDate = dto.Date.AddMonths(1); dto.Status = InvoiceStatus.Invoice; dto.InvoiceNumber = "I123"; dto.PurchaseOrderNumber = "<Auto Number>"; decimal unitsToBuild = 12.25M; foreach (ComboItemLineItemDto itemInCombo in comboItem.Items) { // "purchase" all the items that are part of this combo item so we have valid stock ItemInvoiceItemDto item = new ItemInvoiceItemDto(); item.Quantity = itemInCombo.Quantity * unitsToBuild; item.InventoryItemUid = itemInCombo.Uid; item.Description = "Purchasing: " + itemInCombo.Code; item.TaxCode = TaxCode.ExpInclGst; item.UnitPriceInclTax = 99.95M; dto.Items.Add(item); } invoiceProxy.Insert(dto); // Download stock info before InventoryItemProxy inventoryItemProxy = new InventoryItemProxy(); InventoryItemDto inventoryItem = (InventoryItemDto)inventoryItemProxy.GetByUid(comboItemDto.Uid); decimal stockOnHand = inventoryItem.StockOnHand; // Build the item! BuildComboItemResult result = proxy.Build(comboItemDto.Uid, unitsToBuild); Assert.AreNotEqual(0, result.Uid); Assert.IsNotNull(result.LastUpdatedUid); inventoryItem = (InventoryItemDto)inventoryItemProxy.GetByUid(comboItemDto.Uid); decimal newStockOnHand = inventoryItem.StockOnHand; Assert.AreEqual(stockOnHand + unitsToBuild, newStockOnHand, "We have one extra item in stock"); // Read Inventory Transfer details InventoryTransferProxy transferProxy = new InventoryTransferProxy(); InventoryTransferDto transfer = (InventoryTransferDto)transferProxy.GetByUid(result.Uid); Assert.AreEqual(comboItem.Items.Count + 1, transfer.Items.Count); // +1 as we have the combo item the first one // confirm first item is the combo with +1 InventoryTransferItemDto comboItemTransfer = (InventoryTransferItemDto)transfer.Items[0]; Assert.AreEqual(comboItemDto.Uid, comboItemTransfer.InventoryItemUid); Assert.AreEqual(unitsToBuild, comboItemTransfer.Quantity); for (int i = 0; i < comboItem.Items.Count; i++) { ComboItemLineItemDto line = comboItem.Items[i]; InventoryTransferItemDto item = (InventoryTransferItemDto)transfer.Items[i + 1]; Assert.AreEqual(line.Uid, item.InventoryItemUid); Assert.AreEqual(line.Quantity * unitsToBuild, -item.Quantity); } }