/*
 * 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.catalog.Location;
import com.arrebol.taxiservicios.model.core.User;
import com.arrebol.taxiservicios.model.enums.BasicType;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

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

    private String id;
    private Double amount;
    private Double amountPaymentClient;
    private Double amountInvoice;
    private Double amountExpense;
    private String description;
    private BasicType autorizacion;
    private Location locationSend;
    private Location locationReceiver;
    private Boolean active;
    
    private User createdBy;
    private Date createdOn;
    private User lastUpdatedBy;
    private Date lastUpdatedOn;
    private Location location;

    public TransferMoneyLocation(String id, Double amount, String description, BasicType autorizacion, Location locationSend, Location locationReceiver, Boolean active, User createdBy, Date createdOn, User lastUpdatedBy, Date lastUpdatedOn, Location location) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.autorizacion = autorizacion;
        this.locationSend = locationSend;
        this.locationReceiver = locationReceiver;
        this.active = active;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.lastUpdatedBy = lastUpdatedBy;
        this.lastUpdatedOn = lastUpdatedOn;
        this.location = location;
    }
    
    public TransferMoneyLocation(String id, Double amount, String description, BasicType autorizacion, Location locationSend, Location locationReceiver, Date createdOn, User createdBy, Location location, Boolean active) {
        this.id = id;
        this.amount = amount;
        this.description = description;
        this.autorizacion = autorizacion;
        this.locationSend = locationSend;
        this.locationReceiver = locationReceiver;
        this.active = active;
        this.createdBy = createdBy;
        this.createdOn = createdOn;
        this.location = location;
    }

    public TransferMoneyLocation() {
    }

    public TransferMoneyLocation(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

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

    public Double getAmount() {
        return amount;
    }

    public Double getAmountPaymentClient() {
        return amountPaymentClient;
    }

    public void setAmountPaymentClient(Double amountPaymentClient) {
        this.amountPaymentClient = amountPaymentClient;
    }

    public Double getAmountInvoice() {
        return amountInvoice;
    }

    public void setAmountInvoice(Double amountInvoice) {
        this.amountInvoice = amountInvoice;
    }

    public Double getAmountExpense() {
        return amountExpense;
    }

    public void setAmountExpense(Double amountExpense) {
        this.amountExpense = amountExpense;
    }

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

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public BasicType getAutorizacion() {
        return autorizacion;
    }

    public void setAutorizacion(BasicType autorizacion) {
        this.autorizacion = autorizacion;
    }

    public Location getLocationSend() {
        return locationSend;
    }

    public void setLocationSend(Location locationSend) {
        this.locationSend = locationSend;
    }

    public Location getLocationReceiver() {
        return locationReceiver;
    }

    public void setLocationReceiver(Location locationReceiver) {
        this.locationReceiver = locationReceiver;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    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 Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public boolean getAction(Date lastStableGeneralBox) {
        Date date = createdOn;
        boolean action = true;
        try {
            SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");

            String dateStr = dt1.format(date);
            date = dt1.parse(dateStr);

            action = date.after(lastStableGeneralBox);

        } catch (ParseException ex) {
            Logger.getLogger(ExpenseCompany.class.getName()).log(Level.SEVERE, null, ex);
        }
        return action;
    }
    
    public String getEstatus()
    {
        if(getAutorizacion() == BasicType.DISABLED)
        {
           return "No autorizado";
        }  
        else
        {
            return "Autorizado";
        }
            
    }
    
    public boolean getBtnAutorizar()
    {
        if(getAutorizacion() == BasicType.DISABLED)
        {
           return true;
        }  
        else
        {
            return false;
        }
            
    }
    
    public boolean canAutorizar(String location)
    {
        if(location.equalsIgnoreCase(getLocationReceiver().getId()))
        {
           return true;
        }  
        else
        {
            return false;
        }
            
    }
   
}
