--fIX varios
This commit is contained in:
@@ -4820,7 +4820,7 @@ Partial Class Clientes
|
||||
Private Sub ConsultarAnticiposSaldosClientes()
|
||||
Dim ObjMovtos As New ClsMovimientos()
|
||||
If ObjMovtos.GetAnticiposNCIxCCliente(DdlClienteImportarSaldos.SelectedValue.ToEntero()) Then
|
||||
GvImportarSaldos.DataSource = ObjMovtos.DtResultados.FiltraParametros("ISTotal = 0 AND Saldo > 0 AND Saldo > 0 AND CveIE > 0 AND Tipo IN('NC','IxC','Ant')")
|
||||
GvImportarSaldos.DataSource = ObjMovtos.DtResultados.FiltraParametros("ISTotal = 0 AND Saldo > 0 AND Tipo IN('NC','IxC','Ant')")
|
||||
Else
|
||||
GvImportarSaldos.DataSource = Nothing
|
||||
End If
|
||||
|
||||
@@ -392,13 +392,61 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="portlet light xspadding traspasorow bordered" runat="server" visible="false" id="DivCancelacionesPendientes">
|
||||
<div class="portlet-title">
|
||||
<div class="caption font-green">
|
||||
<span class="caption-subject bold uppercase" style="line-height: 1;">Cancelaciones pendientes
|
||||
<asp:Literal ID="LtlFacturasPendiente" runat="server"></asp:Literal></span>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<div class="btn-group">
|
||||
<div class="row" style="margin-left: 0px; text-align: right" align="left">
|
||||
<div style="margin-right: 15px">
|
||||
<input type="text" id="TxtBusqueda1" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusqueda1','{0}')", GvDatos.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
|
||||
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusqueda','{0}')", GvDatos.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="portlet-body rowpadding">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<asp:GridView ID="GvCancelaciones" runat="server" AutoGenerateColumns="false" EmptyDataText="No se encontraron solicitudes de cancelación" OnRowDataBound="GvCancelaciones_RowDataBound"
|
||||
DataKeyNames="CveVenta,CveCliente,Folio,TipoDocto,Nombre,FolioFiscal,Total,SubTotal,RFCReceptor,CveEstatusRefacturacion"
|
||||
CssClass="table table-striped table-advance table-hover Widthall ScrollAD mysmallbtn" data-sort="true" GridLines="None" Width="99%">
|
||||
<Columns>
|
||||
<asp:BoundField HeaderText="Cliente" DataField="Nombre" ItemStyle-Width="25%" />
|
||||
<asp:HyperLinkField HeaderText="Serie Folio" DataTextField="SerieFolio" DataNavigateUrlFields="CveVenta" ItemStyle-Width="100px" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" />
|
||||
<asp:BoundField HeaderText="Fecha" DataField="Fecha" DataFormatString="{0:dd/MM/yyyy}" ItemStyle-Width="80px" />
|
||||
<asp:BoundField HeaderText="Importe" DataField="Total" DataFormatString="{0:N2}" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Right" />
|
||||
<asp:BoundField HeaderText="Estatus" DataField="EstatusFactura" ItemStyle-Width="160px" />
|
||||
<asp:BoundField HeaderText="Fecha Solicitud" DataField="FechaCambioEstatus" ItemStyle-Width="160px" />
|
||||
<asp:BoundField HeaderText="Motivo" DataField="MotivoCancelacion" ItemStyle-Width="25%" />
|
||||
<asp:TemplateField ItemStyle-Width="35px" HeaderText="Verificar">
|
||||
<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>
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
</Columns>
|
||||
<RowStyle CssClass="Texto" />
|
||||
<HeaderStyle CssClass="Titulos" />
|
||||
</asp:GridView>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<asp:Panel runat="server" ID="PnlContado" DefaultButton="BtnPagar" Visible="false">
|
||||
<div class="row">
|
||||
<div class="note note-success">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<div class="col-md-2">
|
||||
<b>Nombre:</b>
|
||||
</div>
|
||||
<div class="col-md-4"> <label><asp:Literal ID="LtlNombre" runat="server"></asp:Literal></label> </div>
|
||||
@@ -536,7 +584,7 @@
|
||||
<div class="row">
|
||||
<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;" />
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-md-4 input-icon">
|
||||
<i style="margin: 0px;">$</i>
|
||||
@@ -1106,7 +1154,7 @@
|
||||
<div id="DivAnticipos" class="modal ADS fade" role="dialog">
|
||||
<asp:UpdatePanel runat="server" ID="UpAnticipos" UpdateMode="Conditional" RenderMode="Inline">
|
||||
<ContentTemplate>
|
||||
<div class="modal-dialog" style ="width: 700px;">
|
||||
<div class="modal-dialog" style="width: 700px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header ">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
@@ -1187,7 +1235,7 @@
|
||||
</div>
|
||||
<br />
|
||||
<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">
|
||||
<Columns>
|
||||
<asp:TemplateField>
|
||||
@@ -1259,7 +1307,7 @@
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
|
||||
<asp:Button ID="BtnEnviarMailCancelacion" runat="server" ClientIDMode="Static" Text="Enviar Mail Cliente" Style="display: none;" OnClick="BtnEnviarMailCancelacion_Click" />
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
|
||||
<script src="/Scripts/PrintJS/print.min.js"></script>
|
||||
@@ -1268,6 +1316,10 @@
|
||||
// printJS({ printable: urlPDF, type: 'pdf', showModal: true });
|
||||
//}
|
||||
|
||||
function BtnEnviarMailCancelacion() {
|
||||
$('#BtnEnviarMailCancelacion').click();
|
||||
}
|
||||
|
||||
function chkAnt(t, txt, importe, AmorContrato = 0) {
|
||||
let totalAnt = 0;
|
||||
|
||||
@@ -1375,7 +1427,7 @@
|
||||
let totalDebito = ToDouble($get("TxtImporteDebito").value);
|
||||
let totalCheque = ToDouble($get("TxtImporteCheque").value);
|
||||
let totalTransferencia = ToDouble($get("TxtImporteTransferencia").value);
|
||||
let TotalOtrosContado = 0;
|
||||
let TotalOtrosContado = 0;
|
||||
|
||||
let total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia;
|
||||
|
||||
|
||||
@@ -25,6 +25,18 @@ Partial Class Ventas_PVCobranza
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property CveVentaCancelacion As Integer
|
||||
Get
|
||||
If ViewState("CveVentaCancelacion") Is Nothing Then
|
||||
ViewState("CveVentaCancelacion") = -1
|
||||
End If
|
||||
Return ViewState("CveVentaCancelacion").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveVentaCancelacion") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property TmpDTAnticiposNCIxCCliente As DataTable
|
||||
Get
|
||||
Return If(IsNothing(ViewState("TmpDTAnticiposNCIxCCliente")), Nothing, CType(ViewState("TmpDTAnticiposNCIxCCliente"), DataTable))
|
||||
@@ -365,9 +377,30 @@ Partial Class Ventas_PVCobranza
|
||||
End If
|
||||
|
||||
MuestraNoTimbradasCentroCosto()
|
||||
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
|
||||
CargaCancelaciones()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CargaCancelaciones()
|
||||
DivCancelacionesPendientes.Visible = True
|
||||
Dim DtVentas As DataTable = Nothing
|
||||
|
||||
Dim ObjVentas = New ClsVentas()
|
||||
If ObjVentas.GetVentasPendientesCancelacion(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then
|
||||
DtVentas = ObjVentas.DtResultados.Copy()
|
||||
End If
|
||||
ObjVentas.Dispose()
|
||||
|
||||
If DtVentas IsNot Nothing Then
|
||||
GvCancelaciones.DataSource = DtVentas.FiltraParametros("(CveEstatusFactura IN (20,23) AND CveEstatusRefacturacion IN (0,4))")
|
||||
GvCancelaciones.DataBind()
|
||||
End If
|
||||
|
||||
UpL.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
@@ -770,6 +803,12 @@ Partial Class Ventas_PVCobranza
|
||||
AjustarTimbre(respFactura.Factura, Nothing)
|
||||
MsgTimbrado = TimbrarFactura(respFactura.Factura, Nothing)
|
||||
End If
|
||||
|
||||
If Not String.IsNullOrEmpty(MsgTimbrado) Then
|
||||
Dim StrEr As String = $"<br/><div id = 'DivTipoCambioAdvertencia' class='alert alert-warning' style='padding: 5px; margin-bottom: 5px; padding-right: 25px;'><strong style = 'font-size: 20px; margin-right: 25px;' > Comprobante no emitido : </strong> {MsgTimbrado}<br/>Por favor inténtelo de nuevo a través del botón 'Emitir' en ventas.</div>"
|
||||
MsgTimbrado = StrEr
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If respFactura IsNot Nothing Then
|
||||
@@ -1233,7 +1272,7 @@ Partial Class Ventas_PVCobranza
|
||||
Dim TimbroNC As Boolean = ObjTimbradoNC.TimbrarFactura(UsuarioActual, ObjNC)
|
||||
|
||||
If Not TimbroNC Then
|
||||
MsgErrorTimbrado = ObjTimbradoNC.MensajeErrorCFDI
|
||||
MsgErrorTimbrado = $"{MsgErrorTimbrado} {ObjTimbradoNC.MensajeErrorCFDI}"
|
||||
End If
|
||||
ObjTimbradoNC = Nothing
|
||||
End If
|
||||
@@ -2160,4 +2199,391 @@ Partial Class Ventas_PVCobranza
|
||||
|
||||
UpContadoOtros.Update()
|
||||
End Sub
|
||||
|
||||
#Region "C A N C E L A C I O N E S"
|
||||
|
||||
|
||||
Protected Sub BtnValidar_Click(ByVal sender As Object, ByVal e As EventArgs)
|
||||
CveVentaCancelacion = -1
|
||||
|
||||
Dim GvRow As GridViewRow = CType(((CType(sender, LinkButton)).NamingContainer), GridViewRow)
|
||||
CveVentaCancelacion = GvRow.DataKey("CveVenta").ToEntero()
|
||||
Dim CveCliente As Integer = GvRow.DataKey("CveCliente").ToEntero()
|
||||
Dim Total As String = GvRow.DataKey("Total")
|
||||
Dim SubTotal As String = GvRow.DataKey("SubTotal")
|
||||
Dim Uuid As String = GvRow.DataKey("FolioFiscal")
|
||||
Dim RFCReceptor As String = GvRow.DataKey("RFCReceptor")
|
||||
Dim Folio As String = GvRow.DataKey("Folio")
|
||||
Dim TipoDocto As String = GvRow.DataKey("TipoDocto")
|
||||
Dim Nombre As String = GvRow.DataKey("Nombre")
|
||||
Dim CveEstatusRefact As String = GvRow.DataKey("CveEstatusRefacturacion")
|
||||
Dim Msg As String
|
||||
|
||||
If CveVentaCancelacion > 0 AndAlso Uuid <> "" Then
|
||||
Dim resp = VerificarVigenciaSAT(CveVentaCancelacion, CveCliente, Folio, TipoDocto, Uuid, UsuarioActual.Empresa.RFC, RFCReceptor, Total)
|
||||
|
||||
If resp.EnviarAcuse Then
|
||||
Msg = resp.Mensaje
|
||||
|
||||
If CveEstatusRefact = "4" Then
|
||||
Msg = Msg & "<br/><a class='Texto' href='/Ventas/Ventas.aspx?CveDevolucion=" & CveVentaCancelacion & "&NuevaFactura=1'> Refacturar</a>"
|
||||
End If
|
||||
|
||||
Alert(Msg, TipoMensaje.MsgConfirmacion, "BtnEnviarMailCancelacion();", TextoConfirmacion:="Enviar", TextoSegundoBoton:="Cancelar")
|
||||
Else
|
||||
Msg = resp.Mensaje
|
||||
|
||||
If CveEstatusRefact = "4" Then
|
||||
Msg = Msg & "<br/><a class='Texto' href='/Ventas/Ventas.aspx?CveDevolucion=" & CveVentaCancelacion & "&NuevaFactura=1'> Refacturar</a>"
|
||||
End If
|
||||
|
||||
Alert(Msg)
|
||||
End If
|
||||
End If
|
||||
|
||||
CargaCancelaciones()
|
||||
End Sub
|
||||
|
||||
Private Function VerificarVigenciaSAT(ByVal CveVenta As Integer, ByVal CveCliente As Integer, ByVal Folio As String, ByVal TipoDocto As String, ByVal uuid As String, ByVal emisor As String, ByVal receptor As String, ByVal total As String, ByVal Optional EsRefacturacion As Boolean = False, ByVal Optional FolioSustitucion As String = "", ByVal Optional CveEstatusFactura As Integer = -1, ByVal Optional CveMotivoSustitucion As Integer = 0) As MRespuestaSAT
|
||||
Dim retorno = New MRespuestaSAT With {
|
||||
.Mensaje = "",
|
||||
.EnviarAcuse = False,
|
||||
.LigaRefacturacion = "",
|
||||
.IrARefacturar = False
|
||||
}
|
||||
Dim sb = New StringBuilder()
|
||||
Dim CancelacionAcuse As String = ""
|
||||
Dim CancelacionFecha As DateTime = NowADS()
|
||||
Dim CveEstatus As Integer = 4
|
||||
|
||||
Try
|
||||
Dim resp = Timbrado.VerificarVigenciaSAT(uuid, UsuarioActual.Empresa.RFC, receptor, total, True)
|
||||
|
||||
If resp IsNot Nothing Then
|
||||
|
||||
If resp.Estado Is Nothing Then
|
||||
sb.Append("No se pudo comprobar el estado de la factura. El servicio del sat no esta disponible")
|
||||
retorno.Mensaje = sb.ToString()
|
||||
Return retorno
|
||||
End If
|
||||
|
||||
sb.AppendFormat("Folio Fiscal: {0} <br/>", uuid)
|
||||
sb.AppendFormat("Código Estado: {0} <br/>", resp.CodigoEstatus)
|
||||
sb.AppendFormat("Estado: {0} <br/>", resp.Estado)
|
||||
sb.AppendFormat("Es Cancelable: {0} <br/>", If(String.IsNullOrEmpty(resp.EsCancelable), "Desconocido", resp.EsCancelable))
|
||||
sb.AppendFormat("Estatus de Cancelación: {0} <br/><br/>", If(String.IsNullOrEmpty(resp.EsCancelable), "Desconocido", resp.EstatusCancelacion))
|
||||
|
||||
If Not UsuarioActual.Empresa.FacturaProduccion AndAlso (String.IsNullOrEmpty(uuid) OrElse uuid.Contains("test")) Then
|
||||
Dim respCancelacion = CancelarDocumento(CveVenta, CveEstatus, CveCliente, Folio, uuid, CancelacionAcuse, CancelacionFecha, TipoDocto, total.ToDouble(), UsuarioActual.Empresa.CvePAC, EsRefacturacion:=EsRefacturacion, FolioSustitucion:=FolioSustitucion, CveMotivoCancelacion:=CveMotivoSustitucion)
|
||||
|
||||
If Not respCancelacion.HuboError Then
|
||||
CveEstatus = respCancelacion.CveEstatus
|
||||
retorno.EnviarAcuse = True
|
||||
sb.Append("El documento se canceló correctamente.")
|
||||
sb.Append($"</br> <a href='/Compras/PopUpVerFactura.aspx?P={Encripta($"OP=CAN&CVEVTA={CveVenta}")}' class='Texto' target='_blank'>Imprimir Acuse</a>")
|
||||
|
||||
If Not EsRefacturacion Then
|
||||
sb.Append("</br></br> ¿Desea enviar el Acuse de Cancelación al Cliente?")
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
|
||||
If EsRefacturacion AndAlso CveEstatusFactura = 20 AndAlso resp.Estado.ToUpper().Trim() = "VIGENTE" AndAlso String.IsNullOrEmpty(resp.EstatusCancelacion) Then
|
||||
CveEstatus = 23
|
||||
Dim ObjVentas = New ClsVentas()
|
||||
|
||||
If ObjVentas.UpdateEstatusVenta(CveVenta, CveEstatus, UsuarioActual.CveEmpresa) Then
|
||||
sb.Append("El estatus de la factura fue cambiado a 'Cancelación Pendiente'.")
|
||||
Else
|
||||
sb.Append("Ocurrió un error al cambiar el estatus de la factura.")
|
||||
End If
|
||||
|
||||
ObjVentas.Dispose()
|
||||
ElseIf resp.Estado.ToUpper().Trim() = "CANCELADO" OrElse resp.EstatusCancelacion.ToUpper() = "PLAZO VENCIDO" Then
|
||||
CveEstatus = 5
|
||||
Dim respCancelacion = CancelarDocumento(CveVenta, CveEstatus, CveCliente, Folio, uuid, CancelacionAcuse, CancelacionFecha, TipoDocto, total.ToDouble(), UsuarioActual.Empresa.CvePAC, EsRefacturacion:=EsRefacturacion, FolioSustitucion:=FolioSustitucion, CveMotivoCancelacion:=CveMotivoSustitucion)
|
||||
|
||||
If Not respCancelacion.HuboError Then
|
||||
|
||||
If respCancelacion.CveEstatus > 0 Then
|
||||
retorno.EnviarAcuse = True
|
||||
CveEstatus = respCancelacion.CveEstatus
|
||||
Dim ObjVentas = New ClsVentas()
|
||||
|
||||
If ObjVentas.UpdateEstatusVenta(CveVenta, CveEstatus, UsuarioActual.CveEmpresa) Then
|
||||
|
||||
If respCancelacion.CveEstatus = 20 Then
|
||||
sb.Append("El estatus de la factura fue cambiado a 'Cancelación en proceso'.")
|
||||
ElseIf respCancelacion.CveEstatus = 23 Then
|
||||
sb.Append("La solicitud de cancelación no la aplicó el SAT, intente cancelar de nuevo.<br/>")
|
||||
sb.AppendFormat("Folio Fiscal: {0} <br/>", uuid)
|
||||
sb.AppendFormat("Código Estado: {0} <br/>", resp.CodigoEstatus)
|
||||
sb.AppendFormat("Estado: {0} <br/>", resp.Estado)
|
||||
sb.AppendFormat("Es Cancelable: {0} <br/>", If(String.IsNullOrEmpty(resp.EsCancelable), "Desconocido", resp.EsCancelable))
|
||||
sb.AppendFormat("Estatus de Cancelación: {0} <br/><br/>", If(String.IsNullOrEmpty(resp.EsCancelable), "Desconocido", resp.EstatusCancelacion))
|
||||
Else
|
||||
sb.Append("El estatus de la factura fue cambiado a 'Cancelada'.")
|
||||
End If
|
||||
Else
|
||||
sb.Append("Ocurrió un error al cambiar el estatus de la factura.")
|
||||
End If
|
||||
|
||||
ObjVentas.Dispose()
|
||||
sb.Append("El documento se canceló correctamente.")
|
||||
sb.Append($"</br> <a href='/Compras/PopUpVerFactura.aspx?P={Encripta($"OP=CAN&CVEVTA={CveVenta}")}' class='Texto' target='_blank'>Imprimir Acuse</a>")
|
||||
|
||||
If Not EsRefacturacion Then
|
||||
sb.Append("</br></br> ¿Desea enviar el Acuse de Cancelación al Cliente?")
|
||||
End If
|
||||
Else
|
||||
sb.Append(respCancelacion.Mensaje)
|
||||
End If
|
||||
End If
|
||||
ElseIf resp.EstatusCancelacion.ToUpper() = "SOLICITUD RECHAZADA" Then
|
||||
CveEstatus = 3
|
||||
Dim Estatus As String = "Emitida"
|
||||
|
||||
If EsRefacturacion Then
|
||||
CveEstatus = 23
|
||||
Estatus = "Cancelación pendiente"
|
||||
End If
|
||||
|
||||
Dim ObjVentas = New ClsVentas()
|
||||
|
||||
If ObjVentas.UpdateEstatusVenta(CveVenta, CveEstatus, UsuarioActual.CveEmpresa) Then
|
||||
sb.Append($"El estatus de la factura fue cambiado a '{Estatus}'.")
|
||||
Else
|
||||
sb.Append("Ocurrió un error al cambiar el estatus de la factura.")
|
||||
End If
|
||||
|
||||
ObjVentas.Dispose()
|
||||
ElseIf resp.Estado.ToUpper().Trim() = "VIGENTE" AndAlso String.IsNullOrEmpty(resp.EstatusCancelacion) AndAlso Not EsRefacturacion Then
|
||||
CveEstatus = 3
|
||||
Dim Estatus As String = "Emitida"
|
||||
|
||||
If EsRefacturacion Then
|
||||
CveEstatus = 23
|
||||
Estatus = "Cancelación pendiente"
|
||||
End If
|
||||
|
||||
Dim ObjVentas = New ClsVentas()
|
||||
|
||||
If ObjVentas.UpdateEstatusVenta(CveVenta, CveEstatus, UsuarioActual.CveEmpresa) Then
|
||||
sb.Append($"El estatus de la factura fue cambiado a '{Estatus}'.")
|
||||
Else
|
||||
sb.Append("Ocurrió un error al cambiar el estatus de la factura.")
|
||||
End If
|
||||
|
||||
ObjVentas.Dispose()
|
||||
ElseIf (resp.EsCancelable.ToUpper() = "NO CANCELABLE") Then
|
||||
sb.Append("Esta factura no es cancelable.")
|
||||
retorno.Mensaje = sb.ToString()
|
||||
Return retorno
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
sb.Append("No se pudo comprobar la vigencia de la factura.")
|
||||
retorno.Mensaje = sb.ToString()
|
||||
Return retorno
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
sb.Append("Error al consumir el servicio: " & ex.Message)
|
||||
retorno.Mensaje = sb.ToString()
|
||||
Return retorno
|
||||
End Try
|
||||
|
||||
retorno.CveEstatus = CveEstatus
|
||||
retorno.Mensaje = sb.ToString()
|
||||
Return retorno
|
||||
End Function
|
||||
|
||||
Private Function CancelarDocumento(ByVal CveVenta As Integer, ByVal CveEstatus As Integer, ByVal CveCliente As Integer, ByVal Folio As String, ByVal FolioFiscal As String, ByVal CancelacionAcuse As String, ByVal CancelacionFecha As DateTime, ByVal TipoComprobante As String, ByVal Total As Double, ByVal CvePACCancelacion As Integer, ByVal Optional EsRefacturacion As Boolean = False, ByVal Optional FolioSustitucion As String = "", ByVal Optional CveEstatusRefacturacion As Integer = 0, ByVal Optional CveMotivoCancelacion As Integer = 0) As Modelos.Factura.MCancelacionVentaMensaje
|
||||
Dim retorno As Modelos.Factura.MCancelacionVentaMensaje = Nothing
|
||||
Dim factura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=True, VerificaAlmacen:=True)
|
||||
|
||||
If factura.ErrorList.Count > 0 Then
|
||||
retorno.HuboError = True
|
||||
Return retorno
|
||||
End If
|
||||
|
||||
If EsRefacturacion Then
|
||||
|
||||
If Not String.IsNullOrEmpty(FolioSustitucion) Then
|
||||
CveEstatusRefacturacion = 2
|
||||
End If
|
||||
|
||||
If CveEstatusRefacturacion > 0 Then
|
||||
factura.CveEstatusRefacturacion = CveEstatusRefacturacion
|
||||
End If
|
||||
|
||||
If CveMotivoCancelacion > 0 Then
|
||||
factura.CveMotivoCancelacion = CveMotivoCancelacion
|
||||
End If
|
||||
|
||||
Dim CveEstatusFactura As Integer = -1
|
||||
|
||||
If CveEstatus = 5 Then
|
||||
CveEstatusFactura = CveEstatus
|
||||
End If
|
||||
|
||||
If CveEstatus = -2 Then
|
||||
CveEstatusFactura = -1
|
||||
End If
|
||||
|
||||
retorno = factura.CancelarPorRefacturacion(factura.CveMotivoCancelacion, factura.MotivoCancelacion, FolioSustitucion:=FolioSustitucion, CveEstadoCancelacion:=CveEstatusFactura)
|
||||
Else
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso factura.TipoDocto = "Dev" AndAlso factura.SaldoAlmacen <> 0 Then
|
||||
factura.RealizarDevolucionAlmacen = 1
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(567) = "1" AndAlso factura.TipoDocto.Contiene("Ing", "Dev") AndAlso factura.SaldoAlmacen <> 0 Then
|
||||
factura.RealizarDevolucionAlmacen = 1
|
||||
End If
|
||||
|
||||
If UsuarioActual.TienePermisoProceso(269) AndAlso factura.TipoDocto.Contiene("Ing", "Dev") AndAlso factura.SaldoAlmacen <> 0 Then
|
||||
factura.RealizarDevolucionAlmacen = 1
|
||||
End If
|
||||
|
||||
If factura.TipoDocto = "Ing" Then
|
||||
|
||||
Using ObjVentas = New ClsVentas()
|
||||
|
||||
If ObjVentas.GetRemisionesRelacionadas(CveVenta, factura.TipoDocto) Then
|
||||
|
||||
If ObjVentas.DtResultados.Copy().Rows.Count > 0 Then
|
||||
factura.RealizarDevolucionAlmacen = 1
|
||||
End If
|
||||
Else
|
||||
retorno = New Modelos.Factura.MCancelacionVentaMensaje()
|
||||
retorno.Mensaje = "No se pudo verificar si tiene remisiones relacionadas"
|
||||
retorno.HuboError = True
|
||||
Return retorno
|
||||
End If
|
||||
End Using
|
||||
End If
|
||||
|
||||
Dim CancelacionPagos = Modelos.OpcionesCancelacionPagos.SinPagos
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(109) = "1" OrElse UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
|
||||
CancelacionPagos = Modelos.OpcionesCancelacionPagos.ConPagos_CancelarIE
|
||||
End If
|
||||
|
||||
retorno = factura.EjecutarCancelacionPendiente(CveEstatus, CancelacionFecha, CancelacionAcuse, CancelacionPagos:=CancelacionPagos)
|
||||
End If
|
||||
|
||||
Return retorno
|
||||
End Function
|
||||
|
||||
Protected Sub GvCancelaciones_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
Dim gv As GridView = CType(sender, GridView)
|
||||
|
||||
If Not (e.Row.DBCampo("PuedeRefacturar").ToEntero() = 0 OrElse Not String.IsNullOrEmpty(e.Row.DBCampo("FolioFiscalSustitucion"))) Then
|
||||
e.Row.FCHyperLink("HplRefact").NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveDevolucion={0}&NuevaFactura=1", e.Row.DBCampo("CveVenta"))
|
||||
e.Row.FCHyperLink("HplRefact").Visible = True
|
||||
End If
|
||||
|
||||
If e.Row.DBCampo("CveEstatusRefacturacion") = "4" AndAlso gv.ID = "GvDatos" Then
|
||||
e.Row.FCLinkButton("BtnValidar").Text = "<i class='fa fa-check'>02</i>"
|
||||
e.Row.FCLinkButton("BtnValidar").CssClass = "btn btn-circle btn-sm blue"
|
||||
End If
|
||||
|
||||
If e.Row.DBCampo("PuedeRefacturar") = "0" AndAlso e.Row.DBCampo("CveEstatusFactura") = "23" AndAlso e.Row.DBCampo("CveVentaSustitucion").ToEntero() > 0 Then
|
||||
If e.Row.FCLinkButton("LnkCancelar") IsNot Nothing Then e.Row.FCLinkButton("LnkCancelar").Visible = True
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub BtnEnviarMailCancelacion_Click(ByVal sender As Object, ByVal e As EventArgs)
|
||||
If CveVentaCancelacion > 0 Then
|
||||
ImprimeCancelacion(CveVentaCancelacion)
|
||||
Else
|
||||
Alert("No se encontro la factura para enviar el acuse", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub ImprimeCancelacion(ByVal CveVenta As Integer)
|
||||
Dim Archivo = New System.IO.FileInfo(ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\AcuseCancelacion.rdlc")
|
||||
|
||||
If Archivo.Exists Then
|
||||
Dim ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, CargaDTDetalle:=False, CargaDatosRelacionados:=False)
|
||||
Dim ObjetoPDF As Byte() = DescargarPDF(Encripta(String.Format("OP=CAN&CVEVTA={0}", CveVenta)))
|
||||
Dim LSRutasMail As List(Of ClsSisMail.ArchivoMail) = New List(Of ClsSisMail.ArchivoMail)()
|
||||
Dim Asunto As String = String.Empty
|
||||
Dim Cuerpo As String = String.Empty
|
||||
Dim sb As StringBuilder = New StringBuilder()
|
||||
|
||||
sb.Append("<!DOCTYPE html>")
|
||||
sb.Append("<html>")
|
||||
sb.Append("<head>")
|
||||
sb.Append("<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8""/>")
|
||||
sb.Append(" <title>Acuse De Cancelación</title>")
|
||||
sb.Append(vbTab & "<meta charset=""utf-8"" />")
|
||||
sb.Append("</head>")
|
||||
sb.Append("<body>")
|
||||
sb.Append(" <font face=""calibri"">")
|
||||
sb.Append($" Estimado Cliente <b>{ObjFactura.Cliente.Nombre}</b>,<br /><br />")
|
||||
sb.Append($" A través del presente medio la Empresa <b>{UsuarioActual.Empresa.Empresa} - {UsuarioActual.Empresa.RFC}</b>, canceló el documento tipo <b>{ObjFactura.TipodeComprobante}</b> <br />")
|
||||
sb.Append($" con folio <b>{ObjFactura.SerieFolio}</b> y el Importe de <b>${ObjFactura.Total}</b>. <br /><br />")
|
||||
sb.Append(" Le hacemos llegar el acuse de cancelación. </font> ")
|
||||
sb.Append(" <font face=""calibri"" size=""2"">")
|
||||
sb.Append(" <br /><br /><br /><br /><br />")
|
||||
sb.Append(" <i>Este correo se generó automaticamente, favor de no responder este mensaje.</i>")
|
||||
sb.Append(" </font>")
|
||||
sb.Append("</body>")
|
||||
sb.Append("</html>")
|
||||
|
||||
Asunto = $"Acuse de Cancelacion {ObjFactura.SerieFolio}"
|
||||
Cuerpo = sb.ToString()
|
||||
Dim DisplayName As String = ""
|
||||
|
||||
LSRutasMail.Add(New ClsSisMail.ArchivoMail() With {
|
||||
.ArchivoBinario = ObjetoPDF,
|
||||
.NombreArchivo = $"AcuseCancelacion{ObjFactura.SerieFolio}.pdf"
|
||||
})
|
||||
Dim ObjMail As ClsSisMail = New ClsSisMail()
|
||||
|
||||
If ObjMail.SendMail(UsuarioActual.Empresa, ObjFactura.Cliente.Mail, Asunto, Cuerpo, "", LSRutasMail, Displayname:=DisplayName) Then
|
||||
Alert("El acuse de cancelación ha sido envíado correctamente.")
|
||||
Else
|
||||
Alert("El acuse de cancelación no pudo ser enviado.", TipoMensaje.MsgError)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
Private Function DescargarPDF(Parametros As String) As Byte()
|
||||
Dim Url = New Uri(String.Format("{0}Compras/PopUpVerFactura.aspx?P={1}", ClsPaginas.UrlSitio, Parametros))
|
||||
Dim File As Byte() = Nothing
|
||||
Try
|
||||
Using httpClient = New HttpClient()
|
||||
httpClient.Timeout = New TimeSpan(0, 1, 0)
|
||||
Using request = New HttpRequestMessage(HttpMethod.Get, Url)
|
||||
request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CVEUSUARIO={2}", UsuarioActual.CveEmpresa, DateTime.UtcNow.Ticks, UsuarioActual.CveUsuario)))
|
||||
Dim response = httpClient.SendAsync(request).Result
|
||||
If response.StatusCode = Net.HttpStatusCode.OK Then
|
||||
File = response.Content.ReadAsByteArrayAsync().Result
|
||||
End If
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
File = Nothing
|
||||
OnError("Ocurrió un error al descargar la factura", ex)
|
||||
End Try
|
||||
|
||||
Return File
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
|
||||
Public Class MRespuestaSAT
|
||||
Public Property CveEstatus As Integer
|
||||
Public Property EnviarAcuse As Boolean
|
||||
Public Property LigaRefacturacion As String
|
||||
Public Property IrARefacturar As Boolean
|
||||
Public Property Mensaje As String
|
||||
End Class
|
||||
Reference in New Issue
Block a user