package it.integry.integrywmsnative.core.model;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;

import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityString;

public class MtbColr extends EntityBase {


    private String gestione;
    private String serCollo;
    private Integer numCollo;
    private String dataCollo;
    private Integer riga;
    private Integer rigaOrd;
    private String codMart;
    private String codBarre;
    private String codCol;
    private String codTagl;
    private String partitaMag;
    private String gestioneRif;
    private String serColloRif;
    private String note;
    private String dataOrd;
    private String dataColloRif;
    private BigDecimal qtaCnf;
    private BigDecimal qtaCol;
    private Integer numOrd;
    private Integer numEtich;
    private Integer numColloRif;
    private String datetimeRow;
    private String codJcom;
    private BigDecimal numCnf;
    private String insPartitaMag;
    private String mtbPartitaMag_descrizione;
    private LocalDate dataScadPartita;
    private String descrizione;
    private String untMis;
    private Integer causale;
    private String utente;
    private String codAnagDoc;
    private String codDtipDoc;
    private String dataDoc;
    private String serDoc;
    private Integer numDoc;
    private Integer idRigaDoc;
    private BigDecimal pesoNettoKg;
    private BigDecimal pesoLordoKg;

    private MtbAart mtbAart;
    private MtbPartitaMag mtbPartitaMag;


    private transient int id;
    private transient MtbColr refMtbColr;

    public MtbColr() {
        type = "mtb_colr";

        if (SettingsManager.i().isUserLoggedIn()) {
            setUtente(SettingsManager.i().getUser().getFullname());
        }
    }


    public static class Causale {
        public static final int DEFAULT = 0;
        public static final int RETTIFICA = 1;
        public static final int VERSAMENTO = 2;
    }


    public String getGestione() {
        return gestione;
    }

    public GestioneEnum getGestioneEnum() {
        return GestioneEnum.fromString(gestione);
    }


    public MtbColr setGestione(GestioneEnum gestione) {
        this.gestione = gestione.getText();
        return this;
    }

    public MtbColr setGestione(String gestione) {
        this.gestione = gestione;
        return this;
    }

    public String getSerCollo() {
        return serCollo;
    }

    public MtbColr setSerCollo(String serCollo) {
        this.serCollo = serCollo;
        return this;
    }

    public Integer getNumCollo() {
        return numCollo;
    }

    public MtbColr setNumCollo(Integer numCollo) {
        this.numCollo = numCollo;
        return this;
    }

    public String getDataColloS() {
        return dataCollo;
    }

    public Date getDataColloD() {
        return UtilityDate.recognizeDateWithExceptionHandler(getDataColloS());
    }

    public MtbColr setDataCollo(String dataCollo) {
        this.dataCollo = dataCollo;
        return this;
    }

    public MtbColr setDataCollo(Date dataCollo) {
        setDataCollo(UtilityDate.formatDate(dataCollo, UtilityDate.COMMONS_DATE_FORMATS.DMY_TIME_SLASH));
        return this;
    }


    public Integer getRiga() {
        return riga;
    }

    public MtbColr setRiga(Integer riga) {
        this.riga = riga;
        return this;
    }

    public Integer getRigaOrd() {
        return rigaOrd;
    }

    public MtbColr setRigaOrd(Integer rigaOrd) {
        this.rigaOrd = rigaOrd;
        return this;
    }

    public String getCodMart() {
        return codMart;
    }

    public MtbColr setCodMart(String codMart) {
        this.codMart = codMart;
        return this;
    }

    public String getCodBarre() {
        return codBarre;
    }

    public MtbColr setCodBarre(String codBarre) {
        this.codBarre = codBarre;
        return this;
    }

    public String getCodCol() {
        return codCol;
    }

    public MtbColr setCodCol(String codCol) {
        this.codCol = codCol;
        return this;
    }

    public String getCodTagl() {
        return codTagl;
    }

    public MtbColr setCodTagl(String codTagl) {
        this.codTagl = codTagl;
        return this;
    }

    public String getPartitaMag() {
        return partitaMag;
    }

    public MtbColr setPartitaMag(String partitaMag) {
        this.partitaMag = partitaMag;
        return this;
    }

    public String getGestioneRif() {
        return gestioneRif;
    }

    public GestioneEnum getGestioneRifEnum() {
        return GestioneEnum.fromString(gestioneRif);
    }

    public MtbColr setGestioneRif(String gestioneRif) {
        this.gestioneRif = gestioneRif;
        return this;
    }

    public String getSerColloRif() {
        return serColloRif;
    }

    public MtbColr setSerColloRif(String serColloRif) {
        this.serColloRif = serColloRif;
        return this;
    }

    public String getNote() {
        return note;
    }

    public MtbColr setNote(String note) {
        this.note = note;
        return this;
    }

    public String getDataOrdS() {
        return dataOrd;
    }

    public Date getDataOrdD() {
        return UtilityDate.recognizeDateWithExceptionHandler(getDataOrdS());
    }

    public MtbColr setDataOrd(String dataOrd) {
        this.dataOrd = dataOrd;
        return this;
    }

    public MtbColr setDataOrd(Date dataOrd) {
        this.dataOrd = UtilityDate.formatDate(dataOrd, UtilityDate.COMMONS_DATE_FORMATS.DMY_TIME_SLASH);
        return this;
    }

    public String getDataColloRifS() {
        return dataColloRif;
    }

    public Date getDataColloRifD() {
        return UtilityDate.recognizeDateWithExceptionHandler(getDataColloRifS());
    }

    public MtbColr setDataColloRif(String dataColloRif) {
        this.dataColloRif = dataColloRif;
        return this;
    }

    public MtbColr setDataColloRif(Date dataColloRif) {
        this.dataColloRif = UtilityDate.formatDate(dataColloRif, UtilityDate.COMMONS_DATE_FORMATS.DMY_TIME_SLASH);
        return this;
    }

    public BigDecimal getQtaCnf() {
        return qtaCnf;
    }

    public MtbColr setQtaCnf(BigDecimal qtaCnf) {
        this.qtaCnf = qtaCnf;
        return this;
    }

    public BigDecimal getQtaCol() {
        return qtaCol;
    }

    public MtbColr setQtaCol(BigDecimal qtaCol) {
        this.qtaCol = qtaCol;
        return this;
    }

    public Integer getNumOrd() {
        return numOrd;
    }

    public MtbColr setNumOrd(Integer numOrd) {
        this.numOrd = numOrd;
        return this;
    }

    public Integer getNumEtich() {
        return numEtich;
    }

    public MtbColr setNumEtich(Integer numEtich) {
        this.numEtich = numEtich;
        return this;
    }

    public Integer getNumColloRif() {
        return numColloRif;
    }

    public MtbColr setNumColloRif(Integer numColloRif) {
        this.numColloRif = numColloRif;
        return this;
    }


    public String getDatetimeRowS() {
        return datetimeRow;
    }

    public Date getDatetimeRowD() {
        return UtilityDate.recognizeDateWithExceptionHandler(getDatetimeRowS());
    }

    public MtbColr setDatetimeRow(String datetimeRow) {
        this.datetimeRow = datetimeRow;
        return this;
    }

    public MtbColr setDatetimeRow(Date datetimeRow) {
        this.datetimeRow = UtilityDate.formatDate(datetimeRow, UtilityDate.COMMONS_DATE_FORMATS.DMY_TIME_SLASH);
        return this;
    }


    public String getCodJcom() {
        return codJcom;
    }

    public MtbColr setCodJcom(String codJcom) {
        this.codJcom = codJcom;
        return this;
    }

    public BigDecimal getNumCnf() {
        return numCnf;
    }

    public MtbColr setNumCnf(BigDecimal numCnf) {
        this.numCnf = numCnf;
        return this;
    }

    public String getInsPartitaMag() {
        return insPartitaMag;
    }

    public MtbColr setInsPartitaMag(String insPartitaMag) {
        this.insPartitaMag = insPartitaMag;
        return this;
    }

    public String getMtbPartitaMag_descrizione() {
        return mtbPartitaMag_descrizione;
    }

    public MtbColr setMtbPartitaMag_descrizione(String mtbPartitaMag_descrizione) {
        this.mtbPartitaMag_descrizione = mtbPartitaMag_descrizione;
        return this;
    }


    public LocalDate getDataScadPartita() {
        return dataScadPartita;
    }

    public MtbColr setDataScadPartita(LocalDate dataScadPartita) {
        this.dataScadPartita = dataScadPartita;
        return this;
    }

    public String getDescrizione() {
        return UtilityString.isNull(descrizione, getMtbAart() != null ? UtilityString.isNull(getMtbAart().getDescrizioneEstesa(), getMtbAart().getDescrizione()) : null);
    }

    public MtbColr setDescrizione(String descrizione) {
        this.descrizione = descrizione;
        return this;
    }


    public String getUntMis() {
        return untMis;
    }

    public MtbColr setUntMis(String untMis) {
        this.untMis = untMis;
        return this;
    }


    public MtbAart getMtbAart() {
        return mtbAart;
    }

    public MtbColr setMtbAart(MtbAart mtbAart) {
        this.mtbAart = mtbAart;
        return this;
    }


    public MtbPartitaMag getMtbPartitaMag() {
        return mtbPartitaMag;
    }

    public MtbColr setMtbPartitaMag(MtbPartitaMag mtbPartitaMag) {
        this.mtbPartitaMag = mtbPartitaMag;
        return this;
    }

    public Integer getCausale() {
        return causale;
    }

    public MtbColr setCausale(Integer causale) {
        this.causale = causale;
        return this;
    }

    public String getUtente() {
        return utente;
    }

    public MtbColr setUtente(String utente) {
        this.utente = utente;
        return this;
    }

    public String getCodAnagDoc() {
        return codAnagDoc;
    }

    public MtbColr setCodAnagDoc(String codAnagDoc) {
        this.codAnagDoc = codAnagDoc;
        return this;
    }

    public String getCodDtipDoc() {
        return codDtipDoc;
    }

    public MtbColr setCodDtipDoc(String codDtipDoc) {
        this.codDtipDoc = codDtipDoc;
        return this;
    }

    public String getDataDoc() {
        return dataDoc;
    }

    public MtbColr setDataDoc(String dataDoc) {
        this.dataDoc = dataDoc;
        return this;
    }

    public String getSerDoc() {
        return serDoc;
    }

    public MtbColr setSerDoc(String serDoc) {
        this.serDoc = serDoc;
        return this;
    }

    public Integer getNumDoc() {
        return numDoc;
    }

    public MtbColr setNumDoc(Integer numDoc) {
        this.numDoc = numDoc;
        return this;
    }

    public Integer getIdRigaDoc() {
        return idRigaDoc;
    }

    public MtbColr setIdRigaDoc(Integer idRigaDoc) {
        this.idRigaDoc = idRigaDoc;
        return this;
    }

    public BigDecimal getPesoNettoKg() {
        return pesoNettoKg;
    }

    public MtbColr setPesoNettoKg(BigDecimal pesoNettoKg) {
        this.pesoNettoKg = pesoNettoKg;
        return this;
    }

    public BigDecimal getPesoLordoKg() {
        return pesoLordoKg;
    }

    public MtbColr setPesoLordoKg(BigDecimal pesoLordoKg) {
        this.pesoLordoKg = pesoLordoKg;
        return this;
    }

    public int getId() {
        return id;
    }

    public MtbColr setId(int id) {
        this.id = id;
        return this;
    }

    public MtbColr getRefMtbColr() {
        return refMtbColr;
    }

    public MtbColr setRefMtbColr(MtbColr refMtbColr) {
        this.refMtbColr = refMtbColr;
        return this;
    }
}
