Bug 31367: Add subtotals if budget has children

On bug 29287 we added child funds if a fund had no parent id

It turns out funds can have a parent, and still have children (sub-sub-funds)

This patch simply checks for children, rather than checking for lack of parent.

Totals are already calculated correctly in GetBudgetHierarchy

To test:
1 - Add a fund "Fund" to a budget - assign 1000 dollars
2 - Add a sub-fund "SubFund" - assign 100 dollars
3 - Add a sub-sub-fund "SubSubFund" - assign 10 dollars
4 - Add to a basket $5 order from SubSubFund
5 - Add to a basket $50 order from SubFund
6 - Add to a basket $500 order form Fun
7 - View acqui home - note 'SubFund' does not include total from 'SubSubFund'
8 - Apply patch
9 - Confirm all sub-sub-funds totaled in sub-funds and that fund total correctly adds sub and sub-sub funds

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 6523db7321)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 14dd1ab9e4)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
This commit is contained in:
Nick Clemens 2022-08-26 13:32:50 +00:00 committed by Arthur Suzuki
parent eaa45e93db
commit 1af0cc55f2
1 changed files with 3 additions and 3 deletions

View File

@ -159,7 +159,7 @@
</td>
<td class="data">
<a href="ordered.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
[% IF !loop_budge.budget_parent_id %]
[% IF loop_budge.children.size %]
<a title="Ordered from this fund" href="ordered.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
(<span class="total_amount">[% loop_budge.budget_ordered | $Price %]</span>)
</a>
@ -171,7 +171,7 @@
[% END %]
</td>
<td class="data">
[% IF !loop_budge.budget_parent_id %]
[% IF loop_budge.children.size %]
<a title="Spent from this fund" href="spent.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
(<span class="total_amount">[% loop_budge.budget_spent | $Price %]</span>)
</a>
@ -183,7 +183,7 @@
[% END %]
</td>
<td class="data">
[% IF !loop_budge.budget_parent_id %]
[% IF loop_budge.children.size %]
(<span title="Remaining in this fund" class="parent_amount" data-parent_id="[% loop_budge.budget_parent_id | html %]" data-self_id="[% loop_budge.budget_id | html %]">[% loop_budge.budget_avail | $Price %]</span>)
<span title="Remaining with child funds included" class="total_amount" data-parent_id="[% loop_budge.budget_parent_id | html %]" data-self_id="[% loop_budge.budget_id | html %]">[% loop_budge.total_avail | $Price %]</span>
[% ELSE %]