[open-ils-commits] [GIT] Evergreen ILS branch rel_2_2 updated. addef21ade78b1abc52e8ced611b1c162c7c2d65

Evergreen Git git at git.evergreen-ils.org
Tue Aug 14 16:33:01 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_2 has been updated
       via  addef21ade78b1abc52e8ced611b1c162c7c2d65 (commit)
       via  a242871dcb6d4c9e7c4630305a40ffb1be218cc3 (commit)
       via  c997cba9081b07db3779c84ab6b11baae789cfff (commit)
      from  8ab1bd5f05da9dd91a94ad3c1b7f1acf9303496e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit addef21ade78b1abc52e8ced611b1c162c7c2d65
Author: Bill Erickson <berick at esilibrary.com>
Date:   Fri Aug 10 14:59:50 2012 -0400

    Default to current fiscal year in ACQ order upload
    
    * Adds a new API call to determine the current fiscal year for a given
      org unit:  open-ils.acq.org_unit.current_fiscal_year
    
    * Use open-ils.acq.org_unit.current_fiscal_year to populate the correct
      fiscal year in the ACQ order upload selector.
    
    This addresses part 2 of LP 1031927
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Financials.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Financials.pm
index 57eb88c..c33bddf 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Financials.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Financials.pm
@@ -1351,6 +1351,43 @@ sub process_fiscal_rollover {
     return undef;
 }
 
+__PACKAGE__->register_method(
+	method => 'org_fiscal_year',
+	api_name	=> 'open-ils.acq.org_unit.current_fiscal_year',
+	signature => {
+        desc => q/
+            Returns the current fiscal year for the given org unit.
+            If no fiscal year is configured, the current calendar
+            year is returned.
+        /,
+        params => [
+            {desc => 'Authentication token', type => 'string'},
+            {desc => 'Org unit ID', type => 'number'}
+        ],
+        return => {desc => 'Year as a string (e.g. "2012")'}
+    }
+);
+
+sub org_fiscal_year {
+    my($self, $conn, $auth, $org_id) = @_;
+
+    my $e = new_editor(authtoken => $auth);
+    return $e->event unless $e->checkauth;
+
+    my $year = $e->json_query({
+        select => {acqfy => ['year']},
+        from => {acqfy => {acqfc => {join => 'aou'}}},
+        where => {
+            '+acqfy' => {
+                year_begin => {'<=' => 'now'},
+                year_end => {'>=' => 'now'},
+            },
+            '+aou' => {id => $org_id}
+        }
+    })->[0];
+
+    return $year ? $year->{year} : DateTime->now->year;
+}
 
 1;
 
diff --git a/Open-ILS/web/js/ui/default/acq/picklist/upload.js b/Open-ILS/web/js/ui/default/acq/picklist/upload.js
index 1361685..1eb2933 100644
--- a/Open-ILS/web/js/ui/default/acq/picklist/upload.js
+++ b/Open-ILS/web/js/ui/default/acq/picklist/upload.js
@@ -39,7 +39,10 @@ function init() {
         orgLimitPerms : ['CREATE_PICKLIST', 'CREATE_PURCHASE_ORDER'],
         parentNode : dojo.byId('acq-pl-upload-agency'),
     }).build(
-        function(w) { orderAgencyWidget = w }
+        function(w) { 
+            orderAgencyWidget = w 
+            dojo.connect(orderAgencyWidget, 'onChange', setDefaultFiscalYear);
+        }
     );
 
     vlAgent = new VLAgent();
@@ -58,6 +61,24 @@ function init() {
     );
 }
 
+function setDefaultFiscalYear(org) {
+    org = org || orderAgencyWidget.attr('value');
+
+    if (org) {
+
+        fieldmapper.standardRequest(
+            ['open-ils.acq', 'open-ils.acq.org_unit.current_fiscal_year'],
+            {   params : [openils.User.authtoken, org],
+                async : true,
+                oncomplete : function(r) {
+                    var year = openils.Util.readResponse(r);
+                    acqUploadYearSelector.attr('value', year);
+                }
+            }
+        );
+    }
+}
+
 function acqUploadRecords() {
     openils.Util.show('acq-pl-upload-progress');
     var picklist = acqPlUploadPlSelector.attr('value');
@@ -180,9 +201,9 @@ function loadYearSelector() {
                 yearStore.items = yearStore.items.sort().reverse();
                 acqUploadYearSelector.store = new dojo.data.ItemFileReadStore({data:yearStore});
 
-                // default to this year
-                // TODO: current fiscal year
-                acqUploadYearSelector.setValue(new Date().getFullYear().toString());
+                // until an ordering agency is selected, default to the 
+                // fiscal year of the workstation
+                setDefaultFiscalYear(new openils.User().user.ws_ou());
             }
         }
     );

commit a242871dcb6d4c9e7c4630305a40ffb1be218cc3
Author: Bill Erickson <berick at esilibrary.com>
Date:   Fri Aug 10 14:59:29 2012 -0400

    Enable pcrud access to fiscal year / fiscal calendar
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml
index e19d4b3..d388b86 100644
--- a/Open-ILS/examples/fm_IDL.xml
+++ b/Open-ILS/examples/fm_IDL.xml
@@ -6677,7 +6677,7 @@ SELECT  usr,
 		</links>
 	</class>
 
-	<class id="acqfc" controller="open-ils.cstore" oils_obj:fieldmapper="acq::fiscal_calendar" oils_persist:tablename="acq.fiscal_calendar" reporter:label="Fiscal Calendar">
+	<class id="acqfc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::fiscal_calendar" oils_persist:tablename="acq.fiscal_calendar" reporter:label="Fiscal Calendar">
 		<fields oils_persist:primary="id" oils_persist:sequence="acq.fiscal_calendar_id_seq">
 			<field reporter:label="Fiscal Calendar ID" name="id" reporter:datatype="id" reporter:selector='name'/>
 			<field reporter:label="Fiscal Calendar Name" name="name" reporter:datatype="text"/>
@@ -6686,21 +6686,17 @@ SELECT  usr,
 		<links>
             <link field="years" reltype="has_many" map="" key="calendar" class="acqfy"/>
 		</links>
-		<!--
-			For now, we don't have pcrud as one of the controllers, so the permacrud section is moot.
-			But here's what it should look like if we ever do use pcrud.
-		-->
 		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
 			<actions>
 				<create permission="ADMIN_ACQ_FISCAL_YEAR" global_required="true"/>
-				<retrieve permission="ADMIN_ACQ_FISCAL_YEAR" global_required="true"/>
+				<retrieve permission="STAFF_LOGIN" global_required="true"/>
 				<update permission="ADMIN_ACQ_FISCAL_YEAR" global_required="true"/>
 				<delete permission="ADMIN_ACQ_FISCAL_YEAR" global_required="true"/>
 			</actions>
 		</permacrud>
 	</class>
 
-	<class id="acqfy" controller="open-ils.cstore" oils_obj:fieldmapper="acq::fiscal_year" oils_persist:tablename="acq.fiscal_year" reporter:label="Fiscal Year">
+	<class id="acqfy" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::fiscal_year" oils_persist:tablename="acq.fiscal_year" reporter:label="Fiscal Year">
 		<fields oils_persist:primary="id" oils_persist:sequence="acq.fiscal_year_id_seq">
 			<field reporter:label="Fiscal Year ID" name="id" reporter:datatype="id" reporter:selector='year'/>
 			<field reporter:label="Calendar" name="calendar" reporter:datatype="link"/>
@@ -6711,14 +6707,10 @@ SELECT  usr,
 		<links>
 			<link field="calendar" reltype="has_a" key="id" map="" class="acqfc"/>
 		</links>
-		<!--
-			For now, we don't have pcrud as one of the controllers, so the permacrud section is moot.
-			But here's what it should look like if we ever do use pcrud.
-		-->
 		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
 			<actions>
 				<create permission="ADMIN_ACQ_FISCAL_YEAR" global_required="true"/>
-				<retrieve permission="ADMIN_ACQ_FISCAL_YEAR" global_required="true"/>
+				<retrieve permission="STAFF_LOGIN" global_required="true"/>
 				<update permission="ADMIN_ACQ_FISCAL_YEAR" global_required="true"/>
 				<delete permission="ADMIN_ACQ_FISCAL_YEAR" global_required="true"/>
 			</actions>

commit c997cba9081b07db3779c84ab6b11baae789cfff
Author: Bill Erickson <berick at esilibrary.com>
Date:   Fri Aug 10 14:06:36 2012 -0400

    Fiscal year selector in ACQ order record upload
    
    * Support a 'fiscal_year' parameter to ACQ order record upload API.
    * Adds a new "Fiscal Year" selector to the upload form to facilitate
      uploading orders to different fiscal years.
    
    This partially resolves LP 1031927 by allowing manual selection of the
    correct fiscal year.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
index ec94c04..8d65d6d 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
@@ -1324,6 +1324,7 @@ 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 $po;
     my $evt;
 
@@ -1403,7 +1404,8 @@ sub upload_records {
         $mgr->respond;
         $li->provider($provider); # flesh it, we'll need it later
 
-        import_lineitem_details($mgr, $ordering_agency, $li) or return $mgr->editor->die_event;
+        import_lineitem_details($mgr, $ordering_agency, $li, $fiscal_year) 
+            or return $mgr->editor->die_event;
         $mgr->respond;
 
         push(@li_list, $li->id);
@@ -1428,7 +1430,7 @@ sub upload_records {
 }
 
 sub import_lineitem_details {
-    my($mgr, $ordering_agency, $li) = @_;
+    my($mgr, $ordering_agency, $li, $fiscal_year) = @_;
 
     my $holdings = $mgr->editor->json_query({from => ['acq.extract_provider_holding_data', $li->id]});
     return 1 unless @$holdings;
@@ -1441,7 +1443,7 @@ sub import_lineitem_details {
     while(1) {
         # create a lineitem detail for each copy in the data
 
-        my $compiled = extract_lineitem_detail_data($mgr, $org_path, $holdings, $idx);
+        my $compiled = extract_lineitem_detail_data($mgr, $org_path, $holdings, $idx, $fiscal_year);
         last unless defined $compiled;
         return 0 unless $compiled;
 
@@ -1477,7 +1479,7 @@ sub import_lineitem_details {
 
 # return hash on success, 0 on error, undef on no more holdings
 sub extract_lineitem_detail_data {
-    my($mgr, $org_path, $holdings, $index) = @_;
+    my($mgr, $org_path, $holdings, $index, $fiscal_year) = @_;
 
     my @data_list = grep { $_->{holding} eq $index } @$holdings;
     return undef unless @data_list;
@@ -1503,7 +1505,7 @@ sub extract_lineitem_detail_data {
             # search up the org tree for the most appropriate fund
             for my $org (@$org_path) {
                 $fund = $mgr->editor->search_acq_fund(
-                    {org => $org, code => $code, year => DateTime->now->year}, {idlist => 1})->[0];
+                    {org => $org, code => $code, year => $fiscal_year}, {idlist => 1})->[0];
                 last if $fund;
             }
         }
diff --git a/Open-ILS/src/templates/acq/picklist/upload.tt2 b/Open-ILS/src/templates/acq/picklist/upload.tt2
index 6d04d7f..d88bd23 100644
--- a/Open-ILS/src/templates/acq/picklist/upload.tt2
+++ b/Open-ILS/src/templates/acq/picklist/upload.tt2
@@ -32,6 +32,16 @@
                     <select jsId='acqPlUploadPlSelector' dojoType='dijit.form.ComboBox'></select>
                 </td>
             </tr>
+            <tr id='acq-pl-upload-year'>
+                <td>[% l('Fiscal Year') %]</td>
+                <td>
+                    <select dojoType="dijit.form.FilteringSelect"
+                        jsId="acqUploadYearSelector"
+                        labelAttr="year"
+                        searchAttr="year">
+                    </select>
+                </td>
+            </tr>
 
             <tr><td colspan='2'><hr/></td></tr>
             [% PROCESS vlagent_form vl_show_copy_option=1 %]
diff --git a/Open-ILS/web/js/ui/default/acq/picklist/upload.js b/Open-ILS/web/js/ui/default/acq/picklist/upload.js
index 1a6653a..1361685 100644
--- a/Open-ILS/web/js/ui/default/acq/picklist/upload.js
+++ b/Open-ILS/web/js/ui/default/acq/picklist/upload.js
@@ -22,6 +22,8 @@ var usingNewPl = false;
 function init() {
     dojo.byId('acq-pl-upload-ses').value = openils.User.authtoken;
 
+    loadYearSelector();
+
     new openils.widget.AutoFieldWidget({
         fmClass : 'acqpo',
         fmField : 'provider',
@@ -104,7 +106,8 @@ function acqHandlePostUpload(key, plId) {
         ordering_agency : orderAgencyWidget.attr('value'),
         create_po : acqPlUploadCreatePo.attr('value'),
         activate_po : acqPlUploadActivatePo.attr('value'),
-        vandelay : vlAgent.values()
+        vandelay : vlAgent.values(),
+        fiscal_year : acqUploadYearSelector.attr('value')
     };
 
     fieldmapper.standardRequest(
@@ -161,6 +164,31 @@ function acqHandlePostUpload(key, plId) {
     );
 }
 
+function loadYearSelector() {
+
+    fieldmapper.standardRequest(
+        ['open-ils.acq', 'open-ils.acq.fund.org.years.retrieve'],
+        {   async : true,
+            params : [openils.User.authtoken, {}, {limit_perm : 'VIEW_FUND'}],
+            oncomplete : function(r) {
+
+                var yearList = openils.Util.readResponse(r);
+                if(!yearList) return;
+                yearList = yearList.map(function(year){return {year:year+''};}); // dojo wants strings
+
+                var yearStore = {identifier:'year', name:'year', items:yearList};
+                yearStore.items = yearStore.items.sort().reverse();
+                acqUploadYearSelector.store = new dojo.data.ItemFileReadStore({data:yearStore});
+
+                // default to this year
+                // TODO: current fiscal year
+                acqUploadYearSelector.setValue(new Date().getFullYear().toString());
+            }
+        }
+    );
+}
+
+
 
 openils.Util.addOnLoad(init);
 

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/examples/fm_IDL.xml                       |   16 ++-----
 .../lib/OpenILS/Application/Acq/Financials.pm      |   37 ++++++++++++++
 .../perlmods/lib/OpenILS/Application/Acq/Order.pm  |   12 +++--
 Open-ILS/src/templates/acq/picklist/upload.tt2     |   10 ++++
 Open-ILS/web/js/ui/default/acq/picklist/upload.js  |   53 +++++++++++++++++++-
 5 files changed, 109 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list