Beispiel #1
0
 public QuoteController(
     QuoteService quoteService,
     QuoteItemService quoteItemService,
     JobService jobService,
     JobItemService jobItemService,
     ListItemService listItemService,
     CompanyDetailsService companyDetailsService,
     CurrencyService currencyService)
 {
     _quoteService          = quoteService;
     _quoteItemService      = quoteItemService;
     _jobService            = jobService;
     _jobItemService        = jobItemService;
     _listItemService       = listItemService;
     _companyDetailsService = companyDetailsService;
     _currencyService       = currencyService;
 }
Beispiel #2
0
 public JobController(
     JobService jobService,
     ListItemService listItemService,
     JobItemService jobItemService,
     QuoteItemService quoteItemService,
     OrderItemService orderItemService,
     DeliveryItemService deliveryItemService,
     CertificateService certificateService,
     UserManagementService userManagementService)
 {
     _jobService            = jobService;
     _listItemService       = listItemService;
     _jobItemService        = jobItemService;
     _quoteItemService      = quoteItemService;
     _orderItemService      = orderItemService;
     _deliveryItemService   = deliveryItemService;
     _certificateService    = certificateService;
     _userManagementService = userManagementService;
 }
Beispiel #3
0
 public JobItemController(
     UserManagementService userManagementService,
     JobItemService jobItemService,
     ListItemService listItemService,
     InstrumentService instrumentService,
     ConsignmentService consignmentService,
     QuoteItemService quoteItemService,
     OrderItemService orderItemService,
     DeliveryItemService deliveryItemService,
     CertificateService certificateService)
 {
     _jobItemService        = jobItemService;
     _listItemService       = listItemService;
     _instrumentService     = instrumentService;
     _consignmentService    = consignmentService;
     _quoteItemService      = quoteItemService;
     _orderItemService      = orderItemService;
     _deliveryItemService   = deliveryItemService;
     _certificateService    = certificateService;
     _userManagementService = userManagementService;
 }
Beispiel #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);
                }
            }
        }
Beispiel #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);
        }