Bug 38254 - Patron auto-complete search explodes when dateexpiry is NULL
Summary: Patron auto-complete search explodes when dateexpiry is NULL
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords: RM_priority
Depends on:
Blocks:
 
Reported: 2024-10-24 09:13 UTC by Katrin Fischer
Modified: 2024-10-24 09:16 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2024-10-24 09:13:52 UTC
This was moved from bug 31143:

> We either need to fix the auto-complete patron search or have the 
> script re-calculate the dateexpiry from the patron category. I am 
> leaning towards making the patron search deal with NULL.

borrowers.dateexpiry can be NULL so the code needs to be fixed.

I have not tried it but this would be the idea:

iff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js
b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js
index 73a4a0251e1..28060fb35da 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js
@@ -694,10 +694,13 @@ function patron_autocomplete(node, options) {
         }
         let new_date = new Date();
         let today = Date.parse($date_to_rfc3339($date(new_date.toString())));
-        let expiration = Date.parse(
-            $date_to_rfc3339($date(item.expiry_date.toString()))
-        );
-        let expired = today > expiration;
+        let expired = false;
+        if (item.expiry_date){
+            let expiration = Date.parse(
+                $date_to_rfc3339($date(item.expiry_date.toString()))
+            );
+            expired = today > expiration;
+        }
         return $("<li></li>")
             .addClass(loggedInClass)
             .data("ui-autocomplete-item", item)