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 - Direct Cost Made Configurable #861

Merged
merged 8 commits into from
Jan 10, 2017
5 changes: 1 addition & 4 deletions app/assets/javascripts/service_calendar.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,12 @@ calculate_max_rates = (arm_id) ->
direct_total += Math.floor($(visit).data('cents')) / 100.0

indirect_rate = parseFloat($("#indirect_rate").val()) / 100.0
indirect_total = 0
max_total = direct_total + indirect_total
max_total = direct_total * (1 + indirect_rate)

direct_total_display = '$' + (direct_total).toFixed(2)
indirect_total_display = '$' + (Math.floor(indirect_total * 100) / 100).toFixed(2)
max_total_display = '$' + (Math.floor(max_total * 100) / 100).toFixed(2)

$(".arm-calendar-container-#{arm_id}:visible #{column}.max-direct-per-patient").html(direct_total_display)
$(".arm-calendar-container-#{arm_id}:visible #{column}.max-indirect-per-patient").html(indirect_total_display)
$(".arm-calendar-container-#{arm_id}:visible #{column}.max-total-per-patient").html(max_total_display)

getSRId = ->
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/service_calendar.sass
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ th.visit-group-box
.maximum-total-indirect-cost-per-patient,
.maximum-total-per-patient,
.total-per-patient-per-visit-cost-per-study,
.total-direct-one-time-fee-cost-per-study,
.total-one-time-fee-cost-per-study,
.total-cost-per-arm,
.total-cost-one-time-fees,
Expand Down
6 changes: 0 additions & 6 deletions app/helpers/service_calendar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ def display_max_total_direct_cost_per_patient arm, line_items_visits=nil
currency_converter sum
end

def display_max_total_indirect_cost_per_patient arm, line_items_visits=nil
line_items_visits ||= arm.line_items_visits
sum = arm.maximum_indirect_costs_per_patient line_items_visits
currency_converter sum
end

def display_max_total_cost_per_patient arm, line_items_visits=nil
line_items_visits ||= arm.line_items_visits
sum = arm.maximum_total_per_patient line_items_visits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@
= display_total_cost_per_arm(arm, arm.line_items_visits)
%tr.total-cost-one-time-fees
%th{ colspan: 10 }
= t(:calendars)[:otf][:totals][:total_direct]
= t(:calendars)[:otf][:totals][:total_costs]
%td.text-center{ colspan: 2 }
= display_total_direct_cost_per_study_otfs(service_request, service_request.line_items)
= display_total_cost_per_study_otfs(service_request, service_request.line_items)
%tr.bg-primary
%td{ colspan: 13 }
- if USE_INDIRECT_COST
%tr.total-direct-cost
%th{ colspan: 10 }
= t(:calendar_page)[:labels][:direct_cost]
%td.text-center{ colspan: 2 }
= display_study_grand_total_direct_costs(service_request.protocol, service_request)
%tr.grand-total-cost
%th{ colspan: 10 }
= t(:calendars)[:merged_totals][:grand_total]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,4 @@
= display_one_time_fee_direct_cost(line_item)

- unless review
%tr.total-one-time-fee-cost-per-study
%th{ colspan: 11 }
= t(:calendars)[:otf][:totals][:total_direct]
%td.text-center
= display_total_direct_cost_per_study_otfs(service_request, service_request.line_items)
= render 'service_calendars/master_calendar/otf/otf_totals', service_request: service_request
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-# Copyright © 2011 MUSC Foundation for Research Development
-# All rights reserved.

-# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

-# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

-# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided with the distribution.

-# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
-# derived from this software without specific prior written permission.

-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
-# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- if USE_INDIRECT_COST
%tr.total-direct-one-time-fee-cost-per-study
%th{ colspan: 11 }
= t(:calendars)[:otf][:totals][:total_direct]
%td.text-center
= display_total_direct_cost_per_study_otfs(service_request, service_request.line_items)
%tr.total-one-time-fee-cost-per-study
%th{ colspan: 11 }
= t(:calendars)[:otf][:totals][:total_costs]
%td.text-center
= display_total_cost_per_study_otfs(service_request, service_request.line_items)
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,15 @@
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%tr.maximum-total-direct-cost-per-patient{ class: "arm-#{arm.id} " }
%td.col-sm-5{ colspan: tab == 'template' ? 8 : 7 }
%strong
= t(:calendars)[:pppv][:totals][:maximum_direct]
- 5.times do |i|
%td.col-sm-1.text-center{ class: "max-direct-per-patient visit-#{i+1}" }
%td.col-sm-1.text-center
= display_max_total_direct_cost_per_patient(arm, line_items_visits)
%td.col-sm-1.text-center

- if USE_INDIRECT_COST
%tr.maximum-total-indirect-cost-per-patient{ class: "arm-#{arm.id} " }
%tr.maximum-total-direct-cost-per-patient{ class: "arm-#{arm.id} " }
%td.col-sm-5{ colspan: tab == 'template' ? 8 : 7 }
%strong
= t(:calendars)[:pppv][:totals][:maximum_indirect]
= t(:calendars)[:pppv][:totals][:maximum_direct]
- 5.times do |i|
%td.col-sm-1.text-center{ class: "max-indirect-per-patient visit-#{i+1}" }
%td.col-sm-1.text-center{ class: "max-direct-per-patient visit-#{i+1}" }
%td.col-sm-1.text-center
= display_max_total_indirect_cost_per_patient(arm, line_items_visits)
= display_max_total_direct_cost_per_patient(arm, line_items_visits)
%td.col-sm-1.text-center

%tr.maximum-total-per-patient{ class: "arm-#{arm.id} " }
Expand Down
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ en:
percent: "Edit Effort Billing Qty"
totals:
maximum_direct: "Maximum Total Direct Costs Per Patient"
maximum_indirect: "Maximum Total Indirect Costs Per Patient"
maximum_per_patient: "Maximum Total Per Patient"
total_costs: "Total Costs (Per Patient/Visit Services) Per Study -- %{arm_name}"
otf:
Expand All @@ -196,7 +195,8 @@ en:
quantity: "Edit Qty"
unit_quantity: "Edit Units per Qty"
totals:
total_direct: "Total Costs (One Time Fee Services) Per Study"
total_direct: "Total Direct Costs (One Time Fee Services) Per Study"
total_costs: "Total Costs (One Time Fee Services) Per Study"
merged_totals:
header: "Study Cost Totals"
grand_total: "Grand Total"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright © 2011-2016 MUSC Foundation for Research Development
# All rights reserved.

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'rails_helper'

RSpec.describe '/service_calendar/master_calendar/_merged_grand_totals', type: :view do

let_there_be_lane

before(:each) do
@protocol = create(:unarchived_study_without_validations, id: 1, primary_pi: jug2)
@service_request = create(:service_request_without_validations, protocol: @protocol)
@arm1 = create(:arm, protocol: @protocol, name: 'Left Arm')
@arm2 = create(:arm, protocol: @protocol, name: 'Right Arm')
@visit_group1 = create(:visit_group, arm: @arm1)
@visit_group2 = create(:visit_group, arm: @arm2)
end

it 'should display total cost per arm for each arm' do
render "/service_calendars/master_calendar/merged_grand_totals", service_request: @service_request

expect(response).to have_content("Total Costs (Per Patient/Visit Services) Per Study -- #{@arm1.name}")
expect(response).to have_content("Total Costs (Per Patient/Visit Services) Per Study -- #{@arm2.name}")
end

it 'should display total costs for one time fee services' do
render "/service_calendars/master_calendar/merged_grand_totals", service_request: @service_request

expect(response).to have_content('Total Costs (One Time Fee Services) Per Study')
end

it 'should display total direct cost if USE_INDIRECT_COST is true' do
stub_const("USE_INDIRECT_COST", true)
render "/service_calendars/master_calendar/merged_grand_totals", service_request: @service_request

expect(response).to have_content('Total Direct Cost')
end

it 'should not display total direct cost if USE_INDIRECT_COST is false' do
stub_const("USE_INDIRECT_COST", false)
render "/service_calendars/master_calendar/merged_grand_totals", service_request: @service_request

expect(response).to_not have_content('Total Direct Cost')
end

it 'should display the grand total' do
render "/service_calendars/master_calendar/merged_grand_totals", service_request: @service_request

expect(response).to have_content('Grand Total')
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright © 2011-2016 MUSC Foundation for Research Development
# All rights reserved.

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'rails_helper'

RSpec.describe '/service_calendar/master_calendar/otf/_otf_totals', type: :view do

let_there_be_lane

before(:each) do
@protocol = create(:unarchived_study_without_validations, id: 1, primary_pi: jug2)
@service_request = create(:service_request_without_validations, protocol: @protocol)
end

it 'should display total direct costs for one time fee services if USE_INDIRECT_COST is true' do
stub_const("USE_INDIRECT_COST", true)
render "/service_calendars/master_calendar/otf/otf_totals", service_request: @service_request

expect(response).to have_content('Total Direct Costs (One Time Fee Services) Per Study')
end

it 'should not display total direct costs for one time fee services if USE_INDIRECT_COST is false' do
stub_const("USE_INDIRECT_COST", false)
render "/service_calendars/master_calendar/otf/otf_totals", service_request: @service_request

expect(response).to_not have_content('Total Direct Costs (One Time Fee Services) Per Study')
end

it 'should display total one time fees costs' do
render "/service_calendars/master_calendar/otf/otf_totals", service_request: @service_request

expect(response).to have_content('Total Costs (One Time Fee Services) Per Study')
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright © 2011-2016 MUSC Foundation for Research Development
# All rights reserved.

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'rails_helper'

RSpec.describe '/service_calendar/master_calendar/pppv/_pppv_totals', type: :view do

let_there_be_lane

before(:each) do
@protocol = create(:unarchived_study_without_validations, id: 1, primary_pi: jug2)
@service_request = create(:service_request_without_validations, protocol: @protocol)
@arm = create(:arm, protocol: @protocol, name: 'Arm')
@visit_group1 = create(:visit_group, arm: @arm)
@liv = []
end

it 'should display maximum total direct cost per patient if USE_INDIRECT_COST is true' do
stub_const("USE_INDIRECT_COST", true)
render "/service_calendars/master_calendar/pppv/pppv_totals", tab: 'calendar', arm: @arm, line_items_visits: @liv

expect(response).to have_content('Maximum Total Direct Costs Per Patient')
end

it 'should not display maximum total direct cost per patient if USE_INDIRECT_COST is false' do
stub_const("USE_INDIRECT_COST", false)
render "/service_calendars/master_calendar/pppv/pppv_totals", tab: 'calendar', arm: @arm, line_items_visits: @liv

expect(response).to_not have_content('Maximum Total Direct Costs Per Patient')
end

it 'should display maximum total cost per patient' do
render "/service_calendars/master_calendar/pppv/pppv_totals", tab: 'calendar', arm: @arm, line_items_visits: @liv

expect(response).to have_content('Maximum Total Per Patient')
end

it 'should not display total cost per arm' do
render "/service_calendars/master_calendar/pppv/pppv_totals", tab: 'calendar', arm: @arm, line_items_visits: @liv

expect(response).to have_content("Total Costs (Per Patient/Visit Services) Per Study -- #{@arm.name}")
end
end