From 35e8b7ddb96cab6c0220f405bd20383ba4b8dbe7 Mon Sep 17 00:00:00 2001 From: Razvan Raducu Date: Thu, 5 Oct 2017 14:04:47 +0200 Subject: [PATCH] =?UTF-8?q?Empezando=20cambios=20en=20pr=C3=A9stamos.=20MO?= =?UTF-8?q?STRAR=20TOTALES?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ulebankoffice/domain/AlemanDomain.java | 14 ++++++++++++++ .../web/PrestamoAlemanFormController.java | 11 +++++++++++ .../src/main/resources/messages_en.properties | 2 +- .../src/main/resources/messages_es.properties | 2 +- .../main/webapp/WEB-INF/views/germanloan.jsp | 16 ++++++++++++++++ ulebankoffice/src/main/webapp/favicon.ico | Bin 1150 -> 5430 bytes ulebankoffice/src/main/webapp/faviconOLD.ico | Bin 0 -> 1150 bytes 7 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 ulebankoffice/src/main/webapp/faviconOLD.ico diff --git a/ulebankoffice/src/main/java/es/unileon/ulebankoffice/domain/AlemanDomain.java b/ulebankoffice/src/main/java/es/unileon/ulebankoffice/domain/AlemanDomain.java index fee12d6..203db4a 100644 --- a/ulebankoffice/src/main/java/es/unileon/ulebankoffice/domain/AlemanDomain.java +++ b/ulebankoffice/src/main/java/es/unileon/ulebankoffice/domain/AlemanDomain.java @@ -38,6 +38,9 @@ public List> calcularTabla() { double[] amortizacion = new double[numFilas]; double[] interes = new double[numFilas]; double[] capitalPendiente = new double[numFilas]; + double totalAnualidad = 0; + double totalInteres = 0; + double totalAmortizacion = 0; interes[0] = capInicial * tipoInteres / tipoPeriodo; @@ -74,9 +77,20 @@ public List> calcularTabla() { itemTabla.add(Double.toString(redondear(amortizacion[i]))); itemTabla.add(Double.toString(redondear(capitalPendiente[i]))); + totalAnualidad += anualidad[i]; + totalInteres += interes[i]; + totalAmortizacion += amortizacion[i]; + tabla.add(itemTabla); } + itemTabla = new ArrayList<>(); + itemTabla.add(Double.toString(redondear(totalAnualidad))); + itemTabla.add(Double.toString(redondear(totalInteres))); + itemTabla.add(Double.toString(redondear(totalAmortizacion))); + + tabla.add(itemTabla); + return tabla; } diff --git a/ulebankoffice/src/main/java/es/unileon/ulebankoffice/web/PrestamoAlemanFormController.java b/ulebankoffice/src/main/java/es/unileon/ulebankoffice/web/PrestamoAlemanFormController.java index a05d131..6adbdd5 100644 --- a/ulebankoffice/src/main/java/es/unileon/ulebankoffice/web/PrestamoAlemanFormController.java +++ b/ulebankoffice/src/main/java/es/unileon/ulebankoffice/web/PrestamoAlemanFormController.java @@ -38,7 +38,18 @@ public ModelAndView processAdd(@ModelAttribute("prestamoMetodoAleman") @Valid List> tabla = myAleman.calcularTabla(); + /* El último elemento es el de los totales, los sumatorios, así que lo + * insertaré en otra tabla y lo elimino de la original*/ + List totales = tabla.get(tabla.size()-1); + tabla.remove(tabla.size()-1); + + /* Añado un elemento vacío al principio para que la colocación de las + * columnas corresponda con la orginal donde se cuentan los periodos */ + totales.add(0, ""); + + model.addObject("tabla", tabla); + model.addObject("tablaTotales", totales); response.addCookie(new Cookie("resultados", "1")); diff --git a/ulebankoffice/src/main/resources/messages_en.properties b/ulebankoffice/src/main/resources/messages_en.properties index 353d922..327215d 100644 --- a/ulebankoffice/src/main/resources/messages_en.properties +++ b/ulebankoffice/src/main/resources/messages_en.properties @@ -560,4 +560,4 @@ label.queryAuthor=Author label.creationDate = Creation date label.clean= Clean -label.nominalinteresttype= Nominal interest rate. \ No newline at end of file +label.nominalinteresttype= Annual nominal interest rate. \ No newline at end of file diff --git a/ulebankoffice/src/main/resources/messages_es.properties b/ulebankoffice/src/main/resources/messages_es.properties index 6a9b045..8d7a5d6 100644 --- a/ulebankoffice/src/main/resources/messages_es.properties +++ b/ulebankoffice/src/main/resources/messages_es.properties @@ -567,4 +567,4 @@ label.queryAuthor=Autor label.creationDate = Fecha de creación label.clean= Limpiar -label.nominalinteresttype= Tipo de interés nominal. \ No newline at end of file +label.nominalinteresttype= Tipo de interés nominal anual. \ No newline at end of file diff --git a/ulebankoffice/src/main/webapp/WEB-INF/views/germanloan.jsp b/ulebankoffice/src/main/webapp/WEB-INF/views/germanloan.jsp index af062ce..039b72e 100644 --- a/ulebankoffice/src/main/webapp/WEB-INF/views/germanloan.jsp +++ b/ulebankoffice/src/main/webapp/WEB-INF/views/germanloan.jsp @@ -444,6 +444,22 @@ + + + + + + + + + + + + + + + +
TOTAL TOTAL TOTAL