LP1170795: Void deposits on checkin
authorJason Boyer <jboyer@equinoxinitiative.org>
Wed, 11 Sep 2019 15:59:40 +0000 (11:59 -0400)
committerTerran McCanna <tmccanna@georgialibraries.org>
Thu, 12 Aug 2021 18:22:49 +0000 (14:22 -0400)
Refactor the original patch

Signed-off-by: Jason Boyer <jboyer@equinoxinitiative.org>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.LP1170795_Deposit_refunds_not_applying_as_expected_on_item_check_in.sql [deleted file]
Open-ILS/src/sql/Pg/upgrade/XXXX.data.void_deposit_on_checkin.sql [new file with mode: 0755]

index 6041734..40fe4b0 100644 (file)
@@ -3046,31 +3046,31 @@ sub finish_fines_and_voiding {
 }
 
 
-# if a deposit was payed for this item, push the event
-# handle deposit billing void
+# if a deposit was paid for this item, push the event
+# if called with a truthy param perform the void, depending on settings
 sub check_circ_deposit {
     my $self = shift;
     my $void = shift;
+
     return unless $self->circ;
+
     my $deposit = $self->editor->search_money_billing(
         {   btype => 5, 
             xact => $self->circ->id, 
             voided => 'f'
         }, {idlist => 1})->[0];
 
-    if ($deposit) {
-        # We have already vetted the override event when $void is set
-        $self->push_events(OpenILS::Event->new('ITEM_DEPOSIT_PAID', payload => $deposit)) if !$void;
-        # Now do the voiding when the library setting is set
-        if ( $U->ou_ancestor_setting_value(
-             $self->circ_lib,
-             OILS_SETTING_VOID_ITEM_DEPOSIT_ON_CHECKIN,
-             $self->editor) && $void
-            ) {
-            my $circ_money = OpenSRF::AppSession->connect("open-ils.circ");
-            $circ_money->request('open-ils.circ.money.billing.void', $self->editor->authtoken, $deposit );
-            undef $circ_money;
+    return unless $deposit;
+
+    if ($void) {
+         my $void_on_checkin = $U->ou_ancestor_setting_value(
+             $self->circ_lib,OILS_SETTING_VOID_ITEM_DEPOSIT_ON_CHECKIN,$self->editor);
+         if ( $void_on_checkin ) {
+            my $evt = $CC->void_bills($self->editor,[$deposit], "DEPOSIT ITEM RETURNED");
+            return $evt if $evt;
         }
+    } else { # if void is unset this is just a check, notify that there was a deposit billing
+        $self->push_events(OpenILS::Event->new('ITEM_DEPOSIT_PAID', payload => $deposit));
     }
 }
 
index 90f99ab..60279c5 100644 (file)
@@ -4223,10 +4223,10 @@ INSERT into config.org_unit_setting_type
 
 ,( 'circ.void_item_deposit', 'circ',
     oils_i18n_gettext('circ.void_item_deposit',
-        'Void item depsoit fee upon checkin',
+        'Void item deposit fee on checkin',
         'coust', 'label'),
     oils_i18n_gettext('circ.void_item_deposit',
-        'This will cause the deposit fee to be voided upon checkin',
+        'If a deposit was charged when checking out an item, void it when the item is returned',
         'coust', 'description'),
     'bool', null)
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.LP1170795_Deposit_refunds_not_applying_as_expected_on_item_check_in.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.LP1170795_Deposit_refunds_not_applying_as_expected_on_item_check_in.sql
deleted file mode 100755 (executable)
index 11eb4c8..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-
-BEGIN;
-
-
-INSERT into config.org_unit_setting_type
-( name, grp, label, description, datatype, fm_class ) VALUES
-
-( 'circ.void_item_deposit', 'circ',
-    oils_i18n_gettext('circ.void_item_deposit',
-        'Void item depsoit fee upon checkin',
-        'coust', 'label'),
-    oils_i18n_gettext('circ.void_item_deposit',
-        'This will cause the deposit fee to be voided upon checkin',
-        'coust', 'description'),
-    'bool', null);
-    
-COMMIT;
\ No newline at end of file
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.void_deposit_on_checkin.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.void_deposit_on_checkin.sql
new file mode 100755 (executable)
index 0000000..d9329bf
--- /dev/null
@@ -0,0 +1,17 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); -- blake / jboyer
+
+INSERT INTO config.org_unit_setting_type
+( name, grp, label, description, datatype, fm_class ) VALUES
+( 'circ.void_item_deposit', 'circ',
+    oils_i18n_gettext('circ.void_item_deposit',
+        'Void item deposit fee on checkin',
+        'coust', 'label'),
+    oils_i18n_gettext('circ.void_item_deposit',
+        'If a deposit was charged when checking out an item, void it when the item is returned',
+        'coust', 'description'),
+    'bool', null);
+
+COMMIT;
+