Bugzilla – Attachment 28704 Details for
Bug 12164
Rollover outstanding orders not yet received
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12164: On cloning budget periods, add a "reset all funds" option
0003-Bug-12164-On-cloning-budget-periods-add-a-reset-all-.patch (text/plain), 5.80 KB, created by
Paola Rossi
on 2014-06-06 14:26:09 UTC
(
hide
)
Description:
Bug 12164: On cloning budget periods, add a "reset all funds" option
Filename:
MIME Type:
Creator:
Paola Rossi
Created:
2014-06-06 14:26:09 UTC
Size:
5.80 KB
patch
obsolete
>From 53a81ce084392fa12939013d0cdf57d10a17d5e1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 2 Jun 2014 10:16:13 +0200 >Subject: [PATCH 3/7] Bug 12164: On cloning budget periods, add a "reset all > funds" option > >This patch adds a checkbox "reset all funds" (budgets). >If it is checked, the new created budgets (funds) will be reset. > >Signed-off-by: Paola Rossi <paola.rossi@cineca.it> >--- > C4/Budgets.pm | 19 +++++++++++-- > admin/aqbudgetperiods.pl | 2 ++ > .../prog/en/modules/admin/aqbudgetperiods.tt | 5 ++++ > t/db_dependent/Budgets.t | 29 +++++++++++++++++++- > 4 files changed, 51 insertions(+), 4 deletions(-) > >diff --git a/C4/Budgets.pm b/C4/Budgets.pm >index 05dd12d..89b943e 100644 >--- a/C4/Budgets.pm >+++ b/C4/Budgets.pm >@@ -993,15 +993,19 @@ sub ConvertCurrency { > > my $new_budget_period_id = CloneBudgetPeriod({ > budget_period_id => $budget_period_id, >- budget_period_startdate => $budget_period_startdate; >- budget_period_enddate => $budget_period_enddate; >- mark_original_budget_as_inactive => 1 >+ budget_period_startdate => $budget_period_startdate, >+ budget_period_enddate => $budget_period_enddate, >+ mark_original_budget_as_inactive => 1n >+ reset_all_budgets => 1, > }); > > Clone a budget period with all budgets. > If the mark_origin_budget_as_inactive is set (0 by default), > the original budget will be marked as inactive. > >+If the reset_all_budgets is set (0 by default), all budget (fund) >+amounts will be reset. >+ > =cut > > sub CloneBudgetPeriod { >@@ -1011,6 +1015,7 @@ sub CloneBudgetPeriod { > my $budget_period_enddate = $params->{budget_period_enddate}; > my $mark_original_budget_as_inactive = > $params->{mark_original_budget_as_inactive} || 0; >+ my $reset_all_budgets = $params->{reset_all_budgets} || 0; > > my $budget_period = GetBudgetPeriod($budget_period_id); > >@@ -1037,6 +1042,14 @@ sub CloneBudgetPeriod { > ); > } > >+ if ( $reset_all_budgets ) { >+ my $budgets = GetBudgets({ budget_period_id => $new_budget_period_id }); >+ for my $budget ( @$budgets ) { >+ $budget->{budget_amount} = 0; >+ ModBudget( $budget ); >+ } >+ } >+ > return $new_budget_period_id; > } > >diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl >index a62deb2..7c11a34 100755 >--- a/admin/aqbudgetperiods.pl >+++ b/admin/aqbudgetperiods.pl >@@ -186,6 +186,7 @@ elsif ( $op eq 'duplicate_budget' ){ > my $budget_period_startdate = $input->param('budget_period_startdate'); > my $budget_period_enddate = $input->param('budget_period_enddate'); > my $mark_original_budget_as_inactive = $input->param('mark_original_budget_as_inactive'); >+ my $reset_all_budgets = $input->param('reset_all_budgets'); > > my $new_budget_period_id = C4::Budgets::CloneBudgetPeriod( > { >@@ -193,6 +194,7 @@ elsif ( $op eq 'duplicate_budget' ){ > budget_period_startdate => $budget_period_startdate, > budget_period_enddate => $budget_period_enddate, > mark_original_budget_as_inactive => $mark_original_budget_as_inactive, >+ reset_all_budgets => $reset_all_budgets, > } > ); > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >index 0f4bca6..6dc9a4d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt >@@ -190,6 +190,11 @@ > <input type="checkbox" id="mark_as_inactive" name="mark_original_budget_as_inactive" /> > </li> > >+ <li> >+ <label for="reset_all_budgets">Set all funds to zero</label> >+ <input type="checkbox" id="reset_all_budgets" name="reset_all_budgets" /> >+ </li> >+ > </ol> > </fieldset> > >diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t >index 4aac786..b0da03e 100755 >--- a/t/db_dependent/Budgets.t >+++ b/t/db_dependent/Budgets.t >@@ -1,5 +1,5 @@ > use Modern::Perl; >-use Test::More tests => 31; >+use Test::More tests => 33; > > BEGIN {use_ok('C4::Budgets') } > use C4::Context; >@@ -350,6 +350,14 @@ is( $budget_period->{budget_period_active}, 1, > 'CloneBudgetPeriod does not mark as inactive the budgetperiod if not needed' > ); > >+$budget_hierarchy_cloned = GetBudgetHierarchy($budget_period_id_cloned); >+my $number_of_budgets_not_reset = 0; >+for my $budget (@$budget_hierarchy_cloned) { >+ $number_of_budgets_not_reset++ if $budget->{budget_amount} > 0; >+} >+is( $number_of_budgets_not_reset, 5, >+ 'CloneBudgetPeriod does not reset budgets (funds) if not needed' ); >+ > $budget_period_id_cloned = C4::Budgets::CloneBudgetPeriod( > { > budget_period_id => $budget_period_id, >@@ -375,6 +383,25 @@ is( $budget_period->{budget_period_active}, 0, > 'CloneBudgetPeriod (with inactive param) marks as inactive the budgetperiod' > ); > >+# CloneBudgetPeriod with param reset_all_budgets >+$budget_period_id_cloned = C4::Budgets::CloneBudgetPeriod( >+ { >+ budget_period_id => $budget_period_id, >+ budget_period_startdate => '2014-01-01', >+ budget_period_enddate => '2014-12-31', >+ reset_all_budgets => 1, >+ } >+); >+ >+$budget_hierarchy_cloned = GetBudgetHierarchy($budget_period_id_cloned); >+$number_of_budgets_not_reset = 0; >+for my $budget (@$budget_hierarchy_cloned) { >+ $number_of_budgets_not_reset++ if $budget->{budget_amount} > 0; >+} >+is( $number_of_budgets_not_reset, 0, >+ 'CloneBudgetPeriod has reset all budgets (funds)' ); >+ >+ > sub _get_dependencies { > my ($budget_hierarchy) = @_; > my $graph; >-- >1.7.10.4 >
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 12164
:
27905
|
27906
|
27907
|
27908
|
27909
|
27910
|
27911
|
28588
|
28589
|
28590
|
28591
|
28592
|
28593
|
28695
|
28702
|
28703
|
28704
|
28705
|
28706
|
28707
|
28708
|
29354
|
29355
|
29356
|
29422
|
29423
|
29424
|
29425
|
29426
|
29427
|
29428
|
29429
|
29430
|
29733
|
29734
|
29735
|
29736
|
29737
|
29738
|
29739
|
29740
|
29741
|
30043
|
30044