diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/GridRutaTramoCoeficiente.java b/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/GridRutaTramoCoeficiente.java index 5208088a2..2198f5b62 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/GridRutaTramoCoeficiente.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/GridRutaTramoCoeficiente.java @@ -116,7 +116,7 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende actualizaModel(); } - + private Columns generarColumns() { Columns columns = new Columns(); @@ -201,9 +201,12 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende // Campos coeficientes tarifario final Combobox cboCoeficiente1 = new Combobox(); - final Intbox ibxKm1 = new Intbox(); + // final Intbox ibxKm1 = new Intbox(); + final MyCustomTextboxDecimal ibxKm1 = new MyCustomTextboxDecimal(); + final Combobox cboCoeficiente2 = new Combobox(); - final Intbox ibxKm2 = new Intbox(); + // final Intbox ibxKm2 = new Intbox(); + final MyCustomTextboxDecimal ibxKm2 = new MyCustomTextboxDecimal(); // Cell Via final Combobox cboVia = new Combobox(); @@ -228,7 +231,7 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende llenarTramo(secuenciaRutaTramoCoeficienteVO); boolean tramoEditable = (secuenciaRutaTramoCoeficienteVO.getTramoId() == null); - boolean tramoCoeficienteEditable = (secuenciaRutaTramoCoeficienteVO.getOrgaoTramoId()== null); + boolean tramoCoeficienteEditable = (secuenciaRutaTramoCoeficienteVO.getOrgaoTramoId() == null); boolean tramoServicioEditable = (secuenciaRutaTramoCoeficienteVO.getTramoServicioId() == null); if (!tramoEditable) {// cuando el tramo no es editable, es porque ya existe. Entonces lleno la pantalla con los nuevos valores @@ -245,17 +248,17 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende } else { secuenciaRutaTramoCoeficienteVO.setTiempoRecorrido(tiempoRecorridoAntigo); } - - if (!tramoCoeficienteEditable){ + + if (!tramoCoeficienteEditable) { cboCoeficiente1.setText(secuenciaRutaTramoCoeficienteVO.getCoeficienteTarifa1().getDescCoeficiente()); - ibxKm1.setValue(secuenciaRutaTramoCoeficienteVO.getKmCoeficiente1()); - + ibxKm1.setValueBigDecimal(secuenciaRutaTramoCoeficienteVO.getKmCoeficiente1()); + cboCoeficiente2.setSelectedIndex(-1); - ibxKm2.setValue(0); - - if (secuenciaRutaTramoCoeficienteVO.getCoeficienteTarifa2() != null){ + ibxKm2.setValueBigDecimal(BigDecimal.ZERO); + + if (secuenciaRutaTramoCoeficienteVO.getCoeficienteTarifa2() != null) { cboCoeficiente2.setText(secuenciaRutaTramoCoeficienteVO.getCoeficienteTarifa2().getDescCoeficiente()); - ibxKm2.setValue(secuenciaRutaTramoCoeficienteVO.getKmCoeficiente2()); + ibxKm2.setValueBigDecimal(secuenciaRutaTramoCoeficienteVO.getKmCoeficiente2()); } } @@ -279,7 +282,8 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende // Cell Kms Real dKmsReal.setReadonly(!esTramoEditable); - dataBinder.addBinding(dKmsReal, "value", row.getUuid() + ".kmReal", null, null, "save", "com.rjconsultores.ventaboletos.web.utilerias.StringDecimalToDecimalConverter", null, null, null); + dataBinder.addBinding(dKmsReal, "value", row.getUuid() + ".kmReal", null, null, "save", + "com.rjconsultores.ventaboletos.web.utilerias.StringDecimalToDecimalConverter", null, null, null); row.appendChild(dKmsReal); // Cell Tiempo Recorrido @@ -321,7 +325,7 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende cboCoeficiente1.setId(cboCoeficiente1.getUuid()); cboCoeficiente1.setWidth("99%"); - + ListModelList lmlCoeficiente = getListCoeficienteCombobox(); if (secuenciaRutaTramoCoeficienteVO.getCoeficienteTarifa1() != null) { lmlCoeficiente.addSelection(secuenciaRutaTramoCoeficienteVO.getCoeficienteTarifa1()); @@ -334,9 +338,9 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende @Override public void onEvent(Event arg0) throws Exception { - if (cboCoeficiente1.getSelectedItem() == null){ - secuenciaRutaTramoCoeficienteVO.setCoeficienteTarifa1(null); - }else{ + if (cboCoeficiente1.getSelectedItem() == null) { + secuenciaRutaTramoCoeficienteVO.setCoeficienteTarifa1(null); + } else { secuenciaRutaTramoCoeficienteVO.setCoeficienteTarifa1((CoeficienteTarifa) cboCoeficiente1.getSelectedItem().getValue()); } } @@ -344,10 +348,13 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende }); row.appendChild(cboCoeficiente1); // Km 1 do coeficiente 1 - ibxKm1.setValue((secuenciaRutaTramoCoeficienteVO.getKmCoeficiente1() != null) ? secuenciaRutaTramoCoeficienteVO.getKmCoeficiente1() : 0); + ibxKm1.setValueBigDecimal((secuenciaRutaTramoCoeficienteVO.getKmCoeficiente1() != null) ? + secuenciaRutaTramoCoeficienteVO.getKmCoeficiente1() : BigDecimal.ZERO); + ibxKm1.setWidth("80%"); ibxKm1.setReadonly(!esTramoCoeficienteEditable); - dataBinder.addBinding(ibxKm1, "value", row.getUuid() + ".kmCoeficiente1", null, null, "save", null, null, null, null); + dataBinder.addBinding(ibxKm1, "value", row.getUuid() + ".kmCoeficiente1", null, null, + "save", "com.rjconsultores.ventaboletos.web.utilerias.StringDecimalToDecimalConverter", null, null, null); row.appendChild(ibxKm1); // Coeficiente tarifário 2 cboCoeficiente2.setId(cboCoeficiente2.getUuid()); @@ -363,27 +370,27 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende @Override public void onEvent(Event arg0) throws Exception { - if (cboCoeficiente2.getSelectedItem() == null){ - secuenciaRutaTramoCoeficienteVO.setCoeficienteTarifa2(null); - }else{ + if (cboCoeficiente2.getSelectedItem() == null) { + secuenciaRutaTramoCoeficienteVO.setCoeficienteTarifa2(null); + } else { secuenciaRutaTramoCoeficienteVO.setCoeficienteTarifa2((CoeficienteTarifa) cboCoeficiente2.getSelectedItem().getValue()); } } }); - + row.appendChild(cboCoeficiente2); // Km 2 do coeficiente 2 - ibxKm2.setValue((secuenciaRutaTramoCoeficienteVO.getKmCoeficiente2() != null) ? secuenciaRutaTramoCoeficienteVO.getKmCoeficiente2() : 0); + ibxKm2.setValueBigDecimal((secuenciaRutaTramoCoeficienteVO.getKmCoeficiente2() != null) ? + secuenciaRutaTramoCoeficienteVO.getKmCoeficiente2() : BigDecimal.ZERO); ibxKm2.setWidth("80%"); ibxKm2.setReadonly(!esTramoCoeficienteEditable); - dataBinder.addBinding(ibxKm2, "value", row.getUuid() + ".kmCoeficiente2", null, null, "save", null, null, null, null); + dataBinder.addBinding(ibxKm2, "value", row.getUuid() + ".kmCoeficiente2", null, null, + "save", "com.rjconsultores.ventaboletos.web.utilerias.StringDecimalToDecimalConverter", null, null, null); row.appendChild(ibxKm2); } - - /** * Actualiza el modelo de grid */ diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/MyCustomTextboxDecimal.java b/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/MyCustomTextboxDecimal.java index bb765f515..fbae8ca8f 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/MyCustomTextboxDecimal.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/MyCustomTextboxDecimal.java @@ -38,7 +38,7 @@ class MyCustomTextboxDecimal extends Textbox { } private void ejecutaJavaScript() { - Clients.evalJavaScript("jQuery('#" + this.getUuid() + "').format({allow_negative:false,precision: 2,decimal:'.',autofix:true});"); + Clients.evalJavaScript("jQuery('#" + this.getUuid() + "').format({allow_negative:false,precision: 2,decimal:',',autofix:true});"); } private String getBigDecimal(BigDecimal val) { diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/EditarTramosController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/EditarTramosController.java index 2bce139f3..52647f71b 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/EditarTramosController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/EditarTramosController.java @@ -4,6 +4,7 @@ */ package com.rjconsultores.ventaboletos.web.gui.controladores.esquemaoperacional; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Calendar; import java.util.List; @@ -37,7 +38,6 @@ import com.rjconsultores.ventaboletos.entidad.CoeficienteTarifa; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; import com.rjconsultores.ventaboletos.entidad.OrgaoTramo; -import com.rjconsultores.ventaboletos.entidad.Parada; import com.rjconsultores.ventaboletos.entidad.Tramo; import com.rjconsultores.ventaboletos.entidad.TramoKm; import com.rjconsultores.ventaboletos.entidad.TramoServicio; @@ -59,6 +59,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.ConstraintNumberBD; import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; +import com.rjconsultores.ventaboletos.web.utilerias.MyTextboxDecimal; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderOrgaoTramo; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderTramoKm; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderTramoServicio; @@ -121,9 +122,9 @@ public class EditarTramosController extends MyGenericForwardComposer { private Textbox txKmReal; private Textbox txtNome; private Intbox itxCantkmpagoconductor; - private Intbox txtKMCoeficiente1; - private Intbox txtKMCoeficiente2; - private Intbox txtKMCoeficiente3; + private MyTextboxDecimal txtKMCoeficiente1; + private MyTextboxDecimal txtKMCoeficiente2; + private MyTextboxDecimal txtKMCoeficiente3; private Timebox horainicio; private Timebox horafin; private Checkbox lun; @@ -223,25 +224,26 @@ public class EditarTramosController extends MyGenericForwardComposer { public void setLsOrgaoConcedentes(List lsOrgaoConcedentes) { this.lsOrgaoConcedentes = lsOrgaoConcedentes; } - private void generarDescripcionTramo(){ + + private void generarDescripcionTramo() { cmbParadaOrigem.getValue(true); cmbParadaDestino.getValue(true); cmbVia.getValue(); - + Via via = (Via) cmbVia.getSelectedItem().getValue(); - + txtNome.setText(tramoService.gerarDescripcionTramo(tramo.getOrigem(), tramo.getDestino(), via)); } - - public void onSelect$cmbParadaOrigem(){ + + public void onSelect$cmbParadaOrigem() { generarDescripcionTramo(); } - - public void onSelect$cmbParadaDestino(){ + + public void onSelect$cmbParadaDestino() { generarDescripcionTramo(); } - - public void onSelect$cmbVia(){ + + public void onSelect$cmbVia() { generarDescripcionTramo(); } @@ -249,7 +251,7 @@ public class EditarTramosController extends MyGenericForwardComposer { public void doAfterCompose(Component comp) throws Exception { existeRutaOcupaTramo = false; lsVias = viaService.obtenerTodos(); - lsEmpresa = UsuarioLogado.getUsuarioLogado().getEmpresa(); + lsEmpresa = UsuarioLogado.getUsuarioLogado().getEmpresa(); lsClaseServicio = claseServicioService.buscarTodosExceto(-1); lsCoeficienteTarifas = coeficienteTarifaService.obtenerTodos(); lsOrgaoConcedentes = orgaoConcedenteService.obtenerTodos(); @@ -308,7 +310,7 @@ public class EditarTramosController extends MyGenericForwardComposer { } private void aplicarMascaras() { - Clients.evalJavaScript("jQuery('#" + txKmReal.getUuid() + "').format({allow_negative:false,precision: 2,decimal:'.',autofix:true});"); + Clients.evalJavaScript("jQuery('#" + txKmReal.getUuid() + "').format({allow_negative:false,precision: 2,decimal:',',autofix:true});"); } public void onClick$btnSalvarServicio(Event ev) throws InterruptedException { @@ -394,7 +396,7 @@ public class EditarTramosController extends MyGenericForwardComposer { tramoTiempo.setIndaplicvie(vie.isChecked()); tramoTiempo.setIndaplicsab(sab.isChecked()); tramoTiempo.setIndaplicdom(dom.isChecked()); - tramoTiempo.setTiemporecorrido(DateUtil.getFecInicio(spHoraTiempo.getValue(),spMinutoTiempo.getValue()).getTime()); + tramoTiempo.setTiemporecorrido(DateUtil.getFecInicio(spHoraTiempo.getValue(), spMinutoTiempo.getValue()).getTime()); tramoTiempo.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); tramoTiempo.setFecmodif(Calendar.getInstance().getTime()); @@ -549,15 +551,15 @@ public class EditarTramosController extends MyGenericForwardComposer { try { tramo.setVia((Via) cmbVia.getSelectedItem().getValue()); - + tramo.setLsOrgaoTramo(lsOrgamoTramo); tramo.setLsTramoTiempo(listaTramosTiempo); tramo.setTramoServicioList(listaTramoServicio); tramo.setTramoKms(listaTramosKm); - + tramo = tramoService.suscribirActualizar(tramo); tramosList.updateItem(tramo); - + Messagebox.show(Labels.getLabel("editarTramosController.MSG.suscribirOK"), Labels.getLabel("editarTramosController.window.title"), Messagebox.OK, Messagebox.INFORMATION); @@ -655,9 +657,9 @@ public class EditarTramosController extends MyGenericForwardComposer { orgaoConcedente = (OrgaoConcedente) cbiOrgaoConcedente.getValue(); claseServicio = (ClaseServicio) cbiClaseServicio.getValue(); - Integer kmCoeficiente1 = txtKMCoeficiente1.getValue(); - Integer kmCoeficiente2 = txtKMCoeficiente2.getValue(); - Integer kmCoeficiente3 = txtKMCoeficiente3.getValue(); + BigDecimal kmCoeficiente1 = txtKMCoeficiente1.getValueDecimal(); + BigDecimal kmCoeficiente2 = txtKMCoeficiente2.getValueDecimal(); + BigDecimal kmCoeficiente3 = txtKMCoeficiente3.getValueDecimal(); if ((coeficienteTarifa1 == null) && (kmCoeficiente1 == null)) { diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderOrgaoTramo.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderOrgaoTramo.java index f36b5a9cc..35c69b18d 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderOrgaoTramo.java +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderOrgaoTramo.java @@ -1,5 +1,7 @@ package com.rjconsultores.ventaboletos.web.utilerias.render; +import java.math.BigDecimal; + import org.zkoss.zul.Listcell; import org.zkoss.zul.Listitem; import org.zkoss.zul.ListitemRenderer; @@ -17,8 +19,8 @@ public class RenderOrgaoTramo implements ListitemRenderer { Listcell lc = new Listcell(); if (orgaoTramo.getActivo()) { - Integer totalKm = 0; - + BigDecimal totalKm = BigDecimal.ZERO; + CoeficienteTarifa coeficienteTarifa1 = orgaoTramo.getCoeficienteTarifa1(); if (coeficienteTarifa1 != null) { lc = new Listcell(coeficienteTarifa1.toString()); @@ -27,9 +29,9 @@ public class RenderOrgaoTramo implements ListitemRenderer { } lc.setParent(lstm); - Integer kmCoeficienteTarifa1 = orgaoTramo.getKmCoeficiente1(); + BigDecimal kmCoeficienteTarifa1 = orgaoTramo.getKmCoeficiente1(); if (kmCoeficienteTarifa1 != null) { - totalKm += kmCoeficienteTarifa1; + totalKm.add(kmCoeficienteTarifa1); lc = new Listcell(kmCoeficienteTarifa1.toString()); } else { lc = new Listcell(""); @@ -44,9 +46,9 @@ public class RenderOrgaoTramo implements ListitemRenderer { } lc.setParent(lstm); - Integer kmCoeficienteTarifa2 = orgaoTramo.getKmCoeficiente2(); + BigDecimal kmCoeficienteTarifa2 = orgaoTramo.getKmCoeficiente2(); if (kmCoeficienteTarifa2 != null) { - totalKm += kmCoeficienteTarifa2; + totalKm.add(kmCoeficienteTarifa2); lc = new Listcell(kmCoeficienteTarifa2.toString()); } else { lc = new Listcell(""); @@ -61,9 +63,9 @@ public class RenderOrgaoTramo implements ListitemRenderer { } lc.setParent(lstm); - Integer kmCoeficienteTarifa3 = orgaoTramo.getKmCoeficiente3(); + BigDecimal kmCoeficienteTarifa3 = orgaoTramo.getKmCoeficiente3(); if (kmCoeficienteTarifa3 != null) { - totalKm += kmCoeficienteTarifa3; + totalKm.add(kmCoeficienteTarifa3); lc = new Listcell(kmCoeficienteTarifa3.toString()); } else { lc = new Listcell(""); @@ -77,7 +79,7 @@ public class RenderOrgaoTramo implements ListitemRenderer { lc = new Listcell(""); } lc.setParent(lstm); - + ClaseServicio claseServicio = orgaoTramo.getClaseServicio(); if (claseServicio != null) { lc = new Listcell(claseServicio.getDescclase()); @@ -85,10 +87,9 @@ public class RenderOrgaoTramo implements ListitemRenderer { lc = new Listcell(""); } lc.setParent(lstm); - + lc = new Listcell(totalKm.toString()); lc.setParent(lstm); - lstm.setAttribute("data", orgaoTramo); } else { diff --git a/web/gui/esquema_operacional/editarTramos.zul b/web/gui/esquema_operacional/editarTramos.zul index 46b15455b..6c8874572 100644 --- a/web/gui/esquema_operacional/editarTramos.zul +++ b/web/gui/esquema_operacional/editarTramos.zul @@ -5,23 +5,36 @@ - + -