public static bool IsValid(Proposal proposal) { return (HasValidLoanValue(proposal) && HasValidInstallments(proposal) && HasValidWarranties(proposal) && HasValidProponents(proposal)); }
public static bool HasValidWarranties(Proposal proposal) { foreach (var warranty in proposal.Warranties) { if (!WarrantySpecification.IsProvinceAcceptable(warranty)) { return(false); } // throw new Exception("Proposal has warranty with invalid state"); } return(WarrantySpecification.HasCompatibleValue(proposal) && WarrantySpecification.HasAtLeastOne(proposal)); }
public static bool HasValidProponents(Proposal proposal) { foreach (var proponent in proposal.Proponents) { if (!ProponentSpecification.HasCompatibleIncome(proponent, proposal.InstallmentValue)) { return(false); } // throw new Exception("Proposal has proponent with incompatible income"); } return(ProponentSpecification.HasAtLeastTwo(proposal) && ProponentSpecification.HasSingleMain(proposal) && ProponentSpecification.AreAllOverEighteen(proposal)); }
// O valor do empréstimo deve estar entre R$ 30.000,00 e R$ 3.000.000,00 public static bool HasValidLoanValue(Proposal proposal) { return(proposal.LoanValue >= 30000 && proposal.LoanValue <= 3000000); }
// O empréstimo deve ser pago em no mínimo 2 anos e no máximo 15 anos public static bool HasValidInstallments(Proposal proposal) { return(proposal.Installments >= 2 * 12 && proposal.Installments <= 15 * 12); }
// Deve haver no mínimo 2 proponentes por proposta public static bool HasAtLeastTwo(Proposal proposal) { return(proposal.Proponents.Count >= 2); }
// Todos os proponentes devem ser maiores de 18 anos public static bool AreAllOverEighteen(Proposal proposal) { return(proposal.Proponents.Count(proponent => proponent.Age < 18) == 0); }
// Deve haver exatamente 1 proponente principal por proposta public static bool HasSingleMain(Proposal proposal) { return(proposal.Proponents.Count(proponent => proponent.IsMainProponent) == 1); }
// Dever haver no mínimo 1 garantia de imóvel por proposta public static bool HasAtLeastOne(Proposal proposal) { return(proposal.Warranties.Count > 1); }
// A soma do valor das garantias deve ser maior ou igual ao dobro do valor do empréstimo public static bool HasCompatibleValue(Proposal proposal) { return(proposal.Warranties.Sum(warranty => warranty.Value) >= proposal.LoanValue * 2); }