Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions test/pages/test_awards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_fn_payables
",
'today' => (Time.now - (10 * 60 * 60)).utc.iso8601
)
assert_equal('55', xml.xpath('/td/text()').to_s, xml)
assert_equal('30', xml.xpath('/td/text()').to_s, xml)
end

def test_fn_payables_out_of_window
Expand Down Expand Up @@ -81,6 +81,39 @@ def test_fn_payables_out_of_window
assert_equal('75', xml.xpath('/td/text()').to_s, xml)
end

def test_fn_payables_excludes_future_awards_for_historical_report
xml = xslt(
"<xsl:copy-of select=\"z:payables('dude')\"/>",
'
<fb>
<f>
<what>reconciliation</what>
<when>2024-05-31T00:00:00Z</when>
<since>2024-05-01T00:00:00Z</since>
<who_name>dude</who_name>
<awarded>0</awarded>
<payout>0</payout>
<balance>0</balance>
</f>
<f>
<is_human>1</is_human>
<when>2024-06-01T00:00:00Z</when>
<who_name>dude</who_name>
<award>10</award>
</f>
<f>
<is_human>1</is_human>
<when>2024-06-03T00:00:00Z</when>
<who_name>dude</who_name>
<award>50</award>
</f>
</fb>
',
'today' => '2024-06-02T00:00:00Z'
)
assert_equal('10', xml.xpath('/td/text()').to_s, xml)
end

def test_fn_payables_with_few_reconciliations
xml = xslt(
"<xsl:copy-of select=\"z:payables('dude')\"/>",
Expand Down Expand Up @@ -126,7 +159,7 @@ def test_fn_payables_with_few_reconciliations
",
'today' => (Time.now - (10 * 60 * 60)).utc.iso8601
)
assert_equal('55', xml.xpath('/td/text()').to_s, xml)
assert_equal('30', xml.xpath('/td/text()').to_s, xml)
end

def test_fn_payables_uses_latest_reconciliation_when_facts_are_out_of_order
Expand Down
2 changes: 1 addition & 1 deletion xsl/awards.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</xsl:if>
</xsl:for-each>
<td class="right ff">
<xsl:variable name="accumulated" select="xs:integer(sum($fb/f[award and is_human = 1 and who_name=$name and z:when(when) &gt; xs:dateTime(z:value($rec/since))]/award))"/>
<xsl:variable name="accumulated" select="xs:integer(sum($fb/f[award and is_human = 1 and who_name=$name and z:when(when) &gt; xs:dateTime(z:value($rec/since)) and z:when(when) &lt;= xs:dateTime($today)]/award))"/>
<xsl:variable name="delta" select="$accumulated - xs:integer(z:value($rec/awarded))"/>
<xsl:variable name="payable" select="$accumulated - xs:integer(z:value($rec/awarded)) + xs:integer(z:value($rec/balance))"/>
<xsl:attribute name="title">
Expand Down
Loading