示例#1
0
        public ManageIncSourceVM GetManageIncSourceVM(int?id)
        {
            IncomeSourceDetailVM incSource;

            if (id.HasValue)
            {
                incSource = GetIncomeSourceById(id.Value);
            }
            else
            {
                incSource = new IncomeSourceDetailVM();
            }

            List <AccountComboBoxItem> tos = GetAccountComboBoxItem(new List <string>()
            {
                Constants.Accounts.BankAccount.TypeName
            });

            return(new ManageIncSourceVM()
            {
                Account = incSource,
                IsEditMode = id.HasValue,
                ToAccounts = tos,
                Frequencies = Frequency.GetFrequencyComboBoxItems(),
                SelectedFrequency = (int?)incSource.Schedule?.Frequency ?? 0,
                SelectedToAccount = incSource?.DefaultToAccountId
                                    ?? (tos.GetDefaultAccount() ?? 0)
            });
        }
 public IncomeSource(IncomeSourceDetailVM source)
 {
     LocalId            = source.IncomeSourceId;
     AccountId          = source.AccountId;
     DefaultToAccountId = source.DefaultToAccountId;
     ExpectedAmount     = source.ExpectedAmount;
     ScheduleId         = source.Schedule?.ScheduleId;
 }
示例#3
0
        internal IncomeSourceDetailVM SaveAccount(IncomeSourceDetailVM account)
        {
            AccountDetailVM baseAccount = SaveAccount((AccountDetailVM)account);

            account.AccountId = baseAccount.AccountId;
            IncomeSource result          = Repo.SaveAccount(new IncomeSource(account));
            Schedule     accountSchedule = null;

            if (result.ScheduleId.HasValue)
            {
                accountSchedule = Repo.GetSchedule(result.ScheduleId.Value);
            }

            return(new IncomeSourceDetailVM(result, baseAccount, accountSchedule));
        }
示例#4
0
        private IncomeSourceDetailVM CreateDoNotTrackIncomeSource()
        {
            IncomeSourceDetailVM nullSource = new IncomeSourceDetailVM()
            {
                AccountName        = Accounts.DefaultIncomeSourceAccountName,
                Schedule           = null,
                DefaultToAccountId = null,
                ExpectedAmount     = 0,
                TotalFromSource    = 0,
                DateTime_Created   = DateTime.UtcNow,
                Notes = "Default account placeholder for when income source data is not tracked seperately. Info kept for checks and balances",
            };

            nullSource = AccountOverMind.SaveAccount(nullSource);
            if (nullSource.IncomeSourceId == 0)
            {
                throw new Exception("System worked but not saving the null source....");
            }
            AccountOverMind.SetAccountToSystem(nullSource.AccountId);
            return(nullSource);
        }