Exemple #1
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="exportLogic"></param>
 /// <param name="orderLogic"></param>
 /// <param name="listRepo"></param>
 /// <param name="cache"></param>
 /// <param name="invLogic"></param>
 public ExportInvoicesServiceImpl(IExportSettingLogic exportLogic, IOrderLogic orderLogic,
                                  IOnlinePaymentsLogic invLogic, IKPayInvoiceRepository invoiceRepo,
                                  ICustomerRepository customerRepository)
 {
     _customerRepository = customerRepository;
     _exportLogic        = exportLogic;
     _orderLogic         = orderLogic;
     _invLogic           = invLogic;
     _invoiceRepo        = invoiceRepo;
 }
Exemple #2
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="profileLogic"></param>
 /// <param name="invoiceLogic"></param>
 /// <param name="exportSettingsLogic"></param>
 /// <param name="orderLogic"></param>
 /// <param name="invoiceImagingLogic"></param>
 /// <param name="logRepo"></param>
 /// <param name="invService"></param>
 public InvoiceController(IUserProfileLogic profileLogic, IOnlinePaymentsLogic invoiceLogic, IExportSettingLogic exportSettingsLogic,
                          IOrderLogic orderLogic, IImagingLogic invoiceImagingLogic, IEventLogRepository logRepo, ICatalogLogic catalogLogic,
                          IExportInvoicesService invService, IListService listService) : base(profileLogic)
 {
     _invLogic     = invoiceLogic;
     _orderLogic   = orderLogic;
     _exportLogic  = exportSettingsLogic;
     _imgLogic     = invoiceImagingLogic;
     _log          = logRepo;
     _catalogLogic = catalogLogic;
     _invService   = invService;
     _listService  = listService;
 }
            public void WhenBadItemWithNoContract_ResultingDetailIsNull()
            {
                // arrange
                MockDependents              mockDependents = new MockDependents();
                IOnlinePaymentsLogic        testunit       = MakeTestsLogic(true, ref mockDependents);
                Dictionary <string, string> testDict       = new Dictionary <string, string>();
                InvoiceItemModel            testItem       = MakeModel();

                testItem.ItemNumber = "222222";

                // act
                testunit.AssignContractCategory(testDict, testItem);

                // assert
                testItem.Detail
                .Should()
                .BeNull();
            }
            public void WhenGoodItemWithContractNotMatchingItem_ResultingDetailIsExpected()
            {
                // arrange
                MockDependents              mockDependents = new MockDependents();
                IOnlinePaymentsLogic        testunit       = MakeTestsLogic(true, ref mockDependents);
                Dictionary <string, string> testDict       = new Dictionary <string, string>();

                testDict.Add("111111", "Category 1");
                InvoiceItemModel testItem = MakeModel();
                string           expected = "Fake Name / 111111 / Fake Brand / Category 1 / Fake Pack / Fake Size";

                // act
                testunit.AssignContractCategory(testDict, testItem);

                // assert
                testItem.Detail
                .Should()
                .Be(expected);
            }
            public void WhenGettingInvoiceHeadersForCustomerAndSortingByAmountAscending_ResultingInvoiceNumbersAreInExpectedOrder()
            {
                // arrange
                MockDependents       mockDependents = new MockDependents();
                IOnlinePaymentsLogic testunit       = MakeTestsLogic(useAutoFac: true, mockDependents: ref mockDependents);
                var testUser    = new UserProfile();
                var testContext = new UserSelectedContext
                {
                    BranchId   = "XXXXX",
                    CustomerId = "111111"
                };
                var testPaging = new PagingModel()
                {
                    Sort = new List <SortInfo>()
                    {
                        new SortInfo()
                        {
                            Field = "amount",
                            Order = "asc"
                        }
                    }
                };
                var testAllCustomers = false;
                var expected         = "2,1,3";

                BEKConfiguration.Add(
                    "WebNowUrl",
                    "http://invoice.benekeith.com/webnow/index.jsp?action=filter&amp;username=anonymous&amp;drawer={branch}AR501&amp;tab={customer}&amp;field4={invoice}");

                // act
                var result = testunit.GetInvoiceHeaders(testUser, testContext, testPaging, testAllCustomers);

                BEKConfiguration.Reset();

                // assert
                var invoiceNumbers = string.Join(",", result.PagedResults
                                                 .Results
                                                 .Select(im => im.InvoiceNumber));

                invoiceNumbers.Should()
                .Be(expected);
            }
            public void WhenGettingInvoiceCustomersWhenForAllCustomersIsTrue_ResultingFirstInvoiceCustomerNumberInvoicesIsThree()
            {
                // arrange
                MockDependents       mockDependents = new MockDependents();
                IOnlinePaymentsLogic testunit       = MakeTestsLogic(useAutoFac: true, mockDependents: ref mockDependents);
                var testUser    = new UserProfile();
                var testContext = new UserSelectedContext {
                    BranchId   = "XXXXX",
                    CustomerId = "111111"
                };
                var testPaging = new PagingModel()
                {
                    Sort = new List <SortInfo>()
                    {
                        new SortInfo()
                        {
                            Field = "invoiceamount",
                            Order = "desc"
                        }
                    }
                };
                var testAllCustomers = true;

                BEKConfiguration.Add(
                    "WebNowUrl",
                    "http://invoice.benekeith.com/webnow/index.jsp?action=filter&amp;username=anonymous&amp;drawer={branch}AR501&amp;tab={customer}&amp;field4={invoice}");
                var expected = 3;

                // act
                var result = testunit.GetInvoiceCustomers(testUser, testContext, testPaging, testAllCustomers);

                BEKConfiguration.Reset();

                // assert
                result.customers.First()
                .NumberInvoices
                .Should()
                .Be(expected);
            }