Skip to content

Commit

Permalink
Merge pull request #51 from camsys/quarter2
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mathmerized authored Jun 26, 2018
2 parents 72d588e + 0d203a5 commit 9880e40
Show file tree
Hide file tree
Showing 55 changed files with 167 additions and 348 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ spec/tmp/*
tmp/*
Gemfile.lock
.idea/
.DS_Store
.DS_Store
shadowed_views.log
12 changes: 12 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# look for views that might be overriden in different transam engines/apps
files=`git status --porcelain | xargs -n1 basename | grep '\.haml\|erb$'`
for file in $files; do

find .. -path "../$(basename "$PWD")" -prune -o -name $file -print | while read f; do
echo "$file shadows or is shadowed by: $f"
echo "$file shadows or is shadowed by: $f" >> 'shadowed_views.log'
done

done
12 changes: 8 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ source "https://rubygems.org"

# To use debugger
# gem 'debugger'
gem 'transam_core', git: 'https://github.com/camsys/transam_core', branch: :quarter1
gem 'transam_reporting', git: 'https://github.com/camsys/transam_reporting', branch: :quarter1
gem 'transam_transit', git: 'https://github.com/camsys/transam_transit', branch: :quarter1
gem 'mysql2', '~> 0.3.20' # lock gem for dummy app
gem 'transam_core', git: 'https://github.com/camsys/transam_core', branch: :quarter2
gem 'transam_reporting', git: 'https://github.com/camsys/transam_reporting', branch: :quarter2

#gem 'transam_transit', path: '../transam_transit'
gem 'transam_transit', git: 'https://github.com/camsys/transam_transit', branch: :quarter2
gem 'mysql2', '< 0.6.0' # lock gem for dummy app
gem "capybara", '2.6.2' # lock gem for old capybara behavior on hidden element xpath

gem 'rails-controller-testing'

# This gem allows us to share githooks. Githooks in the .hooks folder can be checked
# in, and when "bundle install" is run this gem automatically creates symlinks into
# your local .git/hooks. If you have pre-existing hooks in .git/hooks, it will move
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/funding_sources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FundingSourcesController < OrganizationAwareController
add_breadcrumb "Home", :root_path
add_breadcrumb "Funding Programs", :funding_sources_path

before_filter :check_for_cancel, :only => [:create, :update]
before_action :check_for_cancel, :only => [:create, :update]
before_action :set_funding_source, :only => [:show, :edit, :update, :destroy]

INDEX_KEY_LIST_VAR = "funding_source_key_list_cache_var"
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/general_ledger_accounts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
class GeneralLedgerAccountsController < OrganizationAwareController
include FiscalYearHelper

add_breadcrumb "Home", :root_path

# Set the @chart_of_accounts and @ledger_account variable
before_filter :get_ledger_account, :only => [:show, :edit, :update, :destroy]
before_action :get_ledger_account, :only => [:show, :edit, :update, :destroy]

# Protect the controller
authorize_resource
Expand Down Expand Up @@ -77,9 +78,9 @@ def toggle_archive

if coa.present?
if ArchivedFiscalYear.archive(coa.organization_id, params[:fy_year], true)
notify_user(:notice, "The FY was successfully archived/unarchived.")
notify_user(:notice, "The #{get_fy_label} was successfully archived/unarchived.")
else
notify_user(:alert, "Cannot archive/unarchive FY.")
notify_user(:alert, "Cannot archive/unarchive #{get_fy_label}.")
end

redirect_to general_ledger_accounts_path(organization_id: coa.organization_id)
Expand Down
4 changes: 2 additions & 2 deletions app/reports/asset_accumulated_depreciation_report.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class AssetAccumulatedDepreciationReport < AbstractReport

include FiscalYear

COMMON_LABELS = ['Accumulated Depr. Start', 'Depr. Expense', 'Gain/Loss', 'Accumulated Depr. End']
COMMON_FORMATS = [:currency, :currency, :currency, :currency, :currency, :currency]
DETAIL_LABELS = ['Asset Tag']
Expand Down Expand Up @@ -79,7 +79,7 @@ def get_actions
type: :select,
where: :fy_year,
values: get_past_fiscal_years,
label: 'FY'
label: FiscalYearHelper.get_fy_label
},
{
type: :check_box_collection,
Expand Down
4 changes: 2 additions & 2 deletions app/reports/asset_disposition_gain_loss_report.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class AssetDispositionGainLossReport < AbstractReport

include FiscalYear

COMMON_LABELS = ['Cost Basis', 'Accumulated Depr.', ' Sale Proceeds','Gain/Loss']
COMMON_FORMATS = [:currency, :currency, :currency, :currency]
DETAIL_LABELS = ['Asset Tag']
Expand Down Expand Up @@ -89,7 +89,7 @@ def get_actions
type: :select,
where: :fy_year,
values: get_past_fiscal_years,
label: 'FY'
label: FiscalYearHelper.get_fy_label
},
{
type: :check_box_collection,
Expand Down
6 changes: 3 additions & 3 deletions app/reports/asset_fiscal_year_value_report.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class AssetFiscalYearValueReport < AbstractReport

include FiscalYear

COMMON_LABELS = ['Value FY Start', 'Fixed Asset', 'Depr. Expense', 'Accumulated Depr.', 'Gain/Loss', 'Value FY End']
COMMON_LABELS = ['Value #{FiscalYearHelper.get_fy_label} Start', 'Fixed Asset', 'Depr. Expense', 'Accumulated Depr.', 'Gain/Loss', 'Value #{FiscalYearHelper.get_fy_label} End']
COMMON_FORMATS = [:currency, :currency, :currency, :currency, :currency, :currency]
DETAIL_LABELS = ['Asset Tag']
DETAIL_FORMATS = [:string]
Expand Down Expand Up @@ -106,7 +106,7 @@ def get_actions
type: :select,
where: :fy_year,
values: get_past_fiscal_years,
label: 'FY'
label: FiscalYearHelper.get_fy_label
},
{
type: :check_box_collection,
Expand Down
22 changes: 12 additions & 10 deletions app/reports/asset_funding_source_report.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class AssetFundingSourceReport < AbstractReport

include FiscalYearHelper

COMMON_LABELS = ['# Assets', 'Spent']
COMMON_FORMATS = [:integer, :currency]
DETAIL_LABELS = ['Asset Tag', 'Asset Type', 'Asset Subtype', 'Spent']
Expand All @@ -19,7 +21,7 @@ def self.get_detail_data(organization_id_list, params)
clause = 'organizations.short_name = ?'
elsif grp_clause.include? 'Funding Program'
clause = 'funding_sources.name = ?'
elsif grp_clause.include? 'FY'
elsif grp_clause.include? FiscalYearHelper.get_fy_label
start_of_fy = DateTime.strptime("#{SystemConfig.instance.start_of_fiscal_year}-1900", "%m-%d-%Y").to_date
clause = "IF(DAYOFYEAR(assets.purchase_date) < DAYOFYEAR('#{start_of_fy}'), YEAR(assets.purchase_date)-1, YEAR(assets.purchase_date)) = ?"
end
Expand All @@ -42,16 +44,16 @@ def get_actions
where: :group_by,
values: [
'Agency, Funding Program',
'Agency, Funding Program, FY',
"Agency, Funding Program, #{get_fy_label}",

'Funding Program, Agency',
'Funding Program, Agency, FY',
"Funding Program, Agency, #{get_fy_label}",

'Funding Program, FY',
'Funding Program, FY, Agency',
"Funding Program, #{get_fy_label}",
"Funding Program, #{get_fy_label}, Agency",

'FY, Funding Program',
'FY, Funding Program, Agency',
"#{get_fy_label}, Funding Program",
"#{get_fy_label}, Funding Program, Agency",
],
label: 'Group By'
}
Expand Down Expand Up @@ -83,8 +85,8 @@ def get_data(organization_id_list, params)
labels << 'Funding Program'
formats << :string
clause = 'funding_sources.name'
elsif grp_clause.include? 'FY'
labels << 'FY'
elsif grp_clause.include? get_fy_label
labels << get_fy_label
formats << :fiscal_year
start_of_fy = DateTime.strptime("#{SystemConfig.instance.start_of_fiscal_year}-1900", "%m-%d-%Y").to_date
clause = "IF(DAYOFYEAR(assets.purchase_date) < DAYOFYEAR('#{start_of_fy}'), YEAR(assets.purchase_date)-1, YEAR(assets.purchase_date))"
Expand Down Expand Up @@ -122,7 +124,7 @@ def get_data(organization_id_list, params)

formats[0] = :hidden

return {labels: labels + COMMON_LABELS, data: data, formats: formats + COMMON_FORMATS, header_format: labels[0] == 'FY' ? :fiscal_year : :string}
return {labels: labels + COMMON_LABELS, data: data, formats: formats + COMMON_FORMATS, header_format: labels[0] == get_fy_label ? :fiscal_year : :string}
end

def get_key(row)
Expand Down
6 changes: 3 additions & 3 deletions app/reports/gross_asset_value_report.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class GrossAssetValueReport < AbstractReport

include FiscalYear

COMMON_LABELS = ['Value FY Start', 'Fixed Asset', 'Gain/Loss', 'Value FY End']
COMMON_LABELS = ['Value #{FiscalYearHelper.get_fy_label} Start', 'Fixed Asset', 'Gain/Loss', 'Value #{FiscalYearHelper.get_fy_label} End']
COMMON_FORMATS = [:currency, :currency, :currency, :currency]
DETAIL_LABELS = ['Asset Tag']
DETAIL_FORMATS = [:string]
Expand Down Expand Up @@ -84,7 +84,7 @@ def get_actions
type: :select,
where: :fy_year,
values: get_past_fiscal_years,
label: 'FY'
label: FiscalYearHelper.get_fy_label
},
{
type: :check_box_collection,
Expand Down
31 changes: 6 additions & 25 deletions app/views/asset_events/_book_value_update_event_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
= render :layout => "update_event_form" do |f|
= f.input :event_date, :label => 'Date of Report', :wrapper => :vertical_append do
= f.input_field :event_date, :class => "form-control", :as => :string, :data => {'behavior' => 'datepicker'}, :value => format_as_date(f.object.event_date)
= f.input_field :event_date, :as => :string, :class => 'form-control datepicker',
:data => {'date-container' => "##{format_as_id(@asset_event.asset_event_type.name)}_dialog",
'date-start-date' => "#{format_as_date(start_of_fiscal_year(Organization.get_typed_organization(@asset.organization).first_archivable_fiscal_year))}",
'date-end-date' => "#{format_as_date(@asset.policy_analyzer.get_depreciation_date(Date.today)-1.day)}"},
:value => format_as_date(f.object.event_date)
%span.input-group-addon
%i.fa.fa-calendar

Expand All @@ -16,25 +20,10 @@
.form-group
= f.button :submit, "Update Book Value", :class => 'btn btn-primary'

= render 'shared/table_formatters'

:javascript

$(document).ready(function(){
var strStartDate = '#{start_of_fiscal_year(Organization.get_typed_organization(@asset.organization).first_archivable_fiscal_year)}';
var startDateParts = strStartDate.split("-");
var strEndDate = '#{@asset.policy_analyzer.get_depreciation_date(Date.today)-1.day}';
var endDateParts = strEndDate.split("-");
$('[data-behavior~=datepicker]').datepicker({
startDate: new Date(startDateParts[0], (startDateParts[1] - 1), startDateParts[2]),
endDate: new Date(endDateParts[0], (endDateParts[1] - 1), endDateParts[2]),
onSelect: function(d,i){
if(d !== i.lastVal){
$(this).change();
}
}
});
});

$('#asset_event_event_date').change(function() {
$.ajax({
url: '#{get_book_value_on_date_inventory_path(@asset)}',
Expand All @@ -52,11 +41,3 @@
}
});
});

function integer_formatter(value) {
return format("###,##0.", value);
};

function currency_formatter(value) {
return '$' + integer_formatter(value);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

= render :layout => "update_event_form" do |f|
= f.input :event_date, :label => 'Date of Report', :wrapper => :vertical_append do
= f.input_field :event_date, :as => :string, :class => 'form-control datepicker', :data => {'behavior' => 'datepicker'}, :value => format_as_date(f.object.event_date)
= f.input_field :event_date, :as => :string, :class => 'form-control datepicker',
:data => {'date-container' => "##{format_as_id(@asset_event.asset_event_type.name)}_dialog",
'date-start-date' => "#{format_as_date(start_of_fiscal_year(Organization.get_typed_organization(@asset.organization).first_archivable_fiscal_year))}",
'date-end-date' => "#{format_as_date(@asset.policy_analyzer.get_depreciation_date(Date.today)-1.day)}"},
:value => format_as_date(f.object.event_date)
%span.input-group-addon
%i.fa.fa-calendar
- if AssetSubsystem.active.count > 0
Expand Down Expand Up @@ -65,14 +69,6 @@
$("#total").val(total_rehab_costs);
});

var strStartDate = '#{start_of_fiscal_year(Organization.get_typed_organization(@asset.organization).first_archivable_fiscal_year)}';
var startDateParts = strStartDate.split("-");
var strEndDate = '#{@asset.policy_analyzer.get_depreciation_date(Date.today)-1.day}';
var endDateParts = strEndDate.split("-");
$('[data-behavior~=datepicker]').datepicker({
startDate: new Date(startDateParts[0], (startDateParts[1] - 1), startDateParts[2]),
endDate: new Date(endDateParts[0], (endDateParts[1] - 1), endDateParts[2])
});
});

$('#asset_event_event_date').change(function() {
Expand Down
11 changes: 1 addition & 10 deletions app/views/assets/_depreciation_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
.row
.col-xs-4
= f.input :depreciation_start_date, :wrapper => :vertical_append, :label => "Depreciation Start Date" do
= f.input_field :depreciation_start_date, :as => :string, :class => 'form-control datepicker', :data => {'behavior' => 'datepicker'}, :value => format_as_date(f.object.depreciation_start_date), :disabled => @asset.depreciation_purchase_cost != @asset.book_value
= f.input_field :depreciation_start_date, :as => :string, :class => 'form-control datepicker', :data => {'date-container' => '#depreciation_dialog'}, :value => format_as_date(f.object.depreciation_start_date), :disabled => @asset.depreciation_purchase_cost != @asset.book_value
%span.input-group-addon
%i.fa.fa-calendar

Expand All @@ -48,12 +48,3 @@

= f.button :submit, 'Update Depreciation', :class => 'btn btn-primary'
= link_to "Cancel", :back, {:id => 'cancel-button', :class => "btn btn-default"}

:javascript

// Document Ready
$(document).ready(function(){
$('[data-behavior~=datepicker]').datepicker({
});

});
9 changes: 3 additions & 6 deletions app/views/assets/_expenditure_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
= f.input_field :purchase_cost, :class => "form-control"

= f.input :purchase_date, :wrapper => :vertical_append, :label => "Purchase Date" do
= f.input_field :purchase_date, :as => :string, :class => 'form-control datepicker', :data => {'behavior' => 'datepicker'}, :value => format_as_date(f.object.purchase_date)
= f.input_field :purchase_date, :as => :string, :class => 'form-control datepicker', :data => {'date-container' => '#equipment_dialog'}, :value => format_as_date(f.object.purchase_date)
%span.input-group-addon
%i.fa.fa-calendar
= f.input :warranty_date, :wrapper => :vertical_append, :label => "Warranty Date" do
= f.input_field :warranty_date, :as => :string, :class => 'form-control datepicker', :data => {'behavior' => 'datepicker'}, :value => format_as_date(f.object.warranty_date)
= f.input_field :warranty_date, :as => :string, :class => 'form-control datepicker', :data => {'date-container' => '#equipment_dialog'}, :value => format_as_date(f.object.warranty_date)
%span.input-group-addon
%i.fa.fa-calendar
= f.input :in_service_date, :wrapper => :vertical_append, :label => "In Service Date" do
= f.input_field :in_service_date, :as => :string, :class => 'form-control datepicker', :data => {'behavior' => 'datepicker'}, :value => format_as_date(f.object.in_service_date)
= f.input_field :in_service_date, :as => :string, :class => 'form-control datepicker', :data => {'date-container' => '#equipment_dialog'}, :value => format_as_date(f.object.in_service_date)
%span.input-group-addon
%i.fa.fa-calendar
= f.input :purchased_new, :as => :radio_buttons, :required => true, :label => "Purchased New"
Expand Down Expand Up @@ -76,9 +76,6 @@
this.value = this.value.toUpperCase();
});

$('[data-behavior~=datepicker]').datepicker({
});

$('#vendor_name').on('focus', function() {
_typeahead_source_url = $(this).data('url');
});
Expand Down
6 changes: 5 additions & 1 deletion app/views/expenditures/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
= f.association :expense_type, :required => true, :collection => ExpenseType.active, :label => 'Category'
.col-sm-6
= f.input :expense_date, :required => true, :wrapper => :vertical_append, :label => "Expense Date" do
= f.input_field :expense_date, :as => :string, :class => 'form-control datepicker', :data => {'behavior' => 'datepicker'}, :value => format_as_date(f.object.expense_date)
= f.input_field :expense_date, :as => :string, :class => 'form-control datepicker',
:data => {'date-container' => "##{format_as_id(@asset_event.asset_event_type.name)}_dialog",
'date-start-date' => "#{format_as_date(start_of_fiscal_year(Organization.get_typed_organization(@asset.organization).first_archivable_fiscal_year))}",
'date-end-date' => "#{format_as_date(@asset.policy_analyzer.get_depreciation_date(Date.today)-1.day)}"},
:value => format_as_date(f.object.expense_date)
%span.input-group-addon
%i.fa.fa-calendar

Expand Down
9 changes: 0 additions & 9 deletions app/views/expenditures/_form_scripts.html.haml
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
:javascript
$(document).ready(function() {

var strStartDate = '#{start_of_fiscal_year(Organization.get_typed_organization(@asset.organization).first_archivable_fiscal_year)}';
var startDateParts = strStartDate.split("-");
var strEndDate = '#{@asset.policy_analyzer.get_depreciation_date(Date.today)-1.day}';
var endDateParts = strEndDate.split("-");
$('[data-behavior~=datepicker]').datepicker({
startDate: new Date(startDateParts[0], (startDateParts[1] - 1), startDateParts[2]),
endDate: new Date(endDateParts[0], (endDateParts[1] - 1), endDateParts[2])
});

// jquery validations
$('.expenditure_form').validate({
ignore: [], //validate hidden fields
Expand Down
Binary file removed app/views/funding_sources/.DS_Store
Binary file not shown.
12 changes: 2 additions & 10 deletions app/views/funding_sources/_details.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@
%span.badge.pull-right= @funding_source.assets.count
= "Assets"

%li
%a{:href => "#docs", :data =>{:toggle => 'tab'}}
%span{:style => 'white-space: nowrap !important;'}
= "Documents"
%span.badge= @funding_source.documents.count
%li
%a{:href => "#comments", :data =>{:toggle => 'tab'}}
%span{:style => 'white-space: nowrap !important;'}
= "Comments"
%span.badge= @funding_source.comments.count
= nav_tab_count_tag("#docs", "Documents", @funding_source.documents.count)
= nav_tab_count_tag("#comments", "Comments", @funding_source.comments.count)

.tab-content{:style => 'max-height:400px;overflow-y: auto;'}
.tab-pane.fade#desc
Expand Down
Loading

0 comments on commit 9880e40

Please sign in to comment.