diff --git a/Gemfile b/Gemfile index b9670892..b201a762 100644 --- a/Gemfile +++ b/Gemfile @@ -7,9 +7,9 @@ source "https://rubygems.org" # To use debugger # gem 'debugger' -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', git: 'https://github.com/camsys/transam_transit', branch: :quarter2 +gem 'transam_core', git: 'https://github.com/camsys/transam_core', branch: :quarter3 +gem 'transam_reporting', git: 'https://github.com/camsys/transam_reporting', branch: :quarter3 +gem 'transam_transit', git: 'https://github.com/camsys/transam_transit', branch: :quarter3 gem 'mysql2', '~> 0.5.1' # lock gem for dummy app gem "capybara", '2.6.2' # lock gem for old capybara behavior on hidden element xpath diff --git a/app/jobs/asset_depreciation_expense_update_job.rb b/app/jobs/asset_depreciation_expense_update_job.rb index 20a11d7a..3d7fad35 100644 --- a/app/jobs/asset_depreciation_expense_update_job.rb +++ b/app/jobs/asset_depreciation_expense_update_job.rb @@ -10,7 +10,7 @@ class AssetDepreciationExpenseUpdateJob < ActivityJob def run asset_klass = Rails.application.config.asset_base_class_name.constantize - asset_klass.not_in_transfer.where.not(current_depreciation_date: Policy.first.current_depreciation_date).each do |a| + asset_klass.not_in_transfer.where.not(current_depreciation_date: Policy.first.current_depreciation_date).or(asset_klass.not_in_transfer.where(current_depreciation_date: nil)).each do |a| asset = asset_klass.get_typed_asset(a) asset.update_asset_book_value end diff --git a/app/models/book_value_update_event.rb b/app/models/book_value_update_event.rb index 04ef3341..398107f8 100644 --- a/app/models/book_value_update_event.rb +++ b/app/models/book_value_update_event.rb @@ -44,7 +44,7 @@ def self.asset_event_type # This must be overriden otherwise a stack error will occur def get_update - "Book value: #{self.book_value}." + "Book value: #{self.book_value}" end def can_update? diff --git a/app/models/depreciation_entry.rb b/app/models/depreciation_entry.rb index 565b8894..7fcf3e0a 100644 --- a/app/models/depreciation_entry.rb +++ b/app/models/depreciation_entry.rb @@ -26,6 +26,7 @@ class DepreciationEntry < ActiveRecord::Base #validates :asset, :presence => true validates :description, :presence => true validates :book_value, :presence => true + validates :description, :uniqueness => { :scope => [:transam_asset_id, :event_date]} # List of allowable form param hash keys diff --git a/app/views/grants/_index_actions.html.haml b/app/views/grants/_index_actions.html.haml index 319ab90d..66c62a14 100644 --- a/app/views/grants/_index_actions.html.haml +++ b/app/views/grants/_index_actions.html.haml @@ -5,4 +5,18 @@ = select_tag(:state, options_for_select([["In Development / Open", "default"], ["All", "all"]].concat(Grant.state_names.collect{|a| [a.titleize, a]}), :selected => @state), :class => "form-control") = button_tag :class => 'btn btn-default', :type => 'submit' do - %i.fa.fa-filter \ No newline at end of file + %i.fa.fa-filter + +- if can? :create, Grant + .navbar-form.pull-right + = link_to new_grant_path, :class => 'btn btn-primary' do + %i.fa.fa-plus.fa-fw + = "Add Grant"; + .navbar-form.pull-right + %button.btn.btn-primary.btn-md.dropdown-toggle{:data => {:toggle => 'dropdown'}} + %i.fa.fa-file + = " Export" + %span.caret + %ul.dropdown-menu{:role => 'menu'} + %li + = link_to "XLSX", current_url(format: :xlsx), target: '_blank', title: 'Export all rows and columns to XLSX' \ No newline at end of file diff --git a/app/views/grants/_index_table.html.haml b/app/views/grants/_index_table.html.haml index 9085f7f5..bd7bd77a 100644 --- a/app/views/grants/_index_table.html.haml +++ b/app/views/grants/_index_table.html.haml @@ -24,20 +24,6 @@ - if show_actions == 1 = render :partial => "grants/index_actions" - - if can? :create, Grant - .navbar-form.pull-right - = link_to new_grant_path, :class => 'btn btn-primary' do - %i.fa.fa-plus.fa-fw - = "Add Grant"; - .navbar-form.pull-right - %button.btn.btn-primary.btn-md.dropdown-toggle{:data => {:toggle => 'dropdown'}} - %i.fa.fa-file - = " Export" - %span.caret - %ul.dropdown-menu{:role => 'menu'} - %li - = link_to "XLSX", current_url(format: :xlsx), target: '_blank', title: 'Export all rows and columns to XLSX' - .table-responsive %table.table.table-hover{:id => table_dom_id, :data => {:toggle => 'table', :pagination => 'true', diff --git a/app/views/transit_assets/_accounting_funding_form.html.haml b/app/views/transit_assets/_accounting_funding_form.html.haml index a54f2963..dfe9094e 100644 --- a/app/views/transit_assets/_accounting_funding_form.html.haml +++ b/app/views/transit_assets/_accounting_funding_form.html.haml @@ -45,7 +45,7 @@ }); $('.funding_sources_grant_purchases_form .funding-pcnt').valid(); - var pcnt = $(this).val() * 100 / parseInt($('#purchase_cost').editable('getValue')['asset[purchase_cost]']); + var pcnt = $(this).val() * 100 / parseInt($(this).closest('.tab-content').find('#purchase_cost').editable('getValue')['asset[purchase_cost]']); $(this).parents('.funding-source-fields').find('.funding-pcnt').val(pcnt); $(this).parents('.funding-source-fields').find('.grant-purchase-pcnt.display-value').html(pcnt.toFixed(#{funding_pcnt_precision}) + " %"); @@ -56,7 +56,7 @@ var sum = 0; var tdc_sum = 0; var tdc_funding_programs = JSON.parse('#{FundingSource.where(funding_source_type: FundingSourceType.find_by(name: 'TDC')).map{|f| f.to_global_id.to_s}.to_json.html_safe}') - $('.funding_sources_grant_purchases_form .funding-pcnt').each(function() { + $(element).closest('.tab-content').find('.funding_sources_grant_purchases_form .funding-pcnt').each(function() { var program = $(this).parents('.funding-source-fields').find('.funding-source-global-sourceable').val(); if ($.inArray(program, tdc_funding_programs) >= 0){ diff --git a/app/views/transit_assets/_accounting_purchase_form.html.haml b/app/views/transit_assets/_accounting_purchase_form.html.haml index 3b772abe..827eb091 100644 --- a/app/views/transit_assets/_accounting_purchase_form.html.haml +++ b/app/views/transit_assets/_accounting_purchase_form.html.haml @@ -14,6 +14,8 @@ :file => :vertical_file_input, :boolean => :vertical_boolean}) do |f| + #grant_purchase_cost{style: 'display:none;'}= asset.purchase_cost + %fieldset %legend{style: 'font-size: medium;'} Grants %label#grants-error.error @@ -58,7 +60,7 @@ }); $('.grants_grant_purchases_form .funding-pcnt').valid(); - var pcnt = $(this).val() * 100 / parseInt($('#purchase_cost').editable('getValue')['asset[purchase_cost]']); + var pcnt = $(this).val() * 100 / parseInt($('#grant_purchase_cost').text()); $(this).parents('.grant-fields').find('.funding-pcnt').val(pcnt); $(this).parents('.grant-fields').find('.grant-purchase-pcnt.display-value').html(pcnt.toFixed(#{funding_pcnt_precision}) + " %"); @@ -69,7 +71,7 @@ var sum = 0; var tdc_sum = 0; var tdc_grants = JSON.parse('#{Grant.where(sourceable: FundingSource.where(funding_source_type: FundingSourceType.find_by(name: 'TDC'))).map{|f| f.to_global_id.to_s}.to_json.html_safe}') - $('.grants_grant_purchases_form .funding-pcnt').each(function() { + $(element).closest('.tab-content').find('.grants_grant_purchases_form .funding-pcnt').each(function() { var program = $(this).parents('.grant-fields').find('.global-sourceable').val(); if ($.inArray(program, tdc_grants) >= 0){ tdc_sum += Number($(this).val()); diff --git a/db/data_migrations/20190708132343_change_time_deprecation_activity.rb b/db/data_migrations/20190708132343_change_time_deprecation_activity.rb new file mode 100644 index 00000000..bc8dc902 --- /dev/null +++ b/db/data_migrations/20190708132343_change_time_deprecation_activity.rb @@ -0,0 +1,5 @@ +class ChangeTimeDeprecationActivity < ActiveRecord::DataMigration + def up + Activity.find_by(job_name: 'AssetDepreciationExpenseUpdateJob').update!(execution_time: '22:01') + end +end \ No newline at end of file diff --git a/db/migrate/20190708132532_add_indices_depreciation_entries.rb b/db/migrate/20190708132532_add_indices_depreciation_entries.rb new file mode 100644 index 00000000..971123f7 --- /dev/null +++ b/db/migrate/20190708132532_add_indices_depreciation_entries.rb @@ -0,0 +1,5 @@ +class AddIndicesDepreciationEntries < ActiveRecord::Migration[5.2] + def change + add_index(:depreciation_entries, [:transam_asset_id, :event_date, :description], unique: true, name: 'transam_asset_event_date_description_uniq_idx') + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 71135c64..e2b3e79b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -26,7 +26,7 @@ system_activity: true, frequency_quantity: 1, frequency_type_id: 3, - execution_time: '00:01', + execution_time: '22:01', job_name: 'AssetDepreciationExpenseUpdateJob', active: true } ] diff --git a/lib/transam_accounting/version.rb b/lib/transam_accounting/version.rb index 340fec79..6102620a 100644 --- a/lib/transam_accounting/version.rb +++ b/lib/transam_accounting/version.rb @@ -1,3 +1,3 @@ module TransamAccounting - VERSION = "2.6.1" + VERSION = "2.7.0" end diff --git a/spec/factories/organizations.rb b/spec/factories/organizations.rb index 4d78846f..53b3b5c1 100644 --- a/spec/factories/organizations.rb +++ b/spec/factories/organizations.rb @@ -12,6 +12,7 @@ organization_type_id { 1 } sequence(:name) { |n| "Org #{n}" } short_name { name } + legal_name { name } license_holder { true } end