Ejemplo n.º 1
0
        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)");
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public void TestAverageCostIsReturnedForInventoryItem()
        {
            CrudProxy proxy             = new InventoryAdjustmentProxy();
            InventoryAdjustmentDto dto1 = this.GetInventoryAdjustment();

            proxy.Insert(dto1);

            Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save.");

            proxy = new InventoryItemProxy();
            InventoryItemDto itemDto = (InventoryItemDto)proxy.GetByUid(HardDisk.Uid);

            Assert.IsTrue(itemDto.AverageCost == 200.50M);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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.");
        }
Ejemplo n.º 8
0
        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.");
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
        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 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);
            }
        }