Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt GVA formula to exclude FDI retention projects #5377

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions datahub/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ class FDIType(Enum):
'Creation of new site or activity',
'f8447013-cfdc-4f35-a146-6619665388b3',
)
retention = Constant(
'Retention',
'0657168e-8a58-4f37-914f-ec541556fc28',
)


class FDIValue(Enum):
Expand Down
10 changes: 7 additions & 3 deletions datahub/investment/project/gva_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from django.utils.functional import cached_property

from datahub.core.constants import (
InvestmentBusinessActivity as InvestmentBusinessActivityConstant,
)
from datahub.core.constants import (
FDIType as FDITypeConstant,
InvestmentType as InvestmentTypeConstant,
Sector as SectorConstant,
)
from datahub.core.constants import (
InvestmentBusinessActivity as InvestmentBusinessActivityConstant,
)
from datahub.investment.project.models import GVAMultiplier

logger = getLogger(__name__)
Expand Down Expand Up @@ -82,6 +83,9 @@ def _get_gva_multiplier_for_investment_project(self):
):
return None

if str(self.investment_project.fdi_type_id) == FDITypeConstant.retention.value.id:
return None

if self._has_business_activity_of_retail_or_sales():
return self._get_retail_gva_multiplier()

Expand Down
74 changes: 53 additions & 21 deletions datahub/investment/project/test/test_gva_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from datahub.core.constants import (
FDIType as FDITypeConstant,
InvestmentBusinessActivity as InvestmentBusinessActivityConstant,
InvestmentType as InvestmentTypeConstant,
Sector as SectorConstant,
Expand Down Expand Up @@ -33,36 +34,50 @@ class TestGrossValueAddedCalculator:
"""Test for Gross Value Added Calculator."""

@pytest.mark.parametrize(
'investment_type,sector,business_activities',
'business_activities,fdi_type,investment_type,sector',
[
# Non-FDI investment type
(
[],
FDITypeConstant.creation_of_new_site_or_activity.value.id,
InvestmentTypeConstant.non_fdi.value.id,
SectorConstant.renewable_energy_wind.value.id,
),
# FDI type is retention
(
[],
FDITypeConstant.retention.value.id,
InvestmentTypeConstant.fdi.value.id,
SectorConstant.renewable_energy_wind.value.id,
),
# When sector is empty
(
[],
FDITypeConstant.creation_of_new_site_or_activity.value.id,
InvestmentTypeConstant.fdi.value.id,
None,
[],
),
],
)
def test_get_gva_multiplier_returns_none_when_expected(
self,
business_activities,
fdi_type,
investment_type,
sector,
business_activities,
):
"""Test _get_gva_multiplier_for_investment_project returns none when:
a) investment type is non-FDI,
b) investment project sector is empty.
"""Test _get_gva_multiplier_for_investment_project returns none when expected.

Expected scenarios:
- investment type is non-FDI,
- FDI type is retention,
- investment project sector is empty.
"""
project = InvestmentProjectFactory(
sector_id=sector,
business_activities=business_activities,
fdi_type_id=fdi_type,
investment_type_id=investment_type,
sector_id=sector,
)
assert project.gva_multiplier is None

Expand Down Expand Up @@ -120,10 +135,12 @@ def test_get_gva_multiplier_returns_value_when_expected(
business_activities,
expected_multiplier_value: Decimal,
):
"""Test _get_gva_multiplier_for_investment_project returns value when:
a) investment type is FDI,
b) business activities are retail or sales,
c) investment project has a sector.
"""Test _get_gva_multiplier_for_investment_project returns value when expected.

Expected scenarios:
- investment type is FDI (but not FDI retention),
- business activities are retail or sales,
- investment project has a sector.
"""
project = InvestmentProjectFactory(
sector_id=sector,
Expand All @@ -132,6 +149,19 @@ def test_get_gva_multiplier_returns_value_when_expected(
)
assert project.gva_multiplier.multiplier == expected_multiplier_value

def test_fdi_retention_type_returns_multiplier_of_none(self):
"""Test when it is an FDI retention project, it has a multiplier of None."""
project = InvestmentProjectFactory(
business_activities=[],
investment_type_id=InvestmentTypeConstant.fdi.value.id,
sector_id=SectorConstant.renewable_energy_wind.value.id,
)
assert project.gva_multiplier is not None
project.fdi_type_id = FDITypeConstant.retention.value.id
project.save()
project.refresh_from_db()
assert project.gva_multiplier is None

def test_multiple_gva_multipliers_for_sector_returns_most_recent_multiplier(self):
"""
Test when multiple GVA multipliers are present for a sector, it returns the
Expand Down Expand Up @@ -219,15 +249,16 @@ def test_gva_calculation_based_on_sector_classification_when_expected_gva_is_non
foreign_equity_investment,
number_new_jobs,
):
"""
Tests that GVA value is set to None when:
a) sector is capital intensive, there is no foreign equity investment value,
"""Tests that GVA value is set to None when expected.

Expected scenarios:
- sector is capital intensive, there is no foreign equity investment value,
and there is a value for number of new jobs;
b) sector is capital intensive, there is no foreign equity investment value,
- sector is capital intensive, there is no foreign equity investment value,
and there is no value for number of new jobs;
c) sector is labour intensive, there is a foreign equity investment value,
- sector is labour intensive, there is a foreign equity investment value,
and there is no value for number of new jobs;
d) sector is labour intensive, there is no foreign equity investment value,
- sector is labour intensive, there is no foreign equity investment value,
and there is no value for number of new jobs;
"""
sector = SectorFactory()
Expand Down Expand Up @@ -269,11 +300,12 @@ def test_gva_calculation_based_on_sector_classification_when_expected_gva_is_not
number_new_jobs,
expected_gva_value: Decimal,
):
"""
Tests that the correct gva value is set when:
a) Sector classification is capital, there is foreign equity investment,
"""Tests that the correct gva value is set when expected:

Expected scenarios:
- Sector classification is capital, there is foreign equity investment,
and there is no value for number of new jobs
b) Sector classification is labour, there is no foreign equity investment,
- Sector classification is labour, there is no foreign equity investment,
value and there is a value for number of new jobs
"""
sector = SectorFactory()
Expand Down
Loading