// [Authorize(Roles = RoleName.ADMIN_ROLE)] public HttpResponseMessage AddGLPosting(GLPostingDto glPostingDto) { var userId = _context.Users.SingleOrDefault(c => c.Email.Equals(RoleName.EMAIL)).Id; glPostingDto.UserAccountId = userId; var businessStatus = _context.BusinessStatus.SingleOrDefault(); if (businessStatus.Status == false) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, CBA.BUSINESS_CLOSED_REFRESH_MSG)); } glPostingDto.TransactionDate = DateTime.Now; // if (!checkAccountBalance(glPostingDto.GlCreditAccountId,glPostingDto.CreditAmount)) // { // return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "GL Credit Account Balance Insufficient"); // // } // if (!checkAccountBalance(glPostingDto.GlDebitAccountId, glPostingDto.DebitAmount)) // { // return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "GL Debit Account Balance Insufficient"); // // } var glPosting = new GLPostings() { GlCreditAccountId = glPostingDto.GlCreditAccountId, CreditAmount = glPostingDto.CreditAmount, CreditNarration = glPostingDto.CreditNarration, GlDebitAccountId = glPostingDto.GlDebitAccountId, DebitAmount = glPostingDto.DebitAmount, DebitNarration = glPostingDto.DebitNarration, TransactionDate = glPostingDto.TransactionDate, UserAccountId = glPostingDto.UserAccountId }; var tillAccount = _context.Tellers.ToList(); _context.GlPostings.Add(glPosting); _context.SaveChanges(); CBA.CreditAndDebitAccounts(glPostingDto); var financialReportDto = new FinancialReportDto { PostingType = "GL Posting", CreditAccount = GetCreditAccountName(glPostingDto.GlCreditAccountId), CreditAmount = glPostingDto.CreditAmount, DebitAccount = GetDebitAccountName(glPostingDto.GlDebitAccountId), DebitAmount = glPostingDto.DebitAmount, ReportDate = DateTime.Now }; CBA.AddReport(financialReportDto); return(Request.CreateResponse(HttpStatusCode.OK, "GL Posted Successfully")); }
private static Iso8583Message PerformReversal(Iso8583Message message, ListenerPeer listener) { var STAN = ExtractSTAN(message); message = SetFee(message, 0); var transactionsToReverse = _context.TransactionLogs.Where(c => c.STAN.Equals(STAN) && !c.Narration.Equals("Reversal")).ToList(); try { string responseCode = null; if (transactionsToReverse != null || transactionsToReverse.Count > 0) { foreach (var transaction in transactionsToReverse) { if (!transaction.Narration.Equals("Balance Enquiry")) { if (transaction.TypeOfEntry.Equals("Debit")) { if (transaction.Account2 == null) { bool remote1 = false; if (transaction.RemoteOnUs == true) { remote1 = true; } responseCode = CBA.PerformDoubleEntry("Credit", transaction.Account1, transaction.Amount, remote1); var isoAmt = Convert.ToDouble(FormatTo2Dp(Convert.ToDecimal(transaction.Amount))) * 100; message.Fields.Add(4, isoAmt.ToString().PadLeft(10, '0')); new TransactionLogger().LogTransaction(message, "Credit", "Reversal"); transaction.STAN = transaction.STAN + "R"; continue; } } bool remote = false; if (transaction.RemoteOnUs == true) { remote = true; } responseCode = CBA.PerformDoubleEntry("Debit", transaction.Account1, transaction.Amount, remote); var isoAmount = Convert.ToDouble(FormatTo2Dp(Convert.ToDecimal(transaction.Amount))) * 100; message.Fields.Add(4, isoAmount.ToString().PadLeft(10, '0')); new TransactionLogger().LogTransaction(message, "Debit", "Reversal"); transaction.STAN = transaction.STAN + "R"; } } _context.SaveChanges(); message = SetResponseMessage(message, responseCode); message = SendResponseMessage(listener, message); } } catch (Exception e) { Console.WriteLine(e); throw; } return(message); }
public Iso8583Message ProcessTransaction(Iso8583Message message, ListenerPeer listener) { if (message != null) { if (!message.IsReversalOrChargeBack()) { message = CheckIfFeeApplies(message); var fee = ExtractFee(message); var trxType = ExtractTransactionType(message); var accountNumber = ExtractAccountNumber(message); var amount = ExtractAmount(message); var STAN = ExtractSTAN(message); var RRN = ExtractRRN(message); if (trxType.ToString().Equals(Codes.WITHDRAWAL) || trxType.ToString().Equals(Codes.PAYMENT)) { if (accountNumber != null && amount != null) { if (trxType.ToString().Equals(Codes.PAYMENT)) { } var responseCode = CBA.PerformDoubleEntry("Debit", accountNumber, (amount + fee), CheckIfRemote(message)); message = SetResponseMessage(message, responseCode); message = SendResponseMessage(listener, message); if (!message.Fields[39].Value.ToString().Equals(Codes.APPROVED)) { Debug.WriteLine("Transaction Incomplete ..."); } else { new TransactionLogger().LogTransaction(message, "Debit", "Request"); Debug.WriteLine("Transaction Complete ..."); } } } else if (trxType.ToString().Equals(Codes.BALANCE_ENQUIRY)) { var amountEnquired = CBA.BalanceEnquiry(accountNumber); if (amountEnquired != null) { message.Fields.Add(54, amountEnquired); message.Fields.Add(4, "0000000000"); SetResponseMessage(message, Codes.APPROVED); message = SendResponseMessage(listener, message); new TransactionLogger().LogTransaction(message, null, "Balance Enquiry"); } } return(message); } if (message.IsReversalOrChargeBack()) { message = PerformReversal(message, listener); } } return(message); }
public void AddToReport(string postingType, string debitAccountName, string creditAccountName, float amount) { var creditAmount = (float)System.Math.Round(amount, 2); var debitAmount = (float)System.Math.Round(amount, 2); var financialReportDto = new FinancialReportDto { PostingType = postingType, DebitAccount = debitAccountName, DebitAmount = debitAmount, CreditAccount = creditAccountName, CreditAmount = creditAmount, ReportDate = DateTime.Now }; CBA.AddReport(financialReportDto); }
static void Main(string[] args) { log4net.ILog Logger = log4net.LogManager.GetLogger("AppLogger"); Parallel.For(0, 10000, new ParallelOptions { MaxDegreeOfParallelism = 4 }, i => { StringBuilder sb = new StringBuilder(); CBA cba = new CBA(); cba.executor(sb); Logger.InfoFormat("++Running as {0}", sb.ToString()); }); Logger.Error("This will appear in red in the console and still be written to file!"); Console.ReadLine(); }
public ActionResult Create(CustomerViewModel customerViewModel) { customerViewModel.Customer.Id = CBA.RandomString(9); if (!ModelState.IsValid) { ViewBag.Message = "Invalid"; return(View("Index")); } var customer = new Customer() { Address = customerViewModel.Customer.Address, Email = customerViewModel.Customer.Email, Gender = customerViewModel.Customer.Gender, Id = customerViewModel.Customer.Id, Name = customerViewModel.Customer.Name, PhoneNumber = customerViewModel.Customer.PhoneNumber }; _context.Customers.Add(customer); _context.SaveChanges(); return(RedirectToAction("Index", "Customers")); }
public HttpResponseMessage AddCustomer(CustomerDto customerDto) { customerDto.Id = CBA.RandomString(9); ValidateCustomer(customerDto); if (!errorMessage.Equals("")) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage)); } var customer = new Customer() { Id = customerDto.Id, Address = customerDto.Address.ToString(), Email = customerDto.Email.ToString(), Gender = customerDto.Gender.ToString(), Name = customerDto.Name.ToString(), PhoneNumber = customerDto.PhoneNumber.ToString() }; _context.Customers.Add(customer); _context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Customer has been added successfully")); }
public CBADecorator(CBA inner, A a, B b) : base(a, b) { Inner = inner; }
// [Authorize] public HttpResponseMessage AddTellerPosting(TellerPostingDto tellerPostingDto) { var businessStatus = _context.BusinessStatus.SingleOrDefault(); var customerAccountStatus = _context.CustomerAccounts .SingleOrDefault(c => c.Id == tellerPostingDto.CustomerAccountId).IsClosed; var userId = _context.Users.SingleOrDefault(c => c.Email.Equals(RoleName.EMAIL)).Id; var teller = _context.Tellers.SingleOrDefault(c => c.UserTellerId.Equals(userId)); if (teller != null) { var tellerId = teller.Id; tellerPostingDto.TellerId = tellerId; if (businessStatus.Status == false) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, CBA.BUSINESS_CLOSED_REFRESH_MSG)); } if (customerAccountStatus == true) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Customer Account is <b>CLOSED</b>")); } tellerPostingDto.TransactionDate = DateTime.Now; var tellerPosting = new TellerPosting(); tellerPosting = Mapper.Map <TellerPostingDto, TellerPosting>(tellerPostingDto); _context.TellerPostings.Add(tellerPosting); _context.SaveChanges(); EnforceDoubleEntry(tellerPostingDto.Amount, tellerPosting.CustomerAccountId, tellerPostingDto.PostingType); var financialReportDto = new FinancialReportDto(); financialReportDto.PostingType = "Teller Posting"; if (tellerPostingDto.PostingType == "Deposit") { financialReportDto.CreditAccount = GetCustomerAccountName(tellerPostingDto.CustomerAccountId); financialReportDto.CreditAmount = tellerPostingDto.Amount; financialReportDto.DebitAccount = GetTillAccountName(); financialReportDto.DebitAmount = tellerPostingDto.Amount; } else { financialReportDto.DebitAccount = GetCustomerAccountName(tellerPostingDto.CustomerAccountId); financialReportDto.DebitAmount = tellerPostingDto.Amount; financialReportDto.CreditAccount = GetTillAccountName(); financialReportDto.CreditAmount = tellerPostingDto.Amount; } financialReportDto.ReportDate = DateTime.Now; if (!errorMessage.Equals("")) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage)); } CBA.AddReport(financialReportDto); return(Request.CreateResponse(HttpStatusCode.OK, "Teller Posted Successfully")); } errorMessage = "You have not been assigned a Till Account"; return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, errorMessage)); }