From a4ad5bf9dbb85b088ff9073036e5eac477e18c36 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sun, 13 Sep 2020 21:45:25 +0000 Subject: [PATCH] Bug 15329: Add new column for budget to the late orders table The table currently displays the fund, but as late orders can be from a past budget with the same fund names, this can be confusing. So adding the budget in addition to the fund will be helpful. To test: - Add a basket and an order, close the basket - Go to the late oder page - Make sure your order shows up there - Apply the patch - Reload the late orders page - Verify a new column budget shows in the table - Verify the table configuration settings work for the new column - Run t/db_dependent/Koha/Acquisition/Fund.t Signed-off-by: Martin Renvoize --- Koha/Acquisition/Fund.pm | 16 ++++++++++++++++ admin/columns_settings.yml | 2 ++ .../prog/en/modules/acqui/lateorders.tt | 5 +++-- t/db_dependent/Koha/Acquisition/Fund.t | 19 ++++++++++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Koha/Acquisition/Fund.pm b/Koha/Acquisition/Fund.pm index d32f46af6b..80ef0b2f4a 100644 --- a/Koha/Acquisition/Fund.pm +++ b/Koha/Acquisition/Fund.pm @@ -17,6 +17,7 @@ package Koha::Acquisition::Fund; use Modern::Perl; +use Koha::Acquisition::Budgets; use Koha::Database; use base qw(Koha::Object); @@ -29,6 +30,21 @@ Koha::Acquisition::Fund object class =head2 Class methods +=head3 budget + + my $budget = $fund->budget; + +Returns the I object for the budget (aqbudgetperiods) +associated to the fund. + +=cut + +sub budget { + my ( $self ) = @_; + my $budget_rs = $self->_result->budget; + return Koha::Acquisition::Budget->_new_from_dbic( $budget_rs ); +} + =head3 to_api my $json = $fund->to_api; diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 96b3a31a68..70ba76b18f 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -59,6 +59,8 @@ modules: columnname: basket_group - columnname: library + - + columnname: budget - columnname: fund - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt index 1c81debcab..73fc10bf50 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt @@ -67,6 +67,7 @@ Basket Basket group Library + Budget Fund Claims count Claimed date @@ -131,8 +132,8 @@ [% Branches.GetName( lateorder.basket.authorizer.branchcode ) | html %] - [% lateorder.fund.budget_name | html %] - + [% lateorder.fund.budget.budget_period_description | html %] + [% lateorder.fund.budget_name | html %] [% lateorder.claims.count | html %] [% FOR claim IN lateorder.claims %] diff --git a/t/db_dependent/Koha/Acquisition/Fund.t b/t/db_dependent/Koha/Acquisition/Fund.t index 98ab1dcbf9..38dae6297a 100755 --- a/t/db_dependent/Koha/Acquisition/Fund.t +++ b/t/db_dependent/Koha/Acquisition/Fund.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 1; +use Test::More tests => 2; use t::lib::TestBuilder; @@ -42,3 +42,20 @@ subtest 'to_api() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'budget' => sub { + plan tests => 1; + + $schema->storage->txn_begin; + my $f = $builder->build_object( + { + class => 'Koha::Acquisition::Funds', + } + ); + + my $fund = Koha::Acquisition::Funds->find( $f->budget_id ); + is( ref( $fund->budget ), + 'Koha::Acquisition::Budget', + '->fund should return a Koha::Acquisition::Budget object' ); + $schema->storage->txn_rollback; +}; -- 2.20.1