From 51331b2ff7bb614bef093b0a19dcb6bbd6fd0c1c Mon Sep 17 00:00:00 2001 From: Alex Andrade Date: Fri, 20 Mar 2020 18:47:43 -0400 Subject: [PATCH 1/8] [TTPLAT-1352, TTPLAT-1347] Separate asset events in api call by type. Fix broken associations on infrastructure json responses. --- app/models/book_value_update_event.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/book_value_update_event.rb b/app/models/book_value_update_event.rb index 398107f8..59c6ab0f 100644 --- a/app/models/book_value_update_event.rb +++ b/app/models/book_value_update_event.rb @@ -50,6 +50,13 @@ def get_update def can_update? false # set to false so it doesnt show up in the asset detail page action menu and existing events cannot be updated end + + ######## API Serializer ############## + def api_json(options={}) + super.merge({ + book_value: book_value + }) + end protected From c2e7b60367596cd6834252905dc7ea8d595d80b7 Mon Sep 17 00:00:00 2001 From: Derek Edwards Date: Mon, 30 Mar 2020 15:28:44 -0400 Subject: [PATCH 2/8] Update version. --- lib/transam_accounting/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transam_accounting/version.rb b/lib/transam_accounting/version.rb index f4e4b8ca..12eec244 100644 --- a/lib/transam_accounting/version.rb +++ b/lib/transam_accounting/version.rb @@ -1,3 +1,3 @@ module TransamAccounting - VERSION = "2.9.1" + VERSION = "2.10.0-rc.1" end From badf621b3e840a81558009a92eda510d99eda07b Mon Sep 17 00:00:00 2001 From: mathmerized Date: Wed, 1 Apr 2020 11:47:01 -0400 Subject: [PATCH 3/8] TTPLAT-1433 fix functionality that no longer works for component data with single save/edit on asset detail --- .../_accounting_funding_form.html.haml | 29 +++++------------ .../_accounting_purchase_form.html.haml | 31 ++++++------------- 2 files changed, 17 insertions(+), 43 deletions(-) diff --git a/app/views/transit_assets/_accounting_funding_form.html.haml b/app/views/transit_assets/_accounting_funding_form.html.haml index dfe9094e..e0377945 100644 --- a/app/views/transit_assets/_accounting_funding_form.html.haml +++ b/app/views/transit_assets/_accounting_funding_form.html.haml @@ -1,26 +1,13 @@ - funding_pcnt_precision = Rails.application.config.try(:funding_pcnt_decimal_precision) || 2 -- if can? :update, asset - #funding_sources_grant_purchases.asset-subform{style: "width:95%;"} - = simple_form_for(asset.transam_asset, - :as => :asset, - :url => inventory_path(asset.transam_asset), - :method => 'put', - :remote => true, - :html => {:class => 'form-vertical form-section funding_sources_grant_purchases_form'}, - :wrapper => :vertical_form, - :wrapper_mappings => {:check_boxes => :vertical_radio_and_checkboxes, - :radio_buttons => :vertical_radio_and_checkboxes, - :file => :vertical_file_input, - :boolean => :vertical_boolean}) do |f| - %fieldset - %legend{style: 'font-size: medium;'} Funding Programs - %label#funding_sources-error.error - = f.simple_fields_for :funding_source_grant_purchases do |funding_source| - = render 'transit_assets/transit_assets_funding_source_fields', f: funding_source - .links.pull-right - = link_to_add_association f, :funding_source_grant_purchases, partial: 'transit_assets/transit_assets_funding_source_fields', :class => 'asset-subform-action' do - %i.fa.fa-2x.fa-plus-circle +%fieldset + %legend{style: 'font-size: medium;'} Funding Programs + %label#funding_sources-error.error + = f.simple_fields_for :funding_source_grant_purchases do |funding_source| + = render 'transit_assets/transit_assets_funding_source_fields', f: funding_source + .links.pull-right + = link_to_add_association f, :funding_source_grant_purchases, partial: 'transit_assets/transit_assets_funding_source_fields', :class => 'asset-subform-action' do + %i.fa.fa-2x.fa-plus-circle :javascript $( document ).ready(function() { diff --git a/app/views/transit_assets/_accounting_purchase_form.html.haml b/app/views/transit_assets/_accounting_purchase_form.html.haml index 827eb091..4e98902f 100644 --- a/app/views/transit_assets/_accounting_purchase_form.html.haml +++ b/app/views/transit_assets/_accounting_purchase_form.html.haml @@ -1,29 +1,16 @@ :ruby funding_pcnt_precision = Rails.application.config.try(:funding_pcnt_decimal_precision) || 2 -- if can? :update, asset - #grants_grant_purchases.asset-subform{style: "width:95%;"} - = simple_form_for(asset.transam_asset, - :as => :asset, - :url => inventory_path(asset.transam_asset), - :method => 'put', - :remote => true, - :html => {:class => 'form-vertical form-section grants_grant_purchases_form'}, - :wrapper => :vertical_form, - :wrapper_mappings => {:check_boxes => :vertical_radio_and_checkboxes, - :radio_buttons => :vertical_radio_and_checkboxes, - :file => :vertical_file_input, - :boolean => :vertical_boolean}) do |f| - #grant_purchase_cost{style: 'display:none;'}= asset.purchase_cost +#grant_purchase_cost{style: 'display:none;'}= f.object.purchase_cost - %fieldset - %legend{style: 'font-size: medium;'} Grants - %label#grants-error.error - = f.simple_fields_for :grant_grant_purchases do |grant| - = render 'transit_assets/transit_assets_grant_fields', f: grant - .links.pull-right - = link_to_add_association f, :grant_grant_purchases, partial: 'transit_assets/transit_assets_grant_fields', :class => 'asset-subform-action' do - %i.fa.fa-2x.fa-plus-circle +%fieldset + %legend{style: 'font-size: medium;'} Grants + %label#grants-error.error + = f.simple_fields_for :grant_grant_purchases do |grant| + = render 'transit_assets/transit_assets_grant_fields', f: grant + .links.pull-right + = link_to_add_association f, :grant_grant_purchases, partial: 'transit_assets/transit_assets_grant_fields', :class => 'asset-subform-action' do + %i.fa.fa-2x.fa-plus-circle :javascript $( document ).ready(function() { From 1016fc48a65152d87159142f1c03a0ea1ff956b4 Mon Sep 17 00:00:00 2001 From: mathmerized Date: Wed, 1 Apr 2020 11:54:19 -0400 Subject: [PATCH 4/8] TTPLAT-1475 fix book value update event to use TransamAsset not Asset --- app/models/book_value_update_event.rb | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/app/models/book_value_update_event.rb b/app/models/book_value_update_event.rb index 59c6ab0f..e6791125 100644 --- a/app/models/book_value_update_event.rb +++ b/app/models/book_value_update_event.rb @@ -66,41 +66,43 @@ def set_defaults end def create_depreciation_entry - depr_amount = asset.depreciation_entries.where('event_date <= ?',self.event_date).sum(:book_value) - book_value + asset_instance = self.send(Rails.application.config.asset_base_class_name.underscore) - asset.depreciation_entries.create!(description: "Manual Adjustment: #{self.comments}", book_value: -depr_amount, event_date: self.event_date) - asset.update_columns(current_depreciation_date: self.event_date) + depr_amount = asset_instance.depreciation_entries.where('event_date <= ?',self.event_date).sum(:book_value) - book_value - gl_mapping = asset.general_ledger_mapping + asset_instance.depreciation_entries.create!(description: "Manual Adjustment: #{self.comments}", book_value: -depr_amount, event_date: self.event_date) + asset_instance.update_columns(current_depreciation_date: self.event_date) + + gl_mapping = asset_instance.general_ledger_mapping if gl_mapping.present? # check whether this app records GLAs at all - gl_mapping.accumulated_depr_account.general_ledger_account_entries.create!(event_date: event_date, description: "Manual Adjustment - Accumulated Depreciation: #{asset.asset_path}", amount: -depr_amount, asset: asset) + gl_mapping.accumulated_depr_account.general_ledger_account_entries.create!(event_date: event_date, description: "Manual Adjustment - Accumulated Depreciation: #{asset.asset_path}", amount: -depr_amount, asset: asset_instance) - gl_mapping.depr_expense_account.general_ledger_account_entries.create!(event_date: event_date, description: "Manual Adjustment - Deprectiation Expense: #{asset.asset_path}", amount: depr_amount, asset: asset) + gl_mapping.depr_expense_account.general_ledger_account_entries.create!(event_date: event_date, description: "Manual Adjustment - Deprectiation Expense: #{asset.asset_path}", amount: depr_amount, asset: asset_instance) end # destroy any manual adjustments past the depr start - asset.depreciation_entries.manual_adjustments.where('event_date > ?',self.event_date).each do |depr_entry| + asset_instance.depreciation_entries.manual_adjustments.where('event_date > ?',self.event_date).each do |depr_entry| if gl_mapping.present? - gl_mapping.accumulated_depr_account.general_ledger_account_entries.create!(event_date: event_date, description: "REVERSED Manual Adjustment - Accumulated Depreciation: #{asset.asset_path}", amount: -depr_entry.book_value, asset: asset) + gl_mapping.accumulated_depr_account.general_ledger_account_entries.create!(event_date: event_date, description: "REVERSED Manual Adjustment - Accumulated Depreciation: #{asset.asset_path}", amount: -depr_entry.book_value, asset: asset_instance) - gl_mapping.depr_expense_account.general_ledger_account_entries.create!(event_date: event_date, description: "REVERSED Manual Adjustment - Depreciation Expense: #{asset.asset_path}", amount: depr_entry.book_value, asset: asset) + gl_mapping.depr_expense_account.general_ledger_account_entries.create!(event_date: event_date, description: "REVERSED Manual Adjustment - Depreciation Expense: #{asset.asset_path}", amount: depr_entry.book_value, asset: asset_instance) end depr_entry.destroy! end - asset.depreciation_entries.depreciation_expenses.where('event_date > ?',self.event_date).each do |depr_entry| + asset_instance.depreciation_entries.depreciation_expenses.where('event_date > ?',self.event_date).each do |depr_entry| if gl_mapping.present? - gl_mapping.accumulated_depr_account.general_ledger_account_entries.create!(event_date: event_date, description: "REVERSED Accumulated Depreciation: #{asset.asset_path}", amount: -depr_entry.book_value, asset: asset) + gl_mapping.accumulated_depr_account.general_ledger_account_entries.create!(event_date: event_date, description: "REVERSED Accumulated Depreciation: #{asset.asset_path}", amount: -depr_entry.book_value, asset: asset_instance) - gl_mapping.depr_expense_account.general_ledger_account_entries.create!(event_date: event_date, description: "REVERSED Deprectiation Expense: #{asset.asset_path}", amount: depr_entry.book_value, asset: asset) + gl_mapping.depr_expense_account.general_ledger_account_entries.create!(event_date: event_date, description: "REVERSED Deprectiation Expense: #{asset.asset_path}", amount: depr_entry.book_value, asset: asset_instance) end depr_entry.destroy! end - asset.update_asset_book_value - asset.save(:validate => false) + asset_instance.update_asset_book_value + asset_instance.save(:validate => false) return true end From 32e552e0f37e9d79dd87f108deda2cab22e44b24 Mon Sep 17 00:00:00 2001 From: mathmerized Date: Wed, 1 Apr 2020 15:02:16 -0400 Subject: [PATCH 5/8] TTPLAT-1475 form is only instantianted already for infrastructure/components --- .../_accounting_funding_form.html.haml | 39 +++++++++++++++---- .../_accounting_purchase_form.html.haml | 38 ++++++++++++++---- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/app/views/transit_assets/_accounting_funding_form.html.haml b/app/views/transit_assets/_accounting_funding_form.html.haml index e0377945..39902ecf 100644 --- a/app/views/transit_assets/_accounting_funding_form.html.haml +++ b/app/views/transit_assets/_accounting_funding_form.html.haml @@ -1,13 +1,36 @@ - funding_pcnt_precision = Rails.application.config.try(:funding_pcnt_decimal_precision) || 2 -%fieldset - %legend{style: 'font-size: medium;'} Funding Programs - %label#funding_sources-error.error - = f.simple_fields_for :funding_source_grant_purchases do |funding_source| - = render 'transit_assets/transit_assets_funding_source_fields', f: funding_source - .links.pull-right - = link_to_add_association f, :funding_source_grant_purchases, partial: 'transit_assets/transit_assets_funding_source_fields', :class => 'asset-subform-action' do - %i.fa.fa-2x.fa-plus-circle +- if ['Track', 'PowerSignal', 'Guideway'].include? @asset.class.to_s + %fieldset + %legend{style: 'font-size: medium;'} Funding Programs + %label#funding_sources-error.error + = f.simple_fields_for :funding_source_grant_purchases do |funding_source| + = render 'transit_assets/transit_assets_funding_source_fields', f: funding_source + .links.pull-right + = link_to_add_association f, :funding_source_grant_purchases, partial: 'transit_assets/transit_assets_funding_source_fields', :class => 'asset-subform-action' do + %i.fa.fa-2x.fa-plus-circle +- else + #funding_sources_grant_purchases.asset-subform{style: "width:95%;"} + = simple_form_for(asset.transam_asset, + :as => :asset, + :url => inventory_path(asset.transam_asset), + :method => 'put', + :remote => true, + :html => {:class => 'form-vertical form-section funding_sources_grant_purchases_form'}, + :wrapper => :vertical_form, + :wrapper_mappings => {:check_boxes => :vertical_radio_and_checkboxes, + :radio_buttons => :vertical_radio_and_checkboxes, + :file => :vertical_file_input, + :boolean => :vertical_boolean}) do |f| + %fieldset + %legend{style: 'font-size: medium;'} Funding Programs + %label#funding_sources-error.error + = f.simple_fields_for :funding_source_grant_purchases do |funding_source| + = render 'transit_assets/transit_assets_funding_source_fields', f: funding_source + .links.pull-right + = link_to_add_association f, :funding_source_grant_purchases, partial: 'transit_assets/transit_assets_funding_source_fields', :class => 'asset-subform-action' do + %i.fa.fa-2x.fa-plus-circle + :javascript $( document ).ready(function() { diff --git a/app/views/transit_assets/_accounting_purchase_form.html.haml b/app/views/transit_assets/_accounting_purchase_form.html.haml index 4e98902f..2416b184 100644 --- a/app/views/transit_assets/_accounting_purchase_form.html.haml +++ b/app/views/transit_assets/_accounting_purchase_form.html.haml @@ -3,14 +3,36 @@ #grant_purchase_cost{style: 'display:none;'}= f.object.purchase_cost -%fieldset - %legend{style: 'font-size: medium;'} Grants - %label#grants-error.error - = f.simple_fields_for :grant_grant_purchases do |grant| - = render 'transit_assets/transit_assets_grant_fields', f: grant - .links.pull-right - = link_to_add_association f, :grant_grant_purchases, partial: 'transit_assets/transit_assets_grant_fields', :class => 'asset-subform-action' do - %i.fa.fa-2x.fa-plus-circle +- if ['Track', 'PowerSignal', 'Guideway'].include? @asset.class.to_s + %fieldset + %legend{style: 'font-size: medium;'} Grants + %label#grants-error.error + = f.simple_fields_for :grant_grant_purchases do |grant| + = render 'transit_assets/transit_assets_grant_fields', f: grant + .links.pull-right + = link_to_add_association f, :grant_grant_purchases, partial: 'transit_assets/transit_assets_grant_fields', :class => 'asset-subform-action' do + %i.fa.fa-2x.fa-plus-circle +- else + #grants_grant_purchases.asset-subform{style: "width:95%;"} + = simple_form_for(asset.transam_asset, + :as => :asset, + :url => inventory_path(asset.transam_asset), + :method => 'put', + :remote => true, + :html => {:class => 'form-vertical form-section grants_grant_purchases_form'}, + :wrapper => :vertical_form, + :wrapper_mappings => {:check_boxes => :vertical_radio_and_checkboxes, + :radio_buttons => :vertical_radio_and_checkboxes, + :file => :vertical_file_input, + :boolean => :vertical_boolean}) do |f| + %fieldset + %legend{style: 'font-size: medium;'} Grants + %label#grants-error.error + = f.simple_fields_for :grant_grant_purchases do |grant| + = render 'transit_assets/transit_assets_grant_fields', f: grant + .links.pull-right + = link_to_add_association f, :grant_grant_purchases, partial: 'transit_assets/transit_assets_grant_fields', :class => 'asset-subform-action' do + %i.fa.fa-2x.fa-plus-circle :javascript $( document ).ready(function() { From 65913b44de390169047b0fe72c56f856500b9b38 Mon Sep 17 00:00:00 2001 From: mathmerized Date: Wed, 1 Apr 2020 15:04:08 -0400 Subject: [PATCH 6/8] typo --- .../transit_assets/_accounting_purchase_form.html.haml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/transit_assets/_accounting_purchase_form.html.haml b/app/views/transit_assets/_accounting_purchase_form.html.haml index 2416b184..47d52ed1 100644 --- a/app/views/transit_assets/_accounting_purchase_form.html.haml +++ b/app/views/transit_assets/_accounting_purchase_form.html.haml @@ -1,9 +1,9 @@ :ruby - funding_pcnt_precision = Rails.application.config.try(:funding_pcnt_decimal_precision) || 2 - -#grant_purchase_cost{style: 'display:none;'}= f.object.purchase_cost + funding_pcnt_precision = Rails.application.config.try(:funding_pcnt_decimal_precision) || 2#grant_purchase_cost{style: 'display:none;'}= f.object.purchase_cost - if ['Track', 'PowerSignal', 'Guideway'].include? @asset.class.to_s + #grant_purchase_cost{style: 'display:none;'}= f.object.purchase_cost + %fieldset %legend{style: 'font-size: medium;'} Grants %label#grants-error.error @@ -25,6 +25,9 @@ :radio_buttons => :vertical_radio_and_checkboxes, :file => :vertical_file_input, :boolean => :vertical_boolean}) do |f| + + #grant_purchase_cost{style: 'display:none;'}= f.object.purchase_cost + %fieldset %legend{style: 'font-size: medium;'} Grants %label#grants-error.error From f59b70646229906500ad909da89a673935644df2 Mon Sep 17 00:00:00 2001 From: Derek Edwards Date: Mon, 6 Apr 2020 10:29:22 -0400 Subject: [PATCH 7/8] Update version. --- lib/transam_accounting/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transam_accounting/version.rb b/lib/transam_accounting/version.rb index 12eec244..a12acfd3 100644 --- a/lib/transam_accounting/version.rb +++ b/lib/transam_accounting/version.rb @@ -1,3 +1,3 @@ module TransamAccounting - VERSION = "2.10.0-rc.1" + VERSION = "2.10.0-rc.2" end From c46f8ccdaa2a21ae8427313328c137cf1509a0c7 Mon Sep 17 00:00:00 2001 From: Derek Edwards Date: Fri, 24 Apr 2020 19:49:36 -0400 Subject: [PATCH 8/8] Update version. --- lib/transam_accounting/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transam_accounting/version.rb b/lib/transam_accounting/version.rb index a12acfd3..42058219 100644 --- a/lib/transam_accounting/version.rb +++ b/lib/transam_accounting/version.rb @@ -1,3 +1,3 @@ module TransamAccounting - VERSION = "2.10.0-rc.2" + VERSION = "2.10.0" end