static void CreditGl(GlAccount gl, decimal amt) { blogic.CreditGl(gl, amt); //credit the basic amt glRepo.Update(gl); frLogic.CreateTransaction(gl, amt, TransactionType.Credit); UtilityLogic.LogMessage("Gl account: " + gl.CodeNumber + " creditted NGN" + amt); }
static void Listener_Disconnected(object sender, EventArgs e) { var listener = sender as ListenerPeer; UtilityLogic.LogMessage(listener.Name + " is disonnected"); //Console.WriteLine("Client Disconnected!"); }
static void CreditCustomer(CustomerAccount act, decimal amt) { blogic.CreditCustomerAccount(act, amt); actRepo.Update(act); frLogic.CreateTransaction(act, amt, TransactionType.Credit); //records every Dr and Cr entries to ensure a balance FR UtilityLogic.LogMessage("Customer account: " + act.AccountNumber + " creditted NGN" + amt); }
private static Iso8583Message ProcessPaymentByDeposit(Iso8583Message msg, CbaProcessor.CbaListener.MessageSource msgSource, decimal amount) { UtilityLogic.LogMessage("Processing payment by deposit"); if (!(msgSource == CbaListener.MessageSource.OnUs)) { msg.Fields.Add(MessageField.RESPONSE_FIELD, "31"); //bank not supported return(msg); } //Credit custAct and debit AtmGl 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); } var atmGl = new GlAccountRepository().GetByName("ATMGL"); if (atmGl == null) { msg.Fields.Add(39, ResponseCode.ISSUER_OR_SWITCH_INOPERATIVE); //Issuer or switch inoperative. return(msg); } CreditCustomer(toAct, amount); DebitGl(atmGl, amount); msg.Fields.Add(39, "00"); //successful transaction UtilityLogic.LogMessage("Payment Transaction successful"); return(msg); }
private static Iso8583Message ProcessIntraBankTransfer(Iso8583Message msg, CustomerAccount customerAccount, decimal amount, decimal totalCharges, decimal totalAmt) { UtilityLogic.LogMessage("Processing Intra-bank transfer"); 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(customerAccount, totalAmt))) //insufficient balance { msg.Fields.Add(39, "51"); //insufficient funds (in the ATM) return(msg); } DebitCustomer(customerAccount, totalAmt); CreditCustomer(toAct, amount); CreditGl(intraBankTransferIncomeGl, totalCharges); msg.Fields.Add(39, "00"); //successful transaction UtilityLogic.LogMessage("Transfer executed successfully"); return(msg); }
//UtilityLogic utility = new UtilityLogic(); public void BeginProcess() { UtilityLogic.LogMessage("Initializing nodes..."); var nodes = new NodeRepository().GetAll(); if (nodes == null || nodes.Count() < 1) { UtilityLogic.LogError("No node is configured!"); } else { foreach (var node in nodes) { try { CbaListener.StartUpListener(node.ID.ToString(), node.HostName, Convert.ToInt32(node.Port)); UtilityLogic.LogMessage(node.Name + " now listening on port " + node.Port); } catch (Exception ex) { UtilityLogic.LogError("Message: " + ex.Message + " \t InnerException " + ex.InnerException); } } } }
//[ClaimsAuthorize("DynamicClaim", "AddNewUser")] public async Task <ActionResult> Create(CreateUserViewModel model) { ViewBag.Roles = new SelectList(db.Roles, "ID", "Name"); if (ModelState.IsValid) { try { if (!userLogic.IsUniqueUsername(model.Username)) { AddError("Username must be unique"); return(View(model)); } if (!userLogic.IsUniqueEmail(model.Email)) { AddError("Email must be unique"); return(View(model)); } string autoGeneratedPassword = new UtilityLogic().GetRandomPassword(); var user = new ApplicationUser { UserName = model.Username, Email = model.Email, RoleID = model.RoleID, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber, PasswordChanged = false }; // Send generated password to the user try { userLogic.SendPasswordToUser(model.FirstName, model.Email, model.Username, autoGeneratedPassword); } catch (Exception ex) { AddError($"We encountered an error while attempting to send the mail.\n Error Message : {ex.Message}.\n The auto generated password is: {autoGeneratedPassword}"); } var result = await UserManager.CreateAsync(user, autoGeneratedPassword); if (result.Succeeded) { return(RedirectToAction("Index")); } AddErrors(result); return(View(model)); } catch (Exception ex) { AddError(ex.ToString()); return(View(model)); } } AddError("Please enter valid data"); return(View(model)); }
public async Task <ActionResult> Create(CreateUserViewModel model) { ViewBag.Roles = new SelectList(db.Roles, "ID", "Name"); ViewBag.Branches = new SelectList(db.Branches, "ID", "Name"); if (ModelState.IsValid) { try { if (!userLogic.IsUniqueUsername(model.Username)) { AddError("Username must be unique"); return(View(model)); } if (!userLogic.IsUniqueEmail(model.Email)) { AddError("Email must be unique"); return(View(model)); } string autoGenPassword = new UtilityLogic().GetRandomPassword(); var user = new ApplicationUser { UserName = model.Username, Email = model.Email, BranchID = model.BranchID, RoleID = model.RoleID, FullName = model.FullName, PhoneNumber = model.PhoneNumber, PasswordChanged = false }; try { userLogic.SendPasswordToUser(model.FullName, model.Email, model.Username, autoGenPassword); } catch (Exception ex) { AddError($"An error occured while sending mail, please try again later. Error Message : {ex.Message}. The auto generated is : {autoGenPassword}"); return(View(model)); // return RedirectToAction("Create", new { message = "[User added : " + autoGenPassword + "].Send Mail Failed." }); } var result = await UserManager.CreateAsync(user, autoGenPassword); if (result.Succeeded) { return(RedirectToAction("Index")); } AddErrors(result); return(View(model)); } catch (Exception ex) { ModelState.AddModelError("", ex.ToString()); return(View(model)); } } ModelState.AddModelError("", "Please enter valid data"); return(View(model)); }
// GET: BranchEmailMaster public ActionResult Index() { if (GeneralClass.Role == null || GeneralClass.Role == string.Empty) { return(Redirect(GeneralClass.LoginURL)); } object dataBranch = new UtilityLogic().GetAllBranch(); if (dataBranch != null) { ViewBag.BranchList = JsonConvert.DeserializeObject <List <UtilityClass> >(dataBranch.ToString()); } return(View()); }
private static Iso8583Message ProcessCashWithrawal(Iso8583Message msg, CustomerAccount customerAccount, decimal amount, decimal charge, decimal totalCharges, decimal totalAmt) { UtilityLogic.LogMessage("Processing cash withdrawal"); //for withdrawal, get the fromAccount, the amount and charge. Check the available balance and ... if (!(new CustomerAccountLogic().CustomerAccountHasSufficientBalance(customerAccount, totalAmt))) { msg.Fields.Add(39, "51"); //not sufficient funds (Insufficient balance) in customer's account return(msg); } //perform withdrawal try { //check if a GL account is set for the atm 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); } if (atmGl.AccountBalance < (amount + charge)) { msg.Fields.Add(39, "51"); //insufficient funds (in the ATM) return(msg); } //DEBIT AND CREDIT DebitCustomer(customerAccount, totalAmt); CreditGl(atmGl, amount); CreditGl(withdrawalIncomeGl, totalCharges); //same gl for both onus and remote on-us msg.Fields.Add(39, "00"); //successful transaction UtilityLogic.LogMessage("Withdrawal Transaction successful"); return(msg); } catch (Exception ex) { UtilityLogic.LogError("Error: " + ex.Message + " Inner Exception: " + ex.InnerException); msg.Fields.Add(39, "06"); //ERROR! return(msg); } }
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); }
static void Listener_Receive(object sender, ReceiveEventArgs e) { try { UtilityLogic.LogMessage("Message received!"); var client = sender as ClientPeer; Iso8583Message msg = e.Message as Iso8583Message; switch (GetTransactionSource(msg)) { case MessageSource.OnUs: msg = TransactionManager.ProcessMessage(msg, MessageSource.OnUs); break; case MessageSource.RemoteOnUs: msg = TransactionManager.ProcessMessage(msg, MessageSource.RemoteOnUs); //do nothing yet break; case MessageSource.NotOnUs: //redirect to interswitch msg.Fields.Add(39, "31"); //bank not supported break; default: break; } PeerRequest request = new PeerRequest(client, msg); request.Send(); client.Close(); client.Dispose(); } catch (Exception ex) { UtilityLogic.LogError("Error processing the incoming meaasgae"); UtilityLogic.LogError("Message: " + ex.Message + " \t InnerException " + ex.InnerException); } }
private static Iso8583Message ProcessPaymentFromAccount(Iso8583Message msg, CbaProcessor.CbaListener.MessageSource msgSource, CustomerAccount customerAccount, decimal amount, decimal totalCharges, decimal totalAmt) { UtilityLogic.LogMessage("Processing payment from account"); //debit custAct and credit OnUsPaymentGL (may ba a capital GL) if (!(new CustomerAccountLogic().CustomerAccountHasSufficientBalance(customerAccount, totalAmt))) //insufficient balance { msg.Fields.Add(39, "51"); //insufficient funds (in the ATM) return(msg); } 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); } DebitCustomer(customerAccount, totalAmt); if (msgSource == CbaProcessor.CbaListener.MessageSource.OnUs) { CreditGl(onUsPaymentGl, amount); } else { CreditGl(remoteOnUsPaymentGl, amount); } CreditGl(paymentIncomeGl, totalCharges); msg.Fields.Add(39, "00"); //successful transaction UtilityLogic.LogMessage("Payment Transaction successful"); return(msg); }
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); }
public ActionResult Index() { if (Request.QueryString.Count == 0) { return(Redirect(GeneralClass.LoginURL)); } else if (Request.QueryString.Count == 4) // Branch { if (Request.QueryString.AllKeys.Contains("eid") == false && Request.QueryString.AllKeys.Contains("enm") == false && Request.QueryString.AllKeys.Contains("bnm") == false && Request.QueryString.AllKeys.Contains("role") == false) { return(Redirect(GeneralClass.LoginURL)); } else { GeneralClass.EmployeeID = Request.QueryString["eid"].ToString(); GeneralClass.EmployeeName = Request.QueryString["enm"].ToString(); GeneralClass.BranchID = Request.QueryString["bnm"].ToString(); GeneralClass.Role = Request.QueryString["role"].ToString(); } } else if (Request.QueryString.Count == 3) // Audit { if (Request.QueryString.AllKeys.Contains("eid") == false && Request.QueryString.AllKeys.Contains("enm") == false && Request.QueryString.AllKeys.Contains("role") == false) { return(Redirect(GeneralClass.LoginURL)); } else { GeneralClass.EmployeeID = Request.QueryString["eid"].ToString(); GeneralClass.EmployeeName = Request.QueryString["enm"].ToString(); GeneralClass.Role = Request.QueryString["role"].ToString(); } } else { return(Redirect(GeneralClass.LoginURL)); } object dataStatus = new StatusMasterLogic().StatusMaster_Get_GetAll(0, true); if (dataStatus != null) { ViewBag.StatusList = JsonConvert.DeserializeObject <List <StatusMasterClass> >(dataStatus.ToString()); } object dataBranch = new UtilityLogic().GetAllBranch(); if (dataBranch != null) { ViewBag.BranchList = JsonConvert.DeserializeObject <List <UtilityClass> >(dataBranch.ToString()); } object dataReason = new ReasonMasterLogic().ReasonMaster_Get_GetAll(0, true); if (dataReason != null) { ViewBag.ReasonList = JsonConvert.DeserializeObject <List <ReasonMasterClass> >(dataReason.ToString()); } return(View()); }
public JsonResult GetDashboardCount(string BranchID) { object data = new UtilityLogic().DashboardCount(BranchID); return(Json(data, JsonRequestBehavior.AllowGet)); }