Ejemplo n.º 1
0
        public QualificationService(IAccountManager accountManager, IUnitOfWork unitOfWork)
        {
            this.accountManager = accountManager;
            this.unitOfWork     = unitOfWork;

            settings = new QualificationSettings();
        }
Ejemplo n.º 2
0
        public QualificationResult Qualify(string userId)
        {
            QualificationResult result = new QualificationResult();

            QualificationSettings settings = new QualificationSettings();

            LoanQualificationApplication app = unitOfWork.LoanApplications.GetLatestApp(userId);

            if (app.NetIncome < settings.MinimumNetIncome)
            {
                result.QualifyAmount = 0;
                result.DeniedReason  = "Net income doesn't meet required minimum";
                return(result);
            }

            result.QualifyAmount = QualifyAmount(app);

            if (DateTime.Now > (app.CreatedDate.AddDays(settings.AppValidDays)))
            {
                result.DeniedReason = "Qualification out of date";
                return(result);
            }

            List <Loan> loansInNegStatus = unitOfWork.Loans.GetLoansInNegativeStatus(userId);

            if (loansInNegStatus.Count > 0)
            {
                result.DeniedReason = "laon(s) in negative status";
                return(result);
            }



            BankAccount activeBankAccount = unitOfWork.BankAccounts.GetActive(userId);

            if (activeBankAccount == null)
            {
                result.DeniedReason = "No Active Bank account";
                return(result);
            }

            Transaction lastTransaction = unitOfWork.Transactions.GetLastTransaction(activeBankAccount.Id);

            if (lastTransaction != null &&
                lastTransaction.StatusId == (int)TransactionStatuses.Bounced ||
                lastTransaction.StatusId == (int)TransactionStatuses.Failed)
            {
                result.DeniedReason = "Last Transaction Failed";
                return(result);
            }

            if (activeBankAccount.IsAuthorized)
            {
                result.DeniedReason = "Bank Account Not Authorized";
                return(result);
            }

            if (activeBankAccount.IsVerified)
            {
                result.DeniedReason = "Bank Account Not Verified";
                return(result);
            }



            return(result);
        }