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

SAW - Indirect Cost Rate Validation Change #1062

Merged
merged 4 commits into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 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: "RESEARCH_MASTER_ENABLED && has_human_subject_info?"

validates :indirect_cost_rate, numericality: { greater_than_or_equal_to: 0, 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

attr_accessor :requester_id
attr_accessor :validate_nct
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeProtocolIndirectCostRatePrecision < ActiveRecord::Migration[5.1]
def change
change_column :protocols, :indirect_cost_rate, :decimal, precision: 6, scale: 2
end
end
17 changes: 15 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170817141100) do
ActiveRecord::Schema.define(version: 20170818175101) 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 @@ -506,6 +506,19 @@
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_unicode_ci" do |t|
t.string "key"
t.string "value"
t.string "concept_code"
t.integer "parent_id"
t.integer "sort_order"
t.string "category"
t.boolean "default"
t.boolean "reserved"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "pricing_maps", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci" do |t|
t.integer "service_id"
t.string "unit_type"
Expand Down Expand Up @@ -590,7 +603,7 @@
t.text "title"
t.string "sponsor_name"
t.text "brief_description"
t.decimal "indirect_cost_rate", precision: 5, scale: 2
t.decimal "indirect_cost_rate", precision: 6, scale: 2
t.string "study_phase"
t.string "udak_project_number"
t.string "funding_rfa"
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
title { Faker::Lorem.sentence(3) }
sponsor_name { Faker::Lorem.sentence(3) }
brief_description { Faker::Lorem.paragraph(2) }
indirect_cost_rate { Random.rand(1000) }
indirect_cost_rate { Random.rand(1..1000) }
udak_project_number { Random.rand(1000).to_s }
funding_rfa { Faker::Lorem.word }
potential_funding_start_date { Time.now + 1.year }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/protocol/valid?_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
end
end

it { is_expected.to validate_numericality_of(:indirect_cost_rate).is_greater_than_or_equal_to(0) }
it { is_expected.to validate_numericality_of(:indirect_cost_rate).is_greater_than_or_equal_to(1) }
it { is_expected.to validate_numericality_of(:indirect_cost_rate).is_less_than_or_equal_to(1000) }
end