Skip to content

Commit 0ee79c9

Browse files
refactor: event_procedures and medical_shifts pdf (#346)
1 parent ae33b4c commit 0ee79c9

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

app/pdfs/event_procedures_report_pdf.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ def start_new_page_if_needed
5555

5656
def add_item_details(item)
5757
add_item_line(truncate_text(item.patient.name), item_paid?(item))
58-
add_item_line(truncate_text(item.procedure.name), item.total_amount.format)
58+
add_item_line(truncate_text(item.procedure.name), "")
5959
add_item_line(
60-
"#{truncate_text(item.hospital.name)} - #{truncate_text(item.health_insurance.name)}",
61-
item_date(item)
60+
"#{truncate_text(item.hospital.name)} - #{truncate_text(item.health_insurance.name)} - #{item_date(item)}",
61+
item_amount(item)
6262
)
6363
end
6464

@@ -82,4 +82,8 @@ def item_paid?(item)
8282
def item_date(item)
8383
item.date.strftime("%d/%m/%Y")
8484
end
85+
86+
def item_amount(item)
87+
item.total_amount.format(thousands_separator: ".", decimal_mark: ",")
88+
end
8589
end

app/pdfs/medical_shifts_report_pdf.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def start_new_page_if_needed
5454
end
5555

5656
def add_item_details(item)
57-
add_item_line(truncate_text(item.hospital_name), item_start_date(item))
58-
add_item_line(item_workload(item), item.amount.format)
59-
add_item_line(item_start_hour(item), item_paid?(item))
57+
add_item_line(truncate_text(item.hospital_name), item_amount(item))
58+
add_item_line(item_workload(item), "")
59+
add_item_line(item_start_date(item), item_paid?(item))
6060
end
6161

6262
def add_item_line(left_text, right_text)
@@ -77,18 +77,18 @@ def item_shift(item)
7777
end
7878

7979
def item_workload(item)
80-
"#{item_shift(item)} - #{item.workload_humanize}"
80+
"#{item_shift(item)} - #{item.workload_humanize} - #{item.start_hour.strftime('%H:%M')}"
8181
end
8282

8383
def item_start_date(item)
8484
item.start_date.strftime("%d/%m/%Y")
8585
end
8686

87-
def item_start_hour(item)
88-
"Início: #{item.start_hour.strftime('%H:%M')}"
89-
end
90-
9187
def item_paid?(item)
9288
item.paid ? "Pago" : "A Receber"
9389
end
90+
91+
def item_amount(item)
92+
item.amount.format(thousands_separator: ".", decimal_mark: ",")
93+
end
9494
end

spec/pdfs/event_procedures_report_pdf_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
event_procedures.each do |event_procedure|
2020
expect(text_analysis.strings).to include(
2121
event_procedure.procedure.name,
22-
event_procedure.procedure.amount.format,
2322
event_procedure.patient.name,
24-
"#{event_procedure.hospital.name} - #{event_procedure.health_insurance.name}",
25-
event_procedure.date.strftime("%d/%m/%Y")
23+
"#{event_procedure.hospital.name} - #{event_procedure.health_insurance.name} -
24+
#{event_procedure.date.strftime('%d/%m/%Y')}".squish
2625
)
2726
end
2827
end

spec/pdfs/medical_shifts_report_pdf_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
medical_shifts.each do |medical_shift|
1717
expect(text_analysis.strings).to include(
1818
medical_shift.hospital_name,
19-
medical_shift.amount.format,
19+
medical_shift.amount.format(thousands_separator: ".", decimal_mark: ","),
2020
medical_shift.start_date.strftime("%d/%m/%Y")
2121
)
2222
end

0 commit comments

Comments
 (0)