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

feat(precise_amount): Add precise amounts to fee serializer #2529

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/serializers/v1/fee_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module V1
class FeeSerializer < ModelSerializer
def serialize
# subunit_to_unit = model.amount.currency.subunit_to_unit
subunit_to_unit = model.amount.currency.subunit_to_unit

payload = {
lago_id: model.id,
Expand Down Expand Up @@ -31,10 +31,10 @@ def serialize
invoiceable:,
amount_cents: model.amount_cents,
amount_currency: model.amount_currency,
# precise_amount: model.precise_amount_cents.fdiv(subunit_to_unit),
# precise_total_amount: model.precise_total_amount_cents.fdiv(subunit_to_unit),
precise_amount: model.precise_amount_cents.fdiv(subunit_to_unit),
precise_total_amount: model.precise_total_amount_cents.fdiv(subunit_to_unit),
taxes_amount_cents: model.taxes_amount_cents,
# taxes_precise_amount: model.taxes_precise_amount_cents.fdiv(subunit_to_unit),
taxes_precise_amount: model.taxes_precise_amount_cents.fdiv(subunit_to_unit),
taxes_rate: model.taxes_rate,
total_amount_cents: model.total_amount_cents,
total_amount_currency: model.amount_currency,
Expand Down
6 changes: 3 additions & 3 deletions spec/serializers/v1/fee_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
'taxes_rate' => fee.taxes_rate,
'total_amount_cents' => fee.total_amount_cents,
'total_amount_currency' => fee.amount_currency,
# 'precise_amount' => fee.precise_amount_cents.fdiv(100),
# 'taxes_precise_amount' => fee.taxes_precise_amount_cents.fdiv(100),
# 'precise_total_amount' => fee.precise_total_amount_cents.fdiv(100),
'precise_amount' => fee.precise_amount_cents.fdiv(100),
'taxes_precise_amount' => fee.taxes_precise_amount_cents.fdiv(100),
'precise_total_amount' => fee.precise_total_amount_cents.fdiv(100),
'units' => fee.units.to_s,
'precise_unit_amount' => fee.precise_unit_amount.to_s,
'precise_coupons_amount_cents' => fee.precise_coupons_amount_cents.to_s,
Expand Down