Skip to content

Commit

Permalink
Merge aca1e69 into 1c7590f
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadaljunied authored Oct 30, 2019
2 parents 1c7590f + aca1e69 commit 513a6bb
Show file tree
Hide file tree
Showing 30 changed files with 883 additions and 389 deletions.
1 change: 1 addition & 0 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ image::ModelClassDiagram.png[]
The `Model`,

* stores a `UserPref` object that represents the user's preferences.
* stores an `ExchangeData` object that represents the foreign exchange rates for conversion of currencies.
* stores the MYMorise data.
* exposes an unmodifiable `ObservableList<Expense>` and an unmodifiable `ObservableList<Budget>` that can be 'observed' e.g. the UI can be bound to either list so that the UI automatically updates when the data in the list change.
* does not depend on any of the other three components.
Expand Down
15 changes: 11 additions & 4 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,18 @@ Deletes the 1st expense in the results of the find command.
Deletes the second budget in the budget list in MYMorise.
// end::delete[]

=== Setting a default currency for MYMorise
todo
=== Automatic currency conversion for foreign currencies
MyMorise is able to automatically display foreign currencies in the default currency set by the user. By default this is set
to Singapore Dollars (SGD). The conversions are done in the following scenarios:

* When an expenses specifies a currency that is not the default currency
* When an expense specifies a currency that is different from that budget it is associated to.

This automatic conversion allows for the computation of budgets and expenses regardless of their underlying currencies to provide
a cleaner experience when viewing budgets and expenses with multiple differing currencies.

The latest Foreign Exchange data for a limited set of supported currencies are updated whenever the application is launched. The list of supported currencies are as follows:

=== Convert budgets or expenses to a different currency
{Shows the current list of expenses in a certain currency}

=== Autocomplete
Equip with IDE-like autocomplete function for faster input and
Expand Down
1 change: 1 addition & 0 deletions docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Interface ReadOnlyExpenseList <<Interface>>
Interface Model <<Interface>>
Interface ObservableList <<Interface>>
Class ExpenseList
Class ExchangeData
Class ReadOnlyExpenseList
Class Model
Class ModelManager
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
import seedu.address.model.UserPrefs;
import seedu.address.model.budget.BudgetList;
import seedu.address.model.budget.ReadOnlyBudgetList;
import seedu.address.model.exchangedata.ExchangeData;
import seedu.address.model.util.SampleDataUtil;

import seedu.address.storage.BudgetListStorage;
import seedu.address.storage.ExchangeDataStorage;
import seedu.address.storage.ExpenseListStorage;
import seedu.address.storage.JsonBudgetListStorage;
import seedu.address.storage.JsonExchangeDataStorage;
import seedu.address.storage.JsonExpenseListStorage;
import seedu.address.storage.JsonUserPrefsStorage;
import seedu.address.storage.Storage;
Expand Down Expand Up @@ -62,7 +65,8 @@ public void init() throws Exception {
UserPrefs userPrefs = initPrefs(userPrefsStorage);
ExpenseListStorage expenseListStorage = new JsonExpenseListStorage(userPrefs.getExpenseListFilePath());
BudgetListStorage budgetListStorage = new JsonBudgetListStorage(userPrefs.getBudgetListFilePath());
storage = new StorageManager(expenseListStorage, budgetListStorage, userPrefsStorage);
ExchangeDataStorage exchangeDataStorage = new JsonExchangeDataStorage(userPrefs.getExchangeDataFilePath());
storage = new StorageManager(expenseListStorage, budgetListStorage, exchangeDataStorage, userPrefsStorage);

initLogging(config);

Expand All @@ -82,12 +86,14 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
Optional<ReadOnlyExpenseList> expenseListOptional;
Optional<ReadOnlyBudgetList> budgetListOptional;
ReadOnlyExpenseList initialData;
ExchangeData exchangeData = new ExchangeData();
ReadOnlyBudgetList initialBudgets;
try {
expenseListOptional = storage.readExpenseList();
if (!expenseListOptional.isPresent()) {
logger.info("Data file not found. Will be starting with a sample ExpenseList");
}
exchangeData = storage.readExchangeData().get();
initialData = expenseListOptional.orElseGet(SampleDataUtil::getSampleExpenseList);
} catch (DataConversionException e) {
logger.warning("Data file not in the correct format. Will be starting with an empty ExpenseList");
Expand All @@ -111,7 +117,7 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
initialBudgets = new BudgetList();
}

return new ModelManager(initialData, initialBudgets, userPrefs);
return new ModelManager(initialData, initialBudgets, exchangeData, userPrefs);
}

private void initLogging(Config config) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/seedu/address/commons/util/HttpsClientUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package seedu.address.commons.util;

/**
* Handles all HTTP/S Requests
*/
public class HttpsClientUtil {


}
20 changes: 20 additions & 0 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import seedu.address.commons.core.GuiSettings;
import seedu.address.model.budget.Budget;
import seedu.address.model.budget.ReadOnlyBudgetList;
import seedu.address.model.exchangedata.ExchangeData;

import seedu.address.model.expense.Expense;

/**
Expand Down Expand Up @@ -56,6 +58,24 @@ public interface Model {
/** Returns the ExpenseList */
ReadOnlyExpenseList getExpenseList();

/**
* Returns the user prefs' exchangeData file path.
*/
Path getExchangeDataFilePath();

/**
* Sets the user prefs' exchangeData file path.
*/
void setExchangeDataFilePath(Path exchangeDataFilePath);

/**
* Replaces exchange data with the data in {@code exchangeData}.
*/
void setExchangeData(ExchangeData exchangeData);

/** Returns the ExchangeData */
ExchangeData getExchangeData();

/**
* Returns true if an expense with the same identity as {@code expense} exists in the expense list.
*/
Expand Down
63 changes: 44 additions & 19 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import seedu.address.model.budget.Budget;
import seedu.address.model.budget.BudgetList;
import seedu.address.model.budget.ReadOnlyBudgetList;
import seedu.address.model.exchangedata.ExchangeData;
import seedu.address.model.expense.Expense;

/**
Expand All @@ -28,39 +29,42 @@ public class ModelManager implements Model {
private final UserPrefs userPrefs;
private final FilteredList<Expense> filteredExpenses;
private final FilteredList<Budget> filteredBudgets;
private ExchangeData exchangeData;

/**
* Initializes a ModelManager with the given expenseList and userPrefs.
*/
public ModelManager(ReadOnlyExpenseList expenseList, ReadOnlyBudgetList budgetList, ReadOnlyUserPrefs userPrefs) {
public ModelManager(ReadOnlyExpenseList expenseList, ReadOnlyBudgetList budgetList,
ExchangeData exchangeData, ReadOnlyUserPrefs userPrefs) {
super();
requireAllNonNull(expenseList, userPrefs);
requireAllNonNull(expenseList, exchangeData, userPrefs);

logger.fine("Initializing with expense list: " + expenseList + ", user prefs " + userPrefs
+ " budget list: " + budgetList);
+ " budget list: " + budgetList);

this.expenseList = new ExpenseList(expenseList);
this.exchangeData = new ExchangeData(exchangeData);
this.budgetList = new BudgetList(budgetList);
this.userPrefs = new UserPrefs(userPrefs);
filteredExpenses = new FilteredList<>(this.expenseList.getExpenseList());
filteredBudgets = new FilteredList<>(this.budgetList.getBudgetList());
}

public ModelManager() {
this(new ExpenseList(), new BudgetList(), new UserPrefs());
this(new ExpenseList(), new BudgetList(), new ExchangeData(), new UserPrefs());
}

//=========== UserPrefs ==================================================================================

@Override
public void setUserPrefs(ReadOnlyUserPrefs userPrefs) {
requireNonNull(userPrefs);
this.userPrefs.resetData(userPrefs);
public ReadOnlyUserPrefs getUserPrefs() {
return userPrefs;
}

@Override
public ReadOnlyUserPrefs getUserPrefs() {
return userPrefs;
public void setUserPrefs(ReadOnlyUserPrefs userPrefs) {
requireNonNull(userPrefs);
this.userPrefs.resetData(userPrefs);
}

@Override
Expand All @@ -86,6 +90,16 @@ public void setExpenseListFilePath(Path expenseListFilePath) {
}

@Override
public Path getExchangeDataFilePath() {
return userPrefs.getExchangeDataFilePath();
}

@Override
public void setExchangeDataFilePath(Path exchangeDataFilePath) {
requireNonNull(exchangeDataFilePath);
userPrefs.setExchangeDataFilePath(exchangeDataFilePath);
}

public Path getBudgetListFilePath() {
return userPrefs.getBudgetListFilePath();
}
Expand All @@ -98,14 +112,24 @@ public void setBudgetListFilePath(Path budgetListFilePath) {

//=========== ExpenseList ================================================================================

@Override
public ReadOnlyExpenseList getExpenseList() {
return expenseList;
}

@Override
public void setExpenseList(ReadOnlyExpenseList expenseList) {
this.expenseList.resetData(expenseList);
}

@Override
public ReadOnlyExpenseList getExpenseList() {
return expenseList;
public ExchangeData getExchangeData() {
return exchangeData;
}

@Override
public void setExchangeData(ExchangeData exchangeData) {
this.exchangeData = exchangeData;
}

@Override
Expand Down Expand Up @@ -172,22 +196,23 @@ public boolean equals(Object obj) {
// state check
ModelManager other = (ModelManager) obj;
return expenseList.equals(other.expenseList)
&& userPrefs.equals(other.userPrefs)
&& filteredExpenses.equals(other.filteredExpenses)
&& budgetList.equals(other.budgetList)
&& filteredBudgets.equals(other.filteredBudgets);
&& exchangeData.equals(other.exchangeData)
&& userPrefs.equals(other.userPrefs)
&& filteredExpenses.equals(other.filteredExpenses)
&& budgetList.equals(other.budgetList)
&& filteredBudgets.equals(other.filteredBudgets);
}

//=========== BudgetList ================================================================================

@Override
public void setBudgetList(ReadOnlyBudgetList budgetList) {
this.budgetList.resetData(budgetList);
public ReadOnlyBudgetList getBudgetList() {
return budgetList;
}

@Override
public ReadOnlyBudgetList getBudgetList() {
return budgetList;
public void setBudgetList(ReadOnlyBudgetList budgetList) {
this.budgetList.resetData(budgetList);
}

@Override
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/seedu/address/model/UserPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class UserPrefs implements ReadOnlyUserPrefs {

private GuiSettings guiSettings = new GuiSettings();
private Path expenseListFilePath = Paths.get("data", "expenselist.json");
private Path exchangeDataFilePath = Paths.get("data", "exchangedata.json");
private Path budgetListFilePath = Paths.get("data", "budgetlist.json");

/**
Expand Down Expand Up @@ -58,6 +59,15 @@ public void setExpenseListFilePath(Path expenseListFilePath) {
this.expenseListFilePath = expenseListFilePath;
}

public Path getExchangeDataFilePath() {
return exchangeDataFilePath;
}

public void setExchangeDataFilePath(Path exchangeDataFilePath) {
requireNonNull(exchangeDataFilePath);
this.exchangeDataFilePath = exchangeDataFilePath;
}

public Path getBudgetListFilePath() {
return budgetListFilePath;
}
Expand All @@ -80,19 +90,21 @@ public boolean equals(Object other) {

return guiSettings.equals(o.guiSettings)
&& expenseListFilePath.equals(o.expenseListFilePath)
&& exchangeDataFilePath.equals(o.exchangeDataFilePath)
&& budgetListFilePath.equals(o.budgetListFilePath);
}

@Override
public int hashCode() {
return Objects.hash(guiSettings, expenseListFilePath, budgetListFilePath);
return Objects.hash(guiSettings, expenseListFilePath, budgetListFilePath, exchangeDataFilePath);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Gui Settings : " + guiSettings);
sb.append("\nLocal data file location : " + expenseListFilePath);
sb.append("\nExchange data file location : " + exchangeDataFilePath);
sb.append("\n " + budgetListFilePath);
return sb.toString();
}
Expand Down
Loading

0 comments on commit 513a6bb

Please sign in to comment.