Skip to content

Commit

Permalink
Merge pull request #792 from sparc-request/sj-admin_cost_changes_2
Browse files Browse the repository at this point in the history
part two changes to cost in admin edit [#133937453[
  • Loading branch information
jleonardw9 committed Dec 9, 2016
2 parents 8ad2880 + 1c01454 commit ebb80fd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/helpers/dashboard/sub_service_requests_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def user_display_total sub_service_request
return (sub_service_request.direct_cost_total / 100.0)
end

def user_display_protocol_total protocol, service_request
return (protocol.grand_total(service_request) / 100.0)
end

def effective_current_total sub_service_request
sub_service_request.set_effective_date_for_cost_calculations
total = (sub_service_request.direct_cost_total / 100.0)
Expand Down
4 changes: 2 additions & 2 deletions app/views/dashboard/sub_service_requests/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
%th
= t(:dashboard)[:sub_service_requests][:header][:fulfillment][:header]
%th
= t(:dashboard)[:sub_service_requests][:header][:cost]
= "#{sub_service_request.organization.abbreviation} #{t(:dashboard)[:sub_service_requests][:header][:cost]}"
%th
= t(:dashboard)[:sub_service_requests][:header][:user_cost]

Expand All @@ -58,4 +58,4 @@
%td.effective_cost
= number_to_currency(effective_current_total(sub_service_request))
%td.display_cost
= number_to_currency(user_display_total(sub_service_request))
= number_to_currency(user_display_protocol_total(sub_service_request.protocol, sub_service_request.service_request))
4 changes: 2 additions & 2 deletions config/locales/dashboard.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ en:
in_fulfillment: "In Fulfillment"
send_to_fulfillment: "Send to Fulfillment"
not_enabled: "Not enabled in SPARCCatalog."
cost: "Current Cost"
user_cost: "User Display Cost"
cost: "Cost"
user_cost: "Total Cost"

tabs:
request_details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
RSpec.describe 'dashboard/sub_service_requests/_header', type: :view do
include RSpecHtmlMatchers

before(:each) { stub_const("CLINICAL_WORK_FULFILLMENT_URL", "www.future-url.org") }
before(:each) do
stub_const("CLINICAL_WORK_FULFILLMENT_URL", "www.future-url.org")
allow(view).to receive(:user_display_protocol_total).and_return(100)
end

describe "status dropdown" do
it "should be populated with statuses from associated Organization" do
Expand Down Expand Up @@ -217,7 +220,7 @@

render "dashboard/sub_service_requests/header", sub_service_request: sub_service_request

expect(response).to have_tag("td.display_cost", text: /\$543\.20/)
expect(response).to have_tag("td.display_cost", text: /\$100\.00/)
end

def stub_protocol
Expand Down Expand Up @@ -246,6 +249,7 @@ def stub_sub_service_request(opts = {})
expect(d).to receive(:unset_effective_date_for_cost_calculations) do
allow(d).to receive(:direct_cost_total).and_return(displayed_cost)
end
allow(d).to receive(:service_request)

d
end
Expand All @@ -254,6 +258,7 @@ def stub_organization(opts = {})
default_statuses = { "draft" => "Draft", "not_draft" => "NotDraft" }
instance_double(Organization,
name: "MegaCorp",
abbreviation: "MC",
get_available_statuses: opts[:get_available_statuses].nil? ? default_statuses : opts[:get_available_statuses])
end

Expand Down

0 comments on commit ebb80fd

Please sign in to comment.