Пример #1
0
        public void CreateDeliveriesFromPendingItems_ValidPendingDeliveryItems_DeliveriesCreated()
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var quoteRepository        = new QuoteRepository();
            var quoteItemRepository    = new QuoteItemRepository();
            var customerRepository     = new CustomerRepository();
            var jobRepository          = new JobRepository();
            var jobItemRepository      = new JobItemRepository();
            var listItemRepository     = new ListItemRepository();
            var entityIdProvider       = new DirectEntityIdProvider();
            var instrumentRepository   = new InstrumentRepository();
            var deliveryRepository     = new DeliveryRepository();
            var deliveryItemRepository = new DeliveryItemRepository();

            var customerId1 = Guid.NewGuid();
            var customerId2 = Guid.NewGuid();
            var job1Id      = Guid.NewGuid();
            var job2Id      = Guid.NewGuid();
            var job3Id      = Guid.NewGuid();
            var jobItem1Id  = Guid.NewGuid();
            var jobItem2Id  = Guid.NewGuid();
            var jobItem3Id  = Guid.NewGuid();
            var jobItem4Id  = Guid.NewGuid();
            var jobItem5Id  = Guid.NewGuid();
            var jobItem6Id  = Guid.NewGuid();
            var jobItem7Id  = Guid.NewGuid();
            var jobItem8Id  = Guid.NewGuid();
            var jobItem9Id  = Guid.NewGuid();

            CreateDeliveriesFromPendingItemsHelper.CreateContextForPendingItemTests(
                customerId1, customerId2, job1Id, job2Id, job3Id, jobItem1Id, jobItem2Id, jobItem3Id, jobItem4Id, jobItem5Id, jobItem6Id, jobItem7Id, jobItem8Id, jobItem9Id);

            var deliveryItemService =
                new DeliveryItemService(
                    userContext, deliveryRepository, deliveryItemRepository, jobItemRepository, quoteItemRepository, listItemRepository, customerRepository, dispatcher);
            var deliveryService = new DeliveryService(userContext, deliveryRepository, deliveryItemService, customerRepository, entityIdProvider, dispatcher);

            deliveryItemService.CreatePending(Guid.NewGuid(), jobItem1Id, customerId1, "some notes");
            deliveryItemService.CreatePending(Guid.NewGuid(), jobItem2Id, customerId1, "some notes");
            deliveryItemService.CreatePending(Guid.NewGuid(), jobItem3Id, customerId1, "some notes");
            deliveryItemService.CreatePending(Guid.NewGuid(), jobItem4Id, customerId1, "some notes");
            deliveryItemService.CreatePending(Guid.NewGuid(), jobItem5Id, customerId1, "some notes");
            deliveryItemService.CreatePending(Guid.NewGuid(), jobItem6Id, customerId1, "some notes");
            deliveryItemService.CreatePending(Guid.NewGuid(), jobItem7Id, customerId1, "some notes");
            deliveryItemService.CreatePending(Guid.NewGuid(), jobItem8Id, customerId2, "some notes");
            deliveryItemService.CreatePending(Guid.NewGuid(), jobItem9Id, customerId2, "some notes");
            deliveryService.CreateDeliveriesFromPendingItems();

            var deliveries = deliveryService.GetDeliveries().ToList();

            Assert.AreEqual(2, deliveries.Count);
            var deliveryItems = deliveryItemService.GetDeliveryItems(deliveries[0].Id).ToList();

            Assert.AreEqual(7, deliveryItems.Count);
        }
        public static void CreateContext(Guid testStandardId, Guid jobItemId)
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var companyDetailsRepository = new CompanyDetailsRepository();
            var quoteRepository          = new QuoteRepository();
            var quoteItemRepository      = new QuoteItemRepository();
            var customerRepository       = new CustomerRepository();
            var jobRepository            = new JobRepository();
            var jobItemRepository        = new JobItemRepository();
            var listItemRepository       = new ListItemRepository();
            var entityIdProvider         = new DirectEntityIdProvider();
            var instrumentRepository     = new InstrumentRepository();

            var instrumentId      = Guid.NewGuid();
            var instrumentService = new InstrumentService(userContext, instrumentRepository, dispatcher);

            instrumentService.Create(instrumentId, "Druck", "DPI601IS", "None", "Description", 15);

            var customerId      = Guid.NewGuid();
            var customerService = new CustomerService(userContext, customerRepository, dispatcher);

            customerService.Create(customerId, "Gael Ltd", String.Empty, new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo());

            var listItemService = new ListItemService(userContext, listItemRepository, dispatcher);
            var jobService      = new JobService(userContext, null, jobRepository, listItemRepository, customerRepository, entityIdProvider, dispatcher);
            var jobItemService  = new JobItemService(userContext, jobRepository, jobItemRepository, listItemService, instrumentService, dispatcher);

            var jobId = Guid.NewGuid();

            jobService.CreateJob(jobId, "Some instructions", "PO1000", "AD1000", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId, "some notes", "job contact");
            jobItemService.CreateJobItem(
                jobId, jobItemId, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
        }
Пример #3
0
        public void CreateOrderFromConsignment_ValidConsignment_OrderCreated()
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var orderRepository          = new OrderRepository();
            var orderItemRepository      = new OrderItemRepository();
            var supplierRepository       = new SupplierRepository();
            var listItemRepository       = new ListItemRepository();
            var currencyRepository       = new CurrencyRepository();
            var entityIdProvider         = new DirectEntityIdProvider();
            var jobItemRepository        = new JobItemRepository();
            var companyDetailsRepository = new CompanyDetailsRepository();
            var consignmentRepository    = new ConsignmentRepository();

            var supplierId    = Guid.NewGuid();
            var jobId         = Guid.NewGuid();
            var jobItem1Id    = Guid.NewGuid();
            var jobItem2Id    = Guid.NewGuid();
            var jobItem3Id    = Guid.NewGuid();
            var consignmentId = Guid.NewGuid();

            CreateOrderFromConsignmentHelper.CreateContextForCreateOrderFromConsignmentTest(jobId, supplierId, consignmentId, jobItem1Id, jobItem2Id, jobItem3Id);
            var orderItemService = new OrderItemService(userContext, orderRepository, orderItemRepository, supplierRepository, jobItemRepository, listItemRepository, dispatcher);
            var orderService     = new OrderService(
                userContext, orderRepository, consignmentRepository, supplierRepository, currencyRepository, entityIdProvider,
                orderItemService, companyDetailsRepository, dispatcher);
            var orderId = orderService.CreateOrderFromConsignment(consignmentId);
            var order   = orderService.GetById(orderId);

            Assert.AreEqual(supplierId, order.Supplier.Id);
            var orderItems = orderItemService.GetOrderItems(orderId).OrderBy(o => o.ItemNo).ToList();

            Assert.AreEqual(3, orderItems.Count);
            Assert.AreEqual(ListItemType.StatusItemWithSubContractor, orderItems[0].JobItem.Status.Type);
            Assert.AreEqual("Druck, DPI601IS, Digital Pressure Indicator", orderItems[0].Description);
        }
Пример #4
0
        public static void CreateContextForPendingItemTests(
            Guid customerId1, Guid customerId2,
            Guid job1Id, Guid job2Id, Guid job3Id,
            Guid jobItem1Id, Guid jobItem2Id, Guid jobItem3Id,
            Guid jobItem4Id, Guid jobItem5Id, Guid jobItem6Id, Guid jobItem7Id, Guid jobItem8Id, Guid jobItem9Id)
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var companyDetailsRepository = new CompanyDetailsRepository();
            var quoteRepository          = new QuoteRepository();
            var quoteItemRepository      = new QuoteItemRepository();
            var customerRepository       = new CustomerRepository();
            var jobRepository            = new JobRepository();
            var jobItemRepository        = new JobItemRepository();
            var listItemRepository       = new ListItemRepository();
            var currencyRepository       = new CurrencyRepository();
            var entityIdProvider         = new DirectEntityIdProvider();
            var instrumentRepository     = new InstrumentRepository();

            var instrumentId      = Guid.NewGuid();
            var instrumentService = new InstrumentService(userContext, instrumentRepository, dispatcher);

            instrumentService.Create(instrumentId, "Druck", "DPI601IS", "None", "Description", 0);

            var customerService = new CustomerService(userContext, customerRepository, dispatcher);

            customerService.Create(customerId1, "Gael Ltd", String.Empty, new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo());
            customerService.Create(customerId2, "EMIS (UK) Ltd", String.Empty, new Address(), new ContactInfo(), "EMIS (UK) Ltd", new Address(), new ContactInfo(), "EMIS (UK) Ltd", new Address(), new ContactInfo());

            var listItemService = new ListItemService(userContext, listItemRepository, dispatcher);
            var jobService      = new JobService(userContext, null, jobRepository, listItemRepository, customerRepository, entityIdProvider, dispatcher);

            jobService.CreateJob(job1Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId1, "notes", "contact");
            jobService.CreateJob(job2Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId1, "notes", "contact");
            jobService.CreateJob(job3Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId2, "notes", "contact");

            var jobItemService = new JobItemService(userContext, jobRepository, jobItemRepository, listItemService, instrumentService, dispatcher);

            #region Job 1

            jobItemService.CreateJobItem(
                job1Id, jobItem1Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job1Id, jobItem2Id, instrumentId, "123456", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job1Id, jobItem3Id, instrumentId, "123457", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job1Id, jobItem4Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobService.ApproveJob(job1Id);

            #endregion
            #region Job2

            jobItemService.CreateJobItem(
                job2Id, jobItem5Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job2Id, jobItem6Id, instrumentId, "123456", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job2Id, jobItem7Id, instrumentId, "123457", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobService.ApproveJob(job2Id);

            #endregion
            #region Job 3

            jobItemService.CreateJobItem(
                job3Id, jobItem8Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job3Id, jobItem9Id, instrumentId, "123456", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobService.ApproveJob(job3Id);

            #endregion

            var quoteItemService = new QuoteItemService(userContext, quoteRepository, quoteItemRepository, jobItemRepository, listItemRepository, customerRepository, dispatcher);
            var quoteService     = new QuoteService(userContext, quoteRepository, customerRepository, entityIdProvider, currencyRepository, quoteItemService, companyDetailsRepository, dispatcher);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem1Id, 25, 35, 45, 25, 56, "calibrated", 30, false, "CALORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem3Id, 45, 65, 35, 22, 87, "calibrated", 30, false, "CALORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem2Id, 45, 60, 30, 26, 56, "repaired", 30, false, "REPAIRORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem4Id, 45, 65, 35, 22, 87, "repaired", 30, false, "REPAIRORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem5Id, 25, 35, 45, 25, 56, "calibrated", 30, false, "CALORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem6Id, 25, 35, 45, 25, 56, "calibrated", 30, false, "CALORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId1, jobItem7Id, 25, 35, 45, 25, 56, "calibrated", 30, false, "CALORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId2, jobItem8Id, 25, 35, 45, 25, 56, "repaired", 30, false, "REPAIRORDER", String.Empty);
            quoteItemService.CreatePending(Guid.NewGuid(), customerId2, jobItem9Id, 25, 35, 45, 25, 56, "repaired", 30, false, "REPAIRORDER", String.Empty);
            quoteService.CreateQuotesFromPendingItems();

            foreach (var quote in quoteService.GetQuotes())
            {
                foreach (var quoteItem in quoteItemService.GetQuoteItems(quote.Id))
                {
                    quoteItemService.Accept(quoteItem.Id);
                }
            }
        }
Пример #5
0
        public void CreateQuotesFromPendingItems_ValidPendingQuoteItems_QuotesCreated()
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var quoteRepository      = new QuoteRepository();
            var quoteItemRepository  = new QuoteItemRepository();
            var customerRepository   = new CustomerRepository();
            var jobRepository        = new JobRepository();
            var jobItemRepository    = new JobItemRepository();
            var listItemRepository   = new ListItemRepository();
            var currencyRepository   = new CurrencyRepository();
            var entityIdProvider     = new DirectEntityIdProvider();
            var instrumentRepository = new InstrumentRepository();

            var customerId = Guid.NewGuid();
            var job1Id     = Guid.NewGuid();
            var job2Id     = Guid.NewGuid();
            var job3Id     = Guid.NewGuid();
            var jobItem1Id = Guid.NewGuid();
            var jobItem2Id = Guid.NewGuid();
            var jobItem3Id = Guid.NewGuid();
            var jobItem4Id = Guid.NewGuid();
            var jobItem5Id = Guid.NewGuid();
            var jobItem6Id = Guid.NewGuid();
            var jobItem7Id = Guid.NewGuid();
            var jobItem8Id = Guid.NewGuid();
            var jobItem9Id = Guid.NewGuid();

            CreateQuotesFromPendingItemsHelper.CreateContextForPendingItemTests(
                customerId, job1Id, job2Id, job3Id, jobItem1Id, jobItem2Id, jobItem3Id, jobItem4Id, jobItem5Id, jobItem6Id, jobItem7Id, jobItem8Id, jobItem9Id);

            var quoteItemService = new QuoteItemService(
                userContext, quoteRepository, quoteItemRepository, jobItemRepository, listItemRepository, customerRepository, dispatcher);

            quoteItemService.CreatePending(Guid.NewGuid(), customerId, jobItem1Id, 85, 40, 39, 25, 12, "report", 30, false, "PO1000", "AD1000");
            quoteItemService.CreatePending(Guid.NewGuid(), customerId, jobItem2Id, 85, 40, 39, 25, 12, "report", 30, false, "PO1001", "AD1001");
            quoteItemService.CreatePending(Guid.NewGuid(), customerId, jobItem3Id, 85, 40, 39, 25, 12, "report", 30, false, "PO1000", "AD1000");
            quoteItemService.CreatePending(Guid.NewGuid(), customerId, jobItem4Id, 85, 40, 39, 25, 12, "report", 30, false, "PO1001", "AD1001");
            quoteItemService.CreatePending(Guid.NewGuid(), customerId, jobItem5Id, 85, 40, 39, 25, 12, "report", 30, false, "PO1000", "AD1000");
            quoteItemService.CreatePending(Guid.NewGuid(), customerId, jobItem6Id, 85, 40, 39, 25, 12, "report", 30, false, "PO1000", "AD1000");
            quoteItemService.CreatePending(Guid.NewGuid(), customerId, jobItem7Id, 85, 40, 39, 25, 12, "report", 30, false, "PO1000", "AD1000");
            quoteItemService.CreatePending(Guid.NewGuid(), customerId, jobItem8Id, 85, 40, 39, 25, 12, "report", 30, false, "PO1200", "AD1200");
            quoteItemService.CreatePending(Guid.NewGuid(), customerId, jobItem9Id, 85, 40, 39, 25, 12, "report", 30, false, "PO1200", "AD1200");

            var quoteService = new QuoteService(
                userContext, quoteRepository, customerRepository, entityIdProvider, currencyRepository, quoteItemService, new CompanyDetailsRepository(), dispatcher);

            quoteService.CreateQuotesFromPendingItems();

            var quotes = quoteService.GetQuotes().OrderBy(q => q.QuoteNumber).ToList();

            Assert.AreEqual(4, quotes.Count);
            Assert.AreEqual("1", quotes[0].QuoteNumber);
            Assert.AreEqual("PO1000", quotes[0].OrderNumber);
            Assert.AreEqual("PO1001", quotes[1].OrderNumber);
            Assert.AreEqual("PO1000", quotes[2].OrderNumber);
            Assert.AreEqual("PO1200", quotes[3].OrderNumber);

            var quoteItems = quoteItemService.GetQuoteItems(quotes[0].Id).ToList();

            Assert.AreEqual(2, quoteItems.Count);
            Assert.AreEqual(jobItem1Id, quoteItems[0].JobItem.Id);
            Assert.AreEqual(jobItem3Id, quoteItems[1].JobItem.Id);

            quoteItems = quoteItemService.GetQuoteItems(quotes[1].Id).ToList();
            Assert.AreEqual(2, quoteItems.Count);
            Assert.AreEqual(jobItem2Id, quoteItems[0].JobItem.Id);
            Assert.AreEqual(jobItem4Id, quoteItems[1].JobItem.Id);

            quoteItems = quoteItemService.GetQuoteItems(quotes[2].Id).ToList();
            Assert.AreEqual(3, quoteItems.Count);
            Assert.AreEqual(jobItem5Id, quoteItems[0].JobItem.Id);
            Assert.AreEqual(jobItem6Id, quoteItems[1].JobItem.Id);
            Assert.AreEqual(jobItem7Id, quoteItems[2].JobItem.Id);

            quoteItems = quoteItemService.GetQuoteItems(quotes[3].Id).ToList();
            Assert.AreEqual(2, quoteItems.Count);
            Assert.AreEqual(jobItem8Id, quoteItems[0].JobItem.Id);
            Assert.AreEqual(jobItem9Id, quoteItems[1].JobItem.Id);
        }
Пример #6
0
        public void CreateInvoicesFromPendingItems_ValidPendingInvoiceItems_InvoicesCreated()
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var companyDetailsRepository = new CompanyDetailsRepository();
            var quoteRepository          = new QuoteRepository();
            var quoteItemRepository      = new QuoteItemRepository();
            var customerRepository       = new CustomerRepository();
            var jobRepository            = new JobRepository();
            var jobItemRepository        = new JobItemRepository();
            var listItemRepository       = new ListItemRepository();
            var currencyRepository       = new CurrencyRepository();
            var entityIdProvider         = new DirectEntityIdProvider();
            var instrumentRepository     = new InstrumentRepository();
            var deliveryRepository       = new DeliveryRepository();
            var deliveryItemRepository   = new DeliveryItemRepository();
            var invoiceRepository        = new InvoiceRepository();
            var invoiceItemRepository    = new InvoiceItemRepository();

            var customerId1 = Guid.NewGuid();
            var customerId2 = Guid.NewGuid();
            var job1Id      = Guid.NewGuid();
            var job2Id      = Guid.NewGuid();
            var job3Id      = Guid.NewGuid();
            var jobItem1Id  = Guid.NewGuid();
            var jobItem2Id  = Guid.NewGuid();
            var jobItem3Id  = Guid.NewGuid();
            var jobItem4Id  = Guid.NewGuid();
            var jobItem5Id  = Guid.NewGuid();
            var jobItem6Id  = Guid.NewGuid();
            var jobItem7Id  = Guid.NewGuid();
            var jobItem8Id  = Guid.NewGuid();
            var jobItem9Id  = Guid.NewGuid();

            CreateInvoicesFromPendingItemsHelper.CreateContextForPendingItemTests(
                customerId1, customerId2, job1Id, job2Id, job3Id, jobItem1Id, jobItem2Id, jobItem3Id, jobItem4Id, jobItem5Id, jobItem6Id, jobItem7Id, jobItem8Id, jobItem9Id);
            var invoiceItemService = new InvoiceItemService(userContext, companyDetailsRepository, invoiceRepository, invoiceItemRepository, jobItemRepository, quoteItemRepository, listItemRepository, dispatcher);

            invoiceItemService.CreatePending(Guid.NewGuid(), jobItem1Id);
            invoiceItemService.CreatePending(Guid.NewGuid(), jobItem2Id);
            invoiceItemService.CreatePending(Guid.NewGuid(), jobItem3Id);
            invoiceItemService.CreatePending(Guid.NewGuid(), jobItem4Id);
            invoiceItemService.CreatePending(Guid.NewGuid(), jobItem5Id);
            invoiceItemService.CreatePending(Guid.NewGuid(), jobItem6Id);
            invoiceItemService.CreatePending(Guid.NewGuid(), jobItem7Id);
            invoiceItemService.CreatePending(Guid.NewGuid(), jobItem8Id);
            invoiceItemService.CreatePending(Guid.NewGuid(), jobItem9Id);

            var invoiceService = new InvoiceService(
                userContext, invoiceItemService, invoiceRepository, new DirectEntityIdProvider(), listItemRepository, customerRepository, new BankDetailsRepository(), new TaxCodeRepository(), companyDetailsRepository, currencyRepository, dispatcher);

            invoiceService.CreateInvoicesFromPendingItems();
            var invoices = invoiceService.GetInvoices().ToList();

            Assert.AreEqual(4, invoices.Count);
            var invoiceItems = invoiceItemService.GetInvoiceItems(invoices[0].Id).ToList();

            Assert.AreEqual(2, invoiceItems.Count);
            invoiceItems = invoiceItemService.GetInvoiceItems(invoices[1].Id).ToList();
            Assert.AreEqual(2, invoiceItems.Count);
            invoiceItems = invoiceItemService.GetInvoiceItems(invoices[2].Id).ToList();
            Assert.AreEqual(3, invoiceItems.Count);
            invoiceItems = invoiceItemService.GetInvoiceItems(invoices[3].Id).ToList();
            Assert.AreEqual(2, invoiceItems.Count);
            var pendingItems = invoiceItemService.GetPendingInvoiceItems().ToList();

            Assert.AreEqual(0, pendingItems.Count);
        }
        public static void CreateContextForPendingItemTests(
            Guid job1Id, Guid job2Id, Guid job3Id, Guid supplier1Id, Guid supplier2Id, Guid supplier3Id,
            Guid jobItem1Id, Guid jobItem2Id, Guid jobItem3Id, Guid jobItem4Id, Guid jobItem5Id, Guid jobItem6Id, Guid jobItem7Id)
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var consignmentRepository     = new ConsignmentRepository();
            var consignmentItemRepository = new ConsignmentItemRepository();
            var supplierRepository        = new SupplierRepository();
            var jobRepository             = new JobRepository();
            var jobItemRepository         = new JobItemRepository();
            var listItemRepository        = new ListItemRepository();
            var customerRepository        = new CustomerRepository();
            var entityIdProvider          = new DirectEntityIdProvider();
            var instrumentRepository      = new InstrumentRepository();

            var instrumentId      = Guid.NewGuid();
            var instrumentService = new InstrumentService(userContext, instrumentRepository, dispatcher);

            instrumentService.Create(instrumentId, "Druck", "DPI601IS", "None", "Description", 15);

            var customerId      = Guid.NewGuid();
            var customerService = new CustomerService(userContext, customerRepository, dispatcher);

            customerService.Create(customerId, "Gael Ltd", String.Empty, new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo());

            var supplierService = new SupplierService(userContext, supplierRepository, dispatcher);

            supplierService.Create(supplier1Id, "Supplier 1", new Address(), new ContactInfo(), new Address(), new ContactInfo());
            supplierService.Create(supplier2Id, "Supplier 2", new Address(), new ContactInfo(), new Address(), new ContactInfo());
            supplierService.Create(supplier3Id, "Supplier 3", new Address(), new ContactInfo(), new Address(), new ContactInfo());

            var listItemService = new ListItemService(userContext, listItemRepository, dispatcher);
            var jobService      = new JobService(userContext, null, jobRepository, listItemRepository, customerRepository, entityIdProvider, dispatcher);

            jobService.CreateJob(job1Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId, "notes", "contact");
            jobService.CreateJob(job2Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId, "notes", "contact");
            jobService.CreateJob(job3Id, "some instructions", "order no", "advice no", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId, "notes", "contact");

            var jobItemService = new JobItemService(userContext, jobRepository, jobItemRepository, listItemService, instrumentService, dispatcher);

            jobItemService.CreateJobItem(
                job1Id, jobItem1Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job1Id, jobItem2Id, instrumentId, "123456", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job1Id, jobItem3Id, instrumentId, "123457", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job2Id, jobItem4Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job2Id, jobItem5Id, instrumentId, "123456", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job2Id, jobItem6Id, instrumentId, "1234567", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobItemService.CreateJobItem(
                job3Id, jobItem7Id, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
            jobService.ApproveJob(job1Id);
            jobService.ApproveJob(job2Id);
            jobService.ApproveJob(job3Id);
        }
Пример #8
0
        public void CreateConsignmentsFromPendingItems_ValidPendingConsignmentItems_ConsignmentsCreated()
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var consignmentRepository     = new ConsignmentRepository();
            var consignmentItemRepository = new ConsignmentItemRepository();
            var supplierRepository        = new SupplierRepository();
            var jobRepository             = new JobRepository();
            var jobItemRepository         = new JobItemRepository();
            var listItemRepository        = new ListItemRepository();
            var entityIdProvider          = new DirectEntityIdProvider();
            var instrumentRepository      = new InstrumentRepository();

            var supplier1Id = Guid.NewGuid();
            var supplier2Id = Guid.NewGuid();
            var supplier3Id = Guid.NewGuid();
            var job1Id      = Guid.NewGuid();
            var job2Id      = Guid.NewGuid();
            var job3Id      = Guid.NewGuid();
            var jobItem1Id  = Guid.NewGuid();
            var jobItem2Id  = Guid.NewGuid();
            var jobItem3Id  = Guid.NewGuid();
            var jobItem4Id  = Guid.NewGuid();
            var jobItem5Id  = Guid.NewGuid();
            var jobItem6Id  = Guid.NewGuid();
            var jobItem7Id  = Guid.NewGuid();

            CreateConsignmentsFromPendingItemsHelper.CreateContextForPendingItemTests(
                job1Id, job2Id, job3Id, supplier1Id, supplier2Id, supplier3Id,
                jobItem1Id, jobItem2Id, jobItem3Id, jobItem4Id, jobItem5Id, jobItem6Id, jobItem7Id);

            var instrumentService      = new InstrumentService(userContext, instrumentRepository, dispatcher);
            var listItemService        = new ListItemService(userContext, listItemRepository, dispatcher);
            var jobItemService         = new JobItemService(userContext, jobRepository, jobItemRepository, listItemService, instrumentService, dispatcher);
            var consignmentItemService = new ConsignmentItemService(
                userContext,
                consignmentRepository, consignmentItemRepository, jobItemRepository, new ListItemRepository(), supplierRepository, dispatcher);

            _consignmentService = new ConsignmentService(userContext, consignmentRepository, supplierRepository, new DirectEntityIdProvider(), consignmentItemService, dispatcher);
            var jobItems = jobItemService.GetJobItems(job1Id).OrderBy(ji => ji.ItemNo).ToList();

            consignmentItemService.CreatePending(Guid.NewGuid(), jobItems[0].Id, supplier1Id, "for cal");
            consignmentItemService.CreatePending(Guid.NewGuid(), jobItems[1].Id, supplier2Id, "for repair");
            consignmentItemService.CreatePending(Guid.NewGuid(), jobItems[2].Id, supplier1Id, "for cal");
            jobItems = jobItemService.GetJobItems(job2Id).OrderBy(ji => ji.ItemNo).ToList();
            consignmentItemService.CreatePending(Guid.NewGuid(), jobItems[0].Id, supplier1Id, "for cal");
            consignmentItemService.CreatePending(Guid.NewGuid(), jobItems[1].Id, supplier2Id, "for repair");
            consignmentItemService.CreatePending(Guid.NewGuid(), jobItems[2].Id, supplier3Id, "for cal");
            jobItems = jobItemService.GetJobItems(job3Id).OrderBy(ji => ji.ItemNo).ToList();
            consignmentItemService.CreatePending(Guid.NewGuid(), jobItems[0].Id, supplier3Id, "for cal");

            var consignmentService = new ConsignmentService(userContext, consignmentRepository, supplierRepository, entityIdProvider, consignmentItemService, dispatcher);

            consignmentService.CreateConsignmentsFromPendingItems();

            var consignments = consignmentService.GetConsignments().OrderBy(c => c.ConsignmentNo).ToList();

            Assert.AreEqual(3, consignments.Count);
            Assert.AreEqual("1", consignments[0].ConsignmentNo);
            Assert.AreEqual(supplier1Id, consignments[0].Supplier.Id);
            Assert.AreEqual("2", consignments[1].ConsignmentNo);
            Assert.AreEqual(supplier2Id, consignments[1].Supplier.Id);
            Assert.AreEqual("3", consignments[2].ConsignmentNo);
            Assert.AreEqual(supplier3Id, consignments[2].Supplier.Id);

            var consignmentItems = consignmentItemService.GetConsignmentItems(consignments[0].Id).OrderBy(ci => ci.ItemNo).ToList();

            Assert.AreEqual(3, consignmentItems.Count);
            Assert.AreEqual(jobItem1Id, consignmentItems[0].JobItem.Id);    // JR2000/1
            Assert.AreEqual(jobItem3Id, consignmentItems[1].JobItem.Id);    // JR2000/3
            Assert.AreEqual(jobItem4Id, consignmentItems[2].JobItem.Id);    // JR2001/1

            consignmentItems = consignmentItemService.GetConsignmentItems(consignments[1].Id).OrderBy(ci => ci.ItemNo).ToList();
            Assert.AreEqual(2, consignmentItems.Count);
            Assert.AreEqual(jobItem2Id, consignmentItems[0].JobItem.Id);    // JR2000/2
            Assert.AreEqual(jobItem5Id, consignmentItems[1].JobItem.Id);    // JR2001/2

            consignmentItems = consignmentItemService.GetConsignmentItems(consignments[2].Id).OrderBy(ci => ci.ItemNo).ToList();
            Assert.AreEqual(2, consignmentItems.Count);
            Assert.AreEqual(jobItem6Id, consignmentItems[0].JobItem.Id);    // JR2001/3
            Assert.AreEqual(jobItem7Id, consignmentItems[1].JobItem.Id);    // JR2002/1

            Assert.AreEqual(0, consignmentItemService.GetPendingItems().Count());
        }
Пример #9
0
        public void CreateOrdersFromPendingItems_ValidPendingOrderItems_OrdersCreated()
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var orderRepository          = new OrderRepository();
            var orderItemRepository      = new OrderItemRepository();
            var supplierRepository       = new SupplierRepository();
            var jobRepository            = new JobRepository();
            var jobItemRepository        = new JobItemRepository();
            var listItemRepository       = new ListItemRepository();
            var currencyRepository       = new CurrencyRepository();
            var entityIdProvider         = new DirectEntityIdProvider();
            var instrumentRepository     = new InstrumentRepository();
            var companyDetailsRepository = new CompanyDetailsRepository();
            var consignmentRepository    = new ConsignmentRepository();

            var supplier1Id = Guid.NewGuid();
            var supplier2Id = Guid.NewGuid();
            var supplier3Id = Guid.NewGuid();
            var job1Id      = Guid.NewGuid();
            var job2Id      = Guid.NewGuid();
            var job3Id      = Guid.NewGuid();
            var jobItem1Id  = Guid.NewGuid();
            var jobItem2Id  = Guid.NewGuid();
            var jobItem3Id  = Guid.NewGuid();
            var jobItem4Id  = Guid.NewGuid();
            var jobItem5Id  = Guid.NewGuid();
            var jobItem6Id  = Guid.NewGuid();
            var jobItem7Id  = Guid.NewGuid();

            CreateOrdersFromPendingItemsHelper.CreateContextForPendingItemTests(
                job1Id, job2Id, job3Id, supplier1Id, supplier2Id, supplier3Id,
                jobItem1Id, jobItem2Id, jobItem3Id, jobItem4Id, jobItem5Id, jobItem6Id, jobItem7Id);
            var instrumentService = new InstrumentService(userContext, instrumentRepository, dispatcher);
            var listItemService   = new ListItemService(userContext, listItemRepository, dispatcher);
            var jobItemService    = new JobItemService(userContext, jobRepository, jobItemRepository, listItemService, instrumentService, dispatcher);
            var orderItemService  = new OrderItemService(
                userContext, orderRepository, orderItemRepository, supplierRepository, jobItemRepository, listItemRepository, dispatcher);

            orderItemService.CreatePending(Guid.NewGuid(), supplier1Id, "some description", 1, "partno", "instructions", 30, jobItem1Id, 29.99m, 0m);
            orderItemService.CreatePending(Guid.NewGuid(), supplier2Id, "some description", 1, "partno", "instructions", 30, jobItem2Id, 29.99m, 0m);
            orderItemService.CreatePending(Guid.NewGuid(), supplier1Id, "some description", 1, "partno", "instructions", 30, jobItem3Id, 29.99m, 0m);

            orderItemService.CreatePending(Guid.NewGuid(), supplier1Id, "some description", 1, "partno", "instructions", 30, jobItem4Id, 29.99m, 0m);
            orderItemService.CreatePending(Guid.NewGuid(), supplier2Id, "some description", 1, "partno", "instructions", 30, jobItem5Id, 29.99m, 0m);
            orderItemService.CreatePending(Guid.NewGuid(), supplier3Id, "some description", 1, "partno", "instructions", 30, jobItem6Id, 29.99m, 0m);

            orderItemService.CreatePending(Guid.NewGuid(), supplier3Id, "some description", 1, "partno", "instructions", 30, jobItem7Id, 29.99m, 0m);

            var orderService = new OrderService(
                userContext, orderRepository, consignmentRepository, supplierRepository, currencyRepository, entityIdProvider, orderItemService, companyDetailsRepository, dispatcher);

            orderService.CreateOrdersFromPendingItems();

            var orders = orderService.GetOrders().OrderBy(o => o.OrderNo).ToList();

            Assert.AreEqual(3, orders.Count);
            Assert.AreEqual("1", orders[0].OrderNo);
            Assert.AreEqual(supplier1Id, orders[0].Supplier.Id);
            Assert.AreEqual("2", orders[1].OrderNo);
            Assert.AreEqual(supplier2Id, orders[1].Supplier.Id);
            Assert.AreEqual("3", orders[2].OrderNo);
            Assert.AreEqual(supplier3Id, orders[2].Supplier.Id);

            var orderItems = orderItemService.GetOrderItems(orders[0].Id).OrderBy(oi => oi.ItemNo).ToList();

            Assert.AreEqual(3, orderItems.Count);
            Assert.AreEqual(jobItem1Id, orderItems[0].JobItem.Id);    // JR2000/1
            Assert.AreEqual(jobItem3Id, orderItems[1].JobItem.Id);    // JR2000/3
            Assert.AreEqual(jobItem4Id, orderItems[2].JobItem.Id);    // JR2001/1

            orderItems = orderItemService.GetOrderItems(orders[1].Id).OrderBy(oi => oi.ItemNo).ToList();
            Assert.AreEqual(2, orderItems.Count);
            Assert.AreEqual(jobItem2Id, orderItems[0].JobItem.Id);    // JR2000/2
            Assert.AreEqual(jobItem5Id, orderItems[1].JobItem.Id);    // JR2001/2

            orderItems = orderItemService.GetOrderItems(orders[1].Id).OrderBy(oi => oi.ItemNo).ToList();
            Assert.AreEqual(2, orderItems.Count);
            Assert.AreEqual(jobItem6Id, orderItems[0].JobItem.Id);    // JR2001/3
            Assert.AreEqual(jobItem7Id, orderItems[1].JobItem.Id);    // JR2002/1

            Assert.AreEqual(0, orderItemService.GetPendingOrderItems().Count());
        }