@@ -3,75 +3,25 @@ package hmda.publication.reports.disclosure
3
3
import akka .NotUsed
4
4
import akka .stream .scaladsl .Source
5
5
import hmda .publication .reports ._
6
- import hmda .model .publication .reports ._
7
- import hmda .publication .reports .util .ReportUtil ._
8
- import hmda .publication .reports .util .ReportsMetaDataLookup
9
6
import hmda .query .model .filing .LoanApplicationRegisterQuery
10
7
11
8
import scala .concurrent .Future
12
9
13
- case class D51 (
14
- respondentId : String ,
15
- institutionName : String ,
16
- year : Int ,
17
- msa : MSAReport ,
18
- applicantIncomes : List [ApplicantIncome ],
19
- total : List [Disposition ],
20
- reportDate : String = formattedCurrentDate,
21
- table : String = D51 .metaData.reportTable,
22
- description : String = D51 .metaData.description
23
- ) extends DisclosureReport
24
-
25
10
object D51 {
26
- val metaData = ReportsMetaDataLookup .values(" D51" )
27
- val dispositions = metaData.dispositions
28
11
29
- // Table filters:
30
- // Loan Type 2,3,4
31
- // Property Type 1,2
32
- // Purpose of Loan 1
12
+ def filters (lar : LoanApplicationRegisterQuery ): Boolean = {
13
+ (lar.loanType == 2 || lar.loanType == 3 || lar.loanType == 4 ) &&
14
+ (lar.propertyType == 1 || lar.propertyType == 2 ) &&
15
+ (lar.purpose == 1 )
16
+ }
17
+
33
18
def generate [ec : EC , mat : MAT , as : AS ](
34
19
larSource : Source [LoanApplicationRegisterQuery , NotUsed ],
35
20
fipsCode : Int ,
36
21
respondentId : String ,
37
22
institutionNameF : Future [String ]
38
- ): Future [D51 ] = {
39
-
40
- val lars = larSource
41
- .filter(lar => lar.respondentId == respondentId)
42
- .filter(lar => lar.msa != " NA" )
43
- .filter(lar => lar.msa.toInt == fipsCode)
44
- .filter { lar =>
45
- (lar.loanType == 2 || lar.loanType == 3 || lar.loanType == 4 ) &&
46
- (lar.propertyType == 1 || lar.propertyType == 2 ) &&
47
- (lar.purpose == 1 )
48
- }
49
- val larsWithIncome = lars.filter(lar => lar.income != " NA" )
50
-
51
- val msa = msaReport(fipsCode.toString)
52
-
53
- val incomeIntervals = calculateMedianIncomeIntervals(fipsCode)
54
- val applicantIncomesF = applicantIncomesWithBorrowerCharacteristics(larsWithIncome, incomeIntervals, dispositions)
55
-
56
- val yearF = calculateYear(larSource)
57
- val totalF = calculateDispositions(lars, dispositions)
58
-
59
- for {
60
- institutionName <- institutionNameF
61
- year <- yearF
62
- applicantIncomes <- applicantIncomesF
63
- total <- totalF
64
- } yield {
65
-
66
- D51 (
67
- respondentId,
68
- institutionName,
69
- year,
70
- msa,
71
- applicantIncomes,
72
- total
73
- )
74
- }
23
+ ): Future [D5X ] = {
75
24
25
+ D5X .generate(" D51" , filters, larSource, fipsCode, respondentId, institutionNameF)
76
26
}
77
27
}
0 commit comments