test script for printing a purchase order
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 31 Mar 2009 13:39:50 +0000 (13:39 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 31 Mar 2009 13:39:50 +0000 (13:39 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12730 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/support-scripts/test-scripts/print_po.pl [new file with mode: 0755]

diff --git a/Open-ILS/src/support-scripts/test-scripts/print_po.pl b/Open-ILS/src/support-scripts/test-scripts/print_po.pl
new file mode 100755 (executable)
index 0000000..f63c558
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+
+#----------------------------------------------------------------
+# Print PO
+#----------------------------------------------------------------
+
+require '../oils_header.pl';
+use strict; use warnings;
+my $config             = shift; 
+my $username   = shift || 'admin';
+my $password   = shift || 'open-ils';
+my $po_id       = shift;
+
+osrf_connect($config);
+oils_login($username, $password);
+my $e = OpenILS::Utils::CStoreEditor->new;
+
+my $po = $e->retrieve_acq_purchase_order(
+    [
+        $po_id,
+        {
+            flesh => 3,
+            flesh_fields => {
+                acqpo => [qw/lineitems ordering_agency provider/],
+                jub => [qw/attributes lineitem_details/],
+                acqlid => [qw/fund location/]
+            }
+        }
+    ]
+);
+
+die "No PO with id $po_id\n" unless $po;
+
+
+print 'PO ID: ' . $po->id . "\n";
+print 'Ordering Agency: ' . $po->ordering_agency->shortname . "\n";
+print 'Provider: ' . $po->provider->code . "\n";
+for my $li (@{$po->lineitems}) {
+    print "  Lineitem:------------------\n";
+    for my $li_attr (@{$li->attributes}) {
+        print "  " . $li_attr->attr_name . ': ' . $li_attr->attr_value . "\n";
+    }
+    for my $li_det (@{$li->lineitem_details}) {
+        print "    Copy----------------------\n";
+        print "    Fund: " . $li_det->fund->code . "\n";
+        print "    Location: " . $li_det->location->name . "\n";
+    }
+}