Bugzilla – Attachment 25554 Details for
Bug 11823
Add the "Total sublevels ordered" column to the funds list.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Add the total ordered amount to the funds list.
0001-Add-the-total-ordered-amount-to-the-funds-list.patch (text/plain), 5.34 KB, created by
Frédérick Capovilla
on 2014-02-21 22:32:54 UTC
(
hide
)
Description:
Add the total ordered amount to the funds list.
Filename:
MIME Type:
Creator:
Frédérick Capovilla
Created:
2014-02-21 22:32:54 UTC
Size:
5.34 KB
patch
obsolete
>From 20fee0bb0d5f076a62b8789bf2b996d9b98231f2 Mon Sep 17 00:00:00 2001 >From: Maxime Pelletier <maxime.pelletier@libeo.com> >Date: Fri, 21 Feb 2014 17:18:11 -0500 >Subject: [PATCH] Add the total ordered amount to the funds list. > >--- > C4/Budgets.pm | 29 ++++++++++++++++++++ > admin/aqbudgets.pl | 5 ++- > .../prog/en/modules/admin/aqbudgets.tt | 2 + > t/db_dependent/Acquisition.t | 4 ++- > 4 files changed, 37 insertions(+), 3 deletions(-) > >diff --git a/C4/Budgets.pm b/C4/Budgets.pm >index 334e610..222dfd9 100644 >--- a/C4/Budgets.pm >+++ b/C4/Budgets.pm >@@ -45,6 +45,7 @@ BEGIN { > &GetBudgetName > &GetPeriodsCount > &GetChildBudgetsSpent >+ &GetChildBudgetsOrdered > > &GetBudgetUsers > &ModBudgetUsers >@@ -724,6 +725,34 @@ sub GetChildBudgetsSpent { > return $total_spent; > } > >+=head2 GetChildBudgetsOrdered >+ >+ &GetChildBudgetsOrdered($budget_id); >+ >+gets the total ordered of the level and sublevels of $budget_id >+ >+=cut >+ >+# ------------------------------------------------------------------- >+sub GetChildBudgetsOrdered { >+ my ( $budget_id ) = @_; >+ my $dbh = C4::Context->dbh; >+ my $query = " >+ SELECT * >+ FROM aqbudgets >+ WHERE budget_parent_id=? >+ "; >+ my $sth = $dbh->prepare($query); >+ $sth->execute( $budget_id ); >+ my $result = $sth->fetchall_arrayref({}); >+ my $total_spent = GetBudgetOrdered($budget_id); >+ if ($result){ >+ $total_spent += GetChildBudgetsOrdered($_->{"budget_id"}) foreach @$result; >+ } >+ return $total_spent; >+} >+ >+ > =head2 GetBudgets > > &GetBudgets($filter, $order_by); >diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl >index 42a39f7..ccad617 100755 >--- a/admin/aqbudgets.pl >+++ b/admin/aqbudgets.pl >@@ -283,6 +283,7 @@ if ($op eq 'add_form') { > foreach my $budget (@budgets) { > #Level and sublevels total spent > $budget->{'total_levels_spent'} = GetChildBudgetsSpent($budget->{"budget_id"}); >+ $budget->{'total_levels_ordered'} = GetChildBudgetsOrdered($budget->{"budget_id"}); > > # PERMISSIONS > unless(CanUserModifyBudget($borrowernumber, $budget, $staffflags)) { >@@ -303,7 +304,7 @@ if ($op eq 'add_form') { > # 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'}; >- $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'total_levels_spent'}; >+ $budget->{'budget_remaining'} = $budget->{'budget_amount'} - $budget->{'total_levels_spent'} - $budget->{'total_levels_ordered'}; > > # if amount == 0 dont display... > delete $budget->{'budget_unalloc_sublevel'} >@@ -312,7 +313,7 @@ if ($op eq 'add_form') { > > $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_amount|budget_remaining|budget_unalloc/} keys %$budget){ >+ for (grep {/total_levels_spent|budget_spent|budget_amount|budget_remaining|budget_unalloc|total_levels_ordered/} keys %$budget){ > $budget->{$_} = $num->format_price( $budget->{$_} ) if defined($budget->{$_}) > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt >index 219a049..2b9ee4b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt >@@ -247,6 +247,7 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") > <th>Base-level<br />allocated</th> > <th>Base-level<br />spent</th> > <th>Total sublevels<br />spent</th> >+ <th>Total sublevels<br />ordered</th> > <th>Base-level<br />remaining</th> > <th class="tooltipcontent"> </th> > <th>Actions</th> >@@ -278,6 +279,7 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") > <td class="data">[% budge.budget_amount %] </td> > <td class="data">[% budge.budget_spent %] </td> > <td class="data">[% budge.total_levels_spent %]</td> >+ <td class="data">[% budge.total_levels_ordered %]</td> > [% IF ( budge.remaining_pos ) %] > <td class="data" style="color: green;"> > [% ELSIF ( budge.remaining_neg ) %] >diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t >index 2585802..4eed47e 100755 >--- a/t/db_dependent/Acquisition.t >+++ b/t/db_dependent/Acquisition.t >@@ -8,7 +8,7 @@ use POSIX qw(strftime); > > use C4::Bookseller qw( GetBookSellerFromId ); > >-use Test::More tests => 62; >+use Test::More tests => 63; > > BEGIN { > use_ok('C4::Acquisition'); >@@ -92,6 +92,8 @@ ok( exists( @$orders[0]->{basketgroupname} ), "SearchOrder: The basketgroupname > > ok( GetBudgetByOrderNumber($ordernumber1)->{'budget_id'} eq $budgetid, "GetBudgetByOrderNumber returns expected budget" ); > >+ok(GetChildBudgetsOrdered($budgetid) eq '168', "GetChildBudgetsOrdered returns the cost of all ordered acquisitions for the budget and all sub-budgets."); >+ > C4::Acquisition::CloseBasket( $basketno ); > my @lateorders = GetLateOrders(0); > my $order = $lateorders[0]; >-- >1.7.2.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11823
: 25554