Merge branch 'master' of http://192.168.10.111:8383/SIG
This commit is contained in:
@@ -9043,286 +9043,286 @@ Partial Class Ventas
|
|||||||
|
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Dim DirectoriArchivoXML As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto) ' System.IO.Path.Combine()
|
Dim DirectoriArchivoXML As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto) ' System.IO.Path.Combine()
|
||||||
If Not Directory.Exists(DirectoriArchivoXML) Then
|
If Not Directory.Exists(DirectoriArchivoXML) Then
|
||||||
Directory.CreateDirectory(DirectoriArchivoXML)
|
Directory.CreateDirectory(DirectoriArchivoXML)
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
|
|
||||||
Dim SeTimbro As Boolean = False
|
Dim SeTimbro As Boolean = False
|
||||||
Dim SeTimbroNC As Boolean = False
|
Dim SeTimbroNC As Boolean = False
|
||||||
Dim EstatusSMS = 0
|
Dim EstatusSMS = 0
|
||||||
|
|
||||||
Dim MsgCancelacionRefacturacion As Modelos.Factura.MCancelacionVentaMensaje = Nothing
|
Dim MsgCancelacionRefacturacion As Modelos.Factura.MCancelacionVentaMensaje = Nothing
|
||||||
|
|
||||||
'TIMBRADO Y CASO ESPECIAL NOTA DE CREDITO
|
'TIMBRADO Y CASO ESPECIAL NOTA DE CREDITO
|
||||||
If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "RNC", "Cot", "Ped", "DPe", "PA", "Pd2")) Then
|
If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "RNC", "Cot", "Ped", "DPe", "PA", "Pd2")) Then
|
||||||
|
|
||||||
Dim DebeTimbrar As Boolean = True
|
Dim DebeTimbrar As Boolean = True
|
||||||
If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then
|
If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then
|
||||||
'si tiene anticipos seleccionados y el total es cero, que no se timbre(previo empresa72)
|
'si tiene anticipos seleccionados y el total es cero, que no se timbre(previo empresa72)
|
||||||
If LblAmortizacion.Text.ToDouble > 0 And TxtTotal.Text.ToDouble <= 0 Then
|
If LblAmortizacion.Text.ToDouble > 0 And TxtTotal.Text.ToDouble <= 0 Then
|
||||||
DebeTimbrar = False
|
DebeTimbrar = False
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'Si es AMORTIZACIÓN ANTICIPO SOBRE FACTURA EN CERO no debe timbrar
|
'Si es AMORTIZACIÓN ANTICIPO SOBRE FACTURA EN CERO no debe timbrar
|
||||||
If DdlTipoAmortizacionAnticipo.SelectedValue = "3" Then
|
If DdlTipoAmortizacionAnticipo.SelectedValue = "3" Then
|
||||||
DebeTimbrar = False
|
DebeTimbrar = False
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If UsuarioActual.TienePermisoProceso(335) Then
|
If UsuarioActual.TienePermisoProceso(335) Then
|
||||||
DebeTimbrar = False
|
DebeTimbrar = False
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If DebeTimbrar AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then
|
If DebeTimbrar AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then
|
||||||
If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso (UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1) Then
|
If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso (UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1) Then
|
||||||
|
|
||||||
'FACTURA INGRESO/EGRESO
|
'FACTURA INGRESO/EGRESO
|
||||||
Dim FM As New Modelos.FemsaFactura
|
Dim FM As New Modelos.FemsaFactura
|
||||||
Dim TmpDT7Eleven As New DataTable
|
Dim TmpDT7Eleven As New DataTable
|
||||||
Dim TmpDTComplementosTimbrado As New DataTable
|
Dim TmpDTComplementosTimbrado As New DataTable
|
||||||
|
|
||||||
If AplicaFEMSA Then
|
If AplicaFEMSA Then
|
||||||
PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado)
|
PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim ObjTimbrado As New Timbrado
|
Dim ObjTimbrado As New Timbrado
|
||||||
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
|
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
|
||||||
Dim FolioFiscalFactura As String = ObjTimbrado.UUID
|
Dim FolioFiscalFactura As String = ObjTimbrado.UUID
|
||||||
Dim MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI
|
Dim MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI
|
||||||
ObjTimbrado = Nothing
|
ObjTimbrado = Nothing
|
||||||
|
|
||||||
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
|
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
|
||||||
If DebeTimbrar AndAlso ListaNotasCreditoGeneradas.Count > 0 Then
|
If DebeTimbrar AndAlso ListaNotasCreditoGeneradas.Count > 0 Then
|
||||||
Try
|
Try
|
||||||
For Each NCGenerada In ListaNotasCreditoGeneradas
|
For Each NCGenerada In ListaNotasCreditoGeneradas
|
||||||
If NCGenerada.Timbre IsNot Nothing Then
|
If NCGenerada.Timbre IsNot Nothing Then
|
||||||
NCGenerada.Timbre.CFDIRelacionados.UUID.Clear()
|
NCGenerada.Timbre.CFDIRelacionados.UUID.Clear()
|
||||||
NCGenerada.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura)
|
NCGenerada.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura)
|
||||||
|
|
||||||
Dim ObjTimbradoNC As New Timbrado
|
Dim ObjTimbradoNC As New Timbrado
|
||||||
Dim TimbroNC = ObjTimbradoNC.TimbrarFactura(UsuarioActual, NCGenerada)
|
Dim TimbroNC = ObjTimbradoNC.TimbrarFactura(UsuarioActual, NCGenerada)
|
||||||
|
|
||||||
If Not TimbroNC Then
|
If Not TimbroNC Then
|
||||||
Alert(ObjTimbradoNC.MensajeErrorCFDI, TipoMensaje.MsgError)
|
Alert(ObjTimbradoNC.MensajeErrorCFDI, TipoMensaje.MsgError)
|
||||||
End If
|
|
||||||
ObjTimbradoNC = Nothing
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
Catch ex As Exception
|
|
||||||
OnError("Ocurrió un error al timbrar la NC.", ex)
|
|
||||||
End Try
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
If SeTimbro AndAlso ObjFactura.TipoDocto.Contiene("Ing") Then
|
|
||||||
EstatusSMS = EnviarSMSTimbrado(ObjEventos)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not SeTimbro Then
|
|
||||||
Alert(MsgErrorTimbrado, TipoMensaje.MsgError)
|
|
||||||
End If
|
|
||||||
|
|
||||||
'CANCELAR FACTURA ANTERIOR
|
|
||||||
If SeTimbro AndAlso (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then
|
|
||||||
If Me.ObjFacturaNC IsNot Nothing Then
|
|
||||||
Me.ObjFacturaNC.CveEstatusRefacturacion = 2 'MARCAR COMO REFACTURADA
|
|
||||||
MsgCancelacionRefacturacion = Me.ObjFacturaNC.CancelarPorRefacturacion(Me.ObjFacturaNC.CveMotivoCancelacion, Me.ObjFacturaNC.MotivoCancelacion, FolioFiscalFactura)
|
|
||||||
End If
|
End If
|
||||||
|
ObjTimbradoNC = Nothing
|
||||||
End If
|
End If
|
||||||
End If
|
Next
|
||||||
End If
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al timbrar la NC.", ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'VERIFICAR 100% AVANCE A IMPORTE Y CANTIDAD
|
If SeTimbro AndAlso ObjFactura.TipoDocto.Contiene("Ing") Then
|
||||||
If ObjFactura.TipoDocto.Contiene("Ing", "Ant") AndAlso CveContrato > 0 Then
|
EstatusSMS = EnviarSMSTimbrado(ObjEventos)
|
||||||
If ObjContr.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then
|
End If
|
||||||
|
|
||||||
If ObjContr.DtResultados.Rows.Count > 0 Then
|
If Not SeTimbro Then
|
||||||
|
Alert(MsgErrorTimbrado, TipoMensaje.MsgError)
|
||||||
|
End If
|
||||||
|
|
||||||
|
'CANCELAR FACTURA ANTERIOR
|
||||||
'SI ES FLEXIBLE QUE NOTIFIQUE EL MONTO MAXIMO, SI NO LO ES QUE NOTIFIQUE EL PORCENTAJE ALCANZADO... FLEXIBLE = 2, NO FLEXIBLE = 1
|
If SeTimbro AndAlso (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then
|
||||||
If ObjContr.DtResultados.Rows(0)("ModalidadDetalle").ToString() = "1" Then
|
If Me.ObjFacturaNC IsNot Nothing Then
|
||||||
Dim PorcentajeAvance As Double = ObjContr.DtResultados.Rows(0)("ContratoAvance").ToString().ToDouble
|
Me.ObjFacturaNC.CveEstatusRefacturacion = 2 'MARCAR COMO REFACTURADA
|
||||||
|
MsgCancelacionRefacturacion = Me.ObjFacturaNC.CancelarPorRefacturacion(Me.ObjFacturaNC.CveMotivoCancelacion, Me.ObjFacturaNC.MotivoCancelacion, FolioFiscalFactura)
|
||||||
If PorcentajeAvance >= 100 Then
|
|
||||||
EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString())
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
Dim MontoMaximo As Double = ObjContr.DtResultados.Rows(0)("ImporteMax").ToString().ToDouble
|
|
||||||
Dim Avance As Double = ObjContr.DtResultados.Rows(0)("Avance").ToString().ToDouble
|
|
||||||
|
|
||||||
Dim PorcentajeAvance As Double = (Avance / MontoMaximo) * 100
|
|
||||||
|
|
||||||
If PorcentajeAvance >= 100 And MontoMaximo > 0 Then
|
|
||||||
EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString(), MontoMaximo)
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
'MENSAJE PRINCIPAL
|
End If
|
||||||
MensajeAlert.AppendFormat(String.Format("<br/>La {0}: <b>{1}</b> se generó correctamente.<br/><br/>", ObjFactura.TipoDocumento, ObjFactura.SerieFolio))
|
|
||||||
|
'VERIFICAR 100% AVANCE A IMPORTE Y CANTIDAD
|
||||||
|
If ObjFactura.TipoDocto.Contiene("Ing", "Ant") AndAlso CveContrato > 0 Then
|
||||||
|
If ObjContr.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then
|
||||||
|
|
||||||
|
If ObjContr.DtResultados.Rows.Count > 0 Then
|
||||||
|
|
||||||
|
|
||||||
' DESCARGA XML - SI SE TIMBRA MANDA CORREO CON FACTURA
|
'SI ES FLEXIBLE QUE NOTIFIQUE EL MONTO MAXIMO, SI NO LO ES QUE NOTIFIQUE EL PORCENTAJE ALCANZADO... FLEXIBLE = 2, NO FLEXIBLE = 1
|
||||||
If SeTimbro Then
|
If ObjContr.DtResultados.Rows(0)("ModalidadDetalle").ToString() = "1" Then
|
||||||
Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio)
|
Dim PorcentajeAvance As Double = ObjContr.DtResultados.Rows(0)("ContratoAvance").ToString().ToDouble
|
||||||
If File.Exists(ArchivoXML) Then
|
|
||||||
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar XML</a></li></ul>", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", ObjFactura.SerieFolio, ObjFactura.TipoDocto)))
|
If PorcentajeAvance >= 100 Then
|
||||||
|
EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString())
|
||||||
End If
|
End If
|
||||||
GeneraPDFFactura(ChkEnviarFactura.Checked) 'MANDA CORREO
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
'DESCARGA PDF
|
|
||||||
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant", "Egs", "Dev", "Pd2") Then
|
|
||||||
'If Not ImprimeAlert Then
|
|
||||||
|
|
||||||
Dim ArchivoIngPyMe As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.mrt", UsuarioActual.Empresa.Ruta))
|
|
||||||
Dim ArchivoIng As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.rdlc", UsuarioActual.Empresa.Ruta))
|
|
||||||
Dim ArchivoRem As New System.IO.FileInfo(String.Format("{0}Formatos/Remision.rdlc", UsuarioActual.Empresa.Ruta))
|
|
||||||
Dim ArchivoEgs As New System.IO.FileInfo(String.Format("{0}Formatos/NotaCredito.rdlc", UsuarioActual.Empresa.Ruta))
|
|
||||||
|
|
||||||
If ArchivoIng.Exists Or ArchivoRem.Exists Or ArchivoIngPyMe.Exists Or ArchivoEgs.Exists Then
|
|
||||||
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul><br/>", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta)))
|
|
||||||
Else
|
|
||||||
MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ")
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'ERROR DE NO TIMBRADO
|
|
||||||
If Not SeTimbro And (DdlTipoComprobante.SelectedValue = "Ing" Or DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev") Or DdlTipoComprobante.SelectedValue = "Ant") Then
|
|
||||||
MensajeAlert.AppendFormat("La factura no se pudo timbrar.</b> Por favor intentelo de nuevo a traves del boton Emitir.")
|
|
||||||
End If
|
|
||||||
|
|
||||||
'ERROR DE NO TIMBRADO NC
|
|
||||||
If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 AndAlso Not SeTimbroNC Then
|
|
||||||
MensajeAlert.AppendFormat("<br/>La NC <b>#{0}</b> no se pudo timbrar.</b> Por favor intentelo de nuevo a traves del boton Emitir.", CType(ObjNC(0), Modelos.Factura).SerieFolio)
|
|
||||||
End If
|
|
||||||
|
|
||||||
'NOTIFICACION DE SMS
|
|
||||||
Select Case EstatusSMS
|
|
||||||
Case 1
|
|
||||||
MensajeAlert.AppendFormat("<br/><b>Notificación SMS:</b> enviado con éxito al cliente al celular: <b>{0}</b>", ObjFactura.Cliente.CobranzaTelefono)
|
|
||||||
Case 2
|
|
||||||
MensajeAlert.AppendFormat("<br/><b>Notificación SMS:</b> sin enviar. Ocurrió un error en el envío, por favor verifique la información del cliente.")
|
|
||||||
Case 3
|
|
||||||
MensajeAlert.AppendFormat("<br/><b>Notificación SMS:</b> sin enviar. No se pudo cargar el celular del cliente, por favor verifique la información del cliente.")
|
|
||||||
End Select
|
|
||||||
|
|
||||||
|
|
||||||
'AUTO DESCARGAR PDF
|
|
||||||
If UsuarioActual.CveEmpresa.Contiene(72, 1) Then
|
|
||||||
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then
|
|
||||||
RegistraScript($"window.location.href = '/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))}'", "Imprimir")
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'DESCARGAR PDF DE CICOVISA
|
|
||||||
'If UsuarioActual.CveEmpresa = 72 And CveCliente = 70381 Then
|
|
||||||
' If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") Then
|
|
||||||
' MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar Formato CICOVISA</a></li></ul><br/>", Encripta(String.Format("OP=CIC&CVEVENTA={0}", CveVenta)))
|
|
||||||
' End If
|
|
||||||
'End If
|
|
||||||
|
|
||||||
If DdlTipoComprobante.SelectedValue = "Cot" Then
|
|
||||||
If Not CveEmpresaCRM > 0 Then
|
|
||||||
If CveVenta > 0 Then MensajeAlert = New StringBuilder
|
|
||||||
Dim ArchivoCotizacion As New System.IO.FileInfo(String.Format("{0}Formatos/Cotizacion.rdlc", UsuarioActual.Empresa.Ruta))
|
|
||||||
|
|
||||||
If Opcion = "Cot" And UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
|
|
||||||
MensajeAlert.AppendFormat("<b><a class='Texto' href=""Ventas.aspx?CveVenta={0}"">Facturar</a></b><br/><br/>", CveVenta)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If ArchivoCotizacion.Exists Then
|
|
||||||
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul><br/>", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=0", CveVenta)))
|
|
||||||
Else
|
|
||||||
MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ")
|
|
||||||
End If
|
|
||||||
|
|
||||||
GeneraPDFCotizacion(ChkEnviarFactura.Checked) ' MANDA CORREO
|
|
||||||
End If
|
|
||||||
ElseIf DdlTipoComprobante.SelectedValue = "Rem" Then
|
|
||||||
If UsuarioActual.CveEmpresa.Contiene(81, 109) Then
|
|
||||||
EnviaPDFRemision(ChkEnviarFactura.Checked)
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'ENVIA CORREO CON DETALLE DEL CONTRATO
|
|
||||||
If DdlTipoComprobante.SelectedValue.Contiene("DPe", "Ped") Then
|
|
||||||
If Not String.IsNullOrEmpty(CorreoNotificacionPedDev) Then
|
|
||||||
EnviarCorreoDevPed()
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'MOVIMIENTO DE ALMACEN
|
|
||||||
If ObjFactura.Inv_CveMovimiento > 0 Then
|
|
||||||
MensajeAlert.AppendFormat("<br/><br/><b><a target='_blank' class='Texto' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"">Movimiento de Almacén</a></b><br/>", ObjFactura.Inv_CveMovimiento)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If TieneAnticipo AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
|
|
||||||
MensajeAlert.AppendFormat("<br/><br/><b> Se generó una Nota de crédito Folio: {0} amortizando el anticipo </b><br/>", ObjFacturaDevolucion.Folio)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If RBLPago.SelectedValue.ToEntero() = 2 And TxtCambio.Text.ToDecimal > 0 Then
|
|
||||||
MensajeAlert.AppendFormat("<br/><br/>Su cambio es de <b>${0}</b><br/>", TxtCambio.Text.ToDecimal.FormatoNumero(2))
|
|
||||||
End If
|
|
||||||
|
|
||||||
If CveVentaNCProntoPago > 0 Then
|
|
||||||
MensajeAlert.AppendFormat(String.Format("<br/>La nota de crédito <b>{0}</b> por descuento pronto pago se generó correctamente.<br/><br/>", SerieFolioNCProntoPago))
|
|
||||||
End If
|
|
||||||
|
|
||||||
If MsgCancelacionRefacturacion IsNot Nothing Then
|
|
||||||
If Not MsgCancelacionRefacturacion.HuboError Then
|
|
||||||
If MsgCancelacionRefacturacion.CveEstatus = 5 Then
|
|
||||||
MensajeAlert.AppendFormat("<br/>El folio <b>{0}</b> fue cancelado. <b><a target='_blank' class='Texto' href=""/Compras/PopUpVerFactura.aspx?P={1}"">Descargar Acuse</a></b>", Me.ObjFacturaNC.SerieFolio, Encripta(String.Format("OP=CAN&CVEVTA={0}", Me.ObjFacturaNC.CveVenta)))
|
|
||||||
ElseIf MsgCancelacionRefacturacion.CveEstatus = 20 Then
|
|
||||||
MensajeAlert.AppendFormat("<br/>El folio <b>{0}</b> esta en proceso de cancelación. <b><a target='_blank' class='Texto' href=""/Compras/PopUpVerFactura.aspx?P={1}"">Descargar Acuse</a></b>", Me.ObjFacturaNC.SerieFolio, Encripta(String.Format("OP=CAN&CVEVTA={0}", Me.ObjFacturaNC.CveVenta)))
|
|
||||||
End If
|
|
||||||
MensajeAlert.AppendFormat(" <a target='_self' class='Texto' href=""javascript:BtnEnviarMailCancelacion({0});"">Enviar Acuse</a>.<br/><br/>", Me.ObjFacturaNC.CveVenta)
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'MUESTA ALERT OK
|
|
||||||
' si es elrol 1165-Ventas,EMp:80, o la empresa 119, recarga ventas, para seguir registrando-.
|
|
||||||
'Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";"))
|
|
||||||
'Alert(MensajeAlert.ToString(), TipoMensaje.MsgInformacion, Liga)
|
|
||||||
|
|
||||||
Dim Liga As String = ""
|
|
||||||
Dim Liga2 As String = ""
|
|
||||||
|
|
||||||
If Request("CveCliente") IsNot Nothing AndAlso Request("CveCliente").ToEntero > 0 Then
|
|
||||||
Liga = $"document.location.href=""/Ventas/Ventas.aspx?CveCliente={Request("CveCliente")}"";"
|
|
||||||
Else
|
Else
|
||||||
Liga = "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";"
|
Dim MontoMaximo As Double = ObjContr.DtResultados.Rows(0)("ImporteMax").ToString().ToDouble
|
||||||
|
Dim Avance As Double = ObjContr.DtResultados.Rows(0)("Avance").ToString().ToDouble
|
||||||
|
|
||||||
|
Dim PorcentajeAvance As Double = (Avance / MontoMaximo) * 100
|
||||||
|
|
||||||
|
If PorcentajeAvance >= 100 And MontoMaximo > 0 Then
|
||||||
|
EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString(), MontoMaximo)
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If CveEmpresaCRM > 0 Then
|
End If
|
||||||
Liga2 = $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";"
|
End If
|
||||||
Else
|
End If
|
||||||
Liga2 = $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}"";"
|
|
||||||
End If
|
|
||||||
|
|
||||||
Alert(MensajeAlert.ToString(), TipoMensaje.MsgDosBotones, Liga, TextoConfirmacion:="Seguir Registrando", TextoSegundoBoton:="Ir al Cliente", JSBtn2:=Liga2, ShowCloseButton:=False)
|
'MENSAJE PRINCIPAL
|
||||||
|
MensajeAlert.AppendFormat(String.Format("<br/>La {0}: <b>{1}</b> se generó correctamente.<br/><br/>", ObjFactura.TipoDocumento, ObjFactura.SerieFolio))
|
||||||
|
|
||||||
MensajeAlert.Clear()
|
|
||||||
|
|
||||||
'LIMPIA CONDICIONES DE PAGO - CONTADO
|
' DESCARGA XML - SI SE TIMBRA MANDA CORREO CON FACTURA
|
||||||
RBLPago.SelectedValue = "1"
|
If SeTimbro Then
|
||||||
LimpiaEscondeContado()
|
Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio)
|
||||||
BtnEmitirImprimir.Visible = False
|
If File.Exists(ArchivoXML) Then
|
||||||
ObjFactura = Nothing
|
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar XML</a></li></ul>", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", ObjFactura.SerieFolio, ObjFactura.TipoDocto)))
|
||||||
|
End If
|
||||||
|
GeneraPDFFactura(ChkEnviarFactura.Checked) 'MANDA CORREO
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
'DESCARGA PDF
|
||||||
|
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant", "Egs", "Dev", "Pd2") Then
|
||||||
|
'If Not ImprimeAlert Then
|
||||||
|
|
||||||
|
Dim ArchivoIngPyMe As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.mrt", UsuarioActual.Empresa.Ruta))
|
||||||
|
Dim ArchivoIng As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.rdlc", UsuarioActual.Empresa.Ruta))
|
||||||
|
Dim ArchivoRem As New System.IO.FileInfo(String.Format("{0}Formatos/Remision.rdlc", UsuarioActual.Empresa.Ruta))
|
||||||
|
Dim ArchivoEgs As New System.IO.FileInfo(String.Format("{0}Formatos/NotaCredito.rdlc", UsuarioActual.Empresa.Ruta))
|
||||||
|
|
||||||
|
If ArchivoIng.Exists Or ArchivoRem.Exists Or ArchivoIngPyMe.Exists Or ArchivoEgs.Exists Then
|
||||||
|
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul><br/>", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta)))
|
||||||
|
Else
|
||||||
|
MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ")
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
'ERROR DE NO TIMBRADO
|
||||||
|
If Not SeTimbro And (DdlTipoComprobante.SelectedValue = "Ing" Or DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev") Or DdlTipoComprobante.SelectedValue = "Ant") Then
|
||||||
|
MensajeAlert.AppendFormat("La factura no se pudo timbrar.</b> Por favor intentelo de nuevo a traves del boton Emitir.")
|
||||||
|
End If
|
||||||
|
|
||||||
|
'ERROR DE NO TIMBRADO NC
|
||||||
|
If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 AndAlso Not SeTimbroNC Then
|
||||||
|
MensajeAlert.AppendFormat("<br/>La NC <b>#{0}</b> no se pudo timbrar.</b> Por favor intentelo de nuevo a traves del boton Emitir.", CType(ObjNC(0), Modelos.Factura).SerieFolio)
|
||||||
|
End If
|
||||||
|
|
||||||
|
'NOTIFICACION DE SMS
|
||||||
|
Select Case EstatusSMS
|
||||||
|
Case 1
|
||||||
|
MensajeAlert.AppendFormat("<br/><b>Notificación SMS:</b> enviado con éxito al cliente al celular: <b>{0}</b>", ObjFactura.Cliente.CobranzaTelefono)
|
||||||
|
Case 2
|
||||||
|
MensajeAlert.AppendFormat("<br/><b>Notificación SMS:</b> sin enviar. Ocurrió un error en el envío, por favor verifique la información del cliente.")
|
||||||
|
Case 3
|
||||||
|
MensajeAlert.AppendFormat("<br/><b>Notificación SMS:</b> sin enviar. No se pudo cargar el celular del cliente, por favor verifique la información del cliente.")
|
||||||
|
End Select
|
||||||
|
|
||||||
|
|
||||||
|
'AUTO DESCARGAR PDF
|
||||||
|
If UsuarioActual.CveEmpresa.Contiene(72, 1) Then
|
||||||
|
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then
|
||||||
|
RegistraScript($"window.location.href = '/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))}'", "Imprimir")
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
'DESCARGAR PDF DE CICOVISA
|
||||||
|
'If UsuarioActual.CveEmpresa = 72 And CveCliente = 70381 Then
|
||||||
|
' If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") Then
|
||||||
|
' MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar Formato CICOVISA</a></li></ul><br/>", Encripta(String.Format("OP=CIC&CVEVENTA={0}", CveVenta)))
|
||||||
|
' End If
|
||||||
|
'End If
|
||||||
|
|
||||||
|
If DdlTipoComprobante.SelectedValue = "Cot" Then
|
||||||
|
If Not CveEmpresaCRM > 0 Then
|
||||||
|
If CveVenta > 0 Then MensajeAlert = New StringBuilder
|
||||||
|
Dim ArchivoCotizacion As New System.IO.FileInfo(String.Format("{0}Formatos/Cotizacion.rdlc", UsuarioActual.Empresa.Ruta))
|
||||||
|
|
||||||
|
If Opcion = "Cot" And UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
|
||||||
|
MensajeAlert.AppendFormat("<b><a class='Texto' href=""Ventas.aspx?CveVenta={0}"">Facturar</a></b><br/><br/>", CveVenta)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If ArchivoCotizacion.Exists Then
|
||||||
|
MensajeAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF</a></li></ul><br/>", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=0", CveVenta)))
|
||||||
Else
|
Else
|
||||||
ObjVentas.RollBack()
|
MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ")
|
||||||
|
End If
|
||||||
|
|
||||||
|
GeneraPDFCotizacion(ChkEnviarFactura.Checked) ' MANDA CORREO
|
||||||
|
End If
|
||||||
|
ElseIf DdlTipoComprobante.SelectedValue = "Rem" Then
|
||||||
|
If UsuarioActual.CveEmpresa.Contiene(81, 109) Then
|
||||||
|
EnviaPDFRemision(ChkEnviarFactura.Checked)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
'ENVIA CORREO CON DETALLE DEL CONTRATO
|
||||||
|
If DdlTipoComprobante.SelectedValue.Contiene("DPe", "Ped") Then
|
||||||
|
If Not String.IsNullOrEmpty(CorreoNotificacionPedDev) Then
|
||||||
|
EnviarCorreoDevPed()
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
'MOVIMIENTO DE ALMACEN
|
||||||
|
If ObjFactura.Inv_CveMovimiento > 0 Then
|
||||||
|
MensajeAlert.AppendFormat("<br/><br/><b><a target='_blank' class='Texto' href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"">Movimiento de Almacén</a></b><br/>", ObjFactura.Inv_CveMovimiento)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If TieneAnticipo AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
|
||||||
|
MensajeAlert.AppendFormat("<br/><br/><b> Se generó una Nota de crédito Folio: {0} amortizando el anticipo </b><br/>", ObjFacturaDevolucion.Folio)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If RBLPago.SelectedValue.ToEntero() = 2 And TxtCambio.Text.ToDecimal > 0 Then
|
||||||
|
MensajeAlert.AppendFormat("<br/><br/>Su cambio es de <b>${0}</b><br/>", TxtCambio.Text.ToDecimal.FormatoNumero(2))
|
||||||
|
End If
|
||||||
|
|
||||||
|
If CveVentaNCProntoPago > 0 Then
|
||||||
|
MensajeAlert.AppendFormat(String.Format("<br/>La nota de crédito <b>{0}</b> por descuento pronto pago se generó correctamente.<br/><br/>", SerieFolioNCProntoPago))
|
||||||
|
End If
|
||||||
|
|
||||||
|
If MsgCancelacionRefacturacion IsNot Nothing Then
|
||||||
|
If Not MsgCancelacionRefacturacion.HuboError Then
|
||||||
|
If MsgCancelacionRefacturacion.CveEstatus = 5 Then
|
||||||
|
MensajeAlert.AppendFormat("<br/>El folio <b>{0}</b> fue cancelado. <b><a target='_blank' class='Texto' href=""/Compras/PopUpVerFactura.aspx?P={1}"">Descargar Acuse</a></b>", Me.ObjFacturaNC.SerieFolio, Encripta(String.Format("OP=CAN&CVEVTA={0}", Me.ObjFacturaNC.CveVenta)))
|
||||||
|
ElseIf MsgCancelacionRefacturacion.CveEstatus = 20 Then
|
||||||
|
MensajeAlert.AppendFormat("<br/>El folio <b>{0}</b> esta en proceso de cancelación. <b><a target='_blank' class='Texto' href=""/Compras/PopUpVerFactura.aspx?P={1}"">Descargar Acuse</a></b>", Me.ObjFacturaNC.SerieFolio, Encripta(String.Format("OP=CAN&CVEVTA={0}", Me.ObjFacturaNC.CveVenta)))
|
||||||
|
End If
|
||||||
|
MensajeAlert.AppendFormat(" <a target='_self' class='Texto' href=""javascript:BtnEnviarMailCancelacion({0});"">Enviar Acuse</a>.<br/><br/>", Me.ObjFacturaNC.CveVenta)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
'MUESTA ALERT OK
|
||||||
|
' si es elrol 1165-Ventas,EMp:80, o la empresa 119, recarga ventas, para seguir registrando-.
|
||||||
|
'Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";"))
|
||||||
|
'Alert(MensajeAlert.ToString(), TipoMensaje.MsgInformacion, Liga)
|
||||||
|
|
||||||
|
Dim Liga As String = ""
|
||||||
|
Dim Liga2 As String = ""
|
||||||
|
|
||||||
|
If Request("CveCliente") IsNot Nothing AndAlso Request("CveCliente").ToEntero > 0 Then
|
||||||
|
Liga = $"document.location.href=""/Ventas/Ventas.aspx?CveCliente={Request("CveCliente")}"";"
|
||||||
|
Else
|
||||||
|
Liga = "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";"
|
||||||
|
End If
|
||||||
|
|
||||||
|
If CveEmpresaCRM > 0 Then
|
||||||
|
Liga2 = $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";"
|
||||||
|
Else
|
||||||
|
Liga2 = $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}"";"
|
||||||
|
End If
|
||||||
|
|
||||||
|
Alert(MensajeAlert.ToString(), TipoMensaje.MsgDosBotones, Liga, TextoConfirmacion:="Seguir Registrando", TextoSegundoBoton:="Ir al Cliente", JSBtn2:=Liga2, ShowCloseButton:=False)
|
||||||
|
|
||||||
|
MensajeAlert.Clear()
|
||||||
|
|
||||||
|
'LIMPIA CONDICIONES DE PAGO - CONTADO
|
||||||
|
RBLPago.SelectedValue = "1"
|
||||||
|
LimpiaEscondeContado()
|
||||||
|
BtnEmitirImprimir.Visible = False
|
||||||
|
ObjFactura = Nothing
|
||||||
|
|
||||||
|
Else
|
||||||
|
ObjVentas.RollBack()
|
||||||
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
||||||
|
|
||||||
For Each ErrorItem In ErrorList
|
For Each ErrorItem In ErrorList
|
||||||
|
|||||||
Reference in New Issue
Block a user