added method to return the context org for a given transaction id
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 24 Nov 2008 15:12:44 +0000 (15:12 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 24 Nov 2008 15:12:44 +0000 (15:12 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11318 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm

index d3e4f3c..a8b9fa7 100644 (file)
@@ -1569,5 +1569,27 @@ sub get_copy_price {
        return 0;
 }
 
+# given a transaction ID, this returns the context org_unit for the transaction
+sub xact_org {
+    my($self, $xact_id, $e) = @_;
+    $e ||= new_editor();
+    
+    my $loc = $e->json_query({
+        "select" => {circ => ["circ_lib"]},
+        from     => "circ",
+        "where"  => {id => $xact_id},
+    });
+
+    return $loc->[0]->{circ_lib} if @$loc;
+
+    $loc = $e->json_query({
+        "select" => {mg => ["billing_location"]},
+        from     => "mg",
+        "where"  => {id => $xact_id},
+    });
+
+    return $loc->[0]->{billing_location};
+}
+
 1;