Skip to content

Commit

Permalink
Merge pull request #833 from sparc-request/jjh-ssrs-clash
Browse files Browse the repository at this point in the history
Jjh ssrs clash
  • Loading branch information
jleonardw9 committed Dec 20, 2016
2 parents 2a57ea8 + 9a37ac7 commit 83d8587
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,53 +18,54 @@
-# 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.
- service_request.service_list(true).each do |_, value| # get only one time fee services and group them
- next unless sub_service_request.nil? || sub_service_request.organization.name == value[:process_ssr_organization_name]
- ssr = value[:line_items][0].sub_service_request
- next if ssr.status == 'first_draft' || (!review && consolidated && ssr.status == 'draft')
- locked = !ssr.can_be_edited? && !admin

%tr.organization-header{ class: locked ? 'bg-danger text-danger' : '' }
%th{ colspan: 14 }
= display_org_name(value[:name], ssr, locked)
- value[:line_items].group_by(&:sub_service_request_id).each do |sub_service_request_id, line_items|
- next unless sub_service_request.nil? || sub_service_request.id == sub_service_request_id
- ssr = sub_service_request || SubServiceRequest.find(sub_service_request_id)
- next if ssr.status == 'first_draft' || (!review && consolidated && ssr.status == 'draft')
- locked = !ssr.can_be_edited? && !admin

- value[:line_items].each do |line_item|
- displayed_pricing_map = line_item.service.displayed_pricing_map
- otf_unit_type = displayed_pricing_map.try(:otf_unit_type)
- otf_qty_type = displayed_pricing_map.try(:quantity_type)
%tr.otf-line-item-row{ class: locked ? 'bg-danger text-danger' : '' }
%td.service-name{ colspan: 2 }
= line_item.service.display_service_name
%td.status.text-center
= AVAILABLE_STATUSES[ssr.status]
%td.service-rate.text-center
= display_service_rate(line_item)
%td.your-cost.text-center
= "$#{number_with_precision(Service.cents_to_dollars(line_item.applicable_rate), precision: 2)}"
%tr.organization-header{ class: locked ? 'bg-danger text-danger' : '' }
%th{ colspan: 14 }
= display_org_name(value[:name], ssr, locked)

%td.unit-type-number.text-center{ colspan: 3 }
- if otf_unit_type == 'N/A'
.unit-type
= otf_unit_type
- else
.unit-type.col-sm-6
= otf_unit_type
.units-per-qty.col-sm-6
- if locked || tab == 'calendar'
= line_item.units_per_quantity
- else
%a.edit-units-per-qty{ href: 'javascript:void(0)', data: { name: 'units_per_quantity', title: t(:calendars)[:otf][:editable_fields][:unit_quantity], value: line_item.units_per_quantity, url: line_item_path(line_item, srid: service_request.id) } }
- line_items.each do |line_item|
- displayed_pricing_map = line_item.service.displayed_pricing_map
- otf_unit_type = displayed_pricing_map.try(:otf_unit_type)
- otf_qty_type = displayed_pricing_map.try(:quantity_type)
%tr.otf-line-item-row{ class: locked ? 'bg-danger text-danger' : '' }
%td.service-name{ colspan: 2 }
= line_item.service.display_service_name
%td.status.text-center
= AVAILABLE_STATUSES[ssr.status]
%td.service-rate.text-center
= display_service_rate(line_item)
%td.your-cost.text-center
= "$#{number_with_precision(Service.cents_to_dollars(line_item.applicable_rate), precision: 2)}"

%td.qty-type-number.text-center{ colspan: 3 }
.qty-type.col-sm-6
= otf_qty_type
.qty.col-sm-6
- if locked || tab == 'calendar'
= line_item.quantity
%td.unit-type-number.text-center{ colspan: 3 }
- if otf_unit_type == 'N/A'
.unit-type
= otf_unit_type
- else
%a.edit-qty{ href: 'javascript:void(0)', data: { name: 'quantity', title: t(:calendars)[:otf][:editable_fields][:quantity], value: line_item.quantity, url: line_item_path(line_item, srid: service_request.id) } }
.unit-type.col-sm-6
= otf_unit_type
.units-per-qty.col-sm-6
- if locked || tab == 'calendar'
= line_item.units_per_quantity
- else
%a.edit-units-per-qty{ href: 'javascript:void(0)', data: { name: 'units_per_quantity', title: t(:calendars)[:otf][:editable_fields][:unit_quantity], value: line_item.units_per_quantity, url: line_item_path(line_item, srid: service_request.id) } }

%td.qty-type-number.text-center{ colspan: 3 }
.qty-type.col-sm-6
= otf_qty_type
.qty.col-sm-6
- if locked || tab == 'calendar'
= line_item.quantity
- else
%a.edit-qty{ href: 'javascript:void(0)', data: { name: 'quantity', title: t(:calendars)[:otf][:editable_fields][:quantity], value: line_item.quantity, url: line_item_path(line_item, srid: service_request.id) } }

%td.total-per-study.text-center
= display_one_time_fee_direct_cost(line_item)
%td.total-per-study.text-center
= display_one_time_fee_direct_cost(line_item)

- unless review
%tr.total-one-time-fee-cost-per-study
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
-# 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.
- line_items_visits = []
- Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, service_request, sub_service_request, merged: merged, portal: portal, review: review, consolidated: consolidated).each do |org_name, livs|
- Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, service_request, sub_service_request, merged: merged, portal: portal, review: review, consolidated: consolidated).each do |sub_service_request_id, livs|
- line_items_visits << livs
- ssr = livs[0].sub_service_request
- ssr = SubServiceRequest.find(sub_service_request_id)
- locked = !ssr.can_be_edited? && !admin

-# SSR Header Row
%tr.organization-header{ class: locked ? 'text-danger' : '' }
%th.col-sm-6{ colspan: portal ? 6 : 7 }
= display_org_name(org_name, ssr, locked)
= display_org_name(Dashboard::ServiceCalendars.display_organization_hierarchy(livs[0]), ssr, locked)
- visit_groups.each do
%th.col-sm-1.billing-type-list.text-center
.row
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
-# 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.
- line_items_visits = []
- Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, service_request, sub_service_request, merged: merged, portal: portal, review: review, consolidated: consolidated).each do |org_name, livs|
- Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, service_request, sub_service_request, merged: merged, portal: portal, review: review, consolidated: consolidated).each do |sub_service_request_id, livs|
- line_items_visits << livs
- ssr = livs[0].sub_service_request
- ssr = SubServiceRequest.find(sub_service_request_id)
- locked = !ssr.can_be_edited? && !admin

-# SSR Header Row
%tr.organization-header{ class: locked ? 'text-danger' : '' }
%th{ colspan: 14 }
= display_org_name(org_name, ssr, locked)
= display_org_name(Dashboard::ServiceCalendars.display_organization_hierarchy(livs[0]), ssr, locked)

-# Line Items Visits
- livs.each do |liv|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
-# 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.
- line_items_visits = []
- Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, service_request, sub_service_request, merged: merged, portal: portal, review: review, consolidated: consolidated).each do |org_name, livs|
- Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, service_request, sub_service_request, merged: merged, portal: portal, review: review, consolidated: consolidated).each do |sub_service_request_id, livs|
- line_items_visits << livs
- ssr = livs[0].sub_service_request
- ssr = SubServiceRequest.find(sub_service_request_id)
- locked = !ssr.can_be_edited? && !admin

-# SSR Header Row
%tr.organization-header{ class: locked ? 'text-danger' : '' }
%th{ colspan: 15 }
= display_org_name(org_name, ssr, locked)
= display_org_name(Dashboard::ServiceCalendars.display_organization_hierarchy(livs[0]), ssr, locked)

-# Line Items Visits
- livs.each do |liv|
Expand Down
2 changes: 1 addition & 1 deletion lib/dashboard/service_calendars.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def self.pppv_line_items_visits_to_display(arm, service_request, sub_service_req
joins(line_item: :service).
where(services: { one_time_fee: false }, arm_id: arm.id)
end.group_by do |liv|
self.display_organization_hierarchy(liv)
liv.sub_service_request.id
end
end

Expand Down
34 changes: 21 additions & 13 deletions spec/lib/dashboard/service_calendars_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@
create(:line_items_visit, arm: arm, line_item: li_pppv, sub_service_request: first_draft_ssr)

arm.reload
expect(Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, nil, ssr, merged: true, consolidated: true)).
to eq({ "B > A" => [liv_pppv1, liv_pppv2] })
livs = Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, nil, ssr, merged: true, consolidated: true)
expect(livs.keys).to eq([ssr.id])
expect(livs[ssr.id]).to contain_exactly(liv_pppv1, liv_pppv2)
end
end

Expand Down Expand Up @@ -135,8 +136,10 @@
create(:line_items_visit, arm: arm, line_item: li_pppv, sub_service_request: first_draft_ssr)

arm.reload
expect(Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, nil, ssr, merged: true, consolidated: false)).
to eq({ "B > A" => [liv_draft, liv_pppv1, liv_pppv2] })
livs = Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, nil, ssr, merged: true, consolidated: false)
expect(livs.keys).to contain_exactly(draft_ssr.id, ssr.id)
expect(livs[draft_ssr.id]).to eq([liv_draft])
expect(livs[ssr.id]).to contain_exactly(liv_pppv1, liv_pppv2)
end
end

Expand Down Expand Up @@ -173,8 +176,9 @@
create(:line_items_visit, arm: wrong_arm, line_item: li_pppv, sub_service_request: ssr)

arm.reload
expect(Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, nil, ssr)).
to eq({ "B > A" => [liv_pppv1, liv_pppv2] })
livs = Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, nil, ssr)
expect(livs.keys).to eq([ssr.id])
expect(livs[ssr.id]).to contain_exactly(liv_pppv1, liv_pppv2)
end
end

Expand All @@ -185,33 +189,37 @@
org_B = create(:organization, process_ssrs: true, abbreviation: "B", parent: org_C)
org_A = create(:organization, process_ssrs: false, abbreviation: "A", parent: org_B)
sr = create(:service_request_without_validations)
ssr = create(:sub_service_request, service_request_id: sr.id, organization_id: org_A.id)

# expect this LIV to appear
# expect these LIV's to appear
service_pppv = create(:service, :without_validations, organization: org_A, one_time_fee: false)
li_pppv = create(:line_item, :without_validations, service: service_pppv, service_request: sr)
li_pppv = create(:line_item, :without_validations, service: service_pppv, service_request: sr, sub_service_request: ssr)
liv_pppv1 = create(:line_items_visit, arm: arm, line_item: li_pppv)
liv_pppv2 = create(:line_items_visit, arm: arm, line_item: li_pppv)

# this LIV should not appear (it is not PPPV)
service_otf = create(:service, :without_validations, organization: org_A, one_time_fee: true)
li_otf = create(:line_item, :without_validations, service: service_otf)
li_otf = create(:line_item, :without_validations, service: service_otf, service_request: sr, sub_service_request: ssr)
create(:line_items_visit, arm: arm, line_item: li_otf)

# this LIV should not appear (associated with another SR)
another_sr = create(:service_request_without_validations)
another_ssr = create(:sub_service_request, service_request_id: another_sr.id, organization_id: org_A.id)
service_pppv = create(:service, :without_validations, organization: org_A, one_time_fee: false)
li_pppv = create(:line_item, :without_validations, service: service_pppv, service_request: another_sr)
li_pppv = create(:line_item, :without_validations, service: service_pppv, service_request: another_sr, sub_service_request: another_ssr)
create(:line_items_visit, arm: arm, line_item: li_pppv)

# this LIV should not appear (associated with another Arm)
wrong_arm = create(:arm, :without_validations)
service_pppv = create(:service, :without_validations, organization: org_A, one_time_fee: false)
li_pppv = create(:line_item, :without_validations, service: service_pppv, service_request: sr)
li_pppv = create(:line_item, :without_validations, service: service_pppv, service_request: sr, sub_service_request: ssr)
create(:line_items_visit, arm: wrong_arm, line_item: li_pppv)

arm.reload
expect(Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, sr, nil)).
to eq({ "B > A" => [liv_pppv1, liv_pppv2] })
livs = Dashboard::ServiceCalendars.pppv_line_items_visits_to_display(arm, sr, nil)

expect(livs.keys).to eq([ssr.id])
expect(livs[ssr.id]).to contain_exactly(liv_pppv1, liv_pppv2)
end
end
end
Expand Down

0 comments on commit 83d8587

Please sign in to comment.