From 9739d202339a65fc8073049a1f74acf1a03f02d0 Mon Sep 17 00:00:00 2001 From: Elijah Wright Date: Fri, 30 May 2025 01:57:26 -0700 Subject: [PATCH] fix isTaxYearLeapYear --- .../src/main/resources/tax/constants.xml | 62 +++++++++++++++---- .../gov/irs/factgraph/compnodes/Modulo.scala | 35 +++++++++++ 2 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 direct-file/fact-graph-scala/shared/src/main/scala/gov/irs/factgraph/compnodes/Modulo.scala diff --git a/direct-file/backend/src/main/resources/tax/constants.xml b/direct-file/backend/src/main/resources/tax/constants.xml index d8887a2..f8008fc 100644 --- a/direct-file/backend/src/main/resources/tax/constants.xml +++ b/direct-file/backend/src/main/resources/tax/constants.xml @@ -50,24 +50,62 @@ - + + + + + + + + 100 + + + + + 0 + + + + + - + + + + + + 400 + + - 2024 + 0 - - - - - - 2028 - - - + + + + + + + + + + + + + + + + 4 + + + + + 0 + + diff --git a/direct-file/fact-graph-scala/shared/src/main/scala/gov/irs/factgraph/compnodes/Modulo.scala b/direct-file/fact-graph-scala/shared/src/main/scala/gov/irs/factgraph/compnodes/Modulo.scala new file mode 100644 index 0000000..4ab7cbb --- /dev/null +++ b/direct-file/fact-graph-scala/shared/src/main/scala/gov/irs/factgraph/compnodes/Modulo.scala @@ -0,0 +1,35 @@ + package gov.irs.factgraph.compnodes + +import gov.irs.factgraph.{Expression, FactDictionary, Factual} +import gov.irs.factgraph.definitions.fact.CompNodeConfigTrait +import gov.irs.factgraph.operators.BinaryOperator + +object Modulo extends CompNodeFactory: + override val Key: String = "Modulo" + + private val operator = ModuloOperator() + + def apply(lhs: CompNode, rhs: CompNode): BooleanNode = + if (lhs.getClass != rhs.getClass) + throw new UnsupportedOperationException( + s"cannot modulate a ${lhs.getClass.getName} and a ${rhs.getClass.getName}", + ) + + BooleanNode( + Expression.Binary( + lhs.expr, + rhs.expr, + operator, + ), + ) + + override def fromDerivedConfig(e: CompNodeConfigTrait)(using Factual)(using + FactDictionary, + ): CompNode = + val lhs = CompNode.getConfigChildNode(e, "Left") + val rhs = CompNode.getConfigChildNode(e, "Right") + + this(lhs, rhs) + +private final class ModuloOperator extends BinaryOperator[Boolean, Any, Any]: + override protected def operation(x: Any, y: Any): Boolean = x % y \ No newline at end of file