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

UI - Otf table #2333

Merged
merged 15 commits into from
May 7, 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
48 changes: 39 additions & 9 deletions app/lib/cost_analysis/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,43 @@ def to_pdf(doc)
service_request = CostAnalysis::ServiceRequest.new(sr)

service_request.arms.each do |arm|
table = CostAnalysis::VisitTable.new
table.arm_name = arm.name
table.visit_labels = arm.visit_labels
arm.line_items.each do |core, line_item|
table.add_line_item core, line_item
end

pdf.visit_tables << table
pdf.visit_tables << build_visit_table(arm)
end

pdf.otf_tables << build_otf_table(service_request)

end

pdf.setup_render
end

def build_visit_table(arm)
table = CostAnalysis::VisitTable.new
table.arm_name = arm.name
table.visit_labels = arm.visit_labels
arm.line_items.each do |core, line_item|
table.add_line_item core, line_item
end

table
end

def build_otf_table(service_request)
sub_srv_reqs = service_request.otf_line_items()

tbl = CostAnalysis::OtfTable.new

sub_srv_reqs.each do |ssr_with_lis|
ssr = ssr_with_lis[0]
lis = ssr_with_lis[1]

lis.each do |li|
tbl.add_otf_line_item(li)
end

end

pdf.update
tbl
end

def preview(thing)
Expand All @@ -54,5 +78,11 @@ def preview(thing)
`open preview.pdf`
end
end

def preview_pdf_named(file_name = "tmp/pdfs/preview.pdf")
pdf = Prawn::Document.new(:page_layout => :landscape)
to_pdf(pdf)
pdf.render_file(file_name)
end
end
end