Skip to content

Commit

Permalink
Merge pull request #209 from sheryew/claim-edits
Browse files Browse the repository at this point in the history
Edits for claims
  • Loading branch information
sheryew committed Nov 13, 2023
2 parents cea0498 + 65541ba commit 02e58ca
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
12 changes: 6 additions & 6 deletions docs/team/sheryew.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ Given below are my contributions to the project.
- What it does: Allows users to keep track of remaining claim budget for each employee. Dynamic allocation/subtraction of claims for each employee, allowing latest claim budget to be displayed.
- Justification: This feature reduces the effort required for administrative claim processing, since excessive claims will be rejected automatically by the system and mathematical errors are avoided completely.
- Highlights: This feature is challenging since parsing checks are required to determine if user wants to allocate/subtract those funds and thereafter, having to produce different success commands.
- PR [#63] https://github.com/AY2324S1-CS2103-F13-2/tp/pull/63
- PR [#63](https://github.com/AY2324S1-CS2103-F13-2/tp/pull/63)

- **New Feature**: Added the ability to view specific attribute for employee(s).

- What it does: Allows users to view specific attribute for employee(s). Provides faster access to attributes for employee(s) instead of manual scraping the entire list for just one attribute. (PR)
- Justification: This feature is beneficial if user just wants to view one attribute for a large number of employees. Reduces time required for manual scraping of just that attribute for the whole list.
- Highlights: This feature is challenging as I incorporated multiple index parsing and the effort to ensure every index is captured and checked for validity is time-consuming.
- PR [#70] https://github.com/AY2324S1-CS2103-F13-2/tp/pull/70
- PR [#70](https://github.com/AY2324S1-CS2103-F13-2/tp/pull/70)

- **New Feature**: Added the ability to export Employees' attributes into a CSV file.

- What it does: Allows users to export all employees' attributes into a CSV file. Additionally, users are able to export a subset of employees by filtering on criteria like department.
- Justification: This feature is beneficial as having a CSV file comprising of employees' attributes allow users to incorporate this data into third-party vendors. Allows our application to be used in harmony with others.
- Highlights: Learnt Java and its specific utility classes like PrintWriter and streams to make this feature functional.
- PR [#88] https://github.com/AY2324S1-CS2103-F13-2/tp/pull/88
- PR [#88](https://github.com/AY2324S1-CS2103-F13-2/tp/pull/88)

- **New Feature**: Added the ability to reset all employees' leaves.

- What it does: Allows users to reset existing leaves for all employees.
- Justification: This feature is beneficial whenever a new calendar year strikes, since employees leaves are resetted to zero. We do not want previous year leaves to affect existing year leaves.
- PR [#117] https://github.com/AY2324S1-CS2103-F13-2/tp/pull/117
- PR [#117](https://github.com/AY2324S1-CS2103-F13-2/tp/pull/117)

- **Code contributed**: [RepoSense link](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=sheryew&breakdown=true)

Expand All @@ -47,11 +47,11 @@ Given below are my contributions to the project.

- User Guide:
- Added documentation for the features `claim`, `view_attribute`, `export` and `reset_leaves`.
- Added UI images (Before & After) for each feature. (PR [#119] https://github.com/AY2324S1-CS2103-F13-2/tp/pull/119)
- Added UI images (Before & After) for each feature. (PR ([#119]https://github.com/AY2324S1-CS2103-F13-2/tp/pull/119))
- Developer Guide:
- Added implementation details for `claim`, `view_attribute`, `export` and `reset_leaves`.
- Added UML diagrams for `export`.

- **Community**:

- PRs reviewed. (PR [#130] https://github.com/AY2324S1-CS2103-F13-2/tp/pull/130), (PR [#85] https://github.com/AY2324S1-CS2103-F13-2/tp/pull/85), (PR [#30], https://github.com/AY2324S1-CS2103-F13-2/tp/pull/30)
- PRs reviewed. (PR [#130](https://github.com/AY2324S1-CS2103-F13-2/tp/pull/130)), (PR [#85](https://github.com/AY2324S1-CS2103-F13-2/tp/pull/85)), (PR [#30](https://github.com/AY2324S1-CS2103-F13-2/tp/pull/30))
1 change: 1 addition & 0 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class Messages {

public static final String MESSAGE_INVALID_THEME = "Invalid theme specified.\nValid themes: "
+ "dark, light, red, green, blue";
public static final String TOO_LARGE_A_NUMBER = "Maximum claim budget is $1,000,000,000,000.";

/**
* Returns an error message indicating the duplicate prefixes.
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/seedu/address/logic/commands/ClaimCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public CommandResult execute(Model model, String commandText) throws CommandExce
}

Person personToEdit = lastShownList.get(index.getZeroBased());
long prevClaimBudget = Integer.parseInt(personToEdit.getClaimBudget().amount);
long prevClaimBudget = Long.parseLong(personToEdit.getClaimBudget().amount);
Money claimBudget = calculateNewClaimBudget(prevClaimBudget);
Person editedPerson = postClaimPerson(personToEdit, claimBudget);

Expand All @@ -76,6 +76,7 @@ public CommandResult execute(Model model, String commandText) throws CommandExce

/**
* Returns a Money Object which represents the new amount the user has after the claiming process is completed.
* The maximum final claim budget remaining for each employee is capped at $1000000000000.
*
* @param prevClaimBudget long object on user's claim budget before the claim process.
* @return Money Object that highlights the new claim budget the user has.
Expand All @@ -91,6 +92,9 @@ public Money calculateNewClaimBudget(long prevClaimBudget) throws CommandExcepti
} else {
newClaimBudget = prevClaimBudget + this.amount;
}
if (newClaimBudget > Math.pow(10, 12)) {
throw new CommandException(Messages.TOO_LARGE_A_NUMBER);
}
return new Money(String.valueOf(newClaimBudget));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public ClaimCommand parse(String args) throws ParseException {
}

if (argMultimap.getValue(PREFIX_CLAIM_AMOUNT).isPresent()) {
String claimAmt = argMultimap.getValue(PREFIX_CLAIM_AMOUNT).get().substring(1);
if (claimAmt.length() > 6) {
throw new ParseException("Please input claim amount in the range of 0 to 100000 dollars.");
}
claim = ParserUtil.parseClaim(argMultimap.getValue(PREFIX_CLAIM_AMOUNT).get());
} else {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, ClaimCommand.AMOUNT_EMPTY));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/person/Claim.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Claim {
public static final String ALPHABETS_ERROR = "Kindly only input integers for the claim amount!";

public final boolean isSubtract;
public final int amount;
public final long amount;

/**
* Returns a Claim Object which contains of two variables, isSubtract and amount.
Expand All @@ -26,7 +26,7 @@ public Claim(String numStr) {
} else {
this.isSubtract = true;
}
this.amount = Integer.parseInt(numStr.substring(1));
this.amount = Long.parseLong(numStr.substring(1));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ public void execute_calculationExcessBudget_failure() {
}, Messages.MESSAGE_OVER_CLAIM);
}

@Test
public void execute_calculationExcessLongBudget_failure() {
long claimAmount = (long) (originalBudget + Math.pow(10, 12));
ClaimCommand claimCommand = new ClaimCommand(INDEX_FIRST_PERSON, !isSubtract, claimAmount);
assertThrows(CommandException.class, () -> {
claimCommand.calculateNewClaimBudget(originalBudget);
}, Messages.TOO_LARGE_A_NUMBER);
}

@Test
public void execute_generateNewPerson_success() {
Money newClaimBudget = new Money(String.valueOf(originalBudget + 1));
Expand Down

0 comments on commit 02e58ca

Please sign in to comment.