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

Ppp #230

Merged
merged 2 commits into from
Apr 10, 2024
Merged

Ppp #230

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
45 changes: 45 additions & 0 deletions docs/team/dtaywd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Tay Wen Duan David Project Portfolio Page

## Project: SuperTracker

SuperTracker is a desktop app for managing a supermarket's inventory and expenditures,
optimized for use via a Command Line Interface (CLI).

Given below are my contributions to the project.

- **Feature:** Update Command
- What it does: Allows users to update the price, quantity and/or expiry date.
- Justification: A supermarket manager can make mistakes when adding items
and the app should provide a convenient way to rectify them, instead of manually deleting the item from the inventory
and adding it back in with a new price, quantity and/or expiry date.
- Highlights: Before creating a new update command, the parser helps to validate the users inputs by checking if the
numbers provided are negative or over the integer limit and whether the expiry date follows the correct date format.

- **Feature:** Report Command
- What it does: Allows supermarket managers to see what items are low on stock and are close to expiry.
- Justification: A supermarket manager may want to see what items are low on stock or close to expiry, so that they
may make an order to replace them.
- Highlights: Report command handles two different types of reports with only 1 needing the optional parameter and
sorts the report based on quantity or expiry date for low stock and expiry report respectively.

- **Feature:** Expenditure Command
- What it does: Allows supermarket managers to check their expenditures over a period of time.
- Justification: This function is necessary to see what is the cash outflow of the supermarket. Moreover, this
function is necessary to calculate the profit of the supermarket
- Highlights: The expenditure command unifies what the revenue commands uses to reduce the amount of repeated code.


- **Code contributed** [RepoSense link](https://nus-cs2113-ay2324s2.github.io/tp-dashboard/?search=dtaywd&breakdown=true&sort=groupTitle%20dsc&sortWithin=title&since=2024-02-23&timeframe=commit&mergegroup=&groupSelect=groupByRepos&checkedFileTypes=docs~functional-code~test-code~other)


- **Documentation**
- [User Guide](https://ay2324s2-cs2113-t13-4.github.io/tp/UserGuide.html)
- Added documentation for update, report and expenditure command
- [Developer Guide:](https://ay2324s2-cs2113-t13-4.github.io/tp/DeveloperGuide.html)
- Added implementation details of update command
- Used PlantUML to create the UML class and sequence diagrams for update command

- **Contributions to team-based tasks:**
- Teammate PR reviewed: [40](https://github.com/AY2324S2-CS2113-T13-4/tp/pull/85), [71](https://github.com/AY2324S2-CS2113-T13-4/tp/pull/71), [85](https://github.com/AY2324S2-CS2113-T13-4/tp/pull/85)
- Contributed to the JUnit tests for update and report
- Helped suggest improvements
79 changes: 47 additions & 32 deletions src/main/java/supertracker/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,24 +496,16 @@ private static void validateRevExpFormat(
) throws TrackerException {
switch (taskType) {
case TODAY:
if (hasStart || hasEnd) {
validateTodayFormat(command);
}
todayErrorFormat(hasStart, hasEnd, command);
break;
case TOTAL:
if (hasStart || hasEnd) {
validateTotalFormat(command);
}
totalErrorFormat(hasStart, hasEnd, command);
break;
case DAY:
if (!hasStart || hasEnd || !hasStartParam) {
validateDayFormat(command);
}
dayErrorFormat(hasStart, hasEnd, command, hasStartParam);
break;
case RANGE:
if (!hasStart || !hasEnd || !hasStartParam || !hasEndParam) {
validateRangeFormat(command);
}
rangeErrorFormat(hasStart, hasEnd, command, hasStartParam, hasEndParam);
break;
default:
handleInvalidFormat(command);
Expand All @@ -523,35 +515,58 @@ private static void validateRevExpFormat(
//@@author

//@@author dtaywd
private static void validateTodayFormat(String command) throws TrackerException {
if (command.equals(EXPENDITURE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_EXP_TODAY_FORMAT);
} else if (command.equals(REVENUE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_REV_TODAY_FORMAT);
private static void todayErrorFormat(boolean hasStart, boolean hasEnd, String command) throws TrackerException {
if (hasStart || hasEnd) {
if (command.equals(EXPENDITURE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_EXP_TODAY_FORMAT);
} else if (command.equals(REVENUE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_REV_TODAY_FORMAT);
}
}
}

private static void validateTotalFormat(String command) throws TrackerException {
if (command.equals(EXPENDITURE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_EXP_TOTAL_FORMAT);
} else if (command.equals(REVENUE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_REV_TOTAL_FORMAT);
private static void totalErrorFormat(boolean hasStart, boolean hasEnd, String command) throws TrackerException {
if (hasStart || hasEnd) {
if (command.equals(EXPENDITURE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_EXP_TOTAL_FORMAT);
} else if (command.equals(REVENUE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_REV_TOTAL_FORMAT);
}
}
}

private static void validateDayFormat(String command) throws TrackerException {
if (command.equals(EXPENDITURE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_EXP_DAY_FORMAT);
} else if (command.equals(REVENUE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_REV_DAY_FORMAT);
private static void dayErrorFormat(
boolean hasStart,
boolean hasEnd,
String command,
boolean hasStartParam)
throws TrackerException {
if (!hasStart || hasEnd) {
if (command.equals(EXPENDITURE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_EXP_DAY_FORMAT);
} else if (command.equals(REVENUE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_REV_DAY_FORMAT);
}
} else if (!hasStartParam) {
throw new TrackerException(ErrorMessage.EMPTY_PARAM_INPUT);
}
}

private static void validateRangeFormat(String command) throws TrackerException {
if (command.equals(EXPENDITURE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_EXP_RANGE_FORMAT);
} else if (command.equals(REVENUE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_REV_RANGE_FORMAT);
private static void rangeErrorFormat(
boolean hasStart,
boolean hasEnd,
String command,
boolean hasStartParam,
boolean hasEndParam)
throws TrackerException {
if (!hasStart || !hasEnd) {
if (command.equals(EXPENDITURE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_EXP_RANGE_FORMAT);
} else if (command.equals(REVENUE_COMMAND)) {
throw new TrackerException(ErrorMessage.INVALID_REV_RANGE_FORMAT);
}
} else if (!hasStartParam || !hasEndParam) {
throw new TrackerException(ErrorMessage.EMPTY_PARAM_INPUT);
}
}

Expand Down
Loading