added "due_date"
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 5 Jul 2005 21:14:44 +0000 (21:14 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 5 Jul 2005 21:14:44 +0000 (21:14 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1051 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/action.pm
Open-ILS/src/sql/Postgres/090.schema.action.sql

index 07fbe71..a46f2fe 100644 (file)
@@ -101,6 +101,7 @@ sub fast_fieldmapper {
        my $id = shift;
        my $col = shift;
        my $like = shift;
+       my $options = shift;
        my $class = ref($self) || $self;
        my $fm_class = 'Fieldmapper::'.$class;
        my @fms;
@@ -121,7 +122,7 @@ sub fast_fieldmapper {
                        $search_type = 'search_regex'
                }
 
-               for my $obj ($class->$search_type({ $col => $id})) {
+               for my $obj ($class->$search_type({ $col => $id}, $options)) {
                        push @fms, $obj->to_fieldmapper;
                }
        }
@@ -301,8 +302,6 @@ sub modify_from_fieldmapper {
        
        actor::card->has_a( usr => 'actor::user' );
        
-       config::rules::age_hold_protect->has_a( radius => 'actor::org_unit_type' );
-       
        actor::org_unit->has_a( parent_ou => 'actor::org_unit' );
        actor::org_unit->has_a( ou_type => 'actor::org_unit_type' );
        #actor::org_unit->has_a( address => 'actor::org_address' );
index 9e0485e..b617d83 100644 (file)
@@ -45,7 +45,7 @@ __PACKAGE__->columns(Essential => qw/xact_start usr target_copy circ_lib
                                     duration duration_rule renewal_remaining
                                     recuring_fine_rule recuring_fine stop_fines
                                     max_fine max_fine_rule fine_interval
-                                    stop_fines xact_finish/);
+                                    stop_fines xact_finish due_date/);
 
 #-------------------------------------------------------------------------------
 
index 3b08f56..e2c7c61 100644 (file)
@@ -70,12 +70,32 @@ CREATE TABLE action.circulation (
 ) INHERITS (money.billable_xact);
 CREATE INDEX circ_open_xacts_idx ON action.circulation (usr) WHERE xact_finish IS NULL;
 
+CREATE OR REPLACE VIEW action.open_cirulations AS
+       SELECT  *
+         FROM  action.circulation
+         WHERE xact_finish IS NULL;
+
+CREATE OR REPLACE FUNCTION action.circulation_claims_returned () RETURNS TRIGGER AS $$
+BEGIN
+       IF NEW.stop_fines <> OLD.stop_fines AND NEW.stop_fines = 'CLAIMSRETURNED' THEN
+               UPDATE actor.usr SET claims_returned_count = claims_returned_count + 1 WHERE id = NEW.usr;
+       END IF;
+       RETURN NEW;
+END;
+$$ LANGUAGE 'plpgsql';
+CREATE TRIGGER action_circulation_claims_returned
+       BEFORE UPDATE ON action.circulation
+       FOR EACH ROW
+       EXECUTE PROCEDURE action.circulation_claims_returned ();
+
 
 CREATE TABLE action.hold_request (
        id                      SERIAL                          PRIMARY KEY,
        request_time            TIMESTAMP WITH TIME ZONE        NOT NULL DEFAULT NOW(),
        capture_time            TIMESTAMP WITH TIME ZONE,
        fulfillment_time        TIMESTAMP WITH TIME ZONE,
+       checkin_time            TIMESTAMP WITH TIME ZONE,
+       return_time             TIMESTAMP WITH TIME ZONE,
        prev_check_time         TIMESTAMP WITH TIME ZONE,
        expire_time             TIMESTAMP WITH TIME ZONE,
        requestor               INT                             NOT NULL REFERENCES actor.usr (id),
@@ -101,11 +121,21 @@ CREATE TABLE action.hold_notification (
 
 CREATE TABLE action.hold_copy_map (
        id              SERIAL  PRIMARY KEY,
-       hold            INT     NOT NULL REFERENCES action.hold_notification (id) ON DELETE CASCADE,
+       hold            INT     NOT NULL REFERENCES action.hold_request (id) ON DELETE CASCADE,
        target_copy     BIGINT  NOT NULL REFERENCES asset.copy (id) ON DELETE CASCADE,
-       CONSTRAINT copy_once_per_hold UNIQUE (hold,copy)
+       CONSTRAINT copy_once_per_hold UNIQUE (hold,target_copy)
 );
 
+CREATE TABLE action.hold_transit_copy (
+       id                      SERIAL                          PRIMARY KEY,
+       hold                    INT                             NOT NULL REFERENCES action.hold_request (id),
+       source                  INT                             NOT NULL REFERENCES actor.org_unit (id),
+       dest                    INT                             NOT NULL REFERENCES actor.org_unit (id),
+       persistant_transfer     BOOL                            NOT NULL DEFAULT FALSE,
+       source_send_time        TIMESTAMP WITH TIME ZONE,
+       dest_recv_time          TIMESTAMP WITH TIME ZONE,
+       prev_hop                INT                             REFERENCES action.hold_transit_copy (id)
+);
 
 COMMIT;