/*
 * Arrebol Consultancy copyright.
 * 
 * This code belongs to Arrebol Consultancy
 * its use, redistribution or modification are prohibited 
 * without written authorization from Arrebol Consultancy.
 */
package com.arrebol.taxiservicios.model.admin;

import com.arrebol.taxiservicios.model.core.Person;
import com.arrebol.taxiservicios.model.core.User;
import com.arrebol.taxiservicios.model.enums.FeeType;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 *
 * @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
 */
public class FeeByDriver implements Serializable {

    private static final long serialVersionUID = -1;

    private String id;
    private Person driver;
    private Date feeDate;
    private Double amount;
    private String comment;
    private FeeType status;
    private User createdBy;
    private Date createdOn;
    private User lastUpdatedBy;
    private Date lastUpdatedOn;

    /**
     *
     */
    public FeeByDriver() {
    }

    /**
     *
     * @param id
     */
    public FeeByDriver(String id) {
        this.id = id;
    }

    /**
     *
     * @param id
     * @param driver
     * @param feeDate
     * @param amount
     * @param createdBy
     * @param createdOn
     */
    public FeeByDriver(String id, Person driver, Date feeDate, Double amount, User createdBy, Date createdOn) {
        this.id = id;
        this.driver = driver;
        this.feeDate = feeDate;
        this.amount = amount;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
    }

    /**
     *
     * @param driver
     * @param feeDate
     * @param amount
     * @param createdBy
     * @param createdOn
     */
    public FeeByDriver(Person driver, Date feeDate, Double amount, User createdBy, Date createdOn) {
        this.driver = driver;
        this.feeDate = feeDate;
        this.amount = amount;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
    }

    /**
     *
     * @param id
     * @param driver
     * @param feeDate
     * @param amount
     */
    public FeeByDriver(String id, Person driver, Date feeDate, Double amount) {
        this.id = id;
        this.driver = driver;
        this.feeDate = feeDate;
        this.amount = amount;
    }

    /**
     *
     * @param id
     * @param driver
     * @param feeDate
     * @param amount
     * @param comment
     */
    public FeeByDriver(String id, Person driver, Date feeDate, Double amount, String comment) {
        this.id = id;
        this.driver = driver;
        this.feeDate = feeDate;
        this.amount = amount;
        this.comment = comment;
    }

    /**
     *
     * @param id
     * @param feeDate
     * @param amount
     */
    public FeeByDriver(String id, Date feeDate, Double amount) {
        this.id = id;
        this.feeDate = feeDate;
        this.amount = amount;
    }

    /**
     *
     * @param id
     * @param driver
     * @param feeDate
     * @param amount
     * @param comment
     * @param status
     * @param createdBy
     * @param createdOn
     */
    public FeeByDriver(String id, Person driver, Date feeDate, Double amount, String comment, FeeType status, User createdBy, Date createdOn) {
        this.id = id;
        this.driver = driver;
        this.feeDate = feeDate;
        this.amount = amount;
        this.comment = comment;
        this.status = status;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
    }
    
    /**
     *
     * @param id
     * @param feeDate
     * @param amount
     * @param comment
     */
    public FeeByDriver(String id, Date feeDate, Double amount, String comment) {
        this.id = id;
        this.feeDate = feeDate;
        this.amount = amount;
        this.comment = comment;
    }

    /**
     * row[0] = Person, row[1] = Amount, row[2] = Total of fees by driver.
     *
     * @param row
     */
    public FeeByDriver(Object[] row) {
        try {
            if (row[0] instanceof Person) {
                driver = (Person) row[0];
            } else {
                driver = new Person("", "John", "Doe", "", "");
            }

            if (row[1] instanceof Double) {
                amount = (Double) row[1];
            } else {
                amount = 0D;
            }

            if (row[2] instanceof Long) {
                comment = ((Long) row[2]).toString();
            } else {
                comment = "0";
            }
        } catch (Exception e) {
            driver = new Person("", "John", "Doe", "", "");
            amount = 0D;
            comment = "0";
        }
    }

    /**
     * Complete constructor.
     *
     * @param id
     * @param driver
     * @param feeDate
     * @param amount
     * @param comment
     * @param status
     * @param createdBy
     * @param createdOn
     * @param lastUpdatedBy
     * @param lastUpdatedOn
     */
    public FeeByDriver(String id, Person driver, Date feeDate, Double amount, String comment, FeeType status, User createdBy, Date createdOn, User lastUpdatedBy, Date lastUpdatedOn) {
        this.id = id;
        this.driver = driver;
        this.feeDate = feeDate;
        this.amount = amount;
        this.comment = comment;
        this.status = status;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.lastUpdatedBy = lastUpdatedBy;
        this.lastUpdatedOn = lastUpdatedOn;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Person getDriver() {
        return driver;
    }

    public void setDriver(Person driver) {
        this.driver = driver;
    }

    public Date getFeeDate() {
        return feeDate;
    }

    public void setFeeDate(Date feeDate) {
        this.feeDate = feeDate;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public FeeType getStatus() {
        return status;
    }

    public void setStatus(FeeType status) {
        this.status = status;
    }

    public User getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(User createdBy) {
        this.createdBy = createdBy;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public User getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public void setLastUpdatedBy(User lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    public Date getLastUpdatedOn() {
        return lastUpdatedOn;
    }

    public void setLastUpdatedOn(Date lastUpdatedOn) {
        this.lastUpdatedOn = lastUpdatedOn;
    }

    @Override
    public String toString() {
        return "FeeByDriver{" + "driver=" + driver + ", feeDate=" + feeDate + ", amount=" + amount + '}';
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 19 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final FeeByDriver other = (FeeByDriver) obj;
        return Objects.equals(this.id, other.id);
    }

    @Override
    public FeeByDriver clone() {
        return new FeeByDriver(id, driver, feeDate, amount, comment, status, createdBy, createdOn, lastUpdatedBy, lastUpdatedOn);
    }

}
