Beispiel #1
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"));
        }
        public List <GlAccount> GetAllLiabilityAccounts()
        {
            var liabilityAccounts = _glAccContext.GetByMainCategory(MainAccountCategory.Liability);
            var savingsAccBalance = _customerAccContext.GetByAccountType(AccountType.Savings).Sum(c => c.Balance);
            var currentAccBalance = _customerAccContext.GetByAccountType(AccountType.Current).Sum(c => c.Balance);

            var customerSavingsLiabilityAcc = new GlAccount
            {
                Name    = "Customers Savings Liability Accounts",
                Balance = savingsAccBalance
            };
            var customerCurrentLiabilityAcc = new GlAccount
            {
                Name    = "Customers  Current Liability Accounts",
                Balance = currentAccBalance
            };

            liabilityAccounts.Add(customerSavingsLiabilityAcc);
            liabilityAccounts.Add(customerCurrentLiabilityAcc);
            return(liabilityAccounts);
        }
Beispiel #3
0
        // GET: GlPosting/Create
        public ActionResult Create(int?crId, int?drId)
        {
            if (crId == null || drId == null || crId == drId)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GlAccount drglAccount = db.GlAccounts.Find(drId);
            GlAccount crglAccount = db.GlAccounts.Find(crId);

            if (drglAccount == null || crglAccount == null)
            {
                return(HttpNotFound());
            }

            GlPosting model = new GlPosting();

            model.DrGlAccountID = drglAccount.ID;
            model.CrGlAccountID = crglAccount.ID;

            return(View(model));
        }
Beispiel #4
0
        public ActionResult Create(AddGlActViewModel model)
        {
            ViewBag.GlCategoryId = new SelectList(glCatRepo.GetAll(), "ID", "Name", model.GlCategoryId);
            ViewBag.BranchId     = new SelectList(branchRepo.GetAll(), "ID", "Name", model.BranchId);

            if (ModelState.IsValid)
            {
                try
                {
                    var            category     = glCatRepo.GetById(model.GlCategoryId);
                    var            branch       = branchRepo.GetById(model.BranchId);
                    MainGlCategory mainCategory = (MainGlCategory)((int)category.MainCategory);

                    //if is unique account name
                    if (!gllogic.IsUniqueName(model.AccountName))
                    {
                        ViewBag.Msg = "Account name must be unique";
                        return(View(model));
                    }

                    GlAccount glAccount = new GlAccount()
                    {
                        AccountName = model.AccountName, GlCategory = category, Branch = branch, CodeNumber = gllogic.GenerateGLAccountNumber(mainCategory)
                    };
                    glactRepo.Insert(glAccount);
                    //ViewBag.Msg = "successfully added account";

                    return(RedirectToAction("Create", new { message = "successfully added account" }));
                }
                catch (Exception ex)
                {
                    //ErrorLogger.Log("Message= " + ex.Message + "\nInner Exception= " + ex.InnerException + "\n");
                    return(PartialView("Error"));
                }
            }

            ViewBag.Msg = "Please enter correct data";
            return(View(model));
        }
Beispiel #5
0
        // GET: /GlAccount/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GlAccount glaccount = glactRepo.GetById((int)id);

            if (glaccount == null)
            {
                return(HttpNotFound());
            }
            var model = new EditGlAccountViewModel();

            model.Id          = glaccount.ID;
            model.AccountName = glaccount.AccountName;
            model.BranchId    = glaccount.Branch.ID;

            ViewBag.Msg      = "";
            ViewBag.BranchId = new SelectList(branchRepo.GetAll(), "ID", "Name", glaccount.Branch.ID);
            return(View(model));
        }
Beispiel #6
0
        public double GetGlAccountWithdrawal(int glAccountid, double amount)
        {
            IGlAccountDb glAccountDb = new GlAccountDb();
            GlAccount    glAccount   = glAccountDb.RetrieveById(glAccountid);

            //Credit account if its any of these 2 glAccount Types below:
            if (glAccount.GlAccountCodes.StartsWith("1") || glAccount.GlAccountCodes.StartsWith("5"))
            {
                if (glAccount.Balance >= amount)
                {
                    glAccount.Balance = glAccount.Balance - amount;
                }
            }
            //Credit account if its any of these 3 glAccount Types below:
            else if (glAccount.GlAccountCodes.StartsWith("2") || glAccount.GlAccountCodes.StartsWith("3") ||
                     glAccount.GlAccountCodes.StartsWith("4"))
            {
                glAccount.Balance = glAccount.Balance + amount;
            }

            return(glAccount.Balance);
        }
Beispiel #7
0
        public bool CreditGl(GlAccount account, decimal amount)
        {
            try
            {
                switch (account.GlCategory.MainCategory)
                {
                case MainGlCategory.Asset:
                    account.AccountBalance -= amount;
                    break;

                case MainGlCategory.Capital:
                    account.AccountBalance += amount;
                    break;

                case MainGlCategory.Expenses:
                    account.AccountBalance -= amount;
                    break;

                case MainGlCategory.Income:
                    account.AccountBalance += amount;
                    break;

                case MainGlCategory.Liability:
                    account.AccountBalance += amount;
                    break;

                default:
                    break;
                }//end switch

                //frLogic.CreateTransaction(account, amount, TransactionType.Credit);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }//end creditGl
        public void FillEditParametersTest()
        {
            Associate associate = new Associate();
            Dictionary <string, object> editParameters = new Dictionary <string, object>();

            editParameters.Add("IdCountry", 5);
            associate.FillEditParameters(editParameters);
            Assert.AreEqual(5, associate.IdCountry);

            editParameters.Clear();
            GlAccount glAccount = new GlAccount(connManager);

            editParameters = new Dictionary <string, object>();
            editParameters.Add("IdCountry", 10);
            glAccount.FillEditParameters(editParameters);
            Assert.AreEqual(10, glAccount.IdCountry);

            editParameters.Clear();
            HourlyRate hourlyRate = new HourlyRate(connManager);

            editParameters = new Dictionary <string, object>();
            editParameters.Add("YearMonth", 1010);
            editParameters.Add("IdCostCenter", 2);
            hourlyRate.FillEditParameters(editParameters);
            Assert.AreEqual(1010, hourlyRate.YearMonth);
            Assert.AreEqual(2, hourlyRate.IdCostCenter);

            editParameters.Clear();
            WorkPackage workPackage = new WorkPackage(connManager);

            editParameters = new Dictionary <string, object>();
            editParameters.Add("IdPhase", 1);
            editParameters.Add("IdProject", 2);
            workPackage.FillEditParameters(editParameters);
            Assert.AreEqual(1, workPackage.IdPhase);
            Assert.AreEqual(2, workPackage.IdProject);
        }
Beispiel #9
0
        public string GetGlAccountCode(GlAccount glAccount)
        {
            //GlAccount glAccount = new GlAccount();
            GlCategory glCategory    = new GlCategory();
            Random     Rand          = new Random();
            string     RandString    = Convert.ToString(Rand.Next(10000, 99999));
            string     GlAccountCode = "";

            //var tr = Enum.GetValues(typeof(MainAccountCategory));
            //    int enumId = Convert.ToInt32(tr);

            switch (glAccount.GlCategory.MainAccountCategory)
            {
            case MainAccountCategory.Asset:
                GlAccountCode = '1' + RandString;
                break;

            case MainAccountCategory.Liability:
                GlAccountCode = '2' + RandString;
                break;

            case MainAccountCategory.Capital:
                GlAccountCode = '3' + RandString;
                break;

            case MainAccountCategory.Income:
                GlAccountCode = '4' + RandString;
                break;

            case MainAccountCategory.Expense:
                GlAccountCode = '5' + RandString;
                break;
            }

            glAccount.GlAccountCodes = GlAccountCode;
            return(glAccount.GlAccountCodes);
        }
Beispiel #10
0
        public static GlAccountRoot SageNominalCodeToMTGlAccount(SageNominalCode sagenominalcode)
        {
            GlAccountRoot glaccountroot = new GlAccountRoot();
            GlAccount     glaccount     = new GlAccount();

            glaccount.id                 = "";
            glaccount.externalId         = sagenominalcode.PrimaryKey.DbValue.ToString();
            glaccount.subsidiaries       = null;
            glaccount.departmentRequired = false;
            glaccount.locationRequired   = false;
            glaccount.projectRequired    = false;
            glaccount.customerRequired   = false;
            glaccount.vendorRequired     = false;
            glaccount.employeeRequired   = false;
            glaccount.itemRequired       = false;
            glaccount.classRequired      = false;
            glaccount.ledgerType         = "EXPENSE_ACCOUNT";
            glaccount.accountNumber      = sagenominalcode.Reference;
            glaccount.name               = sagenominalcode.Name;
            glaccount.active             = true; // NO MATCHING FIELD IN SAGE

            glaccountroot.glAccount = glaccount;
            return(glaccountroot);
        }
Beispiel #11
0
        public async Task <bool> AddGlAccount(GlAccountView glakun)
        {
            string test     = glakun.GlAcct.ToUpper();
            var    cekFirst = _context.GlAccounts.Where(x => x.GlAcct == test).ToList();

            if (cekFirst.Count == 0)
            {
                GlAccount Akun = new GlAccount()
                {
                    GlAcct      = glakun.GlAcct.ToUpper(),
                    GlNama      = glakun.GlNama,
                    TipeGl      = glakun.TipeGL,
                    NamaLengkap = glakun.NamaLengkap
                };
                _context.GlAccounts.Add(Akun);
                await _context.SaveChangesAsync();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #12
0
        public ActionResult SelectSecondAccount(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GlAccount crglAccount = db.GlAccounts.Find(id);

            if (crglAccount == null)
            {
                return(HttpNotFound());
            }

            // populate second account table based on first account choice
            // e.g if glaccount main cat is asset, populate with only asset accounts.
            // exclude first selected account with from view of second.
            // but for now populate with everybody

            ViewBag.CrGlAccountID = crglAccount.ID;
            //var acts = db.GlAccounts.ToList();
            var acts = db.GlAccounts.Where(g => g.ID != crglAccount.ID && g.GlCategory.MainCategory == crglAccount.GlCategory.MainCategory).ToList();

            return(View(acts));
        }
Beispiel #13
0
        public ActionResult Save(Teller teller)
        {
            int userId = Convert.ToInt32(Request.Form["userId"]);

            if (_userContext.GetUnassigned(userId) != null)
            {
                var user      = new User();
                var glAccount = new GlAccount();

                var userInDb      = _userContext.Get(userId);
                var glAccountInDb = _glAccountContext.Get(teller.GlAccountId);

                userInDb.IsAssigned = true;
                _userContext.Update(user);

                glAccountInDb.IsAssigned = true;
                _glAccountContext.Update(glAccount);

                teller.UserId = userId;
                _context.Save(teller);
                TempData["Success"] = "Till Account Assigned Successfully";
                return(RedirectToAction("Index"));
            }

            ViewBag.hasTillAccount = "User Has Till Account";
            var tellers            = _context.GetWithAll();
            var selectedUser       = _userContext.Get(userId);
            var selectedGlAccounts = _glAccountContext.GetAllUnassigned();
            var selectedViewModel  = new NewTellerViewModel
            {
                User      = selectedUser,
                GlAccount = selectedGlAccounts
            };

            return(View("TellerForm", selectedViewModel));
        }
Beispiel #14
0
        public GlAccount GetByGlAccountCode(string accountcode)
        {
            GlAccount glAccount = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(LocalhostAddress);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                // HTTP GET
                HttpResponseMessage response = client.GetAsync("api/Glaccount/GetByAccountCode/?Accountcode=" + accountcode).Result;
                if (response.IsSuccessStatusCode)
                {
                    glAccount = response.Content.ReadAsAsync <GlAccount>().Result;
                    return(glAccount);
                }
                else
                {
                    string message = response.ReasonPhrase;
                }
            }
            return(glAccount);
        }
        }//end creditGl

        public bool DebitGl(GlAccount account, decimal amount)
        {
            try
            {
                switch (account.GlCategory.MainCategory)
                {
                case MainGlCategory.Asset:
                    account.AccountBalance += amount;
                    break;

                case MainGlCategory.Capital:
                    account.AccountBalance -= amount;
                    break;

                case MainGlCategory.Expenses:
                    account.AccountBalance += amount;
                    break;

                case MainGlCategory.Income:
                    account.AccountBalance -= amount;
                    break;

                case MainGlCategory.Liability:
                    account.AccountBalance -= amount;
                    break;

                default:
                    break;
                }//end switch
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }//end DebitGl
Beispiel #16
0
        public ActionResult Edit([Bind(Include = "ID,AccountName,CodeNumber,AccountBalance,GlCategoryID,BranchID")] GlAccount glAccount)
        {
            ViewBag.BranchID = new SelectList(db.Branches, "ID", "Name", glAccount.BranchID);
            //ViewBag.GlCategoryID = new SelectList(db.GlCategories, "ID", "Name", glAccount.GlCategoryID);

            if (ModelState.IsValid)
            {
                try
                {
                    //it had to be detached because of the collision. the entity was being tracked by the context.
                    GlAccount originalAccount = db.GlAccounts.Find(glAccount.ID);
                    db.Entry(originalAccount).State = EntityState.Detached;

                    string originalName = originalAccount.AccountName;
                    if (!glAccount.AccountName.ToLower().Equals(originalName.ToLower()))
                    {
                        if (!glActLogic.IsUniqueName(glAccount.AccountName))
                        {
                            AddError("Please select another name");
                            return(View(glAccount));
                        }
                    }

                    db.Entry(glAccount).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    AddError(ex.ToString());
                    return(View(glAccount));
                }
            }
            AddError("Please enter valid data");
            return(View(glAccount));
        }
Beispiel #17
0
        protected void searchsubmit_OnServerClick(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(TextBoxNameDebitNarration.Value))
                {
                    throw new Exception("Debit Narration field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameCreditNarration.Value))
                {
                    throw new Exception("Credit Narration field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameDebitOrCreditAmnt.Value))
                {
                    throw new Exception("Amount field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxId.Value))
                {
                    GlPosting posting = new GlPosting();

                    //GlPosting glPosting = new GlPosting();
                    GlAccount glAccount =
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                        .RetrieveById(int.Parse(DropDownListGlAcctToCredit.SelectedValue));
                    GlAccount glAccounts =
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                        .RetrieveById(int.Parse(DropDownListGlAcctToDebit.SelectedValue));
                    posting.GlAccountToDebit    = new GlAccount();
                    posting.GlAccountToDebit.Id = int.Parse(DropDownListGlAcctToDebit.SelectedValue);
                    var glPostings =
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                        .RetrieveById(posting.GlAccountToDebit.Id);
                    posting.GlAccountToCredit    = new GlAccount();
                    posting.GlAccountToCredit.Id = int.Parse(DropDownListGlAcctToCredit.SelectedValue);
                    var glPosting =
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                        .RetrieveById(posting.GlAccountToCredit.Id);
                    posting.DebitNarration  = TextBoxNameDebitNarration.Value;
                    posting.CreditNarration = TextBoxNameCreditNarration.Value;
                    posting.Amount          = double.Parse(TextBoxNameDebitOrCreditAmnt.Value);

                    IList <EOD> eod =
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IEODDb>().RetrieveAll();
                    posting.TransactionDate = eod[0].FinancialDate;
                    posting.DateAdded       = DateTime.Now;
                    posting.DateUpdated     = DateTime.Now;
                    GlPostingLogic glPostingLogic = new GlPostingLogic();
                    //try
                    //{
                    //    glPosting.Balance = glPostingLogic.CreditGlAccount(glAccount, posting.Amount);
                    //    glPostings.Balance = glPostingLogic.DebitGlAccount(glAccounts, posting.Amount);
                    //}
                    //catch (Exception)
                    //{
                    //    if (glPosting.Balance < 0 || glPostings.Balance < 0)
                    //    {
                    //        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "GL Account Balance Cannot Be Negative. Please Post Appropriately " + "', function(){});</script>", false);
                    //    }
                    //    else if (glPosting.Balance >= 0 || glPostings.Balance >= 0)
                    //    {
                    //        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IGlPostingDb>().InsertData(posting);
                    //        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IGlAccountDb>().UpdateData(glPosting);
                    //        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IGlAccountDb>().UpdateData(glPostings);
                    //    }
                    //}
                    glPosting.Balance  = glPostingLogic.CreditGlAccount(glAccount, posting.Amount);
                    glPostings.Balance = glPostingLogic.DebitGlAccount(glAccounts, posting.Amount);


                    if (glPosting.Balance >= 0 && glPostings.Balance >= 0)
                    {
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlPostingDb>().InsertData(posting);
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                        .UpdateData(glPosting);
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                        .UpdateData(glPostings);
                    }
                    else if (glPosting.Balance < 0 || glPostings.Balance < 0)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "GL Account Balance Cannot Be Negative. Please Post Appropriately " + "', function(){});</script>", false);
                    }
                }

                else
                {
                    //adjust code to tally with the one in 'if' clause
                    GlAccount glAccount = new GlAccount();
                    GlPosting glPosting =
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlPostingDb>()
                        .RetrieveById(Convert.ToInt32(TextBoxId.Value));
                    glPosting.GlAccountToDebit     = new GlAccount();
                    glPosting.GlAccountToDebit.Id  = int.Parse(DropDownListGlAcctToDebit.SelectedValue);
                    glPosting.GlAccountToCredit    = new GlAccount();
                    glPosting.GlAccountToCredit.Id = int.Parse(DropDownListGlAcctToCredit.SelectedValue);
                    glPosting.DebitNarration       = TextBoxNameDebitNarration.Value;
                    glPosting.CreditNarration      = TextBoxNameCreditNarration.Value;
                    glPosting.Amount = double.Parse(TextBoxNameDebitOrCreditAmnt.Value);
                    GlPostingLogic glPostingLogic = new GlPostingLogic();
                    //glAccount.Balance = glPostingLogic.PostIntoGlAccounts(glAccount, glPosting.Amount);
                    glPosting.GlAccountToCredit.Balance = glPostingLogic.CreditGlAccount(glAccount, glPosting.Amount);
                    glPosting.GlAccountToDebit.Balance  = glPostingLogic.CreditGlAccount(glAccount, glPosting.Amount);
                    glPosting.DateUpdated = DateTime.Now;

                    Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlPostingDb>()
                    .UpdateData(glPosting);
                    //Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IGlAccountDb>().UpdateData(glAccount);
                }


                TextBoxNameDebitNarration.Value    = String.Empty;
                TextBoxNameCreditNarration.Value   = String.Empty;
                TextBoxNameDebitOrCreditAmnt.Value = String.Empty;


                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Gl Posting Saved Successfully" + "', function(){location = '/GlPostingMgt/PostTransactionsIntoGLs.aspx';});</script>", false);
                }
            }
            catch (Exception ex)
            {
                var glPostings =
                    Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                    .RetrieveById(int.Parse(DropDownListGlAcctToDebit.SelectedValue));
                var glPosting =
                    Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                    .RetrieveById(int.Parse(DropDownListGlAcctToCredit.SelectedValue));
                if (glPosting.Balance < 0 || glPostings.Balance < 0)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "GL Account Balance Cannot Be Negative. Please Post Appropriately " + "', function(){});</script>", false);
                }
                if (DropDownListGlAcctToDebit.SelectedValue == "0")
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "GL Acct to Debit Not Selected. Please Select One " + "', function(){});</script>", false);
                }
                if (DropDownListGlAcctToCredit.SelectedValue == "0")
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "GL Acct to Credit Not Selected. Please Select One " + "', function(){});</script>", false);
                }
                string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false);
                }
            }
        }
Beispiel #18
0
 public void Update(GlAccount account)
 {
     _db.Save(account);
 }
Beispiel #19
0
 public void Save(GlAccount account)
 {
     _db.Add(account);
     _db.Save(account);
 }
        protected void searchsubmit_OnServerClick(object sender, EventArgs e)
        {
            var tr         = Enum.Parse(typeof(MainAccountCategory), DropDownGlCategory.SelectedValue);
            int categoryID = (int)tr;

            GlCategory glCategory =
                Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlCategoryDb>()
                .RetrieveById(categoryID);

            try
            {
                if (string.IsNullOrWhiteSpace(TextBoxNameGlAccountName.Value))
                {
                    throw new Exception("Gl Account Name field is required");
                }

                if (string.IsNullOrWhiteSpace(TextBoxId.Value))
                {
                    GlAccount glAccount = new GlAccount();
                    Branch    branch    = new Branch();
                    glAccount.Branch = branch;
                    GlAccountLogic glAccountLogic = new GlAccountLogic();
                    glAccount.GlAccountName = TextBoxNameGlAccountName.Value;
                    string glBranchId = DropDownBranch.SelectedValue;
                    glAccount.Branch.Id         = int.Parse(glBranchId);
                    glAccount.Branch.BranchName = Convert.ToString(glAccount.Branch.Id);
                    glAccount.GlCategory        = glCategory;
                    glAccount.GlAccountCodes    = glAccountLogic.GetGlAccountCode(glAccount);
                    glAccount.DateAdded         = DateTime.Now;
                    glAccount.DateUpdated       = DateTime.Now;
                    Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>().InsertData(glAccount);
                }

                else
                {
                    GlAccount glAccount =
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                        .RetrieveById(Convert.ToInt32(TextBoxId.Value));
                    glAccount.GlAccountName = TextBoxNameGlAccountName.Value;
                    glAccount.GlAccountName = TextBoxNameGlAccountName.Value;
                    //glAccount.GlCategory.Id = int.Parse(DropDownGlCategory.SelectedValue);
                    //glAccount.GlCategory.GlCategoryName = DropDownGlCategory.SelectedValue;
                    GlAccountLogic glAccountLogic = new GlAccountLogic();
                    glAccount.GlAccountCodes    = glAccountLogic.GetGlAccountCode(glAccount);
                    glAccount.GlCategory        = glCategory;
                    glAccount.Branch.Id         = int.Parse(DropDownBranch.SelectedValue);
                    glAccount.Branch.BranchName = DropDownBranch.SelectedValue;
                    glAccount.DateUpdated       = DateTime.Now;

                    Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                    .UpdateData(glAccount);
                }


                TextBoxNameGlAccountName.Value = String.Empty;


                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Gl Account Saved Successfully" + "', function(){location = '/GlAccountMgt/AddNewGlAccount.aspx';});</script>", false);
                }
            }
            catch (Exception ex)
            {
                IList <GlAccount> glaccount = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>().RetrieveAll();

                foreach (var glaccounttest in glaccount)
                {
                    if (TextBoxNameGlAccountName.Value == glaccounttest.GlAccountName)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Gl Account Name Already Exists. Change it" + "', function(){});</script>", false);
                    }
                }
                if (DropDownGlCategory.SelectedValue == "0")
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Gl Category Not Selected. Please Select One " + "', function(){});</script>", false);
                }
                if (DropDownBranch.SelectedValue == "0")
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Branch Not Selected. Please Select a Branch " + "', function(){});</script>", false);
                }
                string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false);
                }
            }
        }
        public string PostTeller(CustomerAccount account, GlAccount till, decimal amt, TellerPostingType pType)
        {
            string output = "";

            switch (pType)
            {
            case TellerPostingType.Deposit:
                busLogic.CreditCustomerAccount(account, amt);
                busLogic.DebitGl(till, amt);

                output = "success";
                break;

            //break;
            case TellerPostingType.Withdrawal:
                //Transfer the money from the user's till and reflect the changes in the customer account balance
                //check withdrawal limit

                var config = new ConfigurationRepository().GetFirst();
                //till = user.TillAccount;
                if (account.AccountType == AccountType.Savings)
                {
                    if (account.AccountBalance >= config.SavingsMinimumBalance + amt)
                    {
                        if (till.AccountBalance >= amt)
                        {
                            busLogic.CreditGl(till, amt);
                            busLogic.DebitCustomerAccount(account, amt);

                            output = "success";
                            account.SavingsWithdrawalCount++;
                        }
                        else
                        {
                            output = "Insufficient fund in the Till account";
                        }
                    }
                    else
                    {
                        output = "insufficient Balance in Customer's account, cannot withdraw!";
                    }
                }    //end if savings


                else if (account.AccountType == AccountType.Current)
                {
                    if (account.AccountBalance >= config.SavingsMinimumBalance + amt)
                    {
                        //REVISIT!!!
                        if (till.AccountBalance >= amt)
                        {
                            busLogic.CreditGl(till, amt);
                            busLogic.DebitCustomerAccount(account, amt);

                            output = "success";
                            decimal x      = (amt + account.CurrentLien) / 1000;
                            decimal charge = (int)x * config.CurrentCot;
                            account.dailyInterestAccrued += charge;
                            account.CurrentLien           = (x - (int)x) * 1000;
                        }
                        else
                        {
                            output = "Insufficient fund in the Till account";
                        }
                    }
                    else
                    {
                        output = "insufficient Balance in Customer's account, cannot withdraw!";
                    }
                }
                else     //for loan
                {
                    output = "Please select a valid account";
                }
                break;

            //break;
            default:
                break;
            } //end switch
            return(output);
        }     //end method PostTeller
Beispiel #22
0
        protected void searchsubmit_OnServerClick(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(TextBoxNameCustAcctNo.Value))
                {
                    throw new Exception("Account Number field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameAmount.Value))
                {
                    throw new Exception("Amount field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameDuration.Value))
                {
                    throw new Exception("Duration field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameCustAcctName.Value))
                {
                    throw new Exception("Account Name field is required");
                }
                if (DropDownListPaymentSchedule.SelectedValue == Core.PaymentSchedule.Days.ToString())
                {
                    if (string.IsNullOrWhiteSpace(TextBoxNameNumberOfDays.Value))
                    {
                        throw new Exception("Number of Days field is required");
                    }
                }


                CustomerAccounts checkclosedoropen =
                    Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ICustomerAccountsDb>()
                    .SearchbyAccountNumber(TextBoxNameCustAcctNo.Value);
                if (checkclosedoropen.IsClosed == false)
                {
                    if (string.IsNullOrWhiteSpace(TextBoxId.Value))
                    {
                        LoanAccount loanAccount = new LoanAccount();

                        CustomerAccounts customerAccounts =
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ICustomerAccountsDb>()
                            .SearchbyAccountNumber(TextBoxNameCustAcctNo.Value);
                        //LoanConfig getLoanById = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<ILoanConfigDb>()
                        //        .RetrieveById(1);
                        IList <LoanConfig> getLoanByIds =
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ILoanConfigDb>()
                            .RetrieveAll();
                        IList <EOD> eods =
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IEODDb>().RetrieveAll();
                        TextBoxNameCustAcctName.Value = customerAccounts.AccountName;
                        loanAccount.LinkedAccount     = new CustomerAccounts();
                        loanAccount.LinkedAccount.Id  = customerAccounts.Id;
                        loanAccount.LoanConfig        = new LoanConfig();
                        //loanAccount.LoanConfig.Id = getLoanById.Id;
                        loanAccount.LoanConfig.Id = getLoanByIds[0].Id;
                        loanAccount.AccountName   = TextBoxNameCustAcctName.Value;
                        loanAccount.LoanAmount    = double.Parse(TextBoxNameAmount.Value);
                        loanAccount.LoanDuration  = double.Parse(TextBoxNameDuration.Value);
                        loanAccount.LoanInterest  = getLoanByIds[0].debitInterestRate;
                        DateTime today = DateTime.Now;
                        loanAccount.LoanStartDate = today;
                        loanAccount.LoanDueDate   = today.AddDays(loanAccount.LoanDuration);
                        Random rand       = new Random();
                        String randomPart = Convert.ToString(rand.Next(10000, 99999));
                        String customerId = customerAccounts.Customer.Id.ToString();
                        loanAccount.AccountNumber   = '3' + customerId + randomPart;
                        loanAccount.Balance         = loanAccount.Balance + double.Parse(TextBoxNameAmount.Value);
                        loanAccount.DateAdded       = DateTime.Now;
                        loanAccount.DateUpdated     = DateTime.Now;
                        loanAccount.PaymentSchedule = (PaymentSchedule)Enum.Parse(typeof(PaymentSchedule), DropDownListPaymentSchedule.SelectedValue);
                        loanAccount.LoanStatus      = LoanStatus.BeingPaid;
                        loanAccount.TransactionDate = eods[0].FinancialDate;
                        if (DropDownListPaymentSchedule.SelectedValue == Core.PaymentSchedule.Days.ToString())
                        {
                            loanAccount.NumberOfDays = int.Parse(TextBoxNameNumberOfDays.Value);
                        }

                        GlAccount glAccount =
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                            .RetrieveById(int.Parse(DropDownListLoanAccount.SelectedValue));
                        GlPostingLogic glPostingLogic = new GlPostingLogic();
                        glAccount.Balance = glPostingLogic.DebitGlAccount(glAccount, loanAccount.LoanAmount);

                        User user = new User();
                        user = (User)Session["User"];
                        //Code to update balance in savings account GL
                        var updateSavingsGlBalance =
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ISavingsConfigDb>()
                            .RetrieveByBranch(user.Branch.Id);
                        updateSavingsGlBalance.SavingsAccountGL.Balance =
                            glPostingLogic.CreditGlAccount(updateSavingsGlBalance.SavingsAccountGL, loanAccount.LoanAmount);



                        //Put Code to update balance in current account GL here:
                        var updateCurrentGlBalance =
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ICurrentConfigDb>()
                            .RetrieveByBranch(user.Branch.Id);
                        updateCurrentGlBalance.currentAccountGL.Balance =
                            glPostingLogic.CreditGlAccount(updateCurrentGlBalance.currentAccountGL,
                                                           loanAccount.LoanAmount);


                        IList <EOD> eod =
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IEODDb>().RetrieveAll();
                        //Code to Save savings Transaction in GL Posting:
                        GlPosting savingsGlPosting = new GlPosting();
                        savingsGlPosting.Amount               = loanAccount.LoanAmount;
                        savingsGlPosting.CreditNarration      = String.Format("{0} Credited", updateSavingsGlBalance.SavingsAccountGL.GlAccountName);
                        savingsGlPosting.DebitNarration       = String.Format("{0} Debited", glAccount.GlAccountName);
                        savingsGlPosting.GlAccountToCredit    = new GlAccount();
                        savingsGlPosting.GlAccountToCredit.Id = updateSavingsGlBalance.SavingsAccountGL.Id;
                        savingsGlPosting.GlAccountToDebit     = new GlAccount();
                        savingsGlPosting.GlAccountToDebit.Id  = glAccount.Id;
                        savingsGlPosting.TransactionDate      = eod[0].FinancialDate;
                        savingsGlPosting.DateAdded            = DateTime.Now;
                        savingsGlPosting.DateUpdated          = DateTime.Now;

                        //Code to Save Current A/C Transaction in GL Posting:
                        GlPosting currentGlPosting = new GlPosting();
                        currentGlPosting.Amount               = loanAccount.LoanAmount;
                        currentGlPosting.CreditNarration      = String.Format("{0} Credited", updateCurrentGlBalance.currentAccountGL.GlAccountName);
                        currentGlPosting.DebitNarration       = String.Format("{0} Debited", glAccount.GlAccountName);
                        currentGlPosting.GlAccountToCredit    = new GlAccount();
                        currentGlPosting.GlAccountToCredit.Id = updateCurrentGlBalance.currentAccountGL.Id;
                        currentGlPosting.GlAccountToDebit     = new GlAccount();
                        currentGlPosting.GlAccountToDebit.Id  = glAccount.Id;
                        currentGlPosting.TransactionDate      = eod[0].FinancialDate;
                        currentGlPosting.DateAdded            = DateTime.Now;
                        currentGlPosting.DateUpdated          = DateTime.Now;

                        TellerPostingLogic tellerPostingLogic = new TellerPostingLogic();
                        var updateCustAcctBal =
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ICustomerAccountsDb>()
                            .SearchbyAccountNumber(TextBoxNameCustAcctNo.Value);
                        updateCustAcctBal.Balance = tellerPostingLogic.CreditCustomerAccounts(customerAccounts,
                                                                                              loanAccount.LoanAmount);



                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ILoanAccountDb>().InsertData(loanAccount);
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>().UpdateData(glAccount);
                        Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <ICustomerAccountsDb>().UpdateData(updateCustAcctBal);
                        if (customerAccounts.AccountType == AccountType.Savings)
                        {
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                            .UpdateData(updateSavingsGlBalance.SavingsAccountGL);
                        }
                        if (customerAccounts.AccountType == AccountType.Current)
                        {
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlAccountDb>()
                            .UpdateData(updateCurrentGlBalance.currentAccountGL);
                        }
                        if (customerAccounts.AccountType == AccountType.Savings)
                        {
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlPostingDb>()
                            .InsertData(savingsGlPosting);
                        }
                        if (customerAccounts.AccountType == AccountType.Current)
                        {
                            Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IGlPostingDb>()
                            .InsertData(currentGlPosting);
                        }
                    }

                    else
                    {
                    }


                    TextBoxNameCustAcctNo.Value   = String.Empty;
                    TextBoxNameCustAcctName.Value = String.Empty;
                    TextBoxNameAmount.Value       = String.Empty;
                    TextBoxNameDuration.Value     = String.Empty;

                    if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Loan Disbursed Successfully." + "', function(){location = '/ManageCustomerAcct/AddLoanAcct.aspx';});</script>", false);
                    }
                }

                else if (checkclosedoropen.IsClosed)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message",
                                                                "<script type='text/javascript'>alertify.alert('Message', '" +
                                                                "Customer Account is closed. Open Account" +
                                                                "', function(){location = '/ManageCustomerAcct/AddLoanAcct.aspx';});</script>",
                                                                false);
                }
            }
            catch (Exception ex)
            {
                if (DropDownListLoanAccount.SelectedValue == "0")
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Loan Account Not Selected. Please Select a Loan Account " + "', function(){});</script>", false);
                }
                //if (DropDownListPaymentSchedule.SelectedValue == "10")
                //{
                //    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Payment Schedule Not Selected. Please Select a Payment Schedule" + "', function(){});</script>", false);
                //}
                string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false);
                }
            }
        }
Beispiel #23
0
        private static void ProcessBalanceEnquiry(Iso8583Message msg, CustomerAccount customerAccount, decimal charges, GlAccount feeIncomeGl)
        {
            UtilityLogic.LogMessage("Processing balance enquiry");
            decimal balance = customerAccount.AccountBalance;
            //append the account balance
            //filed 54 is for additional ammount
            string actType      = customerAccount.AccountType == AccountType.Savings ? "00" : (customerAccount.AccountType == AccountType.Current ? "20" : "00"); //00 is for a default (unspecified) account
            string amtType      = "01";                                                                                                                           // Ledger balance
            string currencyCode = msg.Fields[MessageField.CURRENCY_CODE].ToString();
            string amtSign      = "C";                                                                                                                            //for credit
            string amt          = balance.ToString();

            string additionalField = actType + amtType + currencyCode + amtSign + amt;

            msg.Fields.Add(54, additionalField);
            msg.Fields.Add(39, "00");

            DebitCustomer(customerAccount, charges);
            CreditGl(feeIncomeGl, charges);
        }
Beispiel #24
0
        public static Iso8583Message ProcessMessage(Iso8583Message msg, CbaProcessor.CbaListener.MessageSource msgSource)
        {
            //check the transaction type
            string transactionTypeCode = msg.Fields[MessageField.TRANSACTION_TYPE_FIELD].ToString().Substring(0, 2);
            long   accountNumber       = Convert.ToInt64(msg.Fields[MessageField.FROM_ACCOUNT_ID_FIELD].ToString()); //the From account number is the holders's account number
            var    customerAccount     = actRepo.GetByAccountNumber(accountNumber);

            decimal amount        = Convert.ToDecimal(msg[4].Value) / 100;  //converts to Naira
            decimal charge        = Convert.ToDecimal(msg[28].Value) / 100; //converts to Naira
            decimal processingFee = msg.Fields.Contains(31) ? Convert.ToDecimal(msg[31].Value) / 100 : 0;

            decimal totalCharges = charge + processingFee;
            decimal totalAmt     = amount + totalCharges;

            if (customerAccount == null && transactionTypeCode != "51")     //only for payment by deposit (51) do we not need From acct
            {
                msg.Fields.Add(MessageField.RESPONSE_FIELD, ResponseCode.NO_SAVINGS_ACCOUNT);
                return(msg);
            }

            #region REVERSAL
            if (msg.MessageTypeIdentifier == 420)   //Reversal Advice
            {
                msg.MessageTypeIdentifier = 430;    //Reversal Advice Response
                UtilityLogic.LogMessage("Processing a reversal message...");
                //check the transaction type
                if (transactionTypeCode.Equals(TransactionTypeCode.CASH_WITHDRAWAL))   //Reversing a withdrawal
                {
                    //We can only reverse a withdrawal, transfer or payment transaction for this scope

                    //if Withdrawal, debit the AtmGL and credit the customer account with the (amt+fee) in d msg
                    var atmGl = new GlAccountRepository().GetByName("ATMGL");
                    var withdrawalIncomeGl = glRepo.GetByName("WithdrawalIncomeGl");
                    if (atmGl == null || withdrawalIncomeGl == null)
                    {
                        msg.Fields.Add(39, ResponseCode.ISSUER_OR_SWITCH_INOPERATIVE);   //Issuer or switch inoperative.
                        return(msg);
                    }
                    CreditCustomer(customerAccount, totalAmt);
                    DebitGl(atmGl, amount);
                    DebitGl(withdrawalIncomeGl, totalCharges);

                    msg.Fields.Add(39, "00");       //successful transaction
                    UtilityLogic.LogMessage("Withdrawal Transaction reversed successfully");
                    return(msg);
                }
                else if (transactionTypeCode.Equals(TransactionTypeCode.PAYMENT_FROM_ACCOUNT))   //Reversing a (Payment from account)
                {
                    var onUsPaymentGl       = new GlAccountRepository().GetByName("OnUsPaymentGL");
                    var remoteOnUsPaymentGl = new GlAccountRepository().GetByName("RemoteOnUsPaymentGl");
                    var paymentIncomeGl     = glRepo.GetByName("PaymentIncomeGl");
                    if (onUsPaymentGl == null || remoteOnUsPaymentGl == null || paymentIncomeGl == null)
                    {
                        msg.Fields.Add(39, ResponseCode.ISSUER_OR_SWITCH_INOPERATIVE);   //Issuer or switch inoperative.
                        return(msg);
                    }

                    CreditCustomer(customerAccount, totalAmt);
                    if (msgSource == CbaProcessor.CbaListener.MessageSource.OnUs)
                    {
                        DebitGl(onUsPaymentGl, amount);
                    }
                    else
                    {
                        DebitGl(remoteOnUsPaymentGl, amount);
                    }

                    DebitGl(paymentIncomeGl, totalCharges);

                    msg.Fields.Add(39, "00");       //successful transaction
                    UtilityLogic.LogMessage("Payment reversed successfully");
                    return(msg);
                }
                else if (transactionTypeCode.Equals(TransactionTypeCode.INTRA_BANK_TRANSFER))   //Reversing a Transfer, 24 is assumed
                {
                    GlAccount intraBankTransferIncomeGl = glRepo.GetByName("IntraBankTransferIncomeGl");
                    if (intraBankTransferIncomeGl == null)
                    {
                        msg.Fields.Add(MessageField.RESPONSE_FIELD, ResponseCode.ISSUER_OR_SWITCH_INOPERATIVE);
                        return(msg);
                    }
                    var toAccountNumber = Convert.ToInt64(msg.Fields[MessageField.TO_ACCOUNT_ID_FIELD].Value);
                    var toAct           = new CustomerAccountRepository().GetByAccountNumber(toAccountNumber);
                    if (toAct == null)
                    {
                        msg.Fields.Add(MessageField.RESPONSE_FIELD, ResponseCode.NO_SAVINGS_ACCOUNT);
                        return(msg);
                    }
                    if (!(new CustomerAccountLogic().CustomerAccountHasSufficientBalance(toAct, totalAmt))) //insufficient balance
                    {
                        msg.Fields.Add(39, "51");                                                           //insufficient funds (in the ATM)
                        return(msg);
                    }

                    DebitCustomer(toAct, amount);
                    CreditCustomer(customerAccount, totalAmt);
                    DebitGl(intraBankTransferIncomeGl, totalCharges);

                    msg.Fields.Add(39, ResponseCode.SUCCESS);       //successful transaction
                    UtilityLogic.LogMessage("Transfer reversed successfully");
                    return(msg);
                }
            }
            #endregion

            else if (msg.MessageTypeIdentifier == 200)   //Transaction Request
            {
                msg.MessageTypeIdentifier = 210;
                #region BALANCE ENQUIRY
                //if balance enquiry, get the account number and return the balance
                if (transactionTypeCode.Equals(TransactionTypeCode.BALANCE_ENQUIRY))       //BALANCE ENQUIRY
                {
                    var feeIncomeGl = glRepo.GetByName("GeneralRemoteTransactionIncomeGl");
                    if (feeIncomeGl == null)
                    {
                        msg.Fields.Add(MessageField.RESPONSE_FIELD, ResponseCode.ISSUER_OR_SWITCH_INOPERATIVE);
                        return(msg);
                    }
                    ProcessBalanceEnquiry(msg, customerAccount, totalCharges, feeIncomeGl);
                    return(msg);
                }
                #endregion

                #region CASH WITHDRAWAL
                else if (transactionTypeCode.Equals(TransactionTypeCode.CASH_WITHDRAWAL))      //Cash Withdrawal
                {
                    return(ProcessCashWithrawal(msg, customerAccount, amount, charge, totalCharges, totalAmt));
                }
                #endregion Withdrawal

                #region PAYMENT FROM ACCOUNT
                else if (transactionTypeCode.Equals(TransactionTypeCode.PAYMENT_FROM_ACCOUNT))      //payment from account
                {
                    return(ProcessPaymentFromAccount(msg, msgSource, customerAccount, amount, totalCharges, totalAmt));
                }
                #endregion

                #region PAYMENT BY DEPOSIT
                else if (transactionTypeCode.Equals(TransactionTypeCode.PAYMENT_BY_DEPOSIT))      //PAYMENT BY DEPOSIT
                {
                    return(ProcessPaymentByDeposit(msg, msgSource, amount));
                }
                #endregion

                #region INTRA-BANK TRANSFER
                else if (transactionTypeCode.Equals(TransactionTypeCode.INTRA_BANK_TRANSFER))      //Intra-bank Transfer, 24 is just assumed
                {
                    return(ProcessIntraBankTransfer(msg, customerAccount, amount, totalCharges, totalAmt));
                }
                #endregion Intra-Bank Transfer
            }//End else-if

            //if we got this far, the transaction is invalid
            msg.Fields.Add(39, ResponseCode.INVALID_TRANSACTION);       //INVALID TRANSACTION
            return(msg);
        }
Beispiel #25
0
        public ActionResult SaveCurrentConfig(CurrentAccountConfig config)
        {
            var glAccount             = new GlAccount();
            var configInDb            = _context.GetCurrentConfig();
            var interestExpenseGlInDb = _glAccountContext.Get(config.InterestExpenseGlId);
            var cotIncomeGlInDb       = _glAccountContext.Get(config.COTIncomeGlId);

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

                config.Status = true;               //change the status of configuration to true
                _context.SaveCurrent(config);
                TempData["Success"] = "Configurations Created Successfully";

                return(RedirectToAction("CurrentAccount"));
            }

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

                if (config.InterestExpenseGlId == 0) //check if any of the  gl accounts are the same
                {
                    configInDb.InterestExpenseGlId = configInDb.InterestExpenseGlId;
                }
                else
                {
                    var oldInterestExpenseGlInDb = _glAccountContext.Get(configInDb.InterestExpenseGlId); // free up the old gl accounts that was assigned
                    oldInterestExpenseGlInDb.IsAssigned = false;
                    _glAccountContext.Update(glAccount);

                    configInDb.InterestExpenseGlId = config.InterestExpenseGlId;

                    interestExpenseGlInDb.IsAssigned = true; // Update the  new gl account to is assigned
                    _glAccountContext.Update(glAccount);
                }
                if (config.COTIncomeGlId == 0)
                {
                    configInDb.COTIncomeGlId = configInDb.COTIncomeGlId;
                }
                else
                {
                    var oldIncomeGlInDb = _glAccountContext.Get(configInDb.COTIncomeGlId);
                    oldIncomeGlInDb.IsAssigned = false;
                    _glAccountContext.Update(glAccount);


                    configInDb.COTIncomeGlId   = config.COTIncomeGlId;
                    cotIncomeGlInDb.IsAssigned = true;
                    _glAccountContext.Update(glAccount);
                }

                TempData["Success"] = "Configurations Updated Successfully";
                _context.UpdateCurrent(config);
                return(RedirectToAction("CurrentAccount"));
            }
            return(RedirectToAction("CurrentAccount"));
        }