/*
 * 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.ExpenseType;
import com.arrebol.taxiservicios.model.enums.SanctionType;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

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

    private String id;
    private ClosingDay closingDay;
    private String type;
    private BigDecimal amount;
    private BigDecimal amountSaving;
    private BigDecimal amountAccident;
    private Person person;
    private String comments;
    private User createdBy;
    private Date createdOn;
    private User lastUpdatedBy;
    private Date lastUpdatedOn;

    private GeneralPublic general;

    public ClosingDayDetail() {
    }

    /**
     *
     * @param type
     * @param amount
     * @param amountSaving
     * @param amountAccident
     * @param person
     * @param comments
     */
    public ClosingDayDetail(String type, BigDecimal amount, BigDecimal amountSaving, BigDecimal amountAccident, Person person, String comments) {
        this.type = type;
        this.amount = amount;
        this.amountSaving = amountSaving;
        this.amountAccident = amountAccident;
        this.person = person;
        this.comments = comments;
    }

    /**
     *
     * @param queryNumber 1: query_details_sales, 2: query_details_sanctions_in,
     * 3: query_details_sanctions_out, 4: query_details_expenses, 5:
     * query_details_invoices.
     * @param array
     */
    //Para poder añadir que se va a mostrar (supongo)
    public ClosingDayDetail(int queryNumber, Object[] array) {
        switch (queryNumber) {
            case 1:
                if (((String) array[6]).equals("DISABLED")) {
                    this.type = "Venta diaria";
                } else {
                    this.type = "Venta diaria - Depósito";
                }

                this.person = new Person((String) array[3], (String) array[5]);
                this.amount = new BigDecimal((Double) array[0]);
                this.amountSaving = new BigDecimal((Double) array[1]);
                this.amountAccident = new BigDecimal((Double) array[2]);
                this.comments = (String) array[4];
                break;
            case 2:
                this.type = SanctionType.valueOf(array[1].toString()).getType();
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = (String) array[3];
                break;
            case 3:
                this.type = SanctionType.valueOf(array[1].toString()).getType();
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = (String) array[3];
                break;
            case 4:
                this.type = ExpenseType.valueOf(array[1].toString()).getType();
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = (String) array[3];
                break;
            case 5:
                this.type = "Compra";
                this.person = new Person((String) array[1], (String) array[3]);
                this.amount = new BigDecimal((Float) array[0]);
                this.comments = (String) array[2];
                break;
            case 6:
                this.type = "Transferencia enviada";
                this.person = new Person((String) array[1], (String) array[3]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = "Enviada a usuario: " + (String) array[3];
                break;
            case 7:
                this.type = "Transferencia recibida";
                this.person = new Person((String) array[1], (String) array[3]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = "Recibida del usuario: " + (String) array[3];
                break;
            case 8:
                this.type = "Pago cliente";
                this.person = new Person((String) array[1], (String) array[3]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = "";
                break;
            case 9:
                this.type = "Venta público general";
                this.person = null;
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = "";
                break;
            case 10:
                this.type = "Devolución de compra";
                this.person = null;
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = (String) array[2];
                break;
            case 11:
                this.type = "Tiempo aire";
                this.person = new Person((String) array[1], (String) array[3]);
                this.amount = BigDecimal.valueOf(Double.parseDouble(array[0].toString()));
                this.comments = "";
                break;
            case 12:
                this.type = "Transferencia Mutual enviada";
                this.person = new Person((String) array[1], (String) array[3]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = "Enviada a usuario: " + (String) array[3];
                break;
            case 13:
                this.type = array[1].toString();
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = (String) array[3];
                break;
            case 15:
                this.type = array[1].toString() + " Proyecto";
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = "Abono al proyecto " + array[3];
                break;
            case 16:
                this.type = "ABONO Urbanizacion";
                this.person = new Person((String) array[2], (String) array[5]);
                this.amount = new BigDecimal((Double) array[4]);
                this.comments = "Abono a la urbanizacion " + array[3] + " :" + array[4];
                break;
            case 18:
                this.type = array[1].toString();
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = "Devolución de abono a lote ENTRADA" + array[3];
                break;
            case 19:
                this.type = array[1].toString();
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0] * -1);
                this.comments = "Devolución de abono a lote SALIDA" + array[3];
                break;
            case 20:
                this.type = array[1].toString();
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0] * -1);
                this.comments = "Abono a rembolso por cancelacion " + array[3];
                break;
            case 23:
                this.type = array[1].toString();
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = "Devolución de abono multiple a lote ENTRADA" + array[3];
                break;
            case 24:
                this.type = array[1].toString();
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0] * -1);
                this.comments = "Devolución de abono multiple a lote SALIDA" + array[3];
                break;
            case 25:
                this.type = array[1].toString();
                this.person = new Person((String) array[2], (String) array[4]);
                this.amount = new BigDecimal((Double) array[0]);
                this.comments = "Folio del pago: "+ array[3];
                break;
        }

    }

    public String getId() {
        return id;
    }

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

    public ClosingDay getClosingDay() {
        return closingDay;
    }

    public void setClosingDay(ClosingDay closingDay) {
        this.closingDay = closingDay;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public BigDecimal getAmount() {
        return amount;
    }

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

    public BigDecimal getAmountSaving() {
        return amountSaving;
    }

    public void setAmountSaving(BigDecimal amountSaving) {
        this.amountSaving = amountSaving;
    }

    public BigDecimal getAmountAccident() {
        return amountAccident;
    }

    public void setAmountAccident(BigDecimal amountAccident) {
        this.amountAccident = amountAccident;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    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;
    }

    public GeneralPublic getGeneral() {
        return general;
    }

    public void setGeneral(GeneralPublic general) {
        this.general = general;
    }

    @Override
    public String toString() {
        return "ClosingDayDetail{" + "closingDay=" + closingDay + ", type=" + type + ", comments=" + comments + '}';
    }

}
