Skip to content

Commit

Permalink
Merge pull request #586 from sparc-request/jtm_reconfig_completed_ssr_p1
Browse files Browse the repository at this point in the history
Jtm reconfig completed ssr p1
  • Loading branch information
amcates committed Jul 27, 2016
2 parents 4c2cb7e + 6bacb6e commit 82505fb
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/portal/sub_service_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def update_from_fulfillment
if @sub_service_request.update_attributes(params[:sub_service_request])
@sub_service_request.update_based_on_status(saved_status)
@sub_service_request.generate_approvals(@user, params)
@sub_service_request.distribute_surveys if @sub_service_request.status == 'complete' and @sub_service_request.status != saved_status #status is complete and it was something different before
@sub_service_request.distribute_surveys if @sub_service_request.is_complete? and @sub_service_request.status != saved_status #status is complete and it was something different before
@service_request = @sub_service_request.service_request
@protocol = @service_request.protocol
@approvals = [@service_request.approvals, @sub_service_request.approvals].flatten
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SearchController < ApplicationController
def services
term = params[:term].strip
service_request = ServiceRequest.find(session[:service_request_id])
locked_ssrs = service_request.sub_service_requests.reject{ |ssr| ssr.can_be_edited? }
locked_ssrs = service_request.sub_service_requests.reject{ |ssr| ssr.can_be_edited? && ssr.is_complete?}
locked_org_ids = locked_ssrs.map(&:organization_id)
locked_child_ids = Organization.authorized_child_organizations(locked_org_ids).map(&:id)

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/service_calendars_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Copyright © 2011 MUSC Foundation for Research Development
# All rights reserved.

Expand Down Expand Up @@ -269,7 +270,7 @@ def toggle_calendar_column
next unless @sub_service_request.nil? || @sub_service_request.organization.name == value[:process_ssr_organization_name]

@arm.line_items_visits.each do |liv|
next unless value[:line_items].include?(liv.line_item)
next unless value[:line_items].include?(liv.line_item) && liv.line_item.sub_service_request.can_be_edited? && !liv.line_item.sub_service_request.is_complete?
visit = liv.visits[column_id - 1] # columns start with 1 but visits array positions start at 0
if params[:check]
visit.update_attributes quantity: liv.line_item.service.displayed_pricing_map.unit_minimum, research_billing_qty: liv.line_item.service.displayed_pricing_map.unit_minimum, insurance_billing_qty: 0, effort_billing_qty: 0
Expand Down
1 change: 0 additions & 1 deletion app/controllers/service_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ def save_and_exit
update_service_request_status(@service_request, 'draft')
@service_request.ensure_ssr_ids
end

redirect_to dashboard_root_path
end

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/dashboard/sub_service_requests_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def ssr_view_button(ssr)

def ssr_edit_button(ssr, user, permission_to_edit)
# The SSR must not be locked, and the user must either be an authorized user or an authorized admin
if ssr.can_be_edited? && permission_to_edit
if ssr.can_be_edited? && permission_to_edit && ssr.is_complete?
content_tag(:button, t(:dashboard)[:service_requests][:actions][:edit], class: 'edit-service-request btn btn-warning btn-sm', type: 'button', data: { permission: permission_to_edit.to_s, url: "/service_requests/#{ssr.service_request.id}/catalog?sub_service_request_id=#{ssr.id}"})
else
''
Expand Down
3 changes: 1 addition & 2 deletions app/models/service_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,7 @@ def update_status(new_status, use_validation=true)
self.assign_attributes(status: new_status)

self.sub_service_requests.each do |ssr|
next unless ssr.can_be_edited?

next unless ssr.can_be_edited? && !ssr.is_complete?
available = AVAILABLE_STATUSES.keys
editable = EDITABLE_STATUSES[ssr.organization_id] || available

Expand Down
4 changes: 4 additions & 0 deletions app/models/sub_service_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ def can_be_edited?
end
end

def is_complete?
return status == 'complete'
end

def find_editable_id(id)
parent_ids = Organization.find(id).parents.map(&:id)
EDITABLE_STATUSES.keys.each do |org_id|
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalogs/_cart_line_item.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
-# 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.
.line_item
%div= line_item.service.display_service_abbreviation(line_item)
- if line_item.sub_service_request.can_be_edited?
- if line_item.sub_service_request.can_be_edited? && !line_item.sub_service_request.is_complete?
= link_to(image_tag('cancel.png'), 'javascript:void(0);', :class => 'remove-button', :'data-has_fulfillments' => one_time_fee_fulfillments?(line_item.id), :id => "line_item-#{line_item.id}", :sr_id => "#{@service_request.id}", :ssr_id => "#{@sub_service_request.nil? ? '' : @sub_service_request.id}", :'data-request_submitted' => "#{@service_request.submitted_at?}")

#request_submitted_dialog{style: 'display:none;', title: t(:cart)[:request_submitted1]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
-# 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.section_header

- if merged # display merged calendar otf line items
%th{ colspan: 13 }= t(:calendar_page)[:headers][:other_services]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
%th.otf{ colspan: (@study_tracker) ? 13 : 16 }
= value[:name]
- value[:line_items].each do |line_item|
- locked = !line_item.sub_service_request.can_be_edited?
- locked = !line_item.sub_service_request.can_be_edited? || line_item.sub_service_request.is_complete?
%tr.line_item.otfs{ class: [cycle('odd', '', name: 'otfs'), locked ? 'locked' : ''], :"data-unit_factor" => line_item.service.displayed_pricing_map.unit_factor }
%td.service_name
= line_item.service.name
Expand Down Expand Up @@ -201,7 +201,7 @@
- else
= text_field_tag "service_request[line_items_attributes][#{line_item.id}][quantity]", line_item.quantity, |
unit_minimum: line_item.service.displayed_pricing_map.quantity_minimum, units_per_qty_max: line_item.service.displayed_pricing_map.units_per_qty_max, class: 'line_item_quantity', current_quantity: line_item.quantity, previous_quantity: line_item.quantity, |
update: update_otf_qty_and_units_per_qty_service_request_service_calendars_path(@service_request, line_item_id: line_item.id, type: 'qty') |
update: update_otf_qty_and_units_per_qty_service_request_service_calendars_path(@service_request, line_item_id: line_item.id, type: 'qty')
- else
%td{ colspan: 2 }
%span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
- next unless value[:line_items].include?(line_item)
- line_items_visits << line_items_visit
- pricing_map = line_item.service.displayed_pricing_map
- locked = !line_item.sub_service_request.can_be_edited?
- locked = !line_item.sub_service_request.can_be_edited? || line_item.sub_service_request.is_complete?
%tr.line_item{:'data-line_items_visit_id' => line_items_visit.id, :class => [cycle('odd', '', :name => 'pppvs'), locked ? 'locked' : '']}
- if @portal
- if line_item.service.is_available
Expand Down
3 changes: 1 addition & 2 deletions lib/reports/cohr_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def run



next if not ssr.status == 'complete' || ssr.past_statuses.where(:status => 'complete').count > 0
next if not ssr.status == 'complete'
next if not ssr.is_complete? || ssr.past_statuses.where(:status => 'complete').count > 0
complete_date = li.sub_service_request.past_statuses.try(:last).try(:date)
next if not complete_date
next if @from_date and complete_date <= @from_date
Expand Down

0 comments on commit 82505fb

Please sign in to comment.