public ApprovalRegRespObj CustomerTransactionEoD(CustomerTransactionObj item) { try { var update = UpdateCustomerBalanceForEoD(item.DebitAmount, item.CreditAmount, item.CasaAccountNumber, item.ReferenceNo, item.ValueDate.Value.Date); if (update == 0) { return(new ApprovalRegRespObj { Status = new APIResponseStatus { IsSuccessful = false, Message = new APIResponseMessage { FriendlyMessage = "Account Balance Transaction could not update" } } }); } var bal = _dataContext.credit_casa.Where(x => x.AccountNumber == item.CasaAccountNumber).FirstOrDefault().AvailableBalance; fin_customertransaction customerTrans = new fin_customertransaction { TransactionCode = "TRANS-" + GeneralHelpers.GenerateRandomDigitCode(10), AccountNumber = item.CasaAccountNumber, Description = item.Description, TransactionDate = item.TransactionDate, ValueDate = item.ValueDate, TransactionType = item.TransactionType, Amount = item.CreditAmount == 0 ? item.DebitAmount : item.CreditAmount, CreditAmount = item.CreditAmount, DebitAmount = item.DebitAmount, AvailableBalance = bal, Beneficiary = item.Beneficiary, BatchNo = item.ReferenceNo }; _dataContext.fin_customertransaction.Add(customerTrans); var response = _dataContext.SaveChanges() > 0; return(new ApprovalRegRespObj { Status = new APIResponseStatus { IsSuccessful = true, Message = new APIResponseMessage { FriendlyMessage = "Successful" } } }); } catch (Exception ex) { throw ex; } }
public async Task <ApprovalRegRespObj> CustomerTransaction([FromBody] CustomerTransactionObj entity) { try { return(_repo.CustomerTransaction(entity)); } catch (Exception ex) { var errorCode = ErrorID.Generate(5); _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}"); return(new ApprovalRegRespObj { Status = new APIResponseStatus { IsSuccessful = false, Message = new APIResponseMessage { FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode } } }); throw; } }
public async Task <ActionResult <LoanApplicationRespObj> > SubmitLoanForCreditAppraisal([FromQuery] LoanApplicationSearchObj model) { try { var response = await _repo.SubmitLoanForCreditAppraisal(model.LoanApplicationId); if (response.Status.IsSuccessful) { var companyList = await _serverRequest.GetAllCompanyAsync(); var loanObj = _context.credit_loanapplication.Find(model.LoanApplicationId); var customerObj = _context.credit_loancustomer.Find(loanObj.CustomerId); var productFeeList = _context.credit_productfee.Where(x => x.ProductId == loanObj.ApprovedProductId && x.Deleted == false).ToList(); foreach (var item in productFeeList) { decimal productamount = 0; var fee = _context.credit_fee.FirstOrDefault(x => x.FeeId == item.FeeId && x.IsIntegral == false && x.Deleted == false); if (item.ProductFeeType == 2)//Percentage { productamount = (loanObj.ApprovedAmount * Convert.ToDecimal(item.ProductAmount)) / 100; } else///Fixed { productamount = Convert.ToDecimal(item.ProductAmount); } if (fee != null) { CustomerTransactionObj customerTrans = new CustomerTransactionObj { CasaAccountNumber = customerObj.CASAAccountNumber, Description = "Payment of Non Integral Fee", TransactionDate = DateTime.Now, ValueDate = DateTime.Now, TransactionType = "Debit", CreditAmount = 0, DebitAmount = productamount, Beneficiary = companyList.companyStructures.FirstOrDefault(x => x.companyStructureId == loanObj.CompanyId)?.name, ReferenceNo = loanObj.ApplicationRefNumber, }; _customerTrans.CustomerTransaction(customerTrans); } } } return(new LoanApplicationRespObj { ResponseId = response.ResponseId, Status = response.Status }); } catch (Exception ex) { var errorCode = ErrorID.Generate(5); _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}"); return(new LoanApplicationRespObj { Status = new APIResponseStatus { IsSuccessful = false, Message = new APIResponseMessage { FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode } } }); } }