From 8b153a71a03927b7f9b6b1bfcbcfefb92795ab2a Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 18 Feb 2022 12:01:23 -0500 Subject: [PATCH] LP1904036 Patron expire status color fix Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../src/app/staff/circ/patron/resolver.service.ts | 3 +- .../src/app/staff/share/patron/patron.service.ts | 76 ++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts index ec6f987f73..8c2ffcd22b 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts @@ -130,7 +130,8 @@ export class PatronResolver implements Resolve> { '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(); diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts index 7846f9e97e..fbf075a7e9 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts @@ -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'; + } } -- 2.11.0