Use current fiscal year for PO creation (API)
authorBill Erickson <berick@esilibrary.com>
Wed, 5 Sep 2012 18:39:36 +0000 (14:39 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 11 Oct 2012 17:29:00 +0000 (13:29 -0400)
When creating a PO, if no fiscal_year is specified by the caller, use
the current fiscal year of the ordering agency.  This change primarily
affects the Open-ILS/src/support-scripts/acq_order_reader.pl script (and
any other direct API callers) which does not offer the user a chance to
set the fiscal year manually.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm

index 585bca0..a5f5bfe 100644 (file)
@@ -1371,7 +1371,17 @@ sub upload_records {
     my $activate_po     = $args->{activate_po};
     my $vandelay        = $args->{vandelay};
     my $ordering_agency = $args->{ordering_agency} || $e->requestor->ws_ou;
-    my $fiscal_year     = $args->{fiscal_year} || DateTime->now->year;
+    my $fiscal_year     = $args->{fiscal_year};
+
+    # if the user provides no fiscal year, find the
+    # current fiscal year for the ordering agency.
+    $fiscal_year ||= $U->simplereq(
+        'open-ils.acq',
+        'open-ils.acq.org_unit.current_fiscal_year',
+        $auth,
+        $ordering_agency
+    );
+
     my $po;
     my $evt;