Skip to content

[T3746] FEAT gift_compassion: gift limits per currency, official rule in USD as fallback - #2231

Merged
Danielgergely merged 2 commits into
18.0from
T3746-gift-limits-currency
Dec 2, 2026
Merged

Danielgergely merged 2 commits into
18.0from
T3746-gift-limits-currency

Conversation

@davidwul

@davidwul davidwul commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Ticket T3746: gift limits in the correct currencies (Nordic offices give in SEK/NOK/DKK, the official GMC limits are in USD).

What changes

  • gift.threshold.settings: one rule per gift type and currency (unique(gift_type_id, currency_id)); currency required, USD by default. A pre-migration sets USD on rules without a currency.
  • New _get_rule(gift_type, currency) / _get_rules(currency): the rule in the requested currency, else the official one (USD), else the first one. So the official limits stay in USD and each country can add its own rule in its currency.
  • sponsorship.gift.is_eligible: uses the rule of the gift's currency, converts the gift and the other gifts of the year into the rule's currency with _convert (or amount_us_dollars for USD), and messages show the right currency instead of $.
  • Fixes on the way (also change the result for existing offices):
    • the checked gift was counted twice in the yearly total (with frequency 2 and max 100 USD, a 2nd gift of 100 was refused);
    • _compute_currency used self instead of gift in its loop.
  • readme/CONFIGURE.md explains the setup.

Tests

tests/test_gift_threshold_currency.py: 9 tests (rule choice and fallback, unique constraint, eligibility in the rule currency, official rule converted, yearly frequency). They pass on a Nordic test DB; other failures in the suite exist on 18.0 without this change.

Needed by the compassion-website PR (my_compassion), which uses _get_rule / _get_rules: merge this one first.

🤖 Generated with Claude Code

… in USD as fallback

Assisted-by: claude-opus-5-5, medium, claude-code
@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The latest update appears safe to merge and fixes the test failure on USD databases.

Reviews (2) · Last reviewed commit: "[T3746] FIX gift_compassion: currency te..." · Reviewed by Greptile

…, never in USD

Assisted-by: claude-opus-5-5, medium, claude-code
@Danielgergely
Danielgergely merged commit 176fa59 into 18.0 Dec 2, 2026
2 checks passed
@Danielgergely
Danielgergely deleted the T3746-gift-limits-currency branch December 2, 2026 15:44
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