public IActionResult RealizarPrestamo(IFormCollection form) { var pp = new PagoPrestamo(); var pdi = new PrestamoDaoImplements(); var cdi = new CuentaDaoImplements(); NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat; nfi.NumberDecimalSeparator = "."; // Variables del formulario var cuenta = Convert.ToInt16(form["id-cuenta"]); var cliente = Convert.ToInt16(form["id-cliente"]); var efectivoSolicitado = Convert.ToDouble(form["efectivo-solicitado"], NumberFormatInfo.InvariantInfo); var tasaInteres = Convert.ToDouble(form["tasa-interes"], nfi); var limiteAño = Convert.ToInt16(form["limite-año"]); var limiteMes = Convert.ToInt16(form["limite-mes"]); var periodoPagos = Convert.ToInt16(form["periodo-pagos"]); var totalDeuda = Convert.ToDouble(form["total-deuda"], NumberFormatInfo.InvariantInfo); // Fin variables del formulario var cantidadMeses = pp.YearToMonth(limiteAño) + limiteMes; var cuotas = cantidadMeses / periodoPagos; if (cuotas < 1) { ViewBag.mensaje = "No se pudo realizar la transaccion, el plazo limite es menor que el periodo de cuotas"; ViewBag.path = "/Cliente/Prestamo"; return(View("ErrorUser", ViewBag)); } else { var mensualidad = totalDeuda / cuotas; var prestamo = new Prestamo(cliente, efectivoSolicitado, tasaInteres, cantidadMeses, periodoPagos, totalDeuda, false, cuotas, 0, DateTime.Now.AddMonths(cantidadMeses)); var id = pdi.ingresarPrestamo(prestamo); if (id > 0) { List <PagoPrestamo> lpp = new List <PagoPrestamo>(); for (int i = periodoPagos; i <= cantidadMeses; i += periodoPagos) { pp = new PagoPrestamo(id, DateTime.Now.AddMonths(i).Month, pp.NumberToMonth(DateTime.Now.AddMonths(i).Month), mensualidad, false, DateTime.Now.AddMonths(i)); lpp.Add(pp); } var verif = pdi.ingresarPagos(lpp); if (verif) { ViewBag.mensaje = "* El prestamo y la transaccion se realizaron de forma correcta"; ViewBag.mensaje += "- * Registro de pagos correcto"; Registro registro = new Registro("ABONO-PRESTAMO", efectivoSolicitado, efectivoSolicitado, cuenta); rdi.ingresarRegistros(registro); cdi.SumarEfectivoCuenta(cuenta, prestamo.efectivoSolicitado); } if (!verif) { ViewBag.mensaje += "- * Registro de pagos INCORRECTO"; } } if (id < 1) { ViewBag.mensaje += "- * Registro de prestamo INCORRECTO"; } } return(View("Correcto", ViewBag)); }
#pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() { #line 1 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Layout = "_Layout"; Cliente cliente = ViewBag.Cliente; Prestamo prestamo = ViewBag.Prestamo; var pp = new PagoPrestamo(); List <DateTime> lista = ViewBag.ListaFechas; #line default #line hidden BeginContext(191, 612, true); WriteLiteral(@"<nav aria-label=""breadcrumb""> <ol class=""breadcrumb""> <li class=""breadcrumb-item""><a href=""/Home/Index"">Inicio</a></li> <li class=""breadcrumb-item active"" aria-current=""page"">Refinanciamiento</li> </ol> </nav> <div class=""display-4 text-center"">Refinanciamiento</div> <hr> <div class=""row justify-content-left mt-3""> <div class=""col-6""> <div class=""card""> <div class=""card-body""> <div class=""card-title h2"">Informacion del prestamo</div> <div class=""row""> <div class=""col""> <small><strong>I.D PRESTAMO</strong><br>"); EndContext(); BeginContext(804, 11, false); #line 23 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(prestamo.id); #line default #line hidden EndContext(); BeginContext(815, 221, true); WriteLiteral("</small><br>\n </div>\n </div>\n <hr>\n <div class=\"row\">\n <div class=\"col\">\n <small><strong>Efectivo solicitado</strong><br>$ "); EndContext(); BeginContext(1037, 27, false); #line 29 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(prestamo.efectivoSolicitado); #line default #line hidden EndContext(); BeginContext(1064, 118, true); WriteLiteral("</small>\n </div>\n <div class=\"col\">\n <small><strong>Interes al "); EndContext(); BeginContext(1183, 20, false); #line 32 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(prestamo.tasaInteres); #line default #line hidden EndContext(); BeginContext(1203, 17, true); WriteLiteral(" %</strong><br>$ "); EndContext(); BeginContext(1221, 21, false); #line 32 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(prestamo.montoInteres); #line default #line hidden EndContext(); BeginContext(1242, 127, true); WriteLiteral("</small>\n </div>\n <div class=\"col\">\n <small><strong>Total</strong><br>$ "); EndContext(); BeginContext(1370, 19, false); #line 35 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(prestamo.saldoDeuda); #line default #line hidden EndContext(); BeginContext(1389, 203, true); WriteLiteral("</small>\n </div>\n </div>\n <hr>\n <div class=\"row\">\n <div class=\"col\">\n <small><strong>Cliente</strong><br>"); EndContext(); BeginContext(1593, 14, false); #line 41 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(cliente.nombre); #line default #line hidden EndContext(); BeginContext(1607, 1, true); WriteLiteral(" "); EndContext(); BeginContext(1609, 16, false); #line 41 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(cliente.apellido); #line default #line hidden EndContext(); BeginContext(1625, 130, true); WriteLiteral("</small><br>\n </div>\n <div class=\"col\">\n <small><strong>Cedula</strong><br>"); EndContext(); BeginContext(1756, 14, false); #line 44 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(cliente.cedula); #line default #line hidden EndContext(); BeginContext(1770, 193, true); WriteLiteral("</small><br>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col\">\n <small><strong>Fecha solicitado</strong><br>"); EndContext(); BeginContext(1964, 47, false); #line 49 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(prestamo.fechaSolicitado.ToString("MM/dd/yyyy")); #line default #line hidden EndContext(); BeginContext(2011, 131, true); WriteLiteral("</small>\n </div>\n <div class=\"col\">\n <small><strong>Fecha focal</strong><br>"); EndContext(); BeginContext(2143, 42, false); #line 52 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(prestamo.fechaFocal.ToString("MM/dd/yyyy")); #line default #line hidden EndContext(); BeginContext(2185, 161, true); WriteLiteral("</small>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class=\"col-6\">\n <strong>Lista de pagos anterior</strong>\n"); EndContext(); #line 60 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" foreach (var pago in @prestamo.pagos) { #line default #line hidden BeginContext(2395, 126, true); WriteLiteral(" <div class=\"row\">\n <div class=\"col-6\">\n <small><strong>Fecha limite: </strong></small>\n <small>"); EndContext(); BeginContext(2522, 39, false); #line 65 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(pago.fechaLimite.ToString("MM/dd/yyyy")); #line default #line hidden EndContext(); BeginContext(2561, 121, true); WriteLiteral("</small>\n </div>\n <div class=\"col-6\">\n <small><strong>Monto: $ </strong></small>\n <small>"); EndContext(); BeginContext(2683, 15, false); #line 69 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(pago.montoPagar); #line default #line hidden EndContext(); BeginContext(2698, 37, true); WriteLiteral("</small>\n </div>\n </div>\n"); EndContext(); #line 72 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" } #line default #line hidden BeginContext(2741, 17, true); WriteLiteral(" </div>\n</div>\n\n"); EndContext(); BeginContext(2758, 2025, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "e7d3c0c66546b3a85b9393a45ed1e2b2c35e677313097", async() => { BeginContext(2778, 41, true); WriteLiteral("\n <input type=\"hidden\" name=\"prestamoId\""); EndContext(); BeginWriteAttribute("value", " value=\"", 2819, "\"", 2839, 1); #line 77 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" WriteAttributeValue("", 2827, prestamo.id, 2827, 12, false); #line default #line hidden EndWriteAttribute(); BeginContext(2840, 42, true); WriteLiteral(">\n <input type=\"hidden\" name=\"fechaFocal\""); EndContext(); BeginWriteAttribute("value", " value=\"", 2882, "\"", 2931, 1); #line 78 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" WriteAttributeValue("", 2890, prestamo.fechaFocal.ToString("dd/MM/yy"), 2890, 41, false); #line default #line hidden EndWriteAttribute(); BeginContext(2932, 37, true); WriteLiteral(">\n <input type=\"hidden\" name=\"monto\""); EndContext(); BeginWriteAttribute("value", " value=\"", 2969, "\"", 2997, 1); #line 79 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" WriteAttributeValue("", 2977, prestamo.saldoDeuda, 2977, 20, false); #line default #line hidden EndWriteAttribute(); BeginContext(2998, 734, true); WriteLiteral(@"> <div class=""row p-2 mt-3 justify-content-center""> <div class=""col- 4""> <div class=""form-group alert alert-info""> <input type=""checkbox"" id=""checkInteres"" name=""checkInteres""> <label class=""m-0"">Mantener interes fijo a todos los meses.</label> <input class=""form-control text-right"" type=""text"" id=""interesFijo"" name=""interesFijo"" placeholder=""Ingrese el interes 0.0%""> </div> </div> </div> <div class=""row justify-content-center""> <div class=""col-8""> <table class=""w-100""> <thead> <th class=""text-center"" >Mes</th> <th class=""text-center"" >Fecha</th> <th class=""text-center"" >Tasa de interes</th> </thead> <tbody> "); EndContext(); #line 100 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" foreach (var fecha in lista) { #line default #line hidden BeginContext(3784, 85, true); WriteLiteral(" <tr>\n <td class=\"p-2 border border-dark m-auto text-center\">"); EndContext(); BeginContext(3870, 30, false); #line 103 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(pp.NumberToMonth(@fecha.Month)); #line default #line hidden EndContext(); BeginContext(3900, 74, true); WriteLiteral("</td>\n <td class=\"p-2 border border-dark m-auto text-center\">"); EndContext(); BeginContext(3975, 26, false); #line 104 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" Write(fecha.ToString("dd/MM/yy")); #line default #line hidden EndContext(); BeginContext(4001, 56, true); WriteLiteral("</td>\n <input type=\"hidden\" name=\"fechas[]\""); EndContext(); BeginWriteAttribute("value", " value=\"", 4057, "\"", 4092, 1); #line 105 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" WriteAttributeValue("", 4065, fecha.ToString("dd/MM/yy"), 4065, 27, false); #line default #line hidden EndWriteAttribute(); BeginContext(4093, 170, true); WriteLiteral(" >\n <td class=\"border border-dark m-auto text-center\"><input class=\"form-control\" type=\"text\" name=\"interesMes[]\" placeholder=\"0.0%\"></td>\n </tr>\n"); EndContext(); #line 108 "/home/giothcode/Escritorio/MatematicaFinanciera/MatematicaFinanciera/Views/Cliente/Refinanciar.cshtml" } #line default #line hidden BeginContext(4275, 348, true); WriteLiteral(@" </tbody> </table> </div> </div> <div class=""row justify-content-center m-1 mt-3""> <div class=""col-6""> <small class=""text-danger""> * Asegurese de revisar detenidamente la informacion</small><br> <small class=""text-danger""> * Llene todos los campos solicitados</small><br> <div class=""form-group""> "); EndContext(); BeginContext(4623, 119, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagOnly, "e7d3c0c66546b3a85b9393a45ed1e2b2c35e677318346", async() => { } ); __Microsoft_AspNetCore_Mvc_TagHelpers_FormActionTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.FormActionTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_FormActionTagHelper); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0); __Microsoft_AspNetCore_Mvc_TagHelpers_FormActionTagHelper.Route = (string)__tagHelperAttribute_1.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(4742, 34, true); WriteLiteral("\n </div>\n </div>\n </div>\n"); EndContext(); } ); __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper); __Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper); __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Method = (string)__tagHelperAttribute_4.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(4783, 614, true); WriteLiteral(@" <script> var check = document.getElementById('checkInteres') var interesFijo = document.getElementById('interesFijo') var interesMes = document.getElementsByName('interesMes[]') if(!check.checked){ interesFijo.style.display = 'none' } check.addEventListener('click',function(){ if(!check.checked){ interesFijo.style.display = 'none' interesMes.forEach(input => { input.disabled = false }) }else if(check.checked){ interesFijo.style.display = 'inherit' interesMes.forEach(input => { input.disabled = true }) } }) </script>"); EndContext(); }