Skip to content

Commit

Permalink
#138 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 26, 2024
1 parent 5096179 commit 8948129
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions test/pages/test_awards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,39 @@ def test_payables
assert_equal('55', xml.xpath('/td/text()').to_s, xml)
end

def test_payables_out_of_window
xml = xslt(
"<xsl:copy-of select=\"z:payables('dude')\"/>",
"
<fb>
<f>
<what>reconciliation</what>
<when>#{(Time.now - (60 * 60)).utc.iso8601}</when>
<since>#{(Time.now - (1000 * 60 * 60)).utc.iso8601}</since>
<who_name>dude</who_name>
<awarded>0</awarded>
<payout>20</payout>
<balance>10</balance>
</f>
<f>
<is_human>1</is_human>
<when>#{(Time.now - (999 * 60 * 60)).utc.iso8601}</when>
<who_name>dude</who_name>
<award>40</award>
</f>
<f>
<is_human>1</is_human>
<when>#{Time.now.utc.iso8601}</when>
<who_name>dude</who_name>
<award>25</award>
</f>
</fb>
",
'today' => Time.now.utc.iso8601
)
assert_equal('75', xml.xpath('/td/text()').to_s, xml)
end

def test_payables_with_few_reconciliations
xml = xslt(
"<xsl:copy-of select=\"z:payables('dude')\"/>",
Expand Down
2 changes: 1 addition & 1 deletion xsl/awards.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ SOFTWARE.
</xsl:if>
</xsl:for-each>
<td class="right ff">
<xsl:variable name="accumulated" select="xs:integer(sum($facts[who_name=$name and xs:dateTime(when) &gt; xs:dateTime($rec/since)]/award))"/>
<xsl:variable name="accumulated" select="xs:integer(sum($fb/f[award and is_human = 1 and who_name=$name and xs:dateTime(when) &gt; xs:dateTime($rec/since)]/award))"/>
<xsl:variable name="delta" select="$accumulated - xs:integer($rec/awarded)"/>
<xsl:variable name="payable" select="$accumulated - xs:integer($rec/awarded) + xs:integer($rec/balance)"/>
<xsl:attribute name="title">
Expand Down

0 comments on commit 8948129

Please sign in to comment.