Skip to content

Commit

Permalink
Merge pull request #594 from SuperCoopBerlin/fix_deleting_transfer_re…
Browse files Browse the repository at this point in the history
…signation_not_affecting_the_shares

Fix transferred shares not being deleted when deleting a resignation of type transfer.
  • Loading branch information
Theophile-Madet authored Dec 11, 2024
2 parents 338b3b2 + 11c63da commit 38a32f1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tapir/coop/services/membership_resignation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def update_shifts(

@classmethod
def on_resignation_deleted(cls, resignation: MembershipResignation):
cls.delete_end_dates(resignation)
cls.delete_transferred_share_ownerships(resignation)
cls.delete_end_dates(resignation)

@staticmethod
def delete_end_dates(resignation: MembershipResignation):
Expand Down
35 changes: 35 additions & 0 deletions tapir/coop/tests/membership_resignation/test_delete_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest.mock import patch, Mock

from django.urls import reverse
from django.utils import timezone

from tapir import settings
from tapir.coop.config import feature_flag_membership_resignation
Expand All @@ -15,6 +16,7 @@
)
from tapir.coop.tests.factories import (
MembershipResignationFactory,
ShareOwnerFactory,
)
from tapir.utils.tests_utils import (
FeatureFlagTestMixin,
Expand Down Expand Up @@ -83,3 +85,36 @@ def test_membershipResignationDeleteView_default_logEntryCreated(self):
log_entry = MembershipResignationDeleteLogEntry.objects.get()
self.assertEqual(resignation.id, int(log_entry.values["id"]))
self.assertEqual(actor, log_entry.actor)

def test_membershipResignationDeleteView_sharesWereTransferred_updateTransferredShares(
self,
):
actor = self.login_as_vorstand()
member_that_gifts_shares = ShareOwnerFactory.create(nb_shares=3)
member_that_receives_shares = ShareOwnerFactory.create(nb_shares=1)

data = {
"share_owner": member_that_gifts_shares.id,
"cancellation_reason": "Test resignation",
"cancellation_reason_category": MembershipResignation.CancellationReasons.OTHER,
"cancellation_date": timezone.now().date(),
"resignation_type": MembershipResignation.ResignationType.TRANSFER,
"transferring_shares_to": member_that_receives_shares.id,
}

response = self.client.post(
reverse("coop:membership_resignation_create"),
data=data,
follow=True,
)
self.assertStatusCode(response, HTTPStatus.OK)
resignation = MembershipResignation.objects.get()

response = self.client.post(
reverse("coop:membership_resignation_delete", args=[resignation.id]),
follow=True,
)
self.assertStatusCode(response, HTTPStatus.OK)

self.assertEqual(1, member_that_receives_shares.share_ownerships.count())
self.assertEqual(3, member_that_gifts_shares.share_ownerships.count())

0 comments on commit 38a32f1

Please sign in to comment.