LP1904036 Patron expire status color fix
authorBill Erickson <berickxx@gmail.com>
Fri, 18 Feb 2022 17:01:23 +0000 (12:01 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:41 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts
Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts

index ec6f987..8c2ffcd 100644 (file)
@@ -130,7 +130,8 @@ export class PatronResolver implements Resolve<Promise<any[]>> {
           'ui.patron.edit.aua.state.suggest',
           'ui.patron.edit.aua.state.show',
           'ui.admin.work_log.max_entries',
-          'ui.admin.patron_log.max_entries'
+          'ui.admin.patron_log.max_entries',
+          'circ.patron_expires_soon_warning'
         ]).then(settings => {
             this.context.settingsCache = settings;
             return this.circ.applySettings();
index 7846f9e..fbf075a 100644 (file)
@@ -351,5 +351,81 @@ export class PatronService {
             return alerts;
         });
     }
+
+    patronStatusColor(patron: IdlObject, summary: PatronSummary): string {
+
+        if (patron.barred() === 't') {
+            return 'PATRON_BARRED';
+        }
+
+        if (patron.active() === 'f') {
+            return 'PATRON_INACTIVE';
+        }
+
+        if (summary.stats.fines.balance_owed > 0) {
+           return 'PATRON_HAS_BILLS';
+        }
+
+        if (summary.stats.checkouts.overdue > 0) {
+            return 'PATRON_HAS_OVERDUES';
+        }
+
+        if (summary.alerts.accountExpired || summary.alerts.accountExpiresSoon) {
+          return 'PATRON_EXPIRED';
+        }
+
+        if (patron.notes().length > 0) {
+            return 'PATRON_HAS_NOTES';
+        }
+
+        if (summary.stats.checkouts.lost > 0) {
+            return 'PATRON_HAS_LOST';
+        }
+
+        let penalty: string;
+        let penaltyCount = 0;
+
+        patron.standing_penalties().some(p => {
+
+            if (p.standing_penalty().staff_alert() === 't' ||
+                p.standing_penalty().block_list()) {
+                penalty = 'PATRON_HAS_STAFF_ALERT';
+                return true;
+            }
+
+            if (p.standing_penalty().block_list()) {
+                // Penalties without a block are just Notes
+                penaltyCount++;
+            }
+
+            const name = p.standing_penalty();
+
+            switch (name) {
+                case 'PATRON_EXCEEDS_CHECKOUT_COUNT':
+                case 'PATRON_EXCEEDS_OVERDUE_COUNT':
+                case 'PATRON_EXCEEDS_FINES':
+                    penalty = name;
+                    return true;
+            }
+        });
+
+        if (penalty) { return penalty; }
+
+        if (penaltyCount === 1) {
+            return 'ONE_PENALTY';
+        } else if (penaltyCount > 1) {
+            return 'MULTIPLE_PENALTIES';
+        }
+
+        if (patron.alert_message()) {
+            return 'PATRON_HAS_ALERT';
+        }
+
+        if (patron.juvenile() === 't') {
+            return 'PATRON_JUVENILE';
+        }
+
+        return 'NO_PENALTIES';
+    }
 }