We need to set items which were overdue long overdue to lost and didn't find a way to do it with out using A/T, we are still looking into that for the future. In the meanwhile I've attached patches for trunk and rel_1_6_1, if the core devs think it's a useful addition to trunk and/or 1_6_1 please commit. Also attached is the script that calls the new method and which we will run as a cron job.

I can see a scenario where libraries use the LONGOVERDUE status for say fines and don't want those to be updated unless they were LONGOVERDUE for an extra interval, in that case this code should not be used. It requires a different logic which I have not implemented.

Cheers

--
- - - - - - - - - - - - - - - - - - - - - - - - -
Anoop Atre
IS Developer & Integrator, MnPALS
PH: 507.389.5060
OF: 3022 Memorial Library (Office-ML 3022)
--
"Mit der Dummheit kämpfen Götter selbst vergebens"
 ~ Johann Christoph Friedrich von Schiller

Attachment: mark-lost-update.pl
Description: Perl program

Index: trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm	(revision 19533)
+++ trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm	(working copy)
@@ -239,6 +239,46 @@
 	method          => 'mark_longoverdue',
 );
 
+sub mark_lost {
+        my $self = shift;
+        my $client = shift;
+        my $window = shift;
+
+        local $OpenILS::Application::Storage::WRITE = 1;
+
+        throw OpenSRF::EX::InvalidArg ("I need an interval of more than 0 seconds!")
+                unless (interval_to_seconds( $window ));
+
+        my $setting = actor::org_unit_setting->table;
+        my $circ = action::circulation->table;
+
+        my $sql = <<"    SQL";
+                UPDATE  $circ
+                  SET   stop_fines = 'LOST',
+                        stop_fines_time = now()
+                  WHERE id IN (
+                    SELECT  circ.id
+                      FROM  $circ circ
+                            LEFT JOIN $setting setting
+                                ON (circ.circ_lib = setting.org_unit AND setting.name = 'circ.lost.interval')
+                      WHERE circ.checkin_time IS NULL AND (stop_fines IS NULL OR stop_fines != 'LOST')
+                            AND AGE(circ.due_date) > CAST( COALESCE( BTRIM( setting.value,'"' ), ? )  AS INTERVAL)
+                  )
+    SQL
+
+        my $sth = action::circulation->db_Main->prepare_cached($sql);
+        $sth->execute($window);
+
+        return $sth->rows;
+
+}
+__PACKAGE__->register_method(
+        api_name        => 'open-ils.storage.action.circulation.status_mark_lost',
+        api_level       => 1,
+        argc            => 1,
+        method          => 'mark_lost',
+);
+
 sub auto_thaw_frozen_holds {
 	my $self = shift;
 	my $client = shift;
Index: rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	(revision 19533)
+++ rel_1_6_1/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	(working copy)
@@ -235,6 +235,46 @@
 	method          => 'mark_longoverdue',
 );
 
+sub mark_lost {
+        my $self = shift;
+        my $client = shift;
+        my $window = shift;
+
+        local $OpenILS::Application::Storage::WRITE = 1;
+
+        throw OpenSRF::EX::InvalidArg ("I need an interval of more than 0 seconds!")
+                unless (interval_to_seconds( $window ));
+
+        my $setting = actor::org_unit_setting->table;
+        my $circ = action::circulation->table;
+
+        my $sql = <<"    SQL";
+                UPDATE  $circ
+                  SET   stop_fines = 'LOST',
+                        stop_fines_time = now()
+                  WHERE id IN (
+                    SELECT  circ.id
+                      FROM  $circ circ
+                            LEFT JOIN $setting setting
+                                ON (circ.circ_lib = setting.org_unit AND setting.name = 'circ.lost.interval')
+                      WHERE circ.checkin_time IS NULL AND (stop_fines IS NULL OR stop_fines != 'LOST')
+                            AND AGE(circ.due_date) > CAST( COALESCE( BTRIM( setting.value,'"' ), ? )  AS INTERVAL)
+                  )
+    SQL
+
+        my $sth = action::circulation->db_Main->prepare_cached($sql);
+        $sth->execute($window);
+
+        return $sth->rows;
+
+}
+__PACKAGE__->register_method(
+        api_name        => 'open-ils.storage.action.circulation.status_mark_lost',
+        api_level       => 1,
+        argc            => 1,
+        method          => 'mark_lost',
+);
+
 sub auto_thaw_frozen_holds {
 	my $self = shift;
 	my $client = shift;
Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

Signed-off-by: Michael Peters <[email protected]>

Reply via email to