Bugzilla – Attachment 94307 Details for
Bug 23049
Replace MANUAL_INV authorised value with a dedicated table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23049: Add debit_type
Bug-23049-Add-debittype.patch (text/plain), 28.14 KB, created by
Martin Renvoize (ashimema)
on 2019-10-16 15:30:05 UTC
(
hide
)
Description:
Bug 23049: Add debit_type
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-10-16 15:30:05 UTC
Size:
28.14 KB
patch
obsolete
>From 9c01c10c79cddbb89f41ab1d697769753fc6a8d8 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 28 Feb 2019 16:58:06 +0000 >Subject: [PATCH] Bug 23049: Add debit_type >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >* Add account_debit_types table >* Add ac_debit_types_branches table >* Add account_debit_types defaults >* Add Koha::Account::DebitType and Koha::Account::DebitTypes >* Prevent deletion of defaults >* Migrate MANUAL_INV values >* Remove MANUAL_INV references >* Migrate accounttype values > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > C4/Installer.pm | 1 + > Koha/Account.pm | 19 +-- > Koha/Account/DebitType.pm | 60 +++++++++ > Koha/Account/DebitTypes.pm | 70 ++++++++++ > Koha/Schema/Result/AcDebitTypesBranch.pm | 97 ++++++++++++++ > Koha/Schema/Result/AccountDebitType.pm | 122 +++++++++++++++++ > Koha/Schema/Result/Accountline.pm | 33 ++++- > Koha/Schema/Result/Branch.pm | 19 ++- > installer/data/mysql/account_debit_types.sql | 14 ++ > .../mysql/atomicupdate/bug_23049_debit.perl | 125 ++++++++++++++++++ > .../en/mandatory/account_debit_types.sql | 14 ++ > installer/data/mysql/en/optional/auth_val.sql | 3 - > installer/data/mysql/kohastructure.sql | 31 ++++- > .../data/mysql/mandatory/auth_val_cat.sql | 1 - > .../en/modules/admin/authorised_values.tt | 2 - > .../admin/preferences/circulation.pref | 2 +- > misc/devel/populate_db.pl | 1 + > t/db_dependent/Accounts.t | 16 +-- > 18 files changed, 597 insertions(+), 33 deletions(-) > create mode 100644 Koha/Account/DebitType.pm > create mode 100644 Koha/Account/DebitTypes.pm > create mode 100644 Koha/Schema/Result/AcDebitTypesBranch.pm > create mode 100644 Koha/Schema/Result/AccountDebitType.pm > create mode 100644 installer/data/mysql/account_debit_types.sql > create mode 100644 installer/data/mysql/atomicupdate/bug_23049_debit.perl > create mode 100644 installer/data/mysql/en/mandatory/account_debit_types.sql > >diff --git a/C4/Installer.pm b/C4/Installer.pm >index 9b24ff3d2d..e4cae05c06 100644 >--- a/C4/Installer.pm >+++ b/C4/Installer.pm >@@ -332,6 +332,7 @@ sub load_sql_in_order { > push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/userpermissions.sql"; > push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/audio_alerts.sql"; > push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/account_offset_types.sql"; >+ push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/account_debit_types.sql"; > foreach my $file (@fnames) { > # warn $file; > undef $/; >diff --git a/Koha/Account.pm b/Koha/Account.pm >index afff235822..743b4b7d04 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -628,28 +628,21 @@ Charges exempt from non-issue are: > sub non_issues_charges { > my ($self) = @_; > >- # FIXME REMOVE And add a warning in the about page + update DB if length(MANUAL_INV) > 5 >- my $ACCOUNT_TYPE_LENGTH = 5; # this is plain ridiculous... >- >+ #NOTE: With bug 23049 these preferences could be moved to being attached >+ #to individual debit types to give more flexability and specificity. > my @not_fines; > push @not_fines, 'Res' > unless C4::Context->preference('HoldsInNoissuesCharge'); >- push @not_fines, 'Rent' >+ push @not_fines, ( 'RENT', 'RENT_DAILY', 'RENT_RENEW', 'RENT_DAILY_RENEW' ) > unless C4::Context->preference('RentalsInNoissuesCharge'); > unless ( C4::Context->preference('ManInvInNoissuesCharge') ) { >- my $dbh = C4::Context->dbh; >- push @not_fines, >- @{ >- $dbh->selectcol_arrayref(q| >- SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV' >- |) >- }; >+ my @man_inv = Koha::Account::DebitTypes->search({ system => 0 })->get_column('code'); >+ push @not_fines, @man_inv; > } >- @not_fines = map { substr( $_, 0, $ACCOUNT_TYPE_LENGTH ) } uniq(@not_fines); > > return $self->lines->search( > { >- accounttype => { -not_in => \@not_fines } >+ debit_type => { -not_in => \@not_fines } > }, > )->total_outstanding; > } >diff --git a/Koha/Account/DebitType.pm b/Koha/Account/DebitType.pm >new file mode 100644 >index 0000000000..59bb5c1e5e >--- /dev/null >+++ b/Koha/Account/DebitType.pm >@@ -0,0 +1,60 @@ >+package Koha::Account::DebitType; >+ >+# Copyright PTFS Europe 2019 >+# >+# 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 List::Util qw/any/; >+ >+use Koha::Database; >+use Koha::Exceptions; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Account::DebitType - Koha Account debit type Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 delete >+ >+Overridden delete method to prevent system default deletions >+ >+=cut >+ >+sub delete { >+ my ($self) = @_; >+ >+ Koha::Exceptions::CannotDeleteDefault->throw if $self->is_system; >+ >+ return $self->SUPER::delete; >+} >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'AccountDebitType'; >+} >+ >+1; >diff --git a/Koha/Account/DebitTypes.pm b/Koha/Account/DebitTypes.pm >new file mode 100644 >index 0000000000..2e6eb2c9b6 >--- /dev/null >+++ b/Koha/Account/DebitTypes.pm >@@ -0,0 +1,70 @@ >+package Koha::Account::DebitTypes; >+ >+# Copyright PTFS Europe 2019 >+# >+# 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 List::Util qw/any/; >+ >+use Koha::Database; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Account::DebitTypes - Koha Account debit types Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=head3 delete >+ >+Overridden delete method to prevent system default deletions >+ >+=cut >+ >+sub delete { >+ my ($self) = @_; >+ >+ my @set = $self->as_list; >+ for my $type (@set) { >+ if ( $type->is_system ) { >+ Koha::Exceptions::CannotDeleteDefault->throw; >+ } >+ } >+ >+ return $self->SUPER::delete; >+} >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'AccountDebitType'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::Account::DebitType'; >+} >+ >+1; >diff --git a/Koha/Schema/Result/AcDebitTypesBranch.pm b/Koha/Schema/Result/AcDebitTypesBranch.pm >new file mode 100644 >index 0000000000..3a9f4e36fe >--- /dev/null >+++ b/Koha/Schema/Result/AcDebitTypesBranch.pm >@@ -0,0 +1,97 @@ >+use utf8; >+package Koha::Schema::Result::AcDebitTypesBranch; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+=head1 NAME >+ >+Koha::Schema::Result::AcDebitTypesBranch >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+=head1 TABLE: C<ac_debit_types_branches> >+ >+=cut >+ >+__PACKAGE__->table("ac_debit_types_branches"); >+ >+=head1 ACCESSORS >+ >+=head2 debit_type_code >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 16 >+ >+=head2 branchcode >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 10 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "debit_type_code", >+ { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 16 }, >+ "branchcode", >+ { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, >+); >+ >+=head1 RELATIONS >+ >+=head2 branchcode >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Branch> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "branchcode", >+ "Koha::Schema::Result::Branch", >+ { branchcode => "branchcode" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "CASCADE", >+ on_update => "RESTRICT", >+ }, >+); >+ >+=head2 debit_type_code >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::AccountDebitType> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "debit_type_code", >+ "Koha::Schema::Result::AccountDebitType", >+ { code => "debit_type_code" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "CASCADE", >+ on_update => "RESTRICT", >+ }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 10:47:58 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:a4VtzV3gLrij1s0Czant2Q >+ >+ >+# You can replace this text with custom code or comments, and it will be preserved on regeneration >+1; >diff --git a/Koha/Schema/Result/AccountDebitType.pm b/Koha/Schema/Result/AccountDebitType.pm >new file mode 100644 >index 0000000000..43b8583a41 >--- /dev/null >+++ b/Koha/Schema/Result/AccountDebitType.pm >@@ -0,0 +1,122 @@ >+use utf8; >+package Koha::Schema::Result::AccountDebitType; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+=head1 NAME >+ >+Koha::Schema::Result::AccountDebitType >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+=head1 TABLE: C<account_debit_types> >+ >+=cut >+ >+__PACKAGE__->table("account_debit_types"); >+ >+=head1 ACCESSORS >+ >+=head2 code >+ >+ data_type: 'varchar' >+ is_nullable: 0 >+ size: 16 >+ >+=head2 default_amount >+ >+ data_type: 'decimal' >+ is_nullable: 1 >+ size: [28,6] >+ >+=head2 description >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 200 >+ >+=head2 can_be_added_manually >+ >+ data_type: 'tinyint' >+ default_value: 1 >+ is_nullable: 0 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "code", >+ { data_type => "varchar", is_nullable => 0, size => 16 }, >+ "default_amount", >+ { data_type => "decimal", is_nullable => 1, size => [28, 6] }, >+ "description", >+ { data_type => "varchar", is_nullable => 1, size => 200 }, >+ "can_be_added_manually", >+ { data_type => "tinyint", default_value => 1, is_nullable => 0 }, >+); >+ >+=head1 PRIMARY KEY >+ >+=over 4 >+ >+=item * L</code> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->set_primary_key("code"); >+ >+=head1 RELATIONS >+ >+=head2 ac_debit_types_branches >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::AcDebitTypesBranch> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "ac_debit_types_branches", >+ "Koha::Schema::Result::AcDebitTypesBranch", >+ { "foreign.debit_type_code" => "self.code" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+=head2 accountlines >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::Accountline> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "accountlines", >+ "Koha::Schema::Result::Accountline", >+ { "foreign.debit_type" => "self.code" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 10:47:58 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7DG78TAnHRei3U434Vuz9w >+ >+__PACKAGE__->add_columns( >+ '+is_system' => { is_boolean => 1 } >+); >+ >+sub koha_objects_class { >+ 'Koha::Account::DebitTypes'; >+} >+sub koha_object_class { >+ 'Koha::Account::DebitType'; >+} >+ >+1; >diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm >index c2ae858a96..5082443f64 100644 >--- a/Koha/Schema/Result/Accountline.pm >+++ b/Koha/Schema/Result/Accountline.pm >@@ -69,6 +69,13 @@ __PACKAGE__->table("accountlines"); > is_nullable: 1 > size: 80 > >+=head2 debit_type >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 16 >+ > =head2 status > > data_type: 'varchar' >@@ -143,6 +150,8 @@ __PACKAGE__->add_columns( > { data_type => "longtext", is_nullable => 1 }, > "accounttype", > { data_type => "varchar", is_nullable => 1, size => 80 }, >+ "debit_type", >+ { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 16 }, > "status", > { data_type => "varchar", is_nullable => 1, size => 16 }, > "payment_type", >@@ -252,6 +261,26 @@ __PACKAGE__->belongs_to( > }, > ); > >+=head2 debit_type >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::AccountDebitType> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "debit_type", >+ "Koha::Schema::Result::AccountDebitType", >+ { code => "debit_type" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "SET NULL", >+ on_update => "CASCADE", >+ }, >+); >+ > =head2 itemnumber > > Type: belongs_to >@@ -313,8 +342,8 @@ __PACKAGE__->belongs_to( > ); > > >-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-09-23 10:45:21 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L+QlTTT+MdGoA3shpyaBgQ >+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 10:47:58 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RKg4gDSu0WwJ1C9YmDv3pw > > sub koha_objects_class { > 'Koha::Account::Lines'; >diff --git a/Koha/Schema/Result/Branch.pm b/Koha/Schema/Result/Branch.pm >index 6191b31a65..fa9679eb2e 100644 >--- a/Koha/Schema/Result/Branch.pm >+++ b/Koha/Schema/Result/Branch.pm >@@ -211,6 +211,21 @@ __PACKAGE__->set_primary_key("branchcode"); > > =head1 RELATIONS > >+=head2 ac_debit_types_branches >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::AcDebitTypesBranch> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "ac_debit_types_branches", >+ "Koha::Schema::Result::AcDebitTypesBranch", >+ { "foreign.branchcode" => "self.branchcode" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > =head2 accountlines > > Type: has_many >@@ -677,8 +692,8 @@ __PACKAGE__->has_many( > ); > > >-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-09-23 10:45:22 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KDg4i49bpMxXQ1LP6OZFWQ >+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-09-26 15:59:23 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IiEBfDpMBAi9cv7OqevVRQ > > __PACKAGE__->add_columns( > '+pickup_location' => { is_boolean => 1 } >diff --git a/installer/data/mysql/account_debit_types.sql b/installer/data/mysql/account_debit_types.sql >new file mode 100644 >index 0000000000..db769631cc >--- /dev/null >+++ b/installer/data/mysql/account_debit_types.sql >@@ -0,0 +1,14 @@ >+INSERT INTO account_debit_types ( code, description, can_be_added_manually, default_amount, is_system ) VALUES >+('ACCOUNT', 'Account creation fee', 0, NULL, 1), >+('ACCOUNT_RENEW', 'Account renewal fee', 0, NULL, 1), >+('HE', 'Hold waiting too long', 0, NULL, 1), >+('LOST', 'Lost item', 1, NULL, 1), >+('M', 'Manual fee', 1, NULL, 0), >+('N', 'New card fee', 1, NULL, 1), >+('OVERDUE', 'Overdue fine', 0, NULL, 1), >+('PF', 'Lost item processing fee', 0, NULL, 1), >+('RENT', 'Rental fee', 0, NULL, 1), >+('RENT_DAILY', 'Daily rental fee', 0, NULL, 1), >+('RENT_RENEW', 'Renewal of rental item', 0, NULL, 1), >+('RENT_DAILY_RENEW', 'Rewewal of daily rental item', 0, NULL, 1), >+('Res', 'Hold fee', 0, NULL, 1); >diff --git a/installer/data/mysql/atomicupdate/bug_23049_debit.perl b/installer/data/mysql/atomicupdate/bug_23049_debit.perl >new file mode 100644 >index 0000000000..f5fa7c2c97 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_23049_debit.perl >@@ -0,0 +1,125 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if ( CheckVersion($DBversion) ) { >+ >+ $dbh->do( >+ qq{ >+ CREATE TABLE IF NOT EXISTS account_debit_types ( >+ code varchar(64) NOT NULL, >+ description varchar(200) NULL, >+ can_be_added_manually tinyint(4) NOT NULL DEFAULT 1, >+ default_amount decimal(28, 6) NULL, >+ is_system tinyint(1) NOT NULL DEFAULT 0, >+ PRIMARY KEY (code) >+ ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci >+ } >+ ); >+ >+ $dbh->do( >+ qq{ >+ CREATE TABLE IF NOT EXISTS ac_debit_types_branches ( >+ debit_type_code VARCHAR(64), >+ branchcode VARCHAR(10), >+ FOREIGN KEY (debit_type_code) REFERENCES account_debit_types(code) ON DELETE CASCADE, >+ FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci >+ } >+ ); >+ >+ $dbh->do( >+ qq{ >+ INSERT IGNORE INTO account_debit_types ( >+ code, >+ description, >+ can_be_added_manually, >+ default_amount, >+ is_system >+ ) >+ VALUES >+ ('ACCOUNT', 'Account creation fee', 0, NULL, 1), >+ ('ACCOUNT_RENEW', 'Account renewal fee', 0, NULL, 1), >+ ('HE', 'Hold waiting too long', 0, NULL, 1), >+ ('LOST', 'Lost item', 1, NULL, 1), >+ ('M', 'Manual fee', 1, NULL, 0), >+ ('N', 'New card fee', 1, NULL, 1), >+ ('OVERDUE', 'Overdue fine', 0, NULL, 1), >+ ('PF', 'Lost item processing fee', 0, NULL, 1), >+ ('RENT', 'Rental fee', 0, NULL, 1), >+ ('RENT_DAILY', 'Daily rental fee', 0, NULL, 1), >+ ('RENT_RENEW', 'Renewal of rental item', 0, NULL, 1), >+ ('RENT_DAILY_RENEW', 'Rewewal of daily rental item', 0, NULL, 1), >+ ('Res', 'Hold fee', 0, NULL, 1) >+ } >+ ); >+ >+ $dbh->do( >+ qq{ >+ INSERT IGNORE INTO account_debit_types ( >+ code, >+ default_amount, >+ description, >+ can_be_added_manually, >+ is_system >+ ) >+ SELECT >+ SUBSTR(authorised_value, 1, 64), >+ lib, >+ authorised_value, >+ 1, >+ 0 >+ FROM >+ authorised_values >+ WHERE >+ category = 'MANUAL_INV' >+ } >+ ); >+ >+ $dbh->do( >+ qq{ >+ ALTER IGNORE TABLE accountlines >+ ADD >+ debit_type varchar(64) DEFAULT NULL >+ AFTER >+ accounttype >+ } >+ ); >+ >+ $dbh->do( >+ qq{ >+ ALTER TABLE accountlines ADD CONSTRAINT `accountlines_ibfk_debit_type` FOREIGN KEY (`debit_type`) REFERENCES `account_debit_types` (`code`) ON DELETE SET NULL ON UPDATE CASCADE >+ } >+ ); >+ >+ $dbh->do( >+ qq{ >+ UPDATE accountlines SET debit_type = accounttype, accounttype = NULL WHERE accounttype IN (SELECT code from account_debit_types) >+ } >+ ); >+ >+ # Clean up MANUAL_INV >+ $dbh->do( >+ qq{ >+ DELETE FROM authorised_values WHERE category = 'MANUAL_INV' >+ } >+ ); >+ $dbh->do( >+ qq{ >+ DELETE FROM authorised_value_categories WHERE category_name = 'MANUAL_INV' >+ } >+ ); >+ >+ # Add new permission >+ $dbh->do( >+ q{ >+ INSERT IGNORE INTO permissions (module_bit, code, description) >+ VALUES >+ ( >+ 3, >+ 'manage_accounts', >+ 'Manage Account Debit and Credit Types' >+ ) >+ } >+ ); >+ >+ SetVersion($DBversion); >+ print "Upgrade to $DBversion done (Bug 23049 - Add account debit_types)\n"; >+} >diff --git a/installer/data/mysql/en/mandatory/account_debit_types.sql b/installer/data/mysql/en/mandatory/account_debit_types.sql >new file mode 100644 >index 0000000000..db769631cc >--- /dev/null >+++ b/installer/data/mysql/en/mandatory/account_debit_types.sql >@@ -0,0 +1,14 @@ >+INSERT INTO account_debit_types ( code, description, can_be_added_manually, default_amount, is_system ) VALUES >+('ACCOUNT', 'Account creation fee', 0, NULL, 1), >+('ACCOUNT_RENEW', 'Account renewal fee', 0, NULL, 1), >+('HE', 'Hold waiting too long', 0, NULL, 1), >+('LOST', 'Lost item', 1, NULL, 1), >+('M', 'Manual fee', 1, NULL, 0), >+('N', 'New card fee', 1, NULL, 1), >+('OVERDUE', 'Overdue fine', 0, NULL, 1), >+('PF', 'Lost item processing fee', 0, NULL, 1), >+('RENT', 'Rental fee', 0, NULL, 1), >+('RENT_DAILY', 'Daily rental fee', 0, NULL, 1), >+('RENT_RENEW', 'Renewal of rental item', 0, NULL, 1), >+('RENT_DAILY_RENEW', 'Rewewal of daily rental item', 0, NULL, 1), >+('Res', 'Hold fee', 0, NULL, 1); >diff --git a/installer/data/mysql/en/optional/auth_val.sql b/installer/data/mysql/en/optional/auth_val.sql >index 24f036bd20..b4e00fd8b2 100644 >--- a/installer/data/mysql/en/optional/auth_val.sql >+++ b/installer/data/mysql/en/optional/auth_val.sql >@@ -48,9 +48,6 @@ INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('NOT_L > -- restricted status of an item, linked to items.restricted > INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('RESTRICTED','1','Restricted Access'); > >--- manual invoice types >-INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('MANUAL_INV','Copier Fees','.25'); >- > -- custom borrower notes > INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('BOR_NOTES','ADDR','Address Notes'); > >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 7073c9a2d1..87d219ab29 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2621,6 +2621,32 @@ CREATE TABLE `cash_registers` ( > CONSTRAINT cash_registers_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE CASCADE > ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; > >+-- >+-- Table structure for table `account_debit_types` >+-- >+ >+DROP TABLE IF EXISTS `account_debit_types`; >+CREATE TABLE `account_debit_types` ( >+ `code` varchar(64) NOT NULL, >+ `description` varchar(200) DEFAULT NULL, >+ `can_be_added_manually` tinyint(4) NOT NULL DEFAULT 1, >+ `default_amount` decimal(28,6) DEFAULT NULL, >+ `is_system` tinyint(1) NOT NULL DEFAULT 0, >+ PRIMARY KEY (`code`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; >+ >+-- >+-- Table structure for table `ac_debit_types_branches` >+-- >+ >+DROP TABLE IF EXISTS `ac_debit_types_branches`; >+CREATE TABLE `ac_debit_types_branches` ( >+ `debit_type_code` VARCHAR(64), >+ `branchcode` VARCHAR(10), >+ FOREIGN KEY (`debit_type_code`) REFERENCES `account_debit_types` (`code`) ON DELETE CASCADE, >+ FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE >+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; >+ > -- > -- Table structure for table `accountlines` > -- >@@ -2635,6 +2661,7 @@ CREATE TABLE `accountlines` ( > `amount` decimal(28,6) default NULL, > `description` LONGTEXT, > `accounttype` varchar(80) default NULL, >+ `debit_type` varchar(64) default NULL, > `status` varchar(16) default NULL, > `payment_type` varchar(80) default NULL, -- optional authorised value PAYMENT_TYPE > `amountoutstanding` decimal(28,6) default NULL, >@@ -2647,6 +2674,7 @@ CREATE TABLE `accountlines` ( > PRIMARY KEY (`accountlines_id`), > KEY `acctsborridx` (`borrowernumber`), > KEY `timeidx` (`timestamp`), >+ KEY `debit_type` (`debit_type`), > KEY `itemnumber` (`itemnumber`), > KEY `branchcode` (`branchcode`), > KEY `manager_id` (`manager_id`), >@@ -2654,7 +2682,8 @@ CREATE TABLE `accountlines` ( > CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE, > CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, > CONSTRAINT `accountlines_ibfk_branches` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE, >- CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`) REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE >+ CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`) REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, >+ CONSTRAINT `accountlines_ibfk_debit_type` FOREIGN KEY (`debit_type`) REFERENCES `account_debit_types` (`code`) ON DELETE SET NULL ON UPDATE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > > -- >diff --git a/installer/data/mysql/mandatory/auth_val_cat.sql b/installer/data/mysql/mandatory/auth_val_cat.sql >index 70e7d19a95..f39bf93502 100644 >--- a/installer/data/mysql/mandatory/auth_val_cat.sql >+++ b/installer/data/mysql/mandatory/auth_val_cat.sql >@@ -32,7 +32,6 @@ INSERT IGNORE INTO authorised_value_categories( category_name ) > ('NOT_LOAN'), > ('CCODE'), > ('LOC'), >- ('MANUAL_INV'), > ('BOR_NOTES'), > ('OPAC_SUG'), > ('SIP_MEDIA_TYPE'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >index 7715e0b6f5..0c8e1fccab 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt >@@ -384,8 +384,6 @@ > <p>Shelving location (usually appears when adding or editing an item). LOC maps to items.location in the Koha database.</p> > [% CASE 'LOST' %] > <p>Descriptions for the items marked as lost (appears when adding or editing an item)</p> >- [% CASE 'MANUAL_INV' %] >- <p>Values for manual invoicing types</p> > [% CASE 'NOT_LOAN' %] > <p>Reasons why a title is not for loan</p> > [% CASE 'OPAC_SUG' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index 9f7c0dcb48..3c24d51273 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -352,7 +352,7 @@ Circulation: > choices: > yes: Include > no: "Don't include" >- - MANUAL_INV charges when summing up charges for noissuescharge. >+ - custom debit type charges when summing up charges for noissuescharge. > - > - pref: HoldsInNoissuesCharge > choices: >diff --git a/misc/devel/populate_db.pl b/misc/devel/populate_db.pl >index f2cb974655..341c53008f 100755 >--- a/misc/devel/populate_db.pl >+++ b/misc/devel/populate_db.pl >@@ -108,6 +108,7 @@ my @sample_files_mandatory = ( > "$data_dir/userflags.sql", > "$data_dir/userpermissions.sql", > "$data_dir/account_offset_types.sql", >+ "$data_dir/account_debit_types.sql", > ); > my @sample_lang_files_mandatory = ( glob $root . "/installer/data/mysql/$lang/mandatory/*.sql" ); > my @sample_lang_files_optional = ( glob $root . "/installer/data/mysql/$lang/optional/*.sql" ); >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index 4a450632eb..d6fd47524d 100644 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -786,23 +786,23 @@ subtest "Koha::Account::non_issues_charges tests" => sub { > interface => 'commandline' > } > ); >+ Koha::Account::DebitTypes->new( >+ { >+ code => 'Copie', >+ description => 'Fee for copie', >+ is_system => 0 >+ } >+ )->store; > Koha::Account::Line->new( > { > borrowernumber => $patron->borrowernumber, > date => $today, > description => 'a Manual invoice fee', >- accounttype => 'Copie', >+ debit_type => 'Copie', > amountoutstanding => $manual, > interface => 'commandline' > } > )->store; >- Koha::AuthorisedValue->new( >- { >- category => 'MANUAL_INV', >- authorised_value => 'Copie', >- lib => 'Fee for copie', >- } >- )->store; > > > t::lib::Mocks::mock_preference( 'HoldsInNoissuesCharge', 0 ); >-- >2.20.1
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 23049
:
93513
|
93514
|
93515
|
93516
|
93518
|
93519
|
93520
|
93521
|
93522
|
93523
|
93529
|
93557
|
93564
|
93565
|
93567
|
93568
|
93569
|
93570
|
93571
|
93572
|
93573
|
93574
|
93575
|
93576
|
93577
|
93578
|
93579
|
93960
|
93961
|
93962
|
93963
|
93964
|
93965
|
93966
|
93967
|
93968
|
93969
|
93970
|
93972
|
93973
|
93974
|
93975
|
93976
|
93977
|
93978
|
93979
|
93989
|
93990
|
93991
|
93992
|
93993
|
93994
|
93995
|
93996
|
93997
|
93998
|
93999
|
94000
|
94001
|
94002
|
94003
|
94004
|
94005
|
94006
|
94007
|
94008
|
94073
|
94074
|
94075
|
94076
|
94077
|
94078
|
94079
|
94080
|
94081
|
94082
|
94083
|
94084
|
94085
|
94086
|
94087
|
94088
|
94089
|
94090
|
94091
|
94092
|
94093
|
94111
|
94112
|
94113
|
94114
|
94115
|
94116
|
94117
|
94118
|
94119
|
94120
|
94121
|
94122
|
94123
|
94124
|
94125
|
94126
|
94127
|
94128
|
94129
|
94130
|
94131
|
94132
|
94133
|
94134
|
94135
|
94136
|
94137
|
94138
|
94139
|
94140
|
94141
|
94142
|
94143
|
94144
|
94145
|
94146
|
94147
|
94148
|
94149
|
94150
|
94151
|
94152
|
94165
|
94307
|
94308
|
94309
|
94310
|
94311
|
94312
|
94313
|
94314
|
94315
|
94316
|
94317
|
94318
|
94319
|
94320
|
94321
|
94323
|
94324
|
94325
|
94326
|
94327
|
94328
|
94329
|
94331
|
94332
|
94333
|
94334
|
94335
|
94336
|
94337
|
94338
|
94339
|
94340
|
94341
|
94342
|
94343
|
94344
|
94345
|
94346
|
94347
|
94348
|
94349
|
94350
|
94351
|
94352
|
94648