Skip to content
Snippets Groups Projects
Commit 39e32d29 authored by Harry Linrui XU's avatar Harry Linrui XU
Browse files

Cancelling add will not refresh pie chart

parent dcddfd1d
No related branches found
No related tags found
4 merge requests!43Merging frontend-testing into master,!38"Made progressbar dynamic in accordance to spending. Added balance field....,!37Made the sub progress bars respond to changes in expense,!32Added input validation to add dialog boxes.
Pipeline #214574 passed
......@@ -82,6 +82,7 @@ public class BudgetController implements FinanceController {
//TODO disable return to main menu when creating budget because this is the same view as when you create budeget
//TODO make budget item throw exception with negative amount
//TODO specify error messgage for when amount is exceeded / duplicate exists
//todo properly close screen so things are saved
//Initialize table columns
categoryCol.setCellValueFactory(new PropertyValueFactory<BudgetItem, ExpenseCategory>("budgetCategory"));
amountCol.setCellValueFactory(new PropertyValueFactory<BudgetItem, Double>("budgetAmount"));
......@@ -98,13 +99,18 @@ public class BudgetController implements FinanceController {
//sum.setText(String.valueOf(general.totalSum()));
}
private ObservableList<PieChart.Data> createBudgetPieChart() { //TODO DOESNT WORK IF BUDGETITEM HAS NO BUDGET
return FXCollections.observableArrayList(
new Data("Food", general.getBudgetItem(ExpenseCategory.FOOD).getBudgetAmount()),
new Data("Books", general.getBudgetItem(ExpenseCategory.BOOKS).getBudgetAmount()),
new Data("Clothes", general.getBudgetItem(ExpenseCategory.CLOTHES).getBudgetAmount()),
new Data("Other", general.getBudgetItem(ExpenseCategory.OTHER).getBudgetAmount())
);
private ObservableList<PieChart.Data> createBudgetPieChart() throws IllegalArgumentException { //TODO DOESNT WORK IF BUDGETITEM HAS NO BUDGET
try {
return FXCollections.observableArrayList(
new Data("Food", general.getBudgetItem(ExpenseCategory.FOOD).getBudgetAmount()),
new Data("Books", general.getBudgetItem(ExpenseCategory.BOOKS).getBudgetAmount()),
new Data("Clothes",
general.getBudgetItem(ExpenseCategory.CLOTHES).getBudgetAmount()),
new Data("Other", general.getBudgetItem(ExpenseCategory.OTHER).getBudgetAmount())
);
} catch(IllegalArgumentException iae) {
return FXCollections.observableArrayList();
}
}
/**
......
......@@ -227,7 +227,6 @@ public class IncomeExpenseController implements FinanceController {
if (sizeAf != sizeBf) {
refreshTableView();
refreshPieCharts();
refreshProgress();
}
}
......@@ -334,6 +333,7 @@ public class IncomeExpenseController implements FinanceController {
//Adds the new item to the register
if (newIncome != null) {
incomeRegister.addItem(newIncome);
incomePieChart.setData(createIncomePieChart());
}
}
......@@ -369,11 +369,14 @@ public class IncomeExpenseController implements FinanceController {
//Adds the new item to the register
if (newExpense != null) {
expenseRegister.addItem(newExpense);
expensePieChart.setData(createExpensePieChart());
}
}
@FXML
private void handleEditIncome(Income chosenIncome) {
//Create copy of chosenIncome before changes
//Instantiate FXML loader and loads the popup for adding income
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/view/AddIncome.fxml"));
......@@ -398,8 +401,6 @@ public class IncomeExpenseController implements FinanceController {
dialog.setTitle(dialogTitle);
// Show the Dialog and wait for the user to close it
dialog.showAndWait();
this.incomePieChart.setData(createIncomePieChart());
}
@FXML
......
date=2023-03-31
date=2023-04-10
amount=499.0
isRecurring=Not recurring
category=SALARY
category=GIFT
date=2023-04-10
amount=100.0
amount=200.0
isRecurring=Not recurring
category=GIFT
category=SALARY
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment