[open-ils-commits] r14544 - in trunk/Open-ILS/src: perlmods/OpenILS/Application/Circ sql/Pg sql/Pg/upgrade (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Oct 21 16:54:20 EDT 2009
Author: erickson
Date: 2009-10-21 16:54:14 -0400 (Wed, 21 Oct 2009)
New Revision: 14544
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0047.schema.claims-never-checkout-trigger.sql
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
Log:
instead of manually updating the claims-never-checked-out counter, use the existing claims returned trigger to manage that
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm 2009-10-21 20:39:24 UTC (rev 14543)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm 2009-10-21 20:54:14 UTC (rev 14544)
@@ -2289,18 +2289,8 @@
my $evt;
my $obt;
- if($self->claims_never_checked_out) {
+ $self->backdate($circ->xact_start) if $self->claims_never_checked_out;
- # backdate to void any fines accrued on the circ
- $self->backdate($circ->xact_start);
-
- # update the patrons never-checked-out count
- $self->patron->claims_never_checked_out_count(
- $self->patron->claims_never_checked_out_count + 1);
- $self->editor->update_actor_user($self->patron) or
- $self->bail_on_events($self->editor->event);
- }
-
# backdate the circ if necessary
if($self->backdate) {
$self->checkin_handle_backdate;
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-10-21 20:39:24 UTC (rev 14543)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-10-21 20:54:14 UTC (rev 14544)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0046'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0047'); -- berick
CREATE TABLE config.bib_source (
Modified: trunk/Open-ILS/src/sql/Pg/090.schema.action.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/090.schema.action.sql 2009-10-21 20:39:24 UTC (rev 14543)
+++ trunk/Open-ILS/src/sql/Pg/090.schema.action.sql 2009-10-21 20:54:14 UTC (rev 14544)
@@ -298,6 +298,9 @@
IF NEW.stop_fines = 'CLAIMSRETURNED' THEN
UPDATE actor.usr SET claims_returned_count = claims_returned_count + 1 WHERE id = NEW.usr;
END IF;
+ IF NEW.stop_fines = 'CLAIMSNEVERCHECKEDOUT' THEN
+ UPDATE actor.usr SET claims_never_checked_out_count = claims_never_checked_out_count + 1 WHERE id = NEW.usr;
+ END IF;
IF NEW.stop_fines = 'LOST' THEN
UPDATE asset.copy SET status = 3 WHERE id = NEW.target_copy;
END IF;
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0047.schema.claims-never-checkout-trigger.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0047.schema.claims-never-checkout-trigger.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0047.schema.claims-never-checkout-trigger.sql 2009-10-21 20:54:14 UTC (rev 14544)
@@ -0,0 +1,23 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0047');
+
+CREATE OR REPLACE FUNCTION action.circulation_claims_returned () RETURNS TRIGGER AS $$
+BEGIN
+ IF OLD.stop_fines IS NULL OR OLD.stop_fines <> NEW.stop_fines THEN
+ IF NEW.stop_fines = 'CLAIMSRETURNED' THEN
+ UPDATE actor.usr SET claims_returned_count = claims_returned_count + 1 WHERE id = NEW.usr;
+ END IF;
+ IF NEW.stop_fines = 'CLAIMSNEVERCHECKEDOUT' THEN
+ UPDATE actor.usr SET claims_never_checked_out_count = claims_never_checked_out_count + 1 WHERE id = NEW.usr;
+ END IF;
+ IF NEW.stop_fines = 'LOST' THEN
+ UPDATE asset.copy SET status = 3 WHERE id = NEW.target_copy;
+ END IF;
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE 'plpgsql';
+
+COMMIT;
+
More information about the open-ils-commits
mailing list