Bug 7308: rework aqbudgets.pl table
admin/aqbudgets.pl should have the following columns: Base-level allocated (or just Allocated) Base-level ordered Total sub-levels ordered Base-level spent Total sub-levels spent Base-level available Total sub-levels available Base-level is always calculated for one level, without children. Total sub-levels should include child funds. Available is calculated as "allocated - (ordered + spent)". Signed-off-by: Cedric Vita <cedric.vita@dracenie.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Seems to work alright for me. Passes QA script and tests, after I fixed 2 tabs in admin/aqbudgets.pl. Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
dc3a90c411
commit
1e808f1805
3 changed files with 57 additions and 52 deletions
|
@ -613,16 +613,13 @@ sub GetBudgetHierarchy {
|
|||
$r->{'budget_spent'} = GetBudgetSpent( $r->{'budget_id'} );
|
||||
$r->{budget_ordered} = GetBudgetOrdered( $r->{budget_id} );
|
||||
|
||||
$r->{'budget_amount_total'} = $r->{'budget_amount'};
|
||||
|
||||
$r->{budget_spent_sublevels} = 0;
|
||||
$r->{budget_ordered_sublevels} = 0;
|
||||
# foreach sub-levels
|
||||
my $unalloc_count ;
|
||||
|
||||
foreach my $sub (@subs_arr) {
|
||||
my $sub_budget = GetBudget($sub);
|
||||
|
||||
$r->{budget_spent_sublevel} += GetBudgetSpent( $sub_budget->{'budget_id'} );
|
||||
$unalloc_count += $sub_budget->{'budget_amount'};
|
||||
$r->{budget_spent_sublevels} += GetBudgetSpent( $sub_budget->{'budget_id'} );
|
||||
$r->{budget_ordered_sublevels} += GetBudgetOrdered($sub);
|
||||
}
|
||||
}
|
||||
return \@sort;
|
||||
|
|
|
@ -276,14 +276,14 @@ if ($op eq 'add_form') {
|
|||
my $toggle = 0;
|
||||
my @loop;
|
||||
my $period_total = 0;
|
||||
my ( $period_alloc_total, $base_spent_total, $base_ordered_total );
|
||||
my ($period_alloc_total, $spent_total, $ordered_total, $available_total) = (0,0,0,0);
|
||||
|
||||
#This Looks WEIRD to me : should budgets be filtered in such a way ppl who donot own it would not see the amount spent on the budget by others ?
|
||||
|
||||
foreach my $budget (@budgets) {
|
||||
#Level and sublevels total spent
|
||||
$budget->{'total_levels_spent'} = GetChildBudgetsSpent($budget->{"budget_id"});
|
||||
|
||||
#Level and sublevels total spent and ordered
|
||||
$budget->{total_spent} = $budget->{budget_spent_sublevels} + $budget->{budget_spent};
|
||||
$budget->{total_ordered} = $budget->{budget_ordered_sublevels} + $budget->{budget_ordered};
|
||||
# PERMISSIONS
|
||||
unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) {
|
||||
$budget->{'budget_lock'} = 1;
|
||||
|
@ -300,22 +300,29 @@ if ($op eq 'add_form') {
|
|||
}
|
||||
|
||||
## TOTALS
|
||||
$budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'budget_spent'} - $budget->{budget_ordered};
|
||||
$budget->{'total_remaining'} = $budget->{'budget_amount'} - $budget->{'total_spent'} - $budget->{total_ordered};
|
||||
# adds to total - only if budget is a 'top-level' budget
|
||||
$period_alloc_total += $budget->{'budget_amount_total'} if $budget->{'depth'} == 0;
|
||||
$base_spent_total += $budget->{'budget_spent'};
|
||||
$base_ordered_total += $budget->{budget_ordered};
|
||||
$budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'total_levels_spent'};
|
||||
if ($budget->{depth} == 0) {
|
||||
$period_alloc_total += $budget->{'budget_amount'};
|
||||
$spent_total += $budget->{total_spent};
|
||||
$ordered_total += $budget->{total_ordered};
|
||||
$available_total += $budget->{total_remaining};
|
||||
}
|
||||
|
||||
# if amount == 0 dont display...
|
||||
delete $budget->{'budget_unalloc_sublevel'}
|
||||
if (!defined $budget->{'budget_unalloc_sublevel'}
|
||||
or $budget->{'budget_unalloc_sublevel'} == 0);
|
||||
|
||||
$budget->{'remaining_pos'} = 1 if $budget->{'budget_remaining'} > 0;
|
||||
$budget->{'remaining_neg'} = 1 if $budget->{'budget_remaining'} < 0;
|
||||
for (grep {/total_levels_spent|budget_spent|budget_ordered|budget_amount|budget_remaining|budget_unalloc/} keys %$budget){
|
||||
for (grep {/total_spent|budget_spent|total_ordered|budget_ordered|budget_amount/} keys %$budget){
|
||||
$budget->{$_} = $num->format_price( $budget->{$_} ) if defined($budget->{$_})
|
||||
}
|
||||
for (qw/budget_remaining total_remaining/) {
|
||||
if (defined $budget->{$_}) {
|
||||
$budget->{$_.'_display'} = $num->format_price($budget->{$_});
|
||||
}
|
||||
}
|
||||
|
||||
# Value of budget_spent equals 0 instead of undefined value
|
||||
$budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"});
|
||||
|
@ -344,22 +351,10 @@ if ($op eq 'add_form') {
|
|||
);
|
||||
}
|
||||
|
||||
my $budget_period_total;
|
||||
if ( $period->{budget_period_total} ) {
|
||||
$budget_period_total =
|
||||
$num->format_price( $period->{budget_period_total} );
|
||||
}
|
||||
my $budget_period_total = $period->{budget_period_total};
|
||||
|
||||
if ($period_alloc_total) {
|
||||
$period_alloc_total = $num->format_price($period_alloc_total);
|
||||
}
|
||||
|
||||
if ($base_spent_total) {
|
||||
$base_spent_total = $num->format_price($base_spent_total);
|
||||
}
|
||||
|
||||
if ($base_ordered_total) {
|
||||
$base_ordered_total = $num->format_price($base_ordered_total);
|
||||
foreach ($budget_period_total, $period_alloc_total, $spent_total, $ordered_total, $available_total) {
|
||||
$_ = $num->format_price($_);
|
||||
}
|
||||
|
||||
$template->param(
|
||||
|
@ -367,8 +362,9 @@ if ($op eq 'add_form') {
|
|||
budget => \@loop,
|
||||
budget_period_total => $budget_period_total,
|
||||
period_alloc_total => $period_alloc_total,
|
||||
base_spent_total => $base_spent_total,
|
||||
base_ordered_total => $base_ordered_total,
|
||||
spent_total => $spent_total,
|
||||
ordered_total => $ordered_total,
|
||||
available_total => $available_total,
|
||||
branchloop => \@branchloop2,
|
||||
);
|
||||
|
||||
|
|
|
@ -241,12 +241,13 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
|
|||
<tr>
|
||||
<th>Fund code</th>
|
||||
<th>Fund name</th>
|
||||
<th>Total<br />allocated</th>
|
||||
<th>Base-level<br />allocated</th>
|
||||
<th>Base-level<br />ordered</th>
|
||||
<th>Total ordered</th>
|
||||
<th>Base-level<br />spent</th>
|
||||
<th>Total sublevels<br />spent</th>
|
||||
<th>Base-level<br />remaining</th>
|
||||
<th>Total spent</th>
|
||||
<th>Base-level<br />available</th>
|
||||
<th>Total available</th>
|
||||
<th class="tooltipcontent"> </th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
|
@ -255,12 +256,13 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
|
|||
<tr>
|
||||
<th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %] </th>
|
||||
<th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
|
||||
<th nowrap="nowrap" class="data"> [% base_alloc_total %]</th>
|
||||
<th class="data">[% base_ordered_total %]</th>
|
||||
<th class="data">[% base_spent_total %]</th>
|
||||
<th class="data">[% base_spent_total %]</th>
|
||||
<th class="data">[% base_remaining_total %]</th>
|
||||
<th></th>
|
||||
<th class="data">[% ordered_total %]</th>
|
||||
<th></th>
|
||||
<th class="data">[% spent_total %]</th>
|
||||
<th></th>
|
||||
<th class="tooltipcontent"></th>
|
||||
<th class="data">[% available_total %]</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
@ -274,19 +276,29 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
|
|||
|
||||
<td>[% budge.budget_code_indent %]</td>
|
||||
<td>[% budge.budget_name %]</td>
|
||||
<td class="data">[% budge.budget_amount_total %]</td>
|
||||
<td class="data">[% budge.budget_amount %] </td>
|
||||
<td class="data">[% budge.budget_ordered %]</td>
|
||||
<td class="data">[% budge.total_ordered %]</td>
|
||||
<td class="data">[% budge.budget_spent %] </td>
|
||||
<td class="data">[% budge.total_levels_spent %]</td>
|
||||
[% IF ( budge.remaining_pos ) %]
|
||||
<td class="data" style="color: green;">
|
||||
[% ELSIF ( budge.remaining_neg ) %]
|
||||
<td class="data" style="color: red;">
|
||||
<td class="data">[% budge.total_spent %]</td>
|
||||
|
||||
[% BLOCK colorcellvalue %]
|
||||
[% IF (value > 0) %]
|
||||
<span style="color: green;">
|
||||
[% ELSIF (value < 0) %]
|
||||
<span style="color: red;">
|
||||
[% ELSE %]
|
||||
<td class="data">
|
||||
<span>
|
||||
[% END %]
|
||||
[% budge.budget_remaining %] </td>
|
||||
[% text %]
|
||||
</span>
|
||||
[% END %]
|
||||
<td class="data">
|
||||
[% INCLUDE colorcellvalue value=budge.budget_remaining text=budge.budget_remaining_display %]
|
||||
</td>
|
||||
<td class="data">
|
||||
[% INCLUDE colorcellvalue value=budge.total_remaining text=budge.total_remaining_display %]
|
||||
</td>
|
||||
|
||||
<td class="tooltipcontent">[% IF ( budge.budget_owner_id ) %]<strong>Owner: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budge.budget_owner_id %]">[% budge.budget_owner_name %]</a>[% END %]
|
||||
[% IF ( budge.budget_branchcode ) %]<br /><strong>Library: </strong>[% budge.budget_branchcode %][% END %]
|
||||
|
|
Loading…
Reference in a new issue