// Post Teller Product Repayments public bool PostProductRepayment(TellerProductRepaymentsView custDetails, List <RepaymentView> repayments, string tellerLoginCode, string deviceInfo) { bool transactionPosted = false; string tellerAccount = GetTellerGlAccount(tellerLoginCode); double transactionAmount = repayments.Where(x => x.CustomerNo == custDetails.CustomerNo).Sum(x => x.Amount); Validate_Teller_Transaction("PRODUCTREPAYMENTS", tellerAccount, transactionAmount); if (repayments == null || repayments.Count == 0 || repayments.Sum(x => x.Amount) == 0) { _validationDictionary.AddError("customerDetails.CustomerNo", " Nothing To Post "); } string m_transactionid = ValueConverters.RandomString(10); DateTime trdatenow = DateTime.Now; string trdescpt = "Product Repayments Cash Deposit From Mobile App"; string glaccount_db = tellerAccount; string glaccount_cr = string.Empty; string docid = "MAPP"; string referenceNo = transactionsEngine.Generate_PostReference(docid); bool post_comm_to_customerBranch = true;// transactionsEngine.Get_Other_Settings("POST_TELLER_LOAN_INCOME_TO_CUSTOMER_BRANCH"); string defaultBranch = "99"; List <PostTransactionsViewModel> translist = new List <PostTransactionsViewModel>(); InvestmentsCodesManager investMgr = new InvestmentsCodesManager(); LoanProductsManager loanProductsMgr = new LoanProductsManager(); Esoft_WebEntities db = new Esoft_WebEntities(); List <CustomerBalances> customerBalances = new List <CustomerBalances>(); customerBalances = customerManager.GetCustomerBalances(custDetails.CustomerNo, DateTime.Now, customerBalances); string income_branch = defaultBranch; if (post_comm_to_customerBranch) { income_branch = db.tbl_Customer.FirstOrDefault(x => x.CustomerNo == custDetails.CustomerNo).Branch; } var investmentCodes = investMgr.InvestmentsCodes(db).ToList(); var loanCodes = loanProductsMgr.GetLoanCodes(db).ToList(); foreach (var repayment in repayments.Where(x => x.CustomerNo == custDetails.CustomerNo)) { switch (repayment.Ledger) { case "SAVINGS": trdescpt = String.Format("Cash Deposits Mobile App: {0}", referenceNo); CustomerAccountsView customerDetails = customerAccountsManager.GetAccountByAccountNumber(repayment.ProductCode); glaccount_cr = customerDetails.GlMemSav; transactionsEngine.Generate_Ledger_Transactions(translist, m_transactionid, repayment.ProductCode, trdatenow, trdescpt, docid, referenceNo, repayment.Amount, 0, income_branch, glaccount_db, glaccount_cr, tellerAccount, tellerLoginCode); transactionsEngine.Generate_Ledger_Transactions(translist, m_transactionid, repayment.ProductCode, trdatenow, trdescpt, docid, referenceNo, 0, repayment.Amount, income_branch, glaccount_cr, glaccount_db, tellerAccount, tellerLoginCode); transactionsEngine.Generate_Savings_Transactions(translist, m_transactionid, repayment.ProductCode, trdatenow, trdescpt, docid, referenceNo, repayment.Amount, 0, income_branch, glaccount_cr, glaccount_db, repayment.CustomerNo, glaccount_cr, string.Empty, tellerLoginCode); LogMobileTrail(new MobileOperatorTrail() { ReferenceNo = referenceNo, Ledger = "S", CustomerNo = custDetails.CustomerNo, AccountNo = repayment.ProductCode, TransactionDate = trdatenow, Description = trdescpt, Amount = ValueConverters.ConvertDoubleToDecimal(repayment.Amount), DeviceInfo = deviceInfo ?? String.Empty, LoginCode = tellerLoginCode, }); break; case "INVESTMENTS": trdescpt = String.Format("Cash Deposits Mobile App: {0}", referenceNo); glaccount_cr = investmentCodes.FirstOrDefault(x => x.InvestmentCode == repayment.ProductCode).PrincipalAccount.ToString(); transactionsEngine.Generate_Shares_Transactions(translist, m_transactionid, repayment.CustomerNo, trdatenow, trdescpt, docid, referenceNo, 0, repayment.Amount, income_branch, glaccount_db, glaccount_cr, repayment.ProductCode, tellerLoginCode); transactionsEngine.Generate_Ledger_Transactions(translist, m_transactionid, repayment.CustomerNo, trdatenow, trdescpt, docid, referenceNo, 0, repayment.Amount, income_branch, glaccount_cr, tellerAccount, repayment.CustomerNo, tellerLoginCode); // final Debit to Teller Account transactionsEngine.Generate_Ledger_Transactions(translist, m_transactionid, custDetails.CustomerNo, trdatenow, trdescpt, docid, referenceNo, repayment.Amount, 0, income_branch, tellerAccount, glaccount_cr, custDetails.CustomerNo, tellerLoginCode); LogMobileTrail(new MobileOperatorTrail() { ReferenceNo = referenceNo, Ledger = "I", CustomerNo = custDetails.CustomerNo, AccountNo = repayment.ProductCode, TransactionDate = trdatenow, Description = trdescpt, Amount = ValueConverters.ConvertDoubleToDecimal(repayment.Amount), DeviceInfo = deviceInfo ?? String.Empty, LoginCode = tellerLoginCode, }); break; case "LOANS": trdescpt = String.Format("Loan Repayment Mobile App: {0}", referenceNo); var loanProduct = loanCodes.FirstOrDefault(x => x.LoanCode == repayment.ProductCode); loanProductsMgr.Distribute_LoanRepayment(repayment, customerBalances, loanProduct, true); glaccount_cr = loanProduct.PrincipalAccount; loanProductsMgr.GenerateLoanRepaymentStatements(transactionsEngine, translist, m_transactionid, repayment, loanProduct, trdatenow, trdescpt, docid, referenceNo, 0, 0, income_branch, tellerAccount, "1", "", false, tellerLoginCode, db); // final Debit to Teller Account transactionsEngine.Generate_Ledger_Transactions(translist, m_transactionid, custDetails.CustomerNo, trdatenow, trdescpt, docid, referenceNo, repayment.Amount, 0, income_branch, tellerAccount, glaccount_cr, custDetails.CustomerNo, tellerLoginCode); LogMobileTrail(new MobileOperatorTrail() { ReferenceNo = referenceNo, Ledger = "L", CustomerNo = custDetails.CustomerNo, AccountNo = repayment.ProductCode, TransactionDate = trdatenow, Description = trdescpt, Amount = ValueConverters.ConvertDoubleToDecimal(repayment.Amount), DeviceInfo = deviceInfo ?? String.Empty, LoginCode = tellerLoginCode, }); break; default: break; } } string result = transactionsEngine.Post_Transactions(translist, m_transactionid, false, false); if (result == "Transactions Was Updated Successfully ") { transactionPosted = true; } else { _validationDictionary.AddError("", result); } return(transactionPosted); }