Skip to content

Commit

Permalink
Add support for All SUL Funds selection for expenditure and fund reports
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreben committed May 11, 2017
1 parent 045ad2b commit 5b54e63
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/controllers/concerns/endow_funds_params.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
##
# Module to construct the Endow Funds Report params for endow_rpt.cgi
# script exists @bodoni.stanford.edu:/var/www/cgi-bin/webforms/endow_rpt.cgi
# All the args in URL:
# ('ckeys_filename')('date_range')('email')('funds')('output_format')
##
Expand Down
9 changes: 6 additions & 3 deletions app/models/endowed_funds_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ def self.ol_cat_key_fund(fund, date_start, date_end)
fund_codes.uniq
end

def self.ol_cat_key_fund_begin(fund, date_start, date_end)
Expenditures.where("ta_fund_code LIKE ? AND ta_date_2encina between
def self.ol_cat_key_fund_begin(fund_begin, date_start, date_end)
nothing = ''
fund_begin = nothing ? fund_begin == 'All SUL Funds' : fund_begin

Expenditures.where("ta_fund_code LIKE ? AND ti_inv_lib = 'SUL' AND ta_date_2encina between
TO_DATE(?, 'yyyy-mm-dd') AND TO_DATE(?, 'yyyy-mm-dd')",
"%#{fund}%", date_start, date_end).pluck(:ol_cat_key)
"%#{fund_begin}%", date_start, date_end).pluck(:ol_cat_key)
end

attr_reader :ckeys_file
Expand Down
7 changes: 5 additions & 2 deletions app/views/shared/_funds_selection.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class='form-group row'>
<%= f.label :fund_select, 'Select funds for report by:', class: 'col-sm-5 form-control-label'%>
<div class='col-sm-10'>
<p><%= f.radio_button :fund_select, 'fund_name_id', {'data-toggle' => 'collapse', 'data-target' => '.fund_name_id', onChange: '$(".collapse").removeClass("in")'} %> Fund ID/PTA or name</p>
<p><%= f.radio_button :fund_select, 'fund_begins_with', {'data-toggle' => 'collapse', 'data-target' => '.fund_begins_with', onChange: '$(".collapse").removeClass("in")'} %> Fund ID/PTA begins with</p>
<p><%= f.radio_button :fund_select, 'fund_name_id', {'class'=>'fund_selects', 'data-toggle' => 'collapse', 'data-target' => '.fund_name_id', onChange: '$(".collapse").removeClass("in");$(".all_sul").prop("checked", false);'} %> Fund ID/PTA or name</p>
<p><%= f.radio_button :fund_select, 'fund_begins_with', {'class'=>'fund_selects', 'data-toggle' => 'collapse', 'data-target' => '.fund_begins_with', onChange: '$(".collapse").removeClass("in");$(".all_sul").prop("checked", false);'} %> Fund ID/PTA begins with</p>
</div>
</div>
<div class='form-group row'>
Expand Down Expand Up @@ -64,4 +64,7 @@
<% end %>
</div>
</div>
<div class='col-sm-10'>
<p> <%= f.radio_button :fund_begin, 'All SUL Funds', class: 'all_sul', onClick: "$('input:radio[class=fund_selects]').each(function () { $(this).prop('checked', false); });$('.collapse').removeClass('in')" %> Select all SUL funds </p>
</div>
</div>
8 changes: 7 additions & 1 deletion spec/models/endowed_funds_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
rescue ActiveRecord::StatementInvalid
end
end

subject { EndowedFundsReport.ol_cat_key_fund_begin('All SUL Funds', '2015-07-01', '2016-06-30') }
it 'should handle the All SUL Funds selection' do
begin
expect(subject).to be_kind_of(Array)
rescue ActiveRecord::StatementInvalid
end
end
subject { EndowedFundsReport.ol_cat_key_fund(['1000501-1-AACIZ', '1008930-1-HAGOY'], '2015-07-01', '2016-06-30') }
it 'should initialize a container of fund codes' do
begin
Expand Down

0 comments on commit 5b54e63

Please sign in to comment.