Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SJ - Fixing indirect cost validation [#152641470] #1184

Merged
merged 5 commits into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/models/protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Protocol < ApplicationRecord
validates :research_master_id, numericality: { only_integer: true }, allow_blank: true
validates :research_master_id, presence: true, if: :rmid_requires_validation?

validates :indirect_cost_rate, numericality: { greater_than_or_equal_to: 1, less_than_or_equal_to: 1000 }, allow_blank: true
validates :indirect_cost_rate, numericality: { greater_than_or_equal_to: 1, less_than_or_equal_to: 1000 }, allow_blank: true, if: :indirect_cost_enabled

attr_accessor :requester_id
attr_accessor :validate_nct
Expand Down Expand Up @@ -552,6 +552,10 @@ def has_incomplete_additional_details?

private

def indirect_cost_enabled
Setting.find_by_key('use_indirect_cost').value
end

def notify_remote_around_update?
true
end
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20171107195635_correct_bad_indirect_cost_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CorrectBadIndirectCostData < ActiveRecord::Migration[5.1]
def change
protocols = Protocol.where(indirect_cost_rate: 0.0)
protocols.each do |protocol|
protocol.indirect_cost_rate = nil
protocol.save(validate: false)
end
end
end
6 changes: 3 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20171025145319) do
ActiveRecord::Schema.define(version: 20171107195635) do

create_table "admin_rates", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin" do |t|
t.integer "line_item_id"
Expand Down Expand Up @@ -488,7 +488,7 @@
t.index ["sub_service_request_id"], name: "index_payments_on_sub_service_request_id"
end

create_table "permissible_values", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin" do |t|
create_table "permissible_values", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "key"
t.string "value"
t.string "concept_code"
Expand Down Expand Up @@ -810,7 +810,7 @@
t.index ["updated_at"], name: "index_sessions_on_updated_at"
end

create_table "settings", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin" do |t|
create_table "settings", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "key"
t.text "value"
t.string "data_type"
Expand Down