Exemplo n.º 1
0
        public IHttpActionResult Get(DateTime coolDate)
        {
            IncomeService incomeService = CreateIncomeService();
            var           incomes       = incomeService.GetIncomeByMonth(coolDate);

            return(Ok(incomes));
        }
Exemplo n.º 2
0
        // GET: Income
        public IHttpActionResult GetAll()
        {
            IncomeService incomeService = CreateIncomeService();
            var           incomes       = incomeService.GetIncome();

            return(Ok(incomes));
        }
Exemplo n.º 3
0
        public IHttpActionResult Get(int id)
        {
            IncomeService incomeService = CreateIncomeService();
            var           incomes       = incomeService.GetIncomeByID(id);

            return(Ok(incomes));
        }
Exemplo n.º 4
0
        public void Can_Get_Staff_From_Income()
        {
            var service = new IncomeService(_mockIncomeRepository.Object);
            var income  = service.GetIncome(_sampleIncomes[0].Id);

            Assert.AreEqual(sampleManager.Name, income.Staff.Name);
        }
Exemplo n.º 5
0
        // GET: TrialBalance
        public ActionResult Index()
        {
            var unitOfWork          = new UnitOfWork();
            var accountService      = new AccountService(unitOfWork);
            var incomeService       = new IncomeService(unitOfWork);
            var incomeDetailService = new IncomeDetailService(unitOfWork);

            var trialBalanceList = new List <TrialBalanceViewModel>();

            foreach (var income in incomeService.GetAll())
            {
                var payment       = accountService.Find(income.PaymentAccountId);
                var incomeDetails = incomeDetailService.Filter(o => o.IncomeId == income.Id).ToList();
                var amount        = incomeDetails.Sum(o => o.Price);

                trialBalanceList = CheckExistingAccount(trialBalanceList, amount, payment, true);

                foreach (var incomeDetail in incomeDetails)
                {
                    var incomeAccount = accountService.Find(incomeDetail.IncomeAccountId);

                    trialBalanceList = CheckExistingAccount(trialBalanceList, incomeDetail.Price, incomeAccount, false);
                }
            }

            return(View(trialBalanceList.OrderBy(o => o.AccountNo)));
        }
Exemplo n.º 6
0
 public CollectionOrchestration(IIncomeRepository incomeRepository, ISavingsTransactionRepository savingsTransactionRepository, IncomeService incomeService, SavingsService savingsService)
 {
     _incomeRepository             = incomeRepository;
     _savingsTransactionRepository = savingsTransactionRepository;
     _incomeService  = incomeService;
     _savingsService = savingsService;
 }
        public EditTransactionPage(CategoryType type, TransactionDto dto, Action refresh)
        {
            InitializeComponent();
            _type            = type;
            _expenseService  = new ExpenseService();
            _incomeService   = new IncomeService();
            _categoryService = new CategoryService();
            _dto             = dto;
            _refresh         = refresh;

            Date.Date        = dto.Date;
            Description.Text = dto.Description;
            Value.Text       = dto.Value.ToString("F2");


            switch (type)
            {
            case CategoryType.ExpenseCategory:
                Title = "Edit expense";
                break;

            case CategoryType.IncomeCategory:
                Title = "Edit income";
                break;
            }
        }
Exemplo n.º 8
0
        public void Can_Retrieve_All_Saved_Income()
        {
            var service   = new IncomeService(_mockIncomeRepository.Object);
            var allIncome = service.GetAllIncome();

            Assert.AreEqual(4, allIncome.Count);
        }
Exemplo n.º 9
0
 public IncomesPage()
 {
     InitializeComponent();
     _incomeService = new IncomeService();
     DateFrom.Date  = DateTime.Now.AddMonths(-1);
     DateTo.Date    = DateTime.Now;
 }
        public async Task IncomeService_Updates_Wallet_Updated_Income_Increase()
        {
            DateTime now = DateTime.UtcNow;

            UserModel user = new UserModel("Test User", new DateTime(), "*****@*****.**", "password", api.Enums.Currency.Euro);

            user._id  = "1234567891234567891234";
            user.Role = "user";

            WalletModel wallet = new WalletModel("Unit Test", 0, true, 100, null, api.Enums.WalletColor.Green, now);

            wallet._id = "1234567891234567891234";
            wallet.DateOffsetBalance = new List <DateOffsetBalance>();
            wallet.DateOffsetBalance.Add(new DateOffsetBalance(DateTime.UtcNow, 100));

            user.Wallets.Add(wallet);

            IncomeModel oldIncome = new IncomeModel(user._id, wallet._id, 100, DateTime.UtcNow, "unit test");
            IncomeModel newIncome = new IncomeModel(user._id, wallet._id, 120, DateTime.UtcNow, "unit test");

            IncomeService service   = new IncomeService();
            WalletModel   newWallet = await service.UpdateWalletForUpdatedIncome(user, newIncome, oldIncome);

            newWallet.Balance.Should().Be(120);
            newWallet.LastUpdated.Should().NotBeOnOrBefore(now);
            newWallet.DateOffsetBalance.Should().NotBeNull();
        }
Exemplo n.º 11
0
        private IncomeService CreateIncomeService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new IncomeService(userId);

            return(service);
        }
Exemplo n.º 12
0
 public SavesViewModel()
 {
     InSrvc  = new IncomeService();
     OutSrvc = new OutcomeService();
     loadIncomes();
     loadOutcomes();
     calculateCommand = new CommandManager(loadTotal);
 }
Exemplo n.º 13
0
        public DataViewUI()
        {
            InitializeComponent();

            _dataContext    = new AccountingDataContext();
            _expenseService = new ExpenseService(new ExpenseRepository(_dataContext));
            _incomeService  = new IncomeService(new IncomeRepository(_dataContext));
        }
Exemplo n.º 14
0
 public MainForm()
 {
     InitializeComponent();
     settingService = new SettingService();
     incomeService  = new IncomeService(new Dummy());
     InitProvider();
     UpdateData();
 }
Exemplo n.º 15
0
        /// <summary>
        ///     Standard Default Ctor
        /// </summary>
        public InputINUI()
        {
            InitializeComponent();

            _dataContext           = new AccountingDataContext();
            _incomeCategoryService = new IncomeCategoryService(new IncomeCategoryRepository(_dataContext));
            _paymentMethodService  = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
            _incomeService         = new IncomeService(new IncomeRepository(_dataContext));
        }
Exemplo n.º 16
0
 public IncomesViewModel()
 {
     InSrvc = new IncomeService();
     loadIncomes();
     loadTotal();
     CurrentIncome          = new MoneyDTO();
     CurrentIncome.Duration = 1;
     addCommand             = new CommandManager(Add);
 }
        public Result <IList <Income> > GetAll(int plannerId)
        {
            var           result        = new Result <IList <Income> >();
            IncomeService incomeService = new IncomeService();

            result.Value     = incomeService.GetAll(plannerId);
            result.IsSuccess = true;
            return(result);
        }
Exemplo n.º 18
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));
        }
        public Result <Income> Get(int id, int plannerId)
        {
            var           result        = new Result <Income>();
            IncomeService IncomeService = new IncomeService();

            result.Value     = IncomeService.GetById(id, plannerId);
            result.IsSuccess = true;
            return(result);
        }
Exemplo n.º 20
0
        public void Can_Delete_Saved_Income()
        {
            var service     = new IncomeService(_mockIncomeRepository.Object);
            var savedIncome = _sampleIncomes[0];

            service.DeleteIncome(savedIncome.Id);
            _mockIncomeRepository.Verify(x => x.Delete(It.Is <int>(input =>
                                                                   input == savedIncome.Id)
                                                       ));
        }
Exemplo n.º 21
0
        public void Can_Get_Annual_Income_From_Saved_Incomes()
        {
            var service      = new IncomeService(_mockIncomeRepository.Object);
            var yearlyIncome = service.GetYearlyIncome();
            var currentYear  = DateTime.Now.Year.ToString();
            var allKeys      = yearlyIncome.Keys;
            var sampleSum    = _sampleIncomes[0].Amount + _sampleIncomes[1].Amount;

            Assert.IsTrue(allKeys.Contains(currentYear));
            Assert.AreEqual(sampleSum, yearlyIncome[currentYear]);
        }
Exemplo n.º 22
0
        /// <summary>
        ///     Sets the intial state and current state expense properties of the form
        /// </summary>
        /// <param name="income">The income the form was opened for</param>
        public IncomeViewer(Income income)
        {
            InitializeComponent();

            currentIncome  = income;
            originalIncome = currentIncome.Copy();

            _dataContext           = new AccountingDataContext();
            _incomeService         = new IncomeService(new IncomeRepository(_dataContext));
            _incomeCategoryService = new IncomeCategoryService(new IncomeCategoryRepository(_dataContext));
            _paymentMethodService  = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
        }
Exemplo n.º 23
0
        public IHttpActionResult Delete(int id)
        {
            bool result = new IncomeService().Remove(id);

            if (result)
            {
                return(Ok());
            }
            else
            {
                return(Conflict());
            }
        }
Exemplo n.º 24
0
        public void Can_Save_New_Income()
        {
            Income newIncome = new Income(
                "AnyIncome",
                23000,
                "any-stffs-id-12ert"
                );
            var service = new IncomeService(_mockIncomeRepository.Object);

            service.CreateIncome(newIncome);
            _mockIncomeRepository.Verify(x => x.Create(It.Is <Income>(inc =>
                                                                      inc.Description == "AnyIncome"
                                                                      )));
        }
Exemplo n.º 25
0
        public void Can_Update_Saved_Income()
        {
            Income newIncome = _sampleIncomes[0];
            var    service   = new IncomeService(_mockIncomeRepository.Object);

            service.CreateIncome(newIncome);
            _mockIncomeRepository.Verify(x => x.Update(It.Is <Income>(
                                                           inc => inc.Description == newIncome.Description &&
                                                           inc.Amount == newIncome.Amount &&
                                                           inc.StaffId == newIncome.StaffId &&
                                                           inc.Staff == newIncome.Staff &&
                                                           inc.Id == newIncome.Id))
                                         );
        }
Exemplo n.º 26
0
        /// <summary>
        /// 计算结余金额
        /// </summary>
        private void balance()
        {
            if (cmb_custName.SelectedValue != null & cmb_custName.Text != "")
            {
                var incomeMoney = new IncomeService().incomes().Where(w => w.CustormerID.ToString()
                                                                      == cmb_custName.SelectedValue.ToString()).Sum(i => i.Money);
                var amountOfPayout = new WeighingRegisterService().weighingSettlements().Where
                                         (w => w.CustmerCode.ToString() == cmb_custName.SelectedValue.ToString()).Sum(i => i.settleAmount);

                //注意判断txt_money.Text==""而不是判断txt_money.Text==null,否则三无运算会报错,
                //因为无法把""值转为double
                double settleAount = txt_money.Text == "" ? 0 : Convert.ToDouble(txt_money.Text);
                lbl_balance.Text = (incomeMoney - amountOfPayout - settleAount).ToString("C");
            }
        }
Exemplo n.º 27
0
        public void Can_Get_Monthly_Income_From_Saved_Incomes()
        {
            var service = new IncomeService(_mockIncomeRepository.Object);
            Dictionary <string, int> monthlyIncomes = service.GetMonthlyIncome();
            var allKeys      = monthlyIncomes.Keys;
            var currentMonth = DateTime.Now.Month;

            var testKey = _sampleIncomes[0].DateCreated.Month.ToString();

            Assert.IsTrue(allKeys.Contains(testKey));

            var testSum = _sampleIncomes[0].Amount + _sampleIncomes[1].Amount;

            Assert.AreEqual(testSum, monthlyIncomes[testKey]);
        }
Exemplo n.º 28
0
        public IHttpActionResult GetIncomes(int id, string startDate, string endDate)
        {
            var dstartDate = DateTime.ParseExact(startDate, "dd/MM/yyyy",
                                                 System.Globalization.CultureInfo.InvariantCulture);
            var dendDate = DateTime.ParseExact(startDate, "dd/MM/yyyy",
                                               System.Globalization.CultureInfo.InvariantCulture);

            var completeIncomeList = IncomeService.GetByConsortiumId(id, dstartDate, dendDate);

            if (completeIncomeList == null)
            {
                throw new NotFoundException(ErrorMessages.IngresoNoEncontrado);
            }

            return(Ok(completeIncomeList));
        }
Exemplo n.º 29
0
        public async void LoadIncomeList()
        {
            try
            {
                InternetConnectionHelper.GetInstance().CheckConnection();
                IsRunning = true;
                var user    = MainViewModel.GetInstance().GetUser;
                var incomes = await IncomeService
                              .GetInstance()
                              .FindAllByUser(user.Id);

                var incomes_aux = incomes
                                  .Select(x => new IncomeItemSelectedViewModel
                {
                    Id     = x.Id,
                    Amount = x.Amount,
                    Date   = x.Date
                });
                Incomes =
                    new ObservableCollection <IncomeItemSelectedViewModel>(incomes_aux);
                IsRunning = false;
            }
            catch (ErrorResponseServerException e)
            {
                await App.Current.MainPage.DisplayAlert("Advertencia", e.Message, "Aceptar");

                IsRunning = false;
            }
            catch (WarningResponseServerException e)
            {
                await App.Current.MainPage.DisplayAlert("Advertencia", e.Message, "Aceptar");

                IsRunning = false;
            }
            catch (NoInternetConnectionException e)
            {
                await App.Current.MainPage.DisplayAlert("Advertencia", e.Message, "Aceptar");

                IsRunning = false;
            }
            catch (Exception e)
            {
                await App.Current.MainPage.DisplayAlert("Error", e.Message, "Aceptar");

                IsRunning = false;
            }
        }
        public Result Delete(Income Income)
        {
            var result = new Result();

            try
            {
                IncomeService IncomeService = new IncomeService();
                IncomeService.Delete(Income);
                result.IsSuccess = true;
            }
            catch (Exception exception)
            {
                result.IsSuccess     = false;
                result.ExceptionInfo = exception;
            }
            return(result);
        }