Skip to content

Commit

Permalink
fix bug so that we treat no response as 0 for new inits line items
Browse files Browse the repository at this point in the history
  • Loading branch information
katrina-cityofdetroit committed Jul 24, 2024
1 parent 04cd4ca commit 5d2e4a5
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/js/utils/data_utils/local_storage_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ function colSum(table, colName) {
if (headers.includes(colName)) {
let sum = 0;
for (let i = 0; i < table.length; i++){
sum += Math.round(parseFloat(table[i][colName]));
var value = Math.round(parseFloat(table[i][colName]));
// treat NaN (non-numerics) as zeroes
if (value) { sum += value; }
}
return sum;
} else {
Expand Down Expand Up @@ -188,9 +190,21 @@ export class Initiative {
this.name = row['Initiative Name'];
}

expenses() { return this.data['Ballpark Total Expenses']}
expenses() {
if (this.data['Ballpark Total Expenses']) {
return this.data['Ballpark Total Expenses'];
} else {
return 0;
}
}

revenue() { return this.data['Revenue'] }
revenue() {
if (this.data['Revenue']) {
return this.data['Revenue'];
} else {
return 0;
}
}

net() { return this.expenses() - this.revenue() }

Expand Down

0 comments on commit 5d2e4a5

Please sign in to comment.