Closed DeD1rk closed 10 months ago
I think this is what goes wrong:
Renewal.payment
.process_entry_save
that responds to the payment having been set. _create_membership_from_entry
is called.until
is set to None, and saved. So far, this is all fine.entry.membership
is set and saved (https://github.com/svthalia/concrexit/blob/22ff4c23b2373a9baaa0b904bde6ca95ff30f772/website/registrations/services.py#L391-L393), which is also still fine. entry.membership_discount_applies
is evaluated again. This time however, it returns False, because member.current_membership.until
is None (https://github.com/svthalia/concrexit/blob/22ff4c23b2373a9baaa0b904bde6ca95ff30f772/website/registrations/models.py#L127-L132). So then it thinks the contribution should change back to no discount.So we should change the discount application to e.g. only be determined when entry.payment
is None.
Also a note-to-self: I have to clean up any inconsistent entries in the production db at some point, as these and the other similar bugs have left behind e.g. 'Completed' entries without a linked payment, as well as paid entries that have been fully completed, but are still 'Accepted'
And a note to implementer: I would be forever grateful for a regression test for this :)
Describe the bug
https://thalia.sentry.io/issues/4409801909
When people create a renewal to study-time membership, and a payment is made for it, the saving prevention is triggered because the
contribution
amount changed. The discount calculation should probably change to be calculated earlier so the amount is accurate from the start.How to reproduce
Steps to reproduce the behaviour: