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

Bugfix balance refactor #294

Merged
Merged
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
6 changes: 6 additions & 0 deletions src/main/java/ui/ReceiptTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void removeFolder(String tag) throws DukeException {
*/
public ReceiptTracker getReceiptsByTag(String tag) {
ReceiptTracker taggedReceipts = new ReceiptTracker();
taggedReceipts.initializeMainReceiptTracker();
for (Receipt receipt : this) {
if (receipt.containsTag(tag)) {
taggedReceipts.addReceipt(receipt);
Expand All @@ -125,6 +126,7 @@ public ReceiptTracker getReceiptsByTag(String tag) {
public ReceiptTracker getMajorExpenses(String amount) {
int input = Integer.parseInt(amount);
ReceiptTracker expenseReceipts = new ReceiptTracker();
expenseReceipts.initializeMainReceiptTracker();
for (Receipt receipt : this) {
if (receipt.getCashSpent() >= input) {
expenseReceipts.addReceipt(receipt);
Expand All @@ -140,6 +142,7 @@ public ReceiptTracker getMajorExpenses(String amount) {
*/
public ReceiptTracker getMajorReceipts() {
ReceiptTracker receipts = new ReceiptTracker();
receipts.initializeMainReceiptTracker();
for (Receipt receipt : this) {
if (receipt.getCashSpent() >= 100) {
receipts.addReceipt(receipt);
Expand All @@ -155,6 +158,7 @@ public ReceiptTracker getMajorReceipts() {
*/
public ReceiptTracker getReceiptsByDate(String date) {
ReceiptTracker dateReceipts = new ReceiptTracker();
dateReceipts.initializeMainReceiptTracker();
for (Receipt receipt : this) {
if (receipt.equalsDate(date)) {
dateReceipts.addReceipt(receipt);
Expand All @@ -172,6 +176,7 @@ public ReceiptTracker getReceiptsByDate(String date) {
*/
public ReceiptTracker getReceiptsByMonthYear(int month, int year) {
ReceiptTracker receiptByMonthYear = new ReceiptTracker();
receiptByMonthYear.initializeMainReceiptTracker();
for (Receipt receipt : this) {
if ((receipt.getDate().getMonthValue() == month) && (receipt.getDate().getYear() == year)) {
receiptByMonthYear.addReceipt(receipt);
Expand All @@ -187,6 +192,7 @@ public ReceiptTracker getReceiptsByMonthYear(int month, int year) {
*/
public ReceiptTracker getReceiptsByYear(int year) {
ReceiptTracker receiptByYear = new ReceiptTracker();
receiptByYear.initializeMainReceiptTracker();
for (Receipt receipt : this) {
if (receipt.getDate().getYear() == year) {
receiptByYear.addReceipt(receipt);
Expand Down