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

Change app name, fix recurring expense bug, fix save on exit bug #206

Merged
merged 6 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
59 changes: 0 additions & 59 deletions data/addressbook.json

This file was deleted.

149 changes: 149 additions & 0 deletions data/fastTrack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"categories" : [ {
"categoryName" : "food",
"summary" : "For food"
}, {
"categoryName" : "entertainment",
"summary" : "For entertainment"
}, {
"categoryName" : "transportation",
"summary" : "For bus, car, train"
}, {
"categoryName" : "shopping",
"summary" : ""
}, {
"categoryName" : "housing",
"summary" : ""
}, {
"categoryName" : "groceries",
"summary" : ""
} ],
"expenses" : [ {
"name" : "Meal at JE",
"amount" : "4.5",
"date" : "2023-04-03",
"category" : {
"categoryName" : "food",
"summary" : "For food"
}
}, {
"name" : "Groceries",
"amount" : "56.3",
"date" : "2023-03-25",
"category" : {
"categoryName" : "food",
"summary" : "For food"
}
}, {
"name" : "Shoes",
"amount" : "75.0",
"date" : "2023-03-20",
"category" : {
"categoryName" : "shopping",
"summary" : ""
}
}, {
"name" : "Movie ticket",
"amount" : "12.99",
"date" : "2023-03-15",
"category" : {
"categoryName" : "entertainment",
"summary" : "For entertainment"
}
}, {
"name" : "MRT fare",
"amount" : "45.8",
"date" : "2023-03-10",
"category" : {
"categoryName" : "transportation",
"summary" : "For bus, car, train"
}
}, {
"name" : "milk",
"amount" : "4.5",
"date" : "2000-05-15",
"category" : {
"categoryName" : "groceries",
"summary" : ""
}
}, {
"name" : "milk",
"amount" : "4.5",
"date" : "2000-05-08",
"category" : {
"categoryName" : "groceries",
"summary" : ""
}
}, {
"name" : "milk",
"amount" : "4.5",
"date" : "2000-05-01",
"category" : {
"categoryName" : "groceries",
"summary" : ""
}
}, {
"name" : "milk",
"amount" : "4.5",
"date" : "2000-04-24",
"category" : {
"categoryName" : "groceries",
"summary" : ""
}
}, {
"name" : "milk",
"amount" : "4.5",
"date" : "2000-04-17",
"category" : {
"categoryName" : "groceries",
"summary" : ""
}
}, {
"name" : "milk",
"amount" : "4.5",
"date" : "2000-04-10",
"category" : {
"categoryName" : "groceries",
"summary" : ""
}
}, {
"name" : "milk",
"amount" : "4.5",
"date" : "2000-04-03",
"category" : {
"categoryName" : "groceries",
"summary" : ""
}
}, {
"name" : "milk",
"amount" : "4.5",
"date" : "2000-03-27",
"category" : {
"categoryName" : "groceries",
"summary" : ""
}
}, {
"name" : "milk",
"amount" : "4.5",
"date" : "2000-03-20",
"category" : {
"categoryName" : "groceries",
"summary" : ""
}
} ],
"budget" : {
"amount" : "0.0"
},
"recurringGenerators" : [ {
"expenseName" : "milk",
"expenseAmount" : "4.5",
"expenseCategory" : {
"categoryName" : "groceries",
"summary" : ""
},
"nextExpenseDate" : "2000-05-22",
"startDate" : "2000-03-20",
"endDate" : "2000-05-15",
"recurringExpenseType" : "WEEKLY"
} ]
}
2 changes: 1 addition & 1 deletion docs/tutorials/AddRemark.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ While the changes to code may be minimal, the test data will have to be updated

<div markdown="span" class="alert alert-warning">

:exclamation: You must delete AddressBook’s storage file located at `/data/addressbook.json` before running it! Not doing so will cause AddressBook to default to an empty address book!
:exclamation: You must delete AddressBook’s storage file located at `/data/fastTrack.json` before running it! Not doing so will cause AddressBook to default to an empty address book!

</div>

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ public void stop() {
logger.info("============================ [ Stopping Expense Tracker ] =============================");
try {
storage.saveUserPrefs(dataModel.getUserPrefs());
storage.saveExpenseTracker(dataModel.getExpenseTracker());
} catch (IOException e) {
logger.severe("Failed to save preferences " + StringUtil.getDetails(e));
logger.severe("Failed to save data " + StringUtil.getDetails(e));
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/UserPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class UserPrefs implements ReadOnlyUserPrefs {

private GuiSettings guiSettings = new GuiSettings();
private Path expenseTrackerFilePath = Paths.get("data" , "addressbook.json");
private Path expenseTrackerFilePath = Paths.get("data" , "fastTrack.json");

Comment on lines +17 to 18

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good image fix

/**
* Creates a {@code UserPrefs} with default values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ public RecurringExpenseManager(String expenseName, double amount,

public ArrayList<Expense> getExpenses() {
ArrayList<Expense> expenses = new ArrayList<>();
while (nextExpenseDate.isBefore(LocalDate.now())) {
LocalDate newEndDate = LocalDate.now();
if (endDate != null) {
newEndDate = !endDate.isAfter(LocalDate.now()) ? endDate : LocalDate.now();
}
while (!nextExpenseDate.isAfter(newEndDate)) {
Comment on lines +103 to +107

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

important bug fix

expenses.add(new Expense(expenseName, amount, nextExpenseDate, expenseCategory));
nextExpenseDate = recurringExpenseType.getNextExpenseDate(nextExpenseDate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public LocalDate getNextExpenseDate(LocalDate currentDate) {
currentDate = currentDate.plusWeeks(1);
break;
case DAILY:
currentDate = LocalDate.now().plusDays(1);
currentDate = currentDate.plusDays(1);
break;
case YEARLY:
currentDate = currentDate.plusYears(1);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/ui/UiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public UiManager(Logic logic) {
@Override
public void start(Stage primaryStage) {
logger.info("Starting UI...");

//Set the application icon.
primaryStage.getIcons().add(getImage(ICON_APPLICATION));
//primaryStage.getIcons().add(getImage(ICON_APPLICATION));

try {
mainWindow = new MainWindow(primaryStage, logic);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.stage.Stage?>

<fx:root minHeight="600" minWidth="450" onCloseRequest="#handleExit" title="Address App" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1">
<fx:root minHeight="600" minWidth="450" onCloseRequest="#handleExit" title="FastTrack" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1">
<icons>
<Image url="@/images/address_book_32.png" />
</icons>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"z" : 99
}
},
"addressBookFilePath" : "addressbook.json"
"addressBookFilePath" : "fastTrack.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"y" : 100
}
},
"addressBookFilePath" : "addressbook.json"
"addressBookFilePath" : "fastTrack.json"
}
4 changes: 2 additions & 2 deletions src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class LogicManagerTest {
@BeforeEach
public void setUp() {
JsonExpenseTrackerStorage addressBookStorage = new JsonExpenseTrackerStorage(
temporaryFolder.resolve("addressBook.json"));
temporaryFolder.resolve("fastTrack.json"));
JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("userPrefs.json"));
StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage);
logic = new LogicManager(dataModel, storage);
Expand Down Expand Up @@ -70,7 +70,7 @@ public void execute_validCommand_success() throws Exception {
public void execute_storageThrowsIoException_throwsCommandException() {
// Setup LogicManager with JsonAddressBookIoExceptionThrowingStub
JsonExpenseTrackerStorage addressBookStorage = new JsonAddressBookIoExceptionThrowingStub(
temporaryFolder.resolve("ioExceptionAddressBook.json"));
temporaryFolder.resolve("ioExceptionFastTrack.json"));
JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(
temporaryFolder.resolve("ioExceptionUserPrefs.json"));
StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void readUserPrefs_extraValuesInFile_extraValuesIgnored() throws DataConv
private UserPrefs getTypicalUserPrefs() {
UserPrefs userPrefs = new UserPrefs();
userPrefs.setGuiSettings(new GuiSettings(1000, 500, 300, 100));
userPrefs.setExpenseTrackerFilePath(Paths.get("addressbook.json"));
userPrefs.setExpenseTrackerFilePath(Paths.get("FastTrack.json"));
return userPrefs;
}

Expand Down