package com.rjconsultores.ventaboletos.web.utilerias.render;

import org.zkoss.zul.Checkbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;

import com.rjconsultores.ventaboletos.constantes.Constantes;
import com.rjconsultores.ventaboletos.utilerias.BigDecimalUtil;
import com.rjconsultores.ventaboletos.utilerias.LocaleUtil;
import com.rjconsultores.ventaboletos.vo.comissao.BoletoComissao;

public class RenderBoletoComissao implements ListitemRenderer {
	
	
	public RenderBoletoComissao() {
		super();
	}
	
	@Override
	public void render(Listitem lstm, Object o) throws Exception {
		BoletoComissao boletoComissao = (BoletoComissao) o;
		boletoComissao.setConferido(boletoComissao.getLogconferenciaId() != null);
		
		Listcell lc = new Listcell();
		if(boletoComissao.isExigeConferencia()) {
			Checkbox chk = new Checkbox();
			chk.setId(boletoComissao.getBoletoId()+"");
			chk.setChecked(boletoComissao.isConferido());
			chk.setParent(lc);
		}
		lc.setParent(lstm);

		lc = new Listcell(boletoComissao.getNumFolioSistema());
        lc.setParent(lstm);
        
        if(Constantes.TPV_BOLETO_REMOTO.intValue() == boletoComissao.getTipoVenta()) {
        	lc = new Listcell(boletoComissao.getNumoperacion());
        	lc.setParent(lstm);
        }
        
        lc = new Listcell(boletoComissao.getNumSeriePreimpresa());
        lc.setParent(lstm);
        
        lc = new Listcell(boletoComissao.getNumFolioPreImpreso());
        lc.setParent(lstm);

        lc = new Listcell(boletoComissao.getDesccategoria());
        lc.setParent(lstm);

        lc = new Listcell(BigDecimalUtil.getBigDecimalToStringDouble2CasasDecimaisFormatado(boletoComissao.getTotal(), LocaleUtil.getLocale()));
        lc.setParent(lstm);
        
        lc = new Listcell(boletoComissao.getSituacaoBilhete());
        lc.setParent(lstm);
        
        lc = new Listcell(boletoComissao.getStatusDescricao());
        lc.setParent(lstm);

        lc = new Listcell(boletoComissao.getDescFormapagos());
        lc.setParent(lstm);

        lc = new Listcell(boletoComissao.getNombusuario());
        lc.setParent(lstm);

        lstm.setAttribute("data", boletoComissao);
		
	}

}
