Skip to content

fix: use Decimal for revenue calculation to prevent floating-point errors (fixes #820)#1065

Open
menawar wants to merge 1 commit into
rinafcode:mainfrom
menawar:fix-820-floating-point
Open

fix: use Decimal for revenue calculation to prevent floating-point errors (fixes #820)#1065
menawar wants to merge 1 commit into
rinafcode:mainfrom
menawar:fix-820-floating-point

Conversation

@menawar

@menawar menawar commented Jul 24, 2026

Copy link
Copy Markdown

Overview

This PR addresses issue #820 by replacing floating-point arithmetic with decimal.js for all monetary calculations in PayoutsService. This ensures accuracy and eliminates rounding errors (e.g. 0.1 + 0.2 === 0.30).

Changes

  • PayoutsService: Updated getRevenueBreakdown to use Decimal for accumulating gross revenue and refunds.
  • Tests: Added a test case to explicitly verify the calculation logic against floating point edge cases.

Fixes #820

@drips-wave

drips-wave Bot commented Jul 24, 2026

Copy link
Copy Markdown

@menawar Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Great work done so far!
Kindly fix workflow to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revenue calculation in PayoutsService accumulates floating-point rounding errors

2 participants