示例#1
0
 private void AssertEqual(InventoryTransferDto expected, InventoryTransferDto actual)
 {
     foreach (InventoryTransferItemDto expectedItem in expected.Items)
     {
         this.AssertExistsAndRemove(expectedItem, actual.Items);
     }
 }
示例#2
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);
        }
示例#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);
        }
示例#4
0
        public void TestInsertAndGetByUidWithDecimalQuantity()
        {
            InventoryTransferProxy proxy = new InventoryTransferProxy();
            InventoryTransferDto   dto1  = this.GetInventoryTransfer4();

            proxy.Insert(dto1);

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

            InventoryTransferDto dto2 = (InventoryTransferDto)proxy.GetByUid(dto1.Uid);

            AssertEqual(dto1, dto2);
        }
示例#5
0
        public void TestInsertAndGetByUidDoNotBalance()
        {
            InventoryTransferProxy proxy = new InventoryTransferProxy();
            InventoryTransferDto   dto1  = this.GetInventoryTransfer3();

            try
            {
                proxy.Insert(dto1);
                throw new Exception("Expected exception not thrown.");
            }
            catch (RestException rex)
            {
                Assert.AreEqual("The Inventory Transfer is not balanced. The total of all line items must equal to 0.", rex.Message, "Incorrect error message.");
            }
        }
示例#6
0
        public void TestUpdateWithDecimalQuantity()
        {
            InventoryTransferProxy proxy = new InventoryTransferProxy();
            InventoryTransferDto   dto1  = this.GetInventoryTransfer4();

            proxy.Insert(dto1);

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

            dto1.Notes = "Updated inventory transfer";
            dto1.Items.AddRange(this.GetInventoryTransfer2().Items);

            proxy.Update(dto1);

            InventoryTransferDto dto2 = (InventoryTransferDto)proxy.GetByUid(dto1.Uid);

            AssertEqual(dto1, dto2);
        }
示例#7
0
        public void TestDelete()
        {
            CrudProxy            proxy = new InventoryTransferProxy();
            InventoryTransferDto dto1  = this.GetInventoryTransfer1();

            proxy.Insert(dto1);

            proxy.DeleteByUid(dto1.Uid);

            try
            {
                proxy.GetByUid(dto1.Uid);
                throw new Exception("The expected exception was not thrown.");
            }
            catch (RestException ex)
            {
                Assert.AreEqual("RecordNotFoundException", ex.Type, "Incorrect exception type.");
            }
        }
        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);
            }
        }
示例#9
0
        protected virtual ITask CreateUpdateTask(InventoryTransferDto inventoryTransfer)
        {
            UpdateInventoryTransferTask task = (UpdateInventoryTransferTask)base.CreateUpdateTask(inventoryTransfer);

            return(task);
        }
示例#10
0
        protected virtual ITask CreateInsertTask(InventoryTransferDto inventoryTransfer)
        {
            InsertInventoryTransferTask task = (InsertInventoryTransferTask)base.CreateInsertTask(inventoryTransfer);

            return(task);
        }