Skip to content

Commit

Permalink
🥗 Tobias: Confirm issuing indivisible Payout#amount rounds each `…
Browse files Browse the repository at this point in the history
…Beneficiary` `Payment` down

I wasn't exactly sure what would happen, so I took the time to figure it
out.

Apparently, the [`money-rails` gem] we use defaults to rounding down, which is the
safer thing to do.

[`money-rails` gem]: https://github.com/RubyMoney/money-rails
  • Loading branch information
zspencer committed Jan 29, 2024
1 parent cd3d2d8 commit 2dbe0a1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/tobias/payout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,19 @@
expect(beneficiary.payments).to exist(amount_cents: 15_00)
end
end

context "when the Payout#amount does not divide evenly" do
it "rounds down so that it can" do
payout = create(:tobias_payout, amount_cents: 3_33)

beneficiaries = create_list(:tobias_beneficiary, 2, trust: payout.trust)

payout.issue

beneficiaries.each do |beneficiary|
expect(beneficiary.payments).to exist(amount_cents: 1_66)
end
end
end
end
end

0 comments on commit 2dbe0a1

Please sign in to comment.