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

Testing leads #198

Merged
merged 9 commits into from
Apr 15, 2024
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
15 changes: 11 additions & 4 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,20 @@ Examples:

### Getting client call list: `leads`
Generates a list of leads by sorting ALL clients based on the predicted next time of housekeeping.
(There is no way to use the find feature with leads)
Clients with predicted next housekeeping date which is in the future will not be included.
(There is no way to use the find feature with leads)<br>

Format: `leads`
The purpose of the command is to provide a list of clients who are due for housekeeping. This could serve as a
reminder to the client or a sales prompt for you to contact the client for another housekeeping appointment. As such,
clients with predicted next housekeeping date which is in the future will not be included. `leads` will only include
clients with housekeeping details and have predicted next housekeeping date which is in the past or today.
(past is included because you might miss the call for the client)

Format: `leads`<br>

<div markdown="span" class="alert alert-primary">:bulb: **Tip:**
The leads are sorted with the client with the earliest predicted next housekeeping date at the top. Housekeeping details are optional so clients without housekeeping details will not be included in the leads.
The leads are sorted with the client with the earliest predicted next housekeeping date at the top.
Housekeeping details are optional so clients without housekeeping details will not be included in the leads.
Also, so long as `leads` is the first word in the command, the command will work.
</div>

[:arrow_up_small:](#table-of-contents)
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/housekeeping/hub/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import housekeeping.hub.commons.core.index.Index;
import housekeeping.hub.commons.util.StringUtil;
import housekeeping.hub.logic.commands.BookingCommand;
import housekeeping.hub.logic.parser.exceptions.ParseException;
import housekeeping.hub.model.person.Address;
import housekeeping.hub.model.person.Area;
Expand Down Expand Up @@ -188,7 +189,7 @@ public static LocalDate parseLastHousekeepingDate(String lHD) throws ParseExcept
LocalDate parsedLhd = LocalDate.parse(lHD);
return parsedLhd;
} catch (Exception e) {
throw new ParseException(HousekeepingDetails.MESSAGE_CONSTRAINTS);
throw new ParseException(BookingCommand.MESSAGE_USAGE);
}
}

Expand Down Expand Up @@ -231,7 +232,7 @@ public static Period parsePreferredInterval(String pI) throws ParseException {
period = Period.ofYears(quantity);
break;
default:
throw new ParseException(HousekeepingDetails.MESSAGE_CONSTRAINTS);
throw new ParseException(BookingCommand.MESSAGE_USAGE);
}
return period;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.time.LocalDate;
import java.time.Period;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -108,7 +109,7 @@ public static String makeStoredDetailsReadable(String details) {
// Converting Period of preferred interval to a readable format
String[] s = details.split(" ");
// If valid s[0] = lastHousekeepingDate, s[1] = preferredInterval,
// s[2] = booking, s[3] = deferment
// s[2] = booking, s[3?] = am/pm, s[3/4] = deferment
String num = s[1].substring(1, s[1].length() - 1);
String unit = s[1].substring(s[1].length() - 1);
String unitString;
Expand All @@ -130,7 +131,7 @@ public static String makeStoredDetailsReadable(String details) {
}

// Makes null booking readable
String booking = s[2].equals("null") ? "No booking" : s[2];
String booking = s[2].equals("null") ? "No booking" : s[2] + " " + s[3];

return String.format("Last housekeeping: %s\nPreferred interval: %s %s\nBooking date: %s",
s[0], num, unitString, booking);
Expand Down Expand Up @@ -193,7 +194,7 @@ public static String makeStoredDetailsReadableWithDeferment(String details) {
}

// Makes null booking readable
String booking = s[2].equals("null") ? "No booking" : s[2];
String booking = s[2].equals("null") ? "No booking" : s[2] + " " + s[3];

return String.format("Last housekeeping: %s, Preferred interval: %s %s, Booking date: %s, Deferment: %s %s",
s[0], numPI, unitStringPI, booking, numD, unitStringD);
Expand Down Expand Up @@ -241,12 +242,15 @@ public Period getDeferment() {
public Booking getBooking() {
return booking;
}
public String getDefermentToString() {
String details = this.toString();
String[] s = details.split(" "); // If valid s[0] = lastHousekeepingDate, s[1] = preferredInterval,
// s[2] = bookingDate, s[4] = deferment
String num = s[s.length - 1].substring(1, s[3].length() - 1);
String unit = s[s.length - 1].substring(s[s.length - 1].length() - 1);

/**
* Converts the deferment period to a readable format.
* @return
*/
public String getDefermentToReadableString() {
String details = this.getDeferment().toString();
String num = details.substring(1, details.length() - 1);
String unit = details.substring(details.length() - 1);
String unitString;
switch (unit) {
case "Y":
Expand Down Expand Up @@ -288,14 +292,10 @@ public boolean equals(Object other) {
HousekeepingDetails otherDetails = (HousekeepingDetails) other;

// First predicate of each && is for null values, second predicate is for non-null values
return ((lastHousekeepingDate == otherDetails.lastHousekeepingDate
|| lastHousekeepingDate.equals(otherDetails.lastHousekeepingDate))
&& (preferredInterval == otherDetails.preferredInterval
|| preferredInterval.equals(otherDetails.preferredInterval))
&& (booking == otherDetails.booking
|| booking.equals(otherDetails.booking))
&& (deferment == otherDetails.deferment
|| deferment.equals(otherDetails.deferment)));
return Objects.equals(lastHousekeepingDate, otherDetails.lastHousekeepingDate)
&& Objects.equals(preferredInterval, otherDetails.preferredInterval)
&& Objects.equals(booking, otherDetails.booking)
&& Objects.equals(deferment, otherDetails.deferment);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import housekeeping.hub.logic.parser.exceptions.ParseException;
import housekeeping.hub.model.person.Booking;
import housekeeping.hub.model.person.BookingSearchPredicate;
import housekeeping.hub.model.person.HousekeepingDetails;

public class BookingCommandParserTest {

Expand Down Expand Up @@ -310,7 +309,7 @@ public void parse_clientEditLastHousekeepingDate_throwParseException() throws Pa
assertParseFailure(parser, INVALID_CLIENT_EDIT_LAST_HOUSEKEEPING_DATE_MISSING_PREFIX,
MESSAGE_INVALID_FORMAT_EDIT_HOUSEKEEPING_DETAILS_COMMAND);
assertParseFailure(parser, INVALID_CLIENT_EDIT_LAST_HOUSEKEEPING_DATE_MISSING_DATE,
HousekeepingDetails.MESSAGE_CONSTRAINTS);
BookingCommand.MESSAGE_USAGE);
assertParseFailure(
parser, INVALID_CLIENT_EDIT_LAST_HOUSEKEEPING_DATE_MISSING_ALL_PARAMETERS,
MESSAGE_INVALID_FORMAT);
Expand Down Expand Up @@ -340,7 +339,7 @@ public void parse_clientEditPreferredInterval_throwParseException() throws Parse
assertParseFailure(parser, INVALID_CLIENT_EDIT_PREFERRED_INTERVAL_INVALID_PREFIX,
MESSAGE_INVALID_FORMAT_EDIT_HOUSEKEEPING_DETAILS_COMMAND);
assertParseFailure(parser, INVALID_CLIENT_EDIT_PREFERRED_INTERVAL_INVALID_INTERVAL,
HousekeepingDetails.MESSAGE_CONSTRAINTS);
BookingCommand.MESSAGE_USAGE);
}

@Test
Expand Down Expand Up @@ -384,7 +383,7 @@ public void parse_clientEditDeferment_throwParseException() throws ParseExceptio
assertParseFailure(parser, INVALID_CLIENT_EDIT_DEFERMENT_INVALID_PREFIX,
MESSAGE_INVALID_FORMAT_EDIT_HOUSEKEEPING_DETAILS_COMMAND);
assertParseFailure(parser, INVALID_CLIENT_EDIT_DEFERMENT_INVALID_INTERVAL,
HousekeepingDetails.MESSAGE_CONSTRAINTS);
BookingCommand.MESSAGE_USAGE);
}

@Test
Expand Down
Loading
Loading