Skip to content

Commit 4653a45

Browse files
authored
Merge pull request cfpb#1164 from nickgrippin/d52
D52
2 parents 47fabe6 + 6a5d7ca commit 4653a45

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ReportId,Type,ReportTable,Dispositions,Description
22
A52,Aggregate,5-2,Received;Originated;ApprovedButNotAccepted;Denied;Withdrawn;Closed,"Disposition of Applications for Conventional Home-Purchase Loans, 1-to-4 Family and Manufactured Home Dwellings, by Income, Race, and Ethnicity of Applicant"
33
D51,Disclosure,5-1,Received;Originated;ApprovedButNotAccepted;Denied;Withdrawn;Closed,"Disposition of applications for FHA, FSA/RHS, and VA home-purchase loans, 1- to 4-family and manufactured home dwellings, by income, race and ethnicity of applicant"
4+
D52,Disclosure,5-2,Received;Originated;ApprovedButNotAccepted;Denied;Withdrawn;Closed,"Disposition of Applications for Conventional Home-Purchase Loans, 1-to-4 Family and Manufactured Home Dwellings, by Income, Race, and Ethnicity of Applicant"
45
D53,Disclosure,5-3,Received;Originated;ApprovedButNotAccepted;Denied;Withdrawn;Closed,"Disposition of Applications to Refinance Loans on 1-to-4 Family and Manufactured Home Dwellings, by Income, Race, and Ethnicity of Applicant"
56
N52,National Aggregate,5-2,Received;Originated;ApprovedButNotAccepted;Denied;Withdrawn;Closed,"Disposition of Applications for Conventional Home-Purchase Loans, 1-to-4 Family and Manufactured Home Dwellings, by Income, Race, and Ethnicity of Applicant"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package hmda.publication.reports.disclosure
2+
3+
import akka.NotUsed
4+
import akka.stream.scaladsl.Source
5+
import hmda.publication.reports._
6+
import hmda.query.model.filing.LoanApplicationRegisterQuery
7+
8+
import scala.concurrent.Future
9+
10+
object D52 {
11+
12+
def filters(lar: LoanApplicationRegisterQuery): Boolean = {
13+
(lar.loanType == 1) &&
14+
(lar.propertyType == 1 || lar.propertyType == 2) &&
15+
(lar.purpose == 1)
16+
}
17+
18+
def generate[ec: EC, mat: MAT, as: AS](
19+
larSource: Source[LoanApplicationRegisterQuery, NotUsed],
20+
fipsCode: Int,
21+
respondentId: String,
22+
institutionNameF: Future[String]
23+
): Future[D5X] = {
24+
25+
D5X.generate("D52", filters, larSource, fipsCode, respondentId, institutionNameF)
26+
}
27+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package hmda.publication.reports.disclosure
2+
3+
import akka.NotUsed
4+
import akka.actor.ActorSystem
5+
import akka.stream.ActorMaterializer
6+
import akka.stream.scaladsl.Source
7+
import hmda.model.fi.lar.{ LarGenerators, LoanApplicationRegister }
8+
import hmda.model.publication.reports.ActionTakenTypeEnum._
9+
import hmda.model.publication.reports.ApplicantIncomeEnum.LessThan50PercentOfMSAMedian
10+
import hmda.model.publication.reports.{ EthnicityBorrowerCharacteristic, MSAReport, MinorityStatusBorrowerCharacteristic, RaceBorrowerCharacteristic }
11+
import hmda.query.model.filing.LoanApplicationRegisterQuery
12+
import hmda.query.repository.filing.LarConverter._
13+
import org.scalacheck.Gen
14+
import org.scalatest.{ AsyncWordSpec, BeforeAndAfterAll, MustMatchers }
15+
16+
import scala.concurrent.Future
17+
18+
class D52Spec extends AsyncWordSpec with MustMatchers with LarGenerators with BeforeAndAfterAll {
19+
20+
implicit val system = ActorSystem()
21+
implicit val ec = system.dispatcher
22+
implicit val materializer = ActorMaterializer()
23+
24+
override def afterAll(): Unit = {
25+
super.afterAll()
26+
system.terminate()
27+
}
28+
29+
val respId = "98765"
30+
val fips = 18700 //Corvallis, OR
31+
def propType = Gen.oneOf(1, 2).sample.get
32+
33+
val lars = lar100ListGen.sample.get.map { lar: LoanApplicationRegister =>
34+
val geo = lar.geography.copy(msa = fips.toString)
35+
val loan = lar.loan.copy(loanType = 1, propertyType = propType, purpose = 1)
36+
lar.copy(respondentId = respId, geography = geo, loan = loan)
37+
}
38+
39+
val source: Source[LoanApplicationRegisterQuery, NotUsed] = Source
40+
.fromIterator(() => lars.toIterator)
41+
.map(lar => toLoanApplicationRegisterQuery(lar))
42+
43+
val expectedDispositions = List(ApplicationReceived, LoansOriginated, ApprovedButNotAccepted, ApplicationsDenied, ApplicationsWithdrawn, ClosedForIncompleteness)
44+
45+
"Generate a Disclosure 5-2 report" in {
46+
D52.generate(source, fips, respId, Future("Corvallis Test Bank")).map { result =>
47+
48+
result.msa mustBe MSAReport("18700", "Corvallis, OR", "OR", "Oregon")
49+
result.table mustBe "5-2"
50+
result.respondentId mustBe "98765"
51+
result.institutionName mustBe "Corvallis Test Bank"
52+
result.applicantIncomes.size mustBe 5
53+
54+
val lowestIncome = result.applicantIncomes.head
55+
lowestIncome.applicantIncome mustBe LessThan50PercentOfMSAMedian
56+
57+
val races = lowestIncome.borrowerCharacteristics.head.asInstanceOf[RaceBorrowerCharacteristic].races
58+
races.size mustBe 8
59+
60+
val ethnicities = lowestIncome.borrowerCharacteristics(1).asInstanceOf[EthnicityBorrowerCharacteristic].ethnicities
61+
ethnicities.size mustBe 4
62+
63+
val minorityStatuses = lowestIncome.borrowerCharacteristics(2).asInstanceOf[MinorityStatusBorrowerCharacteristic].minoritystatus
64+
minorityStatuses.size mustBe 2
65+
66+
races.head.dispositions.map(_.disposition) mustBe expectedDispositions
67+
}
68+
}
69+
70+
}

0 commit comments

Comments
 (0)