From c645d1aa6c624bf04eb49850527bc45971e177f5 Mon Sep 17 00:00:00 2001 From: emilyrose Date: Thu, 28 Sep 2023 15:28:58 -0400 Subject: [PATCH] Bug 17015 : Correction when creating a new library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch is a rebase of all the other ones. I have also resolved an issue that occurred when creating a new library. When creating a library, days are copied from the first library in the "branches" table and added to the new library in the "discrete_calendar" table. The problem arises because the table stores libraries in alphabetical order based on their branch code. So, if the new library has a branch code that comes first in alphabetical order, no days can be added, which would prevent the calendar from functioning for that library. I resolved this issue by copying the days from the first library that appears in the "discrete_calendar" table. This way, we ensure that days will be found and copied. TEST PLAN 1) Apply the patch 2) Run installer/data/mysql/updatedatabase.pl 3) Run misc/cronjobs/add_days_discrete_calendar.pl 4) Check that the max date is today + 1 day 5) Run t/db_dependent/DiscreteCalendar.t 6) If all the test pass, then the rebase work 7) Now, go to “Koha administration > Libraries > New library” 8) In “Library code” enter “A” 9) Enter the name that you want 10) Click the “Submit” button 11) Go to “Tools > Calendar” 12) Select the calendar for the library you just created 13) If there are no errors displayed on the page, the issue is resolved. --- Koha/DiscreteCalendar.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/DiscreteCalendar.pm b/Koha/DiscreteCalendar.pm index 80161d991b..178e2b1dfe 100644 --- a/Koha/DiscreteCalendar.pm +++ b/Koha/DiscreteCalendar.pm @@ -177,7 +177,7 @@ sub add_new_branch { }); unless ($branch_rs->count) { - $copyBranch = Koha::Libraries->next->branchcode; + $copyBranch = $schema->resultset('DiscreteCalendar')->next->branchcode; $branch_rs = $schema->resultset('DiscreteCalendar')->search({ branchcode => $copyBranch }); -- 2.34.1