Skip to content

Commit

Permalink
found bug and solution, need to clean it up and test some more
Browse files Browse the repository at this point in the history
  • Loading branch information
Prazn committed Sep 12, 2024
1 parent 5e85cbe commit 70b8794
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion my_compassion/controllers/my_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,16 @@ def my_donations(self, invoice_page=1, invoice_per_page=12, **kw):
]
)

end_reason_child_depart = request.env.ref("sponsorship_compassion.end_reason_depart")

sponsorships = partner.sponsorship_ids.filtered(
lambda s: s.state in ["waiting", "active", "mandate"]
and partner == s.mapped("partner_id")
or
s.state == "terminated"
and s.can_write_letter
and s.end_reason_id == end_reason_child_depart
and partner == s.mapped("partner_id")
)
currency = sponsorships.mapped("pricelist_id.currency_id")[:1].name

Expand All @@ -509,7 +516,7 @@ def my_donations(self, invoice_page=1, invoice_per_page=12, **kw):
sponsorships_by_group = {
g: (
sponsorships.filtered(lambda s, g=g: s.group_id == g),
f"{int(g.total_amount):,d} {currency}",
f"{int(sum(sponsorships.filtered(lambda s, g=g: s.group_id == g).mapped('total_amount'))):,d} {currency}",
)
for g in sponsorships.mapped("group_id")
}
Expand Down

0 comments on commit 70b8794

Please sign in to comment.