@@ -4,6 +4,7 @@ import java.util.Calendar
4
4
5
5
import akka .NotUsed
6
6
import akka .stream .scaladsl .Source
7
+ import hmda .census .model .MsaIncomeLookup
7
8
import hmda .model .publication .reports .ApplicantIncomeEnum ._
8
9
import hmda .model .publication .reports .{ ApplicantIncome , Disposition , MSAReport }
9
10
import hmda .publication .reports ._
@@ -16,13 +17,17 @@ import hmda.query.model.filing.LoanApplicationRegisterQuery
16
17
import scala .concurrent .Future
17
18
18
19
case class N52 (
19
- year : Int ,
20
- reportDate : String ,
21
- applicantIncomes : List [ApplicantIncome ],
22
- total : List [Disposition ],
20
+ year : Int = 0 ,
21
+ reportDate : String = " " ,
22
+ applicantIncomes : List [ApplicantIncome ] = List () ,
23
+ total : List [Disposition ] = List () ,
23
24
table : String = N52 .metaData.reportTable,
24
25
description : String = N52 .metaData.description
25
- ) extends NationalAggregateReport
26
+ ) extends NationalAggregateReport {
27
+ def + (a52 : A52 ): N52 = {
28
+
29
+ }
30
+ }
26
31
27
32
object N52 {
28
33
val metaData = ReportsMetaDataLookup .values(" N52" )
@@ -39,61 +44,61 @@ object N52 {
39
44
(lar.propertyType == 1 || lar.propertyType == 2 ) &&
40
45
(lar.purpose == 1 )
41
46
}
42
-
43
47
val larsWithIncome = lars.filter(lar => lar.income != " NA" )
44
- val incomeIntervals = calculateMedianIncomeIntervals(fipsCode)
45
-
46
- val larsByIncome = larsByIncomeInterval(larsWithIncome, incomeIntervals)
47
- val borrowerCharacteristicsByIncomeF = borrowerCharacteristicsByIncomeInterval(larsByIncome, dispositions)
48
48
49
+ val fipsList = MsaIncomeLookup .values.map(_.fips)
49
50
val yearF = calculateYear(larSource)
50
51
val totalF = calculateDispositions(lars, dispositions)
51
52
52
- for {
53
- lars50BorrowerCharacteristics <- borrowerCharacteristicsByIncomeF(LessThan50PercentOfMSAMedian )
54
- lars50To79BorrowerCharacteristics <- borrowerCharacteristicsByIncomeF(Between50And79PercentOfMSAMedian )
55
- lars80To99BorrowerCharacteristics <- borrowerCharacteristicsByIncomeF(Between80And99PercentOfMSAMedian )
56
- lars100To120BorrowerCharacteristics <- borrowerCharacteristicsByIncomeF(Between100And119PercentOfMSAMedian )
57
- lars120BorrowerCharacteristics <- borrowerCharacteristicsByIncomeF(GreaterThan120PercentOfMSAMedian )
58
53
59
- year <- yearF
60
- total <- totalF
61
- } yield {
62
- val income50 = ApplicantIncome (
63
- LessThan50PercentOfMSAMedian ,
64
- lars50BorrowerCharacteristics
65
- )
66
- val income50To79 = ApplicantIncome (
67
- Between50And79PercentOfMSAMedian ,
68
- lars50To79BorrowerCharacteristics
69
- )
70
- val income80To99 = ApplicantIncome (
71
- Between80And99PercentOfMSAMedian ,
72
- lars80To99BorrowerCharacteristics
73
- )
74
- val income100To120 = ApplicantIncome (
75
- Between100And119PercentOfMSAMedian ,
76
- lars100To120BorrowerCharacteristics
77
- )
78
- val income120 = ApplicantIncome (
79
- GreaterThan120PercentOfMSAMedian ,
80
- lars120BorrowerCharacteristics
81
- )
54
+ fipsList.foreach(fipsCode => {
55
+ val incomeIntervals = calculateMedianIncomeIntervals(fipsCode)
56
+ val larsByIncome = larsByIncomeInterval(larsWithIncome, incomeIntervals)
57
+ val borrowerCharacteristicsByIncomeF = borrowerCharacteristicsByIncomeInterval(larsByIncome, dispositions)
58
+
59
+ for {
60
+ lars50BorrowerCharacteristics <- borrowerCharacteristicsByIncomeF(LessThan50PercentOfMSAMedian )
61
+ lars50To79BorrowerCharacteristics <- borrowerCharacteristicsByIncomeF(Between50And79PercentOfMSAMedian )
62
+ lars80To99BorrowerCharacteristics <- borrowerCharacteristicsByIncomeF(Between80And99PercentOfMSAMedian )
63
+ lars100To120BorrowerCharacteristics <- borrowerCharacteristicsByIncomeF(Between100And119PercentOfMSAMedian )
64
+ lars120BorrowerCharacteristics <- borrowerCharacteristicsByIncomeF(GreaterThan120PercentOfMSAMedian )
65
+ } yield {
66
+ val income50 = ApplicantIncome (
67
+ LessThan50PercentOfMSAMedian ,
68
+ lars50BorrowerCharacteristics
69
+ )
70
+ val income50To79 = ApplicantIncome (
71
+ Between50And79PercentOfMSAMedian ,
72
+ lars50To79BorrowerCharacteristics
73
+ )
74
+ val income80To99 = ApplicantIncome (
75
+ Between80And99PercentOfMSAMedian ,
76
+ lars80To99BorrowerCharacteristics
77
+ )
78
+ val income100To120 = ApplicantIncome (
79
+ Between100And119PercentOfMSAMedian ,
80
+ lars100To120BorrowerCharacteristics
81
+ )
82
+ val income120 = ApplicantIncome (
83
+ GreaterThan120PercentOfMSAMedian ,
84
+ lars120BorrowerCharacteristics
85
+ )
82
86
83
- val applicantIncomes = List (
84
- income50,
85
- income50To79,
86
- income80To99,
87
- income100To120,
88
- income120
89
- )
87
+ val applicantIncomes = List (
88
+ income50,
89
+ income50To79,
90
+ income80To99,
91
+ income100To120,
92
+ income120
93
+ )
90
94
91
- N52 (
92
- year,
93
- formatDate(Calendar .getInstance().toInstant),
94
- applicantIncomes,
95
- total
96
- )
97
- }
95
+ N52 (
96
+ year,
97
+ formatDate(Calendar .getInstance().toInstant),
98
+ applicantIncomes,
99
+ total
100
+ )
101
+ }
102
+ })
98
103
}
99
104
}
0 commit comments