// execute covenant rules one by one // *** this allows for future extensibility. *** public bool CheckCovenants(FormattedCovenants covenants, Loan loan) { var ruleStatus = true; foreach (var rule in covenantRules) { // if any of the rule is not fulfilled, loan can not be assigned to current facility var currentRuleResult = rule.CheckRule(covenants, loan); if (currentRuleResult == false) { ruleStatus = false; break; } } return(ruleStatus); }
public List <FormattedCovenants> FormatCovenants(List <Facility> facilities, List <Covenant> covenants) { List <FormattedCovenants> formattedCovenants = new List <FormattedCovenants>(); foreach (var facility in facilities) { var formattedCovant = new FormattedCovenants(); var rules = covenants.Where(c => c.FacilityId == facility.Id); formattedCovant.BannedStates = new List <string>(); foreach (var rule in rules) { formattedCovant.BankId = facility.BankId; formattedCovant.FacilityId = facility.Id; if (rule.MaxDefaultLikelihood != null) { formattedCovant.MaxDefaultLikelihood = rule.MaxDefaultLikelihood; } formattedCovant.BannedStates.Add(rule.BannedState); } formattedCovenants.Add(formattedCovant); } return(formattedCovenants); }
// make sure the loan's default likelihood is less than facility's public bool CheckRule(FormattedCovenants covenants, Loan loan) { return(loan.DefaultLikelyhood <= covenants.MaxDefaultLikelihood); }
// make sure the loan state is not in banned state public bool CheckRule(FormattedCovenants covenants, Loan loan) { return(!(covenants.BannedStates.Contains(loan.State))); }