Skip to content

Commit

Permalink
basic EECS data models
Browse files Browse the repository at this point in the history
  • Loading branch information
open-risk committed Jun 6, 2023
1 parent d127e99 commit 84e3fc4
Show file tree
Hide file tree
Showing 30 changed files with 530 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The initial functionality of Equinox focuses on integrating the following concep
- 💬 [Discussion at the Open Risk Commons](https://www.openriskcommons.org/c/equinox/27)
- For broader sustainable finance knowledge base, consult the [Open Risk Manual](https://www.openriskmanual.org/wiki/Category:Sustainable_Finance)
- 🌱 For training, head to the [Open Risk Academy](https://www.openriskacademy.com/)
- For a [live demo](https://www.equinoxpoint.org/)


## Screenshots

Expand Down
9 changes: 9 additions & 0 deletions docs/source/Certificate.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Certificate
------------------------------

.. automodule:: portfolio.Certificate
:members:
:undoc-members:
:noindex:

.. automethod:: portfolio.Certificate.Certificate
2 changes: 1 addition & 1 deletion docs/source/Reference.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Reference
------------------------------

The **Reference App** is integrates and exposes *third party* data of a reference nature (slowly changing)
The **Reference App** integrates and exposes *third party* data of a reference nature. By reference nature we mean that these datasets are changing only slowly (e.g., annual or less frequent updates and releases, that are clearly versioned).

Reference Views
~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/source/applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Equinox Applications
==============================
The following pages document the builtin Equinox *applications*.
The following pages document the built-in Equinox *applications*.

.. toctree::
:maxdepth: 1
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

django.setup()

__version__ = '0.5'
__version__ = '0.7'

# -- Project information -----------------------------------------------------

Expand Down
8 changes: 4 additions & 4 deletions docs/source/description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ Application Layer
-----------------------
The application layer helps users extract useful information from the database and perform the required portfolio management analyses and reports. There are currently two major groups of application data:

Risk Analysis
~~~~~~~~~~~~~~
Risk Analysis Layer
~~~~~~~~~~~~~~~~~~~~

The **Risk App** is the main interface for *risk analytics* functionality (the calculation or risk metrics, KPI's and other indicators on the basis of portfolio and potentially other external data)

Reporting
~~~~~~~~~~~
Reporting Layer
~~~~~~~~~~~~~~~~

Reports are the primary means to disseminate results of analyses outside the Equinox environment. The **Reporting App** is the primary means of generating reports.
1 change: 1 addition & 0 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Portfolio Data Models

Asset
EmissionsSource
Certificate
Project
ProjectCompany
ProjectActivity
Expand Down
8 changes: 8 additions & 0 deletions dumpfixtures-usecase-3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
source ./venv/bin/activate

python3 manage.py dumpdata --format=json --indent 2 portfolio.Counterparty -o portfolio/fixtures/usecase-3/Counterparty.json

python3 manage.py dumpdata --format=json --indent 2 portfolio.PowerPlant -o portfolio/fixtures/usecase-3/PowerPlant.json

python3 manage.py dumpdata --format=json --indent 2 portfolio.Certificate -o portfolio/fixtures/usecase-3/Certificate.json
2 changes: 1 addition & 1 deletion equinox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['localhost', '0.0.0.0', '127.0.0.1', 'www.equinoxpoint.org']
ALLOWED_HOSTS = ['localhost', '0.0.0.0', '127.0.0.1']

# Application definition

Expand Down
6 changes: 6 additions & 0 deletions loadfixtures-usecase-3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
source ./venv/bin/activate

python3 manage.py loaddata portfolio/fixtures/usecase-3/Counterparty.json
python3 manage.py loaddata portfolio/fixtures/usecase-3/PowerPlant.json
python3 manage.py loaddata portfolio/fixtures/usecase-3/Certificate.json
4 changes: 4 additions & 0 deletions policy/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
ChangeLog
===========================

v0.4.0 (03-06-2023)
-------------------
* Model testing framework

v0.3.0 (21-04-2022)
-------------------
* Earth Day 2022 release
Expand Down
54 changes: 52 additions & 2 deletions portfolio/Asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@

class ProjectAsset(models.Model):
"""
The Project Asset model holds asset specific data for each real asset, facility (plant, infrastructure etc.) that
is part of a Portfolio or Inventory or a Project - which may or may not be financed.
The Project Asset model holds asset specific data for each real asset, facility (plant, infrastructure etc.) that is part of a Portfolio or Inventory or a Project - which may or may not be financed.
A Project Asset will in general be associated with one or more emissions sources.
Expand Down Expand Up @@ -435,3 +434,54 @@ def get_absolute_url(self):
class Meta:
verbose_name = "Building"
verbose_name_plural = "Buildings"


class PowerPlant(models.Model):
"""
The Power Plant Asset model holds power plant specific data for energy producing facilities
"""

# IDENTIFICATION & CATEGORIZATION

production_device_number = models.CharField(max_length=80, blank=True, null=True,
help_text='Production Device Number (GSRN)')

production_device_name = models.CharField(max_length=80, blank=True, null=True,
help_text='Name of Production Device')

description = models.TextField(blank=True, null=True,
help_text='Additional information about the Asset')


#
# GHG Data
#

asset_ghg_emissions = models.FloatField(blank=True, null=True,
help_text='This field stores the aggregate current annualized emissions of an asset in CO2 equivalents')

# OTHER


date_of_commisioning = models.DateField(blank=True, null=True,
help_text='Commissioning date of the power plant. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki">Documentation</a>')




#
# BOOKKEEPING FIELDS
#
creation_date = models.DateTimeField(auto_now_add=True)
last_change_date = models.DateTimeField(auto_now=True)

def __str__(self):
return self.production_device_number

def get_absolute_url(self):
return reverse('portfolio:PowerPlant_edit', kwargs={'pk': self.pk})

class Meta:
verbose_name = "Power Plant"
verbose_name_plural = "Power Plants"
5 changes: 5 additions & 0 deletions portfolio/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
ChangeLog
===========================

v0.4.0 (03-06-2023)
-------------------
* Model testing framework
* Certificate data model for EECS certificates and Guarantees of Origin

v0.3.0 (21-04-2022)
-------------------
* Earth Day 2022 release (starting separate changelog for this app)
107 changes: 107 additions & 0 deletions portfolio/Certificate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Copyright (c) 2020 - 2023 Open Risk (https://www.openriskmanagement.com)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from django.db import models
from django.urls import reverse
from portfolio.Counterparty import Counterparty
from portfolio.Asset import PowerPlant

class Certificate(models.Model):
"""
The Certificate model holds data for each individual Energy Certificate in the Portfolio
"""

# IDENTIFICATION
certificate_identifier = models.CharField(max_length=80, blank=True, null=True,
help_text='Unique EECS Certificate Number.<a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Certficate_Number">Documentation</a>')

# LINKS
seller = models.ForeignKey('Counterparty', blank=True, null=True, on_delete=models.CASCADE, related_name='Seller', help_text='EECS Account Holder (Certificate Seller). <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Account_Holder">Documentation</a>')

buyer = models.ForeignKey('Counterparty', blank=True, null=True, on_delete=models.CASCADE, related_name='Buyer', help_text='EECS Account Holder (Certificate Buyer). <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Account_Holder">Documentation</a>')

production_device = models.ForeignKey('PowerPlant', blank=True, null=True, on_delete=models.CASCADE, help_text='EECS Production Device. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Device">Documentation</a>')

# CERTIFICATE DATA

# production period
production_start = models.DateField(blank=True, null=True, help_text='EECS Production Period Start. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Period">Documentation</a>')

production_end = models.DateField(blank=True, null=True, help_text='EECS Production Period End. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Period">Documentation</a>')

# technology
technology_code = models.CharField(max_length=80, blank=True, null=True,
help_text='EECS Technology Code. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Technology_Code">Documentation</a>')

# delivery date
delivery_date = models.DateField(blank=True, null=True, help_text='EECS Delivery Date. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Delivery_Date">Documentation</a>')

# quantity
contract_quantity = models.IntegerField(default=1, blank=True, null=True,
help_text='EECS Contract Quantity. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Contract_Quantity">Documentation</a>')

# contract price

contract_price = models.FloatField(blank=True, null=True,
help_text='EECS Contract Price. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Contract_Price">Documentation</a>')

# EECS DOMAIN

production_country = models.CharField(max_length=80, blank=True, null=True,
help_text='Country / Countries of Production. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Production_Country">Documentation</a>')

production_issuing_body = models.CharField(max_length=80, blank=True, null=True,
help_text='Authorised Issuing Body of the Country / Countries of Production. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Issuing_Body">Documentation</a>')

delivery_country = models.CharField(max_length=80, blank=True, null=True,
help_text='Country of Delivery')

deliver_issuing_body = models.CharField(max_length=80, blank=True, null=True,
help_text='Authorised Issuing Body of Country of Delivery. <a class="risk_manual_url" href="https://www.openriskmanual.org/wiki/EECS_Issuing_Body">Documentation</a>')


# OTHER


support_type = models.CharField(max_length=40, blank=True, null=True,
help_text='Type of support (no support, production support, etc.)')


ics = models.CharField(max_length=40, blank=True, null=True,
help_text='Independent Criteria Scheme')


#
# BOOKKEEPING FIELDS
#
creation_date = models.DateTimeField(auto_now_add=True)
last_change_date = models.DateTimeField(auto_now=True)

def __str__(self):
return self.certificate_identifier

def get_absolute_url(self):
return reverse('portfolio:certificate_edit', kwargs={'pk': self.pk})

class Meta:
verbose_name = "Certificate"
verbose_name_plural = "Certificates"
4 changes: 2 additions & 2 deletions portfolio/Contractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

class Contractor(models.Model):
"""
The Contractor model holds data for each Contractor with an existing contract (e.g, involved in the construction of a Project, or the fulfillment of a Procurement contract)
The Contractor model holds data for each Contractor with an existing project related contract (e.g, involved in the construction of a Project, or the fulfillment of a Procurement contract)
A Contractor is a type of Counterparty, typically a corporate entity (may be SME or large corporate)
A Contractor is a type of Counterparty, typically a corporate entity (maybe an SME or a large corporate)
The Contractor data fields cover
- identity, type, address
Expand Down
Loading

0 comments on commit 84e3fc4

Please sign in to comment.