diff --git a/backend/src/openarchiefbeheer/destruction/api/serializers.py b/backend/src/openarchiefbeheer/destruction/api/serializers.py index e4065a903..f57d8fbe6 100644 --- a/backend/src/openarchiefbeheer/destruction/api/serializers.py +++ b/backend/src/openarchiefbeheer/destruction/api/serializers.py @@ -449,11 +449,11 @@ class Meta: "deletable_items_count", ) - def get_deletable_items_count(self, instance) -> int: + def get_deletable_items_count(self, instance: DestructionList) -> int: succeeded_count = instance.items.filter( processing_status=InternalStatus.succeeded ).count() - total_count = instance.items.all().count() + total_count = instance.items.filter(status=ListItemStatus.suggested).count() return total_count - succeeded_count diff --git a/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_568_correct_count.py b/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_568_correct_count.py index af8204fc9..02d400e5c 100644 --- a/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_568_correct_count.py +++ b/backend/src/openarchiefbeheer/destruction/tests/e2e/issues/test_568_correct_count.py @@ -3,7 +3,7 @@ from openarchiefbeheer.utils.tests.e2e import browser_page from openarchiefbeheer.utils.tests.gherkin import GherkinLikeTestCase -from ....constants import InternalStatus, ListStatus +from ....constants import InternalStatus, ListItemStatus, ListStatus @tag("e2e") @@ -11,7 +11,7 @@ class Issue568CorrectCount(GherkinLikeTestCase): async def test_destruction_fails_with_incorrect_count(self): async with browser_page() as page: - zaken = await self.given.zaken_are_indexed(amount=5) + zaken = await self.given.zaken_are_indexed(amount=6) await self.given.record_manager_exists() destruction_list = await self.given.list_exists( @@ -45,6 +45,12 @@ async def test_destruction_fails_with_incorrect_count(self): processing_status=InternalStatus.succeeded, zaak=zaken[4], ) + await self.given.list_item_exists( + destruction_list=destruction_list, + status=ListItemStatus.removed, + processing_status=InternalStatus.new, + zaak=zaken[5], + ) await self.when.record_manager_logs_in(page) await self.then.path_should_be(page, "/destruction-lists")