/// <summary>
        /// Constructs the Freshbooks API authentication and wrapper class
        /// </summary>
        /// <param name="accountName">The account name for which you are trying to access</param>
        /// <param name="consumerKey">The developer's freshbooks account name</param>
        /// <param name="oauthSecret">The developer's oauth-secret provided by freshbooks</param>
        public FreshbooksApi(string accountName, string consumerKey, string oauthSecret)
        {
            _accountName = accountName;
            _consumerKey = consumerKey;
            _oauthSecret = oauthSecret ?? String.Empty;

            _baseUri = new UriBuilder { Scheme = "https", Host = accountName + ".freshbooks.com" }.Uri;
            _serviceUri = new Uri(_baseUri, "/api/2.1/xml-in");
            Clear();

            UserAgent = String.Format("{0}/{1} ({2})", 
                GetType().Name,
                GetType().Assembly.GetName().Version.ToString(2), 
                GetType().Assembly.FullName);

            Callback = new CallbackService(new ServiceProxy(this, "callback"));
            Category = new CategoryService(new ServiceProxy(this, "category"));
            Client = new ClientService(new ServiceProxy(this, "client"));
            Estimate = new EstimateService(new ServiceProxy(this, "estimate"));
            Expense = new ExpenseService(new ServiceProxy(this, "expense"));
            Gateway = new GatewayService(new ServiceProxy(this, "gateway"));
            Invoice = new InvoiceService(new ServiceProxy(this, "invoice"));
            Item = new ItemService(new ServiceProxy(this, "item"));
            Language = new LanguageService(new ServiceProxy(this, "language"));
            Payment = new PaymentService(new ServiceProxy(this, "payment"));
            Project = new ProjectService(new ServiceProxy(this, "project"));
            Recurring = new RecurringService(new ServiceProxy(this, "recurring"));
            System = new SystemService(new ServiceProxy(this, "system"));
            Staff = new StaffService(new ServiceProxy(this, "staff"));
            Task = new TaskService(new ServiceProxy(this, "task"));
            Tax = new TaxService(new ServiceProxy(this, "tax"));
            TimeEntry = new TimeEntryService(new ServiceProxy(this, "time_entry"));
        }
Пример #2
0
        public void GetAllShouldReturnCorrectNumberOfPages()
        {
            var options = new DbContextOptionsBuilder <ExpensesDbContext>()
                          .UseInMemoryDatabase(databaseName: "GetAllShouldReturnCorrectNumberOfPages")
                          .Options;

            using (var context = new ExpensesDbContext(options))

            {
                var commentsService = new CommentsService(context);
                var expenseService  = new ExpenseService(context);

                expenseService.Create(new Lab2.DTOs.PostExpenseDto
                {
                    Description = "test_description",
                    Sum         = 999,
                    Location    = "test_location",
                    Date        = DateTime.Now,
                    Type        = "Food",
                    Currency    = "EUR",
                    Comments    = new List <Comment>()
                    {
                        new Comment
                        {
                            Important = true,
                            Text      = "test_comment",
                            Owner     = null
                        }
                    },
                }, null);

                var allComments = commentsService.GetAll(1, string.Empty);
                Assert.AreEqual(1, allComments.NumberOfPages);
            }
        }
Пример #3
0
 public BillsController(ApplicationDbContext context, IConfiguration config, IHttpContextAccessor httpContextAccessor)
 {
     _accountService     = new AccountService(context, config, httpContextAccessor);
     _billService        = new BillService(context, config, httpContextAccessor);
     _expenseService     = new ExpenseService(context, config, httpContextAccessor);
     _transactionService = new TransactionService(context, config, httpContextAccessor);
 }
Пример #4
0
        public void Can_Retrieve_Expenses_By_Staffs_Id()
        {
            var service       = new ExpenseService(_mockExpenseRepo.Object);
            var staffExpenses = _sampleExpenses.Where(x => x.StaffId == sampleEmployee.Id).ToList <Expense>();
            var dbExpenses    = service.GetStaffExpenses(sampleEmployee.Id);

            Assert.AreEqual(staffExpenses.Count, dbExpenses.Count);
        }
Пример #5
0
 protected void BtnSave_Click(object sender, EventArgs e)
 {
     using (var expenseService = new ExpenseService())
     {
         expenseService.UpdateCurrentMonth(DateTime.ParseExact(slcRelatedMonth.Value, "d-M-yyyy", CultureInfo.CurrentCulture), int.Parse(Request.Cookies["ClientId"].Value));
     }
     Response.RedirectPermanent(Request, "AllExpenses.aspx");
 }
            public void IdIsZero_InvalidModel_ReturnsView()
            {
                Controller.ModelState.AddModelError("Error", "Error");
                var result = Controller.AddExpense(new EditExpenseViewModel());

                Assert.IsInstanceOfType(result, typeof(ViewResult));
                ExpenseService.Verify(m => m.AddExpense(It.IsAny <EditExpenseViewModel>(), It.IsAny <string>()), Times.Never);
            }
Пример #7
0
        public DataViewUI()
        {
            InitializeComponent();

            _dataContext    = new AccountingDataContext();
            _expenseService = new ExpenseService(new ExpenseRepository(_dataContext));
            _incomeService  = new IncomeService(new IncomeRepository(_dataContext));
        }
            public void Saved_ReturnsRedirect()
            {
                ExpenseService.Setup(m => m.EditExpense(It.IsAny <EditExpenseViewModel>())).Returns(true);

                var result = Controller.EditExpense(new EditExpenseViewModel());

                Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            }
            public void NotSaved_ReturnsErrorView()
            {
                ExpenseService.Setup(m => m.EditExpense(new EditExpenseViewModel())).Returns(false);

                var result = Controller.EditExpense(new EditExpenseViewModel());

                Assert.IsInstanceOfType(result, typeof(ViewResult));
                Assert.AreEqual("Error", ((ViewResult)result).ViewName);
            }
            public void IdNotZero_ReturnsEditExpense()
            {
                var result = Controller.AddExpense(new EditExpenseViewModel {
                    ExpenseId = 1
                });

                Assert.IsInstanceOfType(result, typeof(ActionResult));
                ExpenseService.Verify(m => m.AddExpense(It.IsAny <EditExpenseViewModel>(), It.IsAny <string>()), Times.Never);
            }
Пример #11
0
        public void Create_Employee_WithDuplicateAlias()
        {
            Employee employee = this.AddRandomEmployee();

            employee.EmployeeId = 0;
            ExpenseService service = new ExpenseService();

            service.SaveEmployee(employee);
        }
Пример #12
0
        public void UpdateTest1()
        {
            var options = new DbContextOptionsBuilder <ExpensesDbContext>()
                          .UseInMemoryDatabase(databaseName: nameof(UpdateTest1))
                          .Options;

            using (var context = new ExpensesDbContext(options))
            {
                var expenseService = new ExpenseService(context);

                var addedExpense = expenseService.Create(new Lab2Expense.ViewModels.ExpensePostModel
                {
                    Description = "lksajdaksld",
                    Sum         = 1.23,
                    Location    = "sjdasjldls",
                    Date        = new DateTime(),
                    Currency    = "euro",
                    ExpenseType = "food",

                    Comments = new List <Comment>()
                    {
                        new Comment
                        {
                            Important = true,
                            Text      = "asd",
                            Owner     = null
                        }
                    },
                }, null);
                context.Entry(addedExpense).State = EntityState.Detached;
                //context.SaveChanges();
                var addedExpenseForUpdate = new Expense
                {
                    Description = "update",
                    Sum         = 1.23,
                    Location    = "update",
                    Date        = new DateTime(),
                    Currency    = "euro",
                    ExpenseType = ExpenseType.food,

                    Comments = new List <Comment>()
                    {
                        new Comment
                        {
                            Important = true,
                            Text      = "asd",
                            Owner     = null
                        }
                    },
                    Owner = null
                };

                var updateResult     = expenseService.Upsert(addedExpense.Id, addedExpenseForUpdate);
                var updateResultNull = expenseService.Upsert(2, addedExpenseForUpdate);
                //Assert.IsNull(updateResultNull);
            }
        }
Пример #13
0
        /// <summary>
        ///     Standard Default Ctor
        /// </summary>
        public InputOutUI()
        {
            InitializeComponent();

            _dataContext            = new AccountingDataContext();
            _expenseService         = new ExpenseService(new ExpenseRepository(_dataContext));
            _expenseCategoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(_dataContext));
            _paymentMethodService   = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
        }
Пример #14
0
        /// <inheritdoc />
        /// <summary>
        ///     Ctor that also sets the data member of the month being viewed
        ///     with the value given
        /// </summary>
        /// <param name="dtMonth">The month to view data for</param>
        public MonthChartUI(DateTime dtMonth)
        {
            _dtMonth = dtMonth;
            InitializeComponent();

            _dataContext    = new AccountingDataContext();
            _expenseService = new ExpenseService(new ExpenseRepository(_dataContext));
            _incomeService  = new IncomeService(new IncomeRepository(_dataContext));
        }
Пример #15
0
 public ExpensesController(
     ImportService importService,
     ExpenseService expenseService,
     ILogger <ExpensesController> logger)
 {
     _importService  = importService;
     _expenseService = expenseService;
     _logger         = logger;
 }
Пример #16
0
 public void SaveOrUpdate(ExpenseService e)
 {
     if (e.Id > 0)
     {
         _commonDao.UpdateObject(e);
         return;
     }
     _commonDao.SaveOrUpdateObject(e);
 }
Пример #17
0
        public async Task GetExpense()
        {
            const string expenseTestCode = "Test";
            var          request         = new ExpenseListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var          expense         = await ExpenseService.GetExpenseAsync(request, expenseTestCode);

            Assert.IsTrue(expense != null);
            Assert.IsTrue(expense.Code == expenseTestCode);
            Assert.IsFalse(string.IsNullOrEmpty(expense.Text));
        }
Пример #18
0
        public ExpenseReportPage(object data) : this()
        {
            var person  = data as Person;
            var service = new ExpenseService();

            person.Expenses = service.GetExpensesByPerson(person.Id).ToList();

            // Bind to expense report data.
            this.DataContext = person;
        }
            public void ReturnsView_ExpenseIndexViewModel()
            {
                ExpenseService.Setup(m => m.MapExpenseIndexViewModel(It.IsAny <string>()))
                .Returns(new ExpenseIndexViewModel());

                var result = Controller.Index();

                Assert.IsInstanceOfType(result, typeof(ViewResult));
                Assert.IsInstanceOfType(((ViewResult)result).Model, typeof(ExpenseIndexViewModel));
            }
            public void ReturnsPartialView_ExpenseTransactionsViewModel()
            {
                ExpenseService.Setup(m => m.MapExpenseTransactionsViewModel(It.IsAny <int>()))
                .Returns(new ExpenseTransactionsViewModel());

                var result = Controller.LoadExpenseTransactions(1);

                Assert.IsInstanceOfType(result, typeof(PartialViewResult));
                Assert.IsInstanceOfType(((PartialViewResult)result).Model, typeof(ExpenseTransactionsViewModel));
            }
Пример #21
0
        public void Can_Delete_Saved_Expense()
        {
            var service      = new ExpenseService(_mockExpenseRepo.Object);
            var savedExpense = _sampleExpenses[0];

            service.DeleteExpense(savedExpense.Id);
            _mockExpenseRepo.Verify(x => x.Delete(It.Is <int>(input =>
                                                              input == savedExpense.Id
                                                              )));
        }
Пример #22
0
        public ActionResult Edit(int id)
        {
            ExpenseModel mdl = new ExpenseModel();

            mdl = ExpenseService.getExpensebyId(id);
            var EmployeeList = CommanService.EmployeeNameList();

            ViewBag.EmployeeList = new SelectList(EmployeeList, "EmployeeID", "Name");
            return(View("Add", mdl));
        }
            public void ReturnsView_EditExpenseTransactionViewModel()
            {
                ExpenseService.Setup(m => m.MapEditTransactionViewModelForAdd(It.IsAny <int>(), It.IsAny <string>()))
                .Returns(new EditExpenseTransactionViewModel());

                var result = Controller.AddTransaction(1);

                Assert.IsInstanceOfType(result, typeof(PartialViewResult));
                Assert.IsInstanceOfType(((PartialViewResult)result).Model, typeof(EditExpenseTransactionViewModel));
            }
Пример #24
0
        public async Task <IActionResult> GroupedBySource()
        {
            using var service = new ExpenseService();

            var data = await service.GetGroupedBySource();

            var model = _mapper.Map <IEnumerable <SourceExpenseViewModel> >(data);

            return(PartialView(model));
        }
        protected void rptExpenseServices_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Footer)
            {
                ExpenseService service = Module.ExpenseServiceGetById(Convert.ToInt32(e.CommandArgument));
                TextBox        txtPay  = (TextBox)e.Item.FindControl("txtPay");
                double         paid;

                if (!string.IsNullOrEmpty(txtPay.Text))
                {
                    paid = Convert.ToDouble(txtPay.Text);
                }
                else
                {
                    paid = service.Cost - service.Paid;
                }

                service.Paid += paid;

                if (service.Paid == service.Cost && !service.PaidDate.HasValue)
                {
                    service.PaidDate = DateTime.Now;
                }
                var transaction = new Transaction();
                transaction.CreatedBy   = UserIdentity;
                transaction.CreatedDate = DateTime.Now;
                transaction.Agency      = service.Supplier;
                transaction.IsExpense   = true;
                transaction.VNDAmount   = paid;

                if (service.Type.IsDailyInput)
                {
                    transaction.TransactionType = Transaction.MANUALDAILY_EXPENSE;
                }
                else
                {
                    transaction.TransactionType = Transaction.CALCULATED_EXPENSE;
                }

                Module.SaveOrUpdate(transaction);
                Module.SaveOrUpdate(service);
                PageRedirect(Request.RawUrl);
            }
            else
            {
                IList list = new ArrayList();//Module.ExpenseServiceGet(null, from, to, agency, null, Request.QueryString["orgid"], UserIdentity, true, type);
                foreach (ExpenseService service in list)
                {
                    service.Paid = service.Cost;
                    Module.SaveOrUpdate(service);
                }
                rptExpenseServices.DataSource = list;
                rptExpenseServices.DataBind();
            }
        }
 public EditModel(
     BillPayService billPayService,
     PaymentService paymentService,
     ExpenseService expenseService,
     BillService billService)
 {
     _billPayService = billPayService;
     _paymentService = paymentService;
     _expenseService = expenseService;
     _billService    = billService;
 }
        public void CommentFactory_ShouldNotCallCreateComment_WhenProvidedCommentIsNullOrEmptyAndCreateExpenseIsCalled(string comment)
        {
            // Arrange
            var expenseService = new ExpenseService(unitOfWorkMock.Object, expenseRepoMock.Object, expenseCategoryRepoMock.Object, expenseFactoryMock.Object, commentFactoryMock.Object);

            // Act
            expenseService.CreateExpense("_", "_", new Guid(), new Guid(), 1M, DateTime.Now, comment, null);

            // Assert
            this.commentFactoryMock.Verify(x => x.CreateComment(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <Guid>()), Times.Never);
        }
        public void ExpenseRepository_ShouldCallAllOnce_WhenGetExpensesIsCalled()
        {
            // Arrange
            var expenseService = new ExpenseService(unitOfWorkMock.Object, expenseRepoMock.Object, expenseCategoryRepoMock.Object, expenseFactoryMock.Object, commentFactoryMock.Object);

            // Act
            expenseService.GetExpenses(new Guid(), 1, false, "_");

            // Assert
            this.expenseRepoMock.Verify(x => x.All, Times.Once);
        }
        public void GetExpenses_ShouldReturnIEumerableOfExpense_WhenIsCalled()
        {
            // Arrange
            var expenseService = new ExpenseService(unitOfWorkMock.Object, expenseRepoMock.Object, expenseCategoryRepoMock.Object, expenseFactoryMock.Object, commentFactoryMock.Object);

            // Act
            var result = expenseService.GetExpenses(new Guid(), 1, false, "_");

            // Assert
            Assert.IsInstanceOf <IEnumerable <Expense> >(result);
        }
        public void GetExpensesCount_ShouldReturnInt_WhenItIsCalled()
        {
            // Arrange
            var expenseService = new ExpenseService(unitOfWorkMock.Object, expenseRepoMock.Object, expenseCategoryRepoMock.Object, expenseFactoryMock.Object, commentFactoryMock.Object);

            // Act
            var result = expenseService.GetExpensesCount();

            // Assert
            Assert.IsInstanceOf <int>(result);
        }
        public void ExpenseRepository_ShouldCallGetAllOnce_WhenGetExpensesCountIsCalled()
        {
            // Arrange
            var expenseService = new ExpenseService(unitOfWorkMock.Object, expenseRepoMock.Object, expenseCategoryRepoMock.Object, expenseFactoryMock.Object, commentFactoryMock.Object);

            // Act
            expenseService.GetExpensesCount();

            // Assert
            this.expenseRepoMock.Verify(x => x.GetAll(), Times.Once);
        }
Пример #32
0
 public ServiceList(string url, ResponseToken token)
 {
     this.eventService = new EventService(url, token);
     this.categoryService = new CategoryService(url, token);
     this.clubService = new ClubService(url, token);
     this.userService = new UserService(url, token);
     this.ticketService = new TicketService(url, token);
     this.meetingService = new MeetingService(url, token);
     this.invoiceService = new InvoiceService(url, token);
     this.groupService = new GroupService(url, token);
     this.expenseService = new ExpenseService(url, token);
     this.emailService = new EmailService(url, token);
     this.depositService = new DepositService(url, token);
     this.customFieldService = new CustomFieldService(url, token);
     this.taskService = new TaskService(url, token);
     this.contactService = new ContactService(url, token);
 }