Skip to content

fix: use invoicing role contact for invoice email - #488

Open
kocaemre wants to merge 1 commit into
tuttle-dev:mainfrom
kocaemre:fix/invoicing-contact-email
Open

fix: use invoicing role contact for invoice email#488
kocaemre wants to merge 1 commit into
tuttle-dev:mainfrom
kocaemre:fix/invoicing-contact-email

Conversation

@kocaemre

Copy link
Copy Markdown

Summary

Fixes #487.

The invoice email path only looked at the legacy client.invoicing_contact relationship. The current contacts UI can also attach contacts through the ClientContact association with role invoicing, which meant a client could visibly have an invoicing contact with an email address while Send Invoice still failed with “No contact email available”.

This adds a shared invoice-recipient contact lookup that:

  • keeps preferring the legacy direct invoicing contact
  • falls back to a many-to-many ClientContact whose role is invoicing
  • reuses that lookup for invoice/reminder email composition and invoice recipient name/address helpers
  • adds regression coverage for generating invoice emails from an invoicing-role contact

AI assistance was used while drafting this change; I reviewed the code path and verified the final patch locally.

Checklist

  • I have read the Contributing guide.
  • I have installed and tested the application for my platform (just dev).
    • Not run: this is a backend/model email-recipient fix and just is not installed in this environment.
  • The test suite passes locally (just test).
    • Equivalent run: pytest -q → 549 passed, 1 skipped.
  • Pre-commit hooks are installed and pass (just precommit).
    • Not run: just is not installed in this environment. Ran ruff check ... and git diff --check instead.
  • I have added or updated tests where appropriate.
  • I have updated the documentation / docstrings where appropriate.
  • If my change touches the schema (tuttle/model.py), I generated and reviewed an Alembic migration (just migrate "<msg>").
    • Not applicable: this only adds Python properties/helper logic; no SQLModel fields, tables, or relationships changed.
  • If my change affects the graphical user interface, I have provided screenshots.
    • Not applicable: no UI files changed.
  • I understand and can explain all submitted changes; if AI assistance was significant, I have disclosed it in the summary above.

Verification

uv sync --dev
source .venv/bin/activate
python -m py_compile tuttle/model.py tuttle/invoicing.py tuttle/app/invoicing/intent.py tuttle_tests/test_invoice.py
pytest tuttle_tests/test_invoice.py -q
pytest -q
ruff check tuttle/model.py tuttle/invoicing.py tuttle/app/invoicing/intent.py tuttle_tests/test_invoice.py
git diff --check

Results:

  • pytest tuttle_tests/test_invoice.py -q: 41 passed
  • pytest -q: 549 passed, 1 skipped
  • ruff check ...: All checks passed
  • git diff --check: no whitespace errors

Signed-off-by: Emre K <110906681+kocaemre@users.noreply.github.com>
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.

"Send Invoice" displays "no contact email available" although an invoicing contact with e-mail has been set for the client

1 participant