public async Task <IActionResult> Edit(int id, [Bind("CashInBankId,CIBDate,OpenningBalance,ClosingBalance,CashIn,CashOut")] CashInBank cashInBank) { if (id != cashInBank.CashInBankId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cashInBank); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CashInBankExists(cashInBank.CashInBankId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(PartialView(cashInBank)); }
public async Task <ActionResult <CashInBank> > PostCashInBank(CashInBank cashInBank) { _context.CashInBanks.Add(cashInBank); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCashInBank", new { id = cashInBank.CashInBankId }, cashInBank)); }
public async Task <IActionResult> PutCashInBank(int id, CashInBank cashInBank) { if (id != cashInBank.CashInBankId) { return(BadRequest()); } _context.Entry(cashInBank).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CashInBankExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static AccountsInfo GetAccoutingRecord(AprajitaRetailsContext db) { AccountsInfo info = new AccountsInfo(); CashInHand cih = db.CashInHands.Where(c => (c.CIHDate) == (DateTime.Today)).FirstOrDefault(); if (cih != null) { info.CashInHand = cih.InHand; info.CashIn = cih.CashIn; info.CashOut = cih.CashOut; info.OpenningBal = cih.OpenningBalance; } CashInBank cib = db.CashInBanks.Where(c => (c.CIBDate) == (DateTime.Today)).FirstOrDefault(); if (cib != null) { info.CashToBank = cib.CashIn; info.CashFromBank = cib.CashOut; info.CashInBank = cib.InHand; } var CashExp = db.PettyCashExpenses.Where(c => (c.ExpDate) == (DateTime.Today)); var CashPay = db.CashPayments.Where(c => (c.PaymentDate) == (DateTime.Today)); if (CashExp != null) { info.TotalCashPayments = (decimal?)CashExp.Sum(c => (decimal?)c.Amount) ?? 0; } if (CashPay != null) { info.TotalCashPayments += (decimal?)CashPay.Sum(c => (decimal?)c.Amount) ?? 0; } return(info); }
public ActionResult DeleteConfirmed(int id) { CashInBank cashInBank = db.CashInBanks.Find(id); db.CashInBanks.Remove(cashInBank); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CashInBankId,CIBDate,OpenningBalance,ClosingBalance,CashIn,CashOut")] CashInBank cashInBank) { if (ModelState.IsValid) { db.Entry(cashInBank).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cashInBank)); }
public ActionResult Create([Bind(Include = "CashInBankId,CIBDate,OpenningBalance,ClosingBalance,CashIn,CashOut")] CashInBank cashInBank) { if (ModelState.IsValid) { db.CashInBanks.Add(cashInBank); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cashInBank)); }
//StoreBased Action public void ProcessBankOpenningBalance(eStoreDbContext db, DateTime date, int StoreId, bool saveit = false) { CashInBank today; today = db.CashInBanks.Where(c => c.CIBDate.Date == date.Date && c.StoreId == StoreId).FirstOrDefault(); DateTime yDate = date.AddDays(-1); CashInBank yesterday = db.CashInBanks.Where(c => c.CIBDate.Date == yDate.Date && c.StoreId == StoreId).FirstOrDefault(); bool isNew = false; if (today == null) { today = new CashInBank() { CashIn = 0, CashOut = 0, CIBDate = date, ClosingBalance = 0, OpenningBalance = 0, StoreId = StoreId }; isNew = true; } if (yesterday == null) { yesterday = new CashInBank() { CashIn = 0, CashOut = 0, CIBDate = yDate, ClosingBalance = 0, OpenningBalance = 0, StoreId = StoreId }; today.OpenningBalance = 0; today.ClosingBalance = today.OpenningBalance + today.CashIn - today.CashOut; db.CashInBanks.Add(yesterday); } else { yesterday.ClosingBalance = yesterday.OpenningBalance + yesterday.CashIn - yesterday.CashOut; today.OpenningBalance = yesterday.ClosingBalance; today.ClosingBalance = today.OpenningBalance + today.CashIn - today.CashOut; db.Entry(yesterday).State = EntityState.Modified; } if (isNew) { db.CashInBanks.Add(today); } else { db.Entry(today).State = EntityState.Modified; } if (saveit) { db.SaveChanges(); } }
public async Task <IActionResult> Create([Bind("CashInBankId,CIBDate,OpenningBalance,ClosingBalance,CashIn,CashOut")] CashInBank cashInBank) { if (ModelState.IsValid) { _context.Add(cashInBank); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(PartialView(cashInBank)); }
public async Task <IActionResult> Create([Bind("CashInBankId,CIBDate,OpenningBalance,ClosingBalance,CashIn,CashOut,StoreId")] CashInBank cashInBank) { if (ModelState.IsValid) { _context.Add(cashInBank); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["StoreId"] = new SelectList(_context.Stores, "StoreId", "StoreId", cashInBank.StoreId); return(View(cashInBank)); }
public static void UpDateCashOutBank(AprajitaRetailsContext db, DateTime dateTime, decimal Amount, bool saveit = false) { CashInBank cashIn = db.CashInBanks.Where(d => d.CIBDate == dateTime).FirstOrDefault(); if (cashIn != null) { cashIn.CashOut += Amount; db.SaveChanges(); } else { CreateCashInBank(db, dateTime, 0, Amount, saveit); } }
// GET: CashInBanks/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CashInBank cashInBank = db.CashInBanks.Find(id); if (cashInBank == null) { return(HttpNotFound()); } return(View(cashInBank)); }
public static void UpdateCashInBank(eStoreDbContext db, DateTime dateTime, decimal Amount, bool saveit = false) { //throw new NotImplementedException(); CashInBank cashIn = db.CashInBanks.Where(d => d.CIBDate == dateTime).FirstOrDefault(); if (cashIn != null) { cashIn.CashIn += Amount; db.SaveChanges(); } else { CreateCashInBank(db, dateTime, Amount, 0, saveit); } }
public static void UpDateCashOutBank(AprajitaRetailsContext db, DateTime dateTime, decimal Amount, bool saveit = false) { { CashInBank cashIn = db.CashInBanks.Where(d => d.CIBDate == dateTime).FirstOrDefault(); if (cashIn != null) { cashIn.CashOut += Amount; db.SaveChanges(); } else { // db.CashInBanks.Add(new CashInBank() { CIBDate = dateTime, CashIn = 0, OpenningBalance = 0, ClosingBalance = 0, CashOut = Amount }); //if (saveit) db.SaveChanges(); CreateCashInBank(db, dateTime, 0, Amount, saveit); } } }
public static void CreateCashInBank(eStoreDbContext db, DateTime date, decimal inAmt, decimal outAmt, bool saveit = false) { //throw new NotImplementedException(); CashInBank today; DateTime yDate = date.AddDays(-1); CashInBank yesterday = db.CashInBanks.Where(c => c.CIBDate == yDate).FirstOrDefault(); today = new CashInBank() { CashIn = inAmt, CashOut = outAmt, CIBDate = date, ClosingBalance = 0, OpenningBalance = 0 }; if (yesterday != null) { yesterday.ClosingBalance = yesterday.OpenningBalance + yesterday.CashIn - yesterday.CashOut; today.ClosingBalance = today.OpenningBalance = yesterday.ClosingBalance; db.CashInBanks.Add(today); if (saveit) { db.SaveChanges(); } } else { //TODO: need to option to create cashinbank entry for all missing entry and correct //if (db.CashInBanks.Count() > 0) // throw new Exception(); //else { today.ClosingBalance = today.OpenningBalance = 0; db.CashInBanks.Add(today); if (saveit) { db.SaveChanges(); } } } }
public static void CreateCashInBank(AprajitaRetailsContext db, DateTime date, decimal inAmt, decimal outAmt, bool saveit = false) { CashInBank today; DateTime yDate = date.AddDays(-1); CashInBank yesterday = db.CashInBanks.Where(c => c.CIBDate == yDate).FirstOrDefault(); today = new CashInBank() { CashIn = inAmt, CashOut = outAmt, CIBDate = date, ClosingBalance = 0, OpenningBalance = 0 }; if (yesterday != null) { yesterday.ClosingBalance = yesterday.OpenningBalance + yesterday.CashIn - yesterday.CashOut; today.ClosingBalance = today.OpenningBalance = yesterday.ClosingBalance; db.CashInBanks.Add(today); if (saveit) { db.SaveChanges(); } } else { if (db.CashInBanks.Count() > 0) { throw new Exception(); } else { today.ClosingBalance = today.OpenningBalance = 0; db.CashInBanks.Add(today); if (saveit) { db.SaveChanges(); } } } }
public async Task <IActionResult> Create([Bind("CashInBankID,Amount,AmountInWords,BankID,CompanyID,CreatedBy,CreationDate,CurrencyID,Date,DepositedBy,ExternalRef,Particulars,PartiesID")] CashInBank cashInBank) { string CompId = User.Claims.Where(r => r.Type == "CompanyID").FirstOrDefault().Value; int CompID = Convert.ToInt32(CompId); cashInBank.CompanyID = CompID; cashInBank.CreatedBy = User.Identity.Name; cashInBank.CreationDate = DateTime.Now; if (ModelState.IsValid) { _context.Add(cashInBank); await _context.SaveChangesAsync(); int CIB = cashInBank.CashInBankID; CashFlow CF2 = new CashFlow(); CF2.Credit = cashInBank.Amount; CF2.CashInBankID = CIB; CF2.CompanyID = CompID; CF2.PartiesID = cashInBank.PartiesID; // Party Credit int?PartyTransID = _context.Parties.Where(r => r.CompanyID == CompID).Where(r => r.PartiesID == cashInBank.PartiesID).FirstOrDefault().TransactionAccountID; int PartMainAcc1_2 = _context.MainAccount.Where(r => r.CompanyID == CompID).Where(r => r.MainAccountNumber == "00").FirstOrDefault().MainAccountID; int PartSubAcc1_2 = _context.SubAccount.Where(r => r.CompanyID == CompID).Where(r => r.SubAccountNumber == "0000").FirstOrDefault().SubAccountID; CF2.MainAccountID = PartMainAcc1_2; CF2.SubAccountID = PartSubAcc1_2; CF2.TransactionAccountID = (int)PartyTransID; CF2.VoucherType = "Cash In Bank Voucher"; CF2.DateCreation = DateTime.Now.Date; // CF2.Narration = _context.CashFlow.Add(CF2); await _context.SaveChangesAsync(); CashFlow CF3 = new CashFlow(); CF3.Debit = cashInBank.Amount; CF3.CashInBankID = CIB; CF3.CompanyID = CompID; CF3.PartiesID = cashInBank.PartiesID; // Bank Debit int?bankID = cashInBank.BankID; int transBankID = _context.Bank.Where(r => r.CompanyID == CompID).Where(r => r.BankID == bankID).FirstOrDefault().TransactionAccountID; int MainAccID_3 = _context.MainAccount.Where(r => r.CompanyID == CompID).Where(r => r.MainAccountNumber == "01").FirstOrDefault().MainAccountID; int SubAccID_3 = _context.SubAccount.Where(r => r.CompanyID == CompID).Where(r => r.MainAccountID == MainAccID_3).Where(r => r.SubAccountNumber == "0002").FirstOrDefault().SubAccountID; CF3.MainAccountID = MainAccID_3; CF3.SubAccountID = SubAccID_3; CF3.TransactionAccountID = transBankID; CF3.VoucherType = "Cash In Bank Voucher"; CF3.DateCreation = DateTime.Now.Date; _context.CashFlow.Add(CF3); await _context.SaveChangesAsync(); if (User.IsInRole("CompanyAdmin")) { return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Home", new { area = "CompanyUser" })); } } ViewData["BankID"] = new SelectList(_context.Bank.Where(r => r.CompanyID == CompID), "BankID", "BankName", cashInBank.BankID); ViewData["CurrencyID"] = new SelectList(_context.Currency.Where(r => r.CompanyID == CompID), "CurrencyID", "CurrencyName", cashInBank.CurrencyID); ViewData["PartiesID"] = new SelectList(_context.Parties.Where(r => r.CompanyID == CompID), "PartiesID", "PartyName", cashInBank.PartiesID); return(View(cashInBank)); }
public static void ProcessOpenningClosingBankBalance(AprajitaRetailsContext db, DateTime date, bool isclosing = false, bool saveit = false) { if (!isclosing) { CashInBank today; today = db.CashInBanks.Where(c => DbFunctions.TruncateTime(c.CIBDate) == DbFunctions.TruncateTime(date)).FirstOrDefault(); DateTime yDate = date.AddDays(-1); CashInBank yesterday = db.CashInBanks.Where(c => DbFunctions.TruncateTime(c.CIBDate) == DbFunctions.TruncateTime(yDate)).FirstOrDefault(); if (today == null) { today = new CashInBank() { CashIn = 0, CashOut = 0, CIBDate = date, ClosingBalance = 0, OpenningBalance = 0 }; if (yesterday != null) { yesterday.ClosingBalance = yesterday.OpenningBalance + yesterday.CashIn - yesterday.CashOut; today.ClosingBalance = today.OpenningBalance = yesterday.ClosingBalance; db.CashInBanks.Add(today); if (saveit) { db.SaveChanges(); } } else { if (db.CashInBanks.Count() > 0) { throw new Exception(); } else { today.ClosingBalance = today.OpenningBalance = 0; db.CashInBanks.Add(today); if (saveit) { db.SaveChanges(); } } } } else { if (yesterday != null) { today.ClosingBalance = today.OpenningBalance = yesterday.ClosingBalance; db.Entry(today).State = EntityState.Modified; if (saveit) { db.SaveChanges(); } } else { if (db.CashInBanks.Count() > 1) { throw new Exception(); } else { today.ClosingBalance = today.OpenningBalance = 0; db.Entry(today).State = EntityState.Modified; if (saveit) { db.SaveChanges(); } } } } } else { //ClosingBalance; CashInBank today; today = db.CashInBanks.Where(c => DbFunctions.TruncateTime(c.CIBDate) == DbFunctions.TruncateTime(date)).FirstOrDefault(); if (today != null) { if (today.ClosingBalance != today.OpenningBalance + today.CashIn - today.CashOut) { today.ClosingBalance = today.OpenningBalance + today.CashIn - today.CashOut; db.Entry(today).State = EntityState.Modified; if (saveit) { db.SaveChanges(); } } } else { //TODO: Implement this on urgent basis throw new Exception(); } } }