Beispiel #1
0
        private BankAccountDetailVM CreateDefaultCashAccount()
        {
            BankAccountDetailVM cash = null;

            var shouldCreate = MessageBox.Show("Would you like to create an account to track your cash?", "Welcome", MessageBoxButton.YesNo);

            if (shouldCreate == MessageBoxResult.Cancel || shouldCreate == MessageBoxResult.No)
            {
                MessageBox.Show("If you change your mind you'll have to manually make a cash account later.",
                                button: MessageBoxButton.OK,
                                caption: MiscConstants.AppName);
            }
            else if (shouldCreate == MessageBoxResult.Yes)
            {
                cash = new BankAccountDetailVM()
                {
                    AccountName         = Accounts.DefaultCashAccountName,
                    InitialDepositId    = null,
                    IsActiveCashAccount = true,
                    IsDefault           = true,
                    Notes            = "Physical Money",
                    DateTime_Created = DateTime.UtcNow,
                };
                cash = AccountOverMind.SaveAccount(cash);
            }
            else
            {
                throw new Exception("WTF! options shouldn't exist!");
            }

            return(cash);
        }
 public BankAccountDetail()
 {
     InitializeComponent();
     ModuleName = "BankAccountSetting";
     VM = new BankAccountDetailVM();
     BindData();
 }
 public BankAccountDetail(PageMode pageMode, int accountId)
     : base(pageMode, Properties.Resources.BankAccount)
 {
     InitializeComponent();
     ModuleName = "BankAccountSetting";
     VM = new BankAccountDetailVM(accountId);
     BindData();
 }
Beispiel #4
0
 public DepositAccount(BankAccountDetailVM accountDetailVM)
 {
     LocalId             = accountDetailVM.DepositAccountId;
     AccountId           = accountDetailVM.AccountId;
     InitialDepositId    = accountDetailVM.InitialDepositId;
     IsActiveCashAccount = accountDetailVM.IsActiveCashAccount;
     IsDefault           = accountDetailVM.IsDefault;
 }
Beispiel #5
0
        public ManageBankAccountVM GetEditBankAccountVM(int?id)
        {
            BankAccountDetailVM bankAccount;

            if (id.HasValue)
            {
                bankAccount = GetBankAccountById(id.Value);
            }
            else
            {
                bankAccount = new BankAccountDetailVM();
            }

            return(new ManageBankAccountVM()
            {
                Account = bankAccount,
                IsEditMode = id.HasValue,
                FromAccounts = GetDepositFromList()
            });
        }
Beispiel #6
0
        internal BankAccountDetailVM SaveAccount(BankAccountDetailVM account)
        {
            // Is this a new account?
            if (account.AccountId == 0)
            {
                // Create the base account to get an accountId
                AccountDetailVM baseAccount = SaveAccount((AccountDetailVM)account);
                account.AccountId = baseAccount.AccountId;

                // Add an initial deposit transaction
                //maybe this needs to go? merge conflict but seems liek should be here
                if (account.InitialBalance.HasValue)
                {
                    var initialD = Repo.SaveTransaction(new Transaction(new TransactionSaveInfo()
                    {
                        Amount            = account.InitialBalance.Value,
                        IsConfirmed       = true,
                        IsUserCreated     = true,
                        Notes             = $"Initial Deposit for {account.AccountName} {Constants.Accounts.GetDisplay(account.AccountType)}",
                        DateTime_Occurred = account.DateTime_Created,
                        Title             = "Initial Deposit",
                        ToAccount         = account.AccountId,
                        TransactionType   = Constants.TransactionType.Deposit,
                        FromAccount       = account.DepositAccountId
                    }));
                    account.InitialDepositId = initialD.LocalId;
                }
                //end merge conflict question code
            }


            var         result      = Repo.SaveAccount(new DepositAccount(account));
            Transaction transaction = null;

            if (result.InitialDepositId.HasValue)
            {
                transaction = Repo.GetTransactionById(result.InitialDepositId.Value);
            }
            return(new BankAccountDetailVM(account, result, transaction));
        }