Skip to content

Conversation

@D0gmaDev
Copy link
Member

@D0gmaDev D0gmaDev commented Dec 11, 2025

Closes #478

Implement proper money handling with money-rails

This PR introduces the money-rails gem to handle monetary values properly throughout the application, replacing manual cents manipulation with Money objects.

Core Implementation:

  • Added money-rails gem with EUR as default currency
  • Migrated price columns to price_cents (integer storage for cents)
  • Added monetize macro to Article and SubscriptionOffer models
  • Implemented total_price method for both Sale and Refund models

Improvements:

  • All monetary arithmetic now uses Money objects (no more manual float operations)
  • Currency consistency validation on all price fields
  • Consistent price display using humanized_money_with_symbol
  • JavaScript layer properly documented to use cents

Invoice System:

  • Enhanced InvoicePdfGenerator to handle both Money objects and serialized Hash formats
  • Added to_money and format_money helper methods for PDF generation

@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3d58786) to head (098207d).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #534   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          109       109           
  Lines         2359      2388   +29     
  Branches        72        78    +6     
=========================================
+ Hits          2359      2388   +29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Better handle prices

1 participant