

package org.mifos.customers.personnel.business;

import java.util.Date;

import org.mifos.application.util.helpers.Status;
import org.mifos.customers.office.business.OfficeBO;
import org.mifos.framework.business.AbstractEntity;
import org.mifos.framework.util.DateTimeService;

public class PersonnelMovementEntity extends AbstractEntity {

    private final Short personnelMovementId;

    private final PersonnelBO personnel;

    private OfficeBO office;

    private final Date startDate;

    private Date endDate;

    private Short status;

    private Date updatedDate;
    
    private Short updatedBy;

    public PersonnelMovementEntity(PersonnelBO personnel, Date startDate) {
        this.personnel = personnel;
        this.office = personnel.getOffice();
        this.startDate = startDate;
        this.status = Status.ACTIVE.getValue();
        this.personnelMovementId = null;
    }

    protected PersonnelMovementEntity() {
        this.personnelMovementId = null;
        this.personnel = null;
        this.office = null;
        this.startDate = null;
    }

    void updateStatus(Status status) {
        this.status = status.getValue();
    }

    public boolean isActive() {
        return status.equals(Status.ACTIVE.getValue());
    }

    public Date getEndDate() {
        return endDate;
    }

    void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Short getPersonnelMovementId() {
        return personnelMovementId;
    }

    public Date getStartDate() {
        return startDate;
    }

    void makeInActive(Short updatedBy) {
        updateStatus(Status.INACTIVE);
        setUpdatedBy(updatedBy);
        setUpdatedDate(new DateTimeService().getCurrentJavaDateTime());
        setEndDate(new DateTimeService().getCurrentJavaDateTime());
    }

    public Short getUpdatedBy() {
        return updatedBy;
    }

    public void setUpdatedBy(Short updatedBy) {
        this.updatedBy = updatedBy;
    }

    public Date getUpdatedDate() {
        return updatedDate;
    }

    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }

}
