From d3c518cbc3234ab1f0b05962b353b4dbfd25feb6 Mon Sep 17 00:00:00 2001 From: Daniel Nottingham Date: Fri, 30 Jan 2026 14:59:59 -0300 Subject: [PATCH] fix: display formatted amount --- app/models/medical_shift.rb | 4 ++++ app/serializers/event_procedure_serializer.rb | 2 +- app/serializers/medical_shift_serializer.rb | 2 +- .../api/v1/event_procedures_request_spec.rb | 2 +- .../api/v1/medical_shifts_request_spec.rb | 16 ++++++++-------- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/models/medical_shift.rb b/app/models/medical_shift.rb index 7a8354c..1b04a9a 100644 --- a/app/models/medical_shift.rb +++ b/app/models/medical_shift.rb @@ -39,4 +39,8 @@ def title def recurring? medical_shift_recurrence_id.present? end + + def formatted_amount + amount.format(thousands_separator: ".", decimal_mark: ",") + end end diff --git a/app/serializers/event_procedure_serializer.rb b/app/serializers/event_procedure_serializer.rb index 206666b..99af641 100755 --- a/app/serializers/event_procedure_serializer.rb +++ b/app/serializers/event_procedure_serializer.rb @@ -29,7 +29,7 @@ def date end def precedure_value - object.procedure.amount.format + object.procedure.amount.format(thousands_separator: ".", decimal_mark: ",") end def precedure_description diff --git a/app/serializers/medical_shift_serializer.rb b/app/serializers/medical_shift_serializer.rb index 8db23f4..3543458 100644 --- a/app/serializers/medical_shift_serializer.rb +++ b/app/serializers/medical_shift_serializer.rb @@ -13,7 +13,7 @@ def hour end def amount_cents - object.amount.format + object.formatted_amount end def workload diff --git a/spec/requests/api/v1/event_procedures_request_spec.rb b/spec/requests/api/v1/event_procedures_request_spec.rb index 6571818..1584dc1 100644 --- a/spec/requests/api/v1/event_procedures_request_spec.rb +++ b/spec/requests/api/v1/event_procedures_request_spec.rb @@ -203,7 +203,7 @@ "payment" => EventProcedures::Payments::HEALTH_INSURANCE, "urgency" => false, "paid" => true, - "precedure_value" => "R$200.00", + "precedure_value" => "R$200,00", "precedure_description" => "nice description" ) end diff --git a/spec/requests/api/v1/medical_shifts_request_spec.rb b/spec/requests/api/v1/medical_shifts_request_spec.rb index 4857f94..4f10d35 100644 --- a/spec/requests/api/v1/medical_shifts_request_spec.rb +++ b/spec/requests/api/v1/medical_shifts_request_spec.rb @@ -38,7 +38,7 @@ "workload" => medical_shifts.second.workload_humanize, "date" => medical_shifts.second.start_date.strftime("%d/%m/%Y"), "hour" => medical_shifts.second.start_hour.strftime("%H:%M"), - "amount_cents" => medical_shifts.second.amount.format, + "amount_cents" => medical_shifts.second.amount.format(thousands_separator: ".", decimal_mark: ","), "paid" => medical_shifts.second.paid, "shift" => medical_shifts.second.shift, "title" => "#{second_hospital_name} | #{second_workload} | #{second_shift}", @@ -51,7 +51,7 @@ "workload" => medical_shifts.first.workload_humanize, "date" => medical_shifts.first.start_date.strftime("%d/%m/%Y"), "hour" => medical_shifts.first.start_hour.strftime("%H:%M"), - "amount_cents" => medical_shifts.first.amount.format, + "amount_cents" => medical_shifts.first.formatted_amount, "paid" => medical_shifts.first.paid, "shift" => medical_shifts.first.shift, "title" => "#{first_hospital_name} | #{first_workload} | #{first_shift}", @@ -134,7 +134,7 @@ "workload" => paid_medical_shifts.second.workload_humanize, "date" => paid_medical_shifts.second.start_date.strftime("%d/%m/%Y"), "hour" => paid_medical_shifts.second.start_hour.strftime("%H:%M"), - "amount_cents" => paid_medical_shifts.second.amount.format, + "amount_cents" => paid_medical_shifts.second.formatted_amount, "paid" => paid_medical_shifts.second.paid, "shift" => paid_medical_shifts.second.shift, "title" => "#{second_hospital_name} | #{second_workload} | #{second_shift}", @@ -147,7 +147,7 @@ "workload" => paid_medical_shifts.first.workload_humanize, "date" => paid_medical_shifts.first.start_date.strftime("%d/%m/%Y"), "hour" => paid_medical_shifts.first.start_hour.strftime("%H:%M"), - "amount_cents" => paid_medical_shifts.first.amount.format, + "amount_cents" => paid_medical_shifts.first.formatted_amount, "paid" => paid_medical_shifts.first.paid, "shift" => paid_medical_shifts.first.shift, "title" => "#{first_hospital_name} | #{first_workload} | #{first_shift}", @@ -177,7 +177,7 @@ "workload" => unpaid_medical_shifts.second.workload_humanize, "date" => unpaid_medical_shifts.second.start_date.strftime("%d/%m/%Y"), "hour" => unpaid_medical_shifts.second.start_hour.strftime("%H:%M"), - "amount_cents" => unpaid_medical_shifts.second.amount.format, + "amount_cents" => unpaid_medical_shifts.second.formatted_amount, "paid" => unpaid_medical_shifts.second.paid, "shift" => unpaid_medical_shifts.second.shift, "title" => "#{second_hospital_name} | #{second_workload} | #{second_shift}", @@ -190,7 +190,7 @@ "workload" => unpaid_medical_shifts.first.workload_humanize, "date" => unpaid_medical_shifts.first.start_date.strftime("%d/%m/%Y"), "hour" => unpaid_medical_shifts.first.start_hour.strftime("%H:%M"), - "amount_cents" => unpaid_medical_shifts.first.amount.format, + "amount_cents" => unpaid_medical_shifts.first.formatted_amount, "paid" => unpaid_medical_shifts.first.paid, "shift" => unpaid_medical_shifts.first.shift, "title" => "#{first_hospital_name} | #{first_workload} | #{first_shift}", @@ -277,7 +277,7 @@ workload: MedicalShift.last.workload_humanize, date: MedicalShift.last.start_date.strftime("%d/%m/%Y"), hour: MedicalShift.last.start_hour.strftime("%H:%M"), - amount_cents: MedicalShift.last.amount.format, + amount_cents: MedicalShift.last.formatted_amount, paid: params[:paid], shift: MedicalShift.last.shift, title: "#{hospital_name} | #{workload} | #{shift}", @@ -361,7 +361,7 @@ workload: workload, date: medical_shift.start_date.strftime("%d/%m/%Y"), hour: medical_shift.start_hour.strftime("%H:%M"), - amount_cents: medical_shift.amount.format, + amount_cents: medical_shift.formatted_amount, paid: medical_shift.paid, shift: medical_shift.reload.shift, title: "#{hospital_name} | #{workload} | #{shift}"