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

Add transactions template to portfolio summary #4891

Merged
merged 35 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3b6c6fe
move functionality to backend
Nov 1, 2024
758ca3d
sorting on related functional
Nov 8, 2024
95d808b
Merge branch 'develop' into portfolio-summary-move-to-backend
perryr16 Nov 22, 2024
64136e7
cleanup
Nov 22, 2024
acee597
precommit
Nov 22, 2024
61613ea
lint
Nov 22, 2024
8681484
add type and trasnaction to goal model
Dec 2, 2024
b3d461b
transactions summary endpoint functional
Dec 3, 2024
a188610
transaction data dev
Dec 3, 2024
868c004
return if not none
Dec 3, 2024
b128138
Merge branch 'portfolio-summary-move-to-backend' into portfolio-summa…
Dec 3, 2024
1ba0b7a
rename transactions_column
Dec 3, 2024
3be9fc0
add transaction data to endpoint
Dec 3, 2024
eee28fb
move goal fxns to util
Dec 4, 2024
fc575c3
transaction data functional
Dec 4, 2024
549bb34
format summary in backend
Dec 4, 2024
79273ef
translations
Dec 4, 2024
85fe78e
precommit
Dec 4, 2024
99c01e2
filters on trasnaction cols
Dec 4, 2024
650fca9
set transactions to none if standard
Dec 5, 2024
8d4fb9c
merge
Dec 5, 2024
846e719
translations
Dec 5, 2024
92701eb
early return
Dec 5, 2024
109c5fb
update tests w new ps format
Dec 6, 2024
4825611
merge conflicts
Dec 10, 2024
bdc720f
catch incorrect datatype
Dec 10, 2024
18b57b9
precommit
Dec 10, 2024
c9241fa
Merge branch 'develop' into portfolio-summary-transactions
perryr16 Dec 10, 2024
294ef9d
merge conflicts
Dec 10, 2024
2630689
Merge branch 'develop' into portfolio-summary-transactions
kflemin Dec 10, 2024
5d76876
missing url
Dec 11, 2024
c273851
add goal type desc, rename migration, and fix typo
kflemin Dec 11, 2024
8c0f1cd
Merge branch 'develop' into portfolio-summary-transactions
kflemin Dec 11, 2024
bb4c6ef
lint
kflemin Dec 11, 2024
6788b68
Merge branch 'develop' into portfolio-summary-transactions
kflemin Dec 11, 2024
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
29 changes: 29 additions & 0 deletions seed/migrations/0234_transaction_goals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 3.2.25 on 2024-12-02 22:02

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("seed", "0233_alter_goal_options"),
]

operations = [
migrations.AddField(
model_name="goal",
name="transactions_column",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="goal_transactions_columns",
to="seed.column",
),
),
migrations.AddField(
model_name="goal",
name="type",
field=models.CharField(choices=[("standard", "standard"), ("transaction", "transaction")], default="standard", max_length=255),
),
]
14 changes: 14 additions & 0 deletions seed/models/goals.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

from seed.models import AccessLevelInstance, Column, Cycle, Organization, Property

GOAL_TYPE_CHOICES = (
("standard", "standard"),
("transaction", "transaction"),
)


class Goal(models.Model):
organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
Expand All @@ -25,10 +30,19 @@ class Goal(models.Model):
target_percentage = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(100)])
commitment_sqft = models.IntegerField(blank=True, null=True, validators=[MinValueValidator(0)])
name = models.CharField(max_length=255, unique=True)
type = models.CharField(max_length=255, choices=GOAL_TYPE_CHOICES, default="standard")
transactions_column = models.ForeignKey(
Column, on_delete=models.CASCADE, related_name="goal_transactions_columns", blank=True, null=True
)

class Meta:
ordering = ["name"]

def save(self, *args, **kwargs):
if self.type == "standard":
self.transactions_column = None
super().save(*args, **kwargs)

def __str__(self):
return f"Goal - {self.name}"

Expand Down
18 changes: 14 additions & 4 deletions seed/serializers/goals.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ def to_representation(self, obj):
"level_name": obj.organization.access_level_names[level_index],
"baseline_cycle_name": obj.baseline_cycle.name,
"current_cycle_name": obj.current_cycle.name,
"eui_column1_name": obj.eui_column1.display_name,
"eui_column2_name": obj.eui_column2.display_name if obj.eui_column2 else None,
"eui_column3_name": obj.eui_column3.display_name if obj.eui_column3 else None,
"area_column_name": obj.area_column.display_name,
"eui_column1_name": self.get_column_name(obj.eui_column1),
"eui_column2_name": self.get_column_name(obj.eui_column2),
"eui_column3_name": self.get_column_name(obj.eui_column3),
"area_column_name": self.get_column_name(obj.area_column),
}
if obj.type == "transaction":
details["transactions_column_name"] = self.get_column_name(obj.transactions_column)
result.update(details)

return result
Expand Down Expand Up @@ -61,3 +63,11 @@ def validate(self, data):
raise ValidationError("Columns must be unique.")

return data

def get_column_name(self, column):
if not column:
return None
elif column.display_name:
return column.display_name
else:
return column.column_name
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ angular.module('SEED.controller.goal_editor_modal', [])
'access_level_tree',
'area_columns',
'auth_payload',
'columns',
'cycles',
'eui_columns',
'goal',
Expand All @@ -31,6 +32,7 @@ angular.module('SEED.controller.goal_editor_modal', [])
access_level_tree,
area_columns,
auth_payload,
columns,
cycles,
eui_columns,
goal,
Expand All @@ -40,20 +42,23 @@ angular.module('SEED.controller.goal_editor_modal', [])
$scope.auth = auth_payload.auth;
$scope.organization = organization;
$scope.write_permission = write_permission;
$scope.goal = goal || {};
$scope.access_level_tree = access_level_tree.access_level_tree;
$scope.level_names = access_level_tree.access_level_names.map((level, i) => ({
index: i,
name: level
}));
$scope.cycles = cycles;
$scope.columns = columns.sort((a, b) => (a.displayName.toLowerCase() < b.displayName.toLowerCase() ? -1 : 1));
$scope.area_columns = area_columns;
$scope.eui_columns = eui_columns;
// allow "none" as an option
if (!eui_columns.find((col) => col.id === null && col.displayName === '')) {
$scope.eui_columns.unshift({ id: null, displayName: '' });
}

$scope.goal = goal || {};
$scope.valid = false;
$scope.goal_types = ['standard', 'transaction'];

const sort_goals = (goals) => goals.sort((a, b) => (a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1));
const get_goals = () => {
Expand Down
Loading
Loading