From 87ac67cf459ac7b42921a60c906942406a928d41 Mon Sep 17 00:00:00 2001 From: valdevir Date: Tue, 4 Jun 2024 19:03:42 -0300 Subject: [PATCH] fixes bug #AL-4474 --- pom.xml | 2 +- .../catalogos/EditarPuntoVentaController.java | 9857 +++++++++-------- web/gui/catalogos/editarPuntoVenta.zul | 5223 ++++----- 3 files changed, 7542 insertions(+), 7540 deletions(-) diff --git a/pom.xml b/pom.xml index b04c91f47..87537df68 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 br.com.rjconsultores ventaboletosadm - 1.80.0 + 1.80.1 war diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarPuntoVentaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarPuntoVentaController.java index eb3c4fe88..a14215def 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarPuntoVentaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarPuntoVentaController.java @@ -1,4929 +1,4930 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.rjconsultores.ventaboletos.web.gui.controladores.catalogos; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.math.BigDecimal; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Observable; -import java.util.Observer; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -import javax.activation.MimetypesFileTypeMap; -import javax.sql.DataSource; -import javax.swing.text.MaskFormatter; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.Predicate; -import org.apache.commons.lang.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Controller; -import org.springframework.transaction.annotation.Transactional; -import org.zkoss.util.resource.Labels; -import org.zkoss.zk.ui.Component; -import org.zkoss.zk.ui.Executions; -import org.zkoss.zk.ui.UiException; -import org.zkoss.zk.ui.WrongValueException; -import org.zkoss.zk.ui.event.Event; -import org.zkoss.zk.ui.event.EventListener; -import org.zkoss.zk.ui.event.Events; -import org.zkoss.zk.ui.event.ForwardEvent; -import org.zkoss.zk.ui.event.InputEvent; -import org.zkoss.zk.ui.event.SelectEvent; -import org.zkoss.zk.ui.event.UploadEvent; -import org.zkoss.zk.ui.util.Clients; -import org.zkoss.zkplus.databind.BindingListModel; -import org.zkoss.zkplus.databind.BindingListModelList; -import org.zkoss.zul.Button; -import org.zkoss.zul.Checkbox; -import org.zkoss.zul.Combobox; -import org.zkoss.zul.Comboitem; -import org.zkoss.zul.Datebox; -import org.zkoss.zul.Decimalbox; -import org.zkoss.zul.Doublebox; -import org.zkoss.zul.Filedownload; -import org.zkoss.zul.Image; -import org.zkoss.zul.Intbox; -import org.zkoss.zul.ListModelList; -import org.zkoss.zul.Listitem; -import org.zkoss.zul.Messagebox; -import org.zkoss.zul.Paging; -import org.zkoss.zul.Radio; -import org.zkoss.zul.Row; -import org.zkoss.zul.Textbox; -import org.zkoss.zul.api.Bandbox; -import org.zkoss.zul.api.Tab; -import org.zkoss.zul.api.Timebox; - -import com.rjconsultores.ventaboletos.constantes.Constantes; -import com.rjconsultores.ventaboletos.constantes.ConstantesFuncionSistema; -import com.rjconsultores.ventaboletos.entidad.Categoria; -import com.rjconsultores.ventaboletos.entidad.CategoriaBloqueioImpPosterior; -import com.rjconsultores.ventaboletos.entidad.Ciudad; -import com.rjconsultores.ventaboletos.entidad.CobrancaAdcPuntoVenta; -import com.rjconsultores.ventaboletos.entidad.CobrancaAdicionalHistorico; -import com.rjconsultores.ventaboletos.entidad.Colonia; -import com.rjconsultores.ventaboletos.entidad.Constante; -import com.rjconsultores.ventaboletos.entidad.Empresa; -import com.rjconsultores.ventaboletos.entidad.EmpresaContaBancaria; -import com.rjconsultores.ventaboletos.entidad.FechamentoParamptovta; -import com.rjconsultores.ventaboletos.entidad.FormaPago; -import com.rjconsultores.ventaboletos.entidad.FormaPagoDet; -import com.rjconsultores.ventaboletos.entidad.HistoricoFormaPagoPuntoVenta; -import com.rjconsultores.ventaboletos.entidad.HistoricoPuntoVenta; -import com.rjconsultores.ventaboletos.entidad.InstiFinanceira; -import com.rjconsultores.ventaboletos.entidad.Moneda; -import com.rjconsultores.ventaboletos.entidad.Nodo; -import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; -import com.rjconsultores.ventaboletos.entidad.Parada; -import com.rjconsultores.ventaboletos.entidad.ParamRecoleccion; -import com.rjconsultores.ventaboletos.entidad.PerfilFuncion; -import com.rjconsultores.ventaboletos.entidad.PtoVtaCheckin; -import com.rjconsultores.ventaboletos.entidad.PtoVtaSeguro; -import com.rjconsultores.ventaboletos.entidad.PtoVtaUsuarioBancario; -import com.rjconsultores.ventaboletos.entidad.PtovtaAgencia; -import com.rjconsultores.ventaboletos.entidad.PtovtaAntecipacomissao; -import com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude; -import com.rjconsultores.ventaboletos.entidad.PtovtaCatInd; -import com.rjconsultores.ventaboletos.entidad.PtovtaComissao; -import com.rjconsultores.ventaboletos.entidad.PtovtaDiversos; -import com.rjconsultores.ventaboletos.entidad.PtovtaEmpresa; -import com.rjconsultores.ventaboletos.entidad.PtovtaEmpresaBloqueada; -import com.rjconsultores.ventaboletos.entidad.PtovtaEmpresaContaBancaria; -import com.rjconsultores.ventaboletos.entidad.PtovtaEstoque; -import com.rjconsultores.ventaboletos.entidad.PtovtaExcecaoMultaCanc; -import com.rjconsultores.ventaboletos.entidad.PtovtaHorario; -import com.rjconsultores.ventaboletos.entidad.PtovtaTitular; -import com.rjconsultores.ventaboletos.entidad.PuntoVenta; -import com.rjconsultores.ventaboletos.entidad.TipoPuntoVenta; -import com.rjconsultores.ventaboletos.entidad.Usuario; -import com.rjconsultores.ventaboletos.entidad.UsuarioBancario; -import com.rjconsultores.ventaboletos.entidad.UsuarioPerfil; -import com.rjconsultores.ventaboletos.enums.TipoAntifraude; -import com.rjconsultores.ventaboletos.enums.TipoSocio; -import com.rjconsultores.ventaboletos.exception.BusinessException; -import com.rjconsultores.ventaboletos.exception.IntegracionException; -import com.rjconsultores.ventaboletos.exception.ValidacionCampoException; -import com.rjconsultores.ventaboletos.service.CategoriaBloqueioImpPosteriorService; -import com.rjconsultores.ventaboletos.service.CategoriaService; -import com.rjconsultores.ventaboletos.service.CobrancaAdcPuntoVentaService; -import com.rjconsultores.ventaboletos.service.ColoniaService; -import com.rjconsultores.ventaboletos.service.ConstanteService; -import com.rjconsultores.ventaboletos.service.EmpresaService; -import com.rjconsultores.ventaboletos.service.FechamentoParamptovtaService; -import com.rjconsultores.ventaboletos.service.FormaPagoService; -import com.rjconsultores.ventaboletos.service.InstiFinanceiraService; -import com.rjconsultores.ventaboletos.service.MonedaService; -import com.rjconsultores.ventaboletos.service.NodoService; -import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; -import com.rjconsultores.ventaboletos.service.PerfilFuncionService; -import com.rjconsultores.ventaboletos.service.PtoVtaCheckinService; -import com.rjconsultores.ventaboletos.service.PtoVtaSeguroService; -import com.rjconsultores.ventaboletos.service.PtoVtaUsuarioBancarioService; -import com.rjconsultores.ventaboletos.service.PtovtaAntifraudeService; -import com.rjconsultores.ventaboletos.service.PtovtaCatIndService; -import com.rjconsultores.ventaboletos.service.PtovtaComissaoService; -import com.rjconsultores.ventaboletos.service.PtovtaEmpresaBloqueadaService; -import com.rjconsultores.ventaboletos.service.PtovtaEmpresaContaBancariaService; -import com.rjconsultores.ventaboletos.service.PtovtaEmpresaService; -import com.rjconsultores.ventaboletos.service.PtovtaExcecaoMultaCancService; -import com.rjconsultores.ventaboletos.service.PtovtaTitularService; -import com.rjconsultores.ventaboletos.service.PuntoVentaService; -import com.rjconsultores.ventaboletos.service.TipoPuntoVentaService; -import com.rjconsultores.ventaboletos.service.UsuarioBancarioService; -import com.rjconsultores.ventaboletos.service.UsuarioService; -import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; -import com.rjconsultores.ventaboletos.utilerias.CustomEnum; -import com.rjconsultores.ventaboletos.utilerias.DateUtil; -import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; -import com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales.FechamentoParamptovtaListItemRenderer; -import com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales.PuntoVendaHistoricoBloqueioListItemRenderer; -import com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales.PuntoVendaHistoricoFormaPagoListItemRenderer; -import com.rjconsultores.ventaboletos.web.utilerias.ConstraintNoEmpty; -import com.rjconsultores.ventaboletos.web.utilerias.ConstraintPorcentagemAllowNull; -import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; -import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxPuntoVenta; -import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; -import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; -import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox; -import com.rjconsultores.ventaboletos.web.utilerias.MyTextboxDecimal; -import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject; -import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper; -import com.rjconsultores.ventaboletos.web.utilerias.render.FormaPagoDetRender; -import com.rjconsultores.ventaboletos.web.utilerias.render.ParamRecoleccionRender; -import com.rjconsultores.ventaboletos.web.utilerias.render.PtovtaAntecipacomissaoRender; -import com.rjconsultores.ventaboletos.web.utilerias.render.PtovtaEmpresaRender; -import com.rjconsultores.ventaboletos.web.utilerias.render.PtovtaEstoqueRender; -import com.rjconsultores.ventaboletos.web.utilerias.render.PtovtaHorarioRender; -import com.rjconsultores.ventaboletos.web.utilerias.render.PtovtaUsuarioBancarioRender; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderCategoriaBloqueioVendaImpPosterior; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderCobrancaAdcPuntoVenta; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderCobrancaAdcicionalHistorico; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderEmpresaBloquear; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderHistoricoFormaPago; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderHistoricoFormaPagoSelecao; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderParadaPtoVtaCheckin; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtoVtaSeguro; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtovtaAntifraude; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtovtaCatInd; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtovtaComissao; -import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtovtaExcecaoMultaCanc; -import com.rjconsultores.ws.totvs.service.GeradorTitulosIntegracion; -import com.rjconsultores.ws.totvs.service.GerenciadorEnvioTitulosWS; -import com.rjconsultores.ws.utileria.RetornoTotvs.TipoRetorno; -import com.rjconsultores.wsag.GeradorTitulosAG; -//import com.rjconsultores.wsag.GeradorTitulosAG; -//import com.rjconsultores.wsag.WSAGLog; -import com.rjconsultores.wsag.WSAGLog; - -/** - * - * @author Rafius - */ -@Controller("editarPuntoVentaController") -@Scope("prototype") -public class EditarPuntoVentaController extends MyGenericForwardComposer { - - private static final long serialVersionUID = 1L; - - private static Logger log = LogManager.getLogger(EditarPuntoVentaController.class); - - public static final String FUNCION_TIPO_BOLETO_BLOQUEADO = "COM.RJCONSULTORES.ADMINISTRACION.PUNTOVENTA.TIPOBOLETOBLOQUEADO"; - public static final String FUNCION_COBRANCA_ADICIONAL = "COM.RJCONSULTORES.ADMINISTRACION.PUNTOVENTA.COBRANCAADICIONAL"; - public static final String PERMITE_APENAS_BLQUEIO_DESBLOQUEIO_AGENCIA = "COM.RJCONSULTORES.ADMINISTRACION.PUNTOVENTA.PERMITEAPENASBLOQUEIODESBLOQUEIOAGENCIA"; - public static final String FUNCION_INSERI_MOTIVO_FORMA_PAGO = "COM.RJCONSULTORES.ADMINISTRACION.PUNTOVENTA.PERMITEINSERIMOTIVOFORMAPAGO"; - public static final String TITULO = "editarPuntoVentaController.window.title"; - - - - @Autowired - private PuntoVentaService puntoVentaService; - @Autowired - private EmpresaService empresaService; - @Autowired - private TipoPuntoVentaService tipoPuntoVentaService; - @Autowired - private MonedaService monedaService; - @Autowired - private InstiFinanceiraService ptovtaBancoService; - @Autowired - private NodoService nodoService; - @Autowired - private FormaPagoService formaPagoService; - @Autowired - private ColoniaService coloniaService; - @Autowired - private PtovtaEmpresaService ptovtaEmpresaService; - @Autowired - private PtovtaEmpresaContaBancariaService ptovtaEmpresaContaBancariaService; - @Autowired - private PtoVtaUsuarioBancarioService ptoVtaUsuarioBancarioService; - @Autowired - private UsuarioBancarioService usuarioBancarioService; - @Autowired - private PtovtaComissaoService ptovtaComissaoService; - @Autowired - private PtovtaEmpresaBloqueadaService ptovtaEmpresaBloqueadaService; - @Autowired - private PtoVtaCheckinService ptoVtaCheckinService; - @Autowired - private PtoVtaSeguroService ptoVtaSeguroService; - @Autowired - private CategoriaService categoriaService; - @Autowired - private PtovtaCatIndService ptovtaCatIndService; - @Autowired - private UsuarioService usuarioService; - @Autowired - private FechamentoParamptovtaService fechamentoParamptovtaService; - @Autowired - private CategoriaBloqueioImpPosteriorService categoriaBloqueioImpPosteriorService; - @Autowired - private ConstanteService constanteService; - @Autowired - private PtovtaAntifraudeService ptovtaAntifraudeService; - @Autowired - private PtovtaExcecaoMultaCancService ptovtaExcecaoMultaCancService; - - @Autowired - private PtovtaTitularService ptovtaTitularService; - - @Autowired - private OrgaoConcedenteService orgaoConcedenteService; - - @Autowired - private PerfilFuncionService perfilFuncionService; - - private PuntoVenta puntoVenta; - private Textbox txtCP; - private MyListbox categoriaList; - private MyListbox puntoVentaList; - private MyListbox puntoVentaHistoricoFormaPagoList; - private MyListbox puntoVentaHistoricoFormaPagoListSel; - private MyListbox paramRecoleccionList; - private MyListbox formaPagoList; - private MyListbox ptovtaEmpresaList; - private MyListbox ptovtaEmpresasBloqueadasList; - private MyListbox ptovtaPtoVtaCheckinList; - private MyListbox ptovtaPtoVtaSeguroList; - private MyListbox ptovtaUsuarioBancarioList; - private MyListbox ptovtaAntecipaList; - private MyListbox ptovtaHorarioList; - private MyListbox ptovtaEstoqueList; - private MyListbox ptovtaComissaoList; - private MyListbox ptovtaCatIndList; - private List ptovtaCatIndListTemp; - private MyListbox fechamentoParamptovtaList; - private MyTextbox txtDiasemtransito; - private MyListbox ptovtaHistoricoList; - private MyListbox ptovtaHistoricoFormaPagoList; - private MyListbox categoriasBloqImpPosteriorList; - private MyListbox empresaContaBancariaList; - private Textbox txtChaveAntifraude; - private MyListbox ptovtaAntifraudeList; - private MyListbox ptovtaExcecaoMultaCancList; - private Bandbox bbCategoria; - - private List lsCategoriaBloquear; - - private List lsEmpresasBloquear; - private List lsEmpresas; - private List lsEmpresasSemTodos; - private List lsEmpresasFormapago; - private List lsEmpresaContaBancarias; - private List lsBanco; - private List lsTipoPuntoVenta; - private List lsMoneda; - private List lsColonia; - private List lsNodos; - private List lsFormaPago; - private List lsFormaPagoDet; - private List lsParamRecoleccion; - private List lsUsuarioBancario; - private List lsPtovtaEmpresa; - private List lsPtovtaUsuarioBancario; - private List lsAntecipacomissao; - private List lsHorario; - private List lsEmpresaComissao; - private List lsEstoque; - private List lsPtovtaComissao; - private List lsLogFiles; - private Radio radDatosTarjetaSi; - private Radio radDatosTarjetaNo; - private Radio radAprobacionAutorizado; - private Radio radAprobacionLatente; - private Radio radIndvendsegopcionalSi; - private Radio radIndvendsegopcionalNo; - private Radio radIndvendsegtabelaSi; - private Radio radIndvendsegtabelaNo; - private Radio radIndestansegopcionalSi; - private Radio radIndestansegopcionalNo; - private Radio radIndestansegtabelaSi; - private Radio radIndestansegtabelaNo; - private Radio radIntervalofechamentoDiario; - private Radio radIntervalofechamentoSemanal; - private Radio radIntervalofechamentoDecendial; - private Radio radIntervalofechamentoQuinzenal; - private Radio radIntervalofechamentoMensal; - private Radio radTotvsSi; - private Radio radTotvsNo; - private Radio radTotvsErro; - private Radio radTipoPagamentoBoleto; - private Radio radIndBloquear; - private Radio radIndLiberar; - private Radio radIndInclusaoHistoricoFormaPago; - private Radio radIndEclusaoHistoricoFormaPago; - private Button btnAdicionarEmpresaComissao; - private MyComboboxPuntoVenta cmbPuntoVentaPadre; - private Combobox cmbFormaPago; - private Combobox cmbEmpresaFormaPago; - private Combobox cmbHistoricoEmpresaFormaPago; - private Combobox cmbEmpresa; - private Combobox cmbEmpresaPtoVta; - private Combobox cmbEmpresaPtoVtaUsuarioBancario; - private Combobox cmbEmpresaPtoVtaAntifraude; - private Combobox cmbEmpresaPtoVtaExcecaoMultaCanc; - private Combobox cmbOrgaoConcedente; - private Combobox cmbParada; - private Combobox cmbPtoVtaCheckinParada; - private Combobox cmbEmpresaSeguro; - private Combobox cmbTipoPontoVenta; - private Combobox cmbMoneda; - /* private Combobox cmbNodo; */ - private Combobox cmbBanco; - private Combobox cmbPessoa; - private Combobox cmbTipoConta; - private Combobox cmbForm; - private Combobox cmbLote; - private Combobox cmbCiudad; - private Combobox cmbColonia; - private Combobox cmbConexion; - private Combobox cmbUsuarioBancario; - private Combobox cmbUsuarioBancarioPtoVtaUsuarioBancario; - private Combobox cmbPosicao; - private Combobox cmbReceita; - private Combobox cmbEmpresaComissao; - private Combobox cmbEmpresas; - private Combobox cmbTipoSocio; - private MyComboboxEstandar cmbEmpresasContaBancarias; - private Combobox cmbUsuarioEmpresa; - private Combobox cmbEmpresaFechamentoParamptovta; - private Combobox cmbLogFiles; - private Combobox cmbLogFilesAG; - private Combobox cmbBloqVendaImpPosterior; - private Combobox cmbUsuarioBloq; - private Button btnSalvarFormaPago; - private Button btnApagar; - private Button btnShowLog; - private Doublebox txtCargosExtras; - private MyTextbox txtNome; - private MyTextbox txtNumFax; - private MyTextbox txtCompl; - private MyTextbox txtNumAg; - private MyTextbox txtDigitoAg; - private MyTextbox txtConta; - private MyTextbox txtDigito; - private MyTextbox txtBilhetes; - private MyTextbox txtCarga; - private MyTextbox txtEspecie; - private MyTextbox txtTitularNome; - private MyTextbox txtTitularCpf; - private MyTextbox txtTitularRg; - private MyTextbox txtTitularEmissor; - private MyTextbox txtResponAluguel; - private MyTextbox txtResponTel; - private MyTextbox txtResponEnergia; - private MyTextbox txtNumDoCPuntoVenta; - private MyTextbox txtRazonSocial; - private MyTextbox txtIdEquivalencia; - private MyTextbox dscUsuarioInternet; - private MyTextbox dscContrasenaInternet; - private MyTextbox comentarios; - private MyTextbox txtHistoricoDescPago; - private MyTextboxDecimal importeInicial; - private MyTextboxDecimal importeAdicional; - private Datebox dateAntecipData; - private Datebox dateAbertura; - private Datebox dateFechamento; - private Datebox fecInicioAlteracaoHistoricoFormaPago; - private Datebox fecFimAlteracaoHistoricoFormaPago; - private MyTextboxDecimal txtAntecipRetem; - private MyTextboxDecimal txtAntecipPercentual; - private Image img; - private Timebox timeboxInicio; - private Timebox timeboxFim; - private Intbox txtQuant; - private Intbox txtcodAg; - private Intbox txtMaxCancelacion; - private Textbox txtNumPtoVta; - private Textbox txtNomeBanco; - private Textbox numtelefonodos; - private Textbox numtelefonouno; - private Textbox logResultAG; - private Checkbox checkInformatizada; - private Checkbox checkBilheteInfo; - private Checkbox checkVendaInternet; - private Checkbox checkTeleEntrega; - private Checkbox checkDigitacao; - private Checkbox checkBilhete; - private Checkbox checkOfpsPropria; - private Checkbox checkOfpsTerceiros; - private Checkbox checkCancelaPTA; - private Checkbox checkUTRRepasse; - private Checkbox checkCancelaPassNormal; - private Checkbox checkPtoVtaEmpresaIndTotalBus; - private Checkbox checkPtoVtaEmpresaIndEmbarcada; - private Radio radIndEstanTasaEmbarqueSi; - private Radio radIndEstanTasaEmbarqueNo; - private Radio radIndPermisoTasaEmbarqueSi; - private Radio radIndPermisoTasaEmbarqueNo; - private Radio radIndPermisoTasaEmbarqueVtaManualSi; - private Radio radIndPermisoTasaEmbarqueVtaAgenciaSi; - private Radio radIndVendeSeguroOpcEmbarcadaSi; - private Radio radIndVendeSeguroTabelaEmbarcadaSi; - private Radio radIndTaxaEmbarqueEmbarcadaSi; - private Checkbox checkPtoVtaEmpresaIndTerceirizada; - private Checkbox checkPtoVtaEmpresaIndBloqueada; - private Checkbox checkPtoVtaEmpresaIndMostrarCaja; - private Checkbox checkPtoVtaEmpresaIndImpCompCartao; - private Textbox txtNumeroSitef; - private Textbox txtMerchantStoreAdyen; - private Checkbox ckIsento; - private Checkbox checkSimulaIntegracion; - private Checkbox checkTodosPuntosVenta; - private Checkbox checkDinheiro; - private Checkbox checkCredito; - private Checkbox checkDebito; - private Checkbox checkTF; - private Checkbox checkBOL; - private Checkbox checkAdiantamentoAG; - private Checkbox checkCartaoAG; - private Checkbox checkBoletoAG; - private Checkbox checkDepositoAG; - private Checkbox checkPtovtaCatIndEmbarcada; - private Checkbox checkPtovtaCatIndTotalBus; - private MyTextbox txtNumIEPuntoVenta; - private Datebox fecIntegracion; - private Datebox fecInicioAG; - private Datebox fecFimAG; - private boolean integracionTotvs; - private boolean integracionAG; - private Timebox txtTempoParaImpressao; - private Checkbox ckValidarTempoParaImpressao; - private Checkbox checkLun; - private Checkbox checkMar; - private Checkbox checkMie; - private Checkbox checkJue; - private Checkbox checkVie; - private Checkbox checkSab; - private Checkbox checkDom; - private Checkbox ckIndEstoqueMotorista; - private Checkbox checkBloqDevolveReativaOutroPto; - private Checkbox checkIndQrcodeCatracaRodEAN13; - private Checkbox checkIndVendeFlexBus; - private Checkbox checkIndQrcodeTaxaEmbarqueRodTTL; - private Checkbox ckIndBloqueiaCancelamentoImpressaoPosterior; - private Checkbox ckIndBloqueiaCancelamentoBilheteImpresso; - private Row rowDateFechamento; - private Row rowMotivoBloqueio; - private Textbox motivoBloqueio; - private String logFileSelected; - private Textbox descCorreo; - private String statusAprobacionInicial = ""; - private Decimalbox txtTaxaConvenienciaPorc; - private Doublebox txtMaximoTaxaConveniencia; - private ConstraintPorcentagemAllowNull ct; - private Intbox intTiempoMaxBoletoEnVenta; - private Intbox intTempoServicoEmVenda; - private Tab tabEndereco; - private Tab tabComissao; - private Tab tabBanco; - private Tab tabTitular; - private Tab tabDiversos; - private Tab tabHorario; - private Tab tabFormaPago; - private Tab tabEmpresaVenta; - private Tab tabEmpresaBloqeuada; - private Tab tabLocalidades; - private Tab tabSeguroTaxaEmbarque; - private Tab tabTipoPassageiro; - private Tab tabfechamentoCntCorrente; - private Tab tabBloqueiaVendaImpPosterior; - private Tab tabAnrifraude; - private Tab tabExcecaoMultaCancelamento; - private Tab tabHistorico; - private Tab tabRecollecion; - private Paging pagingHistoricoFormaPago; - private Paging pagingFormaPago; - private Textbox txtLatitudeLongitude; - private Textbox txtLatitude; - private Textbox txtLongitude; - @Autowired - private transient PagedListWrapper plwHistoricoFormaPagoPuntoVenta; - @Autowired - private transient PagedListWrapper plwHistoricoFormaPago; - - private Set lsCategoriaSel; - - private static final String EMAIL_PATTERN = - "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" - + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; - - private static final Pattern pattern = Pattern.compile(EMAIL_PATTERN, Pattern.CASE_INSENSITIVE); - - private static final int TAMANHO_BUFFER = 4096; // 4kb - - PtovtaEmpresa ptovtaEmpresa; - - @Autowired - private DataSource dataSource; - - //CobrancaAdicional - private Textbox descricaoCobranca; - private Doublebox valorCobrancaAdicional; - private List lsEmpresasCobrancaAdicional; - private List lsTodasCobrancas; - private Combobox cmbEmpresaCobranca; - private Combobox cmbCobrancasPuntoVenta; - private Radio radioDiario; - private Radio radioSemanal; - private Radio radioMensal; - private Radio radioSegunda; - private Radio radioTerca; - private Radio radioQuarta; - private Radio radioQuinta; - private Radio radioSexta; - private Radio radioPrimeiroDiaMes; - private Radio radioUltimoDiaMes; - private MyListbox cobrancaAdicionalList; - private MyListbox historicoCobrancaList; - private Radio radioProximoCiclo; - private Radio radioProximoDia; - private CobrancaAdcPuntoVenta cobrancaAux = new CobrancaAdcPuntoVenta(); - private Datebox dataInicioCobranca; - private Datebox dataFimCobranca; - private Datebox dataInicioHistorico; - private Datebox dataFimHistorico; - private Boolean utilizaCobrancaAdicional = false; - private boolean isPerfilFuncionBloqueiaDesbloqueiaPontoVenda; - private boolean isPermissaoMotivoFormaPago; - - private Checkbox checkIndBloqueioDescontoAPI; - private Checkbox checkIndBloqueioDescontoWEB; - private Checkbox checkIndTaxaConvenienciaOrgaoConcedente; - private final String constanteIndMotivoBloqueio= "IND_MOTIVO_BLOQUEIO"; - - @Autowired - private CobrancaAdcPuntoVentaService cobrancaAdcService; - - private List lsOrgaoConcedentes; - - private boolean indMotivoBloqueio; - - public Button getBtnApagar() { - return btnApagar; - } - - public void setBtnApagar(Button btnApagar) { - this.btnApagar = btnApagar; - } - - public void aplicarMascara() { - Clients.evalJavaScript( - "jQuery('#" + txtNumFax.getUuid() + "').mask('(999)9999-9999?9');" + - "jQuery('#" + numtelefonodos.getUuid() + "').mask('(999)9999-9999?9');" + - "jQuery('#" + numtelefonouno.getUuid() + "').mask('(999)9999-9999?9');"); - } - - private List getLogFiles() { - List files = new ArrayList(); - File logDir = new File(System.getProperty("jboss.server.log.dir")); - for (String str : logDir.list()) { - if (str.contains("ws") && !str.contains("zip")) { - files.add(str); - } - } - return files; - } - - @Override - public void doAfterCompose(Component comp) throws Exception { - setCt(new ConstraintPorcentagemAllowNull()); - isPerfilFuncionBloqueiaDesbloqueiaPontoVenda = isPerfilFuncionBloqueiaDesbloqueiaPontoVenda(); - isPermissaoMotivoFormaPago = isPermiteInserirMotivoFormaPago(); - lsCategoriaSel = new HashSet(); - lsCategoriaBloquear = categoriaService.obtenerTodasCategoriasVisibles(); - lsEmpresasBloquear = empresaService.obtenerTodos(); - lsEmpresasCobrancaAdicional = empresaService.obtenerTodos(); - lsEmpresas = obterEmpresasUsuarioLogadoComOpcaoTodas(); - lsEmpresasSemTodos = UsuarioLogado.getUsuarioLogado().getEmpresa(); - lsMoneda = monedaService.obtenerTodos(); - lsBanco = ptovtaBancoService.obtenerTodos(); - lsColonia = new ArrayList(); - - lsFormaPago = formaPagoService.obtenerTodos(); - lsEmpresasFormapago = obterEmpresasUsuarioLogadoComOpcaoTodas(); - - lsTipoPuntoVenta = tipoPuntoVentaService.obtenerTodosExceto(TipoPuntoVenta.TODOS); - lsUsuarioBancario = usuarioBancarioService.obtenerTodos(); - lsLogFiles = getLogFiles(); - puntoVenta = (PuntoVenta) Executions.getCurrent().getArg().get("puntoVenta"); - lsTodasCobrancas = cobrancaAdcService.buscarTodasAsCobrancas(puntoVenta); - lsOrgaoConcedentes = orgaoConcedenteService.obtenerTodos(); - - super.doAfterCompose(comp); - - if(puntoVenta.getIndBloqueiaTipoPassagem()) { - radIndBloquear.setSelected(Boolean.TRUE); - }else { - radIndLiberar.setSelected(Boolean.TRUE); - } - - bbCategoria.addEventListener(Events.ON_CHANGING, new EventListener() { - - @Override - public void onEvent(Event event) throws Exception { - autoCompleteBandbox(((InputEvent)event).getValue()); - } - }); - - inserirItensLista(lsCategoriaBloquear); - - getTxtTaxaConvenienciaPorc().setConstraint(getCt()); - cmbBanco.addEventListener("onAfterRender", new org.zkoss.zk.ui.event.EventListener() { - @Override - public void onEvent(Event event) throws Exception { - cmbBanco.setSelectedIndex(lsBanco.indexOf(puntoVenta.getAgenciaId().getInstiFinanceiraId())); - } - }); - - utilizaCobrancaAdicional = utilizaCobrancaAdicional(); - - aplicarMascara(); - - popularCombobox(cmbTipoConta, cmbPessoa, cmbForm, cmbLote, cmbPosicao, cmbReceita, cmbEmpresas, cmbUsuarioEmpresa, cmbEmpresaCobranca, cmbCobrancasPuntoVenta, cmbTipoSocio); - - ptovtaEmpresasBloqueadasList.setItemRenderer(new RenderEmpresaBloquear()); - ptovtaPtoVtaCheckinList.setItemRenderer(new RenderParadaPtoVtaCheckin()); - ptovtaPtoVtaSeguroList.setItemRenderer(new RenderPtoVtaSeguro()); - cobrancaAdicionalList.setItemRenderer(new RenderCobrancaAdcPuntoVenta()); - historicoCobrancaList.setItemRenderer(new RenderCobrancaAdcicionalHistorico()); - ptovtaCatIndList.setItemRenderer(new RenderPtovtaCatInd()); - ptovtaCatIndListTemp = new ArrayList(); - ptovtaHistoricoList.setItemRenderer(new PuntoVendaHistoricoBloqueioListItemRenderer()); - categoriasBloqImpPosteriorList.setItemRenderer(new RenderCategoriaBloqueioVendaImpPosterior()); - ptovtaHistoricoFormaPagoList.setItemRenderer(new PuntoVendaHistoricoFormaPagoListItemRenderer()); - puntoVentaHistoricoFormaPagoListSel.setItemRenderer(new RenderHistoricoFormaPago(new EventListener() { - @Override - public void onEvent(Event arg0) throws Exception { - FormaPago pf = (FormaPago) arg0.getTarget().getAttribute("data"); - for (Object formaPago : puntoVentaHistoricoFormaPagoListSel.getListData()) { - if(((FormaPago)formaPago).equals(pf)){ - puntoVentaHistoricoFormaPagoListSel.removeItem(pf); - executarPesquisaFormaPagoHistorico(); - break; - } - } - } - }));; - - cobrancaAdicionalList.addEventListener("onDoubleClick", new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - CobrancaAdcPuntoVenta cobranca = (CobrancaAdcPuntoVenta) cobrancaAdicionalList.getSelected(); - carregarCobrancaAdicional(cobranca); - } - }); - - ptovtaComissaoList.setItemRenderer(new RenderPtovtaComissao()); - ptovtaComissaoList.addEventListener("onDoubleClick", new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - PtovtaComissao ptovtaComissao = (PtovtaComissao) ptovtaComissaoList.getSelected(); - abrirPtovtaComissao(ptovtaComissao); - } - }); - - numtelefonodos.addEventListener(Events.ON_CHANGE, new EventListener() { - - @Override - public void onEvent(Event event) throws Exception { - numtelefonodos.setValue(mascaraTelefone(numtelefonodos.getValue())); - } - }); - - numtelefonouno.addEventListener(Events.ON_CHANGE, new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - numtelefonouno.setValue(mascaraTelefone(numtelefonouno.getValue())); - } - }); - - txtNumFax.addEventListener(Events.ON_CHANGE, new EventListener() { - - @Override - public void onEvent(Event event) throws Exception { - txtNumFax.setValue(mascaraTelefone(txtNumFax.getValue())); - } - }); - - - try { - fechamentoParamptovtaList.setItemRenderer(new FechamentoParamptovtaListItemRenderer()); - - if (puntoVenta.getPuntoventaId() != null) { - puntoVenta = puntoVentaService.obtenerID(puntoVenta.getPuntoventaId()); - - //chamadas de inicialização para evitar LazyInitializationException - puntoVenta.getLsFormaPagoDet().size(); - puntoVenta.getLsParamRecoleccion().size(); - puntoVenta.getLsPtovtaEmpresa().size(); - puntoVenta.getPtovtaAntecipacomissaoList().size(); - puntoVenta.getPtovtaEstoqueList().size(); - puntoVenta.getPtovtaHorarioList().size(); - puntoVenta.getLsPtovtaUsuarioBancario().size(); - - - lsEmpresaComissao = empresaService.buscarNotInPuntoVtaComissao(puntoVenta); - - lsPtovtaComissao = ptovtaComissaoService.buscarByPuntaVenta(puntoVenta); - - btnAdicionarEmpresaComissao.setDisabled(false); - ptovtaComissaoList.setData(lsPtovtaComissao); - - ptovtaEmpresasBloqueadasList.setData(puntoVenta.getPtovtaEmpresaBloqueadaList()); - ptovtaPtoVtaCheckinList.setData(puntoVenta.getPtovtaCheckinList()); - ptovtaPtoVtaSeguroList.setData(puntoVenta.getPtovtaSeguroList()); - ptovtaCatIndList.setData(puntoVenta.getPtovtaCatIndList()); - ptovtaCatIndListTemp.addAll(puntoVenta.getPtovtaCatIndList()); - List lsHistoricoPuntoVentaOrdenada =puntoVenta.getHistoricoPuntoVentaList(); - - Collections.sort(lsHistoricoPuntoVentaOrdenada, new Comparator() { - public int compare(Object o1, Object o2) { - HistoricoPuntoVenta c1 = (HistoricoPuntoVenta) o1; - HistoricoPuntoVenta c2 = (HistoricoPuntoVenta) o2; - return c1.getFecBloqueio().compareTo( c2.getFecBloqueio()); - - } - }); - ptovtaHistoricoList.setData(lsHistoricoPuntoVentaOrdenada); - ptovtaHistoricoFormaPagoList.setData(puntoVenta.getHistoricoFormaPagoPuntoVentaList()); - categoriasBloqImpPosteriorList.setData(puntoVenta.getCategoriaBloqImpPosteriorList()); - cobrancaAdicionalList.setData(puntoVenta.getCobrancaAdicionalList()); - - if (puntoVenta.getColonia() != null) { - cmbCiudad.setText(puntoVenta.getColonia().getCiudad().getNombciudad()); - cmbColonia.setText(puntoVenta.getColonia().getDesccolonia()); - } - - if (puntoVenta.getNumfax() != null) { - txtNumFax.setValue(puntoVenta.getNumfax()); - } - - try { - if (puntoVenta.getNumtelefonouno() != null) { - numtelefonouno.setValue(puntoVenta.getNumtelefonouno()); - } - }catch (WrongValueException e) { - numtelefonouno.setValue(""); - Messagebox.show("Telefone fora do padrão, Preencha novamente", - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - } - - try { - if (puntoVenta.getNumtelefonodos() != null) { - numtelefonodos.setValue(puntoVenta.getNumtelefonodos()); - } - }catch (WrongValueException e) { - numtelefonodos.setValue(""); - Messagebox.show("Celular fora do padrão, Preencha novamente", - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - } - - if (puntoVenta.getNumDoCPuntoVenta() != null) { - txtNumDoCPuntoVenta.setValue(puntoVenta.getNumDoCPuntoVenta()); - } - - if (puntoVenta.getRazonSocial() != null) { - txtRazonSocial.setValue(puntoVenta.getRazonSocial()); - } - - List params = fechamentoParamptovtaService.buscaParametrosPorPuntoventa(puntoVenta); - fechamentoParamptovtaList.setData(params); - - if(puntoVenta.getIndBloqueaCancTrocaPassNormal() != null){ - if(puntoVenta.getIndBloqueaCancTrocaPassNormal()){ - checkCancelaPassNormal.setChecked(true); - }else{ - checkCancelaPassNormal.setChecked(false); - } - } - - if(puntoVenta.getIndBloqueaCancTrocaPTA() != null){ - if(puntoVenta.getIndBloqueaCancTrocaPTA()){ - checkCancelaPTA.setChecked(true); - }else{ - checkCancelaPTA.setChecked(false); - } - } - - if(puntoVenta.getIndRepassaUTR() != null){ - if(puntoVenta.getIndRepassaUTR()){ - checkUTRRepasse.setChecked(true); - }else{ - checkUTRRepasse.setChecked(false); - } - } - if(puntoVenta.getTipoSocio() != null) { - cmbTipoSocio.setValue(puntoVenta.getTipoSocio().toString()); - } - if(puntoVenta.getTitularId() != null) { - puntoVenta.setTitularId(ptovtaTitularService.obtenerID(puntoVenta.getTitularId().getPtovtaTitularId()));; - } - } - - puntoVentaList = (MyListbox) Executions.getCurrent().getArg().get("puntoVentaList"); - - if (puntoVenta.getPuntoventaId() != null) { - if (puntoVenta.getStatusaprobacion() != null) { - if (puntoVenta.getStatusaprobacion().equals("A")) { - radAprobacionAutorizado.setChecked(true); - } else if (puntoVenta.getStatusaprobacion().equals("L")) { - radAprobacionLatente.setChecked(true); - } - } - } - - statusAprobacionInicial = radAprobacionAutorizado.isChecked() ? "A" : "L"; - - obterOValorConstanteIndMotivoBloqueio(); - if (indMotivoBloqueio) { - rowMotivoBloqueio.setVisible(true); - } - - - if (puntoVenta.getPuntoventaId() != null) { - - motivoBloqueio.setValue(puntoVenta.getMotivoBloqueio()); - - if (puntoVenta.getAgenciaId() != null) { - - if (puntoVenta.getAgenciaId().getInstiFinanceiraId() != null) { - txtNomeBanco.setText(puntoVenta.getAgenciaId().getInstiFinanceiraId().getCodigo()); - } - - if (puntoVenta.getAgenciaId().getPessoa() != null) { - if (puntoVenta.getAgenciaId().getPessoa().equals("F")) { - cmbPessoa.setSelectedIndex(0); - } else if (puntoVenta.getAgenciaId().getPessoa().equals("J")) { - cmbPessoa.setSelectedIndex(1); - } - } - - if (puntoVenta.getAgenciaId().getTipo() != null) { - if (puntoVenta.getAgenciaId().getTipo().equals("CC")) { - cmbTipoConta.setSelectedIndex(0); - } else if (puntoVenta.getAgenciaId().getTipo().equals("P")) { - cmbTipoConta.setSelectedIndex(1); - } - } - - } else { - puntoVenta.setAgenciaId(new PtovtaAgencia()); - } - if (puntoVenta.getDateAbertura() != null) { - dateAbertura.setValue(puntoVenta.getDateAbertura()); - } - - if (radAprobacionLatente.isChecked()) { - dateFechamento.setValue(puntoVenta.getDateFechamento()); - rowDateFechamento.setVisible(true); - } - } else { - dateAbertura.setValue(new Date()); - } - - if (puntoVenta.getPuntoventaId() != null) { - if (puntoVenta.getIndIntegracion() != null) { - - if (puntoVenta.getIndIntegracion().equals(TipoRetorno.CONCLUIDA.getValor())) { - radTotvsSi.setChecked(true); - } else if (puntoVenta.getIndIntegracion().equals(TipoRetorno.JA_CADASTRADA.getValor())) { - radTotvsNo.setChecked(true); - } else if (puntoVenta.getIndIntegracion().equals(TipoRetorno.ERRO.getValor())) { - radTotvsErro.setChecked(true); - } - } - if (puntoVenta.getNumIEPuntoVenta() != null) { - if (puntoVenta.getNumIEPuntoVenta().equals("ISENTO")) { - ckIsento.setChecked(true); - txtNumIEPuntoVenta.setDisabled(true); - } - } - - try { - String agencia = puntoVenta.getAgenciaId() == null ? "" : puntoVenta.getAgenciaId().getNumagencia(); - String[] agenciaComp = agencia == null ? null : agencia.split("-"); - txtNumAg.setValue(agencia == null ? "" : agenciaComp[0]); - txtDigitoAg.setValue(agencia == null ? "" : agenciaComp[1]); - } catch (Exception e) { - } - } - - if (puntoVenta.getPuntoventaId() != null) { - if (puntoVenta.getDiversosId() != null) { - if (puntoVenta.getDiversosId().getInformatizada() != null) { - if (puntoVenta.getDiversosId().getInformatizada()) { - checkInformatizada.setChecked(true); - } else { - checkInformatizada.setChecked(false); - } - } - - if (puntoVenta.getDiversosId().getBilheteInfo() != null) { - if (puntoVenta.getDiversosId().getBilheteInfo()) { - checkBilheteInfo.setChecked(true); - } else { - checkBilheteInfo.setChecked(false); - } - } - - if (puntoVenta.getDiversosId().getPosicao() != null) { - if (puntoVenta.getDiversosId().getPosicao().equals("FEL")) { - cmbPosicao.setSelectedIndex(0); - } else if (puntoVenta.getDiversosId().getPosicao().equals("EL")) { - cmbPosicao.setSelectedIndex(1); - } - } - - if (puntoVenta.getDiversosId().getVendaInternet() != null) { - if (puntoVenta.getDiversosId().getVendaInternet()) { - checkVendaInternet.setChecked(true); - } else { - checkVendaInternet.setChecked(false); - } - } - - if (puntoVenta.getDiversosId().getTeleEntrega() != null) { - if (puntoVenta.getDiversosId().getTeleEntrega()) { - checkTeleEntrega.setChecked(true); - } else { - checkTeleEntrega.setChecked(false); - } - } - - if (puntoVenta.getDiversosId().getDigitacaoSeq() != null) { - if (puntoVenta.getDiversosId().getDigitacaoSeq()) { - checkDigitacao.setChecked(true); - } else { - checkDigitacao.setChecked(false); - } - } - - if (puntoVenta.getDiversosId().getTrabalhaBilhete() != null) { - if (puntoVenta.getDiversosId().getTrabalhaBilhete()) { - checkBilhete.setChecked(true); - } else { - checkBilhete.setChecked(false); - } - } - - if (puntoVenta.getDiversosId().getOfpsPropria() != null) { - if (puntoVenta.getDiversosId().getOfpsPropria()) { - checkOfpsPropria.setChecked(true); - } else { - checkOfpsPropria.setChecked(false); - } - } - - if (puntoVenta.getDiversosId().getOfpsTerceiros() != null) { - if (puntoVenta.getDiversosId().getOfpsTerceiros()) { - checkOfpsTerceiros.setChecked(true); - } else { - checkOfpsTerceiros.setChecked(false); - } - } - - } else { - puntoVenta.setDiversosId(new PtovtaDiversos()); - } - } - - if (puntoVenta.getPuntoventaId() != null) { - if (puntoVenta.getTitularId() != null) { - if (puntoVenta.getTitularId().getImagem() != null) { - img.setContent(new org.zkoss.image.AImage("imagem", - puntoVenta.getTitularId().getImagem())); - } - } else { - puntoVenta.setTitularId(new PtovtaTitular()); - } - } - - formaPagoList.setItemRenderer(new FormaPagoDetRender()); - if (puntoVenta.getLsFormaPagoDet() == null) { - puntoVenta.setLsFormaPagoDet(new ArrayList()); - } - lsFormaPagoDet = puntoVenta.getLsFormaPagoDet(); - formaPagoList.setData(lsFormaPagoDet); - - paramRecoleccionList.setItemRenderer(new ParamRecoleccionRender()); - if (puntoVenta.getLsParamRecoleccion() == null) { - puntoVenta.setLsParamRecoleccion(new ArrayList()); - } - - lsParamRecoleccion = puntoVenta.getLsParamRecoleccion(); - paramRecoleccionList.setData(lsParamRecoleccion); - - ptovtaEmpresaList.setItemRenderer(new PtovtaEmpresaRender()); - ptovtaEmpresaList.addEventListener("onDoubleClick", new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - PtovtaEmpresa ptovtaEmpresa = (PtovtaEmpresa) ptovtaEmpresaList.getSelected(); - editarPtovtaEmpresa(ptovtaEmpresa); - } - }); - - if (puntoVenta.getLsPtovtaEmpresa() == null) { - puntoVenta.setLsPtovtaEmpresa(new ArrayList()); - } - - lsPtovtaEmpresa = puntoVenta.getLsPtovtaEmpresa(); - ptovtaEmpresaList.setData(lsPtovtaEmpresa); - - ptovtaAntecipaList.setItemRenderer(new PtovtaAntecipacomissaoRender()); - if (puntoVenta.getPtovtaAntecipacomissaoList() == null) { - puntoVenta.setPtovtaAntecipacomissaoList(new ArrayList()); - } - - lsAntecipacomissao = puntoVenta.getPtovtaAntecipacomissaoList(); - ptovtaAntecipaList.setData(lsAntecipacomissao); - - ptovtaHorarioList.setItemRenderer(new PtovtaHorarioRender()); - if (puntoVenta.getPtovtaHorarioList() == null) { - puntoVenta.setPtovtaHorarioList(new ArrayList()); - } - - lsHorario = puntoVenta.getPtovtaHorarioList(); - ptovtaHorarioList.setData(lsHorario); - - ptovtaEstoqueList.setItemRenderer(new PtovtaEstoqueRender()); - if (puntoVenta.getPtovtaEstoqueList() == null) { - puntoVenta.setPtovtaEstoqueList(new ArrayList()); - } - - lsEstoque = puntoVenta.getPtovtaEstoqueList(); - ptovtaEstoqueList.setData(lsEstoque); - - ptovtaUsuarioBancarioList.setItemRenderer(new PtovtaUsuarioBancarioRender()); - if (puntoVenta.getLsPtovtaUsuarioBancario() == null) { - puntoVenta.setLsPtovtaUsuarioBancario(new ArrayList()); - } - - lsPtovtaUsuarioBancario = puntoVenta.getLsPtovtaUsuarioBancario(); - ptovtaUsuarioBancarioList.setData(lsPtovtaUsuarioBancario); - - if (puntoVenta.getPuntoventaId() == null) { - btnApagar.setVisible(Boolean.FALSE); - } else { - if (puntoVenta.getParada() != null) { - cmbParada.setText(puntoVenta.getParada().getDescparada()); - } - } - - empresaContaBancariaList.setMultiple(true); - empresaContaBancariaList.setData(new ArrayList(0)); - } catch (Exception e) { - log.error("Punto de Venta: ", e); - Messagebox.show( - Labels.getLabel("MSG.Error"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } - - txtNome.focus(); - if (puntoVenta.getValidaTempoParaImpressao() != null) { - txtTempoParaImpressao.setDisabled(!puntoVenta.getValidaTempoParaImpressao()); - } - - ptovtaAntifraudeList.setItemRenderer(new RenderPtovtaAntifraude()); - ptovtaAntifraudeList.setData(puntoVenta.getPtovtaAntifraudes() == null? Collections.emptyList():puntoVenta.getPtovtaAntifraudes()); - ptovtaAntifraudeList.addEventListener("onDoubleClick", new EventListener() { - - @Override - public void onEvent(Event event) throws Exception { - PtovtaAntifraude a = (PtovtaAntifraude) ptovtaAntifraudeList.getSelected(); - verPtovtaAntifraude(a); - } - }); - - ptovtaExcecaoMultaCancList.setItemRenderer(new RenderPtovtaExcecaoMultaCanc()); - ptovtaExcecaoMultaCancList.setData(puntoVenta.getPtovtaExcecaoMultaCancList() == null ? Collections.emptyList() : puntoVenta.getPtovtaExcecaoMultaCancList()); - validaPerfilFuncionBloqueiaDesbloqueiaPontoVenda(); - - txtLatitudeLongitude.addEventListener("onChanging", new EventListener() { - - @Override - public void onEvent(Event event) throws Exception { - if (event instanceof InputEvent) { - InputEvent inputEvent = (InputEvent) event; - if (inputEvent.getValue() != null) { - List coordinates = Arrays.asList(inputEvent.getValue().split("\\s*,\\s*")); - if (!coordinates.isEmpty() && coordinates.size() == 2) { - Float latitude = new BigDecimal(coordinates.get(0)).floatValue(); - Float longitude = new BigDecimal(coordinates.get(1)).floatValue(); - txtLatitude.setValue(String.valueOf(latitude)); - txtLongitude.setValue(String.valueOf(longitude)); - txtLatitudeLongitude.setValue(null); - txtLatitudeLongitude.setText(null); - puntoVenta.setLatitude(latitude); - puntoVenta.setLongitude(longitude); - event.stopPropagation(); - } - } - } - } - - }); - - - - } - - /** - * Desabilita todos os campos deixando apenas o status de aprovação, aberto/fechado. - * Caso adicionar novos campos, favor tratar neste método - */ - private void validaPerfilFuncionBloqueiaDesbloqueiaPontoVenda() { - if(isPerfilFuncionBloqueiaDesbloqueiaPontoVenda) { - tabEndereco.setVisible(false); - tabComissao.setVisible(false); - tabBanco.setVisible(false); - tabTitular.setVisible(false); - tabDiversos.setVisible(false); - tabHorario.setVisible(false); - tabFormaPago.setVisible(false); - tabEmpresaVenta.setVisible(false); - tabEmpresaBloqeuada.setVisible(false); - tabLocalidades.setVisible(false); - tabSeguroTaxaEmbarque.setVisible(false); - tabTipoPassageiro.setVisible(false); - tabfechamentoCntCorrente.setVisible(false); - tabBloqueiaVendaImpPosterior.setVisible(false); - tabAnrifraude.setVisible(false); - tabExcecaoMultaCancelamento.setVisible(false); - tabHistorico.setVisible(false); - tabRecollecion.setVisible(isPerfilFuncionRecollecion()); - //Campos - txtNome.setDisabled(true); - txtIdEquivalencia.setDisabled(true); - txtNumPtoVta.setDisabled(true); - txtMaxCancelacion.setDisabled(true); - radTotvsSi.setDisabled(true); - radTotvsNo.setDisabled(true); - radTotvsErro.setDisabled(true); - radTipoPagamentoBoleto.setDisabled(true); - radIndBloquear.setDisabled(true); - radIndLiberar.setDisabled(true); - txtMaxCancelacion.setDisabled(true); - cmbParada.setDisabled(true); - cmbEmpresa.setDisabled(true); - cmbTipoPontoVenta.setDisabled(true); - cmbMoneda.setDisabled(true); - cmbPuntoVentaPadre.setDisabled(true); - numtelefonouno.setDisabled(true); - numtelefonodos.setDisabled(true); - txtNumFax.setDisabled(true); - //cmbNodo - cmbConexion.setDisabled(true); - cmbUsuarioBancario.setDisabled(true); - dscUsuarioInternet.setDisabled(true); - dscContrasenaInternet.setDisabled(true); - txtNumDoCPuntoVenta.setDisabled(true); - txtRazonSocial.setDisabled(true); - txtNumIEPuntoVenta.setDisabled(true); - ckIsento.setDisabled(true); - ckValidarTempoParaImpressao.setDisabled(true); - comentarios.setDisabled(true); - ckIndEstoqueMotorista.setDisabled(true); - txtMaximoTaxaConveniencia.setDisabled(true); - checkBloqDevolveReativaOutroPto.setDisabled(true); - ckIndBloqueiaCancelamentoImpressaoPosterior.setDisabled(true); - ckIndBloqueiaCancelamentoBilheteImpresso.setDisabled(true); - checkCancelaPassNormal.setDisabled(true); - checkCancelaPTA.setDisabled(true); - checkUTRRepasse.setDisabled(true); - intTiempoMaxBoletoEnVenta.setDisabled(true); - intTempoServicoEmVenda.setDisabled(true); - checkIndQrcodeCatracaRodEAN13.setDisabled(true); - checkIndVendeFlexBus.setDisabled(true); - checkIndQrcodeTaxaEmbarqueRodTTL.setDisabled(true); - dateAbertura.setDisabled(true); - txtTaxaConvenienciaPorc.setDisabled(true); - checkIndBloqueioDescontoAPI.setDisabled(true); - checkIndBloqueioDescontoWEB.setDisabled(true); - checkIndTaxaConvenienciaOrgaoConcedente.setDisabled(true); - } - - } - - @Transactional - public boolean isPerfilFuncionBloqueiaDesbloqueiaPontoVenda() { - Usuario usuarioLogado = usuarioService.obtenerID(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - List listUsuarioPerfil = usuarioLogado.getUsuarioPerfilList(); - for (UsuarioPerfil up : listUsuarioPerfil) { - List listPerfilFuncion = up.getPerfil().getPerfilFuncionList(); - for (PerfilFuncion pf : listPerfilFuncion) { - if(pf.getFuncionSistema().getDescruta().equals(PERMITE_APENAS_BLQUEIO_DESBLOQUEIO_AGENCIA)) - return true; - } - } - - return false; - } - - - public boolean isPerfilFuncionRecollecion() { - return perfilFuncionService.usuarioPossuiPermissaoFuncionalidade(UsuarioLogado.getUsuarioLogado().getUsuarioId(), ConstantesFuncionSistema.FUNCION_RECOLECCION); - } - - - private List obterEmpresasUsuarioLogadoComOpcaoTodas() { - List listaEmpresas = new ArrayList(); - listaEmpresas.add(empresaService.obtenerID(-1)); - listaEmpresas.addAll(UsuarioLogado.getUsuarioLogado().getEmpresa()); - return listaEmpresas; - } - - private void downloadLogIntegracao(Combobox cmb){ - String fileName = System.getProperty("jboss.server.log.dir") + "/" + cmb.getSelectedItem().getValue().toString(); - String fileZip = System.getProperty("jboss.server.log.dir") + "/" + cmb.getSelectedItem().getValue().toString().replace("log", "zip"); - FileInputStream inputStream; - try { - excluirArquivosZip(); - compactarArquivo(fileZip, fileName); - File file = new File(fileZip); - if (file.exists()) { - inputStream = new FileInputStream(file); - Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(file), file.getName()); - } - file.delete(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void onClick$btnAddCategoriaBloqueioImpPosterior(Event event) { - CategoriaBloqueioImpPosterior cat = new CategoriaBloqueioImpPosterior(); - if (cmbBloqVendaImpPosterior.getSelectedItem() == null) { - return; - } - cat.setCategoria((Categoria)cmbBloqVendaImpPosterior.getSelectedItem().getValue()); - cat.setPuntoventa(puntoVenta); - - puntoVenta.addCategoriaBloqImpPosterior(cat); - - categoriasBloqImpPosteriorList.setData(puntoVenta.getCategoriaBloqImpPosteriorList()); - } - - public void onClick$btnRemoveCategoriaBloqueioImpPosterior(Event event) { - try{ - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.borrarCategoriaBloqueioImpPosterior"), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if (resp == Messagebox.YES) { - CategoriaBloqueioImpPosterior cat = (CategoriaBloqueioImpPosterior)categoriasBloqImpPosteriorList.getSelected(); - - puntoVenta.removeCategoriaBloqImpPosterior(cat); - categoriaBloqueioImpPosteriorService.borrar(cat); - - categoriasBloqImpPosteriorList.setData(puntoVenta.getCategoriaBloqImpPosteriorList()); - } - } catch (Exception e){ - log.error("", e); - } - } - - public void onClick$btnDownload(Event event) { - downloadLogIntegracao(cmbLogFiles); - } - - public void onClick$btnDownloadAG(Event event) { - downloadLogIntegracao(cmbLogFilesAG); - } - - @Transactional - public boolean validaFuncionTipoBoletoBloqueado() { - if(isPerfilFuncionBloqueiaDesbloqueiaPontoVenda) { - return false; - } - List listClavesPermisos = new ArrayList(); - - Usuario usuarioLogado = usuarioService.obtenerID(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - List listUsuarioPerfil = usuarioLogado.getUsuarioPerfilList(); - for (UsuarioPerfil up : listUsuarioPerfil) { - List listPerfilFuncion = up.getPerfil().getPerfilFuncionList(); - for (PerfilFuncion pf : listPerfilFuncion) { - listClavesPermisos.add(pf.getFuncionSistema().getDescruta()); - } - } - - - if (listClavesPermisos.contains(FUNCION_TIPO_BOLETO_BLOQUEADO)) { - return true; - } - - return false; - } - - public void clearCombobox(Combobox combobox) { - - int size = combobox.getItemCount(); - - for (int i = size - 1; i >= 0; i--) { - combobox.removeItemAt(i); - } - } - - public void popularCombobox(Combobox cmbConta, Combobox cmbPessoa, Combobox cmbForm, Combobox cmbLote, Combobox cmbPosicao, Combobox cmbReceita, Combobox cmbEmpresas, Combobox cmbUsuarioEmpresa, Combobox cmbEmpresaCobranca, Combobox cmbCobrancasPuntoVenta, Combobox cmbTipoSocio) throws Exception { - - clearCombobox(cmbConta); - clearCombobox(cmbPessoa); - clearCombobox(cmbForm); - clearCombobox(cmbLote); - clearCombobox(cmbPosicao); - clearCombobox(cmbEmpresas); - clearCombobox(cmbUsuarioEmpresa); - clearCombobox(cmbEmpresaCobranca); - clearCombobox(cmbCobrancasPuntoVenta); - - for (CobrancaAdcPuntoVenta cb : lsTodasCobrancas) { - Comboitem comboItem = new Comboitem(cb.getDescricao()); - comboItem.setValue(cb); - comboItem.setParent(cmbCobrancasPuntoVenta); - } - - for (Empresa e : lsEmpresasCobrancaAdicional) { - Comboitem comboItem = new Comboitem(e.getNombempresa()); - comboItem.setValue(e); - comboItem.setParent(cmbEmpresaCobranca); - } - - for (Empresa e : lsEmpresasBloquear) { - Comboitem comboItem = new Comboitem(e.getNombempresa()); - comboItem.setValue(e); - comboItem.setParent(cmbEmpresas); - } - - for (PtovtaAgencia.enumTipoConta p : PtovtaAgencia.enumTipoConta.values()) { - Comboitem comboItem = new Comboitem(p.descricao()); - comboItem.setValue(p.valor()); - comboItem.setParent(cmbConta); - } - - for (PtovtaAgencia.enumTipoPessoa p : PtovtaAgencia.enumTipoPessoa.values()) { - Comboitem comboItem = new Comboitem(p.descricao()); - comboItem.setValue(p.valor()); - comboItem.setParent(cmbPessoa); - } - - for (PtovtaEstoque.gerarEnum p : PtovtaEstoque.gerarEnum.values()) { - Comboitem comboItem = new Comboitem(p.descricao()); - comboItem.setValue(p.valor()); - comboItem.setParent(cmbLote); - } - - for (PtovtaEstoque.gerarEnum p : PtovtaEstoque.gerarEnum.values()) { - Comboitem comboItem = new Comboitem(p.descricao()); - comboItem.setValue(p.valor()); - comboItem.setParent(cmbForm); - } - - for (PtovtaDiversos.gerarEnum p : PtovtaDiversos.gerarEnum.values()) { - Comboitem comboItem = new Comboitem(p.descricao()); - comboItem.setValue(p.valor()); - comboItem.setParent(cmbPosicao); - } - - for (PtovtaComissao.Receita p : PtovtaComissao.Receita.values()) { - Comboitem comboItem = new Comboitem(p.descricao()); - comboItem.setValue(p.valor()); - comboItem.setParent(cmbReceita); - } - - if (lsEmpresas != null && !lsEmpresas.isEmpty()) { - Empresa empresaTodos = new Empresa(); - lsEmpresas.add(empresaTodos); - for (Empresa e : lsEmpresas) { - Comboitem comboItem = new Comboitem(e.getNombempresa()); - comboItem.setValue(e); - comboItem.setParent(cmbUsuarioEmpresa); - } - } - - - for (TipoSocio tipoSocio : TipoSocio.values()) { - Comboitem comboItem = new Comboitem(tipoSocio.toString()); - comboItem.setValue(tipoSocio); - comboItem.setParent(cmbTipoSocio); - } - - - } - - public void onSelect$cmbBanco() { - InstiFinanceira banco = (InstiFinanceira) cmbBanco.getSelectedItem().getValue(); - txtNomeBanco.setValue(banco.getCodigo()); - } - - public void onSelect$cmbEmpresaPtoVta() { - Empresa empresa = (Empresa) cmbEmpresaPtoVta.getSelectedItem().getValue(); - lsEmpresaContaBancarias = ptovtaBancoService.buscarContasBancariasPorIdEmpresa(empresa.getEmpresaId()); - - empresaContaBancariaList.setData(new ArrayList(0)); - - if (lsEmpresaContaBancarias != null && !lsEmpresaContaBancarias.isEmpty()) { - empresaContaBancariaList.setData(lsEmpresaContaBancarias); -// cmbEmpresasContaBancarias.setModel(new BindingListModelList(lsEmpresaContaBancarias, true)); - } else { -// cmbEmpresasContaBancarias.setModel(new BindingListModelList(new ArrayList(), true)); -// cmbEmpresasContaBancarias.setSelectedItem(null); - } - } - - public void onClick$ckIsento(Event ev) { - if (ckIsento.isChecked()) { - puntoVenta.setNumIEPuntoVenta("ISENTO"); - txtNumIEPuntoVenta.setValue("ISENTO"); - txtNumIEPuntoVenta.setDisabled(true); - - } else { - puntoVenta.setNumIEPuntoVenta(""); - txtNumIEPuntoVenta.setValue(""); - txtNumIEPuntoVenta.setDisabled(false); - } - } - - public void onChange$cmbCiudad(Event ev) { - if (cmbCiudad.getSelectedItem() == null) { - return; - } else { - cmbColonia.setSelectedItem(null); - Ciudad c = (Ciudad) cmbCiudad.getSelectedItem().getValue(); - List lsCol = coloniaService.buscarPorCiudad(c); - BindingListModel dictModel = new BindingListModelList(lsCol, false); - cmbColonia.setModel(dictModel); - } - } - - public void onChange$cmbColonia(Event ev) { - if (cmbColonia.getSelectedItem() == null) { - return; - } else { - // Colonia col = (Colonia) cmbColonia.getSelectedItem().getValue(); - // txtCP.setValue(col.getCodpostal()); - } - } - - public String replaceTextbox(Textbox textbox) { - String getString = textbox.getValue(); - getString = getString.replace("(", ""); - getString = getString.replaceAll("_", ""); - getString = getString.replace(")", ""); - getString = getString.replace("-", ""); - - return getString; - } - - public void onClick$btnGeraTitulos(Event ev) throws InterruptedException { - Connection myConn = null; - GeradorTitulosIntegracion gerador; - try { - myConn = dataSource.getConnection(); - Date dateInicio = fecIntegracion.getValue(); - - dateInicio = DateUtil.inicioFecha(dateInicio); - Date dateFim = DateUtil.fimFecha(fecIntegracion.getValue()); - - log.info("puntoVentaId=" + puntoVenta.getPuntoventaId() + ";fecInicio=" + dateInicio + ";fecFin=" + dateFim); - - gerador = new GeradorTitulosIntegracion(myConn, puntoVenta.getPuntoventaId(), dateInicio, - dateFim, checkTodosPuntosVenta.isChecked()); - gerador.execute(); - - } catch (Exception e) { - log.error("Erro ao integrar", e); - - if (e instanceof WrongValueException) { - throw (WrongValueException) e; - } - - log.error("", e); - - Messagebox.show( - e.getMessage(), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - - }finally{ - if(myConn != null){ - try { - myConn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - } - } - - public void onClick$btnIntegracao(Event ev) throws InterruptedException { - - Connection myConn = null; - // GeradorTitulosIntegracion gerador; - try { - myConn = dataSource.getConnection(); - Date dateInicio = fecIntegracion.getValue(); - - dateInicio = DateUtil.inicioFecha(dateInicio); - Date dateFim = DateUtil.fimFecha(fecIntegracion.getValue()); - - log.info("puntoVentaId=" + puntoVenta.getPuntoventaId() + ";fecInicio=" + dateInicio + ";fecFin=" + dateFim); - - GerenciadorEnvioTitulosWS gerenciadorWS = new GerenciadorEnvioTitulosWS(myConn, checkDinheiro.isChecked(), - checkCredito.isChecked(), checkDebito.isChecked(), checkTF.isChecked(), checkBOL.isChecked(), - checkSimulaIntegracion.isChecked(), dateInicio, dateFim); - gerenciadorWS.execute(); - - } catch (Exception e) { - log.error("Erro ao integrar", e); - - if (e instanceof WrongValueException) { - throw (WrongValueException) e; - } - - log.error("", e); - - Messagebox.show( - e.getMessage(), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - - } finally { - // if (myConn != null) { - // try { - // myConn.close(); - // } catch (SQLException e) { - // log.error("Erro ao fechar a conexao", e); - // } - // } - } - } - - public void onClick$btnEnviaAG(Event ev) throws InterruptedException { - Connection myConn = null; - Observer wsevents = new Observer() { - - @Override - public void update(Observable o, Object arg) { - logResultAG.setText(((WSAGLog)o).toString()); - } - }; - - try { - - WSAGLog wslog = WSAGLog.getInstance(); - wslog.clear(); - wslog.addObserver(wsevents); - - myConn = dataSource.getConnection(); - Date dateInicio = fecInicioAG.getValue(); - - dateInicio = DateUtil.inicioFecha(dateInicio); - Date dateFim = DateUtil.fimFecha(fecFimAG.getValue()); - - GeradorTitulosAG gerador = new GeradorTitulosAG(myConn, dateInicio, dateFim); - log.info("puntoVentaId=" + puntoVenta.getPuntoventaId() + ";fecInicio=" + dateInicio + ";fecFin=" + dateFim); - - gerador.send(checkAdiantamentoAG.isChecked(), checkBoletoAG.isChecked(), checkCartaoAG.isChecked(), checkDepositoAG.isChecked(), false); - - gerador.mostraResultado(); - - } catch (Exception e) { - log.error("Erro ao integrar", e); - - if (e instanceof WrongValueException) { - throw (WrongValueException) e; - } - - log.error("", e); - - Messagebox.show( - e.getMessage(), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - - } finally { - try { - if (myConn != null && !myConn.isClosed()) { - myConn.close(); - } - } catch (SQLException e) { - log.error("error fechar conexão", e); - throw new RuntimeException(e); - } - } - } - - public void onClick$btnGeraTitulosAG(Event ev) throws InterruptedException { - Connection myConn = null; - try { - myConn = dataSource.getConnection(); - Date dateInicio = fecInicioAG.getValue(); - - dateInicio = DateUtil.inicioFecha(dateInicio); - Date dateFim = DateUtil.fimFecha(fecFimAG.getValue()); - - GeradorTitulosAG gerador = new GeradorTitulosAG(myConn, dateInicio, dateFim); - log.info("puntoVentaId=" + puntoVenta.getPuntoventaId() + ";fecInicio=" + dateInicio + ";fecFin=" + dateFim); - - if (checkTodosPuntosVenta.isChecked()){ - gerador.execute(checkAdiantamentoAG.isChecked(), checkBoletoAG.isChecked(), checkCartaoAG.isChecked(), checkDepositoAG.isChecked(), false); - } else { - if (puntoVenta.getLsPtovtaEmpresa() != null && !puntoVenta.getLsPtovtaEmpresa().isEmpty()){ - - for (PtovtaEmpresa pte : puntoVenta.getLsPtovtaEmpresa()){ - gerador.setEmpresaId(pte.getEmpresa().getEmpresaId()); - gerador.execute(puntoVenta.getPuntoventaId(), checkAdiantamentoAG.isChecked(), checkBoletoAG.isChecked(), checkCartaoAG.isChecked(), checkDepositoAG.isChecked(), false); - } - } else { - gerador.setEmpresaId(puntoVenta.getEmpresa().getEmpresaId()); - gerador.execute(puntoVenta.getPuntoventaId(), checkAdiantamentoAG.isChecked(), checkBoletoAG.isChecked(), checkCartaoAG.isChecked(), checkDepositoAG.isChecked(), false); - } - } - } catch (Exception e) { - log.error("Erro ao integrar", e); - - if (e instanceof WrongValueException) { - throw (WrongValueException) e; - } - - log.error("Erro ao integrar -> e.getMessage() quando vai mostrar o dialogo de erro na tela: " + e.getMessage()); - - Messagebox.show( - e.getMessage(), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - - } finally { - if (myConn != null) { - try { - myConn.close(); - } catch (SQLException e) { - log.error("Erro ao fechar a conexao", e); - } - } - } - } - - public void onClick$btnAdicionarEmpresaBloqueada(Event ev) { - Empresa e = (Empresa) cmbEmpresas.getSelectedItem().getValue(); - - puntoVenta.addEmpresaBloqueada(e); - - ptovtaEmpresasBloqueadasList.setData(puntoVenta.getPtovtaEmpresaBloqueadaList()); - - } - - public void onClick$btnApagarEmpresaBloqueada(Event ev) { - try { - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.borrarEmpresaBloqueadaPergunta"), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if (resp == Messagebox.YES) { - - PtovtaEmpresaBloqueada e = (PtovtaEmpresaBloqueada) ptovtaEmpresasBloqueadasList.getSelected(); - - ptovtaEmpresaBloqueadaService.borrar(e); - - puntoVenta.removeEmpresaBloqueada(e); - ptovtaEmpresasBloqueadasList.setData(puntoVenta.getPtovtaEmpresaBloqueadaList()); - } - } catch (Exception ex) { - log.error(ex.toString()); - } - } - - public void onClick$btnAdicionarPtoVtaCheckin(Event ev) { - - if (cmbPtoVtaCheckinParada.getSelectedItem() != null) { - - Parada parada = (Parada) cmbPtoVtaCheckinParada.getSelectedItem().getValue(); - - PtoVtaCheckin pto = new PtoVtaCheckin(); - pto.setParadaId(parada); - pto.setPuntoventaId(puntoVenta); - - puntoVenta.addPtovtaCheckin(pto); - - ptovtaPtoVtaCheckinList.setData(puntoVenta.getPtovtaCheckinList()); - } - - } - - public void onClick$btnApagarPtoVtaCheckin(Event ev) { - try { - if (ptovtaPtoVtaCheckinList.getSelected() != null) { - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.borrarPtoVtaCheckin"), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if (resp == Messagebox.YES) { - - PtoVtaCheckin pto = (PtoVtaCheckin) ptovtaPtoVtaCheckinList.getSelected(); - if (pto.getPtoVtaCheckinId() != null) { - ptoVtaCheckinService.borrar(pto); - } - puntoVenta.removePtovtaCheckin(pto); - ptovtaPtoVtaCheckinList.setData(puntoVenta.getPtovtaCheckinList()); - } - } - } catch (Exception ex) { - log.error(ex.toString()); - } - } - - public void onClick$btnAdicionarPtoVtaSeguro(Event ev) { - - if (cmbEmpresaSeguro.getSelectedItem() != null && - (radIndvendsegopcionalSi.isChecked() || radIndvendsegopcionalNo.isChecked() || - radIndestansegopcionalSi.isChecked() || radIndestansegopcionalNo.isChecked()) - && - (radIndvendsegtabelaSi.isChecked() || radIndvendsegtabelaNo.isChecked() || - radIndestansegtabelaSi.isChecked() || radIndestansegtabelaNo.isChecked()) - && - (radIndPermisoTasaEmbarqueSi.isChecked() || radIndPermisoTasaEmbarqueNo.isChecked() || - radIndEstanTasaEmbarqueSi.isChecked() || radIndEstanTasaEmbarqueNo.isChecked())) { - - Empresa empresa = (Empresa) cmbEmpresaSeguro.getSelectedItem().getValue(); - - for(PtoVtaSeguro p : puntoVenta.getPtovtaSeguroList()){ - if(p.getActivo() && p.getEmpresa().equals(empresa)){ - return; - } - } - - PtoVtaSeguro pto = new PtoVtaSeguro(); - - pto.setIndVendeSegOpcional(radIndvendsegopcionalSi.isChecked()); - pto.setIndVendeSegTabela(radIndvendsegtabelaSi.isChecked()); - pto.setIndEstanSegOpcional(radIndestansegopcionalSi.isChecked()); - pto.setIndEstanSegTabela(radIndestansegtabelaSi.isChecked()); - pto.setIndEstanTasaEmbarque(radIndEstanTasaEmbarqueSi.isChecked()); - pto.setIndPermisoTasaEmbarque(radIndPermisoTasaEmbarqueSi.isChecked()); - pto.setIndPermisoTasaEmbarqueVtaManual(radIndPermisoTasaEmbarqueVtaManualSi.isChecked()); - pto.setIndPermisoTasaEmbarqueVtaAgencia(radIndPermisoTasaEmbarqueVtaAgenciaSi.isChecked()); - - pto.setIndTaxaEmbarqueEmbarcada(radIndTaxaEmbarqueEmbarcadaSi.isChecked()); - pto.setIndVendeSeguroOpcEmbarcada(radIndVendeSeguroOpcEmbarcadaSi.isChecked()); - pto.setIndVendeSeguroTabelaEmbarcada(radIndVendeSeguroTabelaEmbarcadaSi.isChecked()); - - pto.setEmpresa(empresa); - pto.setPuntoventaId(puntoVenta); - - puntoVenta.addPtovtaSeguro(pto); - - ptovtaPtoVtaSeguroList.setData(puntoVenta.getPtovtaSeguroList()); - } - - } - - public void onClick$btnApagarPtoVtaSeguro(Event ev) { - try { - if (ptovtaPtoVtaSeguroList.getSelected() != null) { - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.borrarPtoVtaSeguro"), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if (resp == Messagebox.YES) { - - PtoVtaSeguro pto = (PtoVtaSeguro) ptovtaPtoVtaSeguroList.getSelected(); - if (pto.getPtoVtaSeguroId() != null) { - ptoVtaSeguroService.borrar(pto); - } - puntoVenta.removePtovtaSeguro(pto); - ptovtaPtoVtaSeguroList.setData(puntoVenta.getPtovtaSeguroList()); - } - } - } catch (Exception ex) { - log.error(ex.toString()); - } - } - - public void onClick$btnAdicionarPtovtaCatInd(Event ev) { - if (!lsCategoriaSel.isEmpty() && cmbUsuarioBloq.getSelectedItem() != null) { - - if(!checkPtovtaCatIndTotalBus.isChecked() && - !checkPtovtaCatIndEmbarcada.isChecked()){ - try { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.msg.informartipobloqueio.value"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - } catch (InterruptedException e) { - log.error(e); - } - - return; - } - - for (Object item : lsCategoriaSel) { - Categoria categoria = (Categoria) item; - - PtovtaCatInd pto = new PtovtaCatInd(); - pto.setCategoria(categoria); - pto.setPuntoVenta(puntoVenta); - pto.setUsuarioBloqueado((Usuario) cmbUsuarioBloq.getSelectedItem().getValue()); - pto.setEmpresa((Empresa) cmbUsuarioEmpresa.getSelectedItem().getValue()); - pto.setIndEmbarcada(checkPtovtaCatIndEmbarcada.isChecked()); - pto.setIndTotalBus(checkPtovtaCatIndTotalBus.isChecked()); - - - if(existePtoVtaCat(pto)){ - continue; - } - - puntoVenta.addPtovtaCatInd(pto); - ptovtaCatIndListTemp.add(pto); - - - ptovtaCatIndList.setData(puntoVenta.getPtovtaCatIndList()); - } - } - } - - private boolean existePtoVtaCat(PtovtaCatInd ptoVtaCat) { - - for (PtovtaCatInd p : puntoVenta.getPtovtaCatIndList()) { - if (p.getActivo() - && p.getCategoria().equals(ptoVtaCat.getCategoria()) - && p.getEmpresa().equals(ptoVtaCat.getEmpresa()) - && existeConflitoUsuario(p.getUsuarioBloqueado(), ptoVtaCat.getUsuarioBloqueado())) { - return true; - } - } - - return false; - } - - private boolean existeConflitoUsuario(Usuario usuarioNovo, Usuario usuarioAntigo) { - - return usuarioNovo.equals(usuarioAntigo) || - (usuarioNovo.getUsuarioId().equals(-1) || usuarioAntigo.getUsuarioId().equals(-1)); - - } - - public void onClick$btnApagarPtovtaCatInd(Event ev) { - try { - if (ptovtaCatIndList.getSelected() != null) { - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.borrarPtoVtaCheckin"), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if (resp == Messagebox.YES) { - - PtovtaCatInd pto = (PtovtaCatInd) ptovtaCatIndList.getSelected(); - if (pto.getPtovtaCategoriaId() != null) { - ptovtaCatIndService.borrar(pto); - ptovtaCatIndListTemp.remove(pto); - } - puntoVenta.removePtovtaCatInd(pto); - ptovtaCatIndList.setData(puntoVenta.getPtovtaCatIndList()); - } - } - } catch (Exception ex) { - log.error(ex.toString()); - } - } - - @SuppressWarnings("unchecked") - public void onClick$btnSalvar(Event ev) throws InterruptedException { - txtMaxCancelacion.getValue(); - txtNome.getValue(); - txtNumPtoVta.getValue(); - txtNumFax.getValue(); - txtCompl.getValue(); - txtNumAg.getValue(); - txtConta.getValue(); - txtCarga.getValue(); - txtAntecipRetem.getValue(); - txtAntecipPercentual.getValue(); - numtelefonodos.getValue(); - numtelefonouno.getValue(); - if (indMotivoBloqueio) { - if (puntoVenta.getPuntoventaId() != null) { - String statusAprobacionAtual = radAprobacionAutorizado.isChecked() ? "A" : "L"; - if (!statusAprobacionAtual.equals(statusAprobacionInicial)) { - motivoBloqueio.setConstraint("no empty"); - motivoBloqueio.getValue(); - } - } else { - motivoBloqueio.setConstraint("no empty"); - motivoBloqueio.getValue(); - } - } - - getTxtTaxaConvenienciaPorc().getValue(); - if (getTxtTaxaConvenienciaPorc().getValue() != null && - getTxtTaxaConvenienciaPorc().getValue().compareTo(BigDecimal.ZERO) == 1) { - txtMaximoTaxaConveniencia.setConstraint("no empty"); - txtMaximoTaxaConveniencia.getValue(); - } - - cmbEmpresa.getValue(); - cmbParada.getValue(); - cmbPtoVtaCheckinParada.getValue(); - cmbTipoPontoVenta.getValue(); - cmbMoneda.getValue(); - /* cmbNodo.getValue(); */ - cmbColonia.setConstraint("no empty"); - cmbColonia.getValue(); - cmbCiudad.getValue(); - cmbBanco.getValue(); - cmbPessoa.getValue(); - cmbTipoConta.getValue(); - cmbParada.setConstraint("no empty"); - cmbParada.getValue(); - - puntoVenta.setIndBloqueiaTipoPassagem(radIndBloquear.isSelected()); - - if(!validarEmail()){ - - if(descCorreo.getText() == null || descCorreo.getText().trim().isEmpty()){ - Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.emailObrigatorio"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - }else{ - Messagebox.show(Labels.getLabel("editarTipoPuntoVentaController.MSG.emailInvalido"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - } - - descCorreo.focus(); - return; - } - - if (!txtTitularNome.getValue().isEmpty() - || !txtTitularRg.getValue().isEmpty() - || !txtTitularEmissor.getValue().isEmpty() - || img.getContent() != null) { - txtTitularCpf.setConstraint(new ConstraintNoEmpty()); - txtTitularCpf.getValue(); - - puntoVenta.getTitularId().setActivo(Boolean.TRUE); - puntoVenta.getTitularId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - puntoVenta.getTitularId().setFecmodif(Calendar.getInstance().getTime()); - } else { - puntoVenta.setTitularId(null); - } - - validarDiversos(); - - String numagencia = txtNumAg.getValue() + (StringUtils.isBlank(txtDigitoAg.getValue()) ? "" : "-" + txtDigitoAg.getValue()); - - if (puntoVenta.getAgenciaId() != null) { - puntoVenta.getAgenciaId().setNumagencia(numagencia); - puntoVenta.getAgenciaId().setBilhetes(txtBilhetes.getValue()); - puntoVenta.getAgenciaId().setCarga(txtCarga.getValue()); - puntoVenta.getAgenciaId().setDigito(txtDigito.getValue()); - puntoVenta.getAgenciaId().setNumconta(txtConta.getValue()); - } - - if (puntoVenta.getPuntoVentaPadre() == null && !cmbPuntoVentaPadre.getValue().isEmpty()) { - cmbPuntoVentaPadre.getValue(true); - } - - // checar uma forma onde o proprio componente coloque como null o atributo - if (cmbPuntoVentaPadre.getValue().isEmpty()) { - puntoVenta.setPuntoVentaPadre(null); - } - - List lsPuntoVenta = puntoVentaService.buscaPuntoVenta(txtNumPtoVta.getValue()); - - if (!lsPuntoVenta.isEmpty()) { - boolean exists = CollectionUtils.exists(lsPuntoVenta, new Predicate() { - - @Override - public boolean evaluate(Object object) { - return ((PuntoVenta) object).getPuntoventaId().equals(puntoVenta.getPuntoventaId()); - } - }); - - if (!exists) { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.registroNumPtoVtaExiste"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - - return; - } - } - - if (ckValidarTempoParaImpressao.isChecked() && txtTempoParaImpressao.getValue() == null) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.informarTempoMinimo.value"), Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - txtTempoParaImpressao.focus(); - - return; - } - - try { - if (puntoVenta.getEmpresa() == null) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.empresa"), Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - - } else if (puntoVenta.getTipoPuntoVenta() == null) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.punto"), Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - - } else if (puntoVenta.getMoneda() == null) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.moneda"), Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - - /* - * } else if (puntoVenta.getNodo() == null) { Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.nodo"), Labels.getLabel(TITULO), Messagebox.OK, Messagebox.EXCLAMATION); - */ - } else if ((lsFormaPagoDet == null) || (lsFormaPagoDet.isEmpty())) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.formaDePago"), Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - - } else { - if (cmbConexion.getValue().equals("")) { - puntoVenta.setConexionBancaria(null); - puntoVenta.setUsuarioBancario(null); - - } - - if (cmbUsuarioBancario.getValue() == null) { - puntoVenta.setUsuarioBancario(null); - } - - if (cmbColonia.getSelectedItem() != null) { - puntoVenta.setColonia((Colonia) cmbColonia.getSelectedItem().getValue()); - } - - if ((puntoVenta.getComissaoId() != null) && (puntoVenta.getComissaoId().getPtovtaComissaoId() == null)) { - puntoVenta.setComissaoId(null); - } - - // Empresas para Venda - List contasBancariasExcluidas = new ArrayList(0); - - for (PtovtaEmpresa emp : lsPtovtaEmpresa) { - if (emp.getActivo()) { - // Contas bancarias (Temporaria) - for (EmpresaContaBancaria ecc : emp.getContasBancaria()) { - if (ecc.getEmpresaContaBancariaId() == null) { - continue; - } - - // Verificando os bancos adicionados/atualizados - boolean existe = false; - - for (PtovtaEmpresaContaBancaria pto : emp.getLsPtovtaEmpresaContaBancaria()) { - if (pto.getEmpresaContaBancaria() != null && pto.getEmpresaContaBancaria().getEmpresaContaBancariaId().equals(ecc.getEmpresaContaBancariaId())) { - existe = true; - break; - } - } - - if (!existe) { - PtovtaEmpresaContaBancaria pto = new PtovtaEmpresaContaBancaria(); - pto.setPtovtaEmpresa(emp); - pto.setEmpresaContaBancaria(ecc); - pto.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - pto.setFecmodif(new Date()); - pto.setActivo(true); - - emp.getLsPtovtaEmpresaContaBancaria().add(pto); - } - } - - // Contas bancarias removidas - List excluir = new ArrayList(0); - - for (PtovtaEmpresaContaBancaria pto : emp.getLsPtovtaEmpresaContaBancaria()) { - boolean existe = false; - - for (EmpresaContaBancaria ecc : emp.getContasBancaria()) { - if (pto.getEmpresaContaBancaria().getEmpresaContaBancariaId().equals(ecc.getEmpresaContaBancariaId())) { - existe = true; - break; - } - } - - if (!existe) { - excluir.add(pto); - } - } - - emp.getLsPtovtaEmpresaContaBancaria().removeAll(excluir); - - contasBancariasExcluidas.addAll(excluir); - } - } - - puntoVenta.setActivo(Boolean.TRUE); - puntoVenta.setFecmodif(Calendar.getInstance().getTime()); - puntoVenta.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - - if(!isPermissaoMotivoFormaPago || puntoVenta.getPuntoventaId()==null) { - puntoVenta.setLsFormaPagoDet(lsFormaPagoDet); - }else { - puntoVenta.setLsFormaPagoDet(formaPagoList.getListData()); - } - - puntoVenta.setLsParamRecoleccion(lsParamRecoleccion); - puntoVenta.setLsPtovtaEmpresa(lsPtovtaEmpresa); - puntoVenta.setLsPtovtaUsuarioBancario(lsPtovtaUsuarioBancario); - puntoVenta.setPtovtaAntecipacomissaoList(lsAntecipacomissao); - puntoVenta.setPtovtaHorarioList(lsHorario); - puntoVenta.setPtovtaEstoqueList(lsEstoque); - puntoVenta.setValidaTempoParaImpressao(ckValidarTempoParaImpressao.isChecked()); - puntoVenta.setTempoMinimoParaImpressao(txtTempoParaImpressao.getValue()); - puntoVenta.setNodo(nodoService.obtenerId(1)); - puntoVenta.setDateAbertura(dateAbertura.getValue()); - puntoVenta.setPtovtaCatIndList(ptovtaCatIndListTemp); - - if (dateFechamento.getValue() != null && dateAbertura.getValue() != null && dateFechamento.getValue().compareTo(dateAbertura.getValue()) < 0) { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.DatFechMenorDataAbertura"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - return; - } - - puntoVenta.setDateFechamento(dateFechamento.getValue()); - - String getString = null; - - puntoVenta.setNumfax(null); - if (!txtNumFax.getValue().equals("")) { - getString = this.replaceTextbox(txtNumFax); - if (getString.indexOf("_") > -1) { - puntoVenta.setNumfax(txtNumFax.getValue().replace("_", "")); - }else - puntoVenta.setNumfax(txtNumFax.getValue()); - } - - puntoVenta.setNumtelefonouno(""); - if (!numtelefonouno.getValue().equals("")) { - getString = this.replaceTextbox(numtelefonouno); - if (getString.indexOf("_") > -1) { - puntoVenta.setNumtelefonouno(numtelefonouno.getValue().replace("_", "")); - }else - puntoVenta.setNumtelefonouno(numtelefonouno.getValue()); - } - - puntoVenta.setNumtelefonodos(""); - if (!numtelefonodos.getValue().equals("")) { - getString = this.replaceTextbox(numtelefonodos); - if (getString.indexOf("_") > -1) { - puntoVenta.setNumtelefonodos(numtelefonodos.getValue().replace("_", "")); - }else - puntoVenta.setNumtelefonodos(numtelefonodos.getValue()); - } - - if (cmbBanco.getSelectedItem() == null) { - puntoVenta.setAgenciaId(null); - } else { - if (puntoVenta.getAgenciaId() == null) { - puntoVenta.setAgenciaId(new PtovtaAgencia()); - } - puntoVenta.getAgenciaId().setInstiFinanceiraId((InstiFinanceira) cmbBanco.getSelectedItem().getValue()); - if (cmbPessoa.getSelectedItem() != null) { - puntoVenta.getAgenciaId().setPessoa((String) cmbPessoa.getSelectedItem().getValue()); - } - - if (cmbTipoConta.getSelectedItem() != null) { - puntoVenta.getAgenciaId().setTipo((String) cmbTipoConta.getSelectedItem().getValue()); - } - puntoVenta.getAgenciaId().setActivo(Boolean.TRUE); - puntoVenta.getAgenciaId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - puntoVenta.getAgenciaId().setFecmodif(Calendar.getInstance().getTime()); - } - - List lsPto = new ArrayList(); - for (PtovtaEmpresa pto : lsPtovtaEmpresa) { - if (!pto.getActivo()) { - for (PtovtaEmpresaContaBancaria ecc : pto.getLsPtovtaEmpresaContaBancaria()) { - ptovtaEmpresaContaBancariaService.borrarFisico(ecc); - } - - ptovtaEmpresaService.borrarFisico(pto); - } else { - pto.setPuntoVenta(puntoVenta); - lsPto.add(pto); - } - } - puntoVenta.setLsPtovtaEmpresa(lsPto); - - for (PtovtaEmpresaContaBancaria ecc : contasBancariasExcluidas) { - ptovtaEmpresaContaBancariaService.borrarFisico(ecc); - } - - List lsPto2 = new ArrayList(); - for (PtoVtaUsuarioBancario pto2 : lsPtovtaUsuarioBancario) { - if (!pto2.getActivo()) { - ptoVtaUsuarioBancarioService.borrarFisico(pto2); - } else { - pto2.setPuntoVenta(puntoVenta); - lsPto2.add(pto2); - } - } - - if (ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.VALIDA_CONTA_CORRENTE_EMPESA_PTOVTA.getDescricao(), "1")) { - if (!validaCadastroFechamentoContaCorrente()) { - exibeMsgErroFechCtaCorrente(); - return; - } - } - puntoVenta.setLsPtovtaUsuarioBancario(lsPto2); - - if (radAprobacionAutorizado.isChecked()) { - puntoVenta.setStatusaprobacion("A"); - puntoVenta.setDateFechamento(null); - } else if (radAprobacionLatente.isChecked()) { - puntoVenta.setStatusaprobacion("L"); - } - - if (indMotivoBloqueio) { - if (puntoVenta.getPuntoventaId() != null) { - if (!puntoVenta.getStatusaprobacion().equals(statusAprobacionInicial)) { - puntoVenta.setMotivoBloqueio(motivoBloqueio.getValue()); - } - } else { - puntoVenta.setMotivoBloqueio(motivoBloqueio.getValue()); - } - } - - if(!puntoVenta.getStatusaprobacion().equals(statusAprobacionInicial)){ - HistoricoPuntoVenta h = new HistoricoPuntoVenta(); - h.setPuntoVenta(puntoVenta); - - h.setIndBloqueio(!puntoVenta.getStatusaprobacion().equals("A")); - h.setMotivoBloqueio(motivoBloqueio.getValue()); - h.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - h.setActivo(true); - h.setFecmodif(new Date()); - h.setFecBloqueio(new Date()); - - puntoVenta.getHistoricoPuntoVentaList().add(h); - } - - if (puntoVenta.getIndIntegracion() == null) { - puntoVenta.setIndIntegracion(TipoRetorno.PENDENTE.getValor()); - } - if(cmbTipoSocio.getSelectedItem() != null ) { - puntoVenta.setTipoSocio(((TipoSocio) cmbTipoSocio.getSelectedItem().getValue())); - } - - if (puntoVenta.getPuntoventaId() == null) { - puntoVenta = puntoVentaService.suscribir(puntoVenta); - puntoVentaList.addItemNovo(puntoVenta); - } else { - puntoVentaService.actualizacion(puntoVenta); - puntoVentaList.updateItem(puntoVenta); - } - - gravaFechamentoCtaCorrente(); - - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.suscribirOK"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.INFORMATION); - - closeWindow(); - - } - - } catch (ValidacionCampoException ve) { - log.error("editarPuntoVentaController: ", ve); - Messagebox.show( - ve.getMessage(), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - - } catch (IntegracionException ex) { - gravaFechamentoCtaCorrente(); - puntoVentaList.updateItem(puntoVenta); - - log.error("editarPuntoVentaController: ", ex); - - Messagebox.show( - ex.getMessage(), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - - closeWindow(); - - } catch (Exception ex) { - log.error("editarPuntoVentaController: ", ex); - - Messagebox.show( - Labels.getLabel("MSG.Error"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } - - //Aba Excecao Multa Cancelamento - cmbOrgaoConcedente.setModel(new ListModelList(lsOrgaoConcedentes)); - cmbOrgaoConcedente.setSelectedItem(null); - - } - - - private boolean validarEmail() throws InterruptedException { - - descCorreo.getValue(); - - Constante constante = constanteService.buscarPorNomeConstante("TOTALBUS_EMAIL_OPCIONAL_PV"); - - if(constante == null || constante.getValorconstante().equals("0")){ - if(descCorreo.getText() == null || descCorreo.getText().isEmpty()){ - return false; - } - }else{ - if(descCorreo.getText() == null || descCorreo.getText().isEmpty()){ - return true; - } - } - - for(String email : descCorreo.getText().split(";")){ - Matcher matcher = pattern.matcher(email); - if(!matcher.matches()){ - return false; - } - } - - return true; - } - - private void gravaFechamentoCtaCorrente() { - List paramsFechamento = fechamentoParamptovtaService.buscaParametrosPorPuntoventa(puntoVenta); - gravarCC(paramsFechamento); - removerCC(paramsFechamento); - } - - private void gravarCC(List paramsFechamento) { - boolean encontrouEmpresaComFechamentoConfigurado = false; - for (Object object : fechamentoParamptovtaList.getListData()) { - encontrouEmpresaComFechamentoConfigurado = false; - FechamentoParamptovta fechamentoParamptovta = (FechamentoParamptovta) object; - //verifica se empresa ja esta configurada com fechamento de conta corrente - for(FechamentoParamptovta paramFechamento : paramsFechamento){ - if(fechamentoParamptovta.getEmpresa().getEmpresaId() == paramFechamento.getEmpresa().getEmpresaId()){ - encontrouEmpresaComFechamentoConfigurado = true; - paramFechamento.setDiasemtransito(fechamentoParamptovta.getDiasemtransito()); - paramFechamento.setIntervalofechamento(fechamentoParamptovta.getIntervalofechamento()); - paramFechamento.setTipopagamento(fechamentoParamptovta.getTipopagamento()); - fechamentoParamptovtaService.actualizacion(paramFechamento); - break; - } - } - //Caso nao esteja configurada insere no banco - if(!encontrouEmpresaComFechamentoConfigurado){ - fechamentoParamptovta.setPuntoventa(puntoVenta); - fechamentoParamptovtaService.suscribir(fechamentoParamptovta); - } - } - } - - private void removerCC(List paramsFechamento) { - boolean removerEmpresa = true; - for(FechamentoParamptovta paramFechamento : paramsFechamento){ - removerEmpresa = true; - //Procura por empresas que estao no banco mas nao estao na lista - for (Object object : fechamentoParamptovtaList.getListData()) { - FechamentoParamptovta fechamentoParamptovta = (FechamentoParamptovta) object; - if(paramFechamento.getEmpresa().getEmpresaId() == fechamentoParamptovta.getEmpresa().getEmpresaId()){ - removerEmpresa = false; - break; - } - } - //Remove do banco a empresa que nao estao na lista - if(removerEmpresa){ - fechamentoParamptovtaService.borrar(paramFechamento); - } - } - } - - private void exibeMsgErroFechCtaCorrente() throws InterruptedException { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.ParamPtoVtaObrigatorio"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - } - - private boolean validaCadastroFechamentoContaCorrente() { - List empresasVenda = Arrays.asList(ptovtaEmpresaList.getData()); - List empresasFechamento = Arrays.asList(fechamentoParamptovtaList.getData()); - boolean validado = false; - try { - //Valida que todas empresas de Fechamento sao empresa para venda. - for (int i = 0; i < empresasVenda.size(); i++) { - PtovtaEmpresa empresaVenda = (PtovtaEmpresa) empresasVenda.get(i); - - validado = false; - - for (int j = 0; j < empresasFechamento.size(); j++) { - FechamentoParamptovta fechamentoParamptovta = (FechamentoParamptovta) empresasFechamento.get(j); - - if (empresaVenda.getEmpresa().getEmpresaId().equals(fechamentoParamptovta.getEmpresa().getEmpresaId())) { - validado=true; - break; - } - } - if (!validado) { - return false; - } - } - } catch (Throwable e) { - log.error("",e); - return false; - } - return true; - } - - private void validarDiversos() { - if (puntoVenta.getDiversosId() != null) - { - if(!txtResponEnergia.getValue().isEmpty() - || checkInformatizada.isChecked() - || checkBilheteInfo.isChecked() - || checkVendaInternet.isChecked() - || checkTeleEntrega.isChecked() - || checkDigitacao.isChecked() - || checkBilhete.isChecked() - || checkOfpsPropria.isChecked() - || checkOfpsTerceiros.isChecked()) { - - txtResponAluguel.setConstraint("no empty"); - txtResponAluguel.getValue(); - txtResponTel.setConstraint("no empty"); - txtResponTel.getValue(); - - puntoVenta.getDiversosId().setActivo(Boolean.TRUE); - puntoVenta.getDiversosId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - puntoVenta.getDiversosId().setFecmodif(Calendar.getInstance().getTime()); - } - - } else { - puntoVenta.setDiversosId(null); - } - } - - public void onClick$btnApagar(Event ev) { - try { - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.borrarPergunta"), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if (resp == Messagebox.YES) { - - puntoVentaService.borrar(puntoVenta); - - log.warn("Usuário " + UsuarioLogado.getUsuarioLogado().getNombusuario() + " excluiu o ponto de venda " + puntoVenta.getPuntoventaId()); - - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.borrarOK"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.INFORMATION); - - puntoVentaList.removeItem(puntoVenta); - - closeWindow(); - } - } catch (BusinessException ex) { - try { - Messagebox.show(ex.getMessage(), - Labels.getLabel(TITULO), Messagebox.OK, Messagebox.ERROR); - } catch (InterruptedException e) { - log.error(e); - } - } catch (Exception ex) { - log.error(ex); - } - } - - public void uploadPhoto(UploadEvent event) { - org.zkoss.util.media.Media media = event.getMedia(); - - try { - if (media instanceof org.zkoss.image.Image) { - img.setContent(new org.zkoss.image.AImage(media.getName(), - media.getStreamData())); - } else { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.errorIMG") + " " + media, - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } - } catch (IOException ex) { - log.error(ex); - throw UiException.Aide.wrap(ex); - } catch (InterruptedException ex) { - log.error(ex); - throw UiException.Aide.wrap(ex); - } - } - - public void onClick$btnSalvarAntecipa() throws InterruptedException { - dateAntecipData.getValue(); - txtAntecipRetem.getValue(); - txtAntecipPercentual.getValue(); - - try { - PtovtaAntecipacomissao antecipa = new PtovtaAntecipacomissao(); - - antecipa.setData(dateAntecipData.getValue()); - antecipa.setPercentual(txtAntecipPercentual.getValueDecimal()); - antecipa.setRetem(txtAntecipRetem.getValueDecimal()); - antecipa.setPuntoventaId(puntoVenta); - - antecipa.setActivo(Boolean.TRUE); - antecipa.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - antecipa.setFecmodif(Calendar.getInstance().getTime()); - - lsAntecipacomissao.add(antecipa); - ptovtaAntecipaList.setData(lsAntecipacomissao); - - } catch (Exception ex) { - log.error(ex); - Messagebox.show( - Labels.getLabel("MSG.Error"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } - } - - public void onClick$btnApagarAntecipa() { - try { - PtovtaAntecipacomissao antecipa = (PtovtaAntecipacomissao) ptovtaAntecipaList.getSelected(); - if (antecipa != null) { - antecipa.setActivo(Boolean.FALSE); - antecipa.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - antecipa.setFecmodif(Calendar.getInstance().getTime()); - - ptovtaAntecipaList.removeItem(antecipa); - lsAntecipacomissao.remove(antecipa); - } - } catch (Exception ex) { - log.error(ex); - } - } - - public void onClick$btnSalvarHorario() throws InterruptedException { - timeboxInicio.getValue(); - timeboxFim.getValue(); - try { - PtovtaHorario horario = new PtovtaHorario(); - - horario.setInddomingo(checkDom.isChecked()); - horario.setIndjueves(checkJue.isChecked()); - horario.setIndlunes(checkLun.isChecked()); - horario.setIndmartes(checkMar.isChecked()); - horario.setIndmiercoles(checkMie.isChecked()); - horario.setIndsabado(checkSab.isChecked()); - horario.setIndviernes(checkVie.isChecked()); - - horario.setInicio(timeboxInicio.getValue()); - horario.setFim(timeboxFim.getValue()); - horario.setPuntoventaId(puntoVenta); - horario.setActivo(Boolean.TRUE); - horario.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - horario.setFecmodif(Calendar.getInstance().getTime()); - - lsHorario.add(horario); - ptovtaHorarioList.addItemNovo(horario); - - } catch (Exception ex) { - log.error(ex); - Messagebox.show( - Labels.getLabel("MSG.Error"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } - } - - public void onClick$btnApagarHorario() { - try { - PtovtaHorario horario = (PtovtaHorario) ptovtaHorarioList.getSelected(); - if (horario != null) { - horario.setActivo(Boolean.FALSE); - horario.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - horario.setFecmodif(Calendar.getInstance().getTime()); - ptovtaHorarioList.removeItem(horario); - if (horario.getPtovtaHorarioId() == null) { - lsHorario.remove(horario); - } - } - } catch (Exception ex) { - log.error(ex); - } - } - - public void onClick$btnSalvarEstoque() throws InterruptedException { - txtEspecie.getValue(); - cmbForm.getValue(); - txtQuant.getValue(); - cmbLote.getValue(); - try { - PtovtaEstoque estoque = new PtovtaEstoque(); - - estoque.setEspecie(txtEspecie.getValue()); - if (cmbForm.getSelectedItem() != null) { - estoque.setFormCont(Integer.valueOf((String) cmbForm.getSelectedItem().getValue())); - } - if (cmbLote.getSelectedItem() != null) { - estoque.setLoteform(Integer.valueOf((String) cmbLote.getSelectedItem().getValue())); - } - - estoque.setQuantidade(txtQuant.getValue()); - estoque.setPuntoventaId(puntoVenta); - - estoque.setActivo(Boolean.TRUE); - estoque.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - estoque.setFecmodif(Calendar.getInstance().getTime()); - - lsEstoque.add(estoque); - ptovtaEstoqueList.setData(lsEstoque); - - } catch (Exception ex) { - log.error(ex); - Messagebox.show( - Labels.getLabel("MSG.Error"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } - } - - public void onClick$btnApagarEstoque() { - try { - PtovtaEstoque estoque = (PtovtaEstoque) ptovtaEstoqueList.getSelected(); - if (estoque != null) { - estoque.setActivo(Boolean.FALSE); - estoque.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - estoque.setFecmodif(Calendar.getInstance().getTime()); - - ptovtaEstoqueList.removeItem(estoque); - lsEstoque.remove(estoque); - } - } catch (Exception ex) { - log.error(ex); - } - } - - public void onClick$btnSalvarFormaPago(Event ev) throws InterruptedException { - - cmbFormaPago.getValue(); - cmbEmpresaFormaPago.getValue(); - - isPermissaoMotivoFormaPago = isPermiteInserirMotivoFormaPago(); - - try { - FormaPago formaPago = new FormaPago(); - try { - formaPago = (FormaPago) cmbFormaPago.getSelectedItem().getValue(); - Boolean achou = Boolean.FALSE; - Empresa empresa = (Empresa) cmbEmpresaFormaPago.getSelectedItem().getValue(); - if (formaPago != null) { - for (FormaPagoDet fpd : lsFormaPagoDet) { - if (fpd.getFormaPago().equals(formaPago) && empresa.equals(fpd.getEmpresa())) { - achou = Boolean.TRUE; - } - } - if (!achou) { - FormaPagoDet fpd = new FormaPagoDet(); - /* - * Mantis #6874 fpd.setCargosextras(new BigDecimal(txtCargosExtras.getValue())); - */ - fpd.setCargosextras(BigDecimal.ZERO); - fpd.setFormaPago(formaPago); - fpd.setPuntoVenta(puntoVenta); - fpd.setIndTotalBus(checkPtoVtaEmpresaIndTotalBus.isChecked()); - fpd.setIndEmbarcada(checkPtoVtaEmpresaIndEmbarcada.isChecked()); - - if (cmbEmpresaFormaPago.getSelectedItem() != null) { - fpd.setEmpresa(empresa); - } - - fpd.setActivo(Boolean.TRUE); - fpd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - fpd.setFecmodif(Calendar.getInstance().getTime()); - if(isEdicaoDoPuntoVentaEisPermissaoMotivoFormaPago()) { - abrirMotivoFormaPagamento(fpd, Boolean.TRUE, ((Empresa) cmbEmpresaFormaPago.getSelectedItem().getValue()).getEmpresaId()) ; - }else { - lsFormaPagoDet.add(fpd); - formaPagoList.setData(lsFormaPagoDet); - } - - } else { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.Achou.FormaPago"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - } - } - } catch (Exception e) { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.formaDePago"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - } - } catch (Exception ex) { - log.error(ex); - Messagebox.show( - Labels.getLabel("MSG.Error"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } - - - } - - public void onClick$btnApagarFormaPago(Event ev) { - try { - - isPermissaoMotivoFormaPago = isPermiteInserirMotivoFormaPago(); - - FormaPagoDet fpd = (FormaPagoDet) formaPagoList.getSelected(); - if (fpd != null) { - fpd.setActivo(Boolean.FALSE); - fpd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - fpd.setFecmodif(Calendar.getInstance().getTime()); - if(isEdicaoDoPuntoVentaEisPermissaoMotivoFormaPago()) { - abrirMotivoFormaPagamento(fpd, Boolean.FALSE, null) ; - }else { - formaPagoList.removeItem(fpd); - lsFormaPagoDet.remove(fpd); - } - - } - } catch (Exception ex) { - log.error(ex); - } - } - - public void onClick$btnSalvarParamRecoleccion(Event ev) throws InterruptedException { - importeInicial.getValue(); - importeAdicional.getValue(); - try { - ParamRecoleccion paramRecoleccion = new ParamRecoleccion(); - paramRecoleccion.setImporteinicial(importeInicial.getValueDecimal()); - paramRecoleccion.setImporteadicional(importeAdicional.getValueDecimal()); - - Boolean achou = Boolean.FALSE; - - for (ParamRecoleccion fpd : lsParamRecoleccion) { - if (fpd.getImporteinicial().equals(paramRecoleccion.getImporteinicial())) { - achou = Boolean.TRUE; - } - } - if (!achou) { - - paramRecoleccion.setPuntoVenta(puntoVenta); - paramRecoleccion.setActivo(Boolean.TRUE); - paramRecoleccion.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - paramRecoleccion.setFecmodif(Calendar.getInstance().getTime()); - - lsParamRecoleccion.add(paramRecoleccion); - paramRecoleccionList.setData(lsParamRecoleccion); - } else { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.Achou.ParamRecoleccion"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - } - - } catch (Exception ex) { - log.error(ex); - Messagebox.show( - Labels.getLabel("MSG.Error"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } - } - - public void onClick$btnApagarParamRecoleccion(Event ev) { - try { - ParamRecoleccion fpd = (ParamRecoleccion) paramRecoleccionList.getSelected(); - if (fpd != null) { - fpd.setActivo(Boolean.FALSE); - fpd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - fpd.setFecmodif(Calendar.getInstance().getTime()); - - paramRecoleccionList.removeItem(fpd); - lsParamRecoleccion.remove(fpd); - } - } catch (Exception ex) { - log.error(ex); - } - } - - public void onClick$btnSalvarPtovtaEmpresa(Event ev) throws InterruptedException { - cmbEmpresaPtoVta.getValue(); - try { - PtovtaEmpresa ptovtaEmpresa = null; - if(this.ptovtaEmpresa != null) { - ptovtaEmpresa = new PtovtaEmpresa(this.ptovtaEmpresa.getPtovtaempresaId()); - ptovtaEmpresa.setLsPtovtaEmpresaContaBancaria(this.ptovtaEmpresa.getLsPtovtaEmpresaContaBancaria()); - } else { - ptovtaEmpresa = new PtovtaEmpresa(); - } - - Boolean achou = Boolean.FALSE; - - ptovtaEmpresa.setEmpresa((Empresa) cmbEmpresaPtoVta.getSelectedItem().getValue()); - - for (PtovtaEmpresa fpd : lsPtovtaEmpresa) { - if ((ptovtaEmpresa.getPtovtaempresaId() == null || !ptovtaEmpresa.getPtovtaempresaId().equals(fpd.getPtovtaempresaId())) && - fpd.getEmpresa().equals(ptovtaEmpresa.getEmpresa()) && fpd.getActivo()) { - achou = Boolean.TRUE; - } - } - if (!achou) { - ptovtaEmpresa.setPuntoVenta(puntoVenta); - ptovtaEmpresa.setActivo(Boolean.TRUE); - ptovtaEmpresa.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - ptovtaEmpresa.setFecmodif(Calendar.getInstance().getTime()); - ptovtaEmpresa.setIndTerceirizada(checkPtoVtaEmpresaIndTerceirizada.isChecked()); - ptovtaEmpresa.setIndBloqueada(checkPtoVtaEmpresaIndBloqueada.isChecked()); - ptovtaEmpresa.setIndMostrarCaja(checkPtoVtaEmpresaIndMostrarCaja.isChecked()); - ptovtaEmpresa.setIndImpCompCartao(checkPtoVtaEmpresaIndImpCompCartao.isChecked()); - ptovtaEmpresa.setNumeroSitef(txtNumeroSitef.getText()); - ptovtaEmpresa.setMerchantStoreAdyen(txtMerchantStoreAdyen.getText()); - -// if (cmbEmpresasContaBancarias.getSelectedItem() != null) { -// ptovtaEmpresa.setEmpresaContaBancaria((EmpresaContaBancaria) cmbEmpresasContaBancarias.getSelectedItem().getValue()); -// } - - if (empresaContaBancariaList.getSelectedCount() > 0){ - ptovtaEmpresa.getContasBancaria().clear(); - - for (Object o : empresaContaBancariaList.getSelectedModelItems()) { - EmpresaContaBancaria ecb = (EmpresaContaBancaria) o; - ptovtaEmpresa.getContasBancaria().add(ecb); - } - } - - if (ptovtaEmpresa.getPtovtaempresaId() == null){ - lsPtovtaEmpresa.add(ptovtaEmpresa); - ptovtaEmpresaList.addItemNovo(ptovtaEmpresa); - - }else{ - int index = lsPtovtaEmpresa.indexOf(ptovtaEmpresa); - - if(index >= -1) { - lsPtovtaEmpresa.set(index, ptovtaEmpresa); - } else { - lsPtovtaEmpresa.add(ptovtaEmpresa); - } - - ptovtaEmpresaList.updateItem(ptovtaEmpresa); - } - - novoPtovtaEmpresa(); - - } else { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.Achou.PtovtaEmpresa"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - } - - } catch (Exception ex) { - log.error(ex); - Messagebox.show( - Labels.getLabel("MSG.Error"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } - } - - public void onClick$btnApagarPtovtaEmpresa(Event ev) { - try { - PtovtaEmpresa fpd = (PtovtaEmpresa) ptovtaEmpresaList.getSelected(); - if (fpd != null) { - lsPtovtaEmpresa.remove(fpd); - ptovtaEmpresaList.removeItem(fpd); - if (fpd.getPtovtaempresaId() != null) { - fpd.setActivo(Boolean.FALSE); - fpd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - fpd.setFecmodif(Calendar.getInstance().getTime()); - fpd.setPuntoVenta(puntoVenta); - - lsPtovtaEmpresa.add(fpd); - } - } - } catch (Exception ex) { - log.error(ex); - } - } - - public void onClick$btnNovoPtovtaEmpresa(Event ev) throws InterruptedException { - novoPtovtaEmpresa(); - } - - private void novoPtovtaEmpresa() { - cmbEmpresaPtoVta.setSelectedIndex(-1); -// cmbEmpresasContaBancarias.setSelectedIndex(-1); - checkPtoVtaEmpresaIndTerceirizada.setChecked(false); - checkPtoVtaEmpresaIndBloqueada.setChecked(false); - checkPtoVtaEmpresaIndMostrarCaja.setChecked(false); - checkPtoVtaEmpresaIndImpCompCartao.setChecked(false); - txtNumeroSitef.setValue(""); - txtMerchantStoreAdyen.setValue(null); - this.ptovtaEmpresa = null; - empresaContaBancariaList.setData(new ArrayList(0)); - } - - private void editarPtovtaEmpresa(PtovtaEmpresa ptovtaEmpresa) { - this.ptovtaEmpresa = new PtovtaEmpresa(ptovtaEmpresa.getPtovtaempresaId()); - this.ptovtaEmpresa.setLsPtovtaEmpresaContaBancaria(ptovtaEmpresa.getLsPtovtaEmpresaContaBancaria()); - - cmbEmpresaPtoVta.setSelectedIndex(-1); -// cmbEmpresasContaBancarias.setSelectedIndex(-1); - - if(lsEmpresasSemTodos != null) { - int indexOf = lsEmpresasSemTodos.indexOf(ptovtaEmpresa.getEmpresa()); - if (indexOf>-1) { - cmbEmpresaPtoVta.setSelectedIndex(indexOf); - } - } - - if(lsEmpresaContaBancarias != null) { -// cmbEmpresasContaBancarias.setSelectedIndex(lsEmpresaContaBancarias.indexOf(ptovtaEmpresa.getEmpresaContaBancaria())); - } - - lsEmpresaContaBancarias = ptovtaBancoService.buscarContasBancariasPorIdEmpresa(ptovtaEmpresa.getEmpresa().getEmpresaId()); - - empresaContaBancariaList.setData(new ArrayList(0)); - - if (lsEmpresaContaBancarias != null && !lsEmpresaContaBancarias.isEmpty()) { - empresaContaBancariaList.setData(lsEmpresaContaBancarias); - } - - empresaContaBancariaList.selectItems(ptovtaEmpresa.getContasBancaria()); - - - checkPtoVtaEmpresaIndTerceirizada.setChecked(ptovtaEmpresa.getIndTerceirizada()); - checkPtoVtaEmpresaIndBloqueada.setChecked(ptovtaEmpresa.getIndBloqueada()); - checkPtoVtaEmpresaIndMostrarCaja.setChecked(ptovtaEmpresa.getIndMostrarCaja()); - checkPtoVtaEmpresaIndImpCompCartao.setChecked(ptovtaEmpresa.getIndImpCompCartao()); - txtNumeroSitef.setValue(ptovtaEmpresa.getNumeroSitef()); - txtMerchantStoreAdyen.setValue(ptovtaEmpresa.getMerchantStoreAdyen()); - } - - public void onChange$cmbConexion(Event ev) { - habilitarCombo(); - } - - private void habilitarCombo() { - Comboitem cbi = cmbConexion.getSelectedItem(); - if (cbi != null) { - String valor = (String) cbi.getValue(); - - if (valor.equals("S")) { - cmbUsuarioBancario.setDisabled(Boolean.FALSE); - } - } - } - - public void onClick$btnSalvarPtovtaUsuarioBancario(Event ev) throws InterruptedException { - cmbEmpresaPtoVtaUsuarioBancario.getValue(); - cmbUsuarioBancarioPtoVtaUsuarioBancario.getValue(); - - try { - PtoVtaUsuarioBancario usuarioBancario = new PtoVtaUsuarioBancario(); - usuarioBancario.setEmpresa((Empresa) cmbEmpresaPtoVtaUsuarioBancario.getSelectedItem().getValue()); - usuarioBancario.setUsuarioBancario((UsuarioBancario) cmbUsuarioBancarioPtoVtaUsuarioBancario.getSelectedItem().getValue()); - - Boolean achou = Boolean.FALSE; - - for (PtoVtaUsuarioBancario fpd : lsPtovtaUsuarioBancario) { - if (fpd.getEmpresa().equals(usuarioBancario.getEmpresa())) { - achou = Boolean.TRUE; - } - } - if (!achou) { - - usuarioBancario.setPuntoVenta(puntoVenta); - usuarioBancario.setActivo(Boolean.TRUE); - usuarioBancario.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - usuarioBancario.setFecmodif(Calendar.getInstance().getTime()); - - lsPtovtaUsuarioBancario.add(usuarioBancario); - - List lsP = new ArrayList(); - for (PtoVtaUsuarioBancario p : lsPtovtaUsuarioBancario) { - if (p.getActivo()) { - lsP.add(p); - } - } - ptovtaUsuarioBancarioList.setData(lsP); - // ptovtaEmpresaList.addItem(ptovtaEmpresa); - - } else { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.Achou.PtovtaUsuario"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - } - - } catch (Exception ex) { - log.error(ex); - Messagebox.show( - Labels.getLabel("MSG.Error"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } - } - - public void onClick$btnApagarPtovtaUsuarioBancario(Event ev) { - try { - PtoVtaUsuarioBancario fpd = (PtoVtaUsuarioBancario) ptovtaUsuarioBancarioList.getSelected(); - if (fpd != null) { - ptovtaUsuarioBancarioList.removeItem(fpd); - lsPtovtaUsuarioBancario.remove(fpd); - if (fpd.getPtovtaUsuarioBancarioID() != null) { - fpd.setActivo(Boolean.FALSE); - fpd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - fpd.setFecmodif(Calendar.getInstance().getTime()); - - lsPtovtaUsuarioBancario.add(fpd); - } - } - } catch (Exception ex) { - log.error(ex); - } - } - - public void onClick$btnAdicionarEmpresaComissao(Event ev) throws InterruptedException { - if (cmbEmpresaComissao.getSelectedItem() == null) { - Messagebox.show( - Labels.getLabel("MSG.Error.combobox"), - Labels.getLabel("editarPricingController.windowMarca.title"), - Messagebox.OK, Messagebox.EXCLAMATION); - return; - } - Empresa empresa = (Empresa) cmbEmpresaComissao.getSelectedItem().getValue(); - - PtovtaComissao ptovtaComissao = new PtovtaComissao(); - - ptovtaComissao.setEmpresaId(empresa); - ptovtaComissao.setPuntoventaId(this.puntoVenta); - - ptovtaComissaoService.suscribir(ptovtaComissao); - - lsPtovtaComissao.add(ptovtaComissao); - - List lsPtovtaComissaoAtivo = new ArrayList(); - for (PtovtaComissao rc : lsPtovtaComissao) { - if (rc.getActivo()) { - lsPtovtaComissaoAtivo.add(rc); - } - } - ptovtaComissaoList.setData(lsPtovtaComissaoAtivo); - - cmbEmpresaComissao.getSelectedItem().setVisible(false); - - abrirPtovtaComissao(ptovtaComissao); - - } - - public PuntoVenta getPuntoVenta() { - return puntoVenta; - } - - public void setPuntoVenta(PuntoVenta puntoVenta) { - this.puntoVenta = puntoVenta; - } - - public MyListbox getPuntoVentaList() { - return puntoVentaList; - } - - public MyListbox getAntecipaList() { - return ptovtaAntecipaList; - } - - public void setAntecipaList(MyListbox antecipaList) { - this.ptovtaAntecipaList = antecipaList; - } - - public void setPuntoVentaList(MyListbox puntoVentaList) { - this.puntoVentaList = puntoVentaList; - } - - public PuntoVentaService getPuntoVentaService() { - return puntoVentaService; - } - - public void setPuntoVentaService(PuntoVentaService puntoVentaService) { - this.puntoVentaService = puntoVentaService; - } - - public EmpresaService getEmpresaService() { - return empresaService; - } - - public void setEmpresaService(EmpresaService empresaService) { - this.empresaService = empresaService; - } - - public TipoPuntoVentaService getTipoPuntoVentaService() { - return tipoPuntoVentaService; - } - - public void setTipoPuntoVentaService(TipoPuntoVentaService tipoPuntoVentaService) { - this.tipoPuntoVentaService = tipoPuntoVentaService; - } - - public List getLsEmpresas() { - return lsEmpresas; - } - - public void setLsEmpresas(List lsEmpresas) { - this.lsEmpresas = lsEmpresas; - } - - public List getLsPtovtaAntecipa() { - return lsAntecipacomissao; - } - - public void setLsPtovtaAntecipa(List lsAntecipacomissao) { - this.lsAntecipacomissao = lsAntecipacomissao; - } - - public List getLsHorario() { - return lsHorario; - } - - public void setLsHorario(List lsHorario) { - this.lsHorario = lsHorario; - } - - public List getLsTipoPuntoVenta() { - return lsTipoPuntoVenta; - } - - public void setLsTipoPuntoVenta(List lsTipoPuntoVenta) { - this.lsTipoPuntoVenta = lsTipoPuntoVenta; - } - - public MonedaService getMonedaService() { - return monedaService; - } - - public void setMonedaService(MonedaService monedaService) { - this.monedaService = monedaService; - } - - public List getLsMoneda() { - return lsMoneda; - } - - public void setLsMoneda(List lsMoneda) { - this.lsMoneda = lsMoneda; - } - - public InstiFinanceiraService getBancoService() { - return ptovtaBancoService; - } - - public void setBancoService(InstiFinanceiraService ptovtaBancoService) { - this.ptovtaBancoService = ptovtaBancoService; - } - - public List getLsBanco() { - return lsBanco; - } - - public void setLsBanco(List lsBanco) { - this.lsBanco = lsBanco; - } - - public Combobox getCmbBanco() { - return cmbBanco; - } - - public void setCmbBanco(Combobox cmbBanco) { - this.cmbBanco = cmbBanco; - } - - public Combobox getCmbPessoa() { - return cmbPessoa; - } - - public void setCmbPessoa(Combobox cmbPessoa) { - this.cmbPessoa = cmbPessoa; - } - - public Image getImg() { - return img; - } - - public void setImg(Image img) { - this.img = img; - } - - public Radio getRadAprobacionAutorizado() { - return radAprobacionAutorizado; - } - - public void setRadAprobacionAutorizado(Radio radAprobacionAutorizado) { - this.radAprobacionAutorizado = radAprobacionAutorizado; - } - - public Radio getRadAprobacionLatente() { - return radAprobacionLatente; - } - - public void setRadAprobacionLatente(Radio radAprobacionLatente) { - this.radAprobacionLatente = radAprobacionLatente; - } - - public Radio getRadDatosTarjetaNo() { - return radDatosTarjetaNo; - } - - public void setRadDatosTarjetaNo(Radio radDatosTarjetaNo) { - this.radDatosTarjetaNo = radDatosTarjetaNo; - } - - public Radio getRadDatosTarjetaSi() { - return radDatosTarjetaSi; - } - - public void setRadDatosTarjetaSi(Radio radDatosTarjetaSi) { - this.radDatosTarjetaSi = radDatosTarjetaSi; - } - - public MyTextbox getTxtNome() { - return txtNome; - } - - public void setTxtNome(MyTextbox txtNome) { - this.txtNome = txtNome; - } - - public MyTextbox getTxtTitularNome() { - return txtTitularNome; - } - - public void setTxtTitularNome(MyTextbox txtTitularNome) { - this.txtTitularNome = txtTitularNome; - } - - public MyTextbox getTxtTitularCpf() { - return txtTitularCpf; - } - - public void setTxtTitularCpf(MyTextbox txtTitularCpf) { - this.txtTitularCpf = txtTitularCpf; - } - - public MyTextbox getTxtTitularRg() { - return txtTitularRg; - } - - public void setTxtTitularRg(MyTextbox txtTitularRg) { - this.txtTitularRg = txtTitularRg; - } - - public MyTextbox getTxtTitularEmissor() { - return txtTitularEmissor; - } - - public void setTxtTitularEmissor(MyTextbox txtTitularEmissor) { - this.txtTitularEmissor = txtTitularEmissor; - } - - public MyListbox getFormaPagoList() { - return formaPagoList; - } - - public void setFormaPagoList(MyListbox formaPagoList) { - this.formaPagoList = formaPagoList; - } - - public List getLsFormaPago() { - return lsFormaPago; - } - - public void setLsFormaPago(List lsFormaPago) { - this.lsFormaPago = lsFormaPago; - } - - public Combobox getCmbFormaPago() { - return cmbFormaPago; - } - - public void setCmbFormaPago(Combobox cmbFormaPago) { - this.cmbFormaPago = cmbFormaPago; - } - - public Doublebox getTxtCargosExtras() { - return txtCargosExtras; - } - - public void setTxtCargosExtras(Doublebox txtCargosExtras) { - this.txtCargosExtras = txtCargosExtras; - } - - public List getLsNodos() { - return lsNodos; - } - - public void setLsNodos(List lsNodos) { - this.lsNodos = lsNodos; - } - - public Button getBtnSalvarFormaPago() { - return btnSalvarFormaPago; - } - - public void setBtnSalvarFormaPago(Button btnSalvarFormaPago) { - this.btnSalvarFormaPago = btnSalvarFormaPago; - } - - public FormaPagoService getFormaPagoService() { - return formaPagoService; - } - - public void setFormaPagoService(FormaPagoService formaPagoService) { - this.formaPagoService = formaPagoService; - } - - public List getLsFormaPagoDet() { - return lsFormaPagoDet; - } - - public void setLsFormaPagoDet(List lsFormaPagoDet) { - this.lsFormaPagoDet = lsFormaPagoDet; - } - - public Combobox getCmbCiudad() { - return cmbCiudad; - } - - public void setCmbCiudad(Combobox cmbCiudad) { - this.cmbCiudad = cmbCiudad; - } - - public Combobox getCmbEmpresa() { - return cmbEmpresa; - } - - public void setCmbEmpresa(Combobox cmbEmpresa) { - this.cmbEmpresa = cmbEmpresa; - } - - public Combobox getCmbParada() { - return cmbParada; - } - - public void setCmbParada(Combobox cmbParada) { - this.cmbParada = cmbParada; - } - - public Combobox getCmbPtoVtaCheckinParada() { - return cmbPtoVtaCheckinParada; - } - - public void setCmbPtoVtaCheckinParada(Combobox cmbPtoVtaCheckinParada) { - this.cmbPtoVtaCheckinParada = cmbPtoVtaCheckinParada; - } - - public Combobox getCmbMoneda() { - return cmbMoneda; - } - - public void setCmbMoneda(Combobox cmbMoneda) { - this.cmbMoneda = cmbMoneda; - } - - /* - * public Combobox getCmbNodo() { return cmbNodo; } - * - * public void setCmbNodo(Combobox cmbNodo) { this.cmbNodo = cmbNodo; } - */ - - public Combobox getCmbTipoPontoVenta() { - return cmbTipoPontoVenta; - } - - public void setCmbTipoPontoVenta(Combobox cmbTipoPontoVenta) { - this.cmbTipoPontoVenta = cmbTipoPontoVenta; - } - - /** - * @return the lsColonia - */ - public List getLsColonia() { - return lsColonia; - } - - /** - * @param lsColonia - * the lsColonia to set - */ - public void setLsColonia(List lsColonia) { - this.lsColonia = lsColonia; - } - - /** - * @return the cmbColonia - */ - public Combobox getCmbColonia() { - return cmbColonia; - } - - /** - * @param cmbColonia - * the cmbColonia to set - */ - public void setCmbColonia(Combobox cmbColonia) { - this.cmbColonia = cmbColonia; - } - - /** - * @return the txtCP - */ - public Textbox getTxtCP() { - return txtCP; - } - - /** - * @param txtCP - * the txtCP to set - */ - public void setTxtCP(Textbox txtCP) { - this.txtCP = txtCP; - } - - public MyTextbox getTxtNumAg() { - return txtNumAg; - } - - public void setTxtNumAg(MyTextbox txtNumAg) { - this.txtNumAg = txtNumAg; - } - - public List getLsUsuarioBancario() { - return lsUsuarioBancario; - } - - public void setLsUsuarioBancario(List lsUsuarioBancario) { - this.lsUsuarioBancario = lsUsuarioBancario; - } - - public List getLsParamRecoleccion() { - return lsParamRecoleccion; - } - - public void setLsParamRecoleccion(List lsParamRecoleccion) { - this.lsParamRecoleccion = lsParamRecoleccion; - } - - public Intbox getTxtQuant() { - return txtQuant; - } - - public void setTxtQuant(Intbox txtQuant) { - this.txtQuant = txtQuant; - } - - public Intbox getTxtcodAg() { - return txtcodAg; - } - - public void setTxtcodAg(Intbox txtcodAg) { - this.txtcodAg = txtcodAg; - } - - public MyTextbox getTxtNumFax() { - return txtNumFax; - } - - public void setTxtNumFax(MyTextbox txtNumFax) { - this.txtNumFax = txtNumFax; - } - - public MyTextbox getTxtCompl() { - return txtCompl; - } - - public void setTxtCompl(MyTextbox txtCompl) { - this.txtCompl = txtCompl; - } - - public MyTextbox getTxtEspecie() { - return txtEspecie; - } - - public void setTxtEspecie(MyTextbox txtEspecie) { - this.txtEspecie = txtEspecie; - } - - public Textbox getTxtNomeBanco() { - return txtNomeBanco; - } - - public void setTxtNomeBanco(Textbox txtNomeBanco) { - this.txtNomeBanco = txtNomeBanco; - } - - public MyTextbox getTxtConta() { - return txtConta; - } - - public void setTxtConta(MyTextbox txtConta) { - this.txtConta = txtConta; - } - - public MyTextbox getTxtDigito() { - return txtDigito; - } - - public void setTxtDigito(MyTextbox txtDigito) { - this.txtDigito = txtDigito; - } - - public MyTextbox getTxtBilhetes() { - return txtBilhetes; - } - - public void setTxtBilhetes(MyTextbox txtBilhetes) { - this.txtBilhetes = txtBilhetes; - } - - public MyTextbox getTxtCarga() { - return txtCarga; - } - - public void setTxtCarga(MyTextbox txtCarga) { - this.txtCarga = txtCarga; - } - - public Datebox getDateAntecipData() { - return dateAntecipData; - } - - public void setDateAntecipData(Datebox dateAntecipData) { - this.dateAntecipData = dateAntecipData; - } - - public MyTextboxDecimal getTxtAntecipRetem() { - return txtAntecipRetem; - } - - public void setTxtAntecipRetem(MyTextboxDecimal txtAntecipRetem) { - this.txtAntecipRetem = txtAntecipRetem; - } - - public MyTextboxDecimal getTxtAntecipPercentual() { - return txtAntecipPercentual; - } - - public void setTxtAntecipPercentual(MyTextboxDecimal txtAntecipPercentual) { - this.txtAntecipPercentual = txtAntecipPercentual; - } - - public Timebox getTimeboxInicio() { - return timeboxInicio; - } - - public void setTimeboxInicio(Timebox timeboxInicio) { - this.timeboxInicio = timeboxInicio; - } - - public Timebox getTimeboxFim() { - return timeboxFim; - } - - public void setTimeboxFim(Timebox timeboxFim) { - this.timeboxFim = timeboxFim; - } - - public MyListbox getParamRecoleccionList() { - return paramRecoleccionList; - } - - public void setParamRecoleccionList(MyListbox paramRecoleccionList) { - this.paramRecoleccionList = paramRecoleccionList; - } - - public List getLsPtovtaEmpresa() { - return lsPtovtaEmpresa; - } - - public void setLsPtovtaEmpresa(List lsPtovtaEmpresa) { - this.lsPtovtaEmpresa = lsPtovtaEmpresa; - } - - public MyListbox getPtovtaEmpresaList() { - return ptovtaEmpresaList; - } - - public void setPtovtaEmpresaList(MyListbox ptovtaEmpresaList) { - this.ptovtaEmpresaList = ptovtaEmpresaList; - } - - public List getLsPtovtaUsuarioBancario() { - return lsPtovtaUsuarioBancario; - } - - public void setLsPtovtaUsuarioBancario(List lsPtovtaUsuarioBancario) { - this.lsPtovtaUsuarioBancario = lsPtovtaUsuarioBancario; - } - - public MyListbox getPtovtaUsuarioBancarioList() { - return ptovtaUsuarioBancarioList; - } - - public void setPtovtaUsuarioBancarioList(MyListbox ptovtaUsuarioBancarioList) { - this.ptovtaUsuarioBancarioList = ptovtaUsuarioBancarioList; - } - - public List getLsEmpresaComissao() { - return lsEmpresaComissao; - } - - public void setLsEmpresaComissao(List lsEmpresaComissao) { - this.lsEmpresaComissao = lsEmpresaComissao; - } - - public Combobox getCmbEmpresaComissao() { - return cmbEmpresaComissao; - } - - public void setCmbEmpresaComissao(Combobox cmbEmpresaComissao) { - this.cmbEmpresaComissao = cmbEmpresaComissao; - } - - public Button getBtnAdicionarEmpresaComissao() { - return btnAdicionarEmpresaComissao; - } - - public void setBtnAdicionarEmpresaComissao(Button btnAdicionarEmpresaComissao) { - this.btnAdicionarEmpresaComissao = btnAdicionarEmpresaComissao; - } - - public MyTextbox getTxtNumDoCPuntoVenta() { - return txtNumDoCPuntoVenta; - } - - public void setTxtNumDoCPuntoVenta(MyTextbox txtNumDoCPuntoVenta) { - this.txtNumDoCPuntoVenta = txtNumDoCPuntoVenta; - } - - public MyTextbox getTxtRazonSocial() { - return txtRazonSocial; - } - - public void setTxtRazonSocial(MyTextbox txtRazonSocial) { - this.txtRazonSocial = txtRazonSocial; - } - - public String getLogFileSelected() { - return logFileSelected; - } - - public void setLogFileSelected(String logFileSelected) { - this.logFileSelected = logFileSelected; - } - - public void onChange$cmbPuntoVentaPadre(Event ev) throws InterruptedException { - if (puntoVenta.getPuntoventaId() != null) { - List lsPuntosSubordinados = puntoVentaService.buscarPuntoVentaSubordinados(puntoVenta); - - if (!lsPuntosSubordinados.isEmpty()) { - StringBuilder sbPuntosSubordinados = new StringBuilder("\n"); - for (PuntoVenta pv : lsPuntosSubordinados) { - sbPuntosSubordinados.append(pv.getNombpuntoventa()).append("\n"); - } - - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.msg.naopodesersubordinadapossuisubordinadas") + sbPuntosSubordinados.toString(), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - - cmbPuntoVentaPadre.setSelectedItem(null); - cmbPuntoVentaPadre.setText(null); - } - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void abrirPtovtaComissao(PtovtaComissao ptovtaComissao) { - Map args = new HashMap(); - args.put("ptovtaComissao", ptovtaComissao); - args.put("ptovtaComissaoList", ptovtaComissaoList); - - openWindow("/gui/catalogos/editarPuntoVentaComissao.zul", - Labels.getLabel("editarPuntoVentaComissaoController.window.title", new String[] { ptovtaComissao.getEmpresaId().getNombempresa() }), args, MODAL); - - } - - public void onClick$btnApagarFechamentoParamptovta(Event ev) { - try { - if (fechamentoParamptovtaList.getSelected() != null) { - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.borrarFechamentoParamptovta"), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if (resp == Messagebox.YES) { - FechamentoParamptovta fpp = (FechamentoParamptovta) fechamentoParamptovtaList.getSelected(); - fechamentoParamptovtaList.removeItem(fpp); - } - } - } catch (Exception ex) { - log.error(ex.toString()); - } - } - - public void onClick$btnAdicionarFechamentoParamptovta(Event ev) { - txtDiasemtransito.getValue(); - - if (cmbEmpresaFechamentoParamptovta.getSelectedItem() != null && - (radIntervalofechamentoDiario.isChecked() || radIntervalofechamentoSemanal.isChecked() - || radIntervalofechamentoDecendial.isChecked() - || radIntervalofechamentoQuinzenal.isChecked() - || radIntervalofechamentoMensal.isChecked())) { - Empresa empresa = (Empresa) cmbEmpresaFechamentoParamptovta.getSelectedItem().getValue(); - - FechamentoParamptovta fechamentoParamptovta = new FechamentoParamptovta(); - fechamentoParamptovta.setEmpresa(empresa); - fechamentoParamptovta.setPuntoventa(puntoVenta); - Integer intervalofechamento = 0; - - if (radIntervalofechamentoSemanal.isChecked()) { - intervalofechamento = Constantes.INTERVALO_FECHAMENTO_SEMANAL; - - } else if (radIntervalofechamentoDecendial.isChecked()) { - intervalofechamento = Constantes.INTERVALO_FECHAMENTO_DECENDIAL; - - } else if (radIntervalofechamentoQuinzenal.isChecked()) { - intervalofechamento = Constantes.INTERVALO_FECHAMENTO_QUINZENAL; - - } else if (radIntervalofechamentoMensal.isChecked()) { - intervalofechamento = Constantes.INTERVALO_FECHAMENTO_MENSAL; - - } else if (radIntervalofechamentoDiario.isChecked()) { - intervalofechamento = Constantes.INTERVALO_FECHAMENTO_DIARIO; - } - - if (radTipoPagamentoBoleto.isChecked()){ - fechamentoParamptovta.setTipopagamento("B"); - } else { - fechamentoParamptovta.setTipopagamento("D"); - } - - fechamentoParamptovta.setIntervalofechamento(intervalofechamento); - - if (StringUtils.isNotBlank(txtDiasemtransito.getValue())) { - fechamentoParamptovta.setDiasemtransito(Integer.valueOf(txtDiasemtransito.getValue())); - } - - fechamentoParamptovta.setActivo(true); - fechamentoParamptovta.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - fechamentoParamptovta.setFecmodif(new Date()); - - boolean validado = validaFechamentoParamptovta(fechamentoParamptovta); - - if (validado) { - fechamentoParamptovtaList.addItemNovo(fechamentoParamptovta); - resetDadosFechamentoParamptovta(); - } - } - } - - private void resetDadosFechamentoParamptovta() { - - cmbEmpresaFechamentoParamptovta.setSelectedItem(null); - - radIntervalofechamentoSemanal.setChecked(false); - radIntervalofechamentoDecendial.setChecked(false); - radIntervalofechamentoQuinzenal.setChecked(false); - radIntervalofechamentoMensal.setChecked(false); - radIntervalofechamentoDiario.setChecked(false); - radTipoPagamentoBoleto.setChecked(true); - - txtDiasemtransito.setValue(""); - } - - private boolean validaFechamentoParamptovta(FechamentoParamptovta fechamentoParamptovta) { - boolean validado = true; - try { - // Valida Empresa Fechamento ja cadastrada. - Object[] params = fechamentoParamptovtaList.getData(); - for (Object objectData : params) { - - FechamentoParamptovta param = (FechamentoParamptovta) objectData; - if (fechamentoParamptovta.getEmpresa().getEmpresaId() == param.getEmpresa().getEmpresaId()) { - validado = false; - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.fechamentoParamptovtaInvalidado"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - return validado; - } - } - // Valida Empresa para Venda Cadastrada - Object[] empresasVenda = ptovtaEmpresaList.getData(); - for (Object empresa : empresasVenda) { - if (fechamentoParamptovta.getEmpresa().getEmpresaId() == ((PtovtaEmpresa) empresa).getEmpresa().getEmpresaId()) { - return validado; - } - } - validado = false; - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.fechamentoParamptovtaEmpresaInvalida"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.ERROR); - } catch (Exception ex) { - log.error(ex.toString()); - } - - return validado; - } - - public Combobox getCmbEmpresaFechamentoParamptovta() { - return cmbEmpresaFechamentoParamptovta; - } - - public void setCmbEmpresaFechamentoParamptovta(Combobox cmbEmpresaFechamentoParamptovta) { - this.cmbEmpresaFechamentoParamptovta = cmbEmpresaFechamentoParamptovta; - } - - public Radio getRadTotvsSi() { - return radTotvsSi; - } - - public void setRadTotvsSi(Radio radTotvsSi) { - this.radTotvsSi = radTotvsSi; - } - - public Radio getRadTotvsNo() { - return radTotvsNo; - } - - public void setRadTotvsNo(Radio radTotvsNo) { - this.radTotvsNo = radTotvsNo; - } - - public Radio getRadTotvsErro() { - return radTotvsErro; - } - - public void setRadTotvsErro(Radio radTotvsErro) { - this.radTotvsErro = radTotvsErro; - } - - public boolean isIntegracionTotvs() { - if(isPerfilFuncionBloqueiaDesbloqueiaPontoVenda) { - return false; - } - integracionTotvs = false; - if (ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.INTEGRACION_TOTVS.getDescricao())) { - integracionTotvs = true; - } - return integracionTotvs; - } - - public boolean isIntegracionAG() { - if(isPerfilFuncionBloqueiaDesbloqueiaPontoVenda) { - return false; - } - integracionAG = false; - if (ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.INTEGRACION_AG.getDescricao())) { - integracionAG = true; - } - return integracionAG; - } - - public void setIntegracionTotvs(boolean integracionTotvs) { - this.integracionTotvs = integracionTotvs; - } - - public void setIntegracionAG(boolean integracionAG) { - this.integracionAG = integracionAG; - } - - public List getLsLogFiles() { - return lsLogFiles; - } - - public void setLsLogFiles(List lsLogFiles) { - this.lsLogFiles = lsLogFiles; - } - - public Button getBtnShowLog() { - return btnShowLog; - } - - public void setBtnShowLog(Button btnShowLog) { - this.btnShowLog = btnShowLog; - } - - public static void compactarArquivo(String arqSaida, String arqEntrada) throws IOException { - int cont; - byte[] dados = new byte[TAMANHO_BUFFER]; - BufferedInputStream origem = null; - FileInputStream streamDeEntrada = null; - FileOutputStream destino = null; - ZipOutputStream saida = null; - ZipEntry entry = null; - try { - destino = new FileOutputStream(new File(arqSaida)); - saida = new ZipOutputStream(new BufferedOutputStream(destino)); - File file = new File(arqEntrada); - streamDeEntrada = new FileInputStream(file); - origem = new BufferedInputStream(streamDeEntrada, TAMANHO_BUFFER); - entry = new ZipEntry(file.getName()); - saida.putNextEntry(entry); - while ((cont = origem.read(dados, 0, TAMANHO_BUFFER)) != -1) { - saida.write(dados, 0, cont); - } - origem.close(); - saida.close(); - } catch (IOException e) { - throw new IOException(e.getMessage()); - } - } - - private void excluirArquivosZip() { - File pasta = new File(System.getProperty("jboss.server.log.dir")); - File[] arquivos = pasta.listFiles(); - - for (File arquivo : arquivos) { - if (arquivo.getName().endsWith("zip")) { - arquivo.delete(); - } - } - } - - public void onClick$radIndvendsegtabelaSi(Event event) { - if (radIndvendsegtabelaSi.isChecked()) { - radIndestansegtabelaSi.setDisabled(false); - radIndestansegtabelaNo.setDisabled(false); - radIndestansegtabelaNo.setChecked(true); - } - } - - public void onClick$btnAddChaveAntifraude(Event event) { - try { - if(verificarCamposAddChaveAntifraude()) { - if (cmbEmpresaPtoVtaAntifraude.getSelectedItem() == null) { - return; - } - txtChaveAntifraude.getValue(); - - PtovtaAntifraude ptovtaAntifraude = new PtovtaAntifraude(); - ptovtaAntifraude.setEmpresa((Empresa)cmbEmpresaPtoVtaAntifraude.getSelectedItem().getValue()); - ptovtaAntifraude.setPuntoventa(puntoVenta); - ptovtaAntifraude.setChave(txtChaveAntifraude.getValue()); - ptovtaAntifraude.setTipo(TipoAntifraude.KONDUTO); - ptovtaAntifraude.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - - puntoVenta.addChaveAntifurto(ptovtaAntifraude); - - ptovtaAntifraudeList.setData(puntoVenta.getPtovtaAntifraudes()); - - txtChaveAntifraude.setValue(""); - } - } catch (Exception e) { - log.error(e.getMessage(), e); - } - } - - public void onClick$btnAddExcecaoMultaCanc(Event event) { - try { - if(verificarCamposAddExcecaoMultaCanc()) { - if (cmbEmpresaPtoVtaExcecaoMultaCanc.getSelectedItem() == null) { - return; - } - if(cmbOrgaoConcedente.getSelectedItem() == null){ - return; - } - - PtovtaExcecaoMultaCanc ptovtaExcecaoMultaCanc = new PtovtaExcecaoMultaCanc(); - ptovtaExcecaoMultaCanc.setEmpresa((Empresa)cmbEmpresaPtoVtaExcecaoMultaCanc.getSelectedItem().getValue()); - ptovtaExcecaoMultaCanc.setPuntoventa(puntoVenta); - ptovtaExcecaoMultaCanc.setOrgaoConcedente((OrgaoConcedente)cmbOrgaoConcedente.getSelectedItem().getValue()); - ptovtaExcecaoMultaCanc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - - if(puntoVenta.getPtovtaExcecaoMultaCancList() ==null) { - puntoVenta.setPtovtaExcecaoMultaCancList(new ArrayList()); - } - puntoVenta.getPtovtaExcecaoMultaCancList().add(ptovtaExcecaoMultaCanc); - ptovtaExcecaoMultaCancList.setData(puntoVenta.getPtovtaExcecaoMultaCancList()); - - - } - } catch (Exception e) { - log.error("Erro ao adicionar Excecao Multa Cancelamento", e); - } - } - - private boolean verificarCamposAddChaveAntifraude() throws InterruptedException { - if (cmbEmpresaPtoVtaAntifraude.getSelectedItem() == null) { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.empresaAntifraudeNaoInformada"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - return false; - } - - txtChaveAntifraude.getValue(); - if(StringUtils.isBlank(txtChaveAntifraude.getValue())) { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.chaveAntifraudeNaoInformada"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - return false; - } - - if(puntoVenta.getPtovtaAntifraudes() != null) { - Empresa empresa = (Empresa) cmbEmpresaPtoVtaAntifraude.getSelectedItem().getValue(); - for (PtovtaAntifraude ptovtaAntifraude : puntoVenta.getPtovtaAntifraudes()) { - if(empresa.equals(ptovtaAntifraude.getEmpresa())) { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.empresaAntifraudeJaCadastrada"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - return false; - } - } - } - return true; - } - - - private boolean verificarCamposAddExcecaoMultaCanc() throws InterruptedException { - if (cmbEmpresaPtoVtaExcecaoMultaCanc.getSelectedItem() == null) { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.empresaExcecaoMultaCancNaoInformada"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - return false; - } - - if (cmbOrgaoConcedente.getSelectedItem() == null) { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.OrgaoConcedenteExcecaoMultaCancNaoInformada"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - return false; - } - - - if(puntoVenta.getPtovtaExcecaoMultaCancList() != null) { - Empresa empresa = (Empresa) cmbEmpresaPtoVtaExcecaoMultaCanc.getSelectedItem().getValue(); - OrgaoConcedente orgaoConcedente = (OrgaoConcedente) cmbOrgaoConcedente.getSelectedItem().getValue(); - - for (PtovtaExcecaoMultaCanc ptovtaExcecaoMultaCanc : puntoVenta.getPtovtaExcecaoMultaCancList()) { - if(empresa.getEmpresaId().equals(ptovtaExcecaoMultaCanc.getEmpresa().getEmpresaId()) - && orgaoConcedente.getOrgaoConcedenteId().equals(ptovtaExcecaoMultaCanc.getOrgaoConcedente().getOrgaoConcedenteId()) ) { - Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.empresaOrgaoExcecaoMultaCancJaCadastrada"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - return false; - } - } - } - return true; - } - - public void onClick$btnRemoveChaveAntifraude(Event event) { - try{ - PtovtaAntifraude ptovtaAntifraude = (PtovtaAntifraude)ptovtaAntifraudeList.getSelected(); - if(ptovtaAntifraude != null) { - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.borrarChaveAntifraude", new String[] {ptovtaAntifraude.getEmpresa() != null ? ptovtaAntifraude.getEmpresa().getNombempresa() : ""}), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if (resp == Messagebox.YES) { - puntoVenta.removeChaveAntifurto(ptovtaAntifraude); - - if(ptovtaAntifraude.getPtovtaAntifraudeId() != null) { - ptovtaAntifraudeService.borrar(ptovtaAntifraude); - } - ptovtaAntifraudeList.setData(puntoVenta.getPtovtaAntifraudes()); - } - } - } catch (Exception e){ - log.error("", e); - } - } - - public void onClick$btnRemoveExcecaoMultaCanc(Event event) { - try{ - PtovtaExcecaoMultaCanc ptovtaExcecaoMultaCanc = (PtovtaExcecaoMultaCanc)ptovtaExcecaoMultaCancList.getSelected(); - if(ptovtaExcecaoMultaCanc != null) { - String nomeEmpresa = ptovtaExcecaoMultaCanc.getEmpresa() != null ? ptovtaExcecaoMultaCanc.getEmpresa().getNombempresa() : ""; - String nomeOrgao = ptovtaExcecaoMultaCanc.getOrgaoConcedente() != null ? ptovtaExcecaoMultaCanc.getOrgaoConcedente().getDescOrgao() : ""; - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.borrarChaveExcecaoMultaCancJaCadastrada", new String[] {nomeEmpresa, nomeOrgao}), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if (resp == Messagebox.YES) { - puntoVenta.removePtovtaExcecaoMultaCanc(ptovtaExcecaoMultaCanc); - - if(ptovtaExcecaoMultaCanc.getPtovtaExcecaoMultaCancId() != null) { - ptovtaExcecaoMultaCancService.borrar(ptovtaExcecaoMultaCanc); - } - ptovtaExcecaoMultaCancList.setData(puntoVenta.getPtovtaExcecaoMultaCancList()); - } - } - } catch (Exception e){ - log.error("Erro ao processar remocao Exception Multa Cancelamento", e); - } - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private void verPtovtaAntifraude(PtovtaAntifraude ptovtaAntifraude) { - Map args = new HashMap(); - args.put("ptovtaComissao", ptovtaAntifraude); - args.put("puntoVenta", puntoVenta); - args.put("ptovtaAntifraudeList", ptovtaAntifraudeList); - - openWindow("/gui/catalogos/editarPtovtaAntifraude.zul", - Labels.getLabel("editarPtovtaAntifraudeController.window.title"), args, MODAL); - } - - public void onClick$radIndvendsegtabelaNo(Event event) { - if (radIndvendsegtabelaNo.isChecked()) { - radIndestansegtabelaSi.setDisabled(true); - radIndestansegtabelaNo.setDisabled(true); - radIndestansegtabelaNo.setChecked(true); - } - } - - public void onClick$ckValidarTempoParaImpressao(Event event) { - if (ckValidarTempoParaImpressao.isChecked()) { - txtTempoParaImpressao.setDisabled(Boolean.FALSE); - txtTempoParaImpressao.setValue(null); - } else { - txtTempoParaImpressao.setDisabled(Boolean.TRUE); - txtTempoParaImpressao.setValue(null); - } - } - - public void onClick$radAprobacionLatente(Event event) { - if (radAprobacionLatente.isChecked()) { - rowDateFechamento.setVisible(Boolean.TRUE); - } - } - - public void onClick$radAprobacionAutorizado(Event event) { - if (!radAprobacionLatente.isChecked()) { - dateFechamento.setValue(puntoVenta.getDateFechamento()); - rowDateFechamento.setVisible(Boolean.FALSE); - } - } - - public Boolean isPermissaoEditarComissao() { - return UsuarioLogado.getUsuarioLogado().isPermisoClave(ConstantesFuncionSistema.CLAVE_EDITAR_COMISSAO); - } - - public List getLsEmpresaContaBancarias() { - return lsEmpresaContaBancarias; - } - - public void setLsEmpresaContaBancarias(List lsEmpresaContaBancarias) { - this.lsEmpresaContaBancarias = lsEmpresaContaBancarias; - } - - public MyComboboxEstandar getCmbEmpresasContaBancarias() { - return cmbEmpresasContaBancarias; - } - - public void setCmbEmpresasContaBancarias(MyComboboxEstandar cmbEmpresasContaBancarias) { - this.cmbEmpresasContaBancarias = cmbEmpresasContaBancarias; - } - - public List getLsEmpresasFormapago() { - return lsEmpresasFormapago; - } - - public void setLsEmpresasFormapago(List lsEmpresasFormapago) { - this.lsEmpresasFormapago = lsEmpresasFormapago; - } - - public Timebox getTxtTempoParaImpressao() { - return txtTempoParaImpressao; - } - - public void setTxtTempoParaImpressao(Timebox txtTempoParaImpressao) { - this.txtTempoParaImpressao = txtTempoParaImpressao; - } - - public Checkbox getCkValidarTempoParaImpressao() { - return ckValidarTempoParaImpressao; - } - - public void setCkValidarTempoParaImpressao(Checkbox ckValidarTempoParaImpressao) { - this.ckValidarTempoParaImpressao = ckValidarTempoParaImpressao; - } - - public MyListbox getPtovtaHistoricoList() { - return ptovtaHistoricoList; - } - - public void setPtovtaHistoricoList(MyListbox ptovtaHistoricoList) { - this.ptovtaHistoricoList = ptovtaHistoricoList; - } - - public List getLsCategoriaBloquear() { - return lsCategoriaBloquear; - } - - public void setLsCategoriaBloquear(List lsCategoriaBloquear) { - this.lsCategoriaBloquear = lsCategoriaBloquear; - } - - - /** - * @return the txtTaxaConvenienciaPorc - */ - public Decimalbox getTxtTaxaConvenienciaPorc() { - return txtTaxaConvenienciaPorc; - } - - /** - * @param txtTaxaConvenienciaPorc the txtTaxaConvenienciaPorc to set - */ - public void setTxtTaxaConvenienciaPorc(Decimalbox txtTaxaConvenienciaPorc) { - this.txtTaxaConvenienciaPorc = txtTaxaConvenienciaPorc; - } - - /** - * @return the txtMaximoTaxaConveniencia - */ - public Doublebox getTxtMaximoTaxaConveniencia() { - return txtMaximoTaxaConveniencia; - } - - /** - * @param txtMaximoTaxaConveniencia the txtMaximoTaxaConveniencia to set - */ - public void setTxtMaximoTaxaConveniencia(Doublebox txtMaximoTaxaConveniencia) { - this.txtMaximoTaxaConveniencia = txtMaximoTaxaConveniencia; - } - - /** - * @return the ct - */ - public ConstraintPorcentagemAllowNull getCt() { - return ct; - } - - /** - * @param ct the ct to set - */ - public void setCt(ConstraintPorcentagemAllowNull ct) { - this.ct = ct; - } - - public Radio getRadIndvendsegtabelaSi() { - return radIndvendsegtabelaSi; - } - - public void setRadIndvendsegtabelaSi(Radio radIndvendsegtabelaSi) { - this.radIndvendsegtabelaSi = radIndvendsegtabelaSi; - } - - public Radio getRadIndvendsegtabelaNo() { - return radIndvendsegtabelaNo; - } - - public void setRadIndvendsegtabelaNo(Radio radIndvendsegtabelaNo) { - this.radIndvendsegtabelaNo = radIndvendsegtabelaNo; - } - - public List getLsEmpresasSemTodos() { - return lsEmpresasSemTodos; - } - - public MyListbox getCategoriaList() { - return categoriaList; - } - - public void setCategoriaList(MyListbox categoriaList) { - this.categoriaList = categoriaList; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void autoCompleteBandbox(String change) { - categoriaList.clear(); - - if (StringUtils.isNotEmpty(change)) { - for (Object categoria : lsCategoriaBloquear) { - if (categoria.toString().toUpperCase().contains(change.toUpperCase())) { - categoriaList.addItemNovo(categoria); - } - } - } else { - inserirItensLista(lsCategoriaBloquear); - } - categoriaList.selectItems(new ArrayList(lsCategoriaSel)); - } - - private void inserirItensLista(Collection itensLista) { - for (Object c : itensLista) { - categoriaList.addItemNovo(c); - } - } - - public void onSelect$categoriaList(Event ev){ - ForwardEvent fev = (ForwardEvent) ev; - SelectEvent selEv = (SelectEvent) fev.getOrigin(); - - Listitem i = (Listitem) selEv.getReference(); - if(i.isSelected()){ - lsCategoriaSel.add(i.getValue()); - }else{ - lsCategoriaSel.remove(i.getValue()); - } - } - - public void onCheck$radIndBloquear(Event event) { - inverterAbaTipoAssagem(Boolean.TRUE); - } - - public void onCheck$radIndLiberar(Event event) { - inverterAbaTipoAssagem(Boolean.FALSE); - } - - private void inverterAbaTipoAssagem(Boolean isBloquear) { - - if(puntoVenta == null || puntoVenta.getPuntoventaId() == null) { - return; - } - - try { - - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.lbComportamentoAbaTipoPassagem.mensagemAlerta.value"), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if(resp == Messagebox.NO) { - voltarSelecaoIndBloquear(isBloquear); - return; - } - - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void abrirMotivoFormaPagamento(FormaPagoDet formaPagoDet, Boolean inclusao, Integer empresaId) { - Map args = new HashMap(); - args.put("puntoVenta", puntoVenta); - args.put("formaPagoDet", formaPagoDet); - args.put("formaPagoList", formaPagoList); - args.put("ptovtaHistoricoFormaPagoList", ptovtaHistoricoFormaPagoList); - args.put("inclusao", inclusao); - args.put("empresaId", empresaId); - openWindow("/gui/catalogos/editarPuntoVentaMotivoFormaPago.zul", Labels.getLabel("editarPuntoVentaMotivoFormaPagoController.window.title", new String[] { puntoVenta.getNombpuntoventa() }), args, MODAL); - - } - - - - - - private void voltarSelecaoIndBloquear(Boolean isBloquear) { - if(isBloquear) { - radIndLiberar.setSelected(Boolean.TRUE); - }else { - radIndBloquear.setSelected(Boolean.TRUE); - } - } - - public List getLsEmpresasCobrancaAdicional() { - return lsEmpresasCobrancaAdicional; - } - - public List getLsTodasCobrancas() { - return lsTodasCobrancas; - } - - public void setLsTodasCobrancas(List lsTodasCobrancas) { - this.lsTodasCobrancas = lsTodasCobrancas; - } - - public void setLsEmpresasCobrancaAdicional(List lsEmpresasCobrancaAdicional) { - this.lsEmpresasCobrancaAdicional = lsEmpresasCobrancaAdicional; - } - - public void onCheck$radioDiario(Event event) { - deselecionaSemana(); - deselecionaMensal(); - } - - public void onCheck$radioSemanal(Event event) { - deselecionaMensal(); - } - - public void onCheck$radioMensal(Event event) { - deselecionaSemana(); - } - - public void onCheck$radioSegunda(Event event) { - selecaoRadioButtonCobrancaAdicional(); - } - - public void onCheck$radioTerca(Event event) { - selecaoRadioButtonCobrancaAdicional(); - } - - public void onCheck$radioQuarta(Event event) { - selecaoRadioButtonCobrancaAdicional(); - } - - public void onCheck$radioQuinta(Event event) { - selecaoRadioButtonCobrancaAdicional(); - } - - public void onCheck$radioSexta(Event event) { - selecaoRadioButtonCobrancaAdicional(); - } - - public void onCheck$radioPrimeiroDiaMes(Event event) { - selecionadoDiasDoMes(); - } - - public void onCheck$radioUltimoDiaMes(Event event) { - selecionadoDiasDoMes(); - } - - private void selecionadoDiasDoMes() { - if(radioPrimeiroDiaMes.isSelected() || radioUltimoDiaMes.isSelected()) { - deselecionaSemana(); - radioMensal.setSelected(true); - radioSemanal.setSelected(false); - } - } - - private void selecaoRadioButtonCobrancaAdicional() { - if(radioSegunda.isSelected() || radioTerca.isSelected() || radioQuarta.isSelected() - || radioQuinta.isSelected() || radioSexta.isSelected()) { - radioSemanal.setSelected(true); - radioDiario.setSelected(false); - radioMensal.setSelected(false); - } - } - - private void deselecionaSemana() { - radioSegunda.setSelected(false); - radioTerca.setSelected(false); - radioQuarta.setSelected(false); - radioQuinta.setSelected(false); - radioSexta.setSelected(false); - } - - private void deselecionaMensal() { - radioPrimeiroDiaMes.setSelected(false); - radioUltimoDiaMes.setSelected(false); - } - - public void onClick$btnSalvarCobrancaAdicional(Event ev) { - - if(!validaInsercaoCobrancaAdicional()) { - return; - } - - boolean novo = true; - - for (CobrancaAdcPuntoVenta p : puntoVenta.getCobrancaAdicionalList()) { - if (p.getCobrancaAddPuntoVenta_id() != null && p.getActivo() && p.equals(cobrancaAux)) { - cobrancaAux = p; - novo = false; - } - } - - if(novo) { - cobrancaAux = new CobrancaAdcPuntoVenta(); - } - - Empresa empresa = (Empresa) cmbEmpresaCobranca.getSelectedItem().getValue(); - - cobrancaAux.setDescricao(descricaoCobranca.getValue()); - cobrancaAux.setEmpresa(empresa); - cobrancaAux.setValor(BigDecimal.valueOf(valorCobrancaAdicional.getValue())); - cobrancaAux.setPuntoVenta(puntoVenta); - cobrancaAux.setDiario(radioDiario.isSelected()); - cobrancaAux.setSemanal(radioSemanal.isSelected()); - cobrancaAux.setMensal(radioMensal.isSelected()); - cobrancaAux.setSegunda(radioSegunda.isSelected()); - cobrancaAux.setTerca(radioTerca.isSelected()); - cobrancaAux.setQuarta(radioQuarta.isSelected()); - cobrancaAux.setQuinta(radioQuinta.isSelected()); - cobrancaAux.setSexta(radioSexta.isSelected()); - cobrancaAux.setPrimeiroDiaUtil(radioPrimeiroDiaMes.isSelected()); - cobrancaAux.setUltimoDiaUtil(radioUltimoDiaMes.isSelected()); - - cobrancaAux.setDataInicial(dataInicioCobranca.getValue()); - cobrancaAux.setDataFinal(dataFimCobranca.getValue()); - - cobrancaAux.setDescontarProximoCiclo(radioProximoCiclo.isSelected()); - cobrancaAux.setDescontarProximoDia(radioProximoDia.isSelected()); - - if(novo) { - puntoVenta.addCobrancaAddPuntoVenta(cobrancaAux); - } - - cobrancaAdicionalList.setData(puntoVenta.getCobrancaAdicionalList()); - } - - private Boolean validaInsercaoCobrancaAdicional() { - try { - if (cmbEmpresaCobranca.getValue() == null) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemEmpresa.value"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - return false; - } - - if (descricaoCobranca.getValue() == null || descricaoCobranca.getValue().isEmpty()) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemDescricao.value"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - return false; - } - - if (dataInicioCobranca.getValue() == null || dataFimCobranca.getValue() == null) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemDatas.value"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - return false; - } - - if (valorCobrancaAdicional.getValue() == null || valorCobrancaAdicional.getValue() == 0) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemValor.value"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - - return false; - } - - if (!( radioDiario.isSelected() || radioMensal.isSelected() || radioSemanal.isSelected() )) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemFrequencia.value"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - - return false; - - } else if(radioSemanal.isSelected()) { //Se escolher semana e nao escolher um dia - if(!( radioSegunda.isSelected() || radioTerca.isSelected() || radioQuarta.isSelected() - || radioQuinta.isSelected() || radioSexta.isSelected())) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemFrequencia.value"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - - return false; - } - } - - if (!(radioProximoCiclo.isSelected() || radioProximoDia.isSelected())) { - Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemPagamentoDinheiro.value"), - Labels.getLabel(TITULO), - Messagebox.OK, Messagebox.EXCLAMATION); - - return false; - } - } catch (Exception e) { - log.error("Erro ao validar a inserção da cobranca adicional no ponto de venda: ", e); - } - - return true; - } - - public void onClick$btnApagarCobrancaAdicional(Event event) { - try{ - int resp = Messagebox.show( - Labels.getLabel("editarPuntoVentaController.MSG.apagarCobrancaAdicional"), - Labels.getLabel(TITULO), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - - if (resp == Messagebox.YES) { - CobrancaAdcPuntoVenta cobranca = (CobrancaAdcPuntoVenta)cobrancaAdicionalList.getSelected(); - - puntoVenta.removeCobrancaAddPuntoVenta(cobranca); - - if (cobranca.getCobrancaAddPuntoVenta_id() != null) { - cobrancaAdcService.borrar(cobranca); - } - - carregarCobrancaAdicional(null); - cobrancaAdicionalList.setData(puntoVenta.getCobrancaAdicionalList()); - } - } catch (Exception e){ - log.error("Erro ao apagar cobranca adicional", e); - } - } - - private void carregarCobrancaAdicional(CobrancaAdcPuntoVenta cobranca) { - if(cobranca != null) { - cobrancaAux = cobranca; - - descricaoCobranca.setValue(cobrancaAux.getDescricao()); - valorCobrancaAdicional.setValue(cobrancaAux.getValor().doubleValue()); - - cmbEmpresaCobranca.setSelectedIndex(lsEmpresasCobrancaAdicional.indexOf(cobrancaAux.getEmpresa())); - - dataInicioCobranca.setValue(cobranca.getDataInicial()); - dataFimCobranca.setValue(cobranca.getDataFinal()); - - radioDiario.setSelected(cobrancaAux.getDiario()); - radioSemanal.setSelected(cobrancaAux.getSemanal()); - radioMensal.setSelected(cobrancaAux.getMensal()); - radioSegunda.setSelected(cobrancaAux.getSegunda()); - radioTerca.setSelected(cobrancaAux.getTerca()); - radioQuarta.setSelected(cobrancaAux.getQuarta()); - radioQuinta.setSelected(cobrancaAux.getQuinta()); - radioSexta.setSelected(cobrancaAux.getSexta()); - - radioPrimeiroDiaMes.setSelected(cobrancaAux.getPrimeiroDiaUtil()); - radioUltimoDiaMes.setSelected(cobrancaAux.getUltimoDiaUtil()); - - radioProximoCiclo.setSelected(cobrancaAux.getDescontarProximoCiclo()); - radioProximoDia.setSelected(cobrancaAux.getDescontarProximoDia()); - } - } - - public void onClick$btnPesquisarHistorico(Event event) { - try{ - CobrancaAdcPuntoVenta cobranca = (CobrancaAdcPuntoVenta) cmbCobrancasPuntoVenta.getSelectedItem().getValue(); - - List historicoCobranca = cobrancaAdcService.buscaHistoricoCobranca(cobranca, dataInicioHistorico.getValue(), dataFimHistorico.getValue()); - - historicoCobrancaList.setData(historicoCobranca); - - } catch (Exception e){ - log.error("Erro ao buscar historico da cobranca adicional", e); - } - } - - @Transactional - public boolean utilizaCobrancaAdicional() { - if(isPerfilFuncionBloqueiaDesbloqueiaPontoVenda) { - return false; - } - Usuario usuarioLogado = usuarioService.obtenerID(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - List listUsuarioPerfil = usuarioLogado.getUsuarioPerfilList(); - for (UsuarioPerfil up : listUsuarioPerfil) { - List listPerfilFuncion = up.getPerfil().getPerfilFuncionList(); - for (PerfilFuncion pf : listPerfilFuncion) { - if(pf.getFuncionSistema().getDescruta().equals(FUNCION_COBRANCA_ADICIONAL)) - return true; - } - } - - return false; - } - - @Transactional - public boolean isPermiteInserirMotivoFormaPago() { - - Usuario usuarioLogado = usuarioService.obtenerID(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - List listUsuarioPerfil = usuarioLogado.getUsuarioPerfilList(); - for (UsuarioPerfil up : listUsuarioPerfil) { - List listPerfilFuncion = up.getPerfil().getPerfilFuncionList(); - for (PerfilFuncion pf : listPerfilFuncion) { - if(pf.getFuncionSistema().getDescruta().equals(FUNCION_INSERI_MOTIVO_FORMA_PAGO)) - return true; - } - } - - return false; - } - - public void onClick$btnPesquisaHistoricoFormaPago(Event ev) throws InterruptedException { - - HibernateSearchObject busqueda = new HibernateSearchObject(HistoricoFormaPagoPuntoVenta.class, pagingHistoricoFormaPago.getPageSize()); - - Empresa empresa = (Empresa) cmbHistoricoEmpresaFormaPago.getSelectedItem().getValue(); - Integer[] formaPagosIds = new Integer[puntoVentaHistoricoFormaPagoListSel.getSize()]; - - if (radIndInclusaoHistoricoFormaPago.isChecked()) { - busqueda.addFilterEqual("indInclusao", Boolean.TRUE); - }else if(radIndEclusaoHistoricoFormaPago.isChecked()) { - busqueda.addFilterEqual("indInclusao", Boolean.FALSE); - } - - busqueda.addFilterGreaterOrEqual("fecAlteracao", DateUtil.inicioFecha(fecInicioAlteracaoHistoricoFormaPago.getValue())); - busqueda.addFilterLessOrEqual("fecAlteracao", DateUtil.fimFecha(fecFimAlteracaoHistoricoFormaPago.getValue())); - - if (empresa != null && empresa.getEmpresaId() != -1) { - busqueda.addFilterEqual("empresaId", empresa.getEmpresaId()); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - List lsFormaPagoSelecionados = new ArrayList(Arrays.asList(puntoVentaHistoricoFormaPagoListSel.getData())); - if (lsFormaPagoSelecionados.size() > 0) { - for (int i = 0; i < lsFormaPagoSelecionados.size(); i++) { - FormaPago formaPago = lsFormaPagoSelecionados.get(i); - formaPagosIds[i] = formaPago.getFormapagoId().intValue(); - } - } - busqueda.addFilterEqual("puntoVenta",puntoVenta); - busqueda.addFilterEqual("activo", Boolean.TRUE); - busqueda.addSortAsc("fecAlteracao"); - - if(formaPagosIds.length > 0) { - busqueda.addFilterIn("formaPagoId", Arrays.asList(formaPagosIds)); - } - plwHistoricoFormaPagoPuntoVenta.init(busqueda, ptovtaHistoricoFormaPagoList, pagingHistoricoFormaPago); - - if (ptovtaHistoricoFormaPagoList.getData().length == 0) { - try { - Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), - Labels.getLabel("busquedaPuntoVentaController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); - } - catch (InterruptedException ex) { - } - } - } - - public void onClick$btnPesquisaFormaPago() { - - executarPesquisaFormaPagoHistorico(); - - - } - - private void executarPesquisaFormaPagoHistorico() { - - HibernateSearchObject busqueda = new HibernateSearchObject(FormaPago.class, pagingFormaPago.getPageSize()); - - busqueda.addFilterILike("descpago", "%" + txtHistoricoDescPago.getValue() + "%"); - busqueda.addFilterEqual("activo", Boolean.TRUE); - busqueda.addFilterNotEqual("formapagoId", -1); - busqueda.addSortAsc("descpago"); - - plwHistoricoFormaPago.init(busqueda, puntoVentaHistoricoFormaPagoList, pagingFormaPago); - - puntoVentaHistoricoFormaPagoList.setItemRenderer(new RenderHistoricoFormaPagoSelecao(new EventListener() { - @Override - public void onEvent(Event arg0) throws Exception { - FormaPago pf = (FormaPago) arg0.getTarget().getAttribute("data"); - if(arg0.getTarget().getAttribute("tipo").equals(RenderHistoricoFormaPagoSelecao.BOTAO_ADICIONAR_FORMAPAGO)) { - if(puntoVentaHistoricoFormaPagoListSel.getListData().isEmpty()) { - puntoVentaHistoricoFormaPagoListSel.addItemNovo(pf); - }else { - for (Object perfilFuncion : puntoVentaHistoricoFormaPagoListSel.getListData()) { - if(!((FormaPago)perfilFuncion).equals(pf)){ - puntoVentaHistoricoFormaPagoListSel.addItemNovo(pf); - break; - } - } - } - puntoVentaHistoricoFormaPagoList.removeItem(pf); - } - } - })); - - if (puntoVentaHistoricoFormaPagoList.getData().length == 0) { - try { - Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), - Labels.getLabel("relatorioVendasBilheteiroController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); - } catch (InterruptedException ex) { - log.error(ex); - } - } - } - - public Boolean getUtilizaCobrancaAdicional() { - return utilizaCobrancaAdicional; - } - - public void setUtilizaCobrancaAdicional(Boolean utilizaCobrancaAdicional) { - this.utilizaCobrancaAdicional = utilizaCobrancaAdicional; - } - - public Intbox getIntTiempoMaxBoletoEnVenta() { - return intTiempoMaxBoletoEnVenta; - } - - public void setIntTiempoMaxBoletoEnVenta(Intbox intTiempoMaxBoletoEnVenta) { - this.intTiempoMaxBoletoEnVenta = intTiempoMaxBoletoEnVenta; - } - - public List getLsOrgaoConcedentes() { - return lsOrgaoConcedentes; - } - - public void setLsOrgaoConcedentes(List lsOrgaoConcedentes) { - this.lsOrgaoConcedentes = lsOrgaoConcedentes; - } - - public Tab getTabEndereco() { - return tabEndereco; - } - - public void setTabEndereco(Tab tabEndereco) { - this.tabEndereco = tabEndereco; - } - - private String mascaraTelefone(String campo) { - campo = formatString(campo,"(###)####-####"); - return campo; - } - - - public Intbox getIntTempoServicoEmVenda() { - return intTempoServicoEmVenda; - } - - public void setIntTempoServicoEmVenda(Intbox intTempoServicoEmVenda) { - this.intTempoServicoEmVenda = intTempoServicoEmVenda; - } - - private static String formatString(String value, String pattern) { - MaskFormatter mf; - try { - mf = new MaskFormatter(pattern); - mf.setValueContainsLiteralCharacters(false); - return mf.valueToString(value); - } catch (Exception e) { - return value; - } - } - - private Boolean isEdicaoDoPuntoVentaEisPermissaoMotivoFormaPago() { - if(puntoVenta.getPuntoventaId()!=null && isPermissaoMotivoFormaPago) { - return true; - } - return false; - } - - - private void obterOValorConstanteIndMotivoBloqueio() { - Constante constante = constanteService.buscarPorNomeConstante(constanteIndMotivoBloqueio); - if (constante != null && StringUtils.isNotBlank(constante.getValorconstante()) - && constante.getValorconstante().equalsIgnoreCase("true")) { - indMotivoBloqueio = true; - } - - } +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.web.gui.controladores.catalogos; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Observable; +import java.util.Observer; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import javax.activation.MimetypesFileTypeMap; +import javax.sql.DataSource; +import javax.swing.text.MaskFormatter; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.Predicate; +import org.apache.commons.lang.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; +import org.springframework.transaction.annotation.Transactional; +import org.zkoss.util.resource.Labels; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.UiException; +import org.zkoss.zk.ui.WrongValueException; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zk.ui.event.ForwardEvent; +import org.zkoss.zk.ui.event.InputEvent; +import org.zkoss.zk.ui.event.SelectEvent; +import org.zkoss.zk.ui.event.UploadEvent; +import org.zkoss.zk.ui.util.Clients; +import org.zkoss.zkplus.databind.BindingListModel; +import org.zkoss.zkplus.databind.BindingListModelList; +import org.zkoss.zul.Button; +import org.zkoss.zul.Checkbox; +import org.zkoss.zul.Combobox; +import org.zkoss.zul.Comboitem; +import org.zkoss.zul.Datebox; +import org.zkoss.zul.Decimalbox; +import org.zkoss.zul.Doublebox; +import org.zkoss.zul.Filedownload; +import org.zkoss.zul.Image; +import org.zkoss.zul.Intbox; +import org.zkoss.zul.ListModelList; +import org.zkoss.zul.Listitem; +import org.zkoss.zul.Messagebox; +import org.zkoss.zul.Paging; +import org.zkoss.zul.Radio; +import org.zkoss.zul.Row; +import org.zkoss.zul.Textbox; +import org.zkoss.zul.api.Bandbox; +import org.zkoss.zul.api.Tab; +import org.zkoss.zul.api.Timebox; + +import com.rjconsultores.ventaboletos.constantes.Constantes; +import com.rjconsultores.ventaboletos.constantes.ConstantesFuncionSistema; +import com.rjconsultores.ventaboletos.entidad.Categoria; +import com.rjconsultores.ventaboletos.entidad.CategoriaBloqueioImpPosterior; +import com.rjconsultores.ventaboletos.entidad.Ciudad; +import com.rjconsultores.ventaboletos.entidad.CobrancaAdcPuntoVenta; +import com.rjconsultores.ventaboletos.entidad.CobrancaAdicionalHistorico; +import com.rjconsultores.ventaboletos.entidad.Colonia; +import com.rjconsultores.ventaboletos.entidad.Constante; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaContaBancaria; +import com.rjconsultores.ventaboletos.entidad.FechamentoParamptovta; +import com.rjconsultores.ventaboletos.entidad.FormaPago; +import com.rjconsultores.ventaboletos.entidad.FormaPagoDet; +import com.rjconsultores.ventaboletos.entidad.HistoricoFormaPagoPuntoVenta; +import com.rjconsultores.ventaboletos.entidad.HistoricoPuntoVenta; +import com.rjconsultores.ventaboletos.entidad.InstiFinanceira; +import com.rjconsultores.ventaboletos.entidad.Moneda; +import com.rjconsultores.ventaboletos.entidad.Nodo; +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; +import com.rjconsultores.ventaboletos.entidad.Parada; +import com.rjconsultores.ventaboletos.entidad.ParamRecoleccion; +import com.rjconsultores.ventaboletos.entidad.PerfilFuncion; +import com.rjconsultores.ventaboletos.entidad.PtoVtaCheckin; +import com.rjconsultores.ventaboletos.entidad.PtoVtaSeguro; +import com.rjconsultores.ventaboletos.entidad.PtoVtaUsuarioBancario; +import com.rjconsultores.ventaboletos.entidad.PtovtaAgencia; +import com.rjconsultores.ventaboletos.entidad.PtovtaAntecipacomissao; +import com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude; +import com.rjconsultores.ventaboletos.entidad.PtovtaCatInd; +import com.rjconsultores.ventaboletos.entidad.PtovtaComissao; +import com.rjconsultores.ventaboletos.entidad.PtovtaDiversos; +import com.rjconsultores.ventaboletos.entidad.PtovtaEmpresa; +import com.rjconsultores.ventaboletos.entidad.PtovtaEmpresaBloqueada; +import com.rjconsultores.ventaboletos.entidad.PtovtaEmpresaContaBancaria; +import com.rjconsultores.ventaboletos.entidad.PtovtaEstoque; +import com.rjconsultores.ventaboletos.entidad.PtovtaExcecaoMultaCanc; +import com.rjconsultores.ventaboletos.entidad.PtovtaHorario; +import com.rjconsultores.ventaboletos.entidad.PtovtaTitular; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.entidad.TipoPuntoVenta; +import com.rjconsultores.ventaboletos.entidad.Usuario; +import com.rjconsultores.ventaboletos.entidad.UsuarioBancario; +import com.rjconsultores.ventaboletos.entidad.UsuarioPerfil; +import com.rjconsultores.ventaboletos.enums.TipoAntifraude; +import com.rjconsultores.ventaboletos.enums.TipoSocio; +import com.rjconsultores.ventaboletos.exception.BusinessException; +import com.rjconsultores.ventaboletos.exception.IntegracionException; +import com.rjconsultores.ventaboletos.exception.ValidacionCampoException; +import com.rjconsultores.ventaboletos.service.CategoriaBloqueioImpPosteriorService; +import com.rjconsultores.ventaboletos.service.CategoriaService; +import com.rjconsultores.ventaboletos.service.CobrancaAdcPuntoVentaService; +import com.rjconsultores.ventaboletos.service.ColoniaService; +import com.rjconsultores.ventaboletos.service.ConstanteService; +import com.rjconsultores.ventaboletos.service.EmpresaService; +import com.rjconsultores.ventaboletos.service.FechamentoParamptovtaService; +import com.rjconsultores.ventaboletos.service.FormaPagoService; +import com.rjconsultores.ventaboletos.service.InstiFinanceiraService; +import com.rjconsultores.ventaboletos.service.MonedaService; +import com.rjconsultores.ventaboletos.service.NodoService; +import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; +import com.rjconsultores.ventaboletos.service.PerfilFuncionService; +import com.rjconsultores.ventaboletos.service.PtoVtaCheckinService; +import com.rjconsultores.ventaboletos.service.PtoVtaSeguroService; +import com.rjconsultores.ventaboletos.service.PtoVtaUsuarioBancarioService; +import com.rjconsultores.ventaboletos.service.PtovtaAntifraudeService; +import com.rjconsultores.ventaboletos.service.PtovtaCatIndService; +import com.rjconsultores.ventaboletos.service.PtovtaComissaoService; +import com.rjconsultores.ventaboletos.service.PtovtaEmpresaBloqueadaService; +import com.rjconsultores.ventaboletos.service.PtovtaEmpresaContaBancariaService; +import com.rjconsultores.ventaboletos.service.PtovtaEmpresaService; +import com.rjconsultores.ventaboletos.service.PtovtaExcecaoMultaCancService; +import com.rjconsultores.ventaboletos.service.PtovtaTitularService; +import com.rjconsultores.ventaboletos.service.PuntoVentaService; +import com.rjconsultores.ventaboletos.service.TipoPuntoVentaService; +import com.rjconsultores.ventaboletos.service.UsuarioBancarioService; +import com.rjconsultores.ventaboletos.service.UsuarioService; +import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; +import com.rjconsultores.ventaboletos.utilerias.CustomEnum; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; +import com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales.FechamentoParamptovtaListItemRenderer; +import com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales.PuntoVendaHistoricoBloqueioListItemRenderer; +import com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales.PuntoVendaHistoricoFormaPagoListItemRenderer; +import com.rjconsultores.ventaboletos.web.utilerias.ConstraintNoEmpty; +import com.rjconsultores.ventaboletos.web.utilerias.ConstraintPorcentagemAllowNull; +import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; +import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxPuntoVenta; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; +import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; +import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox; +import com.rjconsultores.ventaboletos.web.utilerias.MyTextboxDecimal; +import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject; +import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper; +import com.rjconsultores.ventaboletos.web.utilerias.render.FormaPagoDetRender; +import com.rjconsultores.ventaboletos.web.utilerias.render.ParamRecoleccionRender; +import com.rjconsultores.ventaboletos.web.utilerias.render.PtovtaAntecipacomissaoRender; +import com.rjconsultores.ventaboletos.web.utilerias.render.PtovtaEmpresaRender; +import com.rjconsultores.ventaboletos.web.utilerias.render.PtovtaEstoqueRender; +import com.rjconsultores.ventaboletos.web.utilerias.render.PtovtaHorarioRender; +import com.rjconsultores.ventaboletos.web.utilerias.render.PtovtaUsuarioBancarioRender; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderCategoriaBloqueioVendaImpPosterior; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderCobrancaAdcPuntoVenta; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderCobrancaAdcicionalHistorico; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderEmpresaBloquear; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderHistoricoFormaPago; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderHistoricoFormaPagoSelecao; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderParadaPtoVtaCheckin; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtoVtaSeguro; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtovtaAntifraude; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtovtaCatInd; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtovtaComissao; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtovtaExcecaoMultaCanc; +import com.rjconsultores.ws.totvs.service.GeradorTitulosIntegracion; +import com.rjconsultores.ws.totvs.service.GerenciadorEnvioTitulosWS; +import com.rjconsultores.ws.utileria.RetornoTotvs.TipoRetorno; +import com.rjconsultores.wsag.GeradorTitulosAG; +//import com.rjconsultores.wsag.GeradorTitulosAG; +//import com.rjconsultores.wsag.WSAGLog; +import com.rjconsultores.wsag.WSAGLog; + +/** + * + * @author Rafius + */ +@Controller("editarPuntoVentaController") +@Scope("prototype") +public class EditarPuntoVentaController extends MyGenericForwardComposer { + + private static final long serialVersionUID = 1L; + + private static Logger log = LogManager.getLogger(EditarPuntoVentaController.class); + + public static final String FUNCION_TIPO_BOLETO_BLOQUEADO = "COM.RJCONSULTORES.ADMINISTRACION.PUNTOVENTA.TIPOBOLETOBLOQUEADO"; + public static final String FUNCION_COBRANCA_ADICIONAL = "COM.RJCONSULTORES.ADMINISTRACION.PUNTOVENTA.COBRANCAADICIONAL"; + public static final String PERMITE_APENAS_BLQUEIO_DESBLOQUEIO_AGENCIA = "COM.RJCONSULTORES.ADMINISTRACION.PUNTOVENTA.PERMITEAPENASBLOQUEIODESBLOQUEIOAGENCIA"; + public static final String FUNCION_INSERI_MOTIVO_FORMA_PAGO = "COM.RJCONSULTORES.ADMINISTRACION.PUNTOVENTA.PERMITEINSERIMOTIVOFORMAPAGO"; + public static final String TITULO = "editarPuntoVentaController.window.title"; + + + + @Autowired + private PuntoVentaService puntoVentaService; + @Autowired + private EmpresaService empresaService; + @Autowired + private TipoPuntoVentaService tipoPuntoVentaService; + @Autowired + private MonedaService monedaService; + @Autowired + private InstiFinanceiraService ptovtaBancoService; + @Autowired + private NodoService nodoService; + @Autowired + private FormaPagoService formaPagoService; + @Autowired + private ColoniaService coloniaService; + @Autowired + private PtovtaEmpresaService ptovtaEmpresaService; + @Autowired + private PtovtaEmpresaContaBancariaService ptovtaEmpresaContaBancariaService; + @Autowired + private PtoVtaUsuarioBancarioService ptoVtaUsuarioBancarioService; + @Autowired + private UsuarioBancarioService usuarioBancarioService; + @Autowired + private PtovtaComissaoService ptovtaComissaoService; + @Autowired + private PtovtaEmpresaBloqueadaService ptovtaEmpresaBloqueadaService; + @Autowired + private PtoVtaCheckinService ptoVtaCheckinService; + @Autowired + private PtoVtaSeguroService ptoVtaSeguroService; + @Autowired + private CategoriaService categoriaService; + @Autowired + private PtovtaCatIndService ptovtaCatIndService; + @Autowired + private UsuarioService usuarioService; + @Autowired + private FechamentoParamptovtaService fechamentoParamptovtaService; + @Autowired + private CategoriaBloqueioImpPosteriorService categoriaBloqueioImpPosteriorService; + @Autowired + private ConstanteService constanteService; + @Autowired + private PtovtaAntifraudeService ptovtaAntifraudeService; + @Autowired + private PtovtaExcecaoMultaCancService ptovtaExcecaoMultaCancService; + + @Autowired + private PtovtaTitularService ptovtaTitularService; + + @Autowired + private OrgaoConcedenteService orgaoConcedenteService; + + @Autowired + private PerfilFuncionService perfilFuncionService; + + private PuntoVenta puntoVenta; + private Textbox txtCP; + private MyListbox categoriaList; + private MyListbox puntoVentaList; + private MyListbox puntoVentaHistoricoFormaPagoList; + private MyListbox puntoVentaHistoricoFormaPagoListSel; + private MyListbox paramRecoleccionList; + private MyListbox formaPagoList; + private MyListbox ptovtaEmpresaList; + private MyListbox ptovtaEmpresasBloqueadasList; + private MyListbox ptovtaPtoVtaCheckinList; + private MyListbox ptovtaPtoVtaSeguroList; + private MyListbox ptovtaUsuarioBancarioList; + private MyListbox ptovtaAntecipaList; + private MyListbox ptovtaHorarioList; + private MyListbox ptovtaEstoqueList; + private MyListbox ptovtaComissaoList; + private MyListbox ptovtaCatIndList; + private List ptovtaCatIndListTemp; + private MyListbox fechamentoParamptovtaList; + private MyTextbox txtDiasemtransito; + private MyListbox ptovtaHistoricoList; + private MyListbox ptovtaHistoricoFormaPagoList; + private MyListbox categoriasBloqImpPosteriorList; + private MyListbox empresaContaBancariaList; + private Textbox txtChaveAntifraude; + private MyListbox ptovtaAntifraudeList; + private MyListbox ptovtaExcecaoMultaCancList; + private Bandbox bbCategoria; + + private List lsCategoriaBloquear; + + private List lsEmpresasBloquear; + private List lsEmpresas; + private List lsEmpresasSemTodos; + private List lsEmpresasFormapago; + private List lsEmpresaContaBancarias; + private List lsBanco; + private List lsTipoPuntoVenta; + private List lsMoneda; + private List lsColonia; + private List lsNodos; + private List lsFormaPago; + private List lsFormaPagoDet; + private List lsParamRecoleccion; + private List lsUsuarioBancario; + private List lsPtovtaEmpresa; + private List lsPtovtaUsuarioBancario; + private List lsAntecipacomissao; + private List lsHorario; + private List lsEmpresaComissao; + private List lsEstoque; + private List lsPtovtaComissao; + private List lsLogFiles; + private Radio radDatosTarjetaSi; + private Radio radDatosTarjetaNo; + private Radio radAprobacionAutorizado; + private Radio radAprobacionLatente; + private Radio radIndvendsegopcionalSi; + private Radio radIndvendsegopcionalNo; + private Radio radIndvendsegtabelaSi; + private Radio radIndvendsegtabelaNo; + private Radio radIndestansegopcionalSi; + private Radio radIndestansegopcionalNo; + private Radio radIndestansegtabelaSi; + private Radio radIndestansegtabelaNo; + private Radio radIntervalofechamentoDiario; + private Radio radIntervalofechamentoSemanal; + private Radio radIntervalofechamentoDecendial; + private Radio radIntervalofechamentoQuinzenal; + private Radio radIntervalofechamentoMensal; + private Radio radTotvsSi; + private Radio radTotvsNo; + private Radio radTotvsErro; + private Radio radTipoPagamentoBoleto; + private Radio radIndBloquear; + private Radio radIndLiberar; + private Radio radIndInclusaoHistoricoFormaPago; + private Radio radIndEclusaoHistoricoFormaPago; + private Button btnAdicionarEmpresaComissao; + private MyComboboxPuntoVenta cmbPuntoVentaPadre; + private Combobox cmbFormaPago; + private Combobox cmbEmpresaFormaPago; + private Combobox cmbHistoricoEmpresaFormaPago; + private Combobox cmbEmpresa; + private Combobox cmbEmpresaPtoVta; + private Combobox cmbEmpresaPtoVtaUsuarioBancario; + private Combobox cmbEmpresaPtoVtaAntifraude; + private Combobox cmbEmpresaPtoVtaExcecaoMultaCanc; + private Combobox cmbOrgaoConcedente; + private Combobox cmbParada; + private Combobox cmbPtoVtaCheckinParada; + private Combobox cmbEmpresaSeguro; + private Combobox cmbTipoPontoVenta; + private Combobox cmbMoneda; + /* private Combobox cmbNodo; */ + private Combobox cmbBanco; + private Combobox cmbPessoa; + private Combobox cmbTipoConta; + private Combobox cmbForm; + private Combobox cmbLote; + private Combobox cmbCiudad; + private Combobox cmbColonia; + private Combobox cmbConexion; + private Combobox cmbUsuarioBancario; + private Combobox cmbUsuarioBancarioPtoVtaUsuarioBancario; + private Combobox cmbPosicao; + private Combobox cmbReceita; + private Combobox cmbEmpresaComissao; + private Combobox cmbEmpresas; + private Combobox cmbTipoSocio; + private MyComboboxEstandar cmbEmpresasContaBancarias; + private Combobox cmbUsuarioEmpresa; + private Combobox cmbEmpresaFechamentoParamptovta; + private Combobox cmbLogFiles; + private Combobox cmbLogFilesAG; + private Combobox cmbBloqVendaImpPosterior; + private Combobox cmbUsuarioBloq; + private Button btnSalvarFormaPago; + private Button btnApagar; + private Button btnShowLog; + private Doublebox txtCargosExtras; + private MyTextbox txtNome; + private MyTextbox txtNumFax; + private MyTextbox txtCompl; + private MyTextbox txtNumAg; + private MyTextbox txtDigitoAg; + private MyTextbox txtConta; + private MyTextbox txtDigito; + private MyTextbox txtBilhetes; + private MyTextbox txtCarga; + private MyTextbox txtEspecie; + private MyTextbox txtTitularNome; + private MyTextbox txtTitularCpf; + private MyTextbox txtTitularRg; + private MyTextbox txtTitularEmissor; + private MyTextbox txtResponAluguel; + private MyTextbox txtResponTel; + private MyTextbox txtResponEnergia; + private MyTextbox txtNumDoCPuntoVenta; + private MyTextbox txtRazonSocial; + private MyTextbox txtIdEquivalencia; + private MyTextbox dscUsuarioInternet; + private MyTextbox dscContrasenaInternet; + private MyTextbox comentarios; + private MyTextbox txtHistoricoDescPago; + private MyTextboxDecimal importeInicial; + private MyTextboxDecimal importeAdicional; + private Datebox dateAntecipData; + private Datebox dateAbertura; + private Datebox dateFechamento; + private Datebox fecInicioAlteracaoHistoricoFormaPago; + private Datebox fecFimAlteracaoHistoricoFormaPago; + private MyTextboxDecimal txtAntecipRetem; + private MyTextboxDecimal txtAntecipPercentual; + private Image img; + private Timebox timeboxInicio; + private Timebox timeboxFim; + private Intbox txtQuant; + private Intbox txtcodAg; + private Intbox txtMaxCancelacion; + private Textbox txtNumPtoVta; + private Textbox txtNomeBanco; + private Textbox numtelefonodos; + private Textbox numtelefonouno; + private Textbox logResultAG; + private Checkbox checkInformatizada; + private Checkbox checkBilheteInfo; + private Checkbox checkVendaInternet; + private Checkbox checkTeleEntrega; + private Checkbox checkDigitacao; + private Checkbox checkBilhete; + private Checkbox checkOfpsPropria; + private Checkbox checkOfpsTerceiros; + private Checkbox checkCancelaPTA; + private Checkbox checkUTRRepasse; + private Checkbox checkCancelaPassNormal; + private Checkbox checkPtoVtaEmpresaIndTotalBus; + private Checkbox checkPtoVtaEmpresaIndEmbarcada; + private Radio radIndEstanTasaEmbarqueSi; + private Radio radIndEstanTasaEmbarqueNo; + private Radio radIndPermisoTasaEmbarqueSi; + private Radio radIndPermisoTasaEmbarqueNo; + private Radio radIndPermisoTasaEmbarqueVtaManualSi; + private Radio radIndPermisoTasaEmbarqueVtaAgenciaSi; + private Radio radIndVendeSeguroOpcEmbarcadaSi; + private Radio radIndVendeSeguroTabelaEmbarcadaSi; + private Radio radIndTaxaEmbarqueEmbarcadaSi; + private Checkbox checkPtoVtaEmpresaIndTerceirizada; + private Checkbox checkPtoVtaEmpresaIndBloqueada; + private Checkbox checkPtoVtaEmpresaIndMostrarCaja; + private Checkbox checkPtoVtaEmpresaIndImpCompCartao; + private Textbox txtNumeroSitef; + private Textbox txtMerchantStoreAdyen; + private Checkbox ckIsento; + private Checkbox checkSimulaIntegracion; + private Checkbox checkTodosPuntosVenta; + private Checkbox checkDinheiro; + private Checkbox checkCredito; + private Checkbox checkDebito; + private Checkbox checkTF; + private Checkbox checkBOL; + private Checkbox checkAdiantamentoAG; + private Checkbox checkCartaoAG; + private Checkbox checkBoletoAG; + private Checkbox checkDepositoAG; + private Checkbox checkPtovtaCatIndEmbarcada; + private Checkbox checkPtovtaCatIndTotalBus; + private MyTextbox txtNumIEPuntoVenta; + private Datebox fecIntegracion; + private Datebox fecInicioAG; + private Datebox fecFimAG; + private boolean integracionTotvs; + private boolean integracionAG; + private Timebox txtTempoParaImpressao; + private Checkbox ckValidarTempoParaImpressao; + private Checkbox checkLun; + private Checkbox checkMar; + private Checkbox checkMie; + private Checkbox checkJue; + private Checkbox checkVie; + private Checkbox checkSab; + private Checkbox checkDom; + private Checkbox ckIndEstoqueMotorista; + private Checkbox checkBloqDevolveReativaOutroPto; + private Checkbox checkIndQrcodeCatracaRodEAN13; + private Checkbox checkIndVendeFlexBus; + private Checkbox checkIndQrcodeTaxaEmbarqueRodTTL; + private Checkbox ckIndBloqueiaCancelamentoImpressaoPosterior; + private Checkbox ckIndBloqueiaCancelamentoBilheteImpresso; + private Row rowDateFechamento; + private Row rowMotivoBloqueio; + private Textbox motivoBloqueio; + private String logFileSelected; + private Textbox descCorreo; + private String statusAprobacionInicial = ""; + private Decimalbox txtTaxaConvenienciaPorc; + private Doublebox txtMaximoTaxaConveniencia; + private ConstraintPorcentagemAllowNull ct; + private Intbox intTiempoMaxBoletoEnVenta; + private Intbox intTempoServicoEmVenda; + private Tab tabEndereco; + private Tab tabComissao; + private Tab tabBanco; + private Tab tabTitular; + private Tab tabDiversos; + private Tab tabHorario; + private Tab tabFormaPago; + private Tab tabEmpresaVenta; + private Tab tabEmpresaBloqeuada; + private Tab tabLocalidades; + private Tab tabSeguroTaxaEmbarque; + private Tab tabTipoPassageiro; + private Tab tabfechamentoCntCorrente; + private Tab tabBloqueiaVendaImpPosterior; + private Tab tabAnrifraude; + private Tab tabExcecaoMultaCancelamento; + private Tab tabHistorico; + private Tab tabRecoleccion; + private Paging pagingHistoricoFormaPago; + private Paging pagingFormaPago; + private Textbox txtLatitudeLongitude; + private Textbox txtLatitude; + private Textbox txtLongitude; + @Autowired + private transient PagedListWrapper plwHistoricoFormaPagoPuntoVenta; + @Autowired + private transient PagedListWrapper plwHistoricoFormaPago; + + private Set lsCategoriaSel; + + private static final String EMAIL_PATTERN = + "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; + + private static final Pattern pattern = Pattern.compile(EMAIL_PATTERN, Pattern.CASE_INSENSITIVE); + + private static final int TAMANHO_BUFFER = 4096; // 4kb + + PtovtaEmpresa ptovtaEmpresa; + + @Autowired + private DataSource dataSource; + + //CobrancaAdicional + private Textbox descricaoCobranca; + private Doublebox valorCobrancaAdicional; + private List lsEmpresasCobrancaAdicional; + private List lsTodasCobrancas; + private Combobox cmbEmpresaCobranca; + private Combobox cmbCobrancasPuntoVenta; + private Radio radioDiario; + private Radio radioSemanal; + private Radio radioMensal; + private Radio radioSegunda; + private Radio radioTerca; + private Radio radioQuarta; + private Radio radioQuinta; + private Radio radioSexta; + private Radio radioPrimeiroDiaMes; + private Radio radioUltimoDiaMes; + private MyListbox cobrancaAdicionalList; + private MyListbox historicoCobrancaList; + private Radio radioProximoCiclo; + private Radio radioProximoDia; + private CobrancaAdcPuntoVenta cobrancaAux = new CobrancaAdcPuntoVenta(); + private Datebox dataInicioCobranca; + private Datebox dataFimCobranca; + private Datebox dataInicioHistorico; + private Datebox dataFimHistorico; + private Boolean utilizaCobrancaAdicional = false; + private boolean isPerfilFuncionBloqueiaDesbloqueiaPontoVenda; + private boolean isPermissaoMotivoFormaPago; + + private Checkbox checkIndBloqueioDescontoAPI; + private Checkbox checkIndBloqueioDescontoWEB; + private Checkbox checkIndTaxaConvenienciaOrgaoConcedente; + private final String constanteIndMotivoBloqueio= "IND_MOTIVO_BLOQUEIO"; + + @Autowired + private CobrancaAdcPuntoVentaService cobrancaAdcService; + + private List lsOrgaoConcedentes; + + private boolean indMotivoBloqueio; + + public Button getBtnApagar() { + return btnApagar; + } + + public void setBtnApagar(Button btnApagar) { + this.btnApagar = btnApagar; + } + + public void aplicarMascara() { + Clients.evalJavaScript( + "jQuery('#" + txtNumFax.getUuid() + "').mask('(999)9999-9999?9');" + + "jQuery('#" + numtelefonodos.getUuid() + "').mask('(999)9999-9999?9');" + + "jQuery('#" + numtelefonouno.getUuid() + "').mask('(999)9999-9999?9');"); + } + + private List getLogFiles() { + List files = new ArrayList(); + File logDir = new File(System.getProperty("jboss.server.log.dir")); + for (String str : logDir.list()) { + if (str.contains("ws") && !str.contains("zip")) { + files.add(str); + } + } + return files; + } + + @Override + public void doAfterCompose(Component comp) throws Exception { + setCt(new ConstraintPorcentagemAllowNull()); + isPerfilFuncionBloqueiaDesbloqueiaPontoVenda = isPerfilFuncionBloqueiaDesbloqueiaPontoVenda(); + isPermissaoMotivoFormaPago = isPermiteInserirMotivoFormaPago(); + lsCategoriaSel = new HashSet(); + lsCategoriaBloquear = categoriaService.obtenerTodasCategoriasVisibles(); + lsEmpresasBloquear = empresaService.obtenerTodos(); + lsEmpresasCobrancaAdicional = empresaService.obtenerTodos(); + lsEmpresas = obterEmpresasUsuarioLogadoComOpcaoTodas(); + lsEmpresasSemTodos = UsuarioLogado.getUsuarioLogado().getEmpresa(); + lsMoneda = monedaService.obtenerTodos(); + lsBanco = ptovtaBancoService.obtenerTodos(); + lsColonia = new ArrayList(); + + lsFormaPago = formaPagoService.obtenerTodos(); + lsEmpresasFormapago = obterEmpresasUsuarioLogadoComOpcaoTodas(); + + lsTipoPuntoVenta = tipoPuntoVentaService.obtenerTodosExceto(TipoPuntoVenta.TODOS); + lsUsuarioBancario = usuarioBancarioService.obtenerTodos(); + lsLogFiles = getLogFiles(); + puntoVenta = (PuntoVenta) Executions.getCurrent().getArg().get("puntoVenta"); + lsTodasCobrancas = cobrancaAdcService.buscarTodasAsCobrancas(puntoVenta); + lsOrgaoConcedentes = orgaoConcedenteService.obtenerTodos(); + + super.doAfterCompose(comp); + + if(puntoVenta.getIndBloqueiaTipoPassagem()) { + radIndBloquear.setSelected(Boolean.TRUE); + }else { + radIndLiberar.setSelected(Boolean.TRUE); + } + + bbCategoria.addEventListener(Events.ON_CHANGING, new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + autoCompleteBandbox(((InputEvent)event).getValue()); + } + }); + + inserirItensLista(lsCategoriaBloquear); + + getTxtTaxaConvenienciaPorc().setConstraint(getCt()); + cmbBanco.addEventListener("onAfterRender", new org.zkoss.zk.ui.event.EventListener() { + @Override + public void onEvent(Event event) throws Exception { + cmbBanco.setSelectedIndex(lsBanco.indexOf(puntoVenta.getAgenciaId().getInstiFinanceiraId())); + } + }); + + utilizaCobrancaAdicional = utilizaCobrancaAdicional(); + + aplicarMascara(); + + popularCombobox(cmbTipoConta, cmbPessoa, cmbForm, cmbLote, cmbPosicao, cmbReceita, cmbEmpresas, cmbUsuarioEmpresa, cmbEmpresaCobranca, cmbCobrancasPuntoVenta, cmbTipoSocio); + + ptovtaEmpresasBloqueadasList.setItemRenderer(new RenderEmpresaBloquear()); + ptovtaPtoVtaCheckinList.setItemRenderer(new RenderParadaPtoVtaCheckin()); + ptovtaPtoVtaSeguroList.setItemRenderer(new RenderPtoVtaSeguro()); + cobrancaAdicionalList.setItemRenderer(new RenderCobrancaAdcPuntoVenta()); + historicoCobrancaList.setItemRenderer(new RenderCobrancaAdcicionalHistorico()); + ptovtaCatIndList.setItemRenderer(new RenderPtovtaCatInd()); + ptovtaCatIndListTemp = new ArrayList(); + ptovtaHistoricoList.setItemRenderer(new PuntoVendaHistoricoBloqueioListItemRenderer()); + categoriasBloqImpPosteriorList.setItemRenderer(new RenderCategoriaBloqueioVendaImpPosterior()); + ptovtaHistoricoFormaPagoList.setItemRenderer(new PuntoVendaHistoricoFormaPagoListItemRenderer()); + puntoVentaHistoricoFormaPagoListSel.setItemRenderer(new RenderHistoricoFormaPago(new EventListener() { + @Override + public void onEvent(Event arg0) throws Exception { + FormaPago pf = (FormaPago) arg0.getTarget().getAttribute("data"); + for (Object formaPago : puntoVentaHistoricoFormaPagoListSel.getListData()) { + if(((FormaPago)formaPago).equals(pf)){ + puntoVentaHistoricoFormaPagoListSel.removeItem(pf); + executarPesquisaFormaPagoHistorico(); + break; + } + } + } + }));; + + cobrancaAdicionalList.addEventListener("onDoubleClick", new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + CobrancaAdcPuntoVenta cobranca = (CobrancaAdcPuntoVenta) cobrancaAdicionalList.getSelected(); + carregarCobrancaAdicional(cobranca); + } + }); + + ptovtaComissaoList.setItemRenderer(new RenderPtovtaComissao()); + ptovtaComissaoList.addEventListener("onDoubleClick", new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + PtovtaComissao ptovtaComissao = (PtovtaComissao) ptovtaComissaoList.getSelected(); + abrirPtovtaComissao(ptovtaComissao); + } + }); + + numtelefonodos.addEventListener(Events.ON_CHANGE, new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + numtelefonodos.setValue(mascaraTelefone(numtelefonodos.getValue())); + } + }); + + numtelefonouno.addEventListener(Events.ON_CHANGE, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + numtelefonouno.setValue(mascaraTelefone(numtelefonouno.getValue())); + } + }); + + txtNumFax.addEventListener(Events.ON_CHANGE, new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + txtNumFax.setValue(mascaraTelefone(txtNumFax.getValue())); + } + }); + + + try { + fechamentoParamptovtaList.setItemRenderer(new FechamentoParamptovtaListItemRenderer()); + + if (puntoVenta.getPuntoventaId() != null) { + puntoVenta = puntoVentaService.obtenerID(puntoVenta.getPuntoventaId()); + + //chamadas de inicialização para evitar LazyInitializationException + puntoVenta.getLsFormaPagoDet().size(); + puntoVenta.getLsParamRecoleccion().size(); + puntoVenta.getLsPtovtaEmpresa().size(); + puntoVenta.getPtovtaAntecipacomissaoList().size(); + puntoVenta.getPtovtaEstoqueList().size(); + puntoVenta.getPtovtaHorarioList().size(); + puntoVenta.getLsPtovtaUsuarioBancario().size(); + + + lsEmpresaComissao = empresaService.buscarNotInPuntoVtaComissao(puntoVenta); + + lsPtovtaComissao = ptovtaComissaoService.buscarByPuntaVenta(puntoVenta); + + btnAdicionarEmpresaComissao.setDisabled(false); + ptovtaComissaoList.setData(lsPtovtaComissao); + + ptovtaEmpresasBloqueadasList.setData(puntoVenta.getPtovtaEmpresaBloqueadaList()); + ptovtaPtoVtaCheckinList.setData(puntoVenta.getPtovtaCheckinList()); + ptovtaPtoVtaSeguroList.setData(puntoVenta.getPtovtaSeguroList()); + ptovtaCatIndList.setData(puntoVenta.getPtovtaCatIndList()); + ptovtaCatIndListTemp.addAll(puntoVenta.getPtovtaCatIndList()); + List lsHistoricoPuntoVentaOrdenada =puntoVenta.getHistoricoPuntoVentaList(); + + Collections.sort(lsHistoricoPuntoVentaOrdenada, new Comparator() { + public int compare(Object o1, Object o2) { + HistoricoPuntoVenta c1 = (HistoricoPuntoVenta) o1; + HistoricoPuntoVenta c2 = (HistoricoPuntoVenta) o2; + return c1.getFecBloqueio().compareTo( c2.getFecBloqueio()); + + } + }); + ptovtaHistoricoList.setData(lsHistoricoPuntoVentaOrdenada); + ptovtaHistoricoFormaPagoList.setData(puntoVenta.getHistoricoFormaPagoPuntoVentaList()); + categoriasBloqImpPosteriorList.setData(puntoVenta.getCategoriaBloqImpPosteriorList()); + cobrancaAdicionalList.setData(puntoVenta.getCobrancaAdicionalList()); + + if (puntoVenta.getColonia() != null) { + cmbCiudad.setText(puntoVenta.getColonia().getCiudad().getNombciudad()); + cmbColonia.setText(puntoVenta.getColonia().getDesccolonia()); + } + + if (puntoVenta.getNumfax() != null) { + txtNumFax.setValue(puntoVenta.getNumfax()); + } + + try { + if (puntoVenta.getNumtelefonouno() != null) { + numtelefonouno.setValue(puntoVenta.getNumtelefonouno()); + } + }catch (WrongValueException e) { + numtelefonouno.setValue(""); + Messagebox.show("Telefone fora do padrão, Preencha novamente", + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + } + + try { + if (puntoVenta.getNumtelefonodos() != null) { + numtelefonodos.setValue(puntoVenta.getNumtelefonodos()); + } + }catch (WrongValueException e) { + numtelefonodos.setValue(""); + Messagebox.show("Celular fora do padrão, Preencha novamente", + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + } + + if (puntoVenta.getNumDoCPuntoVenta() != null) { + txtNumDoCPuntoVenta.setValue(puntoVenta.getNumDoCPuntoVenta()); + } + + if (puntoVenta.getRazonSocial() != null) { + txtRazonSocial.setValue(puntoVenta.getRazonSocial()); + } + + List params = fechamentoParamptovtaService.buscaParametrosPorPuntoventa(puntoVenta); + fechamentoParamptovtaList.setData(params); + + if(puntoVenta.getIndBloqueaCancTrocaPassNormal() != null){ + if(puntoVenta.getIndBloqueaCancTrocaPassNormal()){ + checkCancelaPassNormal.setChecked(true); + }else{ + checkCancelaPassNormal.setChecked(false); + } + } + + if(puntoVenta.getIndBloqueaCancTrocaPTA() != null){ + if(puntoVenta.getIndBloqueaCancTrocaPTA()){ + checkCancelaPTA.setChecked(true); + }else{ + checkCancelaPTA.setChecked(false); + } + } + + if(puntoVenta.getIndRepassaUTR() != null){ + if(puntoVenta.getIndRepassaUTR()){ + checkUTRRepasse.setChecked(true); + }else{ + checkUTRRepasse.setChecked(false); + } + } + if(puntoVenta.getTipoSocio() != null) { + cmbTipoSocio.setValue(puntoVenta.getTipoSocio().toString()); + } + if(puntoVenta.getTitularId() != null) { + puntoVenta.setTitularId(ptovtaTitularService.obtenerID(puntoVenta.getTitularId().getPtovtaTitularId()));; + } + } + + puntoVentaList = (MyListbox) Executions.getCurrent().getArg().get("puntoVentaList"); + + if (puntoVenta.getPuntoventaId() != null) { + if (puntoVenta.getStatusaprobacion() != null) { + if (puntoVenta.getStatusaprobacion().equals("A")) { + radAprobacionAutorizado.setChecked(true); + } else if (puntoVenta.getStatusaprobacion().equals("L")) { + radAprobacionLatente.setChecked(true); + } + } + } + + statusAprobacionInicial = radAprobacionAutorizado.isChecked() ? "A" : "L"; + + obterOValorConstanteIndMotivoBloqueio(); + if (indMotivoBloqueio) { + rowMotivoBloqueio.setVisible(true); + } + + + if (puntoVenta.getPuntoventaId() != null) { + + motivoBloqueio.setValue(puntoVenta.getMotivoBloqueio()); + + if (puntoVenta.getAgenciaId() != null) { + + if (puntoVenta.getAgenciaId().getInstiFinanceiraId() != null) { + txtNomeBanco.setText(puntoVenta.getAgenciaId().getInstiFinanceiraId().getCodigo()); + } + + if (puntoVenta.getAgenciaId().getPessoa() != null) { + if (puntoVenta.getAgenciaId().getPessoa().equals("F")) { + cmbPessoa.setSelectedIndex(0); + } else if (puntoVenta.getAgenciaId().getPessoa().equals("J")) { + cmbPessoa.setSelectedIndex(1); + } + } + + if (puntoVenta.getAgenciaId().getTipo() != null) { + if (puntoVenta.getAgenciaId().getTipo().equals("CC")) { + cmbTipoConta.setSelectedIndex(0); + } else if (puntoVenta.getAgenciaId().getTipo().equals("P")) { + cmbTipoConta.setSelectedIndex(1); + } + } + + } else { + puntoVenta.setAgenciaId(new PtovtaAgencia()); + } + if (puntoVenta.getDateAbertura() != null) { + dateAbertura.setValue(puntoVenta.getDateAbertura()); + } + + if (radAprobacionLatente.isChecked()) { + dateFechamento.setValue(puntoVenta.getDateFechamento()); + rowDateFechamento.setVisible(true); + } + } else { + dateAbertura.setValue(new Date()); + } + + if (puntoVenta.getPuntoventaId() != null) { + if (puntoVenta.getIndIntegracion() != null) { + + if (puntoVenta.getIndIntegracion().equals(TipoRetorno.CONCLUIDA.getValor())) { + radTotvsSi.setChecked(true); + } else if (puntoVenta.getIndIntegracion().equals(TipoRetorno.JA_CADASTRADA.getValor())) { + radTotvsNo.setChecked(true); + } else if (puntoVenta.getIndIntegracion().equals(TipoRetorno.ERRO.getValor())) { + radTotvsErro.setChecked(true); + } + } + if (puntoVenta.getNumIEPuntoVenta() != null) { + if (puntoVenta.getNumIEPuntoVenta().equals("ISENTO")) { + ckIsento.setChecked(true); + txtNumIEPuntoVenta.setDisabled(true); + } + } + + try { + String agencia = puntoVenta.getAgenciaId() == null ? "" : puntoVenta.getAgenciaId().getNumagencia(); + String[] agenciaComp = agencia == null ? null : agencia.split("-"); + txtNumAg.setValue(agencia == null ? "" : agenciaComp[0]); + txtDigitoAg.setValue(agencia == null ? "" : agenciaComp[1]); + } catch (Exception e) { + } + } + + if (puntoVenta.getPuntoventaId() != null) { + if (puntoVenta.getDiversosId() != null) { + if (puntoVenta.getDiversosId().getInformatizada() != null) { + if (puntoVenta.getDiversosId().getInformatizada()) { + checkInformatizada.setChecked(true); + } else { + checkInformatizada.setChecked(false); + } + } + + if (puntoVenta.getDiversosId().getBilheteInfo() != null) { + if (puntoVenta.getDiversosId().getBilheteInfo()) { + checkBilheteInfo.setChecked(true); + } else { + checkBilheteInfo.setChecked(false); + } + } + + if (puntoVenta.getDiversosId().getPosicao() != null) { + if (puntoVenta.getDiversosId().getPosicao().equals("FEL")) { + cmbPosicao.setSelectedIndex(0); + } else if (puntoVenta.getDiversosId().getPosicao().equals("EL")) { + cmbPosicao.setSelectedIndex(1); + } + } + + if (puntoVenta.getDiversosId().getVendaInternet() != null) { + if (puntoVenta.getDiversosId().getVendaInternet()) { + checkVendaInternet.setChecked(true); + } else { + checkVendaInternet.setChecked(false); + } + } + + if (puntoVenta.getDiversosId().getTeleEntrega() != null) { + if (puntoVenta.getDiversosId().getTeleEntrega()) { + checkTeleEntrega.setChecked(true); + } else { + checkTeleEntrega.setChecked(false); + } + } + + if (puntoVenta.getDiversosId().getDigitacaoSeq() != null) { + if (puntoVenta.getDiversosId().getDigitacaoSeq()) { + checkDigitacao.setChecked(true); + } else { + checkDigitacao.setChecked(false); + } + } + + if (puntoVenta.getDiversosId().getTrabalhaBilhete() != null) { + if (puntoVenta.getDiversosId().getTrabalhaBilhete()) { + checkBilhete.setChecked(true); + } else { + checkBilhete.setChecked(false); + } + } + + if (puntoVenta.getDiversosId().getOfpsPropria() != null) { + if (puntoVenta.getDiversosId().getOfpsPropria()) { + checkOfpsPropria.setChecked(true); + } else { + checkOfpsPropria.setChecked(false); + } + } + + if (puntoVenta.getDiversosId().getOfpsTerceiros() != null) { + if (puntoVenta.getDiversosId().getOfpsTerceiros()) { + checkOfpsTerceiros.setChecked(true); + } else { + checkOfpsTerceiros.setChecked(false); + } + } + + } else { + puntoVenta.setDiversosId(new PtovtaDiversos()); + } + } + + if (puntoVenta.getPuntoventaId() != null) { + if (puntoVenta.getTitularId() != null) { + if (puntoVenta.getTitularId().getImagem() != null) { + img.setContent(new org.zkoss.image.AImage("imagem", + puntoVenta.getTitularId().getImagem())); + } + } else { + puntoVenta.setTitularId(new PtovtaTitular()); + } + } + + formaPagoList.setItemRenderer(new FormaPagoDetRender()); + if (puntoVenta.getLsFormaPagoDet() == null) { + puntoVenta.setLsFormaPagoDet(new ArrayList()); + } + lsFormaPagoDet = puntoVenta.getLsFormaPagoDet(); + formaPagoList.setData(lsFormaPagoDet); + + paramRecoleccionList.setItemRenderer(new ParamRecoleccionRender()); + if (puntoVenta.getLsParamRecoleccion() == null) { + puntoVenta.setLsParamRecoleccion(new ArrayList()); + } + + lsParamRecoleccion = puntoVenta.getLsParamRecoleccion(); + paramRecoleccionList.setData(lsParamRecoleccion); + + ptovtaEmpresaList.setItemRenderer(new PtovtaEmpresaRender()); + ptovtaEmpresaList.addEventListener("onDoubleClick", new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + PtovtaEmpresa ptovtaEmpresa = (PtovtaEmpresa) ptovtaEmpresaList.getSelected(); + editarPtovtaEmpresa(ptovtaEmpresa); + } + }); + + if (puntoVenta.getLsPtovtaEmpresa() == null) { + puntoVenta.setLsPtovtaEmpresa(new ArrayList()); + } + + lsPtovtaEmpresa = puntoVenta.getLsPtovtaEmpresa(); + ptovtaEmpresaList.setData(lsPtovtaEmpresa); + + ptovtaAntecipaList.setItemRenderer(new PtovtaAntecipacomissaoRender()); + if (puntoVenta.getPtovtaAntecipacomissaoList() == null) { + puntoVenta.setPtovtaAntecipacomissaoList(new ArrayList()); + } + + lsAntecipacomissao = puntoVenta.getPtovtaAntecipacomissaoList(); + ptovtaAntecipaList.setData(lsAntecipacomissao); + + ptovtaHorarioList.setItemRenderer(new PtovtaHorarioRender()); + if (puntoVenta.getPtovtaHorarioList() == null) { + puntoVenta.setPtovtaHorarioList(new ArrayList()); + } + + lsHorario = puntoVenta.getPtovtaHorarioList(); + ptovtaHorarioList.setData(lsHorario); + + ptovtaEstoqueList.setItemRenderer(new PtovtaEstoqueRender()); + if (puntoVenta.getPtovtaEstoqueList() == null) { + puntoVenta.setPtovtaEstoqueList(new ArrayList()); + } + + lsEstoque = puntoVenta.getPtovtaEstoqueList(); + ptovtaEstoqueList.setData(lsEstoque); + + ptovtaUsuarioBancarioList.setItemRenderer(new PtovtaUsuarioBancarioRender()); + if (puntoVenta.getLsPtovtaUsuarioBancario() == null) { + puntoVenta.setLsPtovtaUsuarioBancario(new ArrayList()); + } + + lsPtovtaUsuarioBancario = puntoVenta.getLsPtovtaUsuarioBancario(); + ptovtaUsuarioBancarioList.setData(lsPtovtaUsuarioBancario); + + if (puntoVenta.getPuntoventaId() == null) { + btnApagar.setVisible(Boolean.FALSE); + } else { + if (puntoVenta.getParada() != null) { + cmbParada.setText(puntoVenta.getParada().getDescparada()); + } + } + + empresaContaBancariaList.setMultiple(true); + empresaContaBancariaList.setData(new ArrayList(0)); + } catch (Exception e) { + log.error("Punto de Venta: ", e); + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } + + txtNome.focus(); + if (puntoVenta.getValidaTempoParaImpressao() != null) { + txtTempoParaImpressao.setDisabled(!puntoVenta.getValidaTempoParaImpressao()); + } + + ptovtaAntifraudeList.setItemRenderer(new RenderPtovtaAntifraude()); + ptovtaAntifraudeList.setData(puntoVenta.getPtovtaAntifraudes() == null? Collections.emptyList():puntoVenta.getPtovtaAntifraudes()); + ptovtaAntifraudeList.addEventListener("onDoubleClick", new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + PtovtaAntifraude a = (PtovtaAntifraude) ptovtaAntifraudeList.getSelected(); + verPtovtaAntifraude(a); + } + }); + + ptovtaExcecaoMultaCancList.setItemRenderer(new RenderPtovtaExcecaoMultaCanc()); + ptovtaExcecaoMultaCancList.setData(puntoVenta.getPtovtaExcecaoMultaCancList() == null ? Collections.emptyList() : puntoVenta.getPtovtaExcecaoMultaCancList()); + tabRecoleccion.setVisible(isPerfilFuncionRecollecion()); + validaPerfilFuncionBloqueiaDesbloqueiaPontoVenda(); + + txtLatitudeLongitude.addEventListener("onChanging", new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + if (event instanceof InputEvent) { + InputEvent inputEvent = (InputEvent) event; + if (inputEvent.getValue() != null) { + List coordinates = Arrays.asList(inputEvent.getValue().split("\\s*,\\s*")); + if (!coordinates.isEmpty() && coordinates.size() == 2) { + Float latitude = new BigDecimal(coordinates.get(0)).floatValue(); + Float longitude = new BigDecimal(coordinates.get(1)).floatValue(); + txtLatitude.setValue(String.valueOf(latitude)); + txtLongitude.setValue(String.valueOf(longitude)); + txtLatitudeLongitude.setValue(null); + txtLatitudeLongitude.setText(null); + puntoVenta.setLatitude(latitude); + puntoVenta.setLongitude(longitude); + event.stopPropagation(); + } + } + } + } + + }); + + + + } + + /** + * Desabilita todos os campos deixando apenas o status de aprovação, aberto/fechado. + * Caso adicionar novos campos, favor tratar neste método + */ + private void validaPerfilFuncionBloqueiaDesbloqueiaPontoVenda() { + if(isPerfilFuncionBloqueiaDesbloqueiaPontoVenda) { + tabEndereco.setVisible(false); + tabComissao.setVisible(false); + tabBanco.setVisible(false); + tabTitular.setVisible(false); + tabDiversos.setVisible(false); + tabHorario.setVisible(false); + tabFormaPago.setVisible(false); + tabEmpresaVenta.setVisible(false); + tabEmpresaBloqeuada.setVisible(false); + tabLocalidades.setVisible(false); + tabSeguroTaxaEmbarque.setVisible(false); + tabTipoPassageiro.setVisible(false); + tabfechamentoCntCorrente.setVisible(false); + tabBloqueiaVendaImpPosterior.setVisible(false); + tabAnrifraude.setVisible(false); + tabExcecaoMultaCancelamento.setVisible(false); + tabHistorico.setVisible(false); + tabRecoleccion.setVisible(false); + //Campos + txtNome.setDisabled(true); + txtIdEquivalencia.setDisabled(true); + txtNumPtoVta.setDisabled(true); + txtMaxCancelacion.setDisabled(true); + radTotvsSi.setDisabled(true); + radTotvsNo.setDisabled(true); + radTotvsErro.setDisabled(true); + radTipoPagamentoBoleto.setDisabled(true); + radIndBloquear.setDisabled(true); + radIndLiberar.setDisabled(true); + txtMaxCancelacion.setDisabled(true); + cmbParada.setDisabled(true); + cmbEmpresa.setDisabled(true); + cmbTipoPontoVenta.setDisabled(true); + cmbMoneda.setDisabled(true); + cmbPuntoVentaPadre.setDisabled(true); + numtelefonouno.setDisabled(true); + numtelefonodos.setDisabled(true); + txtNumFax.setDisabled(true); + //cmbNodo + cmbConexion.setDisabled(true); + cmbUsuarioBancario.setDisabled(true); + dscUsuarioInternet.setDisabled(true); + dscContrasenaInternet.setDisabled(true); + txtNumDoCPuntoVenta.setDisabled(true); + txtRazonSocial.setDisabled(true); + txtNumIEPuntoVenta.setDisabled(true); + ckIsento.setDisabled(true); + ckValidarTempoParaImpressao.setDisabled(true); + comentarios.setDisabled(true); + ckIndEstoqueMotorista.setDisabled(true); + txtMaximoTaxaConveniencia.setDisabled(true); + checkBloqDevolveReativaOutroPto.setDisabled(true); + ckIndBloqueiaCancelamentoImpressaoPosterior.setDisabled(true); + ckIndBloqueiaCancelamentoBilheteImpresso.setDisabled(true); + checkCancelaPassNormal.setDisabled(true); + checkCancelaPTA.setDisabled(true); + checkUTRRepasse.setDisabled(true); + intTiempoMaxBoletoEnVenta.setDisabled(true); + intTempoServicoEmVenda.setDisabled(true); + checkIndQrcodeCatracaRodEAN13.setDisabled(true); + checkIndVendeFlexBus.setDisabled(true); + checkIndQrcodeTaxaEmbarqueRodTTL.setDisabled(true); + dateAbertura.setDisabled(true); + txtTaxaConvenienciaPorc.setDisabled(true); + checkIndBloqueioDescontoAPI.setDisabled(true); + checkIndBloqueioDescontoWEB.setDisabled(true); + checkIndTaxaConvenienciaOrgaoConcedente.setDisabled(true); + } + + } + + @Transactional + public boolean isPerfilFuncionBloqueiaDesbloqueiaPontoVenda() { + Usuario usuarioLogado = usuarioService.obtenerID(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + List listUsuarioPerfil = usuarioLogado.getUsuarioPerfilList(); + for (UsuarioPerfil up : listUsuarioPerfil) { + List listPerfilFuncion = up.getPerfil().getPerfilFuncionList(); + for (PerfilFuncion pf : listPerfilFuncion) { + if(pf.getFuncionSistema().getDescruta().equals(PERMITE_APENAS_BLQUEIO_DESBLOQUEIO_AGENCIA)) + return true; + } + } + + return false; + } + + + public boolean isPerfilFuncionRecollecion() { + return perfilFuncionService.usuarioPossuiPermissaoFuncionalidade(UsuarioLogado.getUsuarioLogado().getUsuarioId(), ConstantesFuncionSistema.FUNCION_RECOLECCION); + } + + + private List obterEmpresasUsuarioLogadoComOpcaoTodas() { + List listaEmpresas = new ArrayList(); + listaEmpresas.add(empresaService.obtenerID(-1)); + listaEmpresas.addAll(UsuarioLogado.getUsuarioLogado().getEmpresa()); + return listaEmpresas; + } + + private void downloadLogIntegracao(Combobox cmb){ + String fileName = System.getProperty("jboss.server.log.dir") + "/" + cmb.getSelectedItem().getValue().toString(); + String fileZip = System.getProperty("jboss.server.log.dir") + "/" + cmb.getSelectedItem().getValue().toString().replace("log", "zip"); + FileInputStream inputStream; + try { + excluirArquivosZip(); + compactarArquivo(fileZip, fileName); + File file = new File(fileZip); + if (file.exists()) { + inputStream = new FileInputStream(file); + Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(file), file.getName()); + } + file.delete(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void onClick$btnAddCategoriaBloqueioImpPosterior(Event event) { + CategoriaBloqueioImpPosterior cat = new CategoriaBloqueioImpPosterior(); + if (cmbBloqVendaImpPosterior.getSelectedItem() == null) { + return; + } + cat.setCategoria((Categoria)cmbBloqVendaImpPosterior.getSelectedItem().getValue()); + cat.setPuntoventa(puntoVenta); + + puntoVenta.addCategoriaBloqImpPosterior(cat); + + categoriasBloqImpPosteriorList.setData(puntoVenta.getCategoriaBloqImpPosteriorList()); + } + + public void onClick$btnRemoveCategoriaBloqueioImpPosterior(Event event) { + try{ + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.borrarCategoriaBloqueioImpPosterior"), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + CategoriaBloqueioImpPosterior cat = (CategoriaBloqueioImpPosterior)categoriasBloqImpPosteriorList.getSelected(); + + puntoVenta.removeCategoriaBloqImpPosterior(cat); + categoriaBloqueioImpPosteriorService.borrar(cat); + + categoriasBloqImpPosteriorList.setData(puntoVenta.getCategoriaBloqImpPosteriorList()); + } + } catch (Exception e){ + log.error("", e); + } + } + + public void onClick$btnDownload(Event event) { + downloadLogIntegracao(cmbLogFiles); + } + + public void onClick$btnDownloadAG(Event event) { + downloadLogIntegracao(cmbLogFilesAG); + } + + @Transactional + public boolean validaFuncionTipoBoletoBloqueado() { + if(isPerfilFuncionBloqueiaDesbloqueiaPontoVenda) { + return false; + } + List listClavesPermisos = new ArrayList(); + + Usuario usuarioLogado = usuarioService.obtenerID(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + List listUsuarioPerfil = usuarioLogado.getUsuarioPerfilList(); + for (UsuarioPerfil up : listUsuarioPerfil) { + List listPerfilFuncion = up.getPerfil().getPerfilFuncionList(); + for (PerfilFuncion pf : listPerfilFuncion) { + listClavesPermisos.add(pf.getFuncionSistema().getDescruta()); + } + } + + + if (listClavesPermisos.contains(FUNCION_TIPO_BOLETO_BLOQUEADO)) { + return true; + } + + return false; + } + + public void clearCombobox(Combobox combobox) { + + int size = combobox.getItemCount(); + + for (int i = size - 1; i >= 0; i--) { + combobox.removeItemAt(i); + } + } + + public void popularCombobox(Combobox cmbConta, Combobox cmbPessoa, Combobox cmbForm, Combobox cmbLote, Combobox cmbPosicao, Combobox cmbReceita, Combobox cmbEmpresas, Combobox cmbUsuarioEmpresa, Combobox cmbEmpresaCobranca, Combobox cmbCobrancasPuntoVenta, Combobox cmbTipoSocio) throws Exception { + + clearCombobox(cmbConta); + clearCombobox(cmbPessoa); + clearCombobox(cmbForm); + clearCombobox(cmbLote); + clearCombobox(cmbPosicao); + clearCombobox(cmbEmpresas); + clearCombobox(cmbUsuarioEmpresa); + clearCombobox(cmbEmpresaCobranca); + clearCombobox(cmbCobrancasPuntoVenta); + + for (CobrancaAdcPuntoVenta cb : lsTodasCobrancas) { + Comboitem comboItem = new Comboitem(cb.getDescricao()); + comboItem.setValue(cb); + comboItem.setParent(cmbCobrancasPuntoVenta); + } + + for (Empresa e : lsEmpresasCobrancaAdicional) { + Comboitem comboItem = new Comboitem(e.getNombempresa()); + comboItem.setValue(e); + comboItem.setParent(cmbEmpresaCobranca); + } + + for (Empresa e : lsEmpresasBloquear) { + Comboitem comboItem = new Comboitem(e.getNombempresa()); + comboItem.setValue(e); + comboItem.setParent(cmbEmpresas); + } + + for (PtovtaAgencia.enumTipoConta p : PtovtaAgencia.enumTipoConta.values()) { + Comboitem comboItem = new Comboitem(p.descricao()); + comboItem.setValue(p.valor()); + comboItem.setParent(cmbConta); + } + + for (PtovtaAgencia.enumTipoPessoa p : PtovtaAgencia.enumTipoPessoa.values()) { + Comboitem comboItem = new Comboitem(p.descricao()); + comboItem.setValue(p.valor()); + comboItem.setParent(cmbPessoa); + } + + for (PtovtaEstoque.gerarEnum p : PtovtaEstoque.gerarEnum.values()) { + Comboitem comboItem = new Comboitem(p.descricao()); + comboItem.setValue(p.valor()); + comboItem.setParent(cmbLote); + } + + for (PtovtaEstoque.gerarEnum p : PtovtaEstoque.gerarEnum.values()) { + Comboitem comboItem = new Comboitem(p.descricao()); + comboItem.setValue(p.valor()); + comboItem.setParent(cmbForm); + } + + for (PtovtaDiversos.gerarEnum p : PtovtaDiversos.gerarEnum.values()) { + Comboitem comboItem = new Comboitem(p.descricao()); + comboItem.setValue(p.valor()); + comboItem.setParent(cmbPosicao); + } + + for (PtovtaComissao.Receita p : PtovtaComissao.Receita.values()) { + Comboitem comboItem = new Comboitem(p.descricao()); + comboItem.setValue(p.valor()); + comboItem.setParent(cmbReceita); + } + + if (lsEmpresas != null && !lsEmpresas.isEmpty()) { + Empresa empresaTodos = new Empresa(); + lsEmpresas.add(empresaTodos); + for (Empresa e : lsEmpresas) { + Comboitem comboItem = new Comboitem(e.getNombempresa()); + comboItem.setValue(e); + comboItem.setParent(cmbUsuarioEmpresa); + } + } + + + for (TipoSocio tipoSocio : TipoSocio.values()) { + Comboitem comboItem = new Comboitem(tipoSocio.toString()); + comboItem.setValue(tipoSocio); + comboItem.setParent(cmbTipoSocio); + } + + + } + + public void onSelect$cmbBanco() { + InstiFinanceira banco = (InstiFinanceira) cmbBanco.getSelectedItem().getValue(); + txtNomeBanco.setValue(banco.getCodigo()); + } + + public void onSelect$cmbEmpresaPtoVta() { + Empresa empresa = (Empresa) cmbEmpresaPtoVta.getSelectedItem().getValue(); + lsEmpresaContaBancarias = ptovtaBancoService.buscarContasBancariasPorIdEmpresa(empresa.getEmpresaId()); + + empresaContaBancariaList.setData(new ArrayList(0)); + + if (lsEmpresaContaBancarias != null && !lsEmpresaContaBancarias.isEmpty()) { + empresaContaBancariaList.setData(lsEmpresaContaBancarias); +// cmbEmpresasContaBancarias.setModel(new BindingListModelList(lsEmpresaContaBancarias, true)); + } else { +// cmbEmpresasContaBancarias.setModel(new BindingListModelList(new ArrayList(), true)); +// cmbEmpresasContaBancarias.setSelectedItem(null); + } + } + + public void onClick$ckIsento(Event ev) { + if (ckIsento.isChecked()) { + puntoVenta.setNumIEPuntoVenta("ISENTO"); + txtNumIEPuntoVenta.setValue("ISENTO"); + txtNumIEPuntoVenta.setDisabled(true); + + } else { + puntoVenta.setNumIEPuntoVenta(""); + txtNumIEPuntoVenta.setValue(""); + txtNumIEPuntoVenta.setDisabled(false); + } + } + + public void onChange$cmbCiudad(Event ev) { + if (cmbCiudad.getSelectedItem() == null) { + return; + } else { + cmbColonia.setSelectedItem(null); + Ciudad c = (Ciudad) cmbCiudad.getSelectedItem().getValue(); + List lsCol = coloniaService.buscarPorCiudad(c); + BindingListModel dictModel = new BindingListModelList(lsCol, false); + cmbColonia.setModel(dictModel); + } + } + + public void onChange$cmbColonia(Event ev) { + if (cmbColonia.getSelectedItem() == null) { + return; + } else { + // Colonia col = (Colonia) cmbColonia.getSelectedItem().getValue(); + // txtCP.setValue(col.getCodpostal()); + } + } + + public String replaceTextbox(Textbox textbox) { + String getString = textbox.getValue(); + getString = getString.replace("(", ""); + getString = getString.replaceAll("_", ""); + getString = getString.replace(")", ""); + getString = getString.replace("-", ""); + + return getString; + } + + public void onClick$btnGeraTitulos(Event ev) throws InterruptedException { + Connection myConn = null; + GeradorTitulosIntegracion gerador; + try { + myConn = dataSource.getConnection(); + Date dateInicio = fecIntegracion.getValue(); + + dateInicio = DateUtil.inicioFecha(dateInicio); + Date dateFim = DateUtil.fimFecha(fecIntegracion.getValue()); + + log.info("puntoVentaId=" + puntoVenta.getPuntoventaId() + ";fecInicio=" + dateInicio + ";fecFin=" + dateFim); + + gerador = new GeradorTitulosIntegracion(myConn, puntoVenta.getPuntoventaId(), dateInicio, + dateFim, checkTodosPuntosVenta.isChecked()); + gerador.execute(); + + } catch (Exception e) { + log.error("Erro ao integrar", e); + + if (e instanceof WrongValueException) { + throw (WrongValueException) e; + } + + log.error("", e); + + Messagebox.show( + e.getMessage(), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + + }finally{ + if(myConn != null){ + try { + myConn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + + public void onClick$btnIntegracao(Event ev) throws InterruptedException { + + Connection myConn = null; + // GeradorTitulosIntegracion gerador; + try { + myConn = dataSource.getConnection(); + Date dateInicio = fecIntegracion.getValue(); + + dateInicio = DateUtil.inicioFecha(dateInicio); + Date dateFim = DateUtil.fimFecha(fecIntegracion.getValue()); + + log.info("puntoVentaId=" + puntoVenta.getPuntoventaId() + ";fecInicio=" + dateInicio + ";fecFin=" + dateFim); + + GerenciadorEnvioTitulosWS gerenciadorWS = new GerenciadorEnvioTitulosWS(myConn, checkDinheiro.isChecked(), + checkCredito.isChecked(), checkDebito.isChecked(), checkTF.isChecked(), checkBOL.isChecked(), + checkSimulaIntegracion.isChecked(), dateInicio, dateFim); + gerenciadorWS.execute(); + + } catch (Exception e) { + log.error("Erro ao integrar", e); + + if (e instanceof WrongValueException) { + throw (WrongValueException) e; + } + + log.error("", e); + + Messagebox.show( + e.getMessage(), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + + } finally { + // if (myConn != null) { + // try { + // myConn.close(); + // } catch (SQLException e) { + // log.error("Erro ao fechar a conexao", e); + // } + // } + } + } + + public void onClick$btnEnviaAG(Event ev) throws InterruptedException { + Connection myConn = null; + Observer wsevents = new Observer() { + + @Override + public void update(Observable o, Object arg) { + logResultAG.setText(((WSAGLog)o).toString()); + } + }; + + try { + + WSAGLog wslog = WSAGLog.getInstance(); + wslog.clear(); + wslog.addObserver(wsevents); + + myConn = dataSource.getConnection(); + Date dateInicio = fecInicioAG.getValue(); + + dateInicio = DateUtil.inicioFecha(dateInicio); + Date dateFim = DateUtil.fimFecha(fecFimAG.getValue()); + + GeradorTitulosAG gerador = new GeradorTitulosAG(myConn, dateInicio, dateFim); + log.info("puntoVentaId=" + puntoVenta.getPuntoventaId() + ";fecInicio=" + dateInicio + ";fecFin=" + dateFim); + + gerador.send(checkAdiantamentoAG.isChecked(), checkBoletoAG.isChecked(), checkCartaoAG.isChecked(), checkDepositoAG.isChecked(), false); + + gerador.mostraResultado(); + + } catch (Exception e) { + log.error("Erro ao integrar", e); + + if (e instanceof WrongValueException) { + throw (WrongValueException) e; + } + + log.error("", e); + + Messagebox.show( + e.getMessage(), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + + } finally { + try { + if (myConn != null && !myConn.isClosed()) { + myConn.close(); + } + } catch (SQLException e) { + log.error("error fechar conexão", e); + throw new RuntimeException(e); + } + } + } + + public void onClick$btnGeraTitulosAG(Event ev) throws InterruptedException { + Connection myConn = null; + try { + myConn = dataSource.getConnection(); + Date dateInicio = fecInicioAG.getValue(); + + dateInicio = DateUtil.inicioFecha(dateInicio); + Date dateFim = DateUtil.fimFecha(fecFimAG.getValue()); + + GeradorTitulosAG gerador = new GeradorTitulosAG(myConn, dateInicio, dateFim); + log.info("puntoVentaId=" + puntoVenta.getPuntoventaId() + ";fecInicio=" + dateInicio + ";fecFin=" + dateFim); + + if (checkTodosPuntosVenta.isChecked()){ + gerador.execute(checkAdiantamentoAG.isChecked(), checkBoletoAG.isChecked(), checkCartaoAG.isChecked(), checkDepositoAG.isChecked(), false); + } else { + if (puntoVenta.getLsPtovtaEmpresa() != null && !puntoVenta.getLsPtovtaEmpresa().isEmpty()){ + + for (PtovtaEmpresa pte : puntoVenta.getLsPtovtaEmpresa()){ + gerador.setEmpresaId(pte.getEmpresa().getEmpresaId()); + gerador.execute(puntoVenta.getPuntoventaId(), checkAdiantamentoAG.isChecked(), checkBoletoAG.isChecked(), checkCartaoAG.isChecked(), checkDepositoAG.isChecked(), false); + } + } else { + gerador.setEmpresaId(puntoVenta.getEmpresa().getEmpresaId()); + gerador.execute(puntoVenta.getPuntoventaId(), checkAdiantamentoAG.isChecked(), checkBoletoAG.isChecked(), checkCartaoAG.isChecked(), checkDepositoAG.isChecked(), false); + } + } + } catch (Exception e) { + log.error("Erro ao integrar", e); + + if (e instanceof WrongValueException) { + throw (WrongValueException) e; + } + + log.error("Erro ao integrar -> e.getMessage() quando vai mostrar o dialogo de erro na tela: " + e.getMessage()); + + Messagebox.show( + e.getMessage(), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + + } finally { + if (myConn != null) { + try { + myConn.close(); + } catch (SQLException e) { + log.error("Erro ao fechar a conexao", e); + } + } + } + } + + public void onClick$btnAdicionarEmpresaBloqueada(Event ev) { + Empresa e = (Empresa) cmbEmpresas.getSelectedItem().getValue(); + + puntoVenta.addEmpresaBloqueada(e); + + ptovtaEmpresasBloqueadasList.setData(puntoVenta.getPtovtaEmpresaBloqueadaList()); + + } + + public void onClick$btnApagarEmpresaBloqueada(Event ev) { + try { + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.borrarEmpresaBloqueadaPergunta"), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + + PtovtaEmpresaBloqueada e = (PtovtaEmpresaBloqueada) ptovtaEmpresasBloqueadasList.getSelected(); + + ptovtaEmpresaBloqueadaService.borrar(e); + + puntoVenta.removeEmpresaBloqueada(e); + ptovtaEmpresasBloqueadasList.setData(puntoVenta.getPtovtaEmpresaBloqueadaList()); + } + } catch (Exception ex) { + log.error(ex.toString()); + } + } + + public void onClick$btnAdicionarPtoVtaCheckin(Event ev) { + + if (cmbPtoVtaCheckinParada.getSelectedItem() != null) { + + Parada parada = (Parada) cmbPtoVtaCheckinParada.getSelectedItem().getValue(); + + PtoVtaCheckin pto = new PtoVtaCheckin(); + pto.setParadaId(parada); + pto.setPuntoventaId(puntoVenta); + + puntoVenta.addPtovtaCheckin(pto); + + ptovtaPtoVtaCheckinList.setData(puntoVenta.getPtovtaCheckinList()); + } + + } + + public void onClick$btnApagarPtoVtaCheckin(Event ev) { + try { + if (ptovtaPtoVtaCheckinList.getSelected() != null) { + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.borrarPtoVtaCheckin"), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + + PtoVtaCheckin pto = (PtoVtaCheckin) ptovtaPtoVtaCheckinList.getSelected(); + if (pto.getPtoVtaCheckinId() != null) { + ptoVtaCheckinService.borrar(pto); + } + puntoVenta.removePtovtaCheckin(pto); + ptovtaPtoVtaCheckinList.setData(puntoVenta.getPtovtaCheckinList()); + } + } + } catch (Exception ex) { + log.error(ex.toString()); + } + } + + public void onClick$btnAdicionarPtoVtaSeguro(Event ev) { + + if (cmbEmpresaSeguro.getSelectedItem() != null && + (radIndvendsegopcionalSi.isChecked() || radIndvendsegopcionalNo.isChecked() || + radIndestansegopcionalSi.isChecked() || radIndestansegopcionalNo.isChecked()) + && + (radIndvendsegtabelaSi.isChecked() || radIndvendsegtabelaNo.isChecked() || + radIndestansegtabelaSi.isChecked() || radIndestansegtabelaNo.isChecked()) + && + (radIndPermisoTasaEmbarqueSi.isChecked() || radIndPermisoTasaEmbarqueNo.isChecked() || + radIndEstanTasaEmbarqueSi.isChecked() || radIndEstanTasaEmbarqueNo.isChecked())) { + + Empresa empresa = (Empresa) cmbEmpresaSeguro.getSelectedItem().getValue(); + + for(PtoVtaSeguro p : puntoVenta.getPtovtaSeguroList()){ + if(p.getActivo() && p.getEmpresa().equals(empresa)){ + return; + } + } + + PtoVtaSeguro pto = new PtoVtaSeguro(); + + pto.setIndVendeSegOpcional(radIndvendsegopcionalSi.isChecked()); + pto.setIndVendeSegTabela(radIndvendsegtabelaSi.isChecked()); + pto.setIndEstanSegOpcional(radIndestansegopcionalSi.isChecked()); + pto.setIndEstanSegTabela(radIndestansegtabelaSi.isChecked()); + pto.setIndEstanTasaEmbarque(radIndEstanTasaEmbarqueSi.isChecked()); + pto.setIndPermisoTasaEmbarque(radIndPermisoTasaEmbarqueSi.isChecked()); + pto.setIndPermisoTasaEmbarqueVtaManual(radIndPermisoTasaEmbarqueVtaManualSi.isChecked()); + pto.setIndPermisoTasaEmbarqueVtaAgencia(radIndPermisoTasaEmbarqueVtaAgenciaSi.isChecked()); + + pto.setIndTaxaEmbarqueEmbarcada(radIndTaxaEmbarqueEmbarcadaSi.isChecked()); + pto.setIndVendeSeguroOpcEmbarcada(radIndVendeSeguroOpcEmbarcadaSi.isChecked()); + pto.setIndVendeSeguroTabelaEmbarcada(radIndVendeSeguroTabelaEmbarcadaSi.isChecked()); + + pto.setEmpresa(empresa); + pto.setPuntoventaId(puntoVenta); + + puntoVenta.addPtovtaSeguro(pto); + + ptovtaPtoVtaSeguroList.setData(puntoVenta.getPtovtaSeguroList()); + } + + } + + public void onClick$btnApagarPtoVtaSeguro(Event ev) { + try { + if (ptovtaPtoVtaSeguroList.getSelected() != null) { + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.borrarPtoVtaSeguro"), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + + PtoVtaSeguro pto = (PtoVtaSeguro) ptovtaPtoVtaSeguroList.getSelected(); + if (pto.getPtoVtaSeguroId() != null) { + ptoVtaSeguroService.borrar(pto); + } + puntoVenta.removePtovtaSeguro(pto); + ptovtaPtoVtaSeguroList.setData(puntoVenta.getPtovtaSeguroList()); + } + } + } catch (Exception ex) { + log.error(ex.toString()); + } + } + + public void onClick$btnAdicionarPtovtaCatInd(Event ev) { + if (!lsCategoriaSel.isEmpty() && cmbUsuarioBloq.getSelectedItem() != null) { + + if(!checkPtovtaCatIndTotalBus.isChecked() && + !checkPtovtaCatIndEmbarcada.isChecked()){ + try { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.msg.informartipobloqueio.value"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + } catch (InterruptedException e) { + log.error(e); + } + + return; + } + + for (Object item : lsCategoriaSel) { + Categoria categoria = (Categoria) item; + + PtovtaCatInd pto = new PtovtaCatInd(); + pto.setCategoria(categoria); + pto.setPuntoVenta(puntoVenta); + pto.setUsuarioBloqueado((Usuario) cmbUsuarioBloq.getSelectedItem().getValue()); + pto.setEmpresa((Empresa) cmbUsuarioEmpresa.getSelectedItem().getValue()); + pto.setIndEmbarcada(checkPtovtaCatIndEmbarcada.isChecked()); + pto.setIndTotalBus(checkPtovtaCatIndTotalBus.isChecked()); + + + if(existePtoVtaCat(pto)){ + continue; + } + + puntoVenta.addPtovtaCatInd(pto); + ptovtaCatIndListTemp.add(pto); + + + ptovtaCatIndList.setData(puntoVenta.getPtovtaCatIndList()); + } + } + } + + private boolean existePtoVtaCat(PtovtaCatInd ptoVtaCat) { + + for (PtovtaCatInd p : puntoVenta.getPtovtaCatIndList()) { + if (p.getActivo() + && p.getCategoria().equals(ptoVtaCat.getCategoria()) + && p.getEmpresa().equals(ptoVtaCat.getEmpresa()) + && existeConflitoUsuario(p.getUsuarioBloqueado(), ptoVtaCat.getUsuarioBloqueado())) { + return true; + } + } + + return false; + } + + private boolean existeConflitoUsuario(Usuario usuarioNovo, Usuario usuarioAntigo) { + + return usuarioNovo.equals(usuarioAntigo) || + (usuarioNovo.getUsuarioId().equals(-1) || usuarioAntigo.getUsuarioId().equals(-1)); + + } + + public void onClick$btnApagarPtovtaCatInd(Event ev) { + try { + if (ptovtaCatIndList.getSelected() != null) { + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.borrarPtoVtaCheckin"), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + + PtovtaCatInd pto = (PtovtaCatInd) ptovtaCatIndList.getSelected(); + if (pto.getPtovtaCategoriaId() != null) { + ptovtaCatIndService.borrar(pto); + ptovtaCatIndListTemp.remove(pto); + } + puntoVenta.removePtovtaCatInd(pto); + ptovtaCatIndList.setData(puntoVenta.getPtovtaCatIndList()); + } + } + } catch (Exception ex) { + log.error(ex.toString()); + } + } + + @SuppressWarnings("unchecked") + public void onClick$btnSalvar(Event ev) throws InterruptedException { + txtMaxCancelacion.getValue(); + txtNome.getValue(); + txtNumPtoVta.getValue(); + txtNumFax.getValue(); + txtCompl.getValue(); + txtNumAg.getValue(); + txtConta.getValue(); + txtCarga.getValue(); + txtAntecipRetem.getValue(); + txtAntecipPercentual.getValue(); + numtelefonodos.getValue(); + numtelefonouno.getValue(); + if (indMotivoBloqueio) { + if (puntoVenta.getPuntoventaId() != null) { + String statusAprobacionAtual = radAprobacionAutorizado.isChecked() ? "A" : "L"; + if (!statusAprobacionAtual.equals(statusAprobacionInicial)) { + motivoBloqueio.setConstraint("no empty"); + motivoBloqueio.getValue(); + } + } else { + motivoBloqueio.setConstraint("no empty"); + motivoBloqueio.getValue(); + } + } + + getTxtTaxaConvenienciaPorc().getValue(); + if (getTxtTaxaConvenienciaPorc().getValue() != null && + getTxtTaxaConvenienciaPorc().getValue().compareTo(BigDecimal.ZERO) == 1) { + txtMaximoTaxaConveniencia.setConstraint("no empty"); + txtMaximoTaxaConveniencia.getValue(); + } + + cmbEmpresa.getValue(); + cmbParada.getValue(); + cmbPtoVtaCheckinParada.getValue(); + cmbTipoPontoVenta.getValue(); + cmbMoneda.getValue(); + /* cmbNodo.getValue(); */ + cmbColonia.setConstraint("no empty"); + cmbColonia.getValue(); + cmbCiudad.getValue(); + cmbBanco.getValue(); + cmbPessoa.getValue(); + cmbTipoConta.getValue(); + cmbParada.setConstraint("no empty"); + cmbParada.getValue(); + + puntoVenta.setIndBloqueiaTipoPassagem(radIndBloquear.isSelected()); + + if(!validarEmail()){ + + if(descCorreo.getText() == null || descCorreo.getText().trim().isEmpty()){ + Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.emailObrigatorio"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + }else{ + Messagebox.show(Labels.getLabel("editarTipoPuntoVentaController.MSG.emailInvalido"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + } + + descCorreo.focus(); + return; + } + + if (!txtTitularNome.getValue().isEmpty() + || !txtTitularRg.getValue().isEmpty() + || !txtTitularEmissor.getValue().isEmpty() + || img.getContent() != null) { + txtTitularCpf.setConstraint(new ConstraintNoEmpty()); + txtTitularCpf.getValue(); + + puntoVenta.getTitularId().setActivo(Boolean.TRUE); + puntoVenta.getTitularId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + puntoVenta.getTitularId().setFecmodif(Calendar.getInstance().getTime()); + } else { + puntoVenta.setTitularId(null); + } + + validarDiversos(); + + String numagencia = txtNumAg.getValue() + (StringUtils.isBlank(txtDigitoAg.getValue()) ? "" : "-" + txtDigitoAg.getValue()); + + if (puntoVenta.getAgenciaId() != null) { + puntoVenta.getAgenciaId().setNumagencia(numagencia); + puntoVenta.getAgenciaId().setBilhetes(txtBilhetes.getValue()); + puntoVenta.getAgenciaId().setCarga(txtCarga.getValue()); + puntoVenta.getAgenciaId().setDigito(txtDigito.getValue()); + puntoVenta.getAgenciaId().setNumconta(txtConta.getValue()); + } + + if (puntoVenta.getPuntoVentaPadre() == null && !cmbPuntoVentaPadre.getValue().isEmpty()) { + cmbPuntoVentaPadre.getValue(true); + } + + // checar uma forma onde o proprio componente coloque como null o atributo + if (cmbPuntoVentaPadre.getValue().isEmpty()) { + puntoVenta.setPuntoVentaPadre(null); + } + + List lsPuntoVenta = puntoVentaService.buscaPuntoVenta(txtNumPtoVta.getValue()); + + if (!lsPuntoVenta.isEmpty()) { + boolean exists = CollectionUtils.exists(lsPuntoVenta, new Predicate() { + + @Override + public boolean evaluate(Object object) { + return ((PuntoVenta) object).getPuntoventaId().equals(puntoVenta.getPuntoventaId()); + } + }); + + if (!exists) { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.registroNumPtoVtaExiste"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + + return; + } + } + + if (ckValidarTempoParaImpressao.isChecked() && txtTempoParaImpressao.getValue() == null) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.informarTempoMinimo.value"), Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + txtTempoParaImpressao.focus(); + + return; + } + + try { + if (puntoVenta.getEmpresa() == null) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.empresa"), Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + + } else if (puntoVenta.getTipoPuntoVenta() == null) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.punto"), Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + + } else if (puntoVenta.getMoneda() == null) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.moneda"), Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + + /* + * } else if (puntoVenta.getNodo() == null) { Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.nodo"), Labels.getLabel(TITULO), Messagebox.OK, Messagebox.EXCLAMATION); + */ + } else if ((lsFormaPagoDet == null) || (lsFormaPagoDet.isEmpty())) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.MSG.formaDePago"), Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + + } else { + if (cmbConexion.getValue().equals("")) { + puntoVenta.setConexionBancaria(null); + puntoVenta.setUsuarioBancario(null); + + } + + if (cmbUsuarioBancario.getValue() == null) { + puntoVenta.setUsuarioBancario(null); + } + + if (cmbColonia.getSelectedItem() != null) { + puntoVenta.setColonia((Colonia) cmbColonia.getSelectedItem().getValue()); + } + + if ((puntoVenta.getComissaoId() != null) && (puntoVenta.getComissaoId().getPtovtaComissaoId() == null)) { + puntoVenta.setComissaoId(null); + } + + // Empresas para Venda + List contasBancariasExcluidas = new ArrayList(0); + + for (PtovtaEmpresa emp : lsPtovtaEmpresa) { + if (emp.getActivo()) { + // Contas bancarias (Temporaria) + for (EmpresaContaBancaria ecc : emp.getContasBancaria()) { + if (ecc.getEmpresaContaBancariaId() == null) { + continue; + } + + // Verificando os bancos adicionados/atualizados + boolean existe = false; + + for (PtovtaEmpresaContaBancaria pto : emp.getLsPtovtaEmpresaContaBancaria()) { + if (pto.getEmpresaContaBancaria() != null && pto.getEmpresaContaBancaria().getEmpresaContaBancariaId().equals(ecc.getEmpresaContaBancariaId())) { + existe = true; + break; + } + } + + if (!existe) { + PtovtaEmpresaContaBancaria pto = new PtovtaEmpresaContaBancaria(); + pto.setPtovtaEmpresa(emp); + pto.setEmpresaContaBancaria(ecc); + pto.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + pto.setFecmodif(new Date()); + pto.setActivo(true); + + emp.getLsPtovtaEmpresaContaBancaria().add(pto); + } + } + + // Contas bancarias removidas + List excluir = new ArrayList(0); + + for (PtovtaEmpresaContaBancaria pto : emp.getLsPtovtaEmpresaContaBancaria()) { + boolean existe = false; + + for (EmpresaContaBancaria ecc : emp.getContasBancaria()) { + if (pto.getEmpresaContaBancaria().getEmpresaContaBancariaId().equals(ecc.getEmpresaContaBancariaId())) { + existe = true; + break; + } + } + + if (!existe) { + excluir.add(pto); + } + } + + emp.getLsPtovtaEmpresaContaBancaria().removeAll(excluir); + + contasBancariasExcluidas.addAll(excluir); + } + } + + puntoVenta.setActivo(Boolean.TRUE); + puntoVenta.setFecmodif(Calendar.getInstance().getTime()); + puntoVenta.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + + if(!isPermissaoMotivoFormaPago || puntoVenta.getPuntoventaId()==null) { + puntoVenta.setLsFormaPagoDet(lsFormaPagoDet); + }else { + puntoVenta.setLsFormaPagoDet(formaPagoList.getListData()); + } + + puntoVenta.setLsParamRecoleccion(lsParamRecoleccion); + puntoVenta.setLsPtovtaEmpresa(lsPtovtaEmpresa); + puntoVenta.setLsPtovtaUsuarioBancario(lsPtovtaUsuarioBancario); + puntoVenta.setPtovtaAntecipacomissaoList(lsAntecipacomissao); + puntoVenta.setPtovtaHorarioList(lsHorario); + puntoVenta.setPtovtaEstoqueList(lsEstoque); + puntoVenta.setValidaTempoParaImpressao(ckValidarTempoParaImpressao.isChecked()); + puntoVenta.setTempoMinimoParaImpressao(txtTempoParaImpressao.getValue()); + puntoVenta.setNodo(nodoService.obtenerId(1)); + puntoVenta.setDateAbertura(dateAbertura.getValue()); + puntoVenta.setPtovtaCatIndList(ptovtaCatIndListTemp); + + if (dateFechamento.getValue() != null && dateAbertura.getValue() != null && dateFechamento.getValue().compareTo(dateAbertura.getValue()) < 0) { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.DatFechMenorDataAbertura"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + return; + } + + puntoVenta.setDateFechamento(dateFechamento.getValue()); + + String getString = null; + + puntoVenta.setNumfax(null); + if (!txtNumFax.getValue().equals("")) { + getString = this.replaceTextbox(txtNumFax); + if (getString.indexOf("_") > -1) { + puntoVenta.setNumfax(txtNumFax.getValue().replace("_", "")); + }else + puntoVenta.setNumfax(txtNumFax.getValue()); + } + + puntoVenta.setNumtelefonouno(""); + if (!numtelefonouno.getValue().equals("")) { + getString = this.replaceTextbox(numtelefonouno); + if (getString.indexOf("_") > -1) { + puntoVenta.setNumtelefonouno(numtelefonouno.getValue().replace("_", "")); + }else + puntoVenta.setNumtelefonouno(numtelefonouno.getValue()); + } + + puntoVenta.setNumtelefonodos(""); + if (!numtelefonodos.getValue().equals("")) { + getString = this.replaceTextbox(numtelefonodos); + if (getString.indexOf("_") > -1) { + puntoVenta.setNumtelefonodos(numtelefonodos.getValue().replace("_", "")); + }else + puntoVenta.setNumtelefonodos(numtelefonodos.getValue()); + } + + if (cmbBanco.getSelectedItem() == null) { + puntoVenta.setAgenciaId(null); + } else { + if (puntoVenta.getAgenciaId() == null) { + puntoVenta.setAgenciaId(new PtovtaAgencia()); + } + puntoVenta.getAgenciaId().setInstiFinanceiraId((InstiFinanceira) cmbBanco.getSelectedItem().getValue()); + if (cmbPessoa.getSelectedItem() != null) { + puntoVenta.getAgenciaId().setPessoa((String) cmbPessoa.getSelectedItem().getValue()); + } + + if (cmbTipoConta.getSelectedItem() != null) { + puntoVenta.getAgenciaId().setTipo((String) cmbTipoConta.getSelectedItem().getValue()); + } + puntoVenta.getAgenciaId().setActivo(Boolean.TRUE); + puntoVenta.getAgenciaId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + puntoVenta.getAgenciaId().setFecmodif(Calendar.getInstance().getTime()); + } + + List lsPto = new ArrayList(); + for (PtovtaEmpresa pto : lsPtovtaEmpresa) { + if (!pto.getActivo()) { + for (PtovtaEmpresaContaBancaria ecc : pto.getLsPtovtaEmpresaContaBancaria()) { + ptovtaEmpresaContaBancariaService.borrarFisico(ecc); + } + + ptovtaEmpresaService.borrarFisico(pto); + } else { + pto.setPuntoVenta(puntoVenta); + lsPto.add(pto); + } + } + puntoVenta.setLsPtovtaEmpresa(lsPto); + + for (PtovtaEmpresaContaBancaria ecc : contasBancariasExcluidas) { + ptovtaEmpresaContaBancariaService.borrarFisico(ecc); + } + + List lsPto2 = new ArrayList(); + for (PtoVtaUsuarioBancario pto2 : lsPtovtaUsuarioBancario) { + if (!pto2.getActivo()) { + ptoVtaUsuarioBancarioService.borrarFisico(pto2); + } else { + pto2.setPuntoVenta(puntoVenta); + lsPto2.add(pto2); + } + } + + if (ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.VALIDA_CONTA_CORRENTE_EMPESA_PTOVTA.getDescricao(), "1")) { + if (!validaCadastroFechamentoContaCorrente()) { + exibeMsgErroFechCtaCorrente(); + return; + } + } + puntoVenta.setLsPtovtaUsuarioBancario(lsPto2); + + if (radAprobacionAutorizado.isChecked()) { + puntoVenta.setStatusaprobacion("A"); + puntoVenta.setDateFechamento(null); + } else if (radAprobacionLatente.isChecked()) { + puntoVenta.setStatusaprobacion("L"); + } + + if (indMotivoBloqueio) { + if (puntoVenta.getPuntoventaId() != null) { + if (!puntoVenta.getStatusaprobacion().equals(statusAprobacionInicial)) { + puntoVenta.setMotivoBloqueio(motivoBloqueio.getValue()); + } + } else { + puntoVenta.setMotivoBloqueio(motivoBloqueio.getValue()); + } + } + + if(!puntoVenta.getStatusaprobacion().equals(statusAprobacionInicial)){ + HistoricoPuntoVenta h = new HistoricoPuntoVenta(); + h.setPuntoVenta(puntoVenta); + + h.setIndBloqueio(!puntoVenta.getStatusaprobacion().equals("A")); + h.setMotivoBloqueio(motivoBloqueio.getValue()); + h.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + h.setActivo(true); + h.setFecmodif(new Date()); + h.setFecBloqueio(new Date()); + + puntoVenta.getHistoricoPuntoVentaList().add(h); + } + + if (puntoVenta.getIndIntegracion() == null) { + puntoVenta.setIndIntegracion(TipoRetorno.PENDENTE.getValor()); + } + if(cmbTipoSocio.getSelectedItem() != null ) { + puntoVenta.setTipoSocio(((TipoSocio) cmbTipoSocio.getSelectedItem().getValue())); + } + + if (puntoVenta.getPuntoventaId() == null) { + puntoVenta = puntoVentaService.suscribir(puntoVenta); + puntoVentaList.addItemNovo(puntoVenta); + } else { + puntoVentaService.actualizacion(puntoVenta); + puntoVentaList.updateItem(puntoVenta); + } + + gravaFechamentoCtaCorrente(); + + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.suscribirOK"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.INFORMATION); + + closeWindow(); + + } + + } catch (ValidacionCampoException ve) { + log.error("editarPuntoVentaController: ", ve); + Messagebox.show( + ve.getMessage(), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + + } catch (IntegracionException ex) { + gravaFechamentoCtaCorrente(); + puntoVentaList.updateItem(puntoVenta); + + log.error("editarPuntoVentaController: ", ex); + + Messagebox.show( + ex.getMessage(), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + + closeWindow(); + + } catch (Exception ex) { + log.error("editarPuntoVentaController: ", ex); + + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } + + //Aba Excecao Multa Cancelamento + cmbOrgaoConcedente.setModel(new ListModelList(lsOrgaoConcedentes)); + cmbOrgaoConcedente.setSelectedItem(null); + + } + + + private boolean validarEmail() throws InterruptedException { + + descCorreo.getValue(); + + Constante constante = constanteService.buscarPorNomeConstante("TOTALBUS_EMAIL_OPCIONAL_PV"); + + if(constante == null || constante.getValorconstante().equals("0")){ + if(descCorreo.getText() == null || descCorreo.getText().isEmpty()){ + return false; + } + }else{ + if(descCorreo.getText() == null || descCorreo.getText().isEmpty()){ + return true; + } + } + + for(String email : descCorreo.getText().split(";")){ + Matcher matcher = pattern.matcher(email); + if(!matcher.matches()){ + return false; + } + } + + return true; + } + + private void gravaFechamentoCtaCorrente() { + List paramsFechamento = fechamentoParamptovtaService.buscaParametrosPorPuntoventa(puntoVenta); + gravarCC(paramsFechamento); + removerCC(paramsFechamento); + } + + private void gravarCC(List paramsFechamento) { + boolean encontrouEmpresaComFechamentoConfigurado = false; + for (Object object : fechamentoParamptovtaList.getListData()) { + encontrouEmpresaComFechamentoConfigurado = false; + FechamentoParamptovta fechamentoParamptovta = (FechamentoParamptovta) object; + //verifica se empresa ja esta configurada com fechamento de conta corrente + for(FechamentoParamptovta paramFechamento : paramsFechamento){ + if(fechamentoParamptovta.getEmpresa().getEmpresaId() == paramFechamento.getEmpresa().getEmpresaId()){ + encontrouEmpresaComFechamentoConfigurado = true; + paramFechamento.setDiasemtransito(fechamentoParamptovta.getDiasemtransito()); + paramFechamento.setIntervalofechamento(fechamentoParamptovta.getIntervalofechamento()); + paramFechamento.setTipopagamento(fechamentoParamptovta.getTipopagamento()); + fechamentoParamptovtaService.actualizacion(paramFechamento); + break; + } + } + //Caso nao esteja configurada insere no banco + if(!encontrouEmpresaComFechamentoConfigurado){ + fechamentoParamptovta.setPuntoventa(puntoVenta); + fechamentoParamptovtaService.suscribir(fechamentoParamptovta); + } + } + } + + private void removerCC(List paramsFechamento) { + boolean removerEmpresa = true; + for(FechamentoParamptovta paramFechamento : paramsFechamento){ + removerEmpresa = true; + //Procura por empresas que estao no banco mas nao estao na lista + for (Object object : fechamentoParamptovtaList.getListData()) { + FechamentoParamptovta fechamentoParamptovta = (FechamentoParamptovta) object; + if(paramFechamento.getEmpresa().getEmpresaId() == fechamentoParamptovta.getEmpresa().getEmpresaId()){ + removerEmpresa = false; + break; + } + } + //Remove do banco a empresa que nao estao na lista + if(removerEmpresa){ + fechamentoParamptovtaService.borrar(paramFechamento); + } + } + } + + private void exibeMsgErroFechCtaCorrente() throws InterruptedException { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.ParamPtoVtaObrigatorio"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + } + + private boolean validaCadastroFechamentoContaCorrente() { + List empresasVenda = Arrays.asList(ptovtaEmpresaList.getData()); + List empresasFechamento = Arrays.asList(fechamentoParamptovtaList.getData()); + boolean validado = false; + try { + //Valida que todas empresas de Fechamento sao empresa para venda. + for (int i = 0; i < empresasVenda.size(); i++) { + PtovtaEmpresa empresaVenda = (PtovtaEmpresa) empresasVenda.get(i); + + validado = false; + + for (int j = 0; j < empresasFechamento.size(); j++) { + FechamentoParamptovta fechamentoParamptovta = (FechamentoParamptovta) empresasFechamento.get(j); + + if (empresaVenda.getEmpresa().getEmpresaId().equals(fechamentoParamptovta.getEmpresa().getEmpresaId())) { + validado=true; + break; + } + } + if (!validado) { + return false; + } + } + } catch (Throwable e) { + log.error("",e); + return false; + } + return true; + } + + private void validarDiversos() { + if (puntoVenta.getDiversosId() != null) + { + if(!txtResponEnergia.getValue().isEmpty() + || checkInformatizada.isChecked() + || checkBilheteInfo.isChecked() + || checkVendaInternet.isChecked() + || checkTeleEntrega.isChecked() + || checkDigitacao.isChecked() + || checkBilhete.isChecked() + || checkOfpsPropria.isChecked() + || checkOfpsTerceiros.isChecked()) { + + txtResponAluguel.setConstraint("no empty"); + txtResponAluguel.getValue(); + txtResponTel.setConstraint("no empty"); + txtResponTel.getValue(); + + puntoVenta.getDiversosId().setActivo(Boolean.TRUE); + puntoVenta.getDiversosId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + puntoVenta.getDiversosId().setFecmodif(Calendar.getInstance().getTime()); + } + + } else { + puntoVenta.setDiversosId(null); + } + } + + public void onClick$btnApagar(Event ev) { + try { + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.borrarPergunta"), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + + puntoVentaService.borrar(puntoVenta); + + log.warn("Usuário " + UsuarioLogado.getUsuarioLogado().getNombusuario() + " excluiu o ponto de venda " + puntoVenta.getPuntoventaId()); + + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.borrarOK"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.INFORMATION); + + puntoVentaList.removeItem(puntoVenta); + + closeWindow(); + } + } catch (BusinessException ex) { + try { + Messagebox.show(ex.getMessage(), + Labels.getLabel(TITULO), Messagebox.OK, Messagebox.ERROR); + } catch (InterruptedException e) { + log.error(e); + } + } catch (Exception ex) { + log.error(ex); + } + } + + public void uploadPhoto(UploadEvent event) { + org.zkoss.util.media.Media media = event.getMedia(); + + try { + if (media instanceof org.zkoss.image.Image) { + img.setContent(new org.zkoss.image.AImage(media.getName(), + media.getStreamData())); + } else { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.errorIMG") + " " + media, + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } + } catch (IOException ex) { + log.error(ex); + throw UiException.Aide.wrap(ex); + } catch (InterruptedException ex) { + log.error(ex); + throw UiException.Aide.wrap(ex); + } + } + + public void onClick$btnSalvarAntecipa() throws InterruptedException { + dateAntecipData.getValue(); + txtAntecipRetem.getValue(); + txtAntecipPercentual.getValue(); + + try { + PtovtaAntecipacomissao antecipa = new PtovtaAntecipacomissao(); + + antecipa.setData(dateAntecipData.getValue()); + antecipa.setPercentual(txtAntecipPercentual.getValueDecimal()); + antecipa.setRetem(txtAntecipRetem.getValueDecimal()); + antecipa.setPuntoventaId(puntoVenta); + + antecipa.setActivo(Boolean.TRUE); + antecipa.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + antecipa.setFecmodif(Calendar.getInstance().getTime()); + + lsAntecipacomissao.add(antecipa); + ptovtaAntecipaList.setData(lsAntecipacomissao); + + } catch (Exception ex) { + log.error(ex); + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } + } + + public void onClick$btnApagarAntecipa() { + try { + PtovtaAntecipacomissao antecipa = (PtovtaAntecipacomissao) ptovtaAntecipaList.getSelected(); + if (antecipa != null) { + antecipa.setActivo(Boolean.FALSE); + antecipa.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + antecipa.setFecmodif(Calendar.getInstance().getTime()); + + ptovtaAntecipaList.removeItem(antecipa); + lsAntecipacomissao.remove(antecipa); + } + } catch (Exception ex) { + log.error(ex); + } + } + + public void onClick$btnSalvarHorario() throws InterruptedException { + timeboxInicio.getValue(); + timeboxFim.getValue(); + try { + PtovtaHorario horario = new PtovtaHorario(); + + horario.setInddomingo(checkDom.isChecked()); + horario.setIndjueves(checkJue.isChecked()); + horario.setIndlunes(checkLun.isChecked()); + horario.setIndmartes(checkMar.isChecked()); + horario.setIndmiercoles(checkMie.isChecked()); + horario.setIndsabado(checkSab.isChecked()); + horario.setIndviernes(checkVie.isChecked()); + + horario.setInicio(timeboxInicio.getValue()); + horario.setFim(timeboxFim.getValue()); + horario.setPuntoventaId(puntoVenta); + horario.setActivo(Boolean.TRUE); + horario.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + horario.setFecmodif(Calendar.getInstance().getTime()); + + lsHorario.add(horario); + ptovtaHorarioList.addItemNovo(horario); + + } catch (Exception ex) { + log.error(ex); + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } + } + + public void onClick$btnApagarHorario() { + try { + PtovtaHorario horario = (PtovtaHorario) ptovtaHorarioList.getSelected(); + if (horario != null) { + horario.setActivo(Boolean.FALSE); + horario.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + horario.setFecmodif(Calendar.getInstance().getTime()); + ptovtaHorarioList.removeItem(horario); + if (horario.getPtovtaHorarioId() == null) { + lsHorario.remove(horario); + } + } + } catch (Exception ex) { + log.error(ex); + } + } + + public void onClick$btnSalvarEstoque() throws InterruptedException { + txtEspecie.getValue(); + cmbForm.getValue(); + txtQuant.getValue(); + cmbLote.getValue(); + try { + PtovtaEstoque estoque = new PtovtaEstoque(); + + estoque.setEspecie(txtEspecie.getValue()); + if (cmbForm.getSelectedItem() != null) { + estoque.setFormCont(Integer.valueOf((String) cmbForm.getSelectedItem().getValue())); + } + if (cmbLote.getSelectedItem() != null) { + estoque.setLoteform(Integer.valueOf((String) cmbLote.getSelectedItem().getValue())); + } + + estoque.setQuantidade(txtQuant.getValue()); + estoque.setPuntoventaId(puntoVenta); + + estoque.setActivo(Boolean.TRUE); + estoque.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + estoque.setFecmodif(Calendar.getInstance().getTime()); + + lsEstoque.add(estoque); + ptovtaEstoqueList.setData(lsEstoque); + + } catch (Exception ex) { + log.error(ex); + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } + } + + public void onClick$btnApagarEstoque() { + try { + PtovtaEstoque estoque = (PtovtaEstoque) ptovtaEstoqueList.getSelected(); + if (estoque != null) { + estoque.setActivo(Boolean.FALSE); + estoque.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + estoque.setFecmodif(Calendar.getInstance().getTime()); + + ptovtaEstoqueList.removeItem(estoque); + lsEstoque.remove(estoque); + } + } catch (Exception ex) { + log.error(ex); + } + } + + public void onClick$btnSalvarFormaPago(Event ev) throws InterruptedException { + + cmbFormaPago.getValue(); + cmbEmpresaFormaPago.getValue(); + + isPermissaoMotivoFormaPago = isPermiteInserirMotivoFormaPago(); + + try { + FormaPago formaPago = new FormaPago(); + try { + formaPago = (FormaPago) cmbFormaPago.getSelectedItem().getValue(); + Boolean achou = Boolean.FALSE; + Empresa empresa = (Empresa) cmbEmpresaFormaPago.getSelectedItem().getValue(); + if (formaPago != null) { + for (FormaPagoDet fpd : lsFormaPagoDet) { + if (fpd.getFormaPago().equals(formaPago) && empresa.equals(fpd.getEmpresa())) { + achou = Boolean.TRUE; + } + } + if (!achou) { + FormaPagoDet fpd = new FormaPagoDet(); + /* + * Mantis #6874 fpd.setCargosextras(new BigDecimal(txtCargosExtras.getValue())); + */ + fpd.setCargosextras(BigDecimal.ZERO); + fpd.setFormaPago(formaPago); + fpd.setPuntoVenta(puntoVenta); + fpd.setIndTotalBus(checkPtoVtaEmpresaIndTotalBus.isChecked()); + fpd.setIndEmbarcada(checkPtoVtaEmpresaIndEmbarcada.isChecked()); + + if (cmbEmpresaFormaPago.getSelectedItem() != null) { + fpd.setEmpresa(empresa); + } + + fpd.setActivo(Boolean.TRUE); + fpd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + fpd.setFecmodif(Calendar.getInstance().getTime()); + if(isEdicaoDoPuntoVentaEisPermissaoMotivoFormaPago()) { + abrirMotivoFormaPagamento(fpd, Boolean.TRUE, ((Empresa) cmbEmpresaFormaPago.getSelectedItem().getValue()).getEmpresaId()) ; + }else { + lsFormaPagoDet.add(fpd); + formaPagoList.setData(lsFormaPagoDet); + } + + } else { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.Achou.FormaPago"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + } + } + } catch (Exception e) { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.formaDePago"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + } + } catch (Exception ex) { + log.error(ex); + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } + + + } + + public void onClick$btnApagarFormaPago(Event ev) { + try { + + isPermissaoMotivoFormaPago = isPermiteInserirMotivoFormaPago(); + + FormaPagoDet fpd = (FormaPagoDet) formaPagoList.getSelected(); + if (fpd != null) { + fpd.setActivo(Boolean.FALSE); + fpd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + fpd.setFecmodif(Calendar.getInstance().getTime()); + if(isEdicaoDoPuntoVentaEisPermissaoMotivoFormaPago()) { + abrirMotivoFormaPagamento(fpd, Boolean.FALSE, null) ; + }else { + formaPagoList.removeItem(fpd); + lsFormaPagoDet.remove(fpd); + } + + } + } catch (Exception ex) { + log.error(ex); + } + } + + public void onClick$btnSalvarParamRecoleccion(Event ev) throws InterruptedException { + importeInicial.getValue(); + importeAdicional.getValue(); + try { + ParamRecoleccion paramRecoleccion = new ParamRecoleccion(); + paramRecoleccion.setImporteinicial(importeInicial.getValueDecimal()); + paramRecoleccion.setImporteadicional(importeAdicional.getValueDecimal()); + + Boolean achou = Boolean.FALSE; + + for (ParamRecoleccion fpd : lsParamRecoleccion) { + if (fpd.getImporteinicial().equals(paramRecoleccion.getImporteinicial())) { + achou = Boolean.TRUE; + } + } + if (!achou) { + + paramRecoleccion.setPuntoVenta(puntoVenta); + paramRecoleccion.setActivo(Boolean.TRUE); + paramRecoleccion.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + paramRecoleccion.setFecmodif(Calendar.getInstance().getTime()); + + lsParamRecoleccion.add(paramRecoleccion); + paramRecoleccionList.setData(lsParamRecoleccion); + } else { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.Achou.ParamRecoleccion"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + } + + } catch (Exception ex) { + log.error(ex); + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } + } + + public void onClick$btnApagarParamRecoleccion(Event ev) { + try { + ParamRecoleccion fpd = (ParamRecoleccion) paramRecoleccionList.getSelected(); + if (fpd != null) { + fpd.setActivo(Boolean.FALSE); + fpd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + fpd.setFecmodif(Calendar.getInstance().getTime()); + + paramRecoleccionList.removeItem(fpd); + lsParamRecoleccion.remove(fpd); + } + } catch (Exception ex) { + log.error(ex); + } + } + + public void onClick$btnSalvarPtovtaEmpresa(Event ev) throws InterruptedException { + cmbEmpresaPtoVta.getValue(); + try { + PtovtaEmpresa ptovtaEmpresa = null; + if(this.ptovtaEmpresa != null) { + ptovtaEmpresa = new PtovtaEmpresa(this.ptovtaEmpresa.getPtovtaempresaId()); + ptovtaEmpresa.setLsPtovtaEmpresaContaBancaria(this.ptovtaEmpresa.getLsPtovtaEmpresaContaBancaria()); + } else { + ptovtaEmpresa = new PtovtaEmpresa(); + } + + Boolean achou = Boolean.FALSE; + + ptovtaEmpresa.setEmpresa((Empresa) cmbEmpresaPtoVta.getSelectedItem().getValue()); + + for (PtovtaEmpresa fpd : lsPtovtaEmpresa) { + if ((ptovtaEmpresa.getPtovtaempresaId() == null || !ptovtaEmpresa.getPtovtaempresaId().equals(fpd.getPtovtaempresaId())) && + fpd.getEmpresa().equals(ptovtaEmpresa.getEmpresa()) && fpd.getActivo()) { + achou = Boolean.TRUE; + } + } + if (!achou) { + ptovtaEmpresa.setPuntoVenta(puntoVenta); + ptovtaEmpresa.setActivo(Boolean.TRUE); + ptovtaEmpresa.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + ptovtaEmpresa.setFecmodif(Calendar.getInstance().getTime()); + ptovtaEmpresa.setIndTerceirizada(checkPtoVtaEmpresaIndTerceirizada.isChecked()); + ptovtaEmpresa.setIndBloqueada(checkPtoVtaEmpresaIndBloqueada.isChecked()); + ptovtaEmpresa.setIndMostrarCaja(checkPtoVtaEmpresaIndMostrarCaja.isChecked()); + ptovtaEmpresa.setIndImpCompCartao(checkPtoVtaEmpresaIndImpCompCartao.isChecked()); + ptovtaEmpresa.setNumeroSitef(txtNumeroSitef.getText()); + ptovtaEmpresa.setMerchantStoreAdyen(txtMerchantStoreAdyen.getText()); + +// if (cmbEmpresasContaBancarias.getSelectedItem() != null) { +// ptovtaEmpresa.setEmpresaContaBancaria((EmpresaContaBancaria) cmbEmpresasContaBancarias.getSelectedItem().getValue()); +// } + + if (empresaContaBancariaList.getSelectedCount() > 0){ + ptovtaEmpresa.getContasBancaria().clear(); + + for (Object o : empresaContaBancariaList.getSelectedModelItems()) { + EmpresaContaBancaria ecb = (EmpresaContaBancaria) o; + ptovtaEmpresa.getContasBancaria().add(ecb); + } + } + + if (ptovtaEmpresa.getPtovtaempresaId() == null){ + lsPtovtaEmpresa.add(ptovtaEmpresa); + ptovtaEmpresaList.addItemNovo(ptovtaEmpresa); + + }else{ + int index = lsPtovtaEmpresa.indexOf(ptovtaEmpresa); + + if(index >= -1) { + lsPtovtaEmpresa.set(index, ptovtaEmpresa); + } else { + lsPtovtaEmpresa.add(ptovtaEmpresa); + } + + ptovtaEmpresaList.updateItem(ptovtaEmpresa); + } + + novoPtovtaEmpresa(); + + } else { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.Achou.PtovtaEmpresa"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + } + + } catch (Exception ex) { + log.error(ex); + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } + } + + public void onClick$btnApagarPtovtaEmpresa(Event ev) { + try { + PtovtaEmpresa fpd = (PtovtaEmpresa) ptovtaEmpresaList.getSelected(); + if (fpd != null) { + lsPtovtaEmpresa.remove(fpd); + ptovtaEmpresaList.removeItem(fpd); + if (fpd.getPtovtaempresaId() != null) { + fpd.setActivo(Boolean.FALSE); + fpd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + fpd.setFecmodif(Calendar.getInstance().getTime()); + fpd.setPuntoVenta(puntoVenta); + + lsPtovtaEmpresa.add(fpd); + } + } + } catch (Exception ex) { + log.error(ex); + } + } + + public void onClick$btnNovoPtovtaEmpresa(Event ev) throws InterruptedException { + novoPtovtaEmpresa(); + } + + private void novoPtovtaEmpresa() { + cmbEmpresaPtoVta.setSelectedIndex(-1); +// cmbEmpresasContaBancarias.setSelectedIndex(-1); + checkPtoVtaEmpresaIndTerceirizada.setChecked(false); + checkPtoVtaEmpresaIndBloqueada.setChecked(false); + checkPtoVtaEmpresaIndMostrarCaja.setChecked(false); + checkPtoVtaEmpresaIndImpCompCartao.setChecked(false); + txtNumeroSitef.setValue(""); + txtMerchantStoreAdyen.setValue(null); + this.ptovtaEmpresa = null; + empresaContaBancariaList.setData(new ArrayList(0)); + } + + private void editarPtovtaEmpresa(PtovtaEmpresa ptovtaEmpresa) { + this.ptovtaEmpresa = new PtovtaEmpresa(ptovtaEmpresa.getPtovtaempresaId()); + this.ptovtaEmpresa.setLsPtovtaEmpresaContaBancaria(ptovtaEmpresa.getLsPtovtaEmpresaContaBancaria()); + + cmbEmpresaPtoVta.setSelectedIndex(-1); +// cmbEmpresasContaBancarias.setSelectedIndex(-1); + + if(lsEmpresasSemTodos != null) { + int indexOf = lsEmpresasSemTodos.indexOf(ptovtaEmpresa.getEmpresa()); + if (indexOf>-1) { + cmbEmpresaPtoVta.setSelectedIndex(indexOf); + } + } + + if(lsEmpresaContaBancarias != null) { +// cmbEmpresasContaBancarias.setSelectedIndex(lsEmpresaContaBancarias.indexOf(ptovtaEmpresa.getEmpresaContaBancaria())); + } + + lsEmpresaContaBancarias = ptovtaBancoService.buscarContasBancariasPorIdEmpresa(ptovtaEmpresa.getEmpresa().getEmpresaId()); + + empresaContaBancariaList.setData(new ArrayList(0)); + + if (lsEmpresaContaBancarias != null && !lsEmpresaContaBancarias.isEmpty()) { + empresaContaBancariaList.setData(lsEmpresaContaBancarias); + } + + empresaContaBancariaList.selectItems(ptovtaEmpresa.getContasBancaria()); + + + checkPtoVtaEmpresaIndTerceirizada.setChecked(ptovtaEmpresa.getIndTerceirizada()); + checkPtoVtaEmpresaIndBloqueada.setChecked(ptovtaEmpresa.getIndBloqueada()); + checkPtoVtaEmpresaIndMostrarCaja.setChecked(ptovtaEmpresa.getIndMostrarCaja()); + checkPtoVtaEmpresaIndImpCompCartao.setChecked(ptovtaEmpresa.getIndImpCompCartao()); + txtNumeroSitef.setValue(ptovtaEmpresa.getNumeroSitef()); + txtMerchantStoreAdyen.setValue(ptovtaEmpresa.getMerchantStoreAdyen()); + } + + public void onChange$cmbConexion(Event ev) { + habilitarCombo(); + } + + private void habilitarCombo() { + Comboitem cbi = cmbConexion.getSelectedItem(); + if (cbi != null) { + String valor = (String) cbi.getValue(); + + if (valor.equals("S")) { + cmbUsuarioBancario.setDisabled(Boolean.FALSE); + } + } + } + + public void onClick$btnSalvarPtovtaUsuarioBancario(Event ev) throws InterruptedException { + cmbEmpresaPtoVtaUsuarioBancario.getValue(); + cmbUsuarioBancarioPtoVtaUsuarioBancario.getValue(); + + try { + PtoVtaUsuarioBancario usuarioBancario = new PtoVtaUsuarioBancario(); + usuarioBancario.setEmpresa((Empresa) cmbEmpresaPtoVtaUsuarioBancario.getSelectedItem().getValue()); + usuarioBancario.setUsuarioBancario((UsuarioBancario) cmbUsuarioBancarioPtoVtaUsuarioBancario.getSelectedItem().getValue()); + + Boolean achou = Boolean.FALSE; + + for (PtoVtaUsuarioBancario fpd : lsPtovtaUsuarioBancario) { + if (fpd.getEmpresa().equals(usuarioBancario.getEmpresa())) { + achou = Boolean.TRUE; + } + } + if (!achou) { + + usuarioBancario.setPuntoVenta(puntoVenta); + usuarioBancario.setActivo(Boolean.TRUE); + usuarioBancario.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + usuarioBancario.setFecmodif(Calendar.getInstance().getTime()); + + lsPtovtaUsuarioBancario.add(usuarioBancario); + + List lsP = new ArrayList(); + for (PtoVtaUsuarioBancario p : lsPtovtaUsuarioBancario) { + if (p.getActivo()) { + lsP.add(p); + } + } + ptovtaUsuarioBancarioList.setData(lsP); + // ptovtaEmpresaList.addItem(ptovtaEmpresa); + + } else { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.Achou.PtovtaUsuario"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + } + + } catch (Exception ex) { + log.error(ex); + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } + } + + public void onClick$btnApagarPtovtaUsuarioBancario(Event ev) { + try { + PtoVtaUsuarioBancario fpd = (PtoVtaUsuarioBancario) ptovtaUsuarioBancarioList.getSelected(); + if (fpd != null) { + ptovtaUsuarioBancarioList.removeItem(fpd); + lsPtovtaUsuarioBancario.remove(fpd); + if (fpd.getPtovtaUsuarioBancarioID() != null) { + fpd.setActivo(Boolean.FALSE); + fpd.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + fpd.setFecmodif(Calendar.getInstance().getTime()); + + lsPtovtaUsuarioBancario.add(fpd); + } + } + } catch (Exception ex) { + log.error(ex); + } + } + + public void onClick$btnAdicionarEmpresaComissao(Event ev) throws InterruptedException { + if (cmbEmpresaComissao.getSelectedItem() == null) { + Messagebox.show( + Labels.getLabel("MSG.Error.combobox"), + Labels.getLabel("editarPricingController.windowMarca.title"), + Messagebox.OK, Messagebox.EXCLAMATION); + return; + } + Empresa empresa = (Empresa) cmbEmpresaComissao.getSelectedItem().getValue(); + + PtovtaComissao ptovtaComissao = new PtovtaComissao(); + + ptovtaComissao.setEmpresaId(empresa); + ptovtaComissao.setPuntoventaId(this.puntoVenta); + + ptovtaComissaoService.suscribir(ptovtaComissao); + + lsPtovtaComissao.add(ptovtaComissao); + + List lsPtovtaComissaoAtivo = new ArrayList(); + for (PtovtaComissao rc : lsPtovtaComissao) { + if (rc.getActivo()) { + lsPtovtaComissaoAtivo.add(rc); + } + } + ptovtaComissaoList.setData(lsPtovtaComissaoAtivo); + + cmbEmpresaComissao.getSelectedItem().setVisible(false); + + abrirPtovtaComissao(ptovtaComissao); + + } + + public PuntoVenta getPuntoVenta() { + return puntoVenta; + } + + public void setPuntoVenta(PuntoVenta puntoVenta) { + this.puntoVenta = puntoVenta; + } + + public MyListbox getPuntoVentaList() { + return puntoVentaList; + } + + public MyListbox getAntecipaList() { + return ptovtaAntecipaList; + } + + public void setAntecipaList(MyListbox antecipaList) { + this.ptovtaAntecipaList = antecipaList; + } + + public void setPuntoVentaList(MyListbox puntoVentaList) { + this.puntoVentaList = puntoVentaList; + } + + public PuntoVentaService getPuntoVentaService() { + return puntoVentaService; + } + + public void setPuntoVentaService(PuntoVentaService puntoVentaService) { + this.puntoVentaService = puntoVentaService; + } + + public EmpresaService getEmpresaService() { + return empresaService; + } + + public void setEmpresaService(EmpresaService empresaService) { + this.empresaService = empresaService; + } + + public TipoPuntoVentaService getTipoPuntoVentaService() { + return tipoPuntoVentaService; + } + + public void setTipoPuntoVentaService(TipoPuntoVentaService tipoPuntoVentaService) { + this.tipoPuntoVentaService = tipoPuntoVentaService; + } + + public List getLsEmpresas() { + return lsEmpresas; + } + + public void setLsEmpresas(List lsEmpresas) { + this.lsEmpresas = lsEmpresas; + } + + public List getLsPtovtaAntecipa() { + return lsAntecipacomissao; + } + + public void setLsPtovtaAntecipa(List lsAntecipacomissao) { + this.lsAntecipacomissao = lsAntecipacomissao; + } + + public List getLsHorario() { + return lsHorario; + } + + public void setLsHorario(List lsHorario) { + this.lsHorario = lsHorario; + } + + public List getLsTipoPuntoVenta() { + return lsTipoPuntoVenta; + } + + public void setLsTipoPuntoVenta(List lsTipoPuntoVenta) { + this.lsTipoPuntoVenta = lsTipoPuntoVenta; + } + + public MonedaService getMonedaService() { + return monedaService; + } + + public void setMonedaService(MonedaService monedaService) { + this.monedaService = monedaService; + } + + public List getLsMoneda() { + return lsMoneda; + } + + public void setLsMoneda(List lsMoneda) { + this.lsMoneda = lsMoneda; + } + + public InstiFinanceiraService getBancoService() { + return ptovtaBancoService; + } + + public void setBancoService(InstiFinanceiraService ptovtaBancoService) { + this.ptovtaBancoService = ptovtaBancoService; + } + + public List getLsBanco() { + return lsBanco; + } + + public void setLsBanco(List lsBanco) { + this.lsBanco = lsBanco; + } + + public Combobox getCmbBanco() { + return cmbBanco; + } + + public void setCmbBanco(Combobox cmbBanco) { + this.cmbBanco = cmbBanco; + } + + public Combobox getCmbPessoa() { + return cmbPessoa; + } + + public void setCmbPessoa(Combobox cmbPessoa) { + this.cmbPessoa = cmbPessoa; + } + + public Image getImg() { + return img; + } + + public void setImg(Image img) { + this.img = img; + } + + public Radio getRadAprobacionAutorizado() { + return radAprobacionAutorizado; + } + + public void setRadAprobacionAutorizado(Radio radAprobacionAutorizado) { + this.radAprobacionAutorizado = radAprobacionAutorizado; + } + + public Radio getRadAprobacionLatente() { + return radAprobacionLatente; + } + + public void setRadAprobacionLatente(Radio radAprobacionLatente) { + this.radAprobacionLatente = radAprobacionLatente; + } + + public Radio getRadDatosTarjetaNo() { + return radDatosTarjetaNo; + } + + public void setRadDatosTarjetaNo(Radio radDatosTarjetaNo) { + this.radDatosTarjetaNo = radDatosTarjetaNo; + } + + public Radio getRadDatosTarjetaSi() { + return radDatosTarjetaSi; + } + + public void setRadDatosTarjetaSi(Radio radDatosTarjetaSi) { + this.radDatosTarjetaSi = radDatosTarjetaSi; + } + + public MyTextbox getTxtNome() { + return txtNome; + } + + public void setTxtNome(MyTextbox txtNome) { + this.txtNome = txtNome; + } + + public MyTextbox getTxtTitularNome() { + return txtTitularNome; + } + + public void setTxtTitularNome(MyTextbox txtTitularNome) { + this.txtTitularNome = txtTitularNome; + } + + public MyTextbox getTxtTitularCpf() { + return txtTitularCpf; + } + + public void setTxtTitularCpf(MyTextbox txtTitularCpf) { + this.txtTitularCpf = txtTitularCpf; + } + + public MyTextbox getTxtTitularRg() { + return txtTitularRg; + } + + public void setTxtTitularRg(MyTextbox txtTitularRg) { + this.txtTitularRg = txtTitularRg; + } + + public MyTextbox getTxtTitularEmissor() { + return txtTitularEmissor; + } + + public void setTxtTitularEmissor(MyTextbox txtTitularEmissor) { + this.txtTitularEmissor = txtTitularEmissor; + } + + public MyListbox getFormaPagoList() { + return formaPagoList; + } + + public void setFormaPagoList(MyListbox formaPagoList) { + this.formaPagoList = formaPagoList; + } + + public List getLsFormaPago() { + return lsFormaPago; + } + + public void setLsFormaPago(List lsFormaPago) { + this.lsFormaPago = lsFormaPago; + } + + public Combobox getCmbFormaPago() { + return cmbFormaPago; + } + + public void setCmbFormaPago(Combobox cmbFormaPago) { + this.cmbFormaPago = cmbFormaPago; + } + + public Doublebox getTxtCargosExtras() { + return txtCargosExtras; + } + + public void setTxtCargosExtras(Doublebox txtCargosExtras) { + this.txtCargosExtras = txtCargosExtras; + } + + public List getLsNodos() { + return lsNodos; + } + + public void setLsNodos(List lsNodos) { + this.lsNodos = lsNodos; + } + + public Button getBtnSalvarFormaPago() { + return btnSalvarFormaPago; + } + + public void setBtnSalvarFormaPago(Button btnSalvarFormaPago) { + this.btnSalvarFormaPago = btnSalvarFormaPago; + } + + public FormaPagoService getFormaPagoService() { + return formaPagoService; + } + + public void setFormaPagoService(FormaPagoService formaPagoService) { + this.formaPagoService = formaPagoService; + } + + public List getLsFormaPagoDet() { + return lsFormaPagoDet; + } + + public void setLsFormaPagoDet(List lsFormaPagoDet) { + this.lsFormaPagoDet = lsFormaPagoDet; + } + + public Combobox getCmbCiudad() { + return cmbCiudad; + } + + public void setCmbCiudad(Combobox cmbCiudad) { + this.cmbCiudad = cmbCiudad; + } + + public Combobox getCmbEmpresa() { + return cmbEmpresa; + } + + public void setCmbEmpresa(Combobox cmbEmpresa) { + this.cmbEmpresa = cmbEmpresa; + } + + public Combobox getCmbParada() { + return cmbParada; + } + + public void setCmbParada(Combobox cmbParada) { + this.cmbParada = cmbParada; + } + + public Combobox getCmbPtoVtaCheckinParada() { + return cmbPtoVtaCheckinParada; + } + + public void setCmbPtoVtaCheckinParada(Combobox cmbPtoVtaCheckinParada) { + this.cmbPtoVtaCheckinParada = cmbPtoVtaCheckinParada; + } + + public Combobox getCmbMoneda() { + return cmbMoneda; + } + + public void setCmbMoneda(Combobox cmbMoneda) { + this.cmbMoneda = cmbMoneda; + } + + /* + * public Combobox getCmbNodo() { return cmbNodo; } + * + * public void setCmbNodo(Combobox cmbNodo) { this.cmbNodo = cmbNodo; } + */ + + public Combobox getCmbTipoPontoVenta() { + return cmbTipoPontoVenta; + } + + public void setCmbTipoPontoVenta(Combobox cmbTipoPontoVenta) { + this.cmbTipoPontoVenta = cmbTipoPontoVenta; + } + + /** + * @return the lsColonia + */ + public List getLsColonia() { + return lsColonia; + } + + /** + * @param lsColonia + * the lsColonia to set + */ + public void setLsColonia(List lsColonia) { + this.lsColonia = lsColonia; + } + + /** + * @return the cmbColonia + */ + public Combobox getCmbColonia() { + return cmbColonia; + } + + /** + * @param cmbColonia + * the cmbColonia to set + */ + public void setCmbColonia(Combobox cmbColonia) { + this.cmbColonia = cmbColonia; + } + + /** + * @return the txtCP + */ + public Textbox getTxtCP() { + return txtCP; + } + + /** + * @param txtCP + * the txtCP to set + */ + public void setTxtCP(Textbox txtCP) { + this.txtCP = txtCP; + } + + public MyTextbox getTxtNumAg() { + return txtNumAg; + } + + public void setTxtNumAg(MyTextbox txtNumAg) { + this.txtNumAg = txtNumAg; + } + + public List getLsUsuarioBancario() { + return lsUsuarioBancario; + } + + public void setLsUsuarioBancario(List lsUsuarioBancario) { + this.lsUsuarioBancario = lsUsuarioBancario; + } + + public List getLsParamRecoleccion() { + return lsParamRecoleccion; + } + + public void setLsParamRecoleccion(List lsParamRecoleccion) { + this.lsParamRecoleccion = lsParamRecoleccion; + } + + public Intbox getTxtQuant() { + return txtQuant; + } + + public void setTxtQuant(Intbox txtQuant) { + this.txtQuant = txtQuant; + } + + public Intbox getTxtcodAg() { + return txtcodAg; + } + + public void setTxtcodAg(Intbox txtcodAg) { + this.txtcodAg = txtcodAg; + } + + public MyTextbox getTxtNumFax() { + return txtNumFax; + } + + public void setTxtNumFax(MyTextbox txtNumFax) { + this.txtNumFax = txtNumFax; + } + + public MyTextbox getTxtCompl() { + return txtCompl; + } + + public void setTxtCompl(MyTextbox txtCompl) { + this.txtCompl = txtCompl; + } + + public MyTextbox getTxtEspecie() { + return txtEspecie; + } + + public void setTxtEspecie(MyTextbox txtEspecie) { + this.txtEspecie = txtEspecie; + } + + public Textbox getTxtNomeBanco() { + return txtNomeBanco; + } + + public void setTxtNomeBanco(Textbox txtNomeBanco) { + this.txtNomeBanco = txtNomeBanco; + } + + public MyTextbox getTxtConta() { + return txtConta; + } + + public void setTxtConta(MyTextbox txtConta) { + this.txtConta = txtConta; + } + + public MyTextbox getTxtDigito() { + return txtDigito; + } + + public void setTxtDigito(MyTextbox txtDigito) { + this.txtDigito = txtDigito; + } + + public MyTextbox getTxtBilhetes() { + return txtBilhetes; + } + + public void setTxtBilhetes(MyTextbox txtBilhetes) { + this.txtBilhetes = txtBilhetes; + } + + public MyTextbox getTxtCarga() { + return txtCarga; + } + + public void setTxtCarga(MyTextbox txtCarga) { + this.txtCarga = txtCarga; + } + + public Datebox getDateAntecipData() { + return dateAntecipData; + } + + public void setDateAntecipData(Datebox dateAntecipData) { + this.dateAntecipData = dateAntecipData; + } + + public MyTextboxDecimal getTxtAntecipRetem() { + return txtAntecipRetem; + } + + public void setTxtAntecipRetem(MyTextboxDecimal txtAntecipRetem) { + this.txtAntecipRetem = txtAntecipRetem; + } + + public MyTextboxDecimal getTxtAntecipPercentual() { + return txtAntecipPercentual; + } + + public void setTxtAntecipPercentual(MyTextboxDecimal txtAntecipPercentual) { + this.txtAntecipPercentual = txtAntecipPercentual; + } + + public Timebox getTimeboxInicio() { + return timeboxInicio; + } + + public void setTimeboxInicio(Timebox timeboxInicio) { + this.timeboxInicio = timeboxInicio; + } + + public Timebox getTimeboxFim() { + return timeboxFim; + } + + public void setTimeboxFim(Timebox timeboxFim) { + this.timeboxFim = timeboxFim; + } + + public MyListbox getParamRecoleccionList() { + return paramRecoleccionList; + } + + public void setParamRecoleccionList(MyListbox paramRecoleccionList) { + this.paramRecoleccionList = paramRecoleccionList; + } + + public List getLsPtovtaEmpresa() { + return lsPtovtaEmpresa; + } + + public void setLsPtovtaEmpresa(List lsPtovtaEmpresa) { + this.lsPtovtaEmpresa = lsPtovtaEmpresa; + } + + public MyListbox getPtovtaEmpresaList() { + return ptovtaEmpresaList; + } + + public void setPtovtaEmpresaList(MyListbox ptovtaEmpresaList) { + this.ptovtaEmpresaList = ptovtaEmpresaList; + } + + public List getLsPtovtaUsuarioBancario() { + return lsPtovtaUsuarioBancario; + } + + public void setLsPtovtaUsuarioBancario(List lsPtovtaUsuarioBancario) { + this.lsPtovtaUsuarioBancario = lsPtovtaUsuarioBancario; + } + + public MyListbox getPtovtaUsuarioBancarioList() { + return ptovtaUsuarioBancarioList; + } + + public void setPtovtaUsuarioBancarioList(MyListbox ptovtaUsuarioBancarioList) { + this.ptovtaUsuarioBancarioList = ptovtaUsuarioBancarioList; + } + + public List getLsEmpresaComissao() { + return lsEmpresaComissao; + } + + public void setLsEmpresaComissao(List lsEmpresaComissao) { + this.lsEmpresaComissao = lsEmpresaComissao; + } + + public Combobox getCmbEmpresaComissao() { + return cmbEmpresaComissao; + } + + public void setCmbEmpresaComissao(Combobox cmbEmpresaComissao) { + this.cmbEmpresaComissao = cmbEmpresaComissao; + } + + public Button getBtnAdicionarEmpresaComissao() { + return btnAdicionarEmpresaComissao; + } + + public void setBtnAdicionarEmpresaComissao(Button btnAdicionarEmpresaComissao) { + this.btnAdicionarEmpresaComissao = btnAdicionarEmpresaComissao; + } + + public MyTextbox getTxtNumDoCPuntoVenta() { + return txtNumDoCPuntoVenta; + } + + public void setTxtNumDoCPuntoVenta(MyTextbox txtNumDoCPuntoVenta) { + this.txtNumDoCPuntoVenta = txtNumDoCPuntoVenta; + } + + public MyTextbox getTxtRazonSocial() { + return txtRazonSocial; + } + + public void setTxtRazonSocial(MyTextbox txtRazonSocial) { + this.txtRazonSocial = txtRazonSocial; + } + + public String getLogFileSelected() { + return logFileSelected; + } + + public void setLogFileSelected(String logFileSelected) { + this.logFileSelected = logFileSelected; + } + + public void onChange$cmbPuntoVentaPadre(Event ev) throws InterruptedException { + if (puntoVenta.getPuntoventaId() != null) { + List lsPuntosSubordinados = puntoVentaService.buscarPuntoVentaSubordinados(puntoVenta); + + if (!lsPuntosSubordinados.isEmpty()) { + StringBuilder sbPuntosSubordinados = new StringBuilder("\n"); + for (PuntoVenta pv : lsPuntosSubordinados) { + sbPuntosSubordinados.append(pv.getNombpuntoventa()).append("\n"); + } + + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.msg.naopodesersubordinadapossuisubordinadas") + sbPuntosSubordinados.toString(), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + + cmbPuntoVentaPadre.setSelectedItem(null); + cmbPuntoVentaPadre.setText(null); + } + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void abrirPtovtaComissao(PtovtaComissao ptovtaComissao) { + Map args = new HashMap(); + args.put("ptovtaComissao", ptovtaComissao); + args.put("ptovtaComissaoList", ptovtaComissaoList); + + openWindow("/gui/catalogos/editarPuntoVentaComissao.zul", + Labels.getLabel("editarPuntoVentaComissaoController.window.title", new String[] { ptovtaComissao.getEmpresaId().getNombempresa() }), args, MODAL); + + } + + public void onClick$btnApagarFechamentoParamptovta(Event ev) { + try { + if (fechamentoParamptovtaList.getSelected() != null) { + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.borrarFechamentoParamptovta"), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + FechamentoParamptovta fpp = (FechamentoParamptovta) fechamentoParamptovtaList.getSelected(); + fechamentoParamptovtaList.removeItem(fpp); + } + } + } catch (Exception ex) { + log.error(ex.toString()); + } + } + + public void onClick$btnAdicionarFechamentoParamptovta(Event ev) { + txtDiasemtransito.getValue(); + + if (cmbEmpresaFechamentoParamptovta.getSelectedItem() != null && + (radIntervalofechamentoDiario.isChecked() || radIntervalofechamentoSemanal.isChecked() + || radIntervalofechamentoDecendial.isChecked() + || radIntervalofechamentoQuinzenal.isChecked() + || radIntervalofechamentoMensal.isChecked())) { + Empresa empresa = (Empresa) cmbEmpresaFechamentoParamptovta.getSelectedItem().getValue(); + + FechamentoParamptovta fechamentoParamptovta = new FechamentoParamptovta(); + fechamentoParamptovta.setEmpresa(empresa); + fechamentoParamptovta.setPuntoventa(puntoVenta); + Integer intervalofechamento = 0; + + if (radIntervalofechamentoSemanal.isChecked()) { + intervalofechamento = Constantes.INTERVALO_FECHAMENTO_SEMANAL; + + } else if (radIntervalofechamentoDecendial.isChecked()) { + intervalofechamento = Constantes.INTERVALO_FECHAMENTO_DECENDIAL; + + } else if (radIntervalofechamentoQuinzenal.isChecked()) { + intervalofechamento = Constantes.INTERVALO_FECHAMENTO_QUINZENAL; + + } else if (radIntervalofechamentoMensal.isChecked()) { + intervalofechamento = Constantes.INTERVALO_FECHAMENTO_MENSAL; + + } else if (radIntervalofechamentoDiario.isChecked()) { + intervalofechamento = Constantes.INTERVALO_FECHAMENTO_DIARIO; + } + + if (radTipoPagamentoBoleto.isChecked()){ + fechamentoParamptovta.setTipopagamento("B"); + } else { + fechamentoParamptovta.setTipopagamento("D"); + } + + fechamentoParamptovta.setIntervalofechamento(intervalofechamento); + + if (StringUtils.isNotBlank(txtDiasemtransito.getValue())) { + fechamentoParamptovta.setDiasemtransito(Integer.valueOf(txtDiasemtransito.getValue())); + } + + fechamentoParamptovta.setActivo(true); + fechamentoParamptovta.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + fechamentoParamptovta.setFecmodif(new Date()); + + boolean validado = validaFechamentoParamptovta(fechamentoParamptovta); + + if (validado) { + fechamentoParamptovtaList.addItemNovo(fechamentoParamptovta); + resetDadosFechamentoParamptovta(); + } + } + } + + private void resetDadosFechamentoParamptovta() { + + cmbEmpresaFechamentoParamptovta.setSelectedItem(null); + + radIntervalofechamentoSemanal.setChecked(false); + radIntervalofechamentoDecendial.setChecked(false); + radIntervalofechamentoQuinzenal.setChecked(false); + radIntervalofechamentoMensal.setChecked(false); + radIntervalofechamentoDiario.setChecked(false); + radTipoPagamentoBoleto.setChecked(true); + + txtDiasemtransito.setValue(""); + } + + private boolean validaFechamentoParamptovta(FechamentoParamptovta fechamentoParamptovta) { + boolean validado = true; + try { + // Valida Empresa Fechamento ja cadastrada. + Object[] params = fechamentoParamptovtaList.getData(); + for (Object objectData : params) { + + FechamentoParamptovta param = (FechamentoParamptovta) objectData; + if (fechamentoParamptovta.getEmpresa().getEmpresaId() == param.getEmpresa().getEmpresaId()) { + validado = false; + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.fechamentoParamptovtaInvalidado"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + return validado; + } + } + // Valida Empresa para Venda Cadastrada + Object[] empresasVenda = ptovtaEmpresaList.getData(); + for (Object empresa : empresasVenda) { + if (fechamentoParamptovta.getEmpresa().getEmpresaId() == ((PtovtaEmpresa) empresa).getEmpresa().getEmpresaId()) { + return validado; + } + } + validado = false; + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.fechamentoParamptovtaEmpresaInvalida"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.ERROR); + } catch (Exception ex) { + log.error(ex.toString()); + } + + return validado; + } + + public Combobox getCmbEmpresaFechamentoParamptovta() { + return cmbEmpresaFechamentoParamptovta; + } + + public void setCmbEmpresaFechamentoParamptovta(Combobox cmbEmpresaFechamentoParamptovta) { + this.cmbEmpresaFechamentoParamptovta = cmbEmpresaFechamentoParamptovta; + } + + public Radio getRadTotvsSi() { + return radTotvsSi; + } + + public void setRadTotvsSi(Radio radTotvsSi) { + this.radTotvsSi = radTotvsSi; + } + + public Radio getRadTotvsNo() { + return radTotvsNo; + } + + public void setRadTotvsNo(Radio radTotvsNo) { + this.radTotvsNo = radTotvsNo; + } + + public Radio getRadTotvsErro() { + return radTotvsErro; + } + + public void setRadTotvsErro(Radio radTotvsErro) { + this.radTotvsErro = radTotvsErro; + } + + public boolean isIntegracionTotvs() { + if(isPerfilFuncionBloqueiaDesbloqueiaPontoVenda) { + return false; + } + integracionTotvs = false; + if (ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.INTEGRACION_TOTVS.getDescricao())) { + integracionTotvs = true; + } + return integracionTotvs; + } + + public boolean isIntegracionAG() { + if(isPerfilFuncionBloqueiaDesbloqueiaPontoVenda) { + return false; + } + integracionAG = false; + if (ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.INTEGRACION_AG.getDescricao())) { + integracionAG = true; + } + return integracionAG; + } + + public void setIntegracionTotvs(boolean integracionTotvs) { + this.integracionTotvs = integracionTotvs; + } + + public void setIntegracionAG(boolean integracionAG) { + this.integracionAG = integracionAG; + } + + public List getLsLogFiles() { + return lsLogFiles; + } + + public void setLsLogFiles(List lsLogFiles) { + this.lsLogFiles = lsLogFiles; + } + + public Button getBtnShowLog() { + return btnShowLog; + } + + public void setBtnShowLog(Button btnShowLog) { + this.btnShowLog = btnShowLog; + } + + public static void compactarArquivo(String arqSaida, String arqEntrada) throws IOException { + int cont; + byte[] dados = new byte[TAMANHO_BUFFER]; + BufferedInputStream origem = null; + FileInputStream streamDeEntrada = null; + FileOutputStream destino = null; + ZipOutputStream saida = null; + ZipEntry entry = null; + try { + destino = new FileOutputStream(new File(arqSaida)); + saida = new ZipOutputStream(new BufferedOutputStream(destino)); + File file = new File(arqEntrada); + streamDeEntrada = new FileInputStream(file); + origem = new BufferedInputStream(streamDeEntrada, TAMANHO_BUFFER); + entry = new ZipEntry(file.getName()); + saida.putNextEntry(entry); + while ((cont = origem.read(dados, 0, TAMANHO_BUFFER)) != -1) { + saida.write(dados, 0, cont); + } + origem.close(); + saida.close(); + } catch (IOException e) { + throw new IOException(e.getMessage()); + } + } + + private void excluirArquivosZip() { + File pasta = new File(System.getProperty("jboss.server.log.dir")); + File[] arquivos = pasta.listFiles(); + + for (File arquivo : arquivos) { + if (arquivo.getName().endsWith("zip")) { + arquivo.delete(); + } + } + } + + public void onClick$radIndvendsegtabelaSi(Event event) { + if (radIndvendsegtabelaSi.isChecked()) { + radIndestansegtabelaSi.setDisabled(false); + radIndestansegtabelaNo.setDisabled(false); + radIndestansegtabelaNo.setChecked(true); + } + } + + public void onClick$btnAddChaveAntifraude(Event event) { + try { + if(verificarCamposAddChaveAntifraude()) { + if (cmbEmpresaPtoVtaAntifraude.getSelectedItem() == null) { + return; + } + txtChaveAntifraude.getValue(); + + PtovtaAntifraude ptovtaAntifraude = new PtovtaAntifraude(); + ptovtaAntifraude.setEmpresa((Empresa)cmbEmpresaPtoVtaAntifraude.getSelectedItem().getValue()); + ptovtaAntifraude.setPuntoventa(puntoVenta); + ptovtaAntifraude.setChave(txtChaveAntifraude.getValue()); + ptovtaAntifraude.setTipo(TipoAntifraude.KONDUTO); + ptovtaAntifraude.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + + puntoVenta.addChaveAntifurto(ptovtaAntifraude); + + ptovtaAntifraudeList.setData(puntoVenta.getPtovtaAntifraudes()); + + txtChaveAntifraude.setValue(""); + } + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + + public void onClick$btnAddExcecaoMultaCanc(Event event) { + try { + if(verificarCamposAddExcecaoMultaCanc()) { + if (cmbEmpresaPtoVtaExcecaoMultaCanc.getSelectedItem() == null) { + return; + } + if(cmbOrgaoConcedente.getSelectedItem() == null){ + return; + } + + PtovtaExcecaoMultaCanc ptovtaExcecaoMultaCanc = new PtovtaExcecaoMultaCanc(); + ptovtaExcecaoMultaCanc.setEmpresa((Empresa)cmbEmpresaPtoVtaExcecaoMultaCanc.getSelectedItem().getValue()); + ptovtaExcecaoMultaCanc.setPuntoventa(puntoVenta); + ptovtaExcecaoMultaCanc.setOrgaoConcedente((OrgaoConcedente)cmbOrgaoConcedente.getSelectedItem().getValue()); + ptovtaExcecaoMultaCanc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + + if(puntoVenta.getPtovtaExcecaoMultaCancList() ==null) { + puntoVenta.setPtovtaExcecaoMultaCancList(new ArrayList()); + } + puntoVenta.getPtovtaExcecaoMultaCancList().add(ptovtaExcecaoMultaCanc); + ptovtaExcecaoMultaCancList.setData(puntoVenta.getPtovtaExcecaoMultaCancList()); + + + } + } catch (Exception e) { + log.error("Erro ao adicionar Excecao Multa Cancelamento", e); + } + } + + private boolean verificarCamposAddChaveAntifraude() throws InterruptedException { + if (cmbEmpresaPtoVtaAntifraude.getSelectedItem() == null) { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.empresaAntifraudeNaoInformada"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + return false; + } + + txtChaveAntifraude.getValue(); + if(StringUtils.isBlank(txtChaveAntifraude.getValue())) { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.chaveAntifraudeNaoInformada"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + return false; + } + + if(puntoVenta.getPtovtaAntifraudes() != null) { + Empresa empresa = (Empresa) cmbEmpresaPtoVtaAntifraude.getSelectedItem().getValue(); + for (PtovtaAntifraude ptovtaAntifraude : puntoVenta.getPtovtaAntifraudes()) { + if(empresa.equals(ptovtaAntifraude.getEmpresa())) { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.empresaAntifraudeJaCadastrada"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + return false; + } + } + } + return true; + } + + + private boolean verificarCamposAddExcecaoMultaCanc() throws InterruptedException { + if (cmbEmpresaPtoVtaExcecaoMultaCanc.getSelectedItem() == null) { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.empresaExcecaoMultaCancNaoInformada"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + return false; + } + + if (cmbOrgaoConcedente.getSelectedItem() == null) { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.OrgaoConcedenteExcecaoMultaCancNaoInformada"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + return false; + } + + + if(puntoVenta.getPtovtaExcecaoMultaCancList() != null) { + Empresa empresa = (Empresa) cmbEmpresaPtoVtaExcecaoMultaCanc.getSelectedItem().getValue(); + OrgaoConcedente orgaoConcedente = (OrgaoConcedente) cmbOrgaoConcedente.getSelectedItem().getValue(); + + for (PtovtaExcecaoMultaCanc ptovtaExcecaoMultaCanc : puntoVenta.getPtovtaExcecaoMultaCancList()) { + if(empresa.getEmpresaId().equals(ptovtaExcecaoMultaCanc.getEmpresa().getEmpresaId()) + && orgaoConcedente.getOrgaoConcedenteId().equals(ptovtaExcecaoMultaCanc.getOrgaoConcedente().getOrgaoConcedenteId()) ) { + Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.empresaOrgaoExcecaoMultaCancJaCadastrada"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + return false; + } + } + } + return true; + } + + public void onClick$btnRemoveChaveAntifraude(Event event) { + try{ + PtovtaAntifraude ptovtaAntifraude = (PtovtaAntifraude)ptovtaAntifraudeList.getSelected(); + if(ptovtaAntifraude != null) { + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.borrarChaveAntifraude", new String[] {ptovtaAntifraude.getEmpresa() != null ? ptovtaAntifraude.getEmpresa().getNombempresa() : ""}), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + puntoVenta.removeChaveAntifurto(ptovtaAntifraude); + + if(ptovtaAntifraude.getPtovtaAntifraudeId() != null) { + ptovtaAntifraudeService.borrar(ptovtaAntifraude); + } + ptovtaAntifraudeList.setData(puntoVenta.getPtovtaAntifraudes()); + } + } + } catch (Exception e){ + log.error("", e); + } + } + + public void onClick$btnRemoveExcecaoMultaCanc(Event event) { + try{ + PtovtaExcecaoMultaCanc ptovtaExcecaoMultaCanc = (PtovtaExcecaoMultaCanc)ptovtaExcecaoMultaCancList.getSelected(); + if(ptovtaExcecaoMultaCanc != null) { + String nomeEmpresa = ptovtaExcecaoMultaCanc.getEmpresa() != null ? ptovtaExcecaoMultaCanc.getEmpresa().getNombempresa() : ""; + String nomeOrgao = ptovtaExcecaoMultaCanc.getOrgaoConcedente() != null ? ptovtaExcecaoMultaCanc.getOrgaoConcedente().getDescOrgao() : ""; + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.borrarChaveExcecaoMultaCancJaCadastrada", new String[] {nomeEmpresa, nomeOrgao}), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + puntoVenta.removePtovtaExcecaoMultaCanc(ptovtaExcecaoMultaCanc); + + if(ptovtaExcecaoMultaCanc.getPtovtaExcecaoMultaCancId() != null) { + ptovtaExcecaoMultaCancService.borrar(ptovtaExcecaoMultaCanc); + } + ptovtaExcecaoMultaCancList.setData(puntoVenta.getPtovtaExcecaoMultaCancList()); + } + } + } catch (Exception e){ + log.error("Erro ao processar remocao Exception Multa Cancelamento", e); + } + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private void verPtovtaAntifraude(PtovtaAntifraude ptovtaAntifraude) { + Map args = new HashMap(); + args.put("ptovtaComissao", ptovtaAntifraude); + args.put("puntoVenta", puntoVenta); + args.put("ptovtaAntifraudeList", ptovtaAntifraudeList); + + openWindow("/gui/catalogos/editarPtovtaAntifraude.zul", + Labels.getLabel("editarPtovtaAntifraudeController.window.title"), args, MODAL); + } + + public void onClick$radIndvendsegtabelaNo(Event event) { + if (radIndvendsegtabelaNo.isChecked()) { + radIndestansegtabelaSi.setDisabled(true); + radIndestansegtabelaNo.setDisabled(true); + radIndestansegtabelaNo.setChecked(true); + } + } + + public void onClick$ckValidarTempoParaImpressao(Event event) { + if (ckValidarTempoParaImpressao.isChecked()) { + txtTempoParaImpressao.setDisabled(Boolean.FALSE); + txtTempoParaImpressao.setValue(null); + } else { + txtTempoParaImpressao.setDisabled(Boolean.TRUE); + txtTempoParaImpressao.setValue(null); + } + } + + public void onClick$radAprobacionLatente(Event event) { + if (radAprobacionLatente.isChecked()) { + rowDateFechamento.setVisible(Boolean.TRUE); + } + } + + public void onClick$radAprobacionAutorizado(Event event) { + if (!radAprobacionLatente.isChecked()) { + dateFechamento.setValue(puntoVenta.getDateFechamento()); + rowDateFechamento.setVisible(Boolean.FALSE); + } + } + + public Boolean isPermissaoEditarComissao() { + return UsuarioLogado.getUsuarioLogado().isPermisoClave(ConstantesFuncionSistema.CLAVE_EDITAR_COMISSAO); + } + + public List getLsEmpresaContaBancarias() { + return lsEmpresaContaBancarias; + } + + public void setLsEmpresaContaBancarias(List lsEmpresaContaBancarias) { + this.lsEmpresaContaBancarias = lsEmpresaContaBancarias; + } + + public MyComboboxEstandar getCmbEmpresasContaBancarias() { + return cmbEmpresasContaBancarias; + } + + public void setCmbEmpresasContaBancarias(MyComboboxEstandar cmbEmpresasContaBancarias) { + this.cmbEmpresasContaBancarias = cmbEmpresasContaBancarias; + } + + public List getLsEmpresasFormapago() { + return lsEmpresasFormapago; + } + + public void setLsEmpresasFormapago(List lsEmpresasFormapago) { + this.lsEmpresasFormapago = lsEmpresasFormapago; + } + + public Timebox getTxtTempoParaImpressao() { + return txtTempoParaImpressao; + } + + public void setTxtTempoParaImpressao(Timebox txtTempoParaImpressao) { + this.txtTempoParaImpressao = txtTempoParaImpressao; + } + + public Checkbox getCkValidarTempoParaImpressao() { + return ckValidarTempoParaImpressao; + } + + public void setCkValidarTempoParaImpressao(Checkbox ckValidarTempoParaImpressao) { + this.ckValidarTempoParaImpressao = ckValidarTempoParaImpressao; + } + + public MyListbox getPtovtaHistoricoList() { + return ptovtaHistoricoList; + } + + public void setPtovtaHistoricoList(MyListbox ptovtaHistoricoList) { + this.ptovtaHistoricoList = ptovtaHistoricoList; + } + + public List getLsCategoriaBloquear() { + return lsCategoriaBloquear; + } + + public void setLsCategoriaBloquear(List lsCategoriaBloquear) { + this.lsCategoriaBloquear = lsCategoriaBloquear; + } + + + /** + * @return the txtTaxaConvenienciaPorc + */ + public Decimalbox getTxtTaxaConvenienciaPorc() { + return txtTaxaConvenienciaPorc; + } + + /** + * @param txtTaxaConvenienciaPorc the txtTaxaConvenienciaPorc to set + */ + public void setTxtTaxaConvenienciaPorc(Decimalbox txtTaxaConvenienciaPorc) { + this.txtTaxaConvenienciaPorc = txtTaxaConvenienciaPorc; + } + + /** + * @return the txtMaximoTaxaConveniencia + */ + public Doublebox getTxtMaximoTaxaConveniencia() { + return txtMaximoTaxaConveniencia; + } + + /** + * @param txtMaximoTaxaConveniencia the txtMaximoTaxaConveniencia to set + */ + public void setTxtMaximoTaxaConveniencia(Doublebox txtMaximoTaxaConveniencia) { + this.txtMaximoTaxaConveniencia = txtMaximoTaxaConveniencia; + } + + /** + * @return the ct + */ + public ConstraintPorcentagemAllowNull getCt() { + return ct; + } + + /** + * @param ct the ct to set + */ + public void setCt(ConstraintPorcentagemAllowNull ct) { + this.ct = ct; + } + + public Radio getRadIndvendsegtabelaSi() { + return radIndvendsegtabelaSi; + } + + public void setRadIndvendsegtabelaSi(Radio radIndvendsegtabelaSi) { + this.radIndvendsegtabelaSi = radIndvendsegtabelaSi; + } + + public Radio getRadIndvendsegtabelaNo() { + return radIndvendsegtabelaNo; + } + + public void setRadIndvendsegtabelaNo(Radio radIndvendsegtabelaNo) { + this.radIndvendsegtabelaNo = radIndvendsegtabelaNo; + } + + public List getLsEmpresasSemTodos() { + return lsEmpresasSemTodos; + } + + public MyListbox getCategoriaList() { + return categoriaList; + } + + public void setCategoriaList(MyListbox categoriaList) { + this.categoriaList = categoriaList; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void autoCompleteBandbox(String change) { + categoriaList.clear(); + + if (StringUtils.isNotEmpty(change)) { + for (Object categoria : lsCategoriaBloquear) { + if (categoria.toString().toUpperCase().contains(change.toUpperCase())) { + categoriaList.addItemNovo(categoria); + } + } + } else { + inserirItensLista(lsCategoriaBloquear); + } + categoriaList.selectItems(new ArrayList(lsCategoriaSel)); + } + + private void inserirItensLista(Collection itensLista) { + for (Object c : itensLista) { + categoriaList.addItemNovo(c); + } + } + + public void onSelect$categoriaList(Event ev){ + ForwardEvent fev = (ForwardEvent) ev; + SelectEvent selEv = (SelectEvent) fev.getOrigin(); + + Listitem i = (Listitem) selEv.getReference(); + if(i.isSelected()){ + lsCategoriaSel.add(i.getValue()); + }else{ + lsCategoriaSel.remove(i.getValue()); + } + } + + public void onCheck$radIndBloquear(Event event) { + inverterAbaTipoAssagem(Boolean.TRUE); + } + + public void onCheck$radIndLiberar(Event event) { + inverterAbaTipoAssagem(Boolean.FALSE); + } + + private void inverterAbaTipoAssagem(Boolean isBloquear) { + + if(puntoVenta == null || puntoVenta.getPuntoventaId() == null) { + return; + } + + try { + + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.lbComportamentoAbaTipoPassagem.mensagemAlerta.value"), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if(resp == Messagebox.NO) { + voltarSelecaoIndBloquear(isBloquear); + return; + } + + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void abrirMotivoFormaPagamento(FormaPagoDet formaPagoDet, Boolean inclusao, Integer empresaId) { + Map args = new HashMap(); + args.put("puntoVenta", puntoVenta); + args.put("formaPagoDet", formaPagoDet); + args.put("formaPagoList", formaPagoList); + args.put("ptovtaHistoricoFormaPagoList", ptovtaHistoricoFormaPagoList); + args.put("inclusao", inclusao); + args.put("empresaId", empresaId); + openWindow("/gui/catalogos/editarPuntoVentaMotivoFormaPago.zul", Labels.getLabel("editarPuntoVentaMotivoFormaPagoController.window.title", new String[] { puntoVenta.getNombpuntoventa() }), args, MODAL); + + } + + + + + + private void voltarSelecaoIndBloquear(Boolean isBloquear) { + if(isBloquear) { + radIndLiberar.setSelected(Boolean.TRUE); + }else { + radIndBloquear.setSelected(Boolean.TRUE); + } + } + + public List getLsEmpresasCobrancaAdicional() { + return lsEmpresasCobrancaAdicional; + } + + public List getLsTodasCobrancas() { + return lsTodasCobrancas; + } + + public void setLsTodasCobrancas(List lsTodasCobrancas) { + this.lsTodasCobrancas = lsTodasCobrancas; + } + + public void setLsEmpresasCobrancaAdicional(List lsEmpresasCobrancaAdicional) { + this.lsEmpresasCobrancaAdicional = lsEmpresasCobrancaAdicional; + } + + public void onCheck$radioDiario(Event event) { + deselecionaSemana(); + deselecionaMensal(); + } + + public void onCheck$radioSemanal(Event event) { + deselecionaMensal(); + } + + public void onCheck$radioMensal(Event event) { + deselecionaSemana(); + } + + public void onCheck$radioSegunda(Event event) { + selecaoRadioButtonCobrancaAdicional(); + } + + public void onCheck$radioTerca(Event event) { + selecaoRadioButtonCobrancaAdicional(); + } + + public void onCheck$radioQuarta(Event event) { + selecaoRadioButtonCobrancaAdicional(); + } + + public void onCheck$radioQuinta(Event event) { + selecaoRadioButtonCobrancaAdicional(); + } + + public void onCheck$radioSexta(Event event) { + selecaoRadioButtonCobrancaAdicional(); + } + + public void onCheck$radioPrimeiroDiaMes(Event event) { + selecionadoDiasDoMes(); + } + + public void onCheck$radioUltimoDiaMes(Event event) { + selecionadoDiasDoMes(); + } + + private void selecionadoDiasDoMes() { + if(radioPrimeiroDiaMes.isSelected() || radioUltimoDiaMes.isSelected()) { + deselecionaSemana(); + radioMensal.setSelected(true); + radioSemanal.setSelected(false); + } + } + + private void selecaoRadioButtonCobrancaAdicional() { + if(radioSegunda.isSelected() || radioTerca.isSelected() || radioQuarta.isSelected() + || radioQuinta.isSelected() || radioSexta.isSelected()) { + radioSemanal.setSelected(true); + radioDiario.setSelected(false); + radioMensal.setSelected(false); + } + } + + private void deselecionaSemana() { + radioSegunda.setSelected(false); + radioTerca.setSelected(false); + radioQuarta.setSelected(false); + radioQuinta.setSelected(false); + radioSexta.setSelected(false); + } + + private void deselecionaMensal() { + radioPrimeiroDiaMes.setSelected(false); + radioUltimoDiaMes.setSelected(false); + } + + public void onClick$btnSalvarCobrancaAdicional(Event ev) { + + if(!validaInsercaoCobrancaAdicional()) { + return; + } + + boolean novo = true; + + for (CobrancaAdcPuntoVenta p : puntoVenta.getCobrancaAdicionalList()) { + if (p.getCobrancaAddPuntoVenta_id() != null && p.getActivo() && p.equals(cobrancaAux)) { + cobrancaAux = p; + novo = false; + } + } + + if(novo) { + cobrancaAux = new CobrancaAdcPuntoVenta(); + } + + Empresa empresa = (Empresa) cmbEmpresaCobranca.getSelectedItem().getValue(); + + cobrancaAux.setDescricao(descricaoCobranca.getValue()); + cobrancaAux.setEmpresa(empresa); + cobrancaAux.setValor(BigDecimal.valueOf(valorCobrancaAdicional.getValue())); + cobrancaAux.setPuntoVenta(puntoVenta); + cobrancaAux.setDiario(radioDiario.isSelected()); + cobrancaAux.setSemanal(radioSemanal.isSelected()); + cobrancaAux.setMensal(radioMensal.isSelected()); + cobrancaAux.setSegunda(radioSegunda.isSelected()); + cobrancaAux.setTerca(radioTerca.isSelected()); + cobrancaAux.setQuarta(radioQuarta.isSelected()); + cobrancaAux.setQuinta(radioQuinta.isSelected()); + cobrancaAux.setSexta(radioSexta.isSelected()); + cobrancaAux.setPrimeiroDiaUtil(radioPrimeiroDiaMes.isSelected()); + cobrancaAux.setUltimoDiaUtil(radioUltimoDiaMes.isSelected()); + + cobrancaAux.setDataInicial(dataInicioCobranca.getValue()); + cobrancaAux.setDataFinal(dataFimCobranca.getValue()); + + cobrancaAux.setDescontarProximoCiclo(radioProximoCiclo.isSelected()); + cobrancaAux.setDescontarProximoDia(radioProximoDia.isSelected()); + + if(novo) { + puntoVenta.addCobrancaAddPuntoVenta(cobrancaAux); + } + + cobrancaAdicionalList.setData(puntoVenta.getCobrancaAdicionalList()); + } + + private Boolean validaInsercaoCobrancaAdicional() { + try { + if (cmbEmpresaCobranca.getValue() == null) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemEmpresa.value"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + return false; + } + + if (descricaoCobranca.getValue() == null || descricaoCobranca.getValue().isEmpty()) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemDescricao.value"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + return false; + } + + if (dataInicioCobranca.getValue() == null || dataFimCobranca.getValue() == null) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemDatas.value"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + return false; + } + + if (valorCobrancaAdicional.getValue() == null || valorCobrancaAdicional.getValue() == 0) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemValor.value"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + + return false; + } + + if (!( radioDiario.isSelected() || radioMensal.isSelected() || radioSemanal.isSelected() )) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemFrequencia.value"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + + return false; + + } else if(radioSemanal.isSelected()) { //Se escolher semana e nao escolher um dia + if(!( radioSegunda.isSelected() || radioTerca.isSelected() || radioQuarta.isSelected() + || radioQuinta.isSelected() || radioSexta.isSelected())) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemFrequencia.value"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + + return false; + } + } + + if (!(radioProximoCiclo.isSelected() || radioProximoDia.isSelected())) { + Messagebox.show(Labels.getLabel("editarPuntoVentaController.erroSemPagamentoDinheiro.value"), + Labels.getLabel(TITULO), + Messagebox.OK, Messagebox.EXCLAMATION); + + return false; + } + } catch (Exception e) { + log.error("Erro ao validar a inserção da cobranca adicional no ponto de venda: ", e); + } + + return true; + } + + public void onClick$btnApagarCobrancaAdicional(Event event) { + try{ + int resp = Messagebox.show( + Labels.getLabel("editarPuntoVentaController.MSG.apagarCobrancaAdicional"), + Labels.getLabel(TITULO), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + CobrancaAdcPuntoVenta cobranca = (CobrancaAdcPuntoVenta)cobrancaAdicionalList.getSelected(); + + puntoVenta.removeCobrancaAddPuntoVenta(cobranca); + + if (cobranca.getCobrancaAddPuntoVenta_id() != null) { + cobrancaAdcService.borrar(cobranca); + } + + carregarCobrancaAdicional(null); + cobrancaAdicionalList.setData(puntoVenta.getCobrancaAdicionalList()); + } + } catch (Exception e){ + log.error("Erro ao apagar cobranca adicional", e); + } + } + + private void carregarCobrancaAdicional(CobrancaAdcPuntoVenta cobranca) { + if(cobranca != null) { + cobrancaAux = cobranca; + + descricaoCobranca.setValue(cobrancaAux.getDescricao()); + valorCobrancaAdicional.setValue(cobrancaAux.getValor().doubleValue()); + + cmbEmpresaCobranca.setSelectedIndex(lsEmpresasCobrancaAdicional.indexOf(cobrancaAux.getEmpresa())); + + dataInicioCobranca.setValue(cobranca.getDataInicial()); + dataFimCobranca.setValue(cobranca.getDataFinal()); + + radioDiario.setSelected(cobrancaAux.getDiario()); + radioSemanal.setSelected(cobrancaAux.getSemanal()); + radioMensal.setSelected(cobrancaAux.getMensal()); + radioSegunda.setSelected(cobrancaAux.getSegunda()); + radioTerca.setSelected(cobrancaAux.getTerca()); + radioQuarta.setSelected(cobrancaAux.getQuarta()); + radioQuinta.setSelected(cobrancaAux.getQuinta()); + radioSexta.setSelected(cobrancaAux.getSexta()); + + radioPrimeiroDiaMes.setSelected(cobrancaAux.getPrimeiroDiaUtil()); + radioUltimoDiaMes.setSelected(cobrancaAux.getUltimoDiaUtil()); + + radioProximoCiclo.setSelected(cobrancaAux.getDescontarProximoCiclo()); + radioProximoDia.setSelected(cobrancaAux.getDescontarProximoDia()); + } + } + + public void onClick$btnPesquisarHistorico(Event event) { + try{ + CobrancaAdcPuntoVenta cobranca = (CobrancaAdcPuntoVenta) cmbCobrancasPuntoVenta.getSelectedItem().getValue(); + + List historicoCobranca = cobrancaAdcService.buscaHistoricoCobranca(cobranca, dataInicioHistorico.getValue(), dataFimHistorico.getValue()); + + historicoCobrancaList.setData(historicoCobranca); + + } catch (Exception e){ + log.error("Erro ao buscar historico da cobranca adicional", e); + } + } + + @Transactional + public boolean utilizaCobrancaAdicional() { + if(isPerfilFuncionBloqueiaDesbloqueiaPontoVenda) { + return false; + } + Usuario usuarioLogado = usuarioService.obtenerID(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + List listUsuarioPerfil = usuarioLogado.getUsuarioPerfilList(); + for (UsuarioPerfil up : listUsuarioPerfil) { + List listPerfilFuncion = up.getPerfil().getPerfilFuncionList(); + for (PerfilFuncion pf : listPerfilFuncion) { + if(pf.getFuncionSistema().getDescruta().equals(FUNCION_COBRANCA_ADICIONAL)) + return true; + } + } + + return false; + } + + @Transactional + public boolean isPermiteInserirMotivoFormaPago() { + + Usuario usuarioLogado = usuarioService.obtenerID(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + List listUsuarioPerfil = usuarioLogado.getUsuarioPerfilList(); + for (UsuarioPerfil up : listUsuarioPerfil) { + List listPerfilFuncion = up.getPerfil().getPerfilFuncionList(); + for (PerfilFuncion pf : listPerfilFuncion) { + if(pf.getFuncionSistema().getDescruta().equals(FUNCION_INSERI_MOTIVO_FORMA_PAGO)) + return true; + } + } + + return false; + } + + public void onClick$btnPesquisaHistoricoFormaPago(Event ev) throws InterruptedException { + + HibernateSearchObject busqueda = new HibernateSearchObject(HistoricoFormaPagoPuntoVenta.class, pagingHistoricoFormaPago.getPageSize()); + + Empresa empresa = (Empresa) cmbHistoricoEmpresaFormaPago.getSelectedItem().getValue(); + Integer[] formaPagosIds = new Integer[puntoVentaHistoricoFormaPagoListSel.getSize()]; + + if (radIndInclusaoHistoricoFormaPago.isChecked()) { + busqueda.addFilterEqual("indInclusao", Boolean.TRUE); + }else if(radIndEclusaoHistoricoFormaPago.isChecked()) { + busqueda.addFilterEqual("indInclusao", Boolean.FALSE); + } + + busqueda.addFilterGreaterOrEqual("fecAlteracao", DateUtil.inicioFecha(fecInicioAlteracaoHistoricoFormaPago.getValue())); + busqueda.addFilterLessOrEqual("fecAlteracao", DateUtil.fimFecha(fecFimAlteracaoHistoricoFormaPago.getValue())); + + if (empresa != null && empresa.getEmpresaId() != -1) { + busqueda.addFilterEqual("empresaId", empresa.getEmpresaId()); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + List lsFormaPagoSelecionados = new ArrayList(Arrays.asList(puntoVentaHistoricoFormaPagoListSel.getData())); + if (lsFormaPagoSelecionados.size() > 0) { + for (int i = 0; i < lsFormaPagoSelecionados.size(); i++) { + FormaPago formaPago = lsFormaPagoSelecionados.get(i); + formaPagosIds[i] = formaPago.getFormapagoId().intValue(); + } + } + busqueda.addFilterEqual("puntoVenta",puntoVenta); + busqueda.addFilterEqual("activo", Boolean.TRUE); + busqueda.addSortAsc("fecAlteracao"); + + if(formaPagosIds.length > 0) { + busqueda.addFilterIn("formaPagoId", Arrays.asList(formaPagosIds)); + } + plwHistoricoFormaPagoPuntoVenta.init(busqueda, ptovtaHistoricoFormaPagoList, pagingHistoricoFormaPago); + + if (ptovtaHistoricoFormaPagoList.getData().length == 0) { + try { + Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), + Labels.getLabel("busquedaPuntoVentaController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } + catch (InterruptedException ex) { + } + } + } + + public void onClick$btnPesquisaFormaPago() { + + executarPesquisaFormaPagoHistorico(); + + + } + + private void executarPesquisaFormaPagoHistorico() { + + HibernateSearchObject busqueda = new HibernateSearchObject(FormaPago.class, pagingFormaPago.getPageSize()); + + busqueda.addFilterILike("descpago", "%" + txtHistoricoDescPago.getValue() + "%"); + busqueda.addFilterEqual("activo", Boolean.TRUE); + busqueda.addFilterNotEqual("formapagoId", -1); + busqueda.addSortAsc("descpago"); + + plwHistoricoFormaPago.init(busqueda, puntoVentaHistoricoFormaPagoList, pagingFormaPago); + + puntoVentaHistoricoFormaPagoList.setItemRenderer(new RenderHistoricoFormaPagoSelecao(new EventListener() { + @Override + public void onEvent(Event arg0) throws Exception { + FormaPago pf = (FormaPago) arg0.getTarget().getAttribute("data"); + if(arg0.getTarget().getAttribute("tipo").equals(RenderHistoricoFormaPagoSelecao.BOTAO_ADICIONAR_FORMAPAGO)) { + if(puntoVentaHistoricoFormaPagoListSel.getListData().isEmpty()) { + puntoVentaHistoricoFormaPagoListSel.addItemNovo(pf); + }else { + for (Object perfilFuncion : puntoVentaHistoricoFormaPagoListSel.getListData()) { + if(!((FormaPago)perfilFuncion).equals(pf)){ + puntoVentaHistoricoFormaPagoListSel.addItemNovo(pf); + break; + } + } + } + puntoVentaHistoricoFormaPagoList.removeItem(pf); + } + } + })); + + if (puntoVentaHistoricoFormaPagoList.getData().length == 0) { + try { + Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), + Labels.getLabel("relatorioVendasBilheteiroController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } catch (InterruptedException ex) { + log.error(ex); + } + } + } + + public Boolean getUtilizaCobrancaAdicional() { + return utilizaCobrancaAdicional; + } + + public void setUtilizaCobrancaAdicional(Boolean utilizaCobrancaAdicional) { + this.utilizaCobrancaAdicional = utilizaCobrancaAdicional; + } + + public Intbox getIntTiempoMaxBoletoEnVenta() { + return intTiempoMaxBoletoEnVenta; + } + + public void setIntTiempoMaxBoletoEnVenta(Intbox intTiempoMaxBoletoEnVenta) { + this.intTiempoMaxBoletoEnVenta = intTiempoMaxBoletoEnVenta; + } + + public List getLsOrgaoConcedentes() { + return lsOrgaoConcedentes; + } + + public void setLsOrgaoConcedentes(List lsOrgaoConcedentes) { + this.lsOrgaoConcedentes = lsOrgaoConcedentes; + } + + public Tab getTabEndereco() { + return tabEndereco; + } + + public void setTabEndereco(Tab tabEndereco) { + this.tabEndereco = tabEndereco; + } + + private String mascaraTelefone(String campo) { + campo = formatString(campo,"(###)####-####"); + return campo; + } + + + public Intbox getIntTempoServicoEmVenda() { + return intTempoServicoEmVenda; + } + + public void setIntTempoServicoEmVenda(Intbox intTempoServicoEmVenda) { + this.intTempoServicoEmVenda = intTempoServicoEmVenda; + } + + private static String formatString(String value, String pattern) { + MaskFormatter mf; + try { + mf = new MaskFormatter(pattern); + mf.setValueContainsLiteralCharacters(false); + return mf.valueToString(value); + } catch (Exception e) { + return value; + } + } + + private Boolean isEdicaoDoPuntoVentaEisPermissaoMotivoFormaPago() { + if(puntoVenta.getPuntoventaId()!=null && isPermissaoMotivoFormaPago) { + return true; + } + return false; + } + + + private void obterOValorConstanteIndMotivoBloqueio() { + Constante constante = constanteService.buscarPorNomeConstante(constanteIndMotivoBloqueio); + if (constante != null && StringUtils.isNotBlank(constante.getValorconstante()) + && constante.getValorconstante().equalsIgnoreCase("true")) { + indMotivoBloqueio = true; + } + + } } \ No newline at end of file diff --git a/web/gui/catalogos/editarPuntoVenta.zul b/web/gui/catalogos/editarPuntoVenta.zul index eb03e7cd9..e3daa4167 100644 --- a/web/gui/catalogos/editarPuntoVenta.zul +++ b/web/gui/catalogos/editarPuntoVenta.zul @@ -1,2611 +1,2612 @@ - - - - - - - - - - - -