Skip to content

Commit

Permalink
Merge pull request #41 from NgeowXiuQi/Updated1.2
Browse files Browse the repository at this point in the history
Redid Salary for (V1.1) and added OtHour, OtRate and PayDeductibles (V1.2)
  • Loading branch information
abtyx authored Oct 17, 2018
2 parents c8fc720 + cf313f0 commit 91f6801
Show file tree
Hide file tree
Showing 36 changed files with 945 additions and 26 deletions.
38 changes: 38 additions & 0 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,44 @@ Figure 3.8.2.1 Activity Diagram for `unlock` command

// end::unlockcommand[]

//tag::Salary, OT Hours, OT Rate and Pay Deductibles For Staff[]
=== Salary, OT Hours, OT Rate and Pay Deductibles For Staff

==== Introduction
We have introduced four new fields to a staff namely the salary, overtime(OT) hours, OT rate and Pay deductibles
for a staff. This is to allow the HR department of the company to keep track of individual staff's details.

==== Current Implementation

The current implementation of this feature is embedded into a Person object together with the other information
that was originally in the Person object. Prefixes for the respective fields were also created to allow the HR user
to edit the necessary information whenever needed.

A newly added staff into SSENISUB would be assigned the default values of 0 for all four fields. This is to better
allow the HR staff to manage the information of the staff. Naturally, when a person first joins the company, he would
not have raked up any OT hours and the rate is dependent on the job of the individual.

Should the user now want to edit a staff's salary, OT hours, OT rate or pay deductibles, the user can now simply
input the prefixes followed by the numerals of each field to edit in the edit command. The fields would then be
edited depending if the prefixes were there or not (similar to the edit command).

==== Design Considerations
* ** Alternative 1 (First Implementation):** Merging the OT hours, OT rate and pay deductibles within a Salary class
** Pros: Easier to calculate net pay
** Cons: Harder to implement and would result in many conflicts within the software itself. Harder to debug

image::FirstImplementation.png[height="450"]
Figure 3.9.3.1 Idea of First Implementation

* **Alternative 2 (Current Implementation):** Separating out each field to their own classes
** Pros: Easier to implement and allows for more flexibility if the fields are required to be computed/used for other
information, easier to identify issues when something goes wrong
** Cons: Does not seem intuitive to separate it out since OT hours, OT rate and pay deductibles are used to compute salary

image::SecondImplementation.png[height="450"]
Figure 3.9.3.2 Idea of Second Implementation

// end::Salary, OT Hours, OT Rate and Pay Deductibles For Staff[]
== Documentation

We use asciidoc for writing documentation.
Expand Down
6 changes: 3 additions & 3 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Format: `list`
=== Editing a staff : `edit`

Edits an existing staff in SSENISUB. +
Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [s/SALARY] [d/DEPARTMENT] [m/MANAGER] [t/TAG]...`
Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [s/SALARY] [oth/OTHOUR] [otr/OTRATE] [de/DEDUCTIBLES] [d/DEPARTMENT] [m/MANAGER] [t/TAG]...`

****
* Edits the staff at the specified `INDEX`. The index refers to the index number shown in the displayed staff list. The index *must be a positive integer* 1, 2, 3, ...
Expand Down Expand Up @@ -272,9 +272,9 @@ e.g. `add n/James Ho p/22224444 e/jamesho@example.com a/123, Clementi Rd, 123466
* *Clear* : `clear`
* *Delete* : `delete INDEX` +
e.g. `delete 3`
* *Edit* : `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [s/SALARY] [d/DEPARTMENT] [m/MANAGER] [t/TAG]..
* *Edit* : `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [s/SALARY] [oth/OTHOUR] [otr/OTRATE] [de/DEDUCTIBLES] [d/DEPARTMENT] [m/MANAGER] [t/TAG]..
.` +
e.g. `edit 2 n/James Lee e/jameslee@example.com`
e.g. `edit 2 n/James Lee e/jameslee@example.com oth/10`
* *Feedback* : `feedback INDEX [f/FEEDBACK]` +
e.g. `feedback 1 f/Excellent`
* *Find* : `find KEYWORD [MORE_KEYWORDS]` +
Expand Down
Binary file added docs/images/FirstImplementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/SecondImplementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 64 additions & 2 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DEDUCTIBLES;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DEPARTMENT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_MANAGER;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_OTHOUR;
import static seedu.address.logic.parser.CliSyntax.PREFIX_OTRATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_SALARY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;

Expand All @@ -27,9 +31,13 @@
import seedu.address.model.person.Email;
import seedu.address.model.person.Manager;
import seedu.address.model.person.Name;
import seedu.address.model.person.OtHour;
import seedu.address.model.person.OtRate;
import seedu.address.model.person.PayDeductibles;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Rating;
import seedu.address.model.person.Salary;
import seedu.address.model.tag.Tag;

/**
Expand All @@ -49,6 +57,10 @@ public class EditCommand extends Command {
+ "[" + PREFIX_ADDRESS + "ADDRESS] "
+ "[" + PREFIX_DEPARTMENT + "DEPARTMENT] "
+ "[" + PREFIX_MANAGER + "MANAGER] "
+ "[" + PREFIX_SALARY + "SALARY]"
+ "[" + PREFIX_OTHOUR + "OT HOUR]"
+ "[" + PREFIX_OTRATE + "OT RATE]"
+ "[" + PREFIX_DEDUCTIBLES + "DEDUCTIBLES]"
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + "91234567 "
Expand Down Expand Up @@ -106,13 +118,17 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript
Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone());
Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail());
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress());
Salary updatedSalary = editPersonDescriptor.getSalary().orElse(personToEdit.getSalary());
OtHour updatedHours = editPersonDescriptor.getHours().orElse(personToEdit.getOtHours());
OtRate updatedRate = editPersonDescriptor.getRate().orElse(personToEdit.getOtRate());
PayDeductibles updatedDeductibles = editPersonDescriptor.getDeductibles().orElse(personToEdit.getDeductibles());
Rating updatedRating = editPersonDescriptor.getRating().orElse(personToEdit.getRating());
Department updatedDepartment = editPersonDescriptor.getDepartment().orElse(personToEdit.getDepartment());
Manager updatedManager = editPersonDescriptor.getManager().orElse(personToEdit.getManager());
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());

return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedRating, updatedDepartment,
updatedManager, updatedTags);
updatedManager, updatedSalary, updatedHours, updatedRate, updatedDeductibles, updatedTags);
}

@Override
Expand Down Expand Up @@ -142,6 +158,10 @@ public static class EditPersonDescriptor {
private Phone phone;
private Email email;
private Address address;
private Salary salary;
private OtHour hours;
private OtRate rate;
private PayDeductibles deductibles;
private Rating rating;
private Department department;
private Manager manager;
Expand All @@ -158,6 +178,10 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setPhone(toCopy.phone);
setEmail(toCopy.email);
setAddress(toCopy.address);
setSalary(toCopy.salary);
setHours(toCopy.hours);
setRate(toCopy.rate);
setDeductibles(toCopy.deductibles);
setRating(toCopy.rating);
setDepartment(toCopy.department);
setManager(toCopy.manager);
Expand All @@ -168,7 +192,8 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(name, phone, email, address, department, manager, tags);
return CollectionUtil.isAnyNonNull(name, phone, email, address, department, manager,
salary, hours, rate, deductibles, tags);
}

public void setName(Name name) {
Expand All @@ -195,6 +220,39 @@ public Optional<Email> getEmail() {
return Optional.ofNullable(email);
}

public void setSalary(Salary salary) {
this.salary = salary;
}

public Optional<Salary> getSalary() {
return Optional.ofNullable(salary);
}

public void setHours(OtHour hours) {
this.hours = hours;
}

public Optional<OtHour> getHours() {
return Optional.ofNullable(hours);
}

public void setRate(OtRate rate) {
this.rate = rate;
}

public Optional<OtRate> getRate() {
return Optional.ofNullable(rate);
}

public void setDeductibles(PayDeductibles deductibles) {
this.deductibles = deductibles;
}

public Optional<PayDeductibles> getDeductibles() {
return Optional.ofNullable(deductibles);
}


public void setAddress(Address address) {
this.address = address;
}
Expand Down Expand Up @@ -263,6 +321,10 @@ public boolean equals(Object other) {
&& getPhone().equals(e.getPhone())
&& getEmail().equals(e.getEmail())
&& getAddress().equals(e.getAddress())
&& getSalary().equals(e.getSalary())
&& getHours().equals(e.getHours())
&& getRate().equals(e.getRate())
&& getDeductibles().equals(e.getDeductibles())
&& getRating().equals(e.getRating())
&& getDepartment().equals(e.getDepartment())
&& getManager().equals(e.getManager())
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/logic/commands/RateCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public CommandResult execute(Model model, CommandHistory history) throws Command

Person editedPerson = new Person(personToEdit.getName(), personToEdit.getPhone(), personToEdit.getEmail(),
personToEdit.getAddress(), rating, personToEdit.getDepartment(), personToEdit.getManager(),
personToEdit.getTags());
personToEdit.getSalary(), personToEdit.getOtHours(), personToEdit.getOtRate(),
personToEdit.getDeductibles(), personToEdit.getTags());

model.updatePerson(personToEdit, editedPerson);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/seedu/address/logic/parser/AddCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
import seedu.address.model.person.Email;
import seedu.address.model.person.Manager;
import seedu.address.model.person.Name;
import seedu.address.model.person.OtHour;
import seedu.address.model.person.OtRate;
import seedu.address.model.person.PayDeductibles;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Rating;
import seedu.address.model.person.Salary;
import seedu.address.model.tag.Tag;

/**
Expand Down Expand Up @@ -105,11 +109,16 @@ public AddCommand parse(String args) throws ParseException {
}

Rating rating = Rating.DEFAULT_INITIAL_RATING;
Salary salary = Salary.DEFAULT_INITIAL_SALARY;
OtHour hours = OtHour.DEFAULT_INITIAL_OTHOUR;
OtRate rate = OtRate.DEFAULT_INITIAL_OTRATE;
PayDeductibles deductibles = PayDeductibles.DEFAULT_INITIAL_DEDUCTIBLES;
Department department = ParserUtil.parseDepartment(argMultimap.getValue(PREFIX_DEPARTMENT).get());
Manager manager = ParserUtil.parseManager(argMultimap.getValue(PREFIX_MANAGER).get());
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));

Person person = new Person(name, phone, email, address, rating, department, manager, tagList);
Person person = new Person(name, phone, email, address, rating, department, manager,
salary, hours, rate, deductibles, tagList);

return new AddCommand(person);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ public class CliSyntax {
public static final Prefix PREFIX_MANAGER = new Prefix("m/");
public static final Prefix PREFIX_TAG = new Prefix("t/");
public static final Prefix PREFIX_RATING = new Prefix("r/");
public static final Prefix PREFIX_SALARY = new Prefix("s/");
public static final Prefix PREFIX_OTHOUR = new Prefix("oth/");
public static final Prefix PREFIX_OTRATE = new Prefix("otr/");
public static final Prefix PREFIX_DEDUCTIBLES = new Prefix("de/");


}
20 changes: 19 additions & 1 deletion src/main/java/seedu/address/logic/parser/EditCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DEDUCTIBLES;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DEPARTMENT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_MANAGER;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_OTHOUR;
import static seedu.address.logic.parser.CliSyntax.PREFIX_OTRATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_RATING;
import static seedu.address.logic.parser.CliSyntax.PREFIX_SALARY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import java.util.Collection;
Expand Down Expand Up @@ -36,7 +40,8 @@ public EditCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
PREFIX_RATING, PREFIX_DEPARTMENT, PREFIX_MANAGER, PREFIX_TAG);
PREFIX_RATING, PREFIX_DEPARTMENT, PREFIX_MANAGER, PREFIX_SALARY, PREFIX_OTHOUR,
PREFIX_OTRATE, PREFIX_DEDUCTIBLES, PREFIX_TAG);

Index index;

Expand All @@ -59,6 +64,19 @@ public EditCommand parse(String args) throws ParseException {
if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) {
editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
}
if (argMultimap.getValue(PREFIX_SALARY).isPresent()) {
editPersonDescriptor.setSalary(ParserUtil.parseSalary(argMultimap.getValue(PREFIX_SALARY).get()));
}
if (argMultimap.getValue(PREFIX_OTHOUR).isPresent()) {
editPersonDescriptor.setHours(ParserUtil.parseHours(argMultimap.getValue(PREFIX_OTHOUR).get()));
}
if (argMultimap.getValue(PREFIX_OTRATE).isPresent()) {
editPersonDescriptor.setRate(ParserUtil.parseRate(argMultimap.getValue(PREFIX_OTRATE).get()));
}
if (argMultimap.getValue(PREFIX_DEDUCTIBLES).isPresent()) {
editPersonDescriptor.setDeductibles(ParserUtil.parseDeductibles(argMultimap
.getValue(PREFIX_DEDUCTIBLES).get()));
}
if (argMultimap.getValue(PREFIX_RATING).isPresent()) {
editPersonDescriptor.setRating(ParserUtil.parseRating(argMultimap.getValue(PREFIX_RATING).get()));
}
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
import seedu.address.model.person.Email;
import seedu.address.model.person.Manager;
import seedu.address.model.person.Name;
import seedu.address.model.person.OtHour;
import seedu.address.model.person.OtRate;
import seedu.address.model.person.PayDeductibles;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Rating;
import seedu.address.model.person.Salary;
import seedu.address.model.tag.Tag;

/**
Expand Down Expand Up @@ -98,6 +102,74 @@ public static Email parseEmail(String email) throws ParseException {
return new Email(trimmedEmail);
}

/**
* Parses a (@code String salary) into an (@code Salary).
* Leading and trailing whitespaces will be trimmed.
* @param salary
* @return A salary object after trimming.
* @throws ParseException
*/

public static Salary parseSalary(String salary) throws ParseException {
requireNonNull(salary);
String trimmedSalary = salary.trim();
if (!Salary.isValidSalary(trimmedSalary)) {
throw new ParseException(Salary.MESSAGE_CONSTRAINTS);
}
return new Salary(trimmedSalary);
}

/**
* Parses a (@code String hours) into an (@code OtHour).
* Leading and trailing whitespaces will be trimmed.
* @param hours
* @return An OtHour object after trimming.
* @throws ParseException
*/

public static OtHour parseHours(String hours) throws ParseException {
requireNonNull(hours);
String trimmedHours = hours.trim();
if (!OtHour.isValidTwoDecimalNumber(trimmedHours)) {
throw new ParseException(OtHour.MESSAGE_CONSTRAINTS);
}
return new OtHour(trimmedHours);
}

/**
* Parses a (@code String rate) into an (@code OtRate).
* Leading and trailing whitespaces will be trimmed.
* @param rate
* @return An OtRate object after trimming.
* @throws ParseException
*/

public static OtRate parseRate(String rate) throws ParseException {
requireNonNull(rate);
String trimmedRate = rate.trim();
if (!OtRate.isValidTwoDecimalNumber(trimmedRate)) {
throw new ParseException(OtRate.MESSAGE_CONSTRAINTS);
}
return new OtRate(trimmedRate);
}

/**
* Parses a (@code String deductibles) into an (@code PayDeductibles).
* Leading and trailing whitespaces will be trimmed.
* @param deductibles
* @return A PayDeductibles object after trimming.
* @throws ParseException
*/

public static PayDeductibles parseDeductibles(String deductibles) throws ParseException {
requireNonNull(deductibles);
String trimmedDeductibles = deductibles.trim();
if (!PayDeductibles.isValidTwoDecimalNumber(trimmedDeductibles)) {
throw new ParseException(PayDeductibles.MESSAGE_CONSTRAINTS);
}
return new PayDeductibles(trimmedDeductibles);
}

/**
* Parses a {@code String department} into an {@code Department}
* Leading and trailing whitespaces wil be trimmed.
Expand Down
Loading

0 comments on commit 91f6801

Please sign in to comment.