Bug 29996

Summary: Show an alert on main page when serial issues are late
Product: Koha Reporter: Julian Maurice <julian.maurice>
Component: SerialsAssignee: Julian Maurice <julian.maurice>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: aude.charillon, david, jonathan.druart
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: Sponsored
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
This enhancement to serials adds a "Warn when late" option for a serial. If this is enabled for a serial, an alert is shown on the main page when issues are late.
Version(s) released in:
Circulation function:
Bug Depends on:    
Bug Blocks: 30095    
Attachments: Bug 29996: Show an alert on main page when serial issues are late
Bug 29996: Show an alert on main page when serial issues are late
Bug 29996: Show an alert on main page when serial issues are late
Bug 29996: Show "warn when late" on subscription-detail.pl
Bug 29996: Show an alert on main page when serial issues are late
Bug 29996: Show "warn when late" on subscription-detail.pl
Bug 29996: Show an alert on main page when serial issues are late
Bug 29996: Show an alert on main page when serial issues are late
Bug 29996: (follow-up) Show count of late issues instead of list
Bug 29996: Show an alert on main page when serial issues are late
Bug 29996: (follow-up) Show count of late issues instead of list
Bug 29996: Show an alert on main page when serial issues are late
Bug 29996: (follow-up) Show count of late issues instead of list
Bug 29996: Fix tests and add one for Koha::Serial::subscription

Description Julian Maurice 2022-02-01 15:21:58 UTC

    
Comment 1 Julian Maurice 2022-02-01 15:23:39 UTC Comment hidden (obsolete)
Comment 2 Owen Leonard 2022-05-12 13:40:26 UTC
I did some simple rebasing of this, and I don't *think* I messed it up, but I'm getting this error when I hit the main page:

The method Koha::Serials->subscriptionid is not covered by tests!

Trace begun at /kohadevbox/koha/Koha/Objects.pm line 572
Koha::Objects::AUTOLOAD('Koha::Serials=HASH(0x5608d16fa198)') called at /kohadevbox/koha/mainpage.pl line 129
eval {...} at /kohadevbox/koha/mainpage.pl line 2
Comment 3 Julian Maurice 2022-11-10 10:04:19 UTC Comment hidden (obsolete)
Comment 4 Julian Maurice 2022-11-10 10:06:31 UTC
(In reply to Owen Leonard from comment #2)
> The method Koha::Serials->subscriptionid is not covered by tests!

It was caused by the changes of bug 29844. I added the now required 'as_list' call and it works again :)
Patch rebased on master
Comment 5 Aude Charillon 2023-01-25 17:37:34 UTC
When I reach step 7 of the test plan and save my subscription after disabling "Warn when late", I get the following error:

DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Column 'warn_when_late' cannot be null at /kohadevbox/koha/Koha/Object.pm line 170
 at /usr/share/perl5/DBIx/Class/Exception.pm line 77

On another note, it would be nice to have the "Warn when late" status visible in the subscription details - either the information tab or the summary one. It would save the librarian having to edit the subscription to know whether it is already enabled or not.
Comment 6 Julian Maurice 2023-10-10 13:08:55 UTC Comment hidden (obsolete)
Comment 7 Julian Maurice 2023-10-10 13:10:21 UTC
Patch rebased on master.

I cannot reproduce the issue mentioned in comment 5. Maybe a temporary bug on master ?
Please test again.
Comment 8 Julian Maurice 2023-10-10 13:13:49 UTC Comment hidden (obsolete)
Comment 9 Owen Leonard 2023-10-11 13:36:14 UTC
Even after database update and restart_all I'm getting this error:

No property warn_when_late for Koha::Subscription at /usr/share/perl5/Exception/Class/Base.pm line 88
Comment 10 Julian Maurice 2023-10-11 13:43:39 UTC
Did you update the DBIx::Class schema files ?
Comment 11 Owen Leonard 2023-10-11 14:18:59 UTC
(In reply to Julian Maurice from comment #10)
> Did you update the DBIx::Class schema files ?

I did but I neglected to restart after that!
Comment 12 Owen Leonard 2023-10-11 14:35:43 UTC
Now it's working if I save after checking the "warn when late" box but if I save a subscription with the box unchecked I get this error:

DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Column 'warn_when_late' cannot be null at /kohadevbox/koha/Koha/Object.pm line 170
 at /usr/share/perl5/DBIx/Class/Exception.pm line 77
Comment 13 Julian Maurice 2023-10-11 15:04:49 UTC
That's weird. I cannot reproduce that error... Any idea where it could come from ?
Comment 14 Julian Maurice 2024-12-12 08:49:35 UTC Comment hidden (obsolete)
Comment 15 Julian Maurice 2024-12-12 08:49:38 UTC Comment hidden (obsolete)
Comment 16 Julian Maurice 2024-12-12 09:01:31 UTC Comment hidden (obsolete)
Comment 17 Julian Maurice 2024-12-12 09:05:48 UTC
Patches rebased and squashed.

(In reply to Owen Leonard from comment #12)
> Now it's working if I save after checking the "warn when late" box but if I
> save a subscription with the box unchecked I get this error:
> 
> DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st
> execute failed: Column 'warn_when_late' cannot be null at
> /kohadevbox/koha/Koha/Object.pm line 170
>  at /usr/share/perl5/DBIx/Class/Exception.pm line 77

This should be fixed now
Comment 18 Owen Leonard 2024-12-13 19:32:58 UTC
Created attachment 175467 [details] [review]
Bug 29996: Show an alert on main page when serial issues are late

The alert is disabled by default and can be enabled for each
subscription individually.
Alerts are shown on the main page only for subscriptions that have this
feature enabled and that are of the same library than the connection
library

Test plan:
1. Run `installer/data/mysql/updatedatabase.pl` and
   `misc/devel/update_dbix_class_files.pl --koha-conf`. Restart Koha if
   needed.
2. Create a subscription, set its library to your connection library
   and enable "Warn when late"
3. Verify that you can see the value of "warn when late" setting on
   subscription-detail.pl
4. The automatically generated serial issue should have the status
   "Expected". Change it to "Late".
5. Go back to the main page. You should see an alert with a link to your
   subscription
6. Change your library using the menu in the upper right corner of the
   screen. Now the alert should not appear.
7. Set your library back to its original value to make the alert
   reappear.
8. Edit your subscription and disable "Warn when late". Verify that the
   alert does not appear.

Sponsored-by: Écoles Nationales Supérieures d'Architecture
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 19 Owen Leonard 2024-12-13 19:33:00 UTC
Created attachment 175468 [details] [review]
Bug 29996: (follow-up) Show count of late issues instead of list

This patch makes two changes:
1. Change the label to "The following serials have late issues:"
2. Show the count of late issues rather than a list of the issue
   numbers. This makes it consistent with the other types of messages
   shown in this area of the page.
Comment 20 Owen Leonard 2024-12-13 19:34:17 UTC
Julian I hope my follow-up works for you and your sponsor.
Comment 21 David Nind 2024-12-14 18:16:22 UTC
Created attachment 175474 [details] [review]
Bug 29996: Show an alert on main page when serial issues are late

The alert is disabled by default and can be enabled for each
subscription individually.
Alerts are shown on the main page only for subscriptions that have this
feature enabled and that are of the same library than the connection
library

Test plan:
1. Run `installer/data/mysql/updatedatabase.pl` and
   `misc/devel/update_dbix_class_files.pl --koha-conf`. Restart Koha if
   needed.
2. Create a subscription, set its library to your connection library
   and enable "Warn when late"
3. Verify that you can see the value of "warn when late" setting on
   subscription-detail.pl
4. The automatically generated serial issue should have the status
   "Expected". Change it to "Late".
5. Go back to the main page. You should see an alert with a link to your
   subscription
6. Change your library using the menu in the upper right corner of the
   screen. Now the alert should not appear.
7. Set your library back to its original value to make the alert
   reappear.
8. Edit your subscription and disable "Warn when late". Verify that the
   alert does not appear.

Sponsored-by: Écoles Nationales Supérieures d'Architecture
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: David Nind <david@davidnind.com>
Comment 22 David Nind 2024-12-14 18:16:25 UTC
Created attachment 175475 [details] [review]
Bug 29996: (follow-up) Show count of late issues instead of list

This patch makes two changes:
1. Change the label to "The following serials have late issues:"
2. Show the count of late issues rather than a list of the issue
   numbers. This makes it consistent with the other types of messages
   shown in this area of the page.

Signed-off-by: David Nind <david@davidnind.com>
Comment 23 David Nind 2024-12-14 18:29:19 UTC
Testing notes (using KTD):

1. Step 1: run updatedatabase, dbic, then restart_all

2. Before I could sign off, I had to do a: git checkout Koha/Schema/Result/Subscription.pm (I don't think I've had to do that in the past)
Comment 24 David Nind 2024-12-14 18:32:19 UTC
One thought I had when testing, if a library has "hundreds" of late serials, then this would overwhelm the front page alert - or make it very long.

I'm not sure how realistic this is, but maybe this could with academic libraries or public libraries with lots of magazines?

I really like this enhancement!
Comment 25 Julian Maurice 2024-12-16 07:38:56 UTC
(In reply to Owen Leonard from comment #20)
> Julian I hope my follow-up works for you and your sponsor.
I think it's okay as we can have the list of late issues by clicking on the link
Comment 26 Jonathan Druart 2025-01-16 15:16:44 UTC
Missing tests.
Comment 27 Julian Maurice 2025-06-20 11:44:52 UTC
Created attachment 183386 [details] [review]
Bug 29996: Show an alert on main page when serial issues are late

The alert is disabled by default and can be enabled for each
subscription individually.
Alerts are shown on the main page only for subscriptions that have this
feature enabled and that are of the same library than the connection
library

Test plan:
1. Run `installer/data/mysql/updatedatabase.pl` and
   `misc/devel/update_dbix_class_files.pl --koha-conf`. Restart Koha if
   needed.
2. Create a subscription, set its library to your connection library
   and enable "Warn when late"
3. Verify that you can see the value of "warn when late" setting on
   subscription-detail.pl
4. The automatically generated serial issue should have the status
   "Expected". Change it to "Late".
5. Go back to the main page. You should see an alert with a link to your
   subscription
6. Change your library using the menu in the upper right corner of the
   screen. Now the alert should not appear.
7. Set your library back to its original value to make the alert
   reappear.
8. Edit your subscription and disable "Warn when late". Verify that the
   alert does not appear.

Sponsored-by: Écoles Nationales Supérieures d'Architecture
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: David Nind <david@davidnind.com>
Comment 28 Julian Maurice 2025-06-20 11:44:54 UTC
Created attachment 183387 [details] [review]
Bug 29996: (follow-up) Show count of late issues instead of list

This patch makes two changes:
1. Change the label to "The following serials have late issues:"
2. Show the count of late issues rather than a list of the issue
   numbers. This makes it consistent with the other types of messages
   shown in this area of the page.

Signed-off-by: David Nind <david@davidnind.com>
Comment 29 Julian Maurice 2025-06-20 11:44:56 UTC
Created attachment 183388 [details] [review]
Bug 29996: Fix tests and add one for Koha::Serial::subscription