Esempio n. 1
0
        private async Task PrepareToInputNewExpense(int flowId, bool correcting, string returnPage)
        {
            await PrepareModels(flowId);

            var flow = correcting || flowId == 0 ? null : await _expenseFlowQueries.GetById(flowId);

            Expense = new EditExpense
            {
                Correction = correcting,
                FlowId     = flowId,
                Account    = Accounts.GetDefaultAccount()?.Name,
                FlowName   = flow?.Name,
                DateTime   = _timeService.ClientLocalNow.ToStandardString(),
                Cost       = string.Empty,
                ReturnPage = returnPage,
            };
            if (Categories.Count == 1)
            {
                Expense.Category = Categories.First().Name;
            }

            if (correcting)
            {
                var balanceState = await _inventorizationQueries.GetBalanceState();

                if (balanceState.Balance < 0)
                {
                    Expense.Cost = (-balanceState.Balance).ToStandardString();
                }
            }
        }
Esempio n. 2
0
        public async Task OnGetAsync(int billId)
        {
            Bill = await _expensesBillQueries.GetById(billId);

            ExpenseFlow = await _expenseFlowQueries.GetById(Bill.ExpenseFlowId);

            Account = Bill.AccountId != null ? await _accountQueries.GetById(Bill.AccountId.Value) : null;

            Day    = Bill.DateTime.Date.ToStandardString();
            BillId = Bill.Id;
        }
Esempio n. 3
0
        public async Task <IActionResult> OnPostCommitAsync()
        {
            return(await ExpenseFlow.ProcessAsync(ModelState, nameof(ExpenseFlow),
                                                  async() =>
            {
                var model = await _expenseFlowQueries.GetById(ExpenseFlow.Id);
                ExpenseFlow.ToExpenseFlowModel(model);
                await _expenseFlowCommands.Update(model);
                return RedirectToPage("./ExpenseFlows");
            },

                                                  async() =>
            {
                await LoadCategories();
                return Page();
            }));
        }
Esempio n. 4
0
        private async Task LoadModelsAsync(int expenseId)
        {
            Flow = await _expenseFlowQueries.GetById(expenseId);

            Accounts = await _accountQueries.GetAll();
        }