-- 4 CyC: Poder aplicar una NC/ANT/IxC al mismo tiempo.

This commit is contained in:
2025-02-04 19:22:17 -07:00
parent f2e01602ad
commit 24d5972c2e
2 changed files with 423 additions and 545 deletions

View File

@@ -427,7 +427,7 @@
<asp:BoundField HeaderText="Importe" DataField="Total" DataFormatString="{0:N2}" ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Right" /> <asp:BoundField HeaderText="Importe" DataField="Total" DataFormatString="{0:N2}" ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderText="Fecha Solicitud" DataField="FechaCambioEstatus" ItemStyle-Width="15%" /> <asp:BoundField HeaderText="Fecha Solicitud" DataField="FechaCambioEstatus" ItemStyle-Width="15%" />
<asp:BoundField HeaderText="Motivo" DataField="MotivoCancelacion" ItemStyle-Width="25%" /> <asp:BoundField HeaderText="Motivo" DataField="MotivoCancelacion" ItemStyle-Width="25%" />
<asp:TemplateField ItemStyle-Width="5%" > <asp:TemplateField ItemStyle-Width="5%">
<ItemTemplate> <ItemTemplate>
<asp:LinkButton runat="server" ID="BtnValidar" OnClick="BtnValidar_Click" CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-check'></i>" data-toggle="confirmation" data-popout="true" data-original-title="¿Está seguro que desea verificar la cancelación?" data-btn-ok-label="si"></asp:LinkButton> <asp:LinkButton runat="server" ID="BtnValidar" OnClick="BtnValidar_Click" CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-check'></i>" data-toggle="confirmation" data-popout="true" data-original-title="¿Está seguro que desea verificar la cancelación?" data-btn-ok-label="si"></asp:LinkButton>
</ItemTemplate> </ItemTemplate>
@@ -585,7 +585,6 @@
<div class="row"> <div class="row">
<div class="col-md-2"> <div class="col-md-2">
<label>Anticipos:</label><asp:LinkButton ID="ImgAntiPend" Visible="false" OnClick="ImgAntiPend_Click" runat="server" Text=" <i class='fa fa-money' style='font-size: 18px !important; color: #3c763d !important;'></i> " AlternateText="Aplicación de anticipos" Style="cursor: pointer;" /> <label>Anticipos:</label><asp:LinkButton ID="ImgAntiPend" Visible="false" OnClick="ImgAntiPend_Click" runat="server" Text=" <i class='fa fa-money' style='font-size: 18px !important; color: #3c763d !important;'></i> " AlternateText="Aplicación de anticipos" Style="cursor: pointer;" />
</div> </div>
<div class="col-md-4 input-icon"> <div class="col-md-4 input-icon">
<i style="margin: 0px;">$</i> <i style="margin: 0px;">$</i>
@@ -599,7 +598,7 @@
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<asp:Literal ID="LtlTipoAnticipo" runat="server"></asp:Literal></label> <asp:Literal ID="LtlTipoAnticipo" runat="server"></asp:Literal></label>
<asp:HiddenField ID="HdnTipoAmortizacion" runat="server" Value="" /> <%--<asp:HiddenField ID="HdnTipoAmortizacion" runat="server" Value="" />--%>
<asp:LinkButton ID="LnkCxC" runat="server" CssClass="btn btn-xs btn-success" Text="Cobranza" OnClick="LnkCxC_Click" /> <asp:LinkButton ID="LnkCxC" runat="server" CssClass="btn btn-xs btn-success" Text="Cobranza" OnClick="LnkCxC_Click" />
</div> </div>
@@ -1184,67 +1183,7 @@
</h4> </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="row" runat="server" id="divAmortizacionTipo" visible="false"> <div style="max-height: 700px; overflow-y: auto;">
<div class="col-md-4">
Tipo Amortización:
</div>
<div class="col-md-8">
<asp:DropDownList ID="DdlTipoAmortizacionAnticipo" runat="server" AutoPostBack="true" Width="250px" CssClass="select2me" CausesValidation="true" OnSelectedIndexChanged="DdlTipoAmortizacionAnticipo_SelectedIndexChanged">
<asp:ListItem Text="Seleccionar" Value="-1"></asp:ListItem>
<asp:ListItem Text="Amortización anticipo con nota de crédito" Value="2"></asp:ListItem>
</asp:DropDownList>
</div>
<asp:RequiredFieldValidator ID="RfvDdlTipoAmortizacionAnticipo" runat="server" Display="None" ControlToValidate="DdlTipoAmortizacionAnticipo" InitialValue="-1" ErrorMessage="Debe Seleccionarse un tipo" ValidationGroup="VGAnticiposClientes"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="CEDdlTipoAmortizacionAnticipo" runat="server" HighlightCssClass="vco" TargetControlID="RfvDdlTipoAmortizacionAnticipo" Width="300px"></ajax:ValidatorCalloutExtender>
<div class="row" style="text-align: center;" runat="server" id="divAnticipoMsg" visible="false">
<asp:Label ID="Label2" runat="server" Text="Se aplicará descuento por el total de las amortizaciones en los productos" CssClass="alert alert-warning" Style="padding: 5px; margin-bottom: 5px; padding-right: 25px;"></asp:Label>
</div>
</div>
<div class="row" id="divAmortizacionTipoRelacion" runat="server" visible="false">
<div class="col-md-4">
Tipo Relación:
</div>
<div class="col-md-8">
<asp:DropDownList ID="DdlTipoRelacionAnticipo" runat="server" Width="250px" CssClass="select2me">
<asp:ListItem Text="07 - CFDI por aplicación de anticipo" Value="7"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="row" id="DivConceptoNC" runat="server" visible="false">
<div class="col-md-4">
Concepto:
</div>
<div class="col-md-8">
<asp:DropDownList ID="DdlNCPSAnt" runat="server" DataTextField="PSCodigo" DataValueField="CvePS" Width="250px" CssClass="select2me"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVNCPSAnt" runat="server" InitialValue="-1" ControlToValidate="DdlNCPSAnt" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Concepto''</b> es necesario, por favor ingréselo." ValidationGroup="VGAnticiposClientes"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCERFVNCPSAnt" runat="server" HighlightCssClass="vco" TargetControlID="RFVNCPSAnt" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row" id="DivFechaAnticipoCliente" runat="server" visible="false">
<b>
<label class="col-md-2">Fecha:</label></b>
<div class="col-md-4">
<div class="input-group input-sm input-small date date-picker " data-date-format="dd/mm/yyyy" style="width: 80% !important; padding: 0px;">
<asp:TextBox ID="TxtFechaAnticipoCliente" runat="server" ClientIDMode="Static" CssClass="form-control" CausesValidation="true" MaxLength="10" AutoPostBack="true" OnTextChanged="TxtFechaAnticipoCliente_TextChanged"></asp:TextBox>
<span class="input-group-btn ">
<asp:LinkButton ID="ImgFechaAnticipoCliente" class="btn default " Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
</span>
<ajax:MaskedEditExtender ID="MEEFechaAnticipoCliente" runat="server" TargetControlID="TxtFechaAnticipoCliente" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="CEFechaAnticipoCliente" TargetControlID="TxtFechaAnticipoCliente" PopupButtonID="ImgFechaAnticipoCliente" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:CompareValidator ID="CvFechaAnticipoCliente" runat="server" ControlToValidate="TxtFechaAnticipoCliente" Display="None" Operator="DataTypeCheck" Type="Date" ValidationGroup="VGAnticiposClientes" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Fecha''</b> no tiene el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)."></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="VcoFechaAnticipoCliente" runat="server" Enabled="True" HighlightCssClass="vco" TargetControlID="CvFechaAnticipoCliente" Width="300px"></ajax:ValidatorCalloutExtender>
</div>
</div>
</div>
<br />
<div style="max-height: 300px; overflow-y: auto;">
<div class="row" style="margin-left: 0px; text-align: right" align="left"> <div class="row" style="margin-left: 0px; text-align: right" align="left">
<div class="col-md-2"> <div class="col-md-2">
<asp:LinkButton ID="LnkRecargaAnticipos" NavigateUrl="#" CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-refresh'></i> Actualizar" runat="server" OnClick="LnkRecargaAnticipos_Click" /> <asp:LinkButton ID="LnkRecargaAnticipos" NavigateUrl="#" CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-refresh'></i> Actualizar" runat="server" OnClick="LnkRecargaAnticipos_Click" />
@@ -1255,6 +1194,13 @@
</div> </div>
</div> </div>
<br /> <br />
<div class="row">
<div class="col-md-12" style="display:flex; justify-content:end; font-size:16px; font-weight: bold;">
<span> Total: </span>
<asp:Label ID="LblTotalAnticipos" runat="server" ClientIDMode="Static" Text="0.00"></asp:Label>
</div>
</div>
<asp:GridView ID="GVAnticipos" runat="server" AutoGenerateColumns="False" ClientIDMode="Static" EmptyDataText="No se encontraron Anticipos del Cliente" <asp:GridView ID="GVAnticipos" runat="server" AutoGenerateColumns="False" ClientIDMode="Static" EmptyDataText="No se encontraron Anticipos del Cliente"
ToolTip="Listado de Anticipos" CssClass="GVAnticipos table table-striped table-hover Widthall mysmallbtn" data-height="300" GridLines="None" ToolTip="Listado de Anticipos" CssClass="GVAnticipos table table-striped table-hover Widthall mysmallbtn" data-height="300" GridLines="None"
DataKeyNames="ISTotal,Saldo,CveIE,Folio,Tipo,CveVenta,CveConceptoContable,CveConceptoContableAmor, TotalAnticipo, SubTotalAnticipo, IVAAnticipo,IEPS, ImpuestosLocalesAnticipo, SubTotalAmortizacion, SubTotal, Original, IVA, RetIVA, RetISR, FolioFiscal, CveClasificacionNC, TipoCambio,TipoCambioPago,TipoCambioHoy, CveMoneda,Fecha,SaldoSubTotal,SaldoConImpuestos,RegresarImpuesto,DevolucionImportePagado,CveCliente,Descuentos"> DataKeyNames="ISTotal,Saldo,CveIE,Folio,Tipo,CveVenta,CveConceptoContable,CveConceptoContableAmor, TotalAnticipo, SubTotalAnticipo, IVAAnticipo,IEPS, ImpuestosLocalesAnticipo, SubTotalAmortizacion, SubTotal, Original, IVA, RetIVA, RetISR, FolioFiscal, CveClasificacionNC, TipoCambio,TipoCambioPago,TipoCambioHoy, CveMoneda,Fecha,SaldoSubTotal,SaldoConImpuestos,RegresarImpuesto,DevolucionImportePagado,CveCliente,Descuentos">
@@ -1283,6 +1229,12 @@
<asp:Literal ID="LtlAnticipos" runat="server" Text='<%# Eval("Saldo", "{0:N2}") %>'></asp:Literal>&nbsp; <asp:Literal ID="LtlAnticipos" runat="server" Text='<%# Eval("Saldo", "{0:N2}") %>'></asp:Literal>&nbsp;
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Tipo</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlTipo" runat="server" Text='<%# Eval("Tipo") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false"> <asp:TemplateField Visible="false">
<HeaderTemplate>Moneda Venta</HeaderTemplate> <HeaderTemplate>Moneda Venta</HeaderTemplate>
<ItemTemplate> <ItemTemplate>
@@ -1304,7 +1256,6 @@
<asp:TemplateField> <asp:TemplateField>
<HeaderTemplate>Amort. Ant.</HeaderTemplate> <HeaderTemplate>Amort. Ant.</HeaderTemplate>
<ItemTemplate> <ItemTemplate>
<asp:Label ID="LblTotalAnticipos" runat="server" ClientIDMode="Static" Text="0.00" Visible="false"></asp:Label>
<asp:TextBox ID="TxtAnticipo" CssClass="CSGATxtAnticipo" runat="server" CausesValidation="true" MaxLength="12" Width="76px"></asp:TextBox> <asp:TextBox ID="TxtAnticipo" CssClass="CSGATxtAnticipo" runat="server" CausesValidation="true" MaxLength="12" Width="76px"></asp:TextBox>
<asp:CompareValidator ID="CVAmortAnti" runat="server" ControlToValidate="TxtAnticipo" Display="None" ErrorMessage="El campo <b>''Amortización de Anticipos''</b> no tiene el formato correcto, por favor corrija e intente de nuevo (Solo formato numérico)." Operator="DataTypeCheck" Type="Currency" ValidationGroup="VGAnticiposClientes"></asp:CompareValidator> <asp:CompareValidator ID="CVAmortAnti" runat="server" ControlToValidate="TxtAnticipo" Display="None" ErrorMessage="El campo <b>''Amortización de Anticipos''</b> no tiene el formato correcto, por favor corrija e intente de nuevo (Solo formato numérico)." Operator="DataTypeCheck" Type="Currency" ValidationGroup="VGAnticiposClientes"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="VCOAmortAnti" runat="server" HighlightCssClass="vco" TargetControlID="CVAmortAnti" Width="300px"></ajax:ValidatorCalloutExtender> <ajax:ValidatorCalloutExtender ID="VCOAmortAnti" runat="server" HighlightCssClass="vco" TargetControlID="CVAmortAnti" Width="300px"></ajax:ValidatorCalloutExtender>
@@ -1340,14 +1291,13 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header "> <div class="modal-header ">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"> <h4 class="modal-title">Estados de Cajas
Estados de Cajas
</h4> </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="row"> <div class="row">
<div class="col-md-12" > <div class="col-md-12">
<asp:GridView ID="GvEstadoCajas" runat="server" AutoGenerateColumns="true" ClientIDMode="Static" EmptyDataText="" <asp:GridView ID="GvEstadoCajas" runat="server" AutoGenerateColumns="true" ClientIDMode="Static" EmptyDataText=""
OnRowDataBound="GvEstadoCajas_RowDataBound" OnRowDataBound="GvEstadoCajas_RowDataBound"
@@ -1466,8 +1416,6 @@
function chkAnt(t, txt, importe, AmorContrato = 0) { function chkAnt(t, txt, importe, AmorContrato = 0) {
let totalAnt = 0; let totalAnt = 0;
let TipoAnticipo = $('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').val();
//si es con.nc,es.el.total //si es con.nc,es.el.total
let Total = ToDouble($get("C_LtlSaldo").value.replace(",", "")); let Total = ToDouble($get("C_LtlSaldo").value.replace(",", ""));
@@ -1486,8 +1434,12 @@
totalAnt = FnSumaValoresAnt(); totalAnt = FnSumaValoresAnt();
if (totalAnt > SaldoCompra) { if (totalAnt > SaldoCompra) {
txt.value = FormatoNumero(importe - (totalAnt - SaldoCompra), 2); let valor = FormatoNumero(importe - (totalAnt - SaldoCompra), 2);
//$get('HdnVentaSaldo').value = 0.00; if (valor == 'NaN') {
txt.value = "0.00";
} else {
txt.value = valor;
}
alert("El Importe no debe de exceder a el saldo"); alert("El Importe no debe de exceder a el saldo");
} }
@@ -1508,13 +1460,8 @@
let Total = ToDouble($get("C_LtlSaldo").value.replace(",", ""));// ToDouble($get('TxtSubTotal').value); let Total = ToDouble($get("C_LtlSaldo").value.replace(",", ""));// ToDouble($get('TxtSubTotal').value);
let TipoAnticipo = $('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').val();
let importeTxt = parseFloat(txt.value.replace(/,/g, '')); let importeTxt = parseFloat(txt.value.replace(/,/g, ''));
if (TipoAnticipo == '4') {
Total = ToDouble($get("C_LtlSaldo").value.replace(",", ""));
}
if (isNaN(importeTxt)) { if (isNaN(importeTxt)) {
importeTxt = 0; importeTxt = 0;
} else { } else {

View File

@@ -673,7 +673,9 @@ Partial Class Ventas_PVCobranza
Dim ObjOIEventos As New ClsOIEventos(ObjVentas2.IniciaTransacSQL()) Dim ObjOIEventos As New ClsOIEventos(ObjVentas2.IniciaTransacSQL())
Dim respFactura As Modelos.Factura.MMensajeFactura = Nothing Dim respFactura As Modelos.Factura.MMensajeFactura = Nothing
Dim respNC As Modelos.Factura.MMensajeFactura = Nothing Dim ListaNC As New List(Of Modelos.Factura.MMensajeFactura)
'Dim respNC As Modelos.Factura.MMensajeFactura = Nothing
Dim RegistrarPago As Boolean = True Dim RegistrarPago As Boolean = True
Dim PlazoCobranza As Integer = HdnPlazoCobranza.Value.ToEntero Dim PlazoCobranza As Integer = HdnPlazoCobranza.Value.ToEntero
Try Try
@@ -693,7 +695,6 @@ Partial Class Ventas_PVCobranza
If respFactura IsNot Nothing AndAlso Not respFactura.TieneError Then If respFactura IsNot Nothing AndAlso Not respFactura.TieneError Then
CveVenta = respFactura.CveVenta CveVenta = respFactura.CveVenta
If HdnTipoAmortizacion.Value = "4" Then
If respFactura.Factura.DtAnticiposAplicados IsNot Nothing Then If respFactura.Factura.DtAnticiposAplicados IsNot Nothing Then
PagoAplicado += respFactura.Factura.DtAnticiposAplicados.SUM("Importe") PagoAplicado += respFactura.Factura.DtAnticiposAplicados.SUM("Importe")
SaldoPendienteVenta = SaldoPendienteVenta - PagoAplicado SaldoPendienteVenta = SaldoPendienteVenta - PagoAplicado
@@ -707,41 +708,52 @@ Partial Class Ventas_PVCobranza
Next Next
End If End If
End If
End If End If
End If End If
'GENERAR NC PARA AMORTIZACION 'GENERAR NC PARA AMORTIZACION
If MsgError = "" AndAlso UsuarioActual.CveEmpresa.Contiene(189) AndAlso HdnTipoAmortizacion.Value = "2" Then If ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() Then
respNC = GenerarNC(CveVendedor, VentaActual, ObjVentas2)
If respNC IsNot Nothing Then For Each gvr As GridViewRow In GVAnticipos.Rows
If respNC.TieneError Then If gvr.DataKey("Tipo") = "Ant" AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked Then
Dim ImporteAnticipo As Decimal = gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal
Dim RespNC = GenerarNC(ImporteAnticipo, CveVendedor, VentaActual, gvr, ObjVentas2)
If RespNC IsNot Nothing Then
If RespNC.TieneError Then
CveVenta = -1 CveVenta = -1
If respNC.Mensajes.Count > 0 Then If RespNC.Mensajes.Count > 0 Then
MsgError = respNC.Mensajes(0) MsgError = RespNC.Mensajes(0)
Else Else
MsgError = "Ocurrió un error al generar la nota de crédito" MsgError = "Ocurrió un error al generar la nota de crédito"
End If End If
Exit For
Else Else
PagoAplicado += respNC.Factura.Total PagoAplicado += RespNC.Factura.Total
SaldoPendienteVenta = SaldoPendienteVenta - PagoAplicado SaldoPendienteVenta = SaldoPendienteVenta - PagoAplicado
SaldoPendientePagos = SaldoPendientePagos - PagoAplicado SaldoPendientePagos = SaldoPendientePagos - PagoAplicado
For Each RowAnt As DataRow In respNC.Factura.DtAnticiposAplicados.Rows For Each RowAnt As DataRow In RespNC.Factura.DtAnticiposAplicados.Rows
If Not ActualizaAnticipos(RowAnt("CveIE").ToString().ToEntero(), RowAnt("CveVenta").ToString().ToEntero(), RowAnt("Tipo").ToString(), RowAnt("Folio").ToString(), ObjVentas2, ObjOIEventos) Then If Not ActualizaAnticipos(RowAnt("CveIE").ToString().ToEntero(), RowAnt("CveVenta").ToString().ToEntero(), RowAnt("Tipo").ToString(), RowAnt("Folio").ToString(), ObjVentas2, ObjOIEventos) Then
MsgError = "Ocurrió un error al actualizar los anticipos" MsgError = "Ocurrió un error al actualizar los anticipos"
Exit For Exit For
End If End If
Next Next
ListaNC.Add(RespNC)
End If End If
Else Else
MsgError = "Ocurrió un error al generar la nota de crédito" MsgError = "Ocurrió un error al generar la nota de crédito"
End If End If
End If End If
Next
End If
If MsgError = "" Then If MsgError = "" Then
If SaldoPendienteVenta > 0 AndAlso VentaContado Then If SaldoPendienteVenta > 0 AndAlso VentaContado Then
@@ -906,25 +918,19 @@ Partial Class Ventas_PVCobranza
Dim msBuild As New StringBuilder() Dim msBuild As New StringBuilder()
Try Try
Dim MsgTimbrado As String = "" Dim MsgTimbrado As String = ""
Dim FolioFiscalFactura = ""
Dim DebeTimbrar As Boolean = True Dim DebeTimbrar As Boolean = True
Dim SeTimbro As Boolean = False Dim SeTimbro As Boolean = False
Dim SeTimbroNC As Boolean = False
'SI SE GENERO FACTURA DE INGRESO, TIMBRARLA DESPUES DE REALIZAR EL PAGO 'SI SE GENERO FACTURA DE INGRESO, TIMBRARLA DESPUES DE REALIZAR EL PAGO
If DebeTimbrar AndAlso respFactura IsNot Nothing Then If DebeTimbrar AndAlso respFactura IsNot Nothing Then
Try Try
'VERIFICA SI SE GENERO NC AjustarTimbreFactura(respFactura.Factura)
If respNC IsNot Nothing Then
AjustarTimbre(respFactura.Factura, respNC.Factura) Dim ObjTimbre = TimbrarFactura(respFactura.Factura, SeTimbro)
MsgTimbrado = TimbrarFactura(respFactura.Factura, respNC.Factura, SeTimbro, SeTimbroNC) MsgTimbrado = ObjTimbre.MensajeErrorCFDI
Else FolioFiscalFactura = ObjTimbre.UUID
AjustarTimbre(respFactura.Factura, Nothing)
MsgTimbrado = TimbrarFactura(respFactura.Factura, Nothing, SeTimbro, SeTimbroNC)
End If
If Not String.IsNullOrEmpty(MsgTimbrado) Then If Not String.IsNullOrEmpty(MsgTimbrado) Then
Dim StrEr As String = $"<br/><div id = 'DivTipoCambioAdvertencia' class='alert alert-danger' style='padding: 5px; margin-bottom: 5px; padding-right: 25px;'><strong style = 'font-size: 20px; margin-right: 25px;' > Comprobante no emitido : </strong><br/> {MsgTimbrado}<br/>Por favor inténtelo de nuevo a través del botón 'Emitir' en ventas.</div>" Dim StrEr As String = $"<br/><div id = 'DivTipoCambioAdvertencia' class='alert alert-danger' style='padding: 5px; margin-bottom: 5px; padding-right: 25px;'><strong style = 'font-size: 20px; margin-right: 25px;' > Comprobante no emitido : </strong><br/> {MsgTimbrado}<br/>Por favor inténtelo de nuevo a través del botón 'Emitir' en ventas.</div>"
@@ -932,12 +938,12 @@ Partial Class Ventas_PVCobranza
End If End If
Catch ex As Exception Catch ex As Exception
GuardaLogAD(ex.ToString()) GuardaLogAD(ex.ToString())
msBuild.AppendFormat("<br/>{0}<br/>", MsgTimbrado)
End Try End Try
End If End If
If respFactura IsNot Nothing Then If respFactura IsNot Nothing Then
Try
If RegistrarPago Then If RegistrarPago Then
msBuild.Append("<span style=""font-size:14px;"">Pago Registrado correctamente. </span> <br/><br/>") msBuild.Append("<span style=""font-size:14px;"">Pago Registrado correctamente. </span> <br/><br/>")
End If End If
@@ -947,6 +953,10 @@ Partial Class Ventas_PVCobranza
If SeTimbro Then If SeTimbro Then
Dim xml = String.Format("<ul><li><a class=""Texto"" target=""_blank"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar XML</a></li></ul>", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", respFactura.CveVenta, "XML", respFactura.SerieFolio, respFactura.Factura.TipoDocto))) Dim xml = String.Format("<ul><li><a class=""Texto"" target=""_blank"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar XML</a></li></ul>", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", respFactura.CveVenta, "XML", respFactura.SerieFolio, respFactura.Factura.TipoDocto)))
msBuild.AppendFormat("{0}", xml) msBuild.AppendFormat("{0}", xml)
Else
If Not String.IsNullOrEmpty(MsgTimbrado) Then
msBuild.AppendFormat("<br/>{0}<br/>", MsgTimbrado)
End If
End If End If
Dim pdf = String.Format("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul>", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", respFactura.CveVenta))) Dim pdf = String.Format("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul>", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", respFactura.CveVenta)))
@@ -956,8 +966,38 @@ Partial Class Ventas_PVCobranza
msBuild.AppendFormat("<b><a target='_blank' class='Texto' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"">Movimiento de Almacén</a></b><br/>", respFactura.Factura.Inv_CveMovimiento) msBuild.AppendFormat("<b><a target='_blank' class='Texto' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"">Movimiento de Almacén</a></b><br/>", respFactura.Factura.Inv_CveMovimiento)
End If End If
If respNC IsNot Nothing Then If respFactura IsNot Nothing AndAlso respFactura.Factura IsNot Nothing AndAlso respFactura.Factura.DtAnticiposAplicados IsNot Nothing Then
For Each dr As DataRow In respFactura.Factura.DtAnticiposAplicados.Rows
msBuild.AppendLine($"<br><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=AMORTIZACIONHIS&CVEIE={0}&CVEVENTA={1}&CVECLIENTE={2}&CVEVENTAAMORTIZADA={3}&MONTO={4}",
dr("CveIE").ToString,
dr("CveVenta").ToString,
respFactura.Factura.CveCliente,
respFactura.CveVenta,
respFactura.Factura.Total))}"">Imprimir Saldo Aplicado {dr("Folio").ToString}</a><br/>")
Next
End If
If ListaNC.Count > 0 Then
For Each respNC In ListaNC
Dim MsgTimbradoNC As String = ""
msBuild.AppendFormat("<span style=""font-size:14px;""> La nota de crédito <a class=""Texto"" target=""_blank"" style=""font-size:18px;font-weight:bold;"" href=""/Ventas/Ventas.aspx?CveVenta={0}"">{1}</a> se genero correctamente.</span> <br/>", respNC.CveVenta, respNC.SerieFolio) msBuild.AppendFormat("<span style=""font-size:14px;""> La nota de crédito <a class=""Texto"" target=""_blank"" style=""font-size:18px;font-weight:bold;"" href=""/Ventas/Ventas.aspx?CveVenta={0}"">{1}</a> se genero correctamente.</span> <br/>", respNC.CveVenta, respNC.SerieFolio)
Dim SeTimbroNC As Boolean = False
If SeTimbro Then
'PONER LA RELACION CON LA FACTURA CREADA
AjustarTimbreNC(respNC.Factura, FolioFiscalFactura)
Dim ObjTimbreNC = TimbrarFactura(respNC.Factura, SeTimbroNC)
If Not String.IsNullOrEmpty(ObjTimbreNC.MensajeErrorCFDI) Then
MsgTimbradoNC = ObjTimbreNC.MensajeErrorCFDI
End If
Else
MsgTimbradoNC = $"No se pudo timbrar la NC porque la factura de ingreso no ha sido timbrada previamente"
End If
If SeTimbroNC Then If SeTimbroNC Then
Dim xml = String.Format("<ul><li><a class=""Texto"" target=""_blank"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar XML</a></li></ul>", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", respNC.CveVenta, "XML", respNC.SerieFolio, respNC.Factura.TipoDocto))) Dim xml = String.Format("<ul><li><a class=""Texto"" target=""_blank"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar XML</a></li></ul>", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", respNC.CveVenta, "XML", respNC.SerieFolio, respNC.Factura.TipoDocto)))
msBuild.AppendFormat("{0}", xml) msBuild.AppendFormat("{0}", xml)
@@ -965,10 +1005,8 @@ Partial Class Ventas_PVCobranza
Dim pdfNC = String.Format("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul>", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", respNC.CveVenta))) Dim pdfNC = String.Format("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul>", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", respNC.CveVenta)))
msBuild.AppendFormat("{0}", pdfNC) msBuild.AppendFormat("{0}", pdfNC)
End If
If respNC IsNot Nothing Then
If respNC IsNot Nothing AndAlso respNC.Factura IsNot Nothing AndAlso respNC.Factura.DtAnticiposAplicados IsNot Nothing Then If respNC IsNot Nothing AndAlso respNC.Factura IsNot Nothing AndAlso respNC.Factura.DtAnticiposAplicados IsNot Nothing Then
For Each dr As DataRow In respNC.Factura.DtAnticiposAplicados.Rows For Each dr As DataRow In respNC.Factura.DtAnticiposAplicados.Rows
msBuild.AppendLine($"<br><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=AMORTIZACIONHIS&CVEIE={0}&CVEVENTA={1}&CVECLIENTE={2}&CVEVENTAAMORTIZADA={3}&MONTO={4}", msBuild.AppendLine($"<br><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=AMORTIZACIONHIS&CVEIE={0}&CVEVENTA={1}&CVECLIENTE={2}&CVEVENTAAMORTIZADA={3}&MONTO={4}",
@@ -980,23 +1018,21 @@ Partial Class Ventas_PVCobranza
Next Next
End If End If
Else If Not String.IsNullOrEmpty(MsgTimbradoNC) Then
If respFactura IsNot Nothing AndAlso respFactura.Factura IsNot Nothing AndAlso respFactura.Factura.DtAnticiposAplicados IsNot Nothing Then Dim StrEr As String = $"<br/><div id = 'DivTipoCambioAdvertencia' class='alert alert-danger' style='padding: 5px; margin-bottom: 5px; padding-right: 25px;'><strong style = 'font-size: 20px; margin-right: 25px;' > Comprobante no emitido : </strong><br/> {MsgTimbradoNC}<br/>Por favor inténtelo de nuevo a través del botón 'Emitir' en ventas.</div>"
For Each dr As DataRow In respFactura.Factura.DtAnticiposAplicados.Rows MsgTimbradoNC = StrEr
msBuild.AppendLine($"<br><a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=AMORTIZACIONHIS&CVEIE={0}&CVEVENTA={1}&CVECLIENTE={2}&CVEVENTAAMORTIZADA={3}&MONTO={4}",
dr("CveIE").ToString, msBuild.AppendFormat("<br/>{0}<br/>", MsgTimbradoNC)
dr("CveVenta").ToString,
respFactura.Factura.CveCliente,
respFactura.CveVenta,
respFactura.Factura.Total))}"">Imprimir Saldo Aplicado {dr("Folio").ToString}</a><br/>")
Next
End If
End If End If
If Not String.IsNullOrEmpty(MsgTimbrado) Then Next
msBuild.AppendFormat("<br/>{0}<br/>", MsgTimbrado)
End If End If
Catch ex As Exception
GuardaLogAD(ex.ToString())
msBuild.AppendFormat("<br/>{0}<br/>", MsgTimbrado)
End Try
Else Else
msBuild.Append($"Pago Registrado correctamente.<br/><br/> <a href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1&TICKET=1&REGENERAR=1", CveVenta))}"" class='Texto'>Imprimir ticket</a>") msBuild.Append($"Pago Registrado correctamente.<br/><br/> <a href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1&TICKET=1&REGENERAR=1", CveVenta))}"" class='Texto'>Imprimir ticket</a>")
End If End If
@@ -1049,6 +1085,51 @@ Partial Class Ventas_PVCobranza
End Sub End Sub
Private Sub AjustarTimbreFactura(ByRef ObjFactura As Modelos.Factura)
ObjFactura.Timbre.CFDIRelacionados.UUID.Clear()
'SI TIENE RELACIONADOS ANTICIPOS PONER TIPO RELACION 7
If ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() Then
Dim Anticipos = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "Ant")
If Anticipos IsNot Nothing AndAlso Anticipos.Count() > 0 Then
For Each Ant As Modelos.MAnticipoRelacionado In Anticipos
ObjFactura.Timbre.CFDIRelacionados.UUID.Add(Ant.FolioFiscal)
Next
ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = "07"
ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
End If
End If
'SI TIENE NC/DEV PONER TIPO RELACION 1
If Not ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() AndAlso ListaAnticiposAplicados.Where(Function(x) x.Tipo = "NC").Any() Then
Dim DevolucionesNC = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "NC")
If DevolucionesNC IsNot Nothing AndAlso DevolucionesNC.Count() > 0 Then
For Each NC As Modelos.MAnticipoRelacionado In DevolucionesNC
ObjFactura.Timbre.CFDIRelacionados.UUID.Add(NC.FolioFiscal)
Next
Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {ObjFactura.CveTipoRelacion}")
ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString()
ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString()
End If
End If
End Sub
Private Sub AjustarTimbreNC(ByRef ObjNC As Modelos.Factura, FolioFiscalFactura As String)
ObjNC.Timbre.CFDIRelacionados.UUID.Clear()
ObjNC.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura)
ObjNC.Timbre.CFDIRelacionados.TipoRelacion = "07"
ObjNC.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
ObjNC.Timbre.Comprobante.MetodoPago = GlobalDTVtaMetodoPago.FiltroPrimeroValor("ClaveMetodoPagoSAT", $"CveMetodoPago = {ObjNC.CveMetodoPago}") ' Obj.ClaveMetodoPagoSAT
ObjNC.Timbre.Comprobante.FormadePago = GlobalDTVtaFormaPago.FiltroPrimeroValor("ClaveFormaPagoSAT", $"CveFormaPago = {ObjNC.CveFormaPago}") 'Obj.ClaveFormaPagoSAT
ObjNC.Timbre.Receptor.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", $"CveUsoCFDI = {ObjNC.CveUsoCFDI}")
End Sub
Private Function ActualizaAnticipos(CveIE As Integer, CveVenta As Integer, Tipo As String, Folio As String, ByRef ObjVentas As ClsVentas, ByRef ObjEventoBitacora As ClsOIEventos) As Boolean Private Function ActualizaAnticipos(CveIE As Integer, CveVenta As Integer, Tipo As String, Folio As String, ByRef ObjVentas As ClsVentas, ByRef ObjEventoBitacora As ClsOIEventos) As Boolean
Dim Retorno As Boolean = True Dim Retorno As Boolean = True
@@ -1086,7 +1167,7 @@ Partial Class Ventas_PVCobranza
TxtAutorizo.Text = "" TxtAutorizo.Text = ""
TxtNCDev.Text = "" TxtNCDev.Text = ""
LtlTipoAnticipo.Text = "" LtlTipoAnticipo.Text = ""
HdnTipoAmortizacion.Value = "" 'HdnTipoAmortizacion.Value = ""
CveCliente = -1 CveCliente = -1
CveVendedor = -1 CveVendedor = -1
@@ -1213,8 +1294,6 @@ Partial Class Ventas_PVCobranza
ObjFactura.PreparaTimbre() ObjFactura.PreparaTimbre()
If HdnTipoAmortizacion.Value = "4" Then
DtAnticipos.Columns.Add("CveVenta", GetType(Integer)) DtAnticipos.Columns.Add("CveVenta", GetType(Integer))
DtAnticipos.Columns.Add("Importe", GetType(Decimal)) DtAnticipos.Columns.Add("Importe", GetType(Decimal))
DtAnticipos.Columns.Add("CveConceptoContable", GetType(Integer)) DtAnticipos.Columns.Add("CveConceptoContable", GetType(Integer))
@@ -1230,7 +1309,7 @@ Partial Class Ventas_PVCobranza
DtAnticipos.Columns.Add("Tipo", GetType(String)) DtAnticipos.Columns.Add("Tipo", GetType(String))
For Each GvRow As GridViewRow In GVAnticipos.Rows For Each GvRow As GridViewRow In GVAnticipos.Rows
If GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then If GvRow.DataKey("Tipo").Contiene("NC", "IxC") AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then
Dim CveVenta = GvRow.DataKey("CveVenta").ToEntero() Dim CveVenta = GvRow.DataKey("CveVenta").ToEntero()
Dim Importe = GvRow.FCTextBox(String.Format("TxtAnticipo{0}", GvRow.RowIndex)).Text.ToDecimal() Dim Importe = GvRow.FCTextBox(String.Format("TxtAnticipo{0}", GvRow.RowIndex)).Text.ToDecimal()
@@ -1252,6 +1331,7 @@ Partial Class Ventas_PVCobranza
End If End If
Next Next
If DtAnticipos.Rows.Count > 0 Then
ObjFactura.EsNCAmortizacion = True ObjFactura.EsNCAmortizacion = True
ObjFactura.CveTipoAmortizacionAnticipo = 4 ObjFactura.CveTipoAmortizacionAnticipo = 4
ObjFactura.DtAnticiposAplicados = DtAnticipos ObjFactura.DtAnticiposAplicados = DtAnticipos
@@ -1264,6 +1344,16 @@ Partial Class Ventas_PVCobranza
ObjFactura.PedidoContrato = PedidoContrato ObjFactura.PedidoContrato = PedidoContrato
ObjFactura.OrdenCompra = OrdenCompra ObjFactura.OrdenCompra = OrdenCompra
'SI TIENE RELACIONADOS ANTICIPOS PONER TIPO RELACION 7
If ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() Then
ObjFactura.CveTipoRelacion = 7
End If
'SI TIENE NC/DEV PONER TIPO RELACION 1
If Not ListaAnticiposAplicados.Where(Function(x) x.Tipo = "Ant").Any() AndAlso ListaAnticiposAplicados.Where(Function(x) x.Tipo = "NC").Any() Then
ObjFactura.CveTipoRelacion = 1
End If
Retorno = ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True) Retorno = ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True)
Retorno.Factura = ObjFactura Retorno.Factura = ObjFactura
@@ -1326,6 +1416,7 @@ Partial Class Ventas_PVCobranza
VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal
VentaActual.UsuarioActual = UsuarioActual VentaActual.UsuarioActual = UsuarioActual
VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero
VentaActual.CveUsoCFDI = DbRowVenta("CveUsoCFDI").ToString.ToEntero
VentaRemision = VentaActual VentaRemision = VentaActual
End If End If
@@ -1352,7 +1443,7 @@ Partial Class Ventas_PVCobranza
Return (regex.IsMatch(texto)) Return (regex.IsMatch(texto))
End Function End Function
Private Function GenerarNC(CveVendedor As Integer, ByRef Venta As Venta, ByRef ObjVentas As ClsVentas) As Modelos.Factura.MMensajeFactura Private Function GenerarNC(ImporteTotal As Decimal, CveVendedor As Integer, ByRef Venta As Venta, GvRowAnticipo As GridViewRow, ByRef ObjVentas As ClsVentas) As Modelos.Factura.MMensajeFactura
Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing
Dim SbAlert As New StringBuilder() Dim SbAlert As New StringBuilder()
@@ -1365,7 +1456,7 @@ Partial Class Ventas_PVCobranza
ObjNC.TipoCambio = 1 ObjNC.TipoCambio = 1
End If End If
Dim Total As Decimal = TxtNCDev.Text.ToDecimal() Dim Total As Decimal = ImporteTotal
Dim subTotal As Decimal = (Total / (1D + Venta.PorcentajeIVA)) Dim subTotal As Decimal = (Total / (1D + Venta.PorcentajeIVA))
'Dim IVA = (subTotal * Factura.PorcentajeIVA).RoundSQL(2) 'Dim IVA = (subTotal * Factura.PorcentajeIVA).RoundSQL(2)
Dim PU As Decimal = subTotal Dim PU As Decimal = subTotal
@@ -1373,7 +1464,13 @@ Partial Class Ventas_PVCobranza
Dim Descuento As Decimal = 0 Dim Descuento As Decimal = 0
Dim Obs = "" Dim Obs = ""
ObjNC.AgregarPS(DdlNCPSAnt.SelectedValue.ToEntero(), Cantidad, PU, Descuento, Obs, CveSubProyecto:=Venta.CveSubProyecto, PorcentajeIVA:=Venta.PorcentajeIVA) Dim CvePSAnticipo As Integer = 1
Dim DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:="84111506").FiltroPrimero("CodigoPS LIKE '%ANTICIPO%' OR CodigoPS LIKE '%anticipo%' OR CodigoPS LIKE '%Anticipo%'")
If DatarowPS IsNot Nothing Then
CvePSAnticipo = DatarowPS("CvePS").ToString().ToEntero()
End If
ObjNC.AgregarPS(CvePSAnticipo, Cantidad, PU, Descuento, Obs, CveSubProyecto:=Venta.CveSubProyecto, PorcentajeIVA:=Venta.PorcentajeIVA)
ObjNC.CalculaTotales() ObjNC.CalculaTotales()
Dim DtVentasNC = New DataTable Dim DtVentasNC = New DataTable
@@ -1410,46 +1507,43 @@ Partial Class Ventas_PVCobranza
DtAnticipos.Columns.Add("Folio", GetType(String)) DtAnticipos.Columns.Add("Folio", GetType(String))
DtAnticipos.Columns.Add("Tipo", GetType(String)) DtAnticipos.Columns.Add("Tipo", GetType(String))
For Each GvRow As GridViewRow In GVAnticipos.Rows If GvRowAnticipo IsNot Nothing Then
If GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then Dim CveVenta = GvRowAnticipo.DataKey("CveVenta").ToEntero()
Dim CveVenta = GvRow.DataKey("CveVenta").ToEntero() Dim Importe = GvRowAnticipo.FCTextBox(String.Format("TxtAnticipo{0}", GvRowAnticipo.RowIndex)).Text.ToDecimal()
Dim Importe = GvRow.FCTextBox(String.Format("TxtAnticipo{0}", GvRow.RowIndex)).Text.ToDecimal() Dim CveConceptoContable = GvRowAnticipo.DataKey("CveConceptoContable").ToEntero()
Dim CveConceptoContable = GvRow.DataKey("CveConceptoContable").ToEntero() Dim CveIE = GvRowAnticipo.DataKey("CveIE").ToEntero()
Dim CveIE = GvRow.DataKey("CveIE").ToEntero()
Dim FolioFiscal = GvRow.DataKey("FolioFiscal") Dim FolioFiscal = GvRowAnticipo.DataKey("FolioFiscal")
Dim Descuentos As Decimal = GvRow.DataKey("Descuentos").ToDecimal() Dim Descuentos As Decimal = GvRowAnticipo.DataKey("Descuentos").ToDecimal()
Dim TotalAnticipo As Decimal = GvRow.DataKey("TotalAnticipo").ToDecimal() Dim TotalAnticipo As Decimal = GvRowAnticipo.DataKey("TotalAnticipo").ToDecimal()
Dim SubTotalAnticipo As Decimal = GvRow.DataKey("SubTotalAnticipo").ToDecimal() Dim SubTotalAnticipo As Decimal = GvRowAnticipo.DataKey("SubTotalAnticipo").ToDecimal()
Dim CveMoneda As Integer = GvRow.DataKey("CveMoneda").ToEntero() Dim CveMoneda As Integer = GvRowAnticipo.DataKey("CveMoneda").ToEntero()
Dim Fecha As DateTime = GvRow.DataKey("Fecha").ToDateTime() Dim Fecha As DateTime = GvRowAnticipo.DataKey("Fecha").ToDateTime()
Dim TipoCambioPago As Decimal = GvRow.DataKey("TipoCambioPago").ToDecimal() Dim TipoCambioPago As Decimal = GvRowAnticipo.DataKey("TipoCambioPago").ToDecimal()
Dim Folio = GvRow.DataKey("Folio") Dim Folio = GvRowAnticipo.DataKey("Folio")
Dim Tipo = GvRow.DataKey("Tipo") Dim Tipo = GvRowAnticipo.DataKey("Tipo")
DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio, Tipo) DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda, Fecha, TipoCambioPago, Folio, Tipo)
End If End If
Next
ObjNC.EsNCAmortizacion = True ObjNC.EsNCAmortizacion = True
ObjNC.CveTipoAmortizacionAnticipo = 2 ObjNC.CveTipoAmortizacionAnticipo = 2
ObjNC.DtAnticiposAplicados = DtAnticipos ObjNC.DtAnticiposAplicados = DtAnticipos
ObjNC.PreparaTimbre()
ObjNC.CveFormaPago = 21 'Aplicación de anticipos ObjNC.CveFormaPago = 21 'Aplicación de anticipos
ObjNC.CveMetodoPago = 1 ObjNC.CveMetodoPago = 1
ObjNC.CveMetodoPago = 1 ObjNC.CveUsoCFDI = Venta.CveUsoCFDI
ObjNC.CveVendedor = CveVendedor ObjNC.CveVendedor = CveVendedor
ObjNC.CveTipoRelacion = 7 ObjNC.CveTipoRelacion = 7
ObjNC.PreparaTimbre()
'AjustarTimbreNC(ObjNC)
Retorno = ObjNC.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True) Retorno = ObjNC.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True)
Retorno.Factura = ObjNC Retorno.Factura = ObjNC
If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then
For Each msg In Retorno.Mensajes For Each msg In Retorno.Mensajes
SbAlert.AppendFormat("{0} <br/>", msg) SbAlert.AppendFormat("{0} <br/>", msg)
Next Next
@@ -1465,80 +1559,15 @@ Partial Class Ventas_PVCobranza
Return Retorno Return Retorno
End Function End Function
Private Sub AjustarTimbre(ByRef ObjFactura As Modelos.Factura, ByRef ObjNC As Modelos.Factura) Private Function TimbrarFactura(ByRef ObjFactura As Modelos.Factura, ByRef SeTimbro As Boolean) As Timbrado
ObjFactura.Timbre.CFDIRelacionados.UUID.Clear()
If HdnTipoAmortizacion.Value = "2" Then
Dim Anticipos = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "Ant")
If Anticipos IsNot Nothing AndAlso Anticipos.Count() > 0 Then
For Each Ant As Modelos.MAnticipoRelacionado In Anticipos
ObjFactura.Timbre.CFDIRelacionados.UUID.Add(Ant.FolioFiscal)
Next
ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = "07"
ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
'AJUSTAR NC
If ObjNC IsNot Nothing Then
ObjNC.Timbre.CFDIRelacionados.UUID.Clear()
ObjNC.Timbre.CFDIRelacionados.TipoRelacion = "07"
ObjNC.Timbre.CFDIRelacionados.TipoRelacionTexto = "07-CFDI por aplicación de anticipo"
End If
End If
End If
'DEVOLUCIONES DE OTRA VENTA, APLICADAS EN UNA NUEVA
If HdnTipoAmortizacion.Value = "4" Then
Dim DevolucionesNC = ListaAnticiposAplicados.Where(Function(Obj) Obj.Tipo = "NC")
If DevolucionesNC IsNot Nothing AndAlso DevolucionesNC.Count() > 0 Then
For Each Ant As Modelos.MAnticipoRelacionado In DevolucionesNC
ObjFactura.Timbre.CFDIRelacionados.UUID.Add(Ant.FolioFiscal)
Next
'TEMPORAL- DEBE SER TIPO RELACION "01 - Nota de crédito de los documentos relacionados"
Dim CveTipoRelacion As Integer = 1
ObjFactura.CveTipoRelacion = CveTipoRelacion
Dim RowTipoRelacion As DataRow = GlobalDTVtaTiposRelacion().FiltroPrimero($"CveTipoRelacion = {CveTipoRelacion}")
ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = RowTipoRelacion("SATClaveTipoRelacion").ToString()
ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = RowTipoRelacion("SATTipoRelacion").ToString()
End If
End If
End Sub
Private Function TimbrarFactura(ByRef ObjFactura As Modelos.Factura, ByRef ObjNC As Modelos.Factura, ByRef SeTimbro As Boolean, ByRef SeTimbroNC As Boolean) As String
Dim MsgErrorTimbrado As String = "" Dim MsgErrorTimbrado As String = ""
'Dim SeTimbro As Boolean = False
'Dim TimbroNC As Boolean = False
Dim ObjTimbrado As New Timbrado Dim ObjTimbrado As New Timbrado
Try Try
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
Dim FolioFiscalFactura As String = ObjTimbrado.UUID Dim FolioFiscalFactura As String = ObjTimbrado.UUID
MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI
ObjTimbrado = Nothing
If SeTimbro AndAlso ObjNC IsNot Nothing Then
If ObjNC.Timbre IsNot Nothing Then
ObjNC.Timbre.CFDIRelacionados.UUID.Clear()
ObjNC.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura)
Dim ObjTimbradoNC As New Timbrado
SeTimbroNC = ObjTimbradoNC.TimbrarFactura(UsuarioActual, ObjNC)
If Not SeTimbroNC Then
MsgErrorTimbrado = $"{MsgErrorTimbrado} {ObjTimbradoNC.MensajeErrorCFDI}"
End If
ObjTimbradoNC = Nothing
End If
End If
Catch ex As Exception Catch ex As Exception
OnError("Ocurrió un error al generar el timbrado", ex) OnError("Ocurrió un error al generar el timbrado", ex)
End Try End Try
@@ -1547,7 +1576,7 @@ Partial Class Ventas_PVCobranza
GuardaLogAD(MsgErrorTimbrado, Archivo:="LogTimbrado") GuardaLogAD(MsgErrorTimbrado, Archivo:="LogTimbrado")
End If End If
Return MsgErrorTimbrado Return ObjTimbrado
End Function End Function
Private Function RegistraIE(Metodo As Integer, CveBancoCuenta As Integer, ImporteAbonoVenta As Decimal, ImporteBancos As Decimal, Fecha As Date, CvePrePoliza As Integer, VentaActual As Venta, ByRef ObjIE As ClsBancos, ByRef ObjConta As ClsContabilidad, ByRef ObjVentas As ClsVentas, tCveCorte As Integer, Optional Obs As String = "", Optional CveAutorizacion As String = "", Optional CveSubProyecto As Integer = -1) As String Private Function RegistraIE(Metodo As Integer, CveBancoCuenta As Integer, ImporteAbonoVenta As Decimal, ImporteBancos As Decimal, Fecha As Date, CvePrePoliza As Integer, VentaActual As Venta, ByRef ObjIE As ClsBancos, ByRef ObjConta As ClsContabilidad, ByRef ObjVentas As ClsVentas, tCveCorte As Integer, Optional Obs As String = "", Optional CveAutorizacion As String = "", Optional CveSubProyecto As Integer = -1) As String
@@ -2070,18 +2099,18 @@ Partial Class Ventas_PVCobranza
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero() Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero()
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then 'If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
If DdlTipoAmortizacionAnticipo.Items.FindByValue("4") Is Nothing Then ' If DdlTipoAmortizacionAnticipo.Items.FindByValue("4") Is Nothing Then
DdlTipoAmortizacionAnticipo.Items.Insert(1, New ListItem("Pago con devolución", "4")) ' DdlTipoAmortizacionAnticipo.Items.Insert(1, New ListItem("Pago con devolución", "4"))
End If ' End If
DdlTipoAmortizacionAnticipo.SelectedValueExist("4") ' DdlTipoAmortizacionAnticipo.SelectedValueExist("4")
DdlTipoRelacionAnticipo.SelectedValueExist("-1") ' DdlTipoRelacionAnticipo.SelectedValueExist("-1")
divAmortizacionTipoRelacion.Visible = False ' divAmortizacionTipoRelacion.Visible = False
DdlTipoAmortizacionAnticipo_SelectedIndexChanged(DdlTipoAmortizacionAnticipo, EventArgs.Empty) ' DdlTipoAmortizacionAnticipo_SelectedIndexChanged(DdlTipoAmortizacionAnticipo, EventArgs.Empty)
End If 'End If
Dim DbRowVenta As DataRow = Nothing Dim DbRowVenta As DataRow = Nothing
Dim ObjVentas As New ClsVentas Dim ObjVentas As New ClsVentas
@@ -2106,84 +2135,35 @@ Partial Class Ventas_PVCobranza
Private Sub CargaAnticipos(CveCliente As Integer) Private Sub CargaAnticipos(CveCliente As Integer)
If CveCliente > 0 Then If CveCliente > 0 Then
'QUE NO SE PUEDA REALIZAR AMORTIZACIÓN DE ANTICIPO POR DESCUENTO
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
If DdlTipoAmortizacionAnticipo.Items.FindByValue("1") IsNot Nothing Then
DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("1"))
End If
End If
Dim ObjMovtos As New ClsMovimientos() Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente) Then If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente) Then
Me.TmpDTAnticiposNCIxCCliente = ObjMovtos.DtResultados.Copy() Me.TmpDTAnticiposNCIxCCliente = ObjMovtos.DtResultados.Copy()
End If End If
''AGREGAR LOS ANTICIPOS, DEV, IxC QUE ESTEN EN PUBLICO GENERAL
'If Me.TmpDTAnticiposNCIxCCliente IsNot Nothing AndAlso UsuarioActual.CveEmpresa.Contiene(189, 190, 192, 195, 197) Then
' Dim CveClientePublicoGeneral = UsuarioActual.Empresa.Funcionalidad(714).ToEntero()
' If CveClientePublicoGeneral > 0 Then
' If CveCliente <> CveClientePublicoGeneral Then
' If ObjMovtos.GetAnticiposNCIxCCliente(CveClientePublicoGeneral) Then
' For Each DrGeneral As DataRow In ObjMovtos.DtResultados.Rows
' Me.TmpDTAnticiposNCIxCCliente.Rows.Add(DrGeneral.ItemArray)
' Next
' End If
' End If
' End If
'End If
ObjMovtos.Dispose() ObjMovtos.Dispose()
If Me.TmpDTAnticiposNCIxCCliente IsNot Nothing Then If Me.TmpDTAnticiposNCIxCCliente IsNot Nothing Then
Dim DtMovtos As DataTable = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"Saldo > 0 AND Tipo IN('NC','IxC','Ant') ") GVAnticipos.DataSource = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"ISTotal = 0 AND Saldo > 0 AND Tipo IN('NC','IxC','Ant') ")
If DdlTipoAmortizacionAnticipo.SelectedValue = "4" Then
GVAnticipos.DataSource = DtMovtos.FiltraParametros("Tipo IN('NC','IxC')")
Else
GVAnticipos.DataSource = DtMovtos.FiltraParametros("Tipo IN('Ant')")
End If
Else Else
GVAnticipos.DataSource = Nothing GVAnticipos.DataSource = Nothing
End If End If
divAmortizacionTipo.Visible = True GVAnticipos.Columns(5).Visible = False
GVAnticipos.Columns(9).Visible = False
If UsuarioActual.Empresa.Funcionalidad(343) = "1" Then
DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("1"))
End If
GVAnticipos.Columns(4).Visible = False
GVAnticipos.Columns(8).Visible = False
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
GVAnticipos.Columns(6).Visible = True GVAnticipos.Columns(7).Visible = True
End If End If
GVAnticipos.DataBind() GVAnticipos.DataBind()
If ListaAnticiposAplicados IsNot Nothing Then
ListaAnticiposAplicados.Clear()
End If
TxtNCDev.Text = "0.00"
End If End If
UpAnticipos.Update() UpAnticipos.Update()
End Sub End Sub
Protected Sub TxtFechaAnticipoCliente_TextChanged(sender As Object, e As EventArgs)
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero()
If CveCliente <= 0 Then
Dim DbRowVenta As DataRow = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
End If
ObjVentas.Dispose()
If DbRowVenta IsNot Nothing Then
CveCliente = DbRowVenta("CveCliente").ToString().ToEntero()
End If
End If
If CveCliente > 0 Then
CargaAnticipos(CveCliente)
End If
End Sub
Protected Sub LnkRecargaAnticipos_Click(sender As Object, e As EventArgs) Protected Sub LnkRecargaAnticipos_Click(sender As Object, e As EventArgs)
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero() Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero()
@@ -2283,11 +2263,11 @@ Partial Class Ventas_PVCobranza
DirectCast(e.Row.FindControl("VCOAmortAnti"), AjaxControlToolkit.ValidatorCalloutExtender).TargetControlID = "CVAmortAnti" & e.Row.RowIndex DirectCast(e.Row.FindControl("VCOAmortAnti"), AjaxControlToolkit.ValidatorCalloutExtender).TargetControlID = "CVAmortAnti" & e.Row.RowIndex
'SI NO TIENE PERMISO, NO PERMITIR APLICAR ANTICIPOS PUNTUALES 'SI NO TIENE PERMISO, NO PERMITIR APLICAR ANTICIPOS PUNTUALES
If GVAnticipos.DataSource IsNot Nothing Then 'If GVAnticipos.DataSource IsNot Nothing Then
If CBool(e.Row.DBCampo("AnticipoPuntual")) AndAlso Not UsuarioActual.TienePermisoProceso(377) Then ' If CBool(e.Row.DBCampo("AnticipoPuntual")) AndAlso Not UsuarioActual.TienePermisoProceso(377) Then
e.Row.FCCheckBox("Chk").Enabled = False ' e.Row.FCCheckBox("Chk").Enabled = False
End If ' End If
End If 'End If
End If End If
End Sub End Sub
@@ -2311,12 +2291,10 @@ Partial Class Ventas_PVCobranza
Dim tipoCambio As Decimal = 0 Dim tipoCambio As Decimal = 0
Dim total As Decimal = LtlSaldo.Text.ToDecimal() '- PagadoSinEfectivo Dim total As Decimal = LtlSaldo.Text.ToDecimal() '- PagadoSinEfectivo
saldo = e.Row.DataKey("Saldo").ToString().ToDecimal If e.Row.DBCampo("Tipo").Contiene("Ant") Then
If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("4") Then
saldo = e.Row.DataKey("Saldo").ToString().ToDecimal
Else
saldo = e.Row.DataKey("SaldoConImpuestos").ToString().ToDecimal saldo = e.Row.DataKey("SaldoConImpuestos").ToString().ToDecimal
Else
saldo = e.Row.DataKey("Saldo").ToString().ToDecimal
End If End If
e.Row.FCLiteral("LtlAnticipos").Text = saldo.FormatoNumero e.Row.FCLiteral("LtlAnticipos").Text = saldo.FormatoNumero
@@ -2356,8 +2334,14 @@ Partial Class Ventas_PVCobranza
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right
End If End If
Dim AnticipoAutorizado = CBool(e.Row.DBCampo("AnticipoAutorizado"))
If Not EsProduccion AndAlso UsuarioActual.CveRol = 1 Then
AnticipoAutorizado = True
End If
If UsuarioActual.Empresa.Funcionalidad(185) = "1" Then If UsuarioActual.Empresa.Funcionalidad(185) = "1" Then
If e.Row.DBCampo("Tipo").ToString().Contiene("NC", "Ant", "IxC") AndAlso Not CBool(e.Row.DBCampo("AnticipoAutorizado")) Then If e.Row.DBCampo("Tipo").ToString().Contiene("NC", "Ant", "IxC") AndAlso Not AnticipoAutorizado Then
e.Row.FCCheckBox("Chk" & e.Row.RowIndex).Enabled = False e.Row.FCCheckBox("Chk" & e.Row.RowIndex).Enabled = False
e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ToolTip = "Anticipo Bloqueado" e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ToolTip = "Anticipo Bloqueado"
e.Row.FCLinkButton("LnkSolicitarActivarAnticipo").Visible = True e.Row.FCLinkButton("LnkSolicitarActivarAnticipo").Visible = True
@@ -2373,10 +2357,10 @@ Partial Class Ventas_PVCobranza
Protected Sub BtnAceptarAnticipos_Click(sender As Object, e As System.EventArgs) Handles BtnAceptarAnticipos.Click Protected Sub BtnAceptarAnticipos_Click(sender As Object, e As System.EventArgs) Handles BtnAceptarAnticipos.Click
If DdlTipoAmortizacionAnticipo.SelectedValue.ToEntero() <= 0 Then 'If DdlTipoAmortizacionAnticipo.SelectedValue.ToEntero() <= 0 Then
Alert("Debe seleccionar un tipo de amortización", TipoMensaje.MsgAdvertencia) ' Alert("Debe seleccionar un tipo de amortización", TipoMensaje.MsgAdvertencia)
Exit Sub ' Exit Sub
End If 'End If
Dim Amortizacion As Decimal = 0 Dim Amortizacion As Decimal = 0
@@ -2392,78 +2376,25 @@ Partial Class Ventas_PVCobranza
If gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked Then If gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked Then
If gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal > 0 Then If gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal > 0 Then
Amortizacion += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal() Amortizacion += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal()
If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = gvr.DataKey("CveVenta").ToEntero(), .FolioFiscal = gvr.DataKey("FolioFiscal"), .Tipo = gvr.DataKey("Tipo")}) ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = gvr.DataKey("CveVenta").ToEntero(), .FolioFiscal = gvr.DataKey("FolioFiscal"), .Tipo = gvr.DataKey("Tipo")})
End If End If
If DdlTipoAmortizacionAnticipo.SelectedValue = "4" Then
ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = gvr.DataKey("CveVenta").ToEntero(), .FolioFiscal = gvr.DataKey("FolioFiscal"), .Tipo = gvr.DataKey("Tipo")})
End If
End If
End If End If
Next Next
If Amortizacion > 0 Then If Amortizacion > 0 Then
TxtNCDev.Text = Amortizacion.ToString() TxtNCDev.Text = Amortizacion.ToString()
LtlTipoAnticipo.Text = DdlTipoAmortizacionAnticipo.SelectedItem.Text 'LtlTipoAnticipo.Text = DdlTipoAmortizacionAnticipo.SelectedItem.Text
HdnTipoAmortizacion.Value = DdlTipoAmortizacionAnticipo.SelectedValue 'HdnTipoAmortizacion.Value = DdlTipoAmortizacionAnticipo.SelectedValue
Else Else
TxtNCDev.Text = "" TxtNCDev.Text = ""
LtlTipoAnticipo.Text = "" LtlTipoAnticipo.Text = ""
HdnTipoAmortizacion.Value = "" 'HdnTipoAmortizacion.Value = ""
End If End If
RegistraScript("$('#DivAnticipos').modal('hide');CalculaTotalPagoContado()", "AE") RegistraScript("$('#DivAnticipos').modal('hide');CalculaTotalPagoContado()", "AE")
UpL.Update() UpL.Update()
End Sub End Sub
Protected Sub DdlTipoAmortizacionAnticipo_SelectedIndexChanged(sender As Object, e As EventArgs)
divAmortizacionTipoRelacion.Visible = DdlTipoAmortizacionAnticipo.SelectedValue = "2"
If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
CargaDdlNCPS()
DivConceptoNC.Visible = True
Else
DivConceptoNC.Visible = False
End If
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero
Dim DbRowVenta As DataRow = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
End If
ObjVentas.Dispose()
If DbRowVenta IsNot Nothing Then
CveCliente = DbRowVenta("CveCliente").ToString().ToEntero()
CveVendedor = DbRowVenta("CveVendedor").ToString().ToEntero()
End If
If CveCliente > 0 Then
CargaAnticipos(CveCliente)
End If
UpAnticipos.Update()
End Sub
Public Sub CargaDdlNCPS()
Dim CveSATNC As String = "84111506"
Dim dtt As New DataTable
dtt = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CodigoSATPS:=CveSATNC, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC
If dtt IsNot Nothing Then
DdlNCPSAnt.DataSource = dtt
DdlNCPSAnt.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlNCPSAnt.DataBind()
dtt.Dispose()
End If
End Sub
Protected Sub DdlOtroFormaPago_SelectedIndexChanged(sender As Object, e As EventArgs) Protected Sub DdlOtroFormaPago_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim DtCC As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) Dim DtCC As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
Dim CveMon As Integer = 1 Dim CveMon As Integer = 1