Source code for greenlang.calculations.sfdr.pai_controversial_weapons_exposure
""" controversial_weapons_exposure """
import logging
from fingreen_web.models import CollectionItem
logger = logging.getLogger(__name__)
[docs]
class ControversialWeaponsExposure(): #pylint: disable=[invalid-name, too-few-public-methods]
""" controversial_weapons_exposure """
[docs]
def impact(self, collections, assets, invest_value_tot, period): # pylint: disable=[unused-argument]
""" Compute carbon_footprint
Formula ???
Args:
- assets
Returns:
- share_t
"""
share_t = 0
for asset in assets:
#collection = Collection.objects.get(company=asset.company)
collection = collections.filter(company=asset.company, collection_type='metrics')[0]
collection_item_controversial_weapons_exposure_bool = CollectionItem.objects.get(
collection=collection, template__name='controversial_weapons_exposure_bool')
value = collection_item_controversial_weapons_exposure_bool.value_boolean
if value:
valuation = CollectionItem.objects.get(collection__company=asset.company,
item_type='corp_valuation',
collection__period_year=period['period_year']).value_pint
#share_i =(asset.shares_pct / 100) * asset.company.valuation_eur / invest_value_tot
share_i = (asset.shares_pct / 100) * valuation / invest_value_tot
share_t = share_t + share_i
share_t = round(share_t * 100, 2)
return f'{share_t:g}'