From 805c8bee83fb1b384e6f8625f21aa0686da0368e Mon Sep 17 00:00:00 2001
From: Cesar Velez <cesar.velez@equinoxinitiative.org>
Date: Fri, 8 Dec 2017 13:50:38 -0500
Subject: [PATCH] LP#1732275: Patron Itemsout Notices - Add YAOUS for pre-due
 notices

Adding library permission 'webstaff.circ.itemsout_notice_count_excludes_courtesies'
so that pre-due/courtesy events aren't included in the notices count.

Signed-off-by: Cesar Velez <cesar.velez@equinoxinitiative.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
---
 Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
index 84b328e47b..e62982e79f 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
@@ -3665,6 +3665,8 @@ sub get_itemsout_notices{
     # where hook = 'checkout.due' AND state = 'complete' and target = <circId>;
     #
 
+    my $ctx_loc = $e->requestor->ws_ou;
+    my $exclude_courtesy_notices = $U->ou_ancestor_setting_value($ctx_loc, 'webstaff.circ.itemsout_notice_count_excludes_courtesies');
     my $query = {
 	    select => { atev => ["complete_time"] },
 	    from => {
@@ -3675,6 +3677,10 @@ sub get_itemsout_notices{
 	    where => {"+ath" => { key => "checkout.due" },"+atevdef" => { active => 't' },"+atev" => { target => $circId, state => 'complete' }}
     };
 
+    if ($exclude_courtesy_notices){
+        $query->{"where"}->{"+atevdef"}->{validator} = { "<>" => "CircIsOpen"};
+    }
+
     my %resblob = ( numNotices => 0, lastDt => undef );
 
     my $res = $e->json_query($query);
-- 
2.11.0