diff --git a/docs/team/sheryew.md b/docs/team/sheryew.md index 3ac3693ea76..4016111ed92 100644 --- a/docs/team/sheryew.md +++ b/docs/team/sheryew.md @@ -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) @@ -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)) diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index 7810de699c0..a57d19116f8 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -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. diff --git a/src/main/java/seedu/address/logic/commands/ClaimCommand.java b/src/main/java/seedu/address/logic/commands/ClaimCommand.java index d5a9bea80e5..61b0dec8075 100644 --- a/src/main/java/seedu/address/logic/commands/ClaimCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClaimCommand.java @@ -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); @@ -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. @@ -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)); } diff --git a/src/main/java/seedu/address/logic/parser/ClaimCommandParser.java b/src/main/java/seedu/address/logic/parser/ClaimCommandParser.java index 4403d04e7f1..7104523a016 100644 --- a/src/main/java/seedu/address/logic/parser/ClaimCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/ClaimCommandParser.java @@ -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)); diff --git a/src/main/java/seedu/address/model/person/Claim.java b/src/main/java/seedu/address/model/person/Claim.java index 6aeb35f955e..3c2485c1ca0 100644 --- a/src/main/java/seedu/address/model/person/Claim.java +++ b/src/main/java/seedu/address/model/person/Claim.java @@ -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. @@ -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)); } /** diff --git a/src/test/java/seedu/address/logic/commands/ClaimCommandTest.java b/src/test/java/seedu/address/logic/commands/ClaimCommandTest.java index 6be1a0d7d43..627c46324db 100644 --- a/src/test/java/seedu/address/logic/commands/ClaimCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ClaimCommandTest.java @@ -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));