Validacion de pagos,mensajes del sat

This commit is contained in:
2020-05-22 18:46:58 -07:00
parent c0cfbe5352
commit 253e5ef303
2 changed files with 84 additions and 23 deletions

View File

@@ -6326,12 +6326,12 @@
<label for="<%= TxtCPCliente.ClientID.ToString()%>">Código Postal:</label>
</div>
<div class="form-group form-md-line-input input-iconright col-xs-4">
<asp:TextBox ID="TxtNumExtCliente" CssClass="form-control " runat="server" MaxLength="20" CausesValidation="true"></asp:TextBox>
<asp:TextBox ID="TxtNumExtCliente" CssClass="form-control " runat="server" MaxLength="40" CausesValidation="true"></asp:TextBox>
<asp:RequiredFieldValidator ID="RFVNoEC" runat="server" ControlToValidate="TxtNumExtCliente" CssClass="help-block errorimput" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Número Exterior''</b> es necesario, por favor ingréselo." ValidationGroup="GrpGuardarCliente"></asp:RequiredFieldValidator>
<label for="<%= TxtNumExtCliente.ClientID.ToString()%>">Número Exterior:</label>
</div>
<div class="form-group form-md-line-input input-iconright col-xs-4">
<asp:TextBox ID="TxtNumIntCliente" CssClass="form-control " runat="server" MaxLength="20" CausesValidation="true"></asp:TextBox>
<asp:TextBox ID="TxtNumIntCliente" CssClass="form-control " runat="server" MaxLength="50" CausesValidation="true"></asp:TextBox>
<label for="<%= TxtNumIntCliente.ClientID.ToString()%>">Número Interior:</label>
</div>
</div>

View File

@@ -10,6 +10,7 @@ Imports System.Security.Cryptography.X509Certificates
Imports System.Globalization
Imports System.Net.Http
Imports Newtonsoft.Json.Linq
Imports System.Diagnostics
Partial Class Ventas
Inherits ClsPaginas
@@ -7011,11 +7012,18 @@ Partial Class Ventas
'End If
'Esquema viejo, evitamos que aparezca por surtir
If ErrorList.Count = 0 Then
'MARCAR VENTA ANTERIOR
If Not ObjInventario.ActualizarEsDevolucionVenta(CveDevolucion, 2) Then
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
End If
'MARCAR VENTA ANTERIOR
If VentaSaldoAlmacenNC <> 0 OrElse DevolucionAlmacenNC = 2 Then
If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then
ErrorList.Add("No se pudo Cancelar el movimiento de almacen de la Factura")
End If
End If
End If
End If
End If
@@ -10152,10 +10160,10 @@ Partial Class Ventas
Exit For
Else
ViewState("SeGuardoPrePoliza") = True
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimiento, Referencia, 2, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=ObjFactura.CveCliente, ImporteMX:=importeMovimiento, ImporteME:=If(Dr("TCCambioValuacion").ToString().ToDecimal = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, CveIE:=CveIEAnticipo, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString().ToDecimal, TipoCambioPago:=tipoCambio) Then
ErrorPrepoliza = True
Exit For
End If
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimiento, Referencia, 2, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=ObjFactura.CveCliente, ImporteMX:=importeMovimiento, ImporteME:=If(Dr("TCCambioValuacion").ToString().ToDecimal = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, CveIE:=CveIEAnticipo, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString().ToDecimal, TipoCambioPago:=tipoCambio) Then
ErrorPrepoliza = True
Exit For
End If
'se hace acreditamiento de impuestos
'IVA X TRASLADAR
Dim EsAnticipoEspecial As Boolean = False
@@ -10208,10 +10216,10 @@ Partial Class Ventas
End If
End If
End If
End If
End If
Next
End If
@@ -13289,7 +13297,7 @@ Partial Class Ventas
End If
Else
Alert("Se presento un error al cancelar el complemento.")
Alert("Los servicios de cancelación del SAT no se encuentran disponibles o presentan time out. Intente de nuevo en unos minutos.<br/>Origen del error: WebService www.sat.gob.mx", TipoMensaje.MsgError)
End If
ObjBanco.Dispose()
@@ -16154,6 +16162,8 @@ Partial Class Ventas
End If
MovDetalle.Dispose()
OcurrioError = Not GeneroMovimientoAlmacen
End If
End If
@@ -16167,7 +16177,7 @@ Partial Class Ventas
End If
Next
OcurrioError = Not GeneroMovimientoAlmacen
End If
End If
@@ -16321,7 +16331,7 @@ Partial Class Ventas
CveMovimientoDetalleEntrada = MovDet("CveMovimientoDetalle").ToString().ToEntero()
End If
If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, CveSeccionAlmacen:=CVeSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then
If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then
ContadorMovtosDetalles += 1
Else
OcurrioError = True
@@ -17022,7 +17032,21 @@ Partial Class Ventas
Dim TotalT As Decimal = TxtTotal.Text.ToDecimal
Dim RFCReceptor As String = LblRFC.Text.Trim
Dim SWatch As New Stopwatch
SWatch.Start()
Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), True)
SWatch.Stop()
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 Vigencia IsNot Nothing Then
If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then
@@ -17990,17 +18014,30 @@ Partial Class Ventas
Private Function ValidaPagosContado() As Boolean
Dim Retorno = False
Dim AmortizacionNC As Decimal = 0
'SI ES AMORTIZACION POR NOTA DE CREDITO DEBE SUMAR LA TOTALIDAD PARA COMPARAR EL PAGO
If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
For Each gvr As GridViewRow In GVAnticipos.Rows
If gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked AndAlso gvr.DataKey("CveConceptoContable").ToEntero().Contiene(3) Then
AmortizacionNC += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal
End If
Next
End If
Dim TienePagos As Boolean = ((Not (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0)) AndAlso (DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0)) OrElse AmortizacionNC > 0
'SI LA VENTA ES NUEVA VALIDAR TAMBIEN LOS PAGOS DE CONTADO
If UsuarioActual.CveEmpresa = 141 AndAlso CveVenta <= 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then
If Not PermiteCredito AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) AndAlso TxtTotal.Text.ToDecimal > 0 Then
If Not PermiteCredito AndAlso Not TienePagos AndAlso TxtTotal.Text.ToDecimal > 0 Then
Alert("Es necesario especificar un pago.", TipoMensaje.MsgAdvertencia)
Retorno = True
Return Retorno
End If
If Not PermiteCredito AndAlso (DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0) AndAlso TxtTotal.Text.ToDecimal > 0 Then
Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal()
If Not PermiteCredito AndAlso TienePagos AndAlso TxtTotal.Text.ToDecimal > 0 Then
Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal() + AmortizacionNC
If TotalPago < TxtTotal.Text.ToDecimal Then
Alert("La suma de los pagos debe ser igual al total de la venta.", TipoMensaje.MsgAdvertencia)
@@ -18013,15 +18050,15 @@ Partial Class Ventas
'SI TIENE SALDO PENDIENTE VALIDA SI TIENE PAGOS
If Me.SaldoVenta > 0 Then
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso (UsuarioActual.Empresa.Funcionalidad(531) = "1") AndAlso (Not PermiteCredito) AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) And TxtTotal.Text.ToDecimal > 0 Then
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso (UsuarioActual.Empresa.Funcionalidad(531) = "1") AndAlso (Not PermiteCredito) AndAlso Not TienePagos And TxtTotal.Text.ToDecimal > 0 Then
Alert("Es necesario especificar un pago.", TipoMensaje.MsgAdvertencia)
Retorno = True
End If
If UsuarioActual.CveEmpresa = 141 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then
If Not PermiteCredito AndAlso DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 AndAlso TxtTotal.Text.ToDecimal > 0 Then
Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal()
If Not PermiteCredito AndAlso TienePagos AndAlso TxtTotal.Text.ToDecimal > 0 Then
Dim TotalPago As Decimal = DtPagos.SUM("Importe").ToDecimal() + AmortizacionNC
If TotalPago < TxtTotal.Text.ToDecimal Then
Alert("La suma de los pagos debe ser igual al total de la venta.", TipoMensaje.MsgAdvertencia)
@@ -18035,18 +18072,18 @@ Partial Class Ventas
If UsuarioActual.Empresa.Funcionalidad(572) = "1" Then
Dim TotalNC As Decimal = If(ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0, LblTotalNC.Text.Trim().ToDecimal(), 0)
If TotalNC > 0 Then
If (DtPagos.SUM("Importe").ToString().ToDecimal + Total - TxtCambio.Text.ToDecimal) > TotalNC Then
If (DtPagos.SUM("Importe").ToString().ToDecimal() + AmortizacionNC + Total - TxtCambio.Text.ToDecimal) > TotalNC Then
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia)
Retorno = True
End If
Else
If (DtPagos.SUM("Importe").ToString().ToDecimal + Total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then
If (DtPagos.SUM("Importe").ToString().ToDecimal() + AmortizacionNC + Total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia)
Retorno = True
End If
End If
Else
If (DtPagos.SUM("Importe").ToString().ToDecimal + Total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then
If (DtPagos.SUM("Importe").ToString().ToDecimal() + AmortizacionNC + Total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia)
Retorno = True
End If
@@ -19165,6 +19202,7 @@ Partial Class Ventas
End If
End If
ObjVentas.Dispose()
End Sub
Private Sub MostrarCondicionesCancelacion()
@@ -19199,7 +19237,19 @@ Partial Class Ventas
Dim TotalT As Decimal = TxtTotal.Text.ToDecimal
Dim RFCReceptor As String = LblRFC.Text.Trim
Dim SWatch As New Stopwatch
SWatch.Start()
Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), True)
SWatch.Stop()
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.ToastAdventencia, "")
End If
If Vigencia IsNot Nothing Then
If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then
Alert("Esta factura no es cancelable.", TipoMensaje.MsgAdvertencia)
@@ -19259,7 +19309,7 @@ Partial Class Ventas
CancelacionAcuse = ObjCancelacion.CancelacionAcuse
CveEstatus = 5
Else
Alert("La factura no se pudo cancelar ante el SAT", TipoMensaje.MsgError)
Alert("Los servicios de cancelación del SAT no se encuentran disponibles o presentan time out. Intente de nuevo en unos minutos.<br/>Origen del error: WebService www.sat.gob.mx", TipoMensaje.MsgError)
Exit Sub
End If
Else
@@ -19379,6 +19429,8 @@ Partial Class Ventas
Dim resp As Modelos.Factura.MCancelacionVentaMensaje = Nothing
If ObjFacturaCancelacion IsNot Nothing AndAlso ObjFacturaCancelacion.CveVenta > 0 Then
Dim SWatch As New Stopwatch
SWatch.Start()
If EsRefacturacion Then
resp = ObjFacturaCancelacion.CancelarPorRefacturacion()
@@ -19397,16 +19449,25 @@ Partial Class Ventas
resp = ObjFacturaCancelacion.CancelarFactura(ChkDevAlm.Checked, ListaRemisionesCancelar)
End If
SWatch.Stop()
Dim SegundosRespuesta As Double = SWatch.ElapsedMilliseconds / 1000
SegundosRespuesta = SegundosRespuesta.ToEntero
If SegundosRespuesta >= 5 Then
Alert($"Los servicios de cancelación del SAT presentan lentitud en la respuesta [{ SegundosRespuesta } s].", TipoMensaje.ToastAdventencia, "")
End If
If resp.CveEstatus = 5 AndAlso Not EsRefacturacion Then
Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:="BtnEnviarMailCancelacion();", TextoConfirmacion:="&nbsp;&nbsp;&nbsp;&nbsp;Si&nbsp;&nbsp;&nbsp;&nbsp;", TextoCancelacion:="&nbsp;&nbsp;&nbsp;&nbsp;<a onclick='Recargar()'>No</>&nbsp;&nbsp;&nbsp;&nbsp;")
Else
If EsRefacturacion Then
If resp.CveEstatus = 20 Then
ObjFacturaCancelacion.Dispose()
Response.Redirect($"/Ventas/RepCancelacionesPorRespuesta.aspx?CveVenta={CveVenta}")
Server.Transfer($"/Ventas/RepCancelacionesPorRespuesta.aspx?CveVenta={CveVenta}")
ElseIf resp.CveEstatus.Contiene(4, 5) Then
ObjFacturaCancelacion.Dispose()
Response.Redirect($"Ventas.aspx?CveDevolucion={CveVenta}&NuevaFactura=1")
Server.Transfer($"Ventas.aspx?CveDevolucion={CveVenta}&NuevaFactura=1")
Else
Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:="BtnRefrescarPagina();")
End If