//Get:Checking/Transaction/5 public async Task <IActionResult> Transaction(int?id, string error, DateTime?start, DateTime?end) { if (id == null) { return(NotFound()); } if (start == null) { start = DateTime.Today; } if (end == null) { end = DateTime.Today; } var checking = await DAL.FetchAccount(id); List <Transactions> list = await DAL.FetchTransList(id, start, end); AccountTransactions trans = new AccountTransactions() { Ac = checking, List = list, Start = start, End = end }; ViewData["error"] = error; return(View(trans)); }
public static bool Insert(AccountTransactions objTransaction) { ISalesPOSDBManager dbManager = new SalesPOSDBManager(); Boolean chk = false; try { dbManager.Open(); IDbDataParameter[] param = SalesPOSDBManagerFactory.GetParameters(dbManager.ProviderType, 9); param[0] = dbManager.getparam("@account_number", objTransaction.AccountHolderCode); param[1] = dbManager.getparam("@account_head_id", objTransaction.AccountHead); param[2] = dbManager.getparam("@bill_type", ""); param[3] = dbManager.getparam("@bill_amount", objTransaction.BillAmount); param[4] = dbManager.getparam("@paid_amount", objTransaction.PaidAmount); param[5] = dbManager.getparam("@ref_number", objTransaction.RefNumber); param[6] = dbManager.getparam("@remarks", objTransaction.Remarks); param[7] = dbManager.getparam("@transactionDate", ""); param[8] = dbManager.getparam("@creator", ""); IDbCommand cmd = dbManager.getCommand(CommandType.StoredProcedure, "USP_accountTransactions_Add", param); chk = dbManager.ExecuteQuery(cmd); } catch (Exception ex) { return(false); } finally { dbManager.Dispose(); } return(chk); }
public bool Withdraw(ITransaction transaction) { if ((Balance - transaction.Amount) < 0 && Type == TypeFactory.CheckingAccount) { return(false); } else if ((Balance - transaction.Amount) < 0 && Type == TypeFactory.BusinessAccount) { if (OverDraftLoan == null) { OverDraftLoan = new BankLoan(.1, transaction.Amount - Balance, TypeFactory.GenerateLoanID(), TypeFactory.OverdraftLoan); AccountLoans.Add(OverDraftLoan); AccountTransactions.Add(transaction); Balance = 0; } else { OverDraftLoan.Amount += transaction.Amount; AccountLoans.Add(OverDraftLoan); } } else { Balance -= transaction.Amount; AccountTransactions.Add(transaction); } return(true); }
public bool Withdraw(ITransaction transaction) { if ((Balance - transaction.Amount) < 0) { return(false); } else if ((Balance - transaction.Amount) > 0 && (DateTime.Now < DateOfMaturity)) { if (((transaction.Amount * PenaltyInterestRate) + transaction.Amount) > Balance) { TotalPenalty = transaction.Amount * PenaltyInterestRate; transaction.Amount = Balance - transaction.Amount * PenaltyInterestRate; Balance = 0; AccountTransactions.Add(transaction); } else { Balance -= (transaction.Amount * PenaltyInterestRate) + transaction.Amount; TotalPenalty += transaction.Amount * PenaltyInterestRate; AccountTransactions.Add(transaction); } } else { Balance -= transaction.Amount; AccountTransactions.Add(transaction); } return(true); }
private void AddTransaction(AccountTransactions trans) { //Take the transaction and put it into the grid _transactionGrid.Rows.Insert(0, 1); DataGridViewRow row = _transactionGrid.Rows[0]; row.Cells[_columns["Date"]].Value = trans.TransactionDate.ToShortDateString(); row.Tag = trans.ID; row.Cells[_columns["Description"]].Value = trans.Description; if (trans.Balanced) { row.Cells[_columns["Amount"]].Style.BackColor = Color.LightGray; row.Cells[_columns["Amount"]].ToolTipText = "Balanced here"; _lastBalanced = trans.TransactionDate; } foreach (Transaction t in trans.Transactions) { row.Cells[_columns[t.TransactionBudget]].Value = Math.Round(t.Amount / 100.0, 2); _budget[t.TransactionBudget] += t.Amount; if (t.Amount < 0) { row.Cells[_columns[t.TransactionBudget]].Style.ForeColor = Color.Red; } //keep track of the budget totals _budget["Amount"] += t.Amount; } //populate the running total row.Cells[_columns["Amount"]].Value = Math.Round(_budget["Amount"] / 100.0, 2); }
private void _transaction_TransactionEdited(AccountTransactions trans) { _dataAccess.UpdateTransaction(trans); _dataAccess.ReadTransactions(_accountDesc.CurrentAccount); InitialiseGrid(); FillGrid(); }
public void Save(AccountTransaction accountTransaction) { using (var core = new StandardBusinessLayer(this)) { core.Connect(); bool newTransaction = accountTransaction.No == 0; core.Save(accountTransaction); if (newTransaction) { AccountTransactions.Add(accountTransaction); } else { for (int i = 0; i < AccountTransactions.Count(); i++) { if (AccountTransactions[i].No == accountTransaction.No) { AccountTransactions[i] = accountTransaction; break; } } } FillVerification(Verifications.First(v => v.No == accountTransaction.VerificationNo)); } }
// GET: Accounts/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Account account = db.Accounts.Find(id); if (account == null) { return(HttpNotFound()); } else { var transactions = account.Transactions.ToList(); var viewModel = new AccountTransactions { Account = account, Transactions = transactions }; return(View(viewModel)); } //return View(account); }
public async Task <IActionResult> AddAccountTransactions([FromBody] AccountTransactions accountTransactionsRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var accountTransactions = new AccountTransactions { AccountId = accountTransactionsRequest.AccountId, TransactionAmount = accountTransactionsRequest.TransactionAmount, TransactionType = accountTransactionsRequest.TransactionType, TransactionDate = accountTransactionsRequest.TransactionDate }; var response = await _accountTransactionsService.AddAccountTransactions(accountTransactions); return(Ok(response)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex)); // throw; // Add logger and exception filter to remove try catch } }
public int GenerateAccontTransactionId() { if (AccountTransactions.Count > 0) { return(AccountTransactions.Max(c => c.AccountTransactionId) + 1); } return(1); }
public void Save() { foreach (var account in Accounts) { account.TotalAmount = AccountTransactions.Where(c => c.AccountId == account.AccountId).Sum(c => c.Amount); } write(); }
public override void deposit(string description, double depositAmount) { //create transaction Transaction transaction = new Transaction("Deposit", description, DateTime.Now.ToString("M-dd-yyyy/HH:mm:ss"), depositAmount); //add transactions to checking account List AccountTransactions.Add(transaction); balance += Math.Round(depositAmount, 2); }
internal static void PendingTransaction(int acctId, int tranId) { ApplicationDbContext _db = new ApplicationDbContext(); AccountTransactions acctTran = _db.AccountTransactions.Where(a => a.tranId == tranId).First <AccountTransactions>(); acctTran.pending = false; _db.Entry(acctTran).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); }
public override void withdraw(string description, double withdrawAmount) { //create transaction Transaction transaction = new Transaction("Withdraw", description, DateTime.Now.ToString("M-dd-yyyy/HH:mm:ss"), withdrawAmount); //add transactions to savings account List AccountTransactions.Add(transaction); balance -= Math.Round(withdrawAmount, 2); }
public AccountTransactions GetTransactionsBeforeDate(int accountId, DateTime asOfDate) { var tableTransactions = m_db.Query <TableAccountTransactions>( @"select * from dbo.AccountTransactions where account_id = @0 and transaction_time >= @1 ORDER BY transaction_time", accountId, asOfDate); var rt = new AccountTransactions(tableTransactions); return(rt); }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { int id = Convert.ToInt32(_transactionGrid.Rows[_transactionGrid.SelectedCells[0].RowIndex].Tag); AccountTransactions t = _dataAccess.GetTransaction(id); _transaction.EditTransaction(t); //Reload Data InitialiseGrid(); FillGrid(); }
public void DeleteStockTransaction(int stockTransactionId) { var stockTransaction = GetStockTransaction(stockTransactionId); if (AccountTransactions.Any(c => c.AccountTransactionId == stockTransaction.AccountTransactionId)) { AccountTransactions.Remove(AccountTransactions.First(c => c.AccountTransactionId == stockTransaction.AccountTransactionId)); } StockTransactions.Remove(stockTransaction); Save(); }
public void Setup() { _fileSystem = new FileSystem(); if (!Directory.Exists(SafeDepositLocationDirectory)) { Directory.CreateDirectory(SafeDepositLocationDirectory); } SetTransactions(); _accountTransactions = new AccountTransactions(_fileSystem); }
private void AddTransactionHistory(TransactionType transactionType, decimal amount, string remarks = "", string accountNumberReceiver = "") { if (AccountTransactions == null) { AccountTransactions = new List <Transaction>(); } Transaction trans = new Transaction(Id, transactionType, amount, accountNumberReceiver, remarks); AccountTransactions.Add(trans); }
private void Populate(AccountResource account) { try { IJKEService channel = ServiceManager.GetChannel(); TransactionResource[] transactions = channel.GetTransactionsForAccount(account.UserName, account.Type); AccountTransactions data = new AccountTransactions(account, transactions); this.DataContext = data; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <bool> UpdateAccountTransactions(AccountTransactions accountTransactions) { try { _context.AccountTransaction.Update(accountTransactions); await _context.SaveChangesAsync(); return(true); } catch (Exception) { throw; } }
internal static void AddTransaction(int acctId, int tranType, string tranDesc, decimal tranAmount, int acctType, Boolean pending) { ApplicationDbContext _db = new ApplicationDbContext(); //I also have a sproc for this ymb_Add_Account_Transaction decimal prevBal = GetCurrentAccountBalance(acctId); decimal newBal = GetAccountNewBalance(tranAmount, prevBal, tranType, acctType); AccountTransactions newTran = new AccountTransactions() { acctId = acctId, tranAmount = tranAmount, tranDesc = tranDesc, tranType = tranType, tranDate = DateTime.Now, acctBalance = newBal, pending = pending }; _db.AccountTransactions.Add(newTran); //_db.AccountTransactions.SqlQuery(String.Format("EXEC ymb_Add_Account_Transaction {0},{1},{2},{3}", acctId, tranDesc, tranType, tranAmount)); UpdateAccountBalance(acctId, newBal); _db.SaveChanges(); }
public AccountTransaction PostAccountTransaction(AccountTransaction accountTransaction) { var item = AccountTransactions.FirstOrDefault(c => c.AccountTransactionId == accountTransaction.AccountTransactionId); if (item != null) { item = accountTransaction; return(item); } else { accountTransaction.AccountTransactionId = GenerateAccontTransactionId(); AccountTransactions.Add(accountTransaction); return(accountTransaction); } }
public void Save(Verification verification) { using (var core = new StandardBusinessLayer(this)) { core.Connect(); bool newVerification = verification.No == 0; core.Save(verification); FillVerification(verification); if (newVerification) { Verifications.Add(verification); } else { for (int i = 0; i < Verifications.Count(); i++) { if (Verifications[i].No == verification.No) { Verifications[i] = verification; break; } } for (int i = 0; i < AccountTransactions.Count(); i++) { if (AccountTransactions[i].VerificationNo == verification.No) { AccountTransactions[i].SetTransactionTime(verification.Date); AccountTransactions[i].SetAccountingDate(verification.AccountingDate); break; } } for (int i = 0; i < CashBookTransactions.Count(); i++) { if (CashBookTransactions[i].VerificationNo == verification.No) { CashBookTransactions[i].SetTransactionTime(verification.Date); CashBookTransactions[i].SetAccountingDate(verification.AccountingDate); break; } } } } }
private void _completeTrans_Click(object sender, EventArgs e) { DisableControls(); AccountTransactions trans = new AccountTransactions(); trans.ID = _id; trans.Balanced = _balanced; trans.Description = _description.Text; trans.TransactionDate = _date.Value; trans.AccountName = _account; foreach (DataGridViewRow row in _transaction.Rows) { if (row.Cells[0].Value == null) { continue; } Transaction t = new Transaction(); float fAmount = float.Parse(row.Cells[0].Value.ToString()); fAmount = (float)Math.Round(fAmount, 2); fAmount *= (100.0f); t.Amount = (int)(Math.Round(fAmount)); t.TransactionBudget = row.Cells[1].Value.ToString(); if (row.Tag != null) { foreach (string str in (List <string>)row.Tag) { t.Categories.Add(str); } } trans.Transactions.Add(t); } if (_editMode) { if (TransactionEdited != null) { TransactionEdited(trans); } } else { if (TransactionAdded != null) { TransactionAdded(trans); } } }
public AccountTransaction GetAccountTransactionByStockTransactionId(int stockTransactionId) { if (AccountTransactions.Any(c => c.StockTransactionId == stockTransactionId)) { var result = AccountTransactions.First(c => c.StockTransactionId == stockTransactionId); if (result.Account == null) { result.Account = GetAccount(result.AccountId); } if (result.StockTransaction == null && result.StockTransactionId.HasValue) { result.StockTransaction = GetStockTransaction(result.StockTransactionId.Value); } return(result); } return(null); }
public StockTransaction GetStockTransaction(int stockTransactionId) { if (StockTransactions.Any(c => c.StockTransactionId == stockTransactionId)) { var result = StockTransactions.First(c => c.StockTransactionId == stockTransactionId); if (result.AccountTransaction == null) { result.AccountTransaction = AccountTransactions.FirstOrDefault(c => c.AccountTransactionId == result.AccountTransactionId); } if (result.Stock == null) { result.Stock = GetStock(result.StockCode); } return(result); } return(null); }
public void BalanceAndTransactionConsistencyCheck() { var trans1 = new AccountTransaction(); trans1.Amount = 100; var trans2 = new AccountTransaction(); trans2.Amount = 0.5m; var trans3 = new AccountTransaction(); trans3.Amount = -10; AccountTransactions list = new AccountTransactions(); list.Add(trans1); list.Add(trans2); list.Add(trans3); }
public ActionResult GetAccountTransactions(int accountId, string filterCondition) { if (accountId <= 0 || string.IsNullOrEmpty(filterCondition)) { throw new ApplicationException("传入非法参数"); } AccountTransactions accountTransactions = null; switch (filterCondition) { case "lastWeek": accountTransactions = m_dbAdapter.Transaction.GetTransactionsBeforeDate(accountId, DateTime.Now.AddDays(-7)); break; case "lastMonth": accountTransactions = m_dbAdapter.Transaction.GetTransactionsBeforeDate(accountId, DateTime.Now.AddDays(-30)); break; case "lastHalfYear": accountTransactions = m_dbAdapter.Transaction.GetTransactionsBeforeDate(accountId, DateTime.Now.AddMonths(-6)); break; case "lastYear": accountTransactions = m_dbAdapter.Transaction.GetTransactionsBeforeDate(accountId, DateTime.Now.AddYears(-1)); break; case "all": accountTransactions = m_dbAdapter.Transaction.GetTransactions(accountId); break; } List <object> transactions = new List <object>(); if (accountTransactions != null) { foreach (var transaction in accountTransactions) { transactions.Add(new { Amount = transaction.Amount, Description = transaction.Description, TransactionTime = transaction.TransactionTime.ToString("yyyy-MM-dd") }); } } return(Content(Serialize(transactions), "text/json")); }
public AccountTransactions GetAccountTransaction(string accountNumber, string page, string perPage, DateTime?dateFrom, DateTime?dateTo) { var queryString = HttpUtility.ParseQueryString(string.Empty); page = page == null ? "" : page; perPage = perPage == null ? "" : perPage; string from = dateFrom == null ? "" : dateFrom.Value.ToString("yyyy-MM-dd"); string to = dateTo == null ? "" : dateTo.Value.ToString("yyyy-MM-dd"); HttpResponseMessage response = client.GetAsync(string.Format("https://arionapi-sandbox.azure-api.net/accounts/v1/accounts/{0}/accountTransactions?page={1}&perPage={2}&dateFrom={3}&dateTo={4}", accountNumber, page, perPage, "2016-01-01", "2017-01-01")).Result; var account = new AccountTransactions(); if (response.IsSuccessStatusCode) { var responseContent = response.Content.ReadAsStringAsync().Result; account = JsonConvert.DeserializeObject <AccountTransactions>(responseContent); } return(account); }