instead of manually updating the claims-never-checked-out counter, use the existing...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 21 Oct 2009 20:54:14 +0000 (20:54 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 21 Oct 2009 20:54:14 +0000 (20:54 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14544 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/090.schema.action.sql
Open-ILS/src/sql/Pg/upgrade/0047.schema.claims-never-checkout-trigger.sql [new file with mode: 0644]

index 89581e9..d85af22 100644 (file)
@@ -2289,17 +2289,7 @@ sub checkin_handle_circ {
    my $evt;
    my $obt;
 
-    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);
-    }
+   $self->backdate($circ->xact_start) if $self->claims_never_checked_out;
 
    # backdate the circ if necessary
    if($self->backdate) {
index 62863bd..ab9679c 100644 (file)
@@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log (
     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 (
index 89fd9f5..91bd55f 100644 (file)
@@ -298,6 +298,9 @@ BEGIN
                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;
diff --git a/Open-ILS/src/sql/Pg/upgrade/0047.schema.claims-never-checkout-trigger.sql b/Open-ILS/src/sql/Pg/upgrade/0047.schema.claims-never-checkout-trigger.sql
new file mode 100644 (file)
index 0000000..443c01d
--- /dev/null
@@ -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;
+