Skip to content

Commit

Permalink
convert S303 to Q303 for 2025
Browse files Browse the repository at this point in the history
  • Loading branch information
kgudel committed Sep 13, 2024
1 parent 86acad8 commit 2632b38
Show file tree
Hide file tree
Showing 6 changed files with 676 additions and 2 deletions.
315 changes: 315 additions & 0 deletions common/src/main/resources/2025EditsDescriptions.txt

Large diffs are not rendered by default.

315 changes: 315 additions & 0 deletions common/src/main/resources/2025QuarterlyEditsDescriptions.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ private class HmdaFileValidationHttpApi(implicit mat: Materializer) {

case "validity" =>
checkValidity(ts, ts.LEI, ctx, TsValidationError)

case "quality" =>
checkQuality(ts, ts.LEI, ctx)
}

val maybeErrors = validation.leftMap(xs => xs.toList).toEither
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import hmda.model.filing.ts.TransmittalSheet
import hmda.validation.context.ValidationContext
import hmda.validation.rules.ts.syntactical.{ S300, S303, S302 }
import hmda.validation.rules.ts.validity._
import hmda.validation.rules.ts.quality._
// $COVERAGE-OFF$
private[engine] object TsEngine2025 extends ValidationEngine[TransmittalSheet] {

override def syntacticalChecks(ctx: ValidationContext) = Vector(
S300,
S302.withContext(ctx),
S303.withContext(ctx)
S302.withContext(ctx)
)

override def validityChecks(ctx: ValidationContext) = Vector(
Expand All @@ -27,5 +27,9 @@ private[engine] object TsEngine2025 extends ValidationEngine[TransmittalSheet] {
V719_2
)

override def qualityChecks(ctx: ValidationContext) = Vector(
Q303.withContext(ctx)
)

}
// $COVERAGE-ON$
13 changes: 13 additions & 0 deletions hmda/src/main/scala/hmda/validation/filing/ValidationFlow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ object ValidationFlow extends ColumnDataFormatter {
validationEngine.checkSyntactical(ts, ts.LEI, validationContext, TsValidationError)
case "validity" =>
validationEngine.checkValidity(ts, ts.LEI, validationContext, TsValidationError)
case "quality" =>
validationEngine.checkQuality(ts, ts.LEI, validationContext)
}
(ts, errors)
}
Expand Down Expand Up @@ -153,6 +155,17 @@ object ValidationFlow extends ColumnDataFormatter {
)
): _*
)
case "Q303" =>
ListMap(
affectedFields.map(field =>
(
field,
"Provided: " + ts.valueOf(field) + ", Expected: " + institution
.getOrElse(Institution.empty)
.valueOf(field)
)
): _*
)
case "V718" =>
val quarter =
period.quarter match {
Expand Down
24 changes: 24 additions & 0 deletions hmda/src/main/scala/hmda/validation/rules/ts/quality/Q303.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package hmda.validation.rules.ts.quality

import hmda.model.filing.ts.TransmittalSheet
import hmda.model.institution.Institution
import hmda.validation.context.ValidationContext
import hmda.validation.dsl.ValidationResult
import hmda.validation.rules.{ EditCheck, IfInstitutionPresentIn }
import hmda.validation.dsl.PredicateCommon._
import hmda.validation.dsl.PredicateSyntax._

object Q303 {
def withContext(ctx: ValidationContext): EditCheck[TransmittalSheet] =
IfInstitutionPresentIn(ctx) { new Q303(_) }

}

class Q303 private (institution: Institution) extends EditCheck[TransmittalSheet] {
override def name: String = "Q303"

override def apply(ts: TransmittalSheet): ValidationResult =
(ts.LEI.toLowerCase is equalTo(institution.LEI.toLowerCase)) and
(ts.agency.code is equalTo(institution.agency.code)) and
(ts.taxId is equalTo(institution.taxId.getOrElse("")))
}

0 comments on commit 2632b38

Please sign in to comment.