Bug 10190: (QA follow-up): fix: itiva script

The following issues were identified and resolved:

- items.itemtype does not exist -> swap to items.itype
- leftover WHERE clause still referred to overduerules -> removed
- with the join on overduerules removed there is no need to GROUP BY anymore
- Koha::CirculationRules->all -> use next() instead

Test plan (as per comment 872):
A) In KTD, set 'TalkingTechItivaPhoneNotification' to 'On'.
B) Run perl misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl --type=OVERDUE -o /tmp/out.txt -v
C) No errors / the script does not die mid run.

Quick disclaimer: I am not overly familiar with that script:
while I did remove the causes behind the script dying mid run,
I won't have spotted issues with expected output / outcome.

Assisted-by: Claude Opus 5 (Anthropic)
Sponsored-by: Glasgow Colleges Library Group <https://library.cityofglasgowcollege.ac.uk>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Chloé Zermatten 2026-09-03 08:32:14 +00:00 committed by Pedro Amorim
parent 14e7814c15
commit a4be8b914e
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 5 additions and 6 deletions

View File

@ -257,21 +257,20 @@ Items and holds from other libraries will still be included for the given patron
sub GetOverdueIssues {
my ($patron_branchcode) = @_;
my $patron_branchcode_filter = $patron_branchcode ? "AND borrowers.branchcode = '$patron_branchcode'" : q{};
my $patron_branchcode_filter = $patron_branchcode ? "WHERE borrowers.branchcode = '$patron_branchcode'" : q{};
# get one distinct item (issue.itemnumber is a unique key) with m:1 issues -> one distinct issue per row
my $query =
"SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname,
borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due,
TO_DAYS(NOW())-TO_DAYS(date_due) as daysoverdue, borrowers.categorycode as categorycode, items.itemtype as itemtype,
TO_DAYS(NOW())-TO_DAYS(date_due) as daysoverdue, borrowers.categorycode as categorycode, items.itype as itemtype,
issues.branchcode as site, branches.branchname as site_name
FROM borrowers JOIN issues USING (borrowernumber)
JOIN items USING (itemnumber)
JOIN biblio USING (biblionumber)
JOIN branches ON (issues.branchcode = branches.branchcode)
WHERE ( overduerules.branchcode = borrowers.branchcode )
$patron_branchcode_filter
GROUP BY items.itemnumber
ORDER BY items.itemtype, borrowers.categorycode, branches.branchcode
ORDER BY items.itype, borrowers.categorycode, branches.branchcode
";
my $sth = $dbh->prepare($query);
$sth->execute();
@ -279,7 +278,7 @@ sub GetOverdueIssues {
my @trigger_numbers;
my $triggers = Koha::CirculationRules->search(
{ rule_name => { 'like' => 'overdue_%_mtt' }, rule_value => { like => '%itiva%' } } );
for my $trigger ( $triggers->all ) {
while ( my $trigger = $triggers->next ) {
my $trigger_number = $trigger->rule_name;
$trigger_number =~ s/(.*)(\d+)(.*)/$2/;
push @trigger_numbers, $trigger_number unless grep { $_ == $trigger_number } @trigger_numbers;