Example #1
0
        private InventoryTransferDto GetInventoryTransfer4()
        {
            InventoryTransferDto dto = new InventoryTransferDto();

            dto.Date    = DateTime.Now;
            dto.Summary = "Test Inventory Transfer CRUD with decimal quantities";
            dto.Notes   = "Inventory Transfer from API";
            dto.Tags    = "IT, Test";

            InventoryTransferItemDto item = new InventoryTransferItemDto();

            item.Quantity          = -2.5M;
            item.InventoryItemUid  = this.Cat5Cable.Uid;
            item.UnitPriceExclTax  = 50.00M;
            item.TotalPriceExclTax = -125.00M;
            dto.Items.Add(item);

            item                   = new InventoryTransferItemDto();
            item.Quantity          = 1;
            item.InventoryItemUid  = this.HardDisk.Uid;
            item.UnitPriceExclTax  = 125.00M;
            item.TotalPriceExclTax = 125.00M;
            dto.Items.Add(item);

            return(dto);
        }
Example #2
0
        private void AssertExistsAndRemove
        (
            InventoryTransferItemDto expectedItem,
            ArrayList actualItems
        )
        {
            int count = actualItems.Count;

            for (int i = 0; i < count; i++)
            {
                InventoryTransferItemDto actualItem = (InventoryTransferItemDto)actualItems[i];

                if (
                    actualItem.Quantity == expectedItem.Quantity &&
                    actualItem.InventoryItemUid == expectedItem.InventoryItemUid &&
                    actualItem.UnitPriceExclTax == expectedItem.UnitPriceExclTax &&
                    actualItem.TotalPriceExclTax == expectedItem.TotalPriceExclTax
                    )
                {
                    actualItems.RemoveAt(i);
                    return;
                }
                Assert.IsTrue(false, "Unable to find the expected inventory adjustment item in the collection.");
            }
        }
Example #3
0
        private InventoryTransferDto GetInventoryTransfer1()
        {
            InventoryTransferDto dto = new InventoryTransferDto();

            dto.Date    = DateTime.Now;
            dto.Summary = "Test Inventory Transfer CRUD";
            dto.Notes   = "Inventory Transfer from API";
            dto.Tags    = "IT, Test";

            InventoryTransferItemDto item = new InventoryTransferItemDto();

            item.Quantity          = -2;
            item.InventoryItemUid  = this.HardDisk.Uid;
            item.UnitPriceExclTax  = 120.50M;
            item.TotalPriceExclTax = -241.00M;
            dto.Items.Add(item);

            item                   = new InventoryTransferItemDto();
            item.Quantity          = 1;
            item.InventoryItemUid  = this.AsusLaptop.Uid;
            item.UnitPriceExclTax  = 241.00M;
            item.TotalPriceExclTax = 241.00M;
            dto.Items.Add(item);

            return(dto);
        }
        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);
            }
        }