Skip to content

Make minimum amount env & other small change for euros#1165

Merged
lodewiges merged 10 commits into
stagingfrom
feature/make-minium-amount-env
Dec 10, 2025
Merged

Make minimum amount env & other small change for euros#1165
lodewiges merged 10 commits into
stagingfrom
feature/make-minium-amount-env

Conversation

@lodewiges
Copy link
Copy Markdown
Contributor

@lodewiges lodewiges commented Dec 10, 2025

The last PR before Euros use the system on there first borrel

Summary by CodeRabbit

  • New Features

    • Minimum payment amount is now configurable via app settings and enforced per page/instance.
    • Payment instructions in emails now present available methods (iDEAL button, bank transfer, both, or none).
  • Bug Fixes

    • Improved OTP/login flow handling to better surface prompts and HTML error messages without losing the user prompt.
  • UI/Style

    • Updated branding logo from Alpha to Sofia.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 10, 2025 19:36
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 10, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Externalized the minimum payment amount into config.x.min_payment_amount (from MIN_PAYMENT_AMOUNT), propagated it to frontend dataset and JS, replaced hard-coded 20/21.80 values in validations and mailer, changed mailer header logo, and made the insufficient-credit mail render conditional payment-method options; adjusted OTP JSON handling in login view.

Changes

Cohort / File(s) Summary
Environment & App config
\.env.example, config/application.rb
Added MIN_PAYMENT_AMOUNT to .env.example and introduced config.x.min_payment_amount (float, min 0.01) in application config.
Frontend — payment UI
app/views/payments/add.html.erb, app/javascript/payment_add.js
View now outputs data-min-payment-amount from config; JS removed global MIN_PAYMENT_AMOUNT, reads per-instance minPaymentAmount from dataset and uses it for default amount and validation.
Backend — validations & mailer logic
app/models/payment.rb, app/mailers/user_credit_mailer.rb
Replaced hard-coded minimum amounts with Rails.application.config.x.min_payment_amount in model validation and mailer text/values.
Mailer view updates
app/views/layouts/mailer.html.erb, app/views/user_credit_mailer/insufficient_credit_mail.html.erb
Mailer layout logo image/source/alt/title changed to Sofia asset; insufficient-credit mail refactored to conditionally render iDEAL button and/or bank-transfer instructions (with fallbacks) based on configured payment methods.
Authentication flow tweak (OTP)
app/views/sofia_accounts/login.html.erb
AJAX OTP handling switched to inspect json.state ("logged_in" / "otp_prompt") and render error HTML via showAuthenticateFlashMessage when present.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Verify conditional branches and localization in app/views/user_credit_mailer/insufficient_credit_mail.html.erb.
  • Confirm config.x.min_payment_amount formatting/decimal handling in views and payment_add.js.
  • Ensure data-min-payment-amount is present on all payment pages and JS initialization order is correct.
  • Check mailer layout/logo path and accessibility attributes.
  • Validate OTP JSON shape used in app/views/sofia_accounts/login.html.erb matches backend responses.

Possibly related PRs

Poem

🐰 I nudge the MIN from stone to config tree,
Numbers hop tidy, now fluent and free.
I bound through views, whispered into mail,
A new logo winks as options set sail.
Carrots for tests — code crunch, then a happy squeal.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is vague and incomplete. It does not follow the required template structure with checklist, proper summary section, or details about the changes made. Provide a detailed summary following the template: include the checklist items, clearly describe all changes (configuration, payment validation, email templates), mention any related issues, and explain the euros migration context.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: making the minimum payment amount configurable via environment variable and related euro-related adjustments across multiple files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/make-minium-amount-env

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

This comment was marked as outdated.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.24%. Comparing base (5a58828) to head (359bb1c).
⚠️ Report is 1 commits behind head on staging.

Additional details and impacted files
@@             Coverage Diff             @@
##           staging    #1165      +/-   ##
===========================================
+ Coverage    77.22%   77.24%   +0.01%     
===========================================
  Files           54       54              
  Lines         1348     1349       +1     
===========================================
+ Hits          1041     1042       +1     
  Misses         307      307              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

@lodewiges lodewiges changed the title Make minimum amount env Make minimum amount env & other small change for euros Dec 10, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/views/user_credit_mailer/insufficient_credit_mail.html.erb (1)

4-4: Replace hardcoded "5 euro" with the configurable minimum amount.

Line 4 hardcodes "minstens 5 euro positief" but this PR externalizes the minimum amount to config.x.min_payment_amount. For consistency with the payment model validation, mailer logic, and frontend display, this should dynamically reference the configured value.

Apply this diff to use the config value:

-  U wordt verzocht dit aan te vullen tot minstens 5 euro positief zoals
+  U wordt verzocht dit aan te vullen tot minstens <%= number_to_currency(Rails.application.config.x.min_payment_amount, unit: '€') %> positief zoals
🧹 Nitpick comments (1)
app/views/sofia_accounts/login.html.erb (1)

122-132: Previous error handling issue has been addressed.

The error message handling is now correctly positioned outside the state conditionals (lines 130-132), ensuring errors are displayed regardless of the response state. This resolves the concern from the previous review.

Consider aligning error message handling with authenticate_login.

Line 131 passes { allowHtml: true } to showAuthenticateFlashMessage, while the equivalent call in authenticate_login (line 100) does not. Unless OTP error messages specifically require HTML rendering, consider maintaining consistency between both functions for security and maintainability.

Apply this diff if HTML rendering isn't required for OTP errors:

     if (json.error_message) {
-      showAuthenticateFlashMessage(json.error_message, { allowHtml: true });
+      showAuthenticateFlashMessage(json.error_message);
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9890649 and 359bb1c.

⛔ Files ignored due to path filters (1)
  • public/images/sofia.png is excluded by !**/*.png
📒 Files selected for processing (5)
  • app/models/payment.rb (1 hunks)
  • app/views/layouts/mailer.html.erb (1 hunks)
  • app/views/sofia_accounts/login.html.erb (1 hunks)
  • app/views/user_credit_mailer/insufficient_credit_mail.html.erb (1 hunks)
  • config/application.rb (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/models/payment.rb
  • config/application.rb
  • app/views/layouts/mailer.html.erb
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (4)
app/views/user_credit_mailer/insufficient_credit_mail.html.erb (4)

10-31: LGTM! Clean conditional rendering for dual payment methods.

The logic correctly checks for both payment method configurations and presents clear options to users. The IBAN consistency issue noted in past reviews has been resolved (line 28 correctly uses personal_transaction_iban).


32-39: LGTM! Mollie-only path is correct.

Clean fallback when only iDEAL payment is configured.


40-45: LGTM! IBAN-only path is correct.

Clean fallback when only bank transfer is configured. The IBAN reference is consistent with the conditional check.


46-50: LGTM! Good defensive programming.

The else branch handles the case when no payment method is configured, directing users to contact the treasurer rather than showing broken or missing instructions.

@lodewiges lodewiges enabled auto-merge December 10, 2025 20:17
@lodewiges lodewiges disabled auto-merge December 10, 2025 20:18
@lodewiges lodewiges merged commit 0682a3a into staging Dec 10, 2025
6 checks passed
@lodewiges lodewiges deleted the feature/make-minium-amount-env branch December 10, 2025 20:18
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.

2 participants