Refacturacion de facturas canceladas, cancelacion de refacturada desde el reporte. correccion de poliza en empresa UsaAC
This commit is contained in:
@@ -1266,6 +1266,14 @@ Partial Class Ventas
|
||||
ViewState("CveEstatusRefacturacion") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property RefacturarCancelada As Boolean
|
||||
Get
|
||||
Return If(IsNothing(ViewState("RefacturarCancelada")), False, CBool(ViewState("RefacturarCancelada")))
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("RefacturarCancelada") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property CveEstadoCancelacion As Integer
|
||||
Get
|
||||
@@ -4393,10 +4401,13 @@ Partial Class Ventas
|
||||
'End If
|
||||
|
||||
|
||||
If Not CveEstatus.Contiene(4, 5, 12, 13, 20, 23) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Ant") AndAlso UsuarioActual.TienePermisoProceso(159) Then
|
||||
If (Not CveEstatus.Contiene(4, 5, 12, 13, 20, 23) OrElse (CveEstatus = 5 AndAlso DbRowVenta("CveEstatusRefacturacion").ToString().ToEntero() = 4)) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Ant") AndAlso UsuarioActual.TienePermisoProceso(159) Then
|
||||
Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto")))
|
||||
If TienePermiso <> "" Then
|
||||
LkRefacturacion.Visible = True
|
||||
If (CveEstatus = 5 AndAlso DbRowVenta("CveEstatusRefacturacion").ToString().ToEntero() = 4) Then
|
||||
RefacturarCancelada = True
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -9106,6 +9117,15 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
'MARCAR LA FACTURA ANTERIOR
|
||||
If (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then
|
||||
If Me.ObjFacturaNC IsNot Nothing Then
|
||||
If Me.ObjFacturaNC.CveEstatusRefacturacion = 4 AndAlso Not ObjVentas.UpdateEstatusVenta(ObjFacturaNC.CveVenta, ObjFacturaNC.CveEstatusFactura, UsuarioActual.CveEmpresa, CveEstatusRefacturacion:=5) Then
|
||||
ErrorList.Add("No se actualizó el estatus de la factura anterior.")
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or ObjFactura.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then
|
||||
ObjVentas.Commit()
|
||||
|
||||
@@ -9134,13 +9154,14 @@ Partial Class Ventas
|
||||
End If
|
||||
Else
|
||||
Alert(String.Format("Falta asignación de las siguientes cuentas contables: {0}", CuentasContablesInvalidas), TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
Else
|
||||
If UsuarioActual.Empresa.UsaAC Then
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
'If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
||||
|
||||
'RMF, cuando es pedido, se manda autorización.
|
||||
If ObjFactura.TipoDocto.Contiene("PA") Then
|
||||
|
||||
@@ -9268,7 +9289,7 @@ Partial Class Ventas
|
||||
|
||||
'CANCELAR FACTURA ANTERIOR
|
||||
If SeTimbro AndAlso (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then
|
||||
If Me.ObjFacturaNC IsNot Nothing Then
|
||||
If Me.ObjFacturaNC IsNot Nothing AndAlso Me.ObjFacturaNC.CveEstatusFactura <> 5 Then
|
||||
Me.ObjFacturaNC.CveEstatusRefacturacion = 2 'MARCAR COMO REFACTURADA
|
||||
MsgCancelacionRefacturacion = Me.ObjFacturaNC.CancelarPorRefacturacion(Me.ObjFacturaNC.CveMotivoCancelacion, Me.ObjFacturaNC.MotivoCancelacion, FolioFiscalFactura)
|
||||
End If
|
||||
@@ -20905,129 +20926,134 @@ Partial Class Ventas
|
||||
'End Sub
|
||||
Private Sub BtnNuevaFactura_Click(sender As Object, e As EventArgs) Handles LkRefacturacion.Click
|
||||
'Nos vamos a la nueva factura
|
||||
Dim script As String = ""
|
||||
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Dev", "Egs") Then
|
||||
Dim sb As New StringBuilder()
|
||||
If RefacturarCancelada Then
|
||||
Response.Redirect($"Ventas.aspx?CveDevolucion={CveVenta}&NuevaFactura=1")
|
||||
Else
|
||||
Dim script As String = ""
|
||||
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Dev", "Egs") Then
|
||||
Dim sb As New StringBuilder()
|
||||
|
||||
If Not String.IsNullOrEmpty(FolioFiscal) AndAlso Not (UsuarioActual.Empresa.Funcionalidad(529) = "1") Then
|
||||
sb.Append("La factura se encuentra en el siguiente estatus del SAT:<br/>")
|
||||
If Not String.IsNullOrEmpty(FolioFiscal) AndAlso Not (UsuarioActual.Empresa.Funcionalidad(529) = "1") Then
|
||||
sb.Append("La factura se encuentra en el siguiente estatus del SAT:<br/>")
|
||||
|
||||
Dim TotalT As Decimal = TxtTotal.Text.ToDecimal
|
||||
Dim RFCReceptor As String = LblRFC.Text.Trim
|
||||
Dim TotalT As Decimal = TxtTotal.Text.ToDecimal
|
||||
Dim RFCReceptor As String = LblRFC.Text.Trim
|
||||
|
||||
'SI SE FACTURO LA SUCURSAL DEL CLIENTE TOMA EL RFC DE ESTA
|
||||
If FacturarSucursal AndAlso Me.ClienteSucursal IsNot Nothing Then
|
||||
RFCReceptor = Me.ClienteSucursal.RFC
|
||||
End If
|
||||
'SI SE FACTURO LA SUCURSAL DEL CLIENTE TOMA EL RFC DE ESTA
|
||||
If FacturarSucursal AndAlso Me.ClienteSucursal IsNot Nothing Then
|
||||
RFCReceptor = Me.ClienteSucursal.RFC
|
||||
End If
|
||||
|
||||
Dim SWatch As New Stopwatch
|
||||
SWatch.Start()
|
||||
Dim SWatch As New Stopwatch
|
||||
SWatch.Start()
|
||||
|
||||
Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), True)
|
||||
SWatch.Stop()
|
||||
Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), True)
|
||||
SWatch.Stop()
|
||||
|
||||
Dim SegundosRespuesta As Double = SWatch.ElapsedMilliseconds / 1000
|
||||
SegundosRespuesta = SegundosRespuesta.ToEntero
|
||||
Dim SegundosRespuesta As Double = SWatch.ElapsedMilliseconds / 1000
|
||||
SegundosRespuesta = SegundosRespuesta.ToEntero
|
||||
|
||||
If SegundosRespuesta >= 5 Then
|
||||
Alert($"Los servicios de validacion del SAT presentan lentitud en la respuesta [{ SegundosRespuesta } s].", TipoMensaje.ToastError, "")
|
||||
End If
|
||||
If SegundosRespuesta >= 5 Then
|
||||
Alert($"Los servicios de validacion del SAT presentan lentitud en la respuesta [{ SegundosRespuesta } s].", TipoMensaje.ToastError, "")
|
||||
End If
|
||||
|
||||
If Vigencia IsNot Nothing Then
|
||||
If Vigencia IsNot Nothing Then
|
||||
|
||||
If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then
|
||||
sb.AppendFormat("<b>{0}</b> <br/>", Vigencia.EsCancelable)
|
||||
If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then
|
||||
sb.AppendFormat("<b>{0}</b> <br/>", Vigencia.EsCancelable)
|
||||
|
||||
DivRelacionadasRefacturacion.Visible = True
|
||||
BtnMotivoRefacturacion.Visible = False
|
||||
DivMotivoRefacturacionTexto.Visible = False
|
||||
DivRelacionadasRefacturacion.Visible = True
|
||||
BtnMotivoRefacturacion.Visible = False
|
||||
DivMotivoRefacturacionTexto.Visible = False
|
||||
|
||||
Dim Relacionados = Timbrado.ConsultarUUIDRelacionados(UsuarioActual.Empresa, FolioFiscal, UsuarioActual.Empresa.FacturaProduccion)
|
||||
If Relacionados IsNot Nothing Then
|
||||
Dim sbExtra As New StringBuilder()
|
||||
If Relacionados.Codigo = 500 Then
|
||||
sbExtra.Append("El servicio de verificación de documentos relacionados no esta disponible.")
|
||||
Else
|
||||
sbExtra.Append(Relacionados.Mensaje)
|
||||
Dim Relacionados = Timbrado.ConsultarUUIDRelacionados(UsuarioActual.Empresa, FolioFiscal, UsuarioActual.Empresa.FacturaProduccion)
|
||||
If Relacionados IsNot Nothing Then
|
||||
Dim sbExtra As New StringBuilder()
|
||||
If Relacionados.Codigo = 500 Then
|
||||
sbExtra.Append("El servicio de verificación de documentos relacionados no esta disponible.")
|
||||
Else
|
||||
sbExtra.Append(Relacionados.Mensaje)
|
||||
|
||||
Dim SbHijos = New StringBuilder()
|
||||
Dim SbPadres = New StringBuilder()
|
||||
Dim SbHijos = New StringBuilder()
|
||||
Dim SbPadres = New StringBuilder()
|
||||
|
||||
'If Relacionados.RelacionadosHijo IsNot Nothing Then
|
||||
' For Each hijo In Relacionados.RelacionadosHijo
|
||||
' SbHijos.AppendFormat("{0};", hijo.Uuid)
|
||||
' Next
|
||||
' If SbHijos.Length > 0 Then
|
||||
' SbHijos.Remove(SbHijos.Length - 1, 1)
|
||||
' End If
|
||||
'End If
|
||||
|
||||
If Relacionados.RelacionadosPadre IsNot Nothing Then
|
||||
For Each padre In Relacionados.RelacionadosPadre
|
||||
SbPadres.AppendFormat("{0};", padre.Uuid)
|
||||
Next
|
||||
If SbPadres.Length > 0 Then
|
||||
SbPadres.Remove(SbPadres.Length - 1, 1)
|
||||
End If
|
||||
End If
|
||||
|
||||
Using ObjVentas As New ClsVentas
|
||||
|
||||
'If SbHijos.Length > 0 Then
|
||||
' If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbHijos.ToString(), UsuarioActual.CveEmpresa) Then
|
||||
' GvFacturasHijosCancelar.DataSource = ObjVentas.DtResultados.Copy()
|
||||
'If Relacionados.RelacionadosHijo IsNot Nothing Then
|
||||
' For Each hijo In Relacionados.RelacionadosHijo
|
||||
' SbHijos.AppendFormat("{0};", hijo.Uuid)
|
||||
' Next
|
||||
' If SbHijos.Length > 0 Then
|
||||
' SbHijos.Remove(SbHijos.Length - 1, 1)
|
||||
' End If
|
||||
'End If
|
||||
|
||||
If SbPadres.Length > 0 Then
|
||||
If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbPadres.ToString(), UsuarioActual.CveEmpresa) Then
|
||||
GvFacturasPadreRefacturar.DataSource = ObjVentas.DtResultados.FiltraParametros($"CveVenta <> {CveVenta}")
|
||||
If Relacionados.RelacionadosPadre IsNot Nothing Then
|
||||
For Each padre In Relacionados.RelacionadosPadre
|
||||
SbPadres.AppendFormat("{0};", padre.Uuid)
|
||||
Next
|
||||
If SbPadres.Length > 0 Then
|
||||
SbPadres.Remove(SbPadres.Length - 1, 1)
|
||||
End If
|
||||
End If
|
||||
|
||||
End Using
|
||||
Using ObjVentas As New ClsVentas
|
||||
|
||||
'If SbHijos.Length > 0 Then
|
||||
' If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbHijos.ToString(), UsuarioActual.CveEmpresa) Then
|
||||
' GvFacturasHijosCancelar.DataSource = ObjVentas.DtResultados.Copy()
|
||||
' End If
|
||||
'End If
|
||||
|
||||
If SbPadres.Length > 0 Then
|
||||
If ObjVentas.GetFacturasRelacionadasPorFolioFiscal(SbPadres.ToString(), UsuarioActual.CveEmpresa) Then
|
||||
GvFacturasPadreRefacturar.DataSource = ObjVentas.DtResultados.FiltraParametros($"CveVenta <> {CveVenta}")
|
||||
End If
|
||||
End If
|
||||
|
||||
End Using
|
||||
|
||||
'GvFacturasHijosCancelar.DataBind()
|
||||
GvFacturasPadreRefacturar.DataBind()
|
||||
End If
|
||||
|
||||
If sbExtra.Length > 0 Then
|
||||
LbExtraRefacturacion.Text = $"<br><b>*{sbExtra.ToString()}</b>"
|
||||
End If
|
||||
|
||||
'GvFacturasHijosCancelar.DataBind()
|
||||
GvFacturasPadreRefacturar.DataBind()
|
||||
End If
|
||||
|
||||
If sbExtra.Length > 0 Then
|
||||
LbExtraRefacturacion.Text = $"<br><b>*{sbExtra.ToString()}</b>"
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
If Vigencia.EsCancelable = "Cancelable sin aceptación" Then
|
||||
'script = "BtnRefacturacionConfirmarAceptacion();"
|
||||
Me.CveEstadoCancelacion = 1
|
||||
sb.AppendFormat("<b>{0}</b> <br/>", Vigencia.EsCancelable)
|
||||
sb.Append("Está seguro de realizar la refacturación?.")
|
||||
End If
|
||||
If Vigencia.EsCancelable = "Cancelable sin aceptación" Then
|
||||
'script = "BtnRefacturacionConfirmarAceptacion();"
|
||||
Me.CveEstadoCancelacion = 1
|
||||
sb.AppendFormat("<b>{0}</b> <br/>", Vigencia.EsCancelable)
|
||||
sb.Append("Está seguro de realizar la refacturación?.")
|
||||
End If
|
||||
|
||||
If Vigencia.EsCancelable = "Cancelable con aceptación" OrElse String.IsNullOrEmpty(Vigencia.EsCancelable) Then
|
||||
'script = "BtnRefacturacionConfirmar();"
|
||||
Me.CveEstadoCancelacion = 2
|
||||
sb.AppendFormat("<b>{0}</b> <br/>", "Cancelable con aceptación")
|
||||
sb.Append("Está seguro de cancelar el documento para realizar la refacturación?.")
|
||||
If Vigencia.EsCancelable = "Cancelable con aceptación" OrElse String.IsNullOrEmpty(Vigencia.EsCancelable) Then
|
||||
'script = "BtnRefacturacionConfirmar();"
|
||||
Me.CveEstadoCancelacion = 2
|
||||
sb.AppendFormat("<b>{0}</b> <br/>", "Cancelable con aceptación")
|
||||
sb.Append("Está seguro de cancelar el documento para realizar la refacturación?.")
|
||||
End If
|
||||
Else
|
||||
'If Not UsuarioActual.Empresa.FacturaProduccion Then
|
||||
' script = "BtnRefacturacionConfirmar();"
|
||||
'End If
|
||||
sb.Append("<b>No encontrado</b> <br/>")
|
||||
End If
|
||||
Else
|
||||
'If Not UsuarioActual.Empresa.FacturaProduccion Then
|
||||
' script = "BtnRefacturacionConfirmar();"
|
||||
'End If
|
||||
sb.Append("<b>No encontrado</b> <br/>")
|
||||
'sb.Append("¿Desea realizar la refacturación?<br/>")
|
||||
script = "BtnRefacturacionConfirmarAceptacion();"
|
||||
End If
|
||||
Else
|
||||
'sb.Append("¿Desea realizar la refacturación?<br/>")
|
||||
script = "BtnRefacturacionConfirmarAceptacion();"
|
||||
|
||||
LblEstatusRefacturacion.Text = sb.ToString()
|
||||
UpMotivoRefac.Update()
|
||||
|
||||
RegistraScript("$('#DivMotivoRefacturacion').modal({ backdrop: 'static', keyboard: false });", "R1")
|
||||
'Alert(sb.ToString(), TipoMensaje.MsgConfirmacion, JSBtnAceptar:=script, TextoConfirmacion:=" Si ", TextoCancelacion:=" No ")
|
||||
End If
|
||||
|
||||
LblEstatusRefacturacion.Text = sb.ToString()
|
||||
UpMotivoRefac.Update()
|
||||
|
||||
RegistraScript("$('#DivMotivoRefacturacion').modal({ backdrop: 'static', keyboard: false });", "R1")
|
||||
'Alert(sb.ToString(), TipoMensaje.MsgConfirmacion, JSBtnAceptar:=script, TextoConfirmacion:=" Si ", TextoCancelacion:=" No ")
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub BtnMotivoRefacturacion_Click(sender As Object, e As System.EventArgs) Handles BtnMotivoRefacturacion.Click
|
||||
|
||||
Reference in New Issue
Block a user