fix(fees): search reminder messages across all company users, not just first
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-03-20 08:51:33 +01:00
parent 069280870f
commit 1645ed49f4

View File

@ -678,13 +678,13 @@ def admin_fees():
company_data['monthly_rate'] = int(fee.amount)
if fee.status in ('pending', 'partial', 'overdue'):
has_unpaid = True
# Find last reminder message for this company
# Find last reminder message for this company (to any linked user)
if has_unpaid:
from database import PrivateMessage, UserCompany
manager = db.query(UserCompany).filter(UserCompany.company_id == company.id).first()
if manager:
company_user_ids = [cu.user_id for cu in db.query(UserCompany).filter(UserCompany.company_id == company.id).all()]
if company_user_ids:
last_reminder = db.query(PrivateMessage).filter(
PrivateMessage.recipient_id == manager.user_id,
PrivateMessage.recipient_id.in_(company_user_ids),
PrivateMessage.subject.ilike('%przypomnienie o składce%'),
).order_by(PrivateMessage.created_at.desc()).first()
if last_reminder: