Compras Créditos mejoras

This commit is contained in:
Oscar Irigoyen
2023-05-19 09:39:19 -07:00
parent 4d2852f2d6
commit 59fecd9515
2 changed files with 174 additions and 99 deletions

View File

@@ -4230,13 +4230,13 @@
<div id="DivCreditoFinacieroModal" align="center" class="modal ADS fade" role="dialog">
<div class="modal-dialog" style="width: 450px;">
<div class="modal-dialog" style="width: 1000px;">
<asp:UpdatePanel runat="server" class="modal-content" ID="UpdatePanel3" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-header ">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">
<asp:Literal ID="Literal3" runat="server" Text="Créditos Fianacieros" />
<asp:Literal ID="Literal3" runat="server" Text="Créditos Financieros" />
</h4>
</div>
<div class="modal-body">
@@ -4250,7 +4250,7 @@
<div class="col-md-6" style="text-align: right"></div>
<div class="col-md-6" style="text-align: left">
<asp:Label runat="server" Font-Bold="true" ID="LblImporteCreditos" Text="Total:"> </asp:Label>
<asp:Label runat="server" Font-Bold="true" ID="LblImporteCreditos" Text="Acumulado:"> </asp:Label>
</div>
<br />
<asp:UpdatePanel runat="server" ID="UpGvCreditos" UpdateMode="Conditional">
@@ -4261,20 +4261,23 @@
<div class="col-md-12" >
<asp:GridView ID="GvCreditos" runat="server" AutoGenerateColumns="False"
DataKeyNames="CveCredito,CveCreditoDetalle,FondoGarantia,Periodo,Periodos,Marcador,ProximoPeriodo,TipoPago,Fecha,CveMoneda,Referencia,CveTipoCredito,SeparadorLiquido,Estatus,CveCompra,CveCompraInteres,Mensualidad,CveIE,Total"
DataKeyNames="CveCredito,CveCreditoDetalle,FondoGarantia,Periodo,Periodos,Marcador,ProximoPeriodo,TipoPago,Fecha,CveMoneda,Referencia,CveTipoCredito,SeparadorLiquido,Estatus,CveCompra,CveCompraInteres,Mensualidad,CveIE,Total,ImporteIE"
EmptyDataText="No se encontraron Créditos registrados"
CssClass="table table-striped table-hover Widthall ScrollAD mysmallbtn" data-sort="true" data-height="200" GridLines="None">
<Columns>
<asp:TemplateField HeaderText="Sel" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="5px" Visible="false">
<asp:TemplateField HeaderText="Sel" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="5px" Visible="false">
<ItemTemplate>
<asp:CheckBox ID="ChkSel" CssClass="ChkSelCreditos" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Referencia" HeaderText="Crédito" HeaderStyle-CssClass="rompe" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="Referencia" HeaderText="Crédito" HeaderStyle-CssClass="rompe" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="300px" />
<asp:BoundField DataField="ProximoPeriodo" HeaderText="Pago" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="50px" />
<asp:BoundField DataField="Total" HeaderText="Mensualidad" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N2}" />
<asp:BoundField DataField="ImporteIE" HeaderText="Pagado" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:N2}" />
<asp:TemplateField HeaderText="Capital" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="40px" Visible="false">
<ItemTemplate>
<asp:TextBox runat="server" ID="TxtCapital" Width="60px" Style="text-align: right;" ToolTip="Incluye IVA"></asp:TextBox>
@@ -4285,20 +4288,28 @@
<asp:TextBox runat="server" ID="TxtInteres" Width="60px" Style="text-align: right;" ToolTip="Incluye IVA"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="40px">
<asp:TemplateField HeaderText="Amortizar" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="40px">
<ItemTemplate>
<asp:TextBox runat="server" ID="TxtAmbos" Width="60px" Style="text-align: right;" ToolTip="Incluye IVA"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Comisión" ItemStyle-HorizontalAlign="Right" >
<asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Redondeo" ItemStyle-HorizontalAlign="Right" >
<ItemTemplate>
<asp:TextBox ID="TxtComision" runat="server" MaxLength="12" Width="76px" Style="text-align: right;"></asp:TextBox>
<ajax:FilteredTextBoxExtender ID="FilTxtComision" runat="server" TargetControlID="TxtComision" ValidChars="-." FilterType="Custom, Numbers" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Doc. Por Pagar" ItemStyle-HorizontalAlign="Right" >
<ItemTemplate>
<asp:Label runat="server" ID="LblDocPorPagar" Style="text-align: right;" Text="0" ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
@@ -6600,59 +6611,111 @@
function ValidaCredito(objTxt, event, CveCreditoDetalle, Tipo) {
var ValorInicialTFloat = objTxt.value.toString().replace(/,/g, '').length = 0 ? 0 : parseFloat(objTxt.value.toString().replace(/,/g, ''));
function ValidaCredito( event, CveCreditoDetalle, Tipo, ImporteIE ) {
var char = event.which || event.keyCode;
if (char == 9) {//Evita que se ejecute la rutina cuando se presiona Tap (cuando se salta de interes a ambas si se ejecuta se limpian los valores de capital e interes)
return;
}
if (char == 9) {
return;//Evita que se ejecute la rutina cuando se presiona Tap (cuando se salta de interes a ambas si se ejecuta se limpian los valores de capital e interes)
}
debugger;
if (ValorInicialTFloat == 0) {
objTxt.value = '0';
//return;
}
let TotalCompra = 0;
let ImporteAmortizado = 0;
let ImporteComision = 0;
let ImporteDocPorPagar = 0;
let TotalAmortizaciones = 0;
let TotalComisiones = 0;
let Total = 0;
let TotalString = '';
TotalCompra = parseFloat($('#<%= TxtTotal.ClientID %>').val().replace(/,/g, '')).toFixed(2);
ImporteAmortizado = $(`.CsSelAmbos${CveCreditoDetalle}`).val().replace(/,/g, '').length == 0 ? 0 : parseFloat($(`.CsSelAmbos${CveCreditoDetalle}`).val().replace(/,/g, ''));
ImporteComision = $(`.CsSelComision${CveCreditoDetalle}`).val().replace(/,/g, '').length == 0 ? 0 : parseFloat($(`.CsSelComision${CveCreditoDetalle}`).val().replace(/,/g, ''));
ImporteDocPorPagar = (ImporteIE - ImporteAmortizado - ImporteComision).toFixed(2);
if (Tipo == 1) {
$(`.CsSelAmbos${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
$(`.CsSelAmbos${CveCreditoDetalle}`).each(function () {
$(this).val("");
});
$(`.CsSelCapital${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
$(`.CsSelInteres${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
} else {
$(`.CsSelAmbos${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
$(`.CsSelCapital${CveCreditoDetalle}`).each(function () {
$(this).val("");
});
$(`.CsSelInteres${CveCreditoDetalle}`).each(function () {
$(this).val("");
});
}
var TotalCompra = parseFloat($('#<%= TxtTotal.ClientID %>').val().replace(/,/g, '')).toFixed(2);
$(`.CsSelComision${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
$(`.CsCreGlobal`).each(function () {
let stringTemp = $(this).val().replace(/,/g, '');
let tempValor = parseFloat(stringTemp);
if (!isNaN(tempValor)) {
TotalAmortizaciones += tempValor
}
});
$(`.CsComGlobal`).each(function () {
let stringTemp = $(this).val().replace(/,/g, '');
let tempValor = parseFloat(stringTemp);
if (!isNaN(tempValor)) {
TotalComisiones += tempValor
}
});
if (((TotalAmortizaciones + TotalComisiones) > TotalCompra) || ((ImporteAmortizado + ImporteComision) > ImporteIE)) {
TotalAmortizaciones = 0;
TotalComisiones = 0;
if (Tipo == 1) {
$(`.CsSelAmbos${CveCreditoDetalle}`).val(``);
} else if (Tipo == 2) {
$(`.CsSelComision${CveCreditoDetalle}`).val(``);
}
TotalCompra = parseFloat($('#<%= TxtTotal.ClientID %>').val().replace(/,/g, '')).toFixed(2);
ImporteAmortizado = $(`.CsSelAmbos${CveCreditoDetalle}`).val().replace(/,/g, '').length == 0 ? 0 : parseFloat($(`.CsSelAmbos${CveCreditoDetalle}`).val().replace(/,/g, ''));
ImporteComision = $(`.CsSelComision${CveCreditoDetalle}`).val().replace(/,/g, '').length == 0 ? 0 : parseFloat($(`.CsSelComision${CveCreditoDetalle}`).val().replace(/,/g, ''));
ImporteDocPorPagar = (ImporteIE - ImporteAmortizado - ImporteComision).toFixed(2);
$(`.CsSelAmbos${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
$(`.CsSelComision${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
$(`.CsCreGlobal`).each(function () {
let stringTemp = $(this).val().replace(/,/g, '');
let tempValor = parseFloat(stringTemp);
if (!isNaN(tempValor)) {
TotalAmortizaciones += tempValor
}
});
$(`.CsComGlobal`).each(function () {
let stringTemp = $(this).val().replace(/,/g, '');
let tempValor = parseFloat(stringTemp);
if (!isNaN(tempValor)) {
TotalComisiones += tempValor
}
});
}
if (ImporteAmortizado == 0 & ImporteComision == 0) {
ImporteDocPorPagar = 0;
}
$('#<%= LblImporteCreditos.ClientID %>').text('Acumulado: ' + FormatoNumero((TotalAmortizaciones + TotalComisiones), 2));
$(`.CsSelLblDocPorPagar${CveCreditoDetalle}`).text(FormatoNumero(ImporteDocPorPagar, 2));
/* $(`.CsCreGlobal`).each(function () {
let stringTemp = $(this).val().replace(/,/g, '');
let tempValor = parseFloat(stringTemp);
@@ -6660,11 +6723,11 @@
if (!isNaN(tempValor)) {
Total += tempValor
}
});
});*/
if (Total > TotalCompra) {
/*if (Total > TotalCompra) {
let TmpObtTxtValor = TotalCompra - (Total - ValorInicialTFloat);
let TmpObtTxtValor = TotalCompra - (Total - ImporteAmortizado);
if (TmpObtTxtValor > 0) {
objTxt.value = '' + FormatoNumero(TmpObtTxtValor, 2);
@@ -6673,13 +6736,13 @@
}
Total = TotalCompra;
}
}*/
$('#<%= LblImporteCreditos.ClientID %>').text('Total ' + FormatoMonedaL(Total));
//$('#<%= LblImporteCreditos.ClientID %>').text('Acumulado: ' + FormatoMonedaL(Total));
if (ValorInicialTFloat == 0) {
/*if (ImporteAmortizado == 0) {
objTxt.value = '';
}
}*/
}