Skip to content

Commit

Permalink
Leave storage
Browse files Browse the repository at this point in the history
  • Loading branch information
nixonwidjaja committed Oct 3, 2023
1 parent d44d566 commit 5a95f02
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public Person(Name name, Phone phone, Email email, Address address,
this.leave = new Leave();
}

/**
* Constructs a {@code Person}.
*/
public Person(Name name, Phone phone, Email email, Address address,
Money salary, Money claimBudget, Department dep, Birthday dob, Leave leave) {
requireAllNonNull(name, phone, email, address, salary, claimBudget, dep, dob);
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import seedu.address.model.person.Birthday;
import seedu.address.model.person.Department;
import seedu.address.model.person.Email;
import seedu.address.model.person.Leave;
import seedu.address.model.person.Money;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
Expand All @@ -28,6 +29,7 @@ class JsonAdaptedPerson {
private final String claimBudget;
private final String department;
private final String dob;
private final String leave;

/**
* Constructs a {@code JsonAdaptedPerson} with the given person details.
Expand All @@ -36,7 +38,8 @@ class JsonAdaptedPerson {
public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone,
@JsonProperty("email") String email, @JsonProperty("address") String address,
@JsonProperty("salary") String salary, @JsonProperty("claimBudget") String claimBudget,
@JsonProperty("department") String department, @JsonProperty("dob") String dob) {
@JsonProperty("department") String department, @JsonProperty("dob") String dob,
@JsonProperty("leave") String leave) {
this.name = name;
this.phone = phone;
this.email = email;
Expand All @@ -45,6 +48,7 @@ public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone
this.claimBudget = claimBudget;
this.department = department;
this.dob = dob;
this.leave = leave;
}

/**
Expand All @@ -59,6 +63,7 @@ public JsonAdaptedPerson(Person source) {
claimBudget = source.getClaimBudget().amount;
department = source.getDepartment().department;
dob = source.getDob().dob;
leave = source.getLeave().leave;
}

/**
Expand Down Expand Up @@ -133,8 +138,17 @@ public Person toModelType() throws IllegalValueException {
}
final Birthday modelDob = new Birthday(dob);

if (leave == null) {
throw new IllegalValueException(
String.format(MISSING_FIELD_MESSAGE_FORMAT, Leave.class.getSimpleName()));
}
if (!Leave.isValidLeave(leave)) {
throw new IllegalValueException(Leave.MESSAGE_CONSTRAINTS);
}
final Leave modelLeave = new Leave(leave);

return new Person(modelName, modelPhone, modelEmail, modelAddress, modelSalary,
modelClaimBudget, modelDepartment, modelDob);
modelClaimBudget, modelDepartment, modelDob, modelLeave);
}

}

0 comments on commit 5a95f02

Please sign in to comment.