Added org setting for overriding the circ lib when creating a new pre-cat copy. ...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 17 Sep 2009 20:03:30 +0000 (20:03 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 17 Sep 2009 20:03:30 +0000 (20:03 +0000)
route all pre-cat copies to a different branch at post-circ checkin time.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@14044 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/0004.data.org-setting-precat-circ-lib.sql [new file with mode: 0644]

index 886d6b4..b86c330 100644 (file)
@@ -1603,22 +1603,40 @@ sub make_precat_copy {
         return;
    }
 
-   $logger->info("circulator: Creating a new precataloged ".
+    $logger->info("circulator: Creating a new precataloged ".
         "copy in checkout with barcode " . $self->copy_barcode);
 
-   $copy = Fieldmapper::asset::copy->new;
-   $copy->circ_lib($self->circ_lib);
-   $copy->creator($self->editor->requestor->id);
-   $copy->editor($self->editor->requestor->id);
-   $copy->barcode($self->copy_barcode);
-   $copy->call_number(OILS_PRECAT_CALL_NUMBER); 
-   $copy->loan_duration(OILS_PRECAT_COPY_LOAN_DURATION);
-   $copy->fine_level(OILS_PRECAT_COPY_FINE_LEVEL);
+    $copy = Fieldmapper::asset::copy->new;
+    $copy->circ_lib($self->circ_lib);
+    $copy->creator($self->editor->requestor->id);
+    $copy->editor($self->editor->requestor->id);
+    $copy->barcode($self->copy_barcode);
+    $copy->call_number(OILS_PRECAT_CALL_NUMBER); 
+    $copy->loan_duration(OILS_PRECAT_COPY_LOAN_DURATION);
+    $copy->fine_level(OILS_PRECAT_COPY_FINE_LEVEL);
+
+    $copy->dummy_title($self->dummy_title || "");
+    $copy->dummy_author($self->dummy_author || "");
+    $copy->dummy_isbn($self->dummy_isbn || "");
+    $copy->circ_modifier($self->circ_modifier);
+
+
+    # See if we need to override the circ_lib for the copy with a configured circ_lib
+    # Setting is shortname of the org unit
+    my $precat_circ_lib = $U->ou_ancestor_setting_value(
+        $self->circ_lib, 'circ.pre_cat_copy_circ_lib', $self->editor);
+
+    if($precat_circ_lib) {
+        my $org = $self->editor->search_actor_org_unit({shortname => $precat_circ_lib})->[0];
+
+        if(!$org) {
+            $self->bail_on_events($self->editor->event);
+            return;
+        }
+
+        $copy->circ_lib($org->id);
+    }
 
-   $copy->dummy_title($self->dummy_title || "");
-   $copy->dummy_author($self->dummy_author || "");
-   $copy->dummy_isbn($self->dummy_isbn || "");
-   $copy->circ_modifier($self->circ_modifier);
 
     unless( $self->copy($self->editor->create_asset_copy($copy)) ) {
         $self->bail_out(1);
@@ -1928,7 +1946,7 @@ sub checkin_handle_precat {
    my $copy    = $self->copy;
 
    if( $self->is_precat and ($copy->status != OILS_COPY_STATUS_CATALOGING) ) {
-      $copy->status(OILS_COPY_STATUS_CATALOGING);
+        $copy->status(OILS_COPY_STATUS_CATALOGING);
         $self->update_copy();
         $self->checkin_changed(1);
         $self->push_events(OpenILS::Event->new('ITEM_NOT_CATALOGED'));
index 383831b..4e78079 100644 (file)
@@ -2184,3 +2184,13 @@ INSERT INTO config.org_unit_setting_type (name, label, description, datatype) VA
     'integer'
 );
 
+
+-- Org setting for overriding the circ lib of a precat copy
+INSERT INTO config.org_unit_setting_type (name, label, description, datatype) VALUES (
+    'circ.pre_cat_copy_circ_lib',
+    'Pre-cat Item Circ Lib',
+    'Override the default circ lib of "here" with a pre-configured circ lib for pre-cat items.  The value should be the "shortname" (aka policy name) of the org unit',
+    'string'
+);
+
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/0004.data.org-setting-precat-circ-lib.sql b/Open-ILS/src/sql/Pg/upgrade/0004.data.org-setting-precat-circ-lib.sql
new file mode 100644 (file)
index 0000000..ff678b0
--- /dev/null
@@ -0,0 +1,13 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0004.data.org-setting-precat-circ-lib.sql');
+
+INSERT INTO config.org_unit_setting_type (name, label, description, datatype) VALUES (
+    'circ.pre_cat_copy_circ_lib',
+    'Pre-cat Item Circ Lib',
+    'Override the default circ lib of "here" with a pre-configured circ lib for pre-cat items.  The value should be the "shortname" (aka policy name) of the org unit',
+    'string'
+);
+
+COMMIT;
+