From 6cd3975f64bd8cf31d626c6061d33f1974df9ea8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 29 Oct 2015 11:43:17 +0000 Subject: [PATCH] Bug 15084: Add Koha::Acquisition::Currenc[y|ies] classes The first step of this patch set is to move the business logic code from admin/currencies.pl to Koha::Acquisition::Currenc[y|ies]. Then a foreign key will be created on aqorders.currency as we want to assure data integrity. Note that a aqbooksellers.currency also exists but is never used. It could be removed in another bug report. This update has to care about possible breaking relation. For instance an old order has been made using a currency which is now deleted. To be sure the update process won't break a new column currency.archived is created and leave open the door for a further improvement (marked a currency as archived from the interface: this won't be provided by this enhancement). These archived currencies won't appear on the interface for newly created items (order/suggestion). Once this is done it becomes easy to remove the subroutine from C4::Budgets: GetCurrencies and GetCurrency. ConvertCurrency will also be removed but is not used anymore. Note that none of these subroutines were covered by tests. Now they are. Test plan: 0/ Don't apply this patch 1/ Create a temporary currency and an order using it 2/ Remove the currency from your CLI 3/ Apply the patch and execute the DB entry 4/ Note that the currency is inserted and marked as archived. 5/ Edit the previous order and confirm that the correct currency is still selected. It won't never be displayed anywhere else. 6/ Test the admin script: on admin/currency.pl add/remove/edit currencies. You could not have 2 active currencies at the same time. 7/ Then on the different scripts of the acquisition module, focus on the currencies values and create a new order, receive it. Create/edit a suggestion Other changes must be checked by the QAer. Signed-off-by: Josef Moravec Signed-off-by: Kyle M Hall Signed-off-by: Brendan A Gallagher --- Koha/Acquisition/Currencies.pm | 50 ++++++++++++++++++++++++++++++++++ Koha/Acquisition/Currency.pm | 44 ++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 Koha/Acquisition/Currencies.pm create mode 100644 Koha/Acquisition/Currency.pm diff --git a/Koha/Acquisition/Currencies.pm b/Koha/Acquisition/Currencies.pm new file mode 100644 index 0000000000..7f506a722e --- /dev/null +++ b/Koha/Acquisition/Currencies.pm @@ -0,0 +1,50 @@ +package Koha::Acquisition::Currencies; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Carp; + +use Koha::Database; + +use Koha::Acquisition::Currency; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Acquisition::Currencies - Koha Acquisition Currency Object set class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'Currency'; +} + +sub object_class { + return 'Koha::Acquisition::Currency'; +} + +1; diff --git a/Koha/Acquisition/Currency.pm b/Koha/Acquisition/Currency.pm new file mode 100644 index 0000000000..dd34cc2046 --- /dev/null +++ b/Koha/Acquisition/Currency.pm @@ -0,0 +1,44 @@ +package Koha::Acquisition::Currency; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Carp; + +use Koha::Database; + +use base qw(Koha::Object); + +=head1 NAME + +Koha::Acquisition::Currency - Koha Acquisition Currency Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'Currency'; +} + +1; -- 2.39.5