Skip to content

Commit

Permalink
fix: Income vs Expense Report could show NaN% savings ratio (#3049)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdoherty committed Mar 29, 2023
1 parent 979c927 commit 381995f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const MonthlySavingsRatioRow = (props) => {
);

let allMonthsRatioTotal = 0;
if (allMonthsIncomeTotal >= allMonthsExpenseTotal) {
if (allMonthsIncomeTotal !== 0 && allMonthsIncomeTotal >= allMonthsExpenseTotal) {
allMonthsRatioTotal = 1 - allMonthsExpenseTotal / allMonthsIncomeTotal;
}

Expand All @@ -38,7 +38,7 @@ export const MonthlySavingsRatioRow = (props) => {
const incomeTotal = incomeMonthData.get('total');
const expenseTotal = Math.abs(expenseMonthData.get('total'));
let ratio = 0;
if (incomeTotal >= expenseTotal) {
if (incomeTotal !== 0 && incomeTotal >= expenseTotal) {
ratio = 1 - expenseTotal / incomeTotal;
}

Expand Down

0 comments on commit 381995f

Please sign in to comment.