示例#1
0
 public SavingsAccountConfigViewModel(SavingsAccountConfig config)
 {
     if (config == null)
     {
         Id = 0;
     }
     else
     {
         Id                  = config.Id;
         CInterestRate       = config.CInterestRate;
         InterestExpenseGlId = config.InterestExpenseGlId;
         InterestPayableGlId = (int)config.InterestPayableGlId;
         MinBalance          = config.MinBalance;
         Status              = config.Status;
         InterestExpenseGl   = config.InterestExpenseGl;
     }
 }
示例#2
0
        public ActionResult SaveSavingsConfig(SavingsAccountConfig config)
        {
            var glAccount     = new GlAccount();
            var configInDb    = _context.GetSavingsConfig();
            var glAccountInDb = _glAccountContext.Get(config.InterestExpenseGlId);

            if (config.Id == 0)                  //setup new configuration
            {
                glAccountInDb.IsAssigned = true; // Update the gl account to is assigned
                _glAccountContext.Update(glAccount);

                config.Status = true;
                _context.SaveSavings(config);
                TempData["Success"] = "Configurations Added Successfully";
                return(RedirectToAction("SavingsAccount"));
            }

            if (config.Id != 0) //update current savings configuration
            {
                configInDb.CInterestRate       = config.CInterestRate;
                configInDb.MinBalance          = config.MinBalance;
                configInDb.InterestPayableGlId = config.InterestPayableGlId;

                if (config.InterestExpenseGlId == 0) //check if gl account is the same
                {
                    configInDb.InterestExpenseGlId = configInDb.InterestExpenseGlId;
                }
                else
                {
                    var newGlAccountInDb = _glAccountContext.Get(configInDb.InterestExpenseGlId); // free up the old gl account that was assigned
                    newGlAccountInDb.IsAssigned = false;
                    _glAccountContext.Update(glAccount);

                    configInDb.InterestExpenseGlId = config.InterestExpenseGlId;

                    glAccountInDb.IsAssigned = true; // Update the  new gl account to is assigned
                    _glAccountContext.Update(glAccount);
                }
                TempData["Success"] = "Configurations Updated Successfully";
                _context.UpdateSavings(config);
            }
            return(RedirectToAction("SavingsAccount"));
        }
示例#3
0
 public void UpdateSavings(SavingsAccountConfig savingsConfig)
 {
     _savingsAccContext.Save(savingsConfig);
 }
示例#4
0
 public void SaveSavings(SavingsAccountConfig config)
 {
     _savingsAccContext.Add(config);
     _savingsAccContext.Save(config);
 }