Skip to content

Commit 192b454

Browse files
Refactor/event procedures and medical shifts pdf (#347)
* refactor: event_procedures and medical_shifts pdf * refactor: event_procedures and medical_shifts pdf
1 parent 0ee79c9 commit 192b454

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

app/operations/event_procedures/total_amount_cents.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def call
1515
end
1616

1717
def convert_money(amount_cents)
18-
Money.new(amount_cents, "BRL").format
18+
Money.new(amount_cents, "BRL").format(thousands_separator: ".", decimal_mark: ",")
1919
end
2020

2121
def calculate_amount(filtered_event_procedures)

app/operations/medical_shifts/total_amount_cents.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ class TotalAmountCents < Actor
99
output :unpaid, type: String
1010

1111
def call
12-
self.total = Money.new(medical_shifts.sum(&:amount_cents), "BRL").format
13-
self.paid = Money.new(medical_shifts.select(&:paid).sum(&:amount_cents), "BRL").format
14-
self.unpaid = Money.new(medical_shifts.reject(&:paid).sum(&:amount_cents), "BRL").format
12+
self.total = formatted_amount(medical_shifts.sum(&:amount_cents))
13+
self.paid = formatted_amount(medical_shifts.select(&:paid).sum(&:amount_cents))
14+
self.unpaid = formatted_amount(medical_shifts.reject(&:paid).sum(&:amount_cents))
15+
end
16+
17+
private
18+
19+
def formatted_amount(value)
20+
Money.new(value, "BRL").format(thousands_separator: ".", decimal_mark: ",")
1521
end
1622
end
1723
end

spec/operations/event_procedures/total_amount_cents_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
event_procedures = paid_event_procedures + unpaid_event_procedures
3434
total_amount_cents = described_class.call(event_procedures: event_procedures)
3535

36-
expect(total_amount_cents.total).to eq("R$190.00")
37-
expect(total_amount_cents.paid).to eq("R$150.00")
38-
expect(total_amount_cents.unpaid).to eq("R$40.00")
36+
expect(total_amount_cents.total).to eq("R$190,00")
37+
expect(total_amount_cents.paid).to eq("R$150,00")
38+
expect(total_amount_cents.unpaid).to eq("R$40,00")
3939
end
4040
end
4141
end

spec/operations/medical_shifts/total_amount_cents_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
]
3030
)
3131

32-
expect(result.total).to eq("R$45.00")
33-
expect(result.paid).to eq("R$30.00")
34-
expect(result.unpaid).to eq("R$15.00")
32+
expect(result.total).to eq("R$45,00")
33+
expect(result.paid).to eq("R$30,00")
34+
expect(result.unpaid).to eq("R$15,00")
3535
end
3636
end
3737
end

spec/requests/api/v1/event_procedures_request_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
end
132132

133133
it "returns total values without consider page and per_page params" do
134-
expect(response.parsed_body["total"]).to eq("R$400.00")
134+
expect(response.parsed_body["total"]).to eq("R$400,00")
135135
end
136136
end
137137
end

spec/requests/api/v1/medical_shifts_request_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@
9393

9494
get path, params: { month: "2" }, headers: headers
9595

96-
expect(response.parsed_body["total"]).to eq("R$30.00")
97-
expect(response.parsed_body["total_paid"]).to eq("R$10.00")
98-
expect(response.parsed_body["total_unpaid"]).to eq("R$20.00")
96+
expect(response.parsed_body["total"]).to eq("R$30,00")
97+
expect(response.parsed_body["total_paid"]).to eq("R$10,00")
98+
expect(response.parsed_body["total_unpaid"]).to eq("R$20,00")
9999
end
100100
end
101101

@@ -207,9 +207,9 @@
207207

208208
expect(response.parsed_body.symbolize_keys).to eq(
209209
{
210-
total: "R$0.00",
211-
total_paid: "R$0.00",
212-
total_unpaid: "R$0.00",
210+
total: "R$0,00",
211+
total_paid: "R$0,00",
212+
total_unpaid: "R$0,00",
213213
medical_shifts: []
214214
}
215215
)

0 commit comments

Comments
 (0)