Bugzilla – Attachment 77522 Details for
Bug 14850
Funds from inactive budgets appear in 'Funds' dropdown on acqui/invoice.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14850: Use optgroups to display active/inactive budgets
Bug-14850-Use-optgroups-to-display-activeinactive-.patch (text/plain), 11.49 KB, created by
Nick Clemens
on 2018-08-07 13:13:00 UTC
(
hide
)
Description:
Bug 14850: Use optgroups to display active/inactive budgets
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2018-08-07 13:13:00 UTC
Size:
11.49 KB
patch
obsolete
>From ad2240b0cf924fdd3cbcdeadbee4e4fa46bb5b56 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 7 Aug 2018 13:09:22 +0000 >Subject: [PATCH] Bug 14850: Use optgroups to display active/inactive budgets > >This is incomplete, some issues: >1 - It doesn't match current use of checkbox on other pages >2 - It should use a block instead of repeating code >3 - All of the dropdowns for funds should probably be moved to a single >include file and/or use a template plugin > >Leaving this here rather for future work > >https://bugs.koha-community.org/show_bug.cgi?id=14580 >--- > Koha/Acquisition/Fund.pm | 15 ++++ > acqui/invoice.pl | 25 ++++--- > .../intranet-tmpl/prog/en/modules/acqui/invoice.tt | 87 ++++++++++++++++------ > t/db_dependent/Koha/Acquisition/Funds.t | 19 ++++- > 4 files changed, 114 insertions(+), 32 deletions(-) > >diff --git a/Koha/Acquisition/Fund.pm b/Koha/Acquisition/Fund.pm >index 20cc26e..5b6f0ef 100644 >--- a/Koha/Acquisition/Fund.pm >+++ b/Koha/Acquisition/Fund.pm >@@ -18,6 +18,7 @@ package Koha::Acquisition::Fund; > use Modern::Perl; > > use Koha::Database; >+use Koha::Acquisition::Budgets; > > use base qw(Koha::Object); > >@@ -37,4 +38,18 @@ sub _type { > return 'Aqbudget'; > } > >+=head3 budget >+ >+my $budget = $fund->budget; >+ >+Return the budget this fund belongs to >+ >+=cut >+ >+sub budget { >+ my ( $self ) = @_; >+ my $budget = Koha::Acquisition::Budgets->find( $self->budget_period_id); >+ return $budget; >+} >+ > 1; >diff --git a/acqui/invoice.pl b/acqui/invoice.pl >index bdf9485..5463233 100755 >--- a/acqui/invoice.pl >+++ b/acqui/invoice.pl >@@ -36,6 +36,7 @@ use C4::Budgets; > > use Koha::Acquisition::Booksellers; > use Koha::Acquisition::Currencies; >+use Koha::Acquisition::Funds; > use Koha::DateUtils; > use Koha::Misc::Files; > use Koha::Acquisition::Invoice::Adjustments; >@@ -187,18 +188,23 @@ foreach my $order (@$orders) { > > push @foot_loop, map {$_} values %foot; > >-my $budgets = GetBudgets(); >-my @budgets_loop; >+my @funds = Koha::Acquisition::Funds->search(); >+my @active_funds_loop; >+my @inactive_funds_loop; > my $shipmentcost_budgetid = $details->{shipmentcost_budgetid}; >-foreach my $budget (@$budgets) { >- next unless CanUserUseBudget( $loggedinuser, $budget, $flags ); >- my %line = %{$budget}; >+foreach my $fund (@funds) { >+ my $line = $fund->unblessed; >+ next unless CanUserUseBudget( $loggedinuser, $fund, $flags ); > if ( $shipmentcost_budgetid >- and $budget->{budget_id} == $shipmentcost_budgetid ) >+ and $fund->budget_id == $shipmentcost_budgetid ) > { >- $line{selected} = 1; >+ $line->{selected} = 1; >+ } >+ if ( $fund->budget->budget_period_active ){ >+ push @active_funds_loop, \%$line; >+ } else { >+ push @inactive_funds_loop, \%$line; > } >- push @budgets_loop, \%line; > } > > my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({ invoiceid => $details->{'invoiceid'} }); >@@ -223,7 +229,8 @@ $template->param( > total_tax_included_shipment => $total_tax_included + $shipmentcost, > invoiceincgst => $bookseller->invoiceincgst, > currency => Koha::Acquisition::Currencies->get_active, >- budgets_loop => \@budgets_loop, >+ active_funds_loop => \@active_funds_loop, >+ inactive_funds_loop => \@inactive_funds_loop, > ); > > defined( $invoice_files ) && $template->param( files => $invoice_files->GetFilesInfo() ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt >index 85a23c5..48369b6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt >@@ -50,15 +50,28 @@ > <li><label for="shipment_budget_id">Shipping fund:</label> > <select id="shipment_budget_id" name="shipment_budget_id"> > <option value="">No fund</option> >- [% FOREACH budget IN budgets_loop %] >- [% IF ( budget.selected ) %] >- <option selected="selected" value="[% budget.budget_id %]"> >- [% ELSE %] >- <option value="[% budget.budget_id %]"> >- [% END %] >- [% budget.budget_name %] >- </option> >- [% END %] >+ <optgroup label="Active budgets"> >+ [% FOREACH fund IN active_funds_loop %] >+ [% IF ( fund.selected ) %] >+ <option selected="selected" value="[% fund.budget_id %]"> >+ [% ELSE %] >+ <option value="[% fund.budget_id %]"> >+ [% END %] >+ [% fund.budget_name %] >+ </option> >+ [% END %] >+ </optgroup> >+ <optgroup label="Inactive budgets"> >+ [% FOREACH fund IN inactive_funds_loop %] >+ [% IF ( fund.selected ) %] >+ <option selected="selected" value="[% fund.budget_id %]"> >+ [% ELSE %] >+ <option value="[% fund.budget_id %]"> >+ [% END %] >+ [% fund.budget_name %] >+ </option> >+ [% END %] >+ </optgroup> > </select></li> > > [% IF ( invoiceclosedate ) %] >@@ -132,16 +145,29 @@ > <td><input type="text" name="note" id="note_new" value="[% adjustment.note %]"/></td> > <td> > <select id="budget_id_[% adjustment.adjustment_id %]" name="budget_id"> >- <option value="">No fund</option> >- [% FOREACH budget IN budgets_loop %] >- [% IF ( budget.budget_id == adjustment.budget_id ) %] >- <option selected="selected" value="[% budget.budget_id %]"> >- [% ELSE %] >- <option value="[% budget.budget_id %]"> >- [% END %] >- [% budget.budget_name %] >- </option> >+ <option value="">No fund</option> >+ <optgroup label="Active budgets"> >+ [% FOREACH fund IN active_funds_loop %] >+ [% IF ( fund.selected ) %] >+ <option selected="selected" value="[% fund.budget_id %]"> >+ [% ELSE %] >+ <option value="[% fund.budget_id %]"> >+ [% END %] >+ [% fund.budget_name %] >+ </option> >+ [% END %] >+ </optgroup> >+ <optgroup label="Inactive budgets"> >+ [% FOREACH fund IN inactive_funds_loop %] >+ [% IF ( fund.selected ) %] >+ <option selected="selected" value="[% fund.budget_id %]"> >+ [% ELSE %] >+ <option value="[% fund.budget_id %]"> >+ [% END %] >+ [% fund.budget_name %] >+ </option> > [% END %] >+ </optgroup> > </select> > </td> > [% IF adjustment.encumber_open %] >@@ -201,11 +227,28 @@ > <label for="budget_id_new">Fund: </label> > <select id="budget_id_new" name="budget_id"> > <option selected="selected" value="">No fund</option> >- [% FOREACH budget IN budgets_loop %] >- <option value="[% budget.budget_id %]"> >- [% budget.budget_name %] >- </option> >+ <optgroup label="Active budgets"> >+ [% FOREACH fund IN active_funds_loop %] >+ [% IF ( fund.selected ) %] >+ <option selected="selected" value="[% fund.budget_id %]"> >+ [% ELSE %] >+ <option value="[% fund.budget_id %]"> >+ [% END %] >+ [% fund.budget_name %] >+ </option> >+ [% END %] >+ </optgroup> >+ <optgroup label="Inactive budgets"> >+ [% FOREACH fund IN inactive_funds_loop %] >+ [% IF ( fund.selected ) %] >+ <option selected="selected" value="[% fund.budget_id %]"> >+ [% ELSE %] >+ <option value="[% fund.budget_id %]"> >+ [% END %] >+ [% fund.budget_name %] >+ </option> > [% END %] >+ </optgroup> > </select> > </li> > <li> >diff --git a/t/db_dependent/Koha/Acquisition/Funds.t b/t/db_dependent/Koha/Acquisition/Funds.t >index 4232571..b32e7e5 100644 >--- a/t/db_dependent/Koha/Acquisition/Funds.t >+++ b/t/db_dependent/Koha/Acquisition/Funds.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; > > use Koha::Acquisition::Funds; > use Koha::Database; >@@ -45,5 +45,22 @@ is( $retrieved_fund_1->budget_name, $new_fund->budget_name, 'Find a fund by budg > $retrieved_fund_1->delete; > is( Koha::Acquisition::Funds->search->count, $nb_of_funds, 'Delete should have deleted the fund' ); > >+subtest 'budget method tests' => sub { >+ >+ plan tests => 1; >+ >+ my $budget = $builder->build({ >+ source => 'Aqbudgetperiod' >+ }); >+ my $fund = $builder->build({ >+ source => 'Aqbudget', >+ value => { budget_period_id => $budget->{budget_period_id} } >+ }); >+ my $retrieved_fund = Koha::Acquisition::Funds->find( $fund->{budget_id} ); >+ >+ is( $retrieved_fund->budget->budget_period_id, $budget->{budget_period_id},"The budget retrieved is the same as the one created"); >+ >+}; >+ > $schema->storage->txn_rollback; > >-- >2.1.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 14850
:
66555
|
66556
|
77522
|
85521
|
85522
|
85600
|
85601
|
85602