From c594080aec47e139c277e6c8ec5d23e58c26c084 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Fri, 6 Jan 2023 13:52:32 +0000 Subject: [PATCH] Bug 32450: Update db to add noissuescharge flag and remove sysprefs This commit updates the database to add a new flag to show which debit_types are included in noissuescharge. It also deletes the current sysprefs that are hardcoded for this as these are now redundant. Test plan: 1) Choose a patron and add some fines to this patron that have different debit_types 2) Navigate to system preferences and observe that currently you can only amend the noissuescharge included debit types using three preferences: ManInvInNoissuesCharge, RentalsInNoissuesCharge, HoldsInNoissuesCharge 3) Apply both commits attached to this bug 4) Navigate as above and observe that these three system preferences are now gone 5) Navigate to Debit Types in System Preferences, the table should have a column called No issues charge that shows whether a debit_type is Included or Not included 6) Click the edit button and there should be a checkbox for Included in noissuescharge 7) Change some of the debit_types using this option and observe that the patron you added fines to will either be blocked from checkouts or able to checkout depending on which debit_types you include and the value of these fines. --- Koha/Schema/Result/AccountDebitType.pm | 18 ++++++++++-- .../bug_32450-add_debit_type_flag.pl | 29 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/mandatory/sysprefs.sql | 2 -- .../admin/preferences/circulation.pref | 18 ------------ 5 files changed, 46 insertions(+), 22 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_32450-add_debit_type_flag.pl diff --git a/Koha/Schema/Result/AccountDebitType.pm b/Koha/Schema/Result/AccountDebitType.pm index 74c6da8a80b..e6608a0aa68 100644 --- a/Koha/Schema/Result/AccountDebitType.pm +++ b/Koha/Schema/Result/AccountDebitType.pm @@ -71,6 +71,14 @@ boolean flag to denote if this debit type is available at point of sale boolean flag to denote if this till is archived or not +=head2 no_issues_charge + + data_type: 'tinyint' + default_value: 1 + is_nullable: 0 + +boolean flag to denote if the noissuescharge syspref for this debit type is active + =cut __PACKAGE__->add_columns( @@ -88,6 +96,8 @@ __PACKAGE__->add_columns( { data_type => "tinyint", default_value => 0, is_nullable => 0 }, "archived", { data_type => "tinyint", default_value => 0, is_nullable => 0 }, + "no_issues_charge", + { data_type => "tinyint", default_value => 1, is_nullable => 0 }, ); =head1 PRIMARY KEY @@ -135,8 +145,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ulpJRbi7H40EXr1QG+URKg +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-01-06 13:08:15 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4yfwGQzH8AzZYXfje3MH/A __PACKAGE__->add_columns( '+is_system' => { is_boolean => 1 } @@ -150,6 +160,10 @@ __PACKAGE__->add_columns( "+can_be_invoiced" => { is_boolean => 1 } ); +__PACKAGE__->add_columns( + "+no_issues_charge" => { is_boolean => 1 } +); + sub koha_objects_class { 'Koha::Account::DebitTypes'; } diff --git a/installer/data/mysql/atomicupdate/bug_32450-add_debit_type_flag.pl b/installer/data/mysql/atomicupdate/bug_32450-add_debit_type_flag.pl new file mode 100644 index 00000000000..32df1be5665 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_32450-add_debit_type_flag.pl @@ -0,0 +1,29 @@ +use Modern::Perl; + +return { + bug_number => "32450", + description => "Create a database flag for whether a debit type should be included in the noissuescharge block on circulation and remove redundant sysprefs.", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + if( !column_exists( 'account_debit_types', 'no_issues_charge' ) ) { + $dbh->do(q{ + ALTER TABLE account_debit_types ADD COLUMN `no_issues_charge` tinyint(1) NOT NULL DEFAULT 1 AFTER `archived` + }); + + say $out "Added column 'account_debit_types.no_issues_charge'"; + } + + $dbh->do(q{ + DELETE FROM systempreferences WHERE variable = 'ManInvInNoissuesCharge' + }); + + $dbh->do(q{ + DELETE FROM systempreferences WHERE variable = 'RentalsInNoissuesCharge' + }); + $dbh->do(q{ + DELETE FROM systempreferences WHERE variable = 'HoldsInNoissuesCharge' + }); + }, +}; \ No newline at end of file diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 59607073cac..471929f339f 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -65,6 +65,7 @@ CREATE TABLE `account_debit_types` ( `default_amount` decimal(28,6) DEFAULT NULL, `is_system` tinyint(1) NOT NULL DEFAULT 0, `archived` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'boolean flag to denote if this till is archived or not', + `no_issues_charge` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'boolean flag to denote if the noissuescharge syspref for this debit type is active', PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index beebd27a6fd..6065329b9d9 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -354,7 +354,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('LockExpiredDelay','','','Delay for locking expired patrons (empty means no locking)','Integer'), ('makePreviousSerialAvailable','0','','make previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.','YesNo'), ('Mana','2',NULL,'request to Mana Webservice. Mana centralize common information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','Choice'), -('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'), ('MARCAuthorityControlField008','|| aca||aabn | a|a d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'), ('MarcFieldDocURL', NULL, NULL, 'URL used for MARC field documentation. Following substitutions are available: {MARC} = marc flavour, eg. "MARC21" or "UNIMARC". {FIELD} = field number, eg. "000" or "048". {LANG} = user language, eg. "en" or "fi-FI"', 'free'), ('MarcFieldForCreatorId','',NULL,'Where to store the borrowernumber of the record''s creator','Free'), @@ -599,7 +598,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RenewalSendNotice','0','',NULL,'YesNo'), ('RenewSerialAddsSuggestion','0',NULL,'If ON, adds a new suggestion at serial subscription renewal','YesNo'), ('RentalFeesCheckoutConfirmation', '0', NULL , 'Allow user to confirm when checking out an item with rental fees.', 'YesNo'), -('RentalsInNoissuesCharge','1',NULL,'Rental charges block checkouts (added to noissuescharge).','YesNo'), ('ReplyToDefault','',NULL,'Use this email address as the replyto in emails','Free'), ('ReportsLog','0',NULL,'If ON, log information about reports.','YesNo'), ('RequireCashRegister','0',NULL,'Require a cash register when collecting a payment','YesNo'), 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 e025fc6e9d0..5683384fd69 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 @@ -375,24 +375,6 @@ Circulation: - pref: NoIssuesChargeGuarantorsWithGuarantees class: integer - '[% local_currency %] in fines.' - - - - pref: RentalsInNoissuesCharge - choices: - 1: Include - 0: "Don't include" - - rental charges when summing up charges for limit set in the noissuescharge system preference. - - - - pref: ManInvInNoissuesCharge - choices: - 1: Include - 0: "Don't include" - - custom debit type charges when summing up charges for limit set in the noissuescharge system preference. - - - - pref: HoldsInNoissuesCharge - choices: - 1: Include - 0: "Don't include" - - hold charges when summing up charges for limit set in the noissuescharge system preference. - - pref: ReturnBeforeExpiry choices: -- 2.37.1 (Apple Git-137.1)