Browse Source

Bug 26341: Database update for bug 21443 is not idempotent and will destroy settings

If the database update for bug 21443 is run, and the library changes any
of the hourly or daily rental fees following the calendar, a second run
of the database update will overwrite those changes.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Kyle Hall 4 years ago
committed by Jonathan Druart
parent
commit
e708566e72
  1. 4
      installer/data/mysql/kohastructure.sql
  2. 11
      installer/data/mysql/updatedatabase.pl

4
installer/data/mysql/kohastructure.sql

@ -906,9 +906,9 @@ CREATE TABLE `itemtypes` ( -- defines the item types
description LONGTEXT, -- a plain text explanation of the item type
rentalcharge decimal(28,6) default NULL, -- the amount charged when this item is checked out/issued
rentalcharge_daily decimal(28,6) default NULL, -- the amount charged for each day between checkout date and due date
rentalcharge_daily_calendar tinyint(1) NOT NULL DEFAULT 1, -- controls if the daily retnal fee is calculated directly or using finesCalendar
rentalcharge_daily_calendar tinyint(1) NOT NULL DEFAULT 1, -- controls if the daily rental fee is calculated directly or using finesCalendar
rentalcharge_hourly decimal(28,6) default NULL, -- the amount charged for each hour between checkout date and due date
rentalcharge_hourly_calendar tinyint(1) NOT NULL DEFAULT 1, -- controls if the hourly retnal fee is calculated directly or using finesCalendar
rentalcharge_hourly_calendar tinyint(1) NOT NULL DEFAULT 1, -- controls if the hourly rental fee is calculated directly or using finesCalendar
defaultreplacecost decimal(28,6) default NULL, -- default replacement cost
processfee decimal(28,6) default NULL, -- default text be recorded in the column note when the processing fee is applied
notforloan smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan

11
installer/data/mysql/updatedatabase.pl

@ -21260,12 +21260,17 @@ if( CheckVersion( $DBversion ) ) {
$DBversion = '19.12.00.052';
if( CheckVersion( $DBversion ) ) {
my $finesCalendar = C4::Context->preference('finesCalendar');
my $value = $finesCalendar eq 'noFinesWhenClosed' ? 1 : 0;
if( !column_exists( 'itemtypes', 'rentalcharge_daily_calendar' ) ) {
$dbh->do(q{
ALTER TABLE itemtypes ADD COLUMN
rentalcharge_daily_calendar tinyint(1) NOT NULL DEFAULT 1
AFTER rentalcharge_daily;
});
$dbh->do("UPDATE itemtypes SET rentalcharge_daily_calendar = $value");
}
if( !column_exists( 'itemtypes', 'rentalcharge_hourly_calendar' ) ) {
@ -21274,11 +21279,9 @@ if( CheckVersion( $DBversion ) ) {
rentalcharge_hourly_calendar tinyint(1) NOT NULL DEFAULT 1
AFTER rentalcharge_hourly;
});
}
my $finesCalendar = C4::Context->preference('finesCalendar');
my $value = $finesCalendar eq 'noFinesWhenClosed' ? 1 : 0;
$dbh->do("UPDATE itemtypes SET rentalcharge_hourly_calendar = $value, rentalcharge_daily_calendar = $value");
$dbh->do("UPDATE itemtypes SET rentalcharge_hourly_calendar = $value");
}
NewVersion( $DBversion, 21443, "Add ability to exclude holidays when calculating rentals fees by time period");
}

Loading…
Cancel
Save