Skip to content

include total_grantee_reimbursement_amount in invitation letter template#4551

Merged
marcoacierno merged 1 commit intomainfrom
claude/issue-4550-20260202-1220
Feb 2, 2026
Merged

include total_grantee_reimbursement_amount in invitation letter template#4551
marcoacierno merged 1 commit intomainfrom
claude/issue-4550-20260202-1220

Conversation

@marcoacierno
Copy link
Member

Include grant total_grantee_reimbursement_amount in the invitation letter template context so it can be used via {{total_grantee_reimbursement_amount}} in dynamic documents.

Closes #4550

Generated with Claude Code

… template

Add the grant's total_grantee_reimbursement_amount as a template variable
available in invitation letter dynamic documents. This allows the invitation
letter to display the post-conference reimbursement amount for grantees.

Changes:
- Add total_grantee_reimbursement_amount property to InvitationLetterRequest
  model (returns None if no grant, otherwise delegates to the grant model)
- Pass total_grantee_reimbursement_amount in the template context for
  dynamic document rendering
- Add tests for the new property and template variable rendering

Closes #4550

Co-authored-by: Marco Acierno <marcoacierno@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pycon Ready Ready Preview Feb 2, 2026 0:26am

@claude
Copy link
Contributor

claude bot commented Feb 2, 2026

Summary

This PR adds the total_grantee_reimbursement_amount field to the invitation letter template context, allowing it to be used in dynamic documents via {{total_grantee_reimbursement_amount}}. The implementation correctly delegates to the existing Grant.total_grantee_reimbursement_amount property which excludes ticket costs and only includes travel and accommodation reimbursements.

Changes:

  • Added total_grantee_reimbursement_amount property to InvitationLetterRequest model
  • Included the property in the template rendering context
  • Added comprehensive test coverage

Review Feedback

Architecture & Design ✅

Good:

  • Clean delegation pattern: The new property on InvitationLetterRequest properly delegates to the existing Grant.total_grantee_reimbursement_amount property, maintaining single source of truth
  • Consistent with existing patterns: Follows the same pattern as grant_approved_type, has_accommodation_via_grant(), and has_travel_via_grant()
  • Returns None when no grant exists, which is appropriate for template rendering

Minor observation:

  • Lines 125-132 in visa/models.py: Consider using @property decorator with @cached_property on user_grant for consistency, but current implementation is fine since it's a simple delegation

Testing & Coverage ✅

Excellent test coverage:

  • test_request_on_behalf_of_other (line 29): Tests the None case when no grant exists
  • test_request_grant_info (lines 88-97): Parametrized test validates the calculation across all grant category combinations, correctly verifying that ticket amounts are excluded
  • test_process_invitation_letter_request_renders_total_grantee_reimbursement_amount (lines 190-246): Full integration test verifying the value renders correctly in dynamic documents, with explicit setup of ticket (€100), travel (€500), and accommodation (€200) resulting in €700 total (ticket excluded)

Edge cases covered:

  • ✅ No grant exists (returns None)
  • ✅ Multiple reimbursement categories
  • ✅ Ticket amount properly excluded from calculation
  • ✅ Integration with template rendering

Error Handling ✅

Appropriate handling:

  • Returns None when user_grant is None (line 130), which is safe for Django template rendering
  • No exceptions expected as the property gracefully handles missing grants

Performance ✅

No concerns:

  • Uses existing @cached_property for user_grant (line 134), preventing N+1 queries
  • The calculation happens in Python memory (summing already-fetched reimbursements via grant.total_grantee_reimbursement_amount)
  • No new database queries introduced

Code Quality ✅

Clean implementation:

  • Follows existing code conventions
  • Type hints are consistent with surrounding code
  • Test assertions are clear and explicit (lines 88-97 show the calculation breakdown in comments)

Conclusion

LGTM ✅ - This is a well-implemented, thoroughly tested change that follows established patterns in the codebase. The feature correctly exposes grant reimbursement amounts (excluding tickets) for use in invitation letter templates.

@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.16%. Comparing base (8e4618c) to head (9e1d537).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4551   +/-   ##
=======================================
  Coverage   94.15%   94.16%           
=======================================
  Files         353      353           
  Lines       10342    10348    +6     
  Branches      761      762    +1     
=======================================
+ Hits         9738     9744    +6     
  Misses        502      502           
  Partials      102      102           
🚀 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.

@marcoacierno marcoacierno merged commit 10b9c2c into main Feb 2, 2026
8 checks passed
@marcoacierno marcoacierno deleted the claude/issue-4550-20260202-1220 branch February 2, 2026 14:07
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.

Include Grant total_grantee_reimbursement_amount in the invitation letter template

1 participant