@@ -, +, @@ --- 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 --- a/C4/Installer.pm +++ a/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 $/; --- a/Koha/Account.pm +++ a/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; } --- a/Koha/Account/DebitType.pm +++ a/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; --- a/Koha/Account/DebitTypes.pm +++ a/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; --- a/Koha/Schema/Result/AcDebitTypesBranch.pm +++ a/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 + +=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 + +=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 + +=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; --- a/Koha/Schema/Result/AccountDebitType.pm +++ a/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 + +=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 + +=back + +=cut + +__PACKAGE__->set_primary_key("code"); + +=head1 RELATIONS + +=head2 ac_debit_types_branches + +Type: has_many + +Related object: L + +=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 + +=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; --- a/Koha/Schema/Result/Accountline.pm +++ a/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 + +=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'; --- a/Koha/Schema/Result/Branch.pm +++ a/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 + +=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 } --- a/installer/data/mysql/account_debit_types.sql +++ a/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); --- a/installer/data/mysql/atomicupdate/bug_23049_debit.perl +++ a/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"; +} --- a/installer/data/mysql/en/mandatory/account_debit_types.sql +++ a/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); --- a/installer/data/mysql/en/optional/auth_val.sql +++ a/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'); --- a/installer/data/mysql/kohastructure.sql +++ a/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; -- --- a/installer/data/mysql/mandatory/auth_val_cat.sql +++ a/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'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt @@ -384,8 +384,6 @@

Shelving location (usually appears when adding or editing an item). LOC maps to items.location in the Koha database.

[% CASE 'LOST' %]

Descriptions for the items marked as lost (appears when adding or editing an item)

- [% CASE 'MANUAL_INV' %] -

Values for manual invoicing types

[% CASE 'NOT_LOAN' %]

Reasons why a title is not for loan

[% CASE 'OPAC_SUG' %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ a/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: --- a/misc/devel/populate_db.pl +++ a/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" ); --- a/t/db_dependent/Accounts.t +++ a/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 ); --