Bug 22180

Summary: SERIAL_ALERT email does not send if the status is claimed before arrived
Product: Koha Reporter: Marjorie Barry-Vila <marjorie.barry-vila>
Component: SerialsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: colin.campbell, maude.boudreau, patrick.robitaille
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Marjorie Barry-Vila 2019-01-21 20:04:42 UTC
Hi,

SERIAL_ALERT email sends itself correctly when the status of the issue changes from Expected to Arrived.
But the issues goes from Expected to Claimed and then to Arrived, the email does not send.
I also tested it with other status. Only the way Expected> Arrived works.
Is it normal?
Version tested: 18.05.04

REgards,
Marjorie
Comment 1 Marjorie Barry-Vila 2022-02-24 20:04:46 UTC
still valid in 21.05
Comment 2 Katrin Fischer 2022-06-14 08:45:41 UTC
I've just verified this on master:

Expected - Arrived - Sends email
Late - Arrived - NO email
Missing - Arrived - NO email

I believe every time an issue changes to Arrived, we should send the email. If a late issue arrives, the user should be informed, also if a missing one is found or made available.
Comment 3 Katrin Fischer 2022-06-14 09:02:39 UTC
ModSerialStatus has 2 checks:

# create new expected entry if needed (ie : was "expected" and has changed)
my $otherIssueExpected = scalar findSerialsByStatus(EXPECTED, $subscriptionid);
if ( !$otherIssueExpected && $oldstatus == EXPECTED && $status != EXPECTED ) {

And within:

if ( $subscription->{letter} && $status == ARRIVED && $oldstatus != ARRIVED ) {
 require C4::Letters;
 C4::Letters::SendAlerts( 'issue', $serialid, $subscription->{letter} );
}

I am tempted to move the second if outside of the first one that has the expected check... might do that for testing.
Comment 4 Katrin Fischer 2022-06-14 09:06:48 UTC
If I understand the code correctly:

As soon as there is another 'Expected' issue, changing any of the old issues to 'Arrived' will no longer create an email.

If you are using the cron to automatically set issues late, which always creates the next issue as well, you are possibly going to miss out on a lot of emails to patrons that they expected/have waited for.

Same if you set an issue to missing - it auto-creates the next issue, taking the changed one out of the email loop.

I'd be interested to hear if people agree that this should be changed and how it should work for older (not the currently expected) issues.