package com.arrebol.taxiservicios.model.sp.report;

import java.io.Serializable;

/**
 *
 * @author Carlos Janitzio Zavala López.
 */
public class ReportCustomerPay implements Serializable {

    private static final long serialVersionUID = -5319452600487510947L;

    private String economicNumber;
    private String customerName;
    private String driverName;
    private Integer workedDays;
    private Integer toCollectDay;
    private Float totalWorkedToPayDays;
    private Float totalElectricExpense;
    private Float totalTornoExpense;
    private Float totalSoldaduraExpense;
    private Float totalEsteticoExpense;
    private Float totalGruaExpense;
    private Float totalServiceOrder;
    private String serviceOrderFolios;
    private String serviceOrderDesc;
    private String contractService;
    private Float totalContractService;
    private Float totalPaysToDiscount;
    private Float paymentCar;
    private Float clientCompromise;
    private Float excess;
    private Float totalToPayToClient;
    private Float totalOfContracts;
    private Long numberOfSelectedDays;
    private Float totalWorkedToPayDaysSunday;
    private Float totalOtrasEntradas;
    private Float totalOtrasSalidas;
    private int totalDiscountFixContract;
    private float totalTallerCarDriver;
    private float pagoDiario;
    private int weekDays;
    
    private Long numberOfSelectedDaysAll;
    private Float diasEnBanca;
    
    private float compromisoTotal;

    /**
     * Detault constructor.
     */
    public ReportCustomerPay() {
    }

    /**
     * queryMySQL.
     *
     * @param economicNumber
     * @param customerName
     * @param driverName
     * @param workedDays
     * @param toCollectDay
     * @param totalWorkedToPayDays
     * @param totalElectricExpense
     * @param totalTornoExpense
     * @param totalSoldaduraExpense
     * @param totalEsteticoExpense
     * @param totalGruaExpense
     * @param totalServiceOrder
     * @param serviceOrderFolios
     * @param serviceOrderDesc
     * @param contractService
     * @param totalContractService
     * @param totalPaysToDiscount
     * @param paymentCar
     * @param numberOfSelectedDays
     * @param numberOfSelectedDaysAll
     * @param totalWorkedToPayDaysSunday
     * @param totalOtrasEntradas
     * @param totalOtrasSalidas
     * @param totalDiscountFixContract
     * @param totalTallerCarDriver
     * @param pagoDiario
     */
    public ReportCustomerPay(String economicNumber, String customerName,
            String driverName, Integer workedDays, Integer toCollectDay,
            Float totalWorkedToPayDays, Float totalElectricExpense,
            Float totalTornoExpense, Float totalSoldaduraExpense,
            Float totalEsteticoExpense, Float totalGruaExpense,
            Float totalServiceOrder, String serviceOrderFolios,
            String serviceOrderDesc, String contractService,
            Float totalContractService, Float totalPaysToDiscount,
            Float paymentCar, Long numberOfSelectedDays,
            Long numberOfSelectedDaysAll, Float totalWorkedToPayDaysSunday,
            Float totalOtrasEntradas, Float totalOtrasSalidas, int totalDiscountFixContract,
            float totalTallerCarDriver, float pagoDiario) {
        this.economicNumber = economicNumber;
        this.customerName = customerName;
        this.driverName = driverName;
        this.workedDays = workedDays;
        this.totalWorkedToPayDays = totalWorkedToPayDays;
        this.totalElectricExpense = totalElectricExpense;
        this.totalTornoExpense = totalTornoExpense;
        this.totalSoldaduraExpense = totalSoldaduraExpense;
        this.totalEsteticoExpense = totalEsteticoExpense;
        this.totalGruaExpense = totalGruaExpense;
        this.totalServiceOrder = totalServiceOrder;
        this.serviceOrderFolios = serviceOrderFolios;
        this.serviceOrderDesc = serviceOrderDesc;
        this.contractService = contractService;
        this.totalContractService = totalContractService;
        this.totalPaysToDiscount = totalPaysToDiscount;
        this.paymentCar = paymentCar;
        this.numberOfSelectedDays = numberOfSelectedDays;
        this.numberOfSelectedDaysAll = numberOfSelectedDaysAll;
        this.totalWorkedToPayDaysSunday = totalWorkedToPayDaysSunday;
        this.totalOtrasEntradas = totalOtrasEntradas;
        this.totalOtrasSalidas = totalOtrasSalidas;
        this.totalDiscountFixContract = totalDiscountFixContract;
        this.totalTallerCarDriver = totalTallerCarDriver;
        this.pagoDiario = pagoDiario;
    }
    
    public ReportCustomerPay(String economicNumber, String customerName,
            String driverName, Integer workedDays, Integer toCollectDay,
            Float totalWorkedToPayDays, Float totalElectricExpense,
            Float totalTornoExpense, Float totalSoldaduraExpense,
            Float totalEsteticoExpense, Float totalGruaExpense,
            Float totalServiceOrder, String serviceOrderFolios,
            String serviceOrderDesc, String contractService,
            Float totalContractService, Float totalPaysToDiscount,
            Float paymentCar, Long numberOfSelectedDays,
            Long numberOfSelectedDaysAll, Float totalWorkedToPayDaysSunday,
            Float totalOtrasEntradas, Float totalOtrasSalidas, int totalDiscountFixContract,
            float totalTallerCarDriver, float pagoDiario, int weekDays) {
        this.economicNumber = economicNumber;
        this.customerName = customerName;
        this.driverName = driverName;
        this.workedDays = workedDays;
        this.totalWorkedToPayDays = totalWorkedToPayDays;
        this.totalElectricExpense = totalElectricExpense;
        this.totalTornoExpense = totalTornoExpense;
        this.totalSoldaduraExpense = totalSoldaduraExpense;
        this.totalEsteticoExpense = totalEsteticoExpense;
        this.totalGruaExpense = totalGruaExpense;
        this.totalServiceOrder = totalServiceOrder;
        this.serviceOrderFolios = serviceOrderFolios;
        this.serviceOrderDesc = serviceOrderDesc;
        this.contractService = contractService;
        this.totalContractService = totalContractService;
        this.totalPaysToDiscount = totalPaysToDiscount;
        this.paymentCar = paymentCar;
        this.numberOfSelectedDays = numberOfSelectedDays;
        this.numberOfSelectedDaysAll = numberOfSelectedDaysAll;
        this.totalWorkedToPayDaysSunday = totalWorkedToPayDaysSunday;
        this.totalOtrasEntradas = totalOtrasEntradas;
        this.totalOtrasSalidas = totalOtrasSalidas;
        this.totalDiscountFixContract = totalDiscountFixContract;
        this.totalTallerCarDriver = totalTallerCarDriver;
        this.pagoDiario = pagoDiario;
        this.weekDays = weekDays;
    }
    

    public float getPagoDiario() {
        return pagoDiario;
    }

    public void setPagoDiario(float pagoDiario) {
        this.pagoDiario = pagoDiario;
    }

    public float getTotalTallerCarDriver() {
        if (totalTallerCarDriver == 0F) {
            return totalTallerCarDriver;
        }

        if (totalDiscountFixContract == 0) {
            return 0F;
        }
        if (totalDiscountFixContract == 100) {
            return totalTallerCarDriver;
        } else {
            return (totalTallerCarDriver * totalDiscountFixContract) / 100;
        }
    }

    public void setTotalTallerCarDriver(float totalTallerCarDriver) {
        this.totalTallerCarDriver = totalTallerCarDriver;
    }

    public int getTotalDiscountFixContract() {
        return totalDiscountFixContract;
    }

    public void setTotalDiscountFixContract(int totalDiscountFixContract) {
        this.totalDiscountFixContract = totalDiscountFixContract;
    }

    public Float getTotalOtrasEntradas() {
        return totalOtrasEntradas;
    }

    public void setTotalOtrasEntradas(Float totalOtrasEntradas) {
        this.totalOtrasEntradas = totalOtrasEntradas;
    }

    public Float getTotalOtrasSalidas() {
        return totalOtrasSalidas;
    }

    public void setTotalOtrasSalidas(Float totalOtrasSalidas) {
        this.totalOtrasSalidas = totalOtrasSalidas;
    }

    public Float getTotalWorkedToPayDaysSunday() {
        if (null == totalWorkedToPayDaysSunday) {
            totalWorkedToPayDaysSunday = 0f;
        }
        return totalWorkedToPayDaysSunday;
    }

    public void setTotalWorkedToPayDaysSunday(Float totalWorkedToPayDaysSunday) {
        this.totalWorkedToPayDaysSunday = totalWorkedToPayDaysSunday;
    }

    public Long getNumberOfSelectedDaysAll() {
        if (null == numberOfSelectedDaysAll) {
            numberOfSelectedDaysAll = 1l;
        }
        return numberOfSelectedDaysAll;
    }

    public void setNumberOfSelectedDaysAll(Long numberOfSelectedDaysAll) {
        this.numberOfSelectedDaysAll = numberOfSelectedDaysAll;
    }

    public String getEconomicNumber() {
        return economicNumber;
    }

    public void setEconomicNumber(String economicNumber) {
        this.economicNumber = economicNumber;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getDriverName() {
        return driverName;
    }

    public void setDriverName(String driverName) {
        this.driverName = driverName;
    }

    public Integer getWorkedDays() {
        return workedDays;
    }

    public void setWorkedDays(Integer workedDays) {
        this.workedDays = workedDays;
    }

    public Integer getToCollectDay() {
        return toCollectDay;
    }

    public void setToCollectDay(Integer toCollectDay) {
        this.toCollectDay = toCollectDay;
    }

    public Float getTotalWorkedToPayDays() {
        if (null == totalWorkedToPayDays) {
            totalWorkedToPayDays = 0f;
        }
        return totalWorkedToPayDays;
    }

    public void setTotalWorkedToPayDays(Float totalWorkedToPayDays) {
        this.totalWorkedToPayDays = totalWorkedToPayDays;
    }

    public Float getTotalElectricExpense() {
        if (null == totalElectricExpense) {
            totalElectricExpense = 0f;
        }
        return totalElectricExpense;
    }

    public void setTotalElectricExpense(Float totalElectricExpense) {
        this.totalElectricExpense = totalElectricExpense;
    }

    public Float getTotalTornoExpense() {
        if (null == totalTornoExpense) {
            totalTornoExpense = 0f;
        }
        return totalTornoExpense;
    }

    public void setTotalTornoExpense(Float totalTornoExpense) {
        this.totalTornoExpense = totalTornoExpense;
    }

    public Float getTotalSoldaduraExpense() {
        if (null == totalSoldaduraExpense) {
            totalSoldaduraExpense = 0f;
        }
        return totalSoldaduraExpense;
    }

    public void setTotalSoldaduraExpense(Float totalSoldaduraExpense) {
        this.totalSoldaduraExpense = totalSoldaduraExpense;
    }

    public Float getTotalEsteticoExpense() {
        if (null == totalEsteticoExpense) {
            totalEsteticoExpense = 0f;
        }
        return totalEsteticoExpense;
    }

    public void setTotalEsteticoExpense(Float totalEsteticoExpense) {
        this.totalEsteticoExpense = totalEsteticoExpense;
    }

    public Float getTotalGruaExpense() {
        if (null == totalGruaExpense) {
            totalGruaExpense = 0f;
        }
        return totalGruaExpense;
    }

    public void setTotalGruaExpense(Float totalGruaExpense) {
        this.totalGruaExpense = totalGruaExpense;
    }

    public Float getTotalServiceOrder() {
        if (null == totalServiceOrder) {
            totalServiceOrder = 0f;
        }

        return totalServiceOrder - getTotalTallerCarDriver();

    }

    public void setTotalServiceOrder(Float totalServiceOrder) {
        this.totalServiceOrder = totalServiceOrder;
    }

    public String getServiceOrderFolios() {
        return serviceOrderFolios;
    }

    public void setServiceOrderFolios(String serviceOrderFolios) {
        this.serviceOrderFolios = serviceOrderFolios;
    }

    public String getServiceOrderDesc() {
        return serviceOrderDesc;
    }

    public void setServiceOrderDesc(String serviceOrderDesc) {
        this.serviceOrderDesc = serviceOrderDesc;
    }

    public String getContractService() {
        return contractService;
    }

    public void setContractService(String contractService) {
        this.contractService = contractService;
    }

    public Float getTotalContractService() {
        if (null == totalContractService) {
            totalContractService = 0f;
        }
        return totalContractService;
    }

    public void setTotalContractService(Float totalContractService) {
        this.totalContractService = totalContractService;
    }

    public Float getTotalPaysToDiscount() {
        return totalPaysToDiscount;
    }

    public void setTotalPaysToDiscount(Float totalPaysToDiscount) {
        this.totalPaysToDiscount = totalPaysToDiscount;
    }

    public Float getPaymentCar() {
        if (null == paymentCar) {
            paymentCar = 0f;
        }
        return paymentCar;
    }

    public void setPaymentCar(Float paymentCar) {
        this.paymentCar = paymentCar;
    }

    /**
     * Formula = payment_car / 7 * total días (rango de fechas)
     *
     * @return
     */
    public Float getClientCompromise() {
        try {
            //clientCompromise = (getPaymentCar() / 6) * getNumberOfSelectedDays();
            clientCompromise = (getPaymentCar() / weekDays) * (getNumberOfSelectedDays() - getDiasEnBanca()); // TODO es correcto
        } catch (Exception e) {
            clientCompromise = 0f;
        }
        return clientCompromise;
    }

    public void setClientCompromise(Float clientCompromise) {
        this.clientCompromise = clientCompromise;
    }


    /**
     * Formula = percepcion - compromiso al cliente
     *
     * @return
     */
    public Float getExcess() {
        try {
            excess = getTotalWorkedToPayDays() - getCompromisoTotal();
        } catch (Exception e) {
            excess = 0f;
        }
        return excess;
    }

    public void setExcess(Float excess) {
        this.excess = excess;
    }

    /**
     * Formula = Compromiso al cliente - ((report.totalElectricExpense +
     * report.totalTornoExpense + report.totalSoldaduraExpense +
     * report.totalEsteticoExpense + report.totalGruaExpense +
     * report.totalServiceOrder))
     *
     * @return
     */
    public Float getTotalToPayToClient() {
        try {
            totalToPayToClient = getClientCompromise() - (getTotalOfContracts()
                    + getTotalElectricExpense()
                    + getTotalTornoExpense()
                    + getTotalSoldaduraExpense()
                    + getTotalEsteticoExpense()
                    + getTotalGruaExpense()
                    + getTotalServiceOrder());
        } catch (Exception e) {
            totalToPayToClient = 0f;
        }
        return totalToPayToClient;
    }

    public void setTotalToPayToClient(Float totalToPayToClient) {
        this.totalToPayToClient = totalToPayToClient;
    }

    /**
     * formula = monto de contrato / 30 * total días (rango de fechas)
     *
     * @return
     */
    public Float getTotalOfContracts() {
        try {
            //totalOfContracts = (getTotalContractService() / 30) * getNumberOfSelectedDaysAll();
            totalOfContracts = (getTotalContractService());
        } catch (Exception e) {
            totalOfContracts = 0f;
        }
        return totalOfContracts;
    }

    public void setTotalOfContracts(Float totalOfContracts) {
        this.totalOfContracts = totalOfContracts;
    }

    public Long getNumberOfSelectedDays() {
        if (null == numberOfSelectedDays) {
            numberOfSelectedDays = 1l;
        }
        return numberOfSelectedDays;
    }

    public void setNumberOfSelectedDays(Long numberOfSelectedDays) {
        this.numberOfSelectedDays = numberOfSelectedDays;
    }

    public Float getDiasEnBanca() {
        return diasEnBanca;
    }

    public void setDiasEnBanca(Float diasEnBanca) {
        this.diasEnBanca = diasEnBanca;
    }
    
    public float getPorcentajeEfectividad(){
        
        return Math.abs((((paymentCar / weekDays) * 100) / pagoDiario) - 100);
    }

    public float getCompromisoTotal() {
        return compromisoTotal;
    }

    public void setCompromisoTotal(float compromisoTotal) {
        this.compromisoTotal = compromisoTotal;
    }

    @Override
    public String toString() {
        return "ReportCustomerPay{" + "economicNumber=" + economicNumber + ", customerName=" + customerName + ", driverName=" + driverName + ", serviceOrderFolios=" + serviceOrderFolios + ", serviceOrderDesc=" + serviceOrderDesc + ", contractService=" + contractService + '}';
    }

}
