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

JM - (SPARCFulfillment) Ability to Forfeit Charges #665

Merged
merged 4 commits into from
Mar 5, 2020
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
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@
//= require visit_group_form
//= require imports
//= require fulfillments
//= require procedures
1 change: 0 additions & 1 deletion app/assets/javascripts/appointments.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,3 @@ $ ->
$(document).on 'click', '.disabled-status.btn-group .btn.disabled ', (e) ->
e.stopPropagation()
alert(I18n["appointment"]["procedure_invoiced_warning"])

1 change: 0 additions & 1 deletion app/assets/javascripts/fulfillments.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ $(document).on 'click', '.otf_fulfillment_delete', ->
$.ajax
type: 'delete'
url: "/fulfillments/#{$(this).data('id')}.js"

41 changes: 41 additions & 0 deletions app/assets/javascripts/procedures.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright © 2011-2019 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.~

$(document).on 'change', 'input.toggle_invoice_procedure', ->
invoiced = $(this).prop('checked')
procedure_id = $(this).data('id')
$.ajax
type: 'PUT'
url: "/procedures/#{procedure_id}.js"
data:
procedure:
invoiced: invoiced
credited: !invoiced

$(document).on 'change', 'input.toggle_credit_procedure', ->
credited = $(this).prop('checked')
procedure_id = $(this).data('id')
$.ajax
type: 'PUT'
url: "/procedures/#{procedure_id}.js"
data:
procedure:
credited: credited
invoiced: !credited
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.sass
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
@import 'reports'
@import 'header'
@import 'imports'
@import 'appointments'

.overflow_webkit_button
-ms-overflow-style: none
Expand Down
24 changes: 24 additions & 0 deletions app/assets/stylesheets/appointments.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright © 2011-2019 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.~

.disabled_tooltip {
padding: 6px 12px;
margin: -6px -12px;
}
8 changes: 0 additions & 8 deletions app/assets/stylesheets/study_level_activities.sass
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,3 @@ td.wrap

.invoiced .btn-group
width: 95px

.credited .toggle-group .toggle-on
background-color: #5cb85c
border-color: #4cae4c

.credited .btn-primary
background-color: #5cb85c
border-color: #4cae4c
2 changes: 2 additions & 0 deletions app/controllers/fulfillments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ def update
def toggle_invoiced
persist_original_attributes_to_track_changes
@fulfillment.update_attributes(invoiced: fulfillment_params[:invoiced])
@fulfillment.update_attributes(credited: !fulfillment_params[:invoiced])
detect_changes_and_create_notes
end

def toggle_credit
persist_original_attributes_to_track_changes
@fulfillment.update_attributes(credited: fulfillment_params[:credited])
@fulfillment.update_attributes(invoiced: !fulfillment_params[:credited])
detect_changes_and_create_notes
end

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def procedure_params
:completed_date,
:billing_type,
:performer_id,
:invoiced,
:credited,
notes_attributes: [:comment, :kind, :identity_id, :reason],
tasks_attributes: [:assignee_id, :identity_id, :body, :due_at])
end
Expand Down
10 changes: 9 additions & 1 deletion app/helpers/appointment_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ def procedure_notes_formatter(procedure)
button_class: "#{procedure.appt_started? ? '' : 'disabled'}"})
end

def procedures_invoiced_or_credited?(appointment)
appointment.procedures.any?{ |procedure| procedure.invoiced == true || procedure.credited == true }
end

def procedures_invoiced?(appointment)
appointment.procedures.any?{|procedure| procedure.invoiced == true}
appointment.procedures.any?{ |procedure| procedure.invoiced == true }
end

def procedures_credited?(appointment)
appointment.procedures.any?{ |procedure| procedure.credited == true }
end
end
12 changes: 10 additions & 2 deletions app/helpers/study_level_activities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ def toggle_invoiced(fulfillment)
end
end

def toggle_credited(fulfillment)
if current_identity.billing_manager_protocols_allow_credit.include?(fulfillment.protocol)
credit_toggle_button(fulfillment)
else
credit_read_only(fulfillment)
end
end

def invoice_read_only(fulfillment)
(fulfillment.invoiced? ? "Yes" : "No")
end
Expand Down Expand Up @@ -139,11 +147,11 @@ def fulfillment_date_formatter(fulfillment)
private

def invoice_toggle_button(fulfillment)
content_tag(:input, '', type: "checkbox", name: "invoiced", checked: fulfillment.invoiced?, data: {toggle: 'toggle', on: "Yes", off: "No", id: fulfillment.id}, disabled: fulfillment.invoiced?, class: 'invoice_toggle')
content_tag(:input, '', type: "checkbox", name: "invoiced", checked: fulfillment.invoiced?, data: {toggle: 'toggle', on: "Yes", off: "No", id: fulfillment.id}, disabled: fulfillment.invoiced? || fulfillment.credited?, class: 'invoice_toggle')
end

def credit_toggle_button(fulfillment)
content_tag(:input, '', type: "checkbox", name: "credited", checked: fulfillment.credited?, data: {toggle: 'toggle', on: "Yes", off: "No", id: fulfillment.id}, disabled: fulfillment.credited?, class: 'credit_toggle')
content_tag(:input, '', type: "checkbox", name: "credited", checked: fulfillment.credited?, data: {toggle: 'toggle', on: "Yes", off: "No", id: fulfillment.id}, disabled: fulfillment.credited? || fulfillment.invoiced?, class: 'credit_toggle')
end

def note_list_item(params)
Expand Down
10 changes: 9 additions & 1 deletion app/views/appointments/_core.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@
= t(:procedure)[:performed_by]
%th.notes
= t(:procedure)[:notes]
- if procedures_invoiced?(appointment)
- if current_identity.billing_manager_protocols.include?(appointment.protocol)
%th.invoiced
= t(:procedure)[:invoiced]
%th.credited
= t(:procedure)[:credited]
- else
%th.invoiced
= t(:procedure)[:invoiced]
%th.credited
= t(:procedure)[:credited]
%th.remove
= t(:procedure)[:remove]

%tbody
= render partial: 'appointments/procedure', collection: procedures, as: :procedure
26 changes: 18 additions & 8 deletions app/views/appointments/_procedure.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.~

%tr.procedure.new_service{ data: { id: procedure.id, service_id: procedure.service_id, billing_type: procedure.billing_type, group_id: procedure.group_id, disabled: procedure.invoiced? ? 'true' : 'false' } }
%td.name{class: "#{procedures_invoiced?(procedure.appointment) ? 'col-sm-1' : 'col-sm-2'} #{procedure.invoiced? ? 'disabled-status' : ''}"}
%td.name{class: "#{procedures_invoiced_or_credited?(procedure.appointment) || current_identity.billing_manager_protocols.include?(procedure.protocol) ? 'col-sm-1' : 'col-sm-2'} #{procedure.invoiced? ? 'disabled-status' : ''}"}
= service_name_display(procedure.service)
%td.col-sm-1.billing
= select_tag "quantity_type_#{procedure.id}", options_for_select(Procedure.billing_display, procedure.billing_type), class: procedure.invoiced? ? "form-control billing_type selectpicker disable-select-box invoiced_disabled " : "form-control billing_type selectpicker", disabled: procedure.invoiced?
Expand All @@ -34,16 +34,26 @@
%td.col-sm-1.completed-date
.input-group.date{class: procedure.invoiced? ? "invoiced_disabled" : ""}
%input.datetimepicker{type: "text", class: "form-control completed_date_field", disabled: !(procedure.appt_started? && procedure.complete?) || procedure.invoiced?, value: format_date(procedure.completed_date), readonly: true}
%td.performed-by{class: procedures_invoiced?(procedure.appointment) ? "col-sm-1" : "col-sm-2"}
%td.performed-by{class: procedures_invoiced_or_credited?(procedure.appointment) || current_identity.billing_manager_protocols.include?(procedure.protocol) ? "col-sm-1" : "col-sm-2"}
= select_tag "performed-by-#{procedure.id}", options_for_select(procedure.performable_by, procedure.performer_id), include_blank: "N/A", class: procedure.invoiced? ? "performed-by-dropdown selectpicker disable-select-box invoiced_disabled" : "performed-by-dropdown selectpicker", data: { width: '125px' }, 'showIcon' => false, disabled: procedure.invoiced?
%td.col-sm-1.notes
-# div used for capturing click events when button is disabled
.btn-group{ class: "#{ procedure.appt_started? ? '' : 'pre_start_disabled' }" }
= procedure_notes_formatter(procedure)
- if procedures_invoiced?(procedure.appointment)
%td.col-sm-2.invoiced
- if current_identity.billing_manager_protocols.include?(procedure.protocol)
%td.col-sm-1.invoiced_toggle
= check_box_tag :invoiced_procedure, '', procedure.invoiced?, class: 'toggle_invoice_procedure', disabled: !procedure.complete? || procedure.invoiced? || procedure.credited?, data: { toggle: 'toggle', id: procedure.id, on: 'Yes', off: 'No' }
- if current_identity.billing_manager_protocols_allow_credit.include?(procedure.protocol)
%td.col-sm-1.credited_toggle
= check_box_tag :credited_procedure, '', procedure.credited?, class: 'toggle_credit_procedure', disabled: !procedure.complete? || procedure.invoiced? || procedure.credited?, data: { toggle: 'toggle', id: procedure.id, on: 'Yes', off: 'No' }
- else
%td.col-sm-2.credited_view_only
= (procedure.credited? ? "Yes" : "No")
- else
%td.col-sm-2.invoiced_view_only
= (procedure.invoiced? ? "Yes" : "No")
- unless procedure.invoiced?
%td.col-sm-1.remove
%button.btn.btn-danger.delete{type: "button", aria: {label: "Remove Procedure"}}
%span.glyphicon.glyphicon-remove{aria: {hidden: "true"}}
%td.col-sm-2.credited_view_only
= (procedure.credited? ? "Yes" : "No")
%td.col-sm-1.remove
%button.btn.btn-danger.delete{type: "button", disabled: procedure.invoiced? || procedure.credited?, aria: {label: "Remove Procedure"}}
%span.glyphicon.glyphicon-remove.disabled_tooltip{aria: {hidden: "true"}, title: procedure.invoiced? ? t(:appointment)[:procedure_disabled_invoiced] : procedure.credited? ? t(:appointment)[:procedure_disabled_credited] : ''}
5 changes: 3 additions & 2 deletions app/views/appointments/_start_complete_buttons.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
.col-xs-6
= text_field_tag 'start_date', '', class: 'form-control', readonly: true
.col-xs-1.reset_button
%button.btn.btn-warning.reset_visit{type: "button", class: hidden_class(procedures_invoiced?(appointment))}= t(:appointment)[:reset_visit]
/ %button.btn.btn-warning.reset_visit{type: "button", class: "#{procedures_invoiced?(appointment) ? 'disabled' : ''}"}= t(:appointment)[:reset_visit]
%button.btn.btn-warning.reset_visit{type: "button", disabled: procedures_invoiced_or_credited?(appointment), data: {toggle: "tooltip", animation: 'false'} }
%span.disabled_tooltip{title: (procedures_invoiced?(appointment) && procedures_credited?(appointment)) ? t(:appointment)[:reset_visit_disabled_credited_and_invoiced] : procedures_invoiced?(appointment) ? t(:appointment)[:reset_visit_disabled_invoiced] : procedures_credited?(appointment) ? t(:appointment)[:reset_visit_disabled_credited] : ''}
= t(:appointment)[:reset_visit]

.start_date_btn{class: hidden_class(!appointment.start_date.blank?) }
%button.btn.btn-success.start_visit= t(:appointment)[:start_visit]
Expand Down
3 changes: 3 additions & 0 deletions app/views/appointments/show.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ $('.row.appointment [data-toggle="tooltip"]').tooltip()
<% if @refresh_dashboard %>
$('table#completed-appointments-table').bootstrapTable('refresh', {url: "/appointments/completed_appointments.json?protocols_participant_id=<%= @appointment.protocols_participant_id %>", silent: "true"})
<% end %>

$('input#invoiced_procedure').bootstrapToggle()
$('input#credited_procedure').bootstrapToggle()
2 changes: 1 addition & 1 deletion app/views/fulfillments/_fulfillment.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ json.performed_by fulfillment.performer.full_name if fulfillment.pe
json.components fulfillment_components_formatter(fulfillment.components)
json.options fulfillment_options_buttons(fulfillment)
json.invoiced toggle_invoiced(fulfillment)
json.credited credit_toggle_button(fulfillment)
json.credited toggle_credited(fulfillment)
json.export_credited credit_read_only(fulfillment)
json.export_invoiced invoice_read_only(fulfillment)
json.notes notes(fulfillment.notes)
Expand Down
6 changes: 6 additions & 0 deletions app/views/fulfillments/index.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ $('#fulfillments-table').on 'column-switch.bs.table', (e, field, checked) ->
$('input.invoice_toggle').bootstrapToggle()
if field == 'credited' && checked == true
$('input.credit_toggle').bootstrapToggle()

$('.fulfillments-list .table-responsive').on 'show.bs.dropdown', ->
$('.table-responsive').css 'overflow', 'inherit'

$('.fulfillments-list .table-responsive').on 'hide.bs.dropdown', ->
$('.table-responsive').css 'overflow', 'auto'
3 changes: 3 additions & 0 deletions app/views/procedures/create.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ $(".completed_date_field").datetimepicker
ignoreReadonly: true

update_complete_visit_button(<%= @appointment.can_finish? %>)

$('input#invoiced_procedure').bootstrapToggle()
$('input#credited_procedure').bootstrapToggle()
3 changes: 3 additions & 0 deletions app/views/procedures/update.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@ $("#modal_place").modal 'hide'
swal("<%= @cost_error_message %>")
<% end %>
<% end %>

$('input#invoiced_procedure').bootstrapToggle()
$('input#credited_procedure').bootstrapToggle()
10 changes: 4 additions & 6 deletions app/views/study_level_activities/_fulfillments_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@
= t(:fulfillment)[:components]
%th{data: {class: 'options exclude_in_export', align: "center", field: "options"}}
= t(:actions)[:actions]
- if line_item.fulfillments.any?{|fulfillment| fulfillment.invoiced == true} || current_identity.billing_manager_protocols.include?(line_item.protocol)
%th{data: {class: 'invoiced exclude_in_export', align: "center", field: "invoiced"}}
= t(:fulfillment)[:invoiced]
- if current_identity.billing_manager_protocols_allow_credit.include?(line_item.protocol)
%th{data: {class: 'credited exclude_in_export', align: "center", field: "credited"}}
= t(:fulfillment)[:credited]
%th{data: {class: 'invoiced exclude_in_export', align: "center", field: "invoiced"}}
= t(:fulfillment)[:invoiced]
%th{data: {class: 'credited exclude_in_export', align: "center", field: "credited"}}
= t(:fulfillment)[:credited]
%th{data: {class: 'export_credited hidden', align: "center", field: "export_credited"}}
= t(:fulfillment)[:credited]
%th{data: {class: 'export_invoiced hidden', align: "center", field: "export_invoiced"}}
Expand Down
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ en:
protocol_id: "Protocol ID"
reason: "Reason"
reset_visit: "Reset Visit"
reset_visit_disabled_invoiced: "A procedure within this visit has been invoiced and cannot be altered."
reset_visit_disabled_credited: "A procedure within this visit has been credited and cannot be altered."
reset_visit_disabled_credited_and_invoiced: "A procedure within this visit has been credited or invoiced and cannot be altered."
service_error: 'Please choose the service that is desired to be added'
srid: "SRID"
start_date: "Start Date:"
Expand All @@ -98,6 +101,8 @@ en:
visit_indications: "Visit Indications:"
visit_type: "Type of Visit:"
warning: "Please click 'Start Visit' and enter a start date to continue."
procedure_disabled_credited: "This item cannot be removed because it is credited."
procedure_disabled_invoiced: "This item cannot be removed because it is invoiced."
procedure_invoiced_warning: "This procedure has been invoiced and cannot be altered."
procedure_group_invoiced_warning: "This group of procedures have been invoiced and cannot be altered."

Expand Down Expand Up @@ -301,6 +306,7 @@ en:
object: "Procedure"
complete: "Complete All"
completed_date: "Completed Date"
credited: "Credited"
edit_header: "Follow Up"
followup: "Follow Up"
follow_up_date: "Follow Up Date"
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20200205133947_add_credited_to_procedures.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCreditedToProcedures < ActiveRecord::Migration[5.2]
def change
add_column :procedures, :credited, :boolean
end
end
3 changes: 2 additions & 1 deletion 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: 2020_01_13_023916) do
ActiveRecord::Schema.define(version: 2020_02_05_133947) do

create_table "appointment_statuses", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin", force: :cascade do |t|
t.string "status"
Expand Down Expand Up @@ -235,6 +235,7 @@
t.datetime "incompleted_date"
t.boolean "invoiced"
t.string "funding_source"
t.boolean "credited"
t.index ["appointment_id"], name: "index_procedures_on_appointment_id"
t.index ["completed_date"], name: "index_procedures_on_completed_date"
t.index ["service_id"], name: "index_procedures_on_service_id"
Expand Down