Skip to content

[FIX] thankyou_letters: donation amount of lines booked from bank statements - #2198

Merged
ecino merged 1 commit into
18.0from
18.0-thankyou-entry-donation-amount
Nov 2, 2026
Merged

ecino merged 1 commit into
18.0from
18.0-thankyou-entry-donation-amount

Conversation

@davidwul

@davidwul davidwul commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Since donations are booked directly from the bank statement (journal entry, no invoice), their move lines have price_unit = 0, so price_subtotal = 0; the amount is only in amount_currency (negative, credit side). Everything summing price_subtotal got 0 for these donations:

  • get_donations() → thank-you letter showed CHF 0.-
  • thankyou.config.for_donation() → wrong config chosen (min donation amount never reached, e.g. no call for large gifts)
  • partner.communication.job.amount (stored) → 0

Fix

New account.move.line.get_donation_amount(): price_subtotal for invoice lines, -amount_currency for journal entry lines (a debit line on such an entry, i.e. a reversal, reduces the total instead of being added as abs() would). Used in the three places above. Invoice lines are computed exactly as before.

Tested on a copy of the Swiss DB: 3 statement donations of 20/100/40 → CHF 160.- (was CHF 0.-); invoice lines unchanged.

Companion PR in compassion-switzerland (partner_communication_switzerland.get_donations override) depends on this one.

Note: existing pending communications keep their stored amount until their objects change.

🤖 Generated with Claude Code

…tements

Donations reconciled directly on a bank statement line (journal entry,
no invoice) have no unit price, so price_subtotal is 0 and the amount is
only in amount_currency (negative, credit side). The thank-you letter
amount, the thank-you config selection (min donation amount) and the
stored communication amount were all computed as 0 for these donations.

Add get_donation_amount() on account.move.line: price_subtotal for
invoice lines, -amount_currency for journal entry lines (a debit line on
such an entry, i.e. a reversal, reduces the total).

Assisted-by: claude-opus-5-5, medium, claude-code
@davidwul

davidwul commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@ecino thank you letter are generated wrongly when the donation is comming directly from the bankstatement,
can you review this ?

@ecino
ecino merged commit 8637aec into 18.0 Nov 2, 2026
1 check passed
@ecino
ecino deleted the 18.0-thankyou-entry-donation-amount branch November 2, 2026 12:28
ecino pushed a commit to CompassionCH/compassion-switzerland that referenced this pull request Nov 2, 2026
…ked from bank statements

Use thankyou_letters get_donation_amount() instead of summing
price_subtotal, which is 0 for donations reconciled directly on a bank
statement line (journal entry without invoice).

Depends on CompassionCH/compassion-modules#2198

Assisted-by: claude-opus-5-5, medium, claude-code
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