Skip to content

Commit

Permalink
Merge branch 'master' into add-user-confirmation-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
wn committed Oct 25, 2018
2 parents d824ee5 + 4741095 commit 77d7034
Show file tree
Hide file tree
Showing 44 changed files with 898 additions and 381 deletions.
43 changes: 43 additions & 0 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,49 @@ It is possible for the LoanBook to have a loan that lasts for 0 minutes. This is
** Pros: Computing the `summary` of the LoanBook would be much easier, and quicker.
** Cons: `return` functionality would run much slower, as there will be empty slots in the ArrayList after shifting the Loan objects around. Searching for loans would also be much more difficult, as the results from the various Loan ArrayLists has to be appended together.

=== Summary Feature
==== Proposed Implementation

Getting the summary of all the loans is simply done by looping through all the stored loans before and aggregating the statistics of all the loans.

Currently, the `summary` command would display to the user the following statistics:

* Total number of ongoing loans
* Total number of loans ever taken out
* Total amount of time all bikes have been loaned for
* Total revenue from the loan service

This would give a very handy summary page as well as an audit page for the bicycle shop owners.

Given below is an example usage scenerio and how the internals of the Loan would behave:

**Step 1.** The user simply has to type the `summary` keyword into the CLI.

**Step 2.** The LoanBook will proceed to loop through all the loans and aggregate the statistics of the loans. Simple statistics to be counted include the total time of loan and the total revenue gained from the loans.

**Step 3.** The LoanBook will update the display with the aggregated statistics, and this can be screenshotted by the user as an audit page.

==== Design considerations:
===== Aspect: Getting the summary
* **Alternative 1 (current choice):** Looping through the entire list of loans to get the summary of the content
** Pros: Easy to implement, and do not need to create new data storage features.
** Cons: Looping through all loans will take more time, as the LoanBook would have to check every loan and recalculate.

* Alternative 2: Use a cache to store previously calculated values of the summaries.
** Pros: Quicker response time to the users.
** Cons: Much hearder to implement, cache might break if user edits past loans.

==== Future features
We plan to include a feature which allows users to summarize the loanbook based on certain parameters. For example, in future implementations, the user will be able to filter the statistics based on the identity of a bicycle.

These are the proposed features you would be able to search based on:

* Bicycle
* Time period
* Person who took out the loan

As well, having to recalculate all the loans would be a bad idea when the LoanBook contains many loans. A proposed solution would be to cache the results of the main summary method, so that the LoanBook would only have to recalculate the numbers based on loans that have not been added to the final tally.

=== Logging

We are using `java.util.logging` package for logging. The `LogsCenter` class is used to manage the logging levels and logging destinations.
Expand Down
45 changes: 34 additions & 11 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ e.g. typing *`help`* and pressing kbd:[ENTER] will open the help window.

=== Viewing help : `help`

Provides a list of all commands together with a basic description, how-to-use and example usage for each +
Provides a list of all commands together with a basic description, how-to-use and example usage for each command. +
Format: `help`

=== Adding a loan: `add`

Adds a loan to the loan book with the following parameters, and displays the transaction along with a Loan ID to keep track of the loan +
Adds a loan to the loan book with the following parameters, and displays the transaction along with a LOAN_ID to keep track of the loan. +
Format: `add p/PERSON_NAME hp/PERSON_PHONE_NO e/PERSON_EMAIL r/RATE o/OBJECT_IDENTITY`

[TIP]
Expand All @@ -67,7 +67,7 @@ Examples:

=== Listing all loans : `list`

Shows a list of all loans in the loan book. +
Shows a list of all loans in the LoanBook. +
Format: `list`

=== Editing a loan : `edit`
Expand All @@ -76,7 +76,7 @@ In case a wrong entry is keyed in, or the customer changes their mind, this comm
Format: `edit i/LOAN_ID [p/PERSON_NAME] [hp/PERSON_PHONE_NO] [e/PERSON_EMAIL] [r/RATE] [o/OBJECT_IDENTITY]`

****
* Edits the loan at the specified `LOAN_ID`. The index refers to the index number shown in the displayed loan list. The index *must be a positive integer* 1, 2, 3, ...
* Edits the loan at the specified `LOAN_ID`. This LOAN_ID refers to the LOAN_ID number shown in the displayed loan list. The LOAN_ID *must be a positive integer* 1, 2, 3, ...
* At least one of the optional fields must be provided.
* Existing values will be updated to the input values.
* When editing tags, the existing tags of the loan will be removed i.e adding of tags is not cumulative.
Expand All @@ -91,7 +91,7 @@ For the loan with Loan ID 90210, changes the customer to James Tan, who has the

=== Locating loans by key words: `search`

Returns a loan based on parameters of LOAN_ ID, PERSON_NAME or OBJECT_IDENTITY. +
Returns a loan based on parameters of LOAN_ID, PERSON_NAME or OBJECT_IDENTITY. +
Format: `search [i/LOAN_ID] [p/PERSON_NAME] [o/OBJECT_IDENTITY]`

****
Expand All @@ -104,7 +104,7 @@ Format: `search [i/LOAN_ID] [p/PERSON_NAME] [o/OBJECT_IDENTITY]`
Examples:

* `search i/11037` +
Searches for the loan with Loan ID 11037
Searches for the loan with LOAN_ID 11037
* `search p/James Tan` +
Searches for loans made by James Tan
* `search p/John Doe o/Bicycle-007` +
Expand All @@ -123,30 +123,53 @@ Format: `delete i/LOAN_ID` or `delete!`
Examples:

* `delete i/11037` +
Deletes the loan with Loan ID 11037.
Deletes the loan with LOAN_ID 11037.
* `delete!` +
Deletes all loan records.

=== Returning a loan : `return`

Marks a loan as returned based on LOAN_ ID and automatically prints out the amount payable. +
Marks a loan as returned based on LOAN_ID and automatically prints out the amount payable. +
Format: `return i/LOAN_ID`

Examples:

* `return i/11037` +
Marks the loan with Loan ID 11037 as returned. Also automatically prints out the amount payable based on loan time and rate.
Marks the loan with LOAN_ID 11037 as returned. Also automatically prints out the amount payable based on loan time and rate.

=== Hard reset the entire loan book : `reset`

Removes all the loans from the loan book and resets the LOAN_ID counter. +
Format: `reset`

[NOTE]
====
The difference between deleting all the loans and hard resetting the LoanBook is that when a loan is delete, you will still be able to search for it. However, the statistics of deleted loans do not appear in the `summary` command.
====

[WARNING]
====
**Hard resetting the LoanBook will remove ALL loans! Do this ar your own peril.**
====

=== Summarize all the transactions : `summary`

Show the total number of loans that are done and in progress. Also summarizes the loan status of each item, the number of times an object was loaned before. +
Show the total number of loans that are done and in progress. Also summarizes the loan status of each item, the number of times an object was loaned before.

The `summary` function would display the statistics of all your loans in the display box on the right of the application. There, you will find the following statistics:

* Total number of ongoing loans
* Total number of loans ever taken out
* Total amount of time all bikes have been loaned for
* Total revenue from the loan service

Format: `summary`

[NOTE]
====
The summary feature may take a while to run, especially when you have many loans that you have made in the past. Please allow about a second for it to process.
====

=== Listing entered commands : `history`

Lists all the commands that you have entered in reverse chronological order. +
Expand All @@ -165,7 +188,7 @@ Pressing the kbd:[↑] and kbd:[↓] arrows will display the previous and
** Populate recently loaned items/users, depending on the input. i.e. add i/ should show a dropdown on the last 5 items used. User can type add i/5 to select the 5th LRU item.
** typing `del` followed by tab auto completes to `delete`
* Send reminder email to the borrower after a day of borrowing reminding them to return the bike.
* Login authentication to ensure that some other bugger don't delete the loan stuffs. Require password when deleting.
* Login authentication to ensure that unauthorised people do not delete the loans which they are not supposed to. Require password when deleting.

////
// tag::undoredo[]
Expand Down
Binary file modified docs/diagrams/ModelComponentClassDiagram.pptx
Binary file not shown.
Binary file modified docs/images/ModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 15 additions & 2 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import seedu.address.model.loan.Email;
import seedu.address.model.loan.Loan;
import seedu.address.model.loan.LoanRate;
import seedu.address.model.loan.LoanStatus;
import seedu.address.model.loan.LoanTime;
import seedu.address.model.loan.Name;
import seedu.address.model.loan.Nric;
Expand Down Expand Up @@ -90,7 +91,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
Loan loanToEdit = lastShownList.get(index.getZeroBased());
Loan editedLoan = createEditedLoan(loanToEdit, editLoanDescriptor);

if (!loanToEdit.isSameLoan(editedLoan) && model.hasLoan(editedLoan)) {
if (!loanToEdit.isSame(editedLoan) && model.hasLoan(editedLoan)) {
throw new CommandException(MESSAGE_DUPLICATE_LOAN);
}

Expand All @@ -116,6 +117,7 @@ private static Loan createEditedLoan(Loan loanToEdit, EditLoanDescriptor editLoa
LoanRate updatedRate = editLoanDescriptor.getLoanRate().orElse(loanToEdit.getLoanRate());
LoanTime updatedTime = editLoanDescriptor.getLoanTime().orElse(loanToEdit.getLoanTime());
Set<Tag> updatedTags = editLoanDescriptor.getTags().orElse(loanToEdit.getTags());
LoanStatus updatedLoanStatus = editLoanDescriptor.getLoanStatus().orElse(loanToEdit.getLoanStatus());

return new Loan(updatedName,
updatedNric,
Expand All @@ -125,7 +127,8 @@ private static Loan createEditedLoan(Loan loanToEdit, EditLoanDescriptor editLoa
updatedBike,
updatedRate,
updatedTime,
updatedTags);
updatedLoanStatus, updatedTags
);
}

@Override
Expand Down Expand Up @@ -160,6 +163,7 @@ public static class EditLoanDescriptor {
private LoanRate rate;
private LoanTime time;
private Set<Tag> tags;
private LoanStatus loanStatus;

public EditLoanDescriptor() {}

Expand All @@ -177,6 +181,7 @@ public EditLoanDescriptor(EditLoanDescriptor toCopy) {
setLoanRate(toCopy.rate);
setLoanTime(toCopy.time);
setTags(toCopy.tags);
setLoanStatus(toCopy.loanStatus);
}

/**
Expand Down Expand Up @@ -267,6 +272,14 @@ public Optional<Set<Tag>> getTags() {
return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty();
}

public void setLoanStatus(LoanStatus loanStatus) {
this.loanStatus = loanStatus;
}

public Optional<LoanStatus> getLoanStatus() {
return Optional.ofNullable(loanStatus);
}

@Override
public boolean equals(Object other) {
// short circuit if same object
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/seedu/address/model/LoanBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import seedu.address.model.loan.UniqueLoanList;

/**
* Wraps all data (bikes and loans) at the loan-book level
* Duplicates are not allowed (by .isSameBike and .isSameLoan comparison)
* Wraps all data (bikes and loans) at the loanbook level.
* Duplicates are not allowed.
*/
public class LoanBook implements ReadOnlyLoanBook {

Expand Down Expand Up @@ -49,15 +49,15 @@ public LoanBook(ReadOnlyLoanBook toBeCopied) {
* {@code bikes} must not contain duplicate bikes.
*/
public void setBikes(List<Bike> bikes) {
this.bikes.setBikes(bikes);
this.bikes.setAll(bikes);
}

/**
* Replaces the contents of the loan list with {@code loans}.
* {@code loans} must not contain duplicate loans.
*/
public void setLoans(List<Loan> loans) {
this.loans.setLoans(loans);
this.loans.setAll(loans);
}

/**
Expand Down Expand Up @@ -96,7 +96,7 @@ public void addBike(Bike p) {
public void updateBike(Bike target, Bike editedBike) {
requireNonNull(editedBike);

bikes.setBike(target, editedBike);
bikes.set(target, editedBike);
}

/**
Expand Down Expand Up @@ -133,7 +133,7 @@ public void addLoan(Loan p) {
public void updateLoan(Loan target, Loan editedLoan) {
requireNonNull(editedLoan);

loans.setLoan(target, editedLoan);
loans.set(target, editedLoan);
}

/**
Expand Down
Loading

0 comments on commit 77d7034

Please sign in to comment.