Beispiel #1
0
        private void Save_Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (vm.IsAddMode)
                {
                    // Store Initial Deposit info or will be lost on account save
                    decimal?amount = vm.Account.InitialBalance;

                    // Save Account without transaction to get an AccountId
                    vm.OGAccount = accountsOM.SaveAccount(vm.Account);

                    // Create Initial Transaction and update the account with it's info
                    if (amount.HasValue)
                    {
                        InitialDeposit = new TransactionSaveInfo()
                        {
                            Amount            = amount.Value,
                            DateTime_Occurred = vm.Account.DateTime_Created,
                            FromAccount       = vm.SelectedFromAccount,
                            IsConfirmed       = true,
                            IsUserCreated     = false,
                            Title             = "Initial Deposit",
                            OccerrenceAccount = null,
                            ToAccount         = vm.Account.AccountId,
                            TransactionType   = TransactionType.Deposit,
                            Notes             = $"Initial Deposit for {vm.Account.AccountName} {Constants.Accounts.GetDisplay(vm.Account.AccountType)}"
                        };

                        TransactionDetailBase savedTransaction = transactionsOM.SaveTransaction(InitialDeposit);

                        vm.Account.InitialBalance          = savedTransaction.Amount;
                        vm.Account.InitialDepositAccountId = savedTransaction.FromAccount.AccountId;
                        vm.Account.InitialDepositId        = savedTransaction.TransactionId;

                        vm.OGAccount = accountsOM.SaveAccount(vm.Account);
                    }
                }
                else
                {
                    if (vm.IsDirty)
                    {
                        vm.OGAccount = accountsOM.SaveAccount(vm.Account);
                    }
                }

                this.Close();
            }
            catch (Exception ex)
            {
                //todo: add error logging
            }
        }
 public Transaction(TransactionSaveInfo saveModel)
 {
     LocalId           = saveModel.TransactionId;
     Title             = saveModel.Title;
     Amount            = saveModel.Amount;
     ToAccount         = saveModel.ToAccount;
     FromAccount       = saveModel.FromAccount;
     DateTime_Occurred = saveModel.DateTime_Occurred;
     TransactionType   = Constants.Transactions.GetDisplay(saveModel.TransactionType).TypeName;
     IsUserCreated     = saveModel.IsUserCreated;
     IsConfirmed       = saveModel.IsConfirmed;
     OccerrenceAccount = saveModel.OccerrenceAccount;
     Notes             = saveModel.Notes;
 }
Beispiel #3
0
 private void Save_Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (IsAddMode)
         {
             var amount = Account.InitialBalance.HasValue ? Account.InitialBalance.Value : 0.0M;
             InitialDeposit = new TransactionSaveInfo()
             {
                 Amount            = amount,
                 DateTime_Occurred = Account.DateTime_Created,
                 FromAccount       = vm.SelectedFromAccount,
                 IsConfirmed       = true,
                 IsUserCreated     = false,
                 Title             = "Default Cash Account Initial Deposit",
                 OccerrenceAccount = null,
                 ToAccount         = Account.AccountId,
                 TransactionType   = TransactionType.Deposit
             };
             if (InitialDeposit.Amount != 0)
             {
                 transactionsOM.SaveTransaction(InitialDeposit);
             }
         }
         else
         {
             if (Account != OGAccount)
             {
                 OGAccount = accountsOM.SaveAccount(Account);
             }
         }
         this.Close();
     }
     catch (Exception ex)
     {
         //todo: add error logging
     }
 }
Beispiel #4
0
        internal TransactionDetailBase SaveTransaction(TransactionSaveInfo transaction)
        {
            var result = Repo.SaveTransaction(new Transaction(transaction));

            return(new TransactionDetailBase(result, AccountsOM));
        }