Notificaciones en envio de estados de cuenta
This commit is contained in:
@@ -20,6 +20,8 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
Dim retorno As String = "no se encontro la variable"
|
||||
Try
|
||||
Dim metodo As String = ""
|
||||
Dim FechaActual As DateTime = Now
|
||||
Dim FechaEnvio As DateTime = FechaActual
|
||||
|
||||
If context.Request("var") IsNot Nothing Then
|
||||
URLParametros = Parametros(context.Request("var"))
|
||||
@@ -36,6 +38,9 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
End Using
|
||||
ElseIf context.Request("metodo") IsNot Nothing Then
|
||||
metodo = context.Request("metodo").ToString()
|
||||
If context.Request("FechaEnvio") IsNot Nothing Then
|
||||
FechaEnvio = context.Request("FechaEnvio").ToString().ToDateTime()
|
||||
End If
|
||||
End If
|
||||
|
||||
Select Case metodo
|
||||
@@ -46,7 +51,7 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
context.Response.Write(retorno)
|
||||
Case "EstadosCuenta"
|
||||
'CargaEstadosCuenta(context, 119, 227774)
|
||||
CargaEstadosCuenta(context, 119, -1)
|
||||
CargaEstadosCuenta(context, 119, -1, FechaEnvio, FechaActual)
|
||||
End Select
|
||||
Catch ex As Exception
|
||||
ex.GuardaLog(ex.ToString())
|
||||
@@ -270,7 +275,7 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
|
||||
|
||||
#Region "E S T A D O S D E C U E N T A"
|
||||
Private Sub CargaEstadosCuenta(ByVal context As HttpContext, pCveEmpresa As Integer, pCveCliente As Integer)
|
||||
Private Sub CargaEstadosCuenta(ByVal context As HttpContext, pCveEmpresa As Integer, pCveCliente As Integer, FechaEnvio As DateTime, FechaActual As DateTime)
|
||||
Dim Retorno As New JArray()
|
||||
Dim DtEmpresas As DataTable = Nothing
|
||||
Using ObjEmpresas As New ClsSisEmpresas()
|
||||
@@ -282,7 +287,7 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
If DtEmpresas IsNot Nothing Then
|
||||
For Each Row As DataRow In DtEmpresas.Rows
|
||||
Dim Usuario = ValidaUsuarioSistema(Row("CveEmpresa").ToString().ToEntero())
|
||||
Dim obj = EjecutarEnvioEstadoCuenta(Usuario, pCveCliente:=pCveCliente)
|
||||
Dim obj = EjecutarEnvioEstadoCuenta(Usuario, FechaEnvio, FechaActual, pCveCliente:=pCveCliente)
|
||||
|
||||
Retorno.Add(obj)
|
||||
Next
|
||||
@@ -331,7 +336,7 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
End Sub
|
||||
|
||||
|
||||
Private Function EjecutarEnvioEstadoCuenta(UsuarioActual As Usuario, Optional pCveCliente As Integer = -1) As JObject
|
||||
Private Function EjecutarEnvioEstadoCuenta(UsuarioActual As Usuario, FechaEnvio As DateTime, FechaActual As DateTime, Optional pCveCliente As Integer = -1) As JObject
|
||||
Dim ClientesSinEnviar As New JArray()
|
||||
Dim ClientesEdoEnviado As New JArray()
|
||||
|
||||
@@ -341,78 +346,133 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
New JProperty("Fecha", DateTime.Now.ToString("dd/MM/yyy HH:mm:ss"))
|
||||
)
|
||||
Dim DTClientes As DataTable = Nothing
|
||||
Dim EnviarPendientes As Boolean = False
|
||||
|
||||
'Using ObjCliente As New ClsClientes
|
||||
' If ObjCliente.GetClientes(pCveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, TipoCliente:=-1, Estatus:=1) Then
|
||||
' If ObjCliente.DtResultados.Rows.Count > 0 Then
|
||||
' DTClientes = ObjCliente.DtResultados.Copy()
|
||||
' End If
|
||||
' End If
|
||||
'End Using
|
||||
If FechaActual <> FechaEnvio Then
|
||||
EnviarPendientes = True
|
||||
End If
|
||||
|
||||
Using ObjMov As New ClsMovimientos
|
||||
Dim FechaI As String = "-1"
|
||||
Dim FechaF As String = "-1"
|
||||
Dim FechaVI As String = "-1"
|
||||
Dim FechaVF As String = "-1"
|
||||
Dim TCEspecifico = -1
|
||||
If Not EnviarPendientes Then
|
||||
Using ObjMov As New ClsMovimientos
|
||||
Dim FechaI As String = "-1"
|
||||
Dim FechaF As String = "-1"
|
||||
Dim FechaVI As String = "-1"
|
||||
Dim FechaVF As String = "-1"
|
||||
Dim TCEspecifico = -1
|
||||
|
||||
Dim CveCobranzaEstatus As Integer = -1
|
||||
Dim CveClienteClasificacion As Integer = -1
|
||||
Dim CveCliente As Integer = -1
|
||||
Dim AplicaAnticipos As Integer = 0
|
||||
Dim CveCobranzaEstatus As Integer = -1
|
||||
Dim CveClienteClasificacion As Integer = -1
|
||||
Dim CveCliente As Integer = -1
|
||||
Dim AplicaAnticipos As Integer = 0
|
||||
|
||||
Dim CveSubProyecto As Integer = -1
|
||||
Dim CveVendedor As Integer = -1
|
||||
Dim Grupo As Integer = 5
|
||||
Dim TipoCambio As Integer = 1
|
||||
Dim TipoDocto As String = "-1"
|
||||
Dim FechaCorte As DateTime = New DateTime(Now.Year, 12, 31)
|
||||
Dim CveSubProyecto As Integer = -1
|
||||
Dim CveVendedor As Integer = -1
|
||||
Dim Grupo As Integer = 5
|
||||
Dim TipoCambio As Integer = 1
|
||||
Dim TipoDocto As String = "-1"
|
||||
Dim FechaCorte As DateTime = New DateTime(Now.Year, 12, 31)
|
||||
|
||||
If ObjMov.GetCxC(FechaI, FechaF, CveCliente, CveSubProyecto, CveVendedor, -1, -1, "-1", UsuarioActual.CveEmpresa, Grupo, -1, TipoCambio, TCEspecifico, TipoDocto, FechaVI, FechaVF, FechaCorte:=FechaCorte,
|
||||
EstatusCliente:=1, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveCobranzaEstatus:=CveCobranzaEstatus, CveClienteClasificacion:=-1, TipoCliente:=-1, AplicaAnticiposPagados:=AplicaAnticipos) Then
|
||||
DTClientes = ObjMov.DtResultados.FiltraParametros("CveCliente > 0", DistinctColumns:={"CveCliente"})
|
||||
End If
|
||||
If ObjMov.GetCxC(FechaI, FechaF, CveCliente, CveSubProyecto, CveVendedor, -1, -1, "-1", UsuarioActual.CveEmpresa, Grupo, -1, TipoCambio, TCEspecifico, TipoDocto, FechaVI, FechaVF, FechaCorte:=FechaCorte,
|
||||
EstatusCliente:=1, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveCobranzaEstatus:=CveCobranzaEstatus, CveClienteClasificacion:=-1, TipoCliente:=-1, AplicaAnticiposPagados:=AplicaAnticipos) Then
|
||||
DTClientes = ObjMov.DtResultados.FiltraParametros("CveCliente > 0", DistinctColumns:={"CveCliente"})
|
||||
End If
|
||||
|
||||
End Using
|
||||
End Using
|
||||
End If
|
||||
|
||||
If DTClientes IsNot Nothing Then
|
||||
|
||||
If DTClientes IsNot Nothing OrElse EnviarPendientes Then
|
||||
|
||||
'DTClientes = DTClientes.FiltraParametros("CveCliente IN (227289,227429,227733,227838,228181,228544,229176,229481,230029,230432,230860,230911,230918,231197,231576,232173,232185,233055,233295,233357,233588,236379,236460,237161,237635,238285,238530,238622,238724,239033,239099,239865,239895,239903,240202,240235,240236,240238,240303,240340,262404,262517,264765,264806,264825,264848,264930,265063,265180,265213,265214,265236,265344,265492,265555,265669,265797,265952,265963,266156,266182,268346,268396,268488,268535,268539,268558,268562,268706,268726,268787,268868,268889,268910,268925,269023,269081,269089,272066,272070,272657,273080,273084,275627,276259,276587,281115,283110,284664,285392,287653,288711,291374,292444,295578,296375,296598,302728,303936,306897,307183,311007,320060,320685,320800,323520,323772,325237,326996,327801,330630,331741,332118,337105,340502,341796,342807,343858,355862,358123,365794,371524,375391,377122,377948,378267,380167,381210,381878,383098,383250,383339,383650,384472,385321,385585,386630,387114,388987,396341,396405,396541,401995,404175,408306,416386,416819,420275,438732,447566,447636,450284,464150,464376,468051,475172,475932,476984,477997,478426)")
|
||||
Dim DtNotificaciones As DataTable = Nothing
|
||||
|
||||
For Each RowCliente As DataRow In DTClientes.Rows
|
||||
|
||||
Dim CveCliente As Integer = RowCliente("CveCliente").ToString().ToEntero()
|
||||
Dim Cliente As New Modelos.ClienteModel(CveCliente, UsuarioActual.CveEmpresa)
|
||||
Dim TieneErrorRegistro As Boolean = False
|
||||
|
||||
If Cliente IsNot Nothing Then
|
||||
Dim Correo As String = Cliente.CobranzaCorreo '"japmx95@gmail.com" 'RowCliente("CobranzaCorreo").ToString()
|
||||
Dim ObjMovimientos As New ClsMovimientos
|
||||
ObjMovimientos.IniciaTransacSQL()
|
||||
|
||||
Dim Envio As Boolean = False
|
||||
If Not String.IsNullOrEmpty(Correo) Then
|
||||
Envio = EnviarEstadoCuenta(UsuarioActual, Correo, Cliente)
|
||||
End If
|
||||
If Not EnviarPendientes Then
|
||||
Try
|
||||
For Each RowCliente As DataRow In DTClientes.Rows
|
||||
If Not ObjMovimientos.AddNotificacionEdoCuentaCliente(RowCliente("CveCliente").ToString().ToEntero(), FechaEnvio) Then
|
||||
GuardaLog("Ocurrio un error al agregar las notificaciones de edo cuenta. CveCliente: " + RowCliente("CveCliente").ToString())
|
||||
TieneErrorRegistro = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Catch ex As Exception
|
||||
GuardaLog("Ocurrio un error al agregar las notificaciones de edo cuenta" + ex.ToString())
|
||||
TieneErrorRegistro = True
|
||||
End Try
|
||||
End If
|
||||
|
||||
If Envio Then
|
||||
|
||||
ClientesEdoEnviado.Add(New JObject(
|
||||
New JProperty("CveCliente", Cliente.CveCliente),
|
||||
New JProperty("Cliente", Cliente.Nombre)
|
||||
))
|
||||
|
||||
Using ObjBitacora As New ClsOIEventos
|
||||
ObjBitacora.AddEventoBitacora("Se envió correo con el estado de cuenta del cliente", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=Cliente.CveCliente)
|
||||
End Using
|
||||
Else
|
||||
ClientesSinEnviar.Add(New JObject(
|
||||
New JProperty("CveCliente", Cliente.CveCliente),
|
||||
New JProperty("Cliente", Cliente.Nombre)
|
||||
))
|
||||
End If
|
||||
If Not TieneErrorRegistro Then
|
||||
If ObjMovimientos.GetNotificacionEdoCuentaCliente(UsuarioActual.CveEmpresa, -1, FechaEnvio) Then
|
||||
DtNotificaciones = ObjMovimientos.DtResultados.Copy()
|
||||
Else
|
||||
TieneErrorRegistro = True
|
||||
End If
|
||||
|
||||
Next
|
||||
DTClientes.Dispose()
|
||||
End If
|
||||
|
||||
|
||||
If Not TieneErrorRegistro Then
|
||||
ObjMovimientos.Commit()
|
||||
Else
|
||||
ObjMovimientos.RollBack()
|
||||
If DtNotificaciones IsNot Nothing Then
|
||||
DtNotificaciones.Clear()
|
||||
DtNotificaciones = Nothing
|
||||
End If
|
||||
End If
|
||||
ObjMovimientos.Dispose()
|
||||
DTClientes.Dispose()
|
||||
|
||||
Try
|
||||
If DtNotificaciones IsNot Nothing Then
|
||||
For Each Row As DataRow In DtNotificaciones.Rows
|
||||
Dim CveCliente As Integer = Row("CveCliente").ToString().ToEntero()
|
||||
Dim Cliente As New Modelos.ClienteModel(CveCliente, UsuarioActual.CveEmpresa)
|
||||
|
||||
If Cliente IsNot Nothing Then
|
||||
Dim Correo As String = Cliente.CobranzaCorreo
|
||||
|
||||
Dim Envio As Boolean = False
|
||||
If Not String.IsNullOrEmpty(Correo) Then
|
||||
Envio = EnviarEstadoCuenta(UsuarioActual, Correo, Cliente)
|
||||
End If
|
||||
|
||||
If Envio Then
|
||||
|
||||
Using ObjMov As New ClsMovimientos
|
||||
ObjMov.UpdateNotificacionEdoCuentaCliente(Row("CveNotificacionBitacora").ToString().ToEntero(), Notifico:=True)
|
||||
End Using
|
||||
|
||||
ClientesEdoEnviado.Add(New JObject(
|
||||
New JProperty("CveCliente", Cliente.CveCliente),
|
||||
New JProperty("Cliente", Cliente.Nombre)
|
||||
))
|
||||
|
||||
Using ObjBitacora As New ClsOIEventos
|
||||
ObjBitacora.AddEventoBitacora("Se envió correo con el estado de cuenta del cliente", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=Cliente.CveCliente)
|
||||
End Using
|
||||
Else
|
||||
ClientesSinEnviar.Add(New JObject(
|
||||
New JProperty("CveCliente", Cliente.CveCliente),
|
||||
New JProperty("Cliente", Cliente.Nombre)
|
||||
))
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
GuardaLog("Ocurrio un error al agregar las notificaciones de edo cuenta. " + ex.ToString())
|
||||
End Try
|
||||
|
||||
If DtNotificaciones IsNot Nothing Then
|
||||
DtNotificaciones.Dispose()
|
||||
End If
|
||||
|
||||
End If
|
||||
Json.Add(New JProperty("ClientesSinEnviar", ClientesSinEnviar))
|
||||
Json.Add(New JProperty("ClientesEdoEnviado", ClientesEdoEnviado))
|
||||
@@ -422,244 +482,245 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
|
||||
Private Function EnviarEstadoCuenta(UsuarioActual As Usuario, Correo As String, Cliente As Modelos.ClienteModel) As Boolean
|
||||
Dim Retorno As Boolean = True
|
||||
|
||||
Dim ArchivoPDF As Byte() = Nothing
|
||||
|
||||
Dim Formato As String = "PDF"
|
||||
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/RepClientesCxC.rpt", UsuarioActual.Empresa.Ruta))
|
||||
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
||||
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, UsuarioActual.CveEmpresa)
|
||||
'OBTENEMOS LOS DATOS
|
||||
Dim DtCxCFact As DataTable = Nothing
|
||||
|
||||
Dim SaldoIngDolares As Double = 0
|
||||
Dim SaldoIngPesos As Double = 0
|
||||
Dim SaldoIngDolaresPesos As Double = 0
|
||||
Dim TotalIng As Double = 0
|
||||
Dim SaldoAntDolares As Double = 0
|
||||
Dim SaldoAntPesos As Double = 0
|
||||
Dim SaldoAntDolaresPesos As Double = 0
|
||||
Dim TotalAnt As Double = 0
|
||||
Dim ContaIng As Integer = 0
|
||||
Dim ContaAnt As Integer = 0
|
||||
Dim FechaCorte As Date = ("9999/01/01").ToDate
|
||||
|
||||
Dim TipoDocto2 As String = "'Ing','NC','Dev'"
|
||||
Dim FechaVencimientoI As String = "-1"
|
||||
Dim FechaVencimientoF As String = "-1"
|
||||
Dim FI As String = "-1"
|
||||
Dim FF As String = "-1"
|
||||
Dim dtt As DataTable = Nothing
|
||||
|
||||
Try
|
||||
Using ObjMovtos As New ClsMovimientos()
|
||||
If ObjMovtos.GetCxCClienteDetalle(Cliente.CveCliente, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, CveClienteSucursal:=-1) Then
|
||||
DtCxCFact = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'", "TipoDocto")
|
||||
'cargo los anticipos NC
|
||||
DtCxCFact.Columns.Add("SaldoAnticipo", GetType(Decimal))
|
||||
If ObjMovtos.GetAnticiposNCIxCCliente(Cliente.CveCliente, -1, -1) Then
|
||||
dtt = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0 AND SaldoVentaAnticipo = 0 AND ((Tipo = 'IxC' AND CveIE > 0) OR (Tipo = 'Ant' AND CveVenta > 0) OR (Tipo = 'NC' AND CveVenta > 0) OR (Tipo = 'Egs' AND CveVenta > 0) )")
|
||||
End If
|
||||
End If
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
Retorno = False
|
||||
dtt = Nothing
|
||||
OnError("Ocurrió un erro al obtener el CxC", ex)
|
||||
End Try
|
||||
Dim ArchivoPDF As Byte() = Nothing
|
||||
|
||||
If Not Retorno Then
|
||||
Return Retorno
|
||||
End If
|
||||
Dim Formato As String = "PDF"
|
||||
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/RepClientesCxC.rpt", UsuarioActual.Empresa.Ruta))
|
||||
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
||||
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, UsuarioActual.CveEmpresa)
|
||||
'OBTENEMOS LOS DATOS
|
||||
Dim DtCxCFact As DataTable = Nothing
|
||||
|
||||
Try
|
||||
If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then
|
||||
For Each drt As DataRow In dtt.Rows
|
||||
Dim drr As DataRow = DtCxCFact.NewRow
|
||||
drr("TipoDocto") = drt("Tipo")
|
||||
drr("SerieFolio") = drt("Folio")
|
||||
drr("Original") = drt("Original")
|
||||
drr("TipoCambio") = drt("TipoCambio")
|
||||
drr("Saldo") = 0
|
||||
drr("SaldoAnticipo") = drt("Saldo")
|
||||
drr("Fecha") = drt("Fecha")
|
||||
drr("Moneda") = drt("Moneda")
|
||||
drr("CveMoneda") = drt("CveMoneda")
|
||||
DtCxCFact.Rows.Add(drr)
|
||||
Next
|
||||
End If
|
||||
Dim SaldoIngDolares As Double = 0
|
||||
Dim SaldoIngPesos As Double = 0
|
||||
Dim SaldoIngDolaresPesos As Double = 0
|
||||
Dim TotalIng As Double = 0
|
||||
Dim SaldoAntDolares As Double = 0
|
||||
Dim SaldoAntPesos As Double = 0
|
||||
Dim SaldoAntDolaresPesos As Double = 0
|
||||
Dim TotalAnt As Double = 0
|
||||
Dim ContaIng As Integer = 0
|
||||
Dim ContaAnt As Integer = 0
|
||||
Dim FechaCorte As Date = ("9999/01/01").ToDate
|
||||
|
||||
If DtCxCFact IsNot Nothing Then
|
||||
For Each Row As DataRow In DtCxCFact.FiltraParametros($"TipoDocto IN ({TipoDocto2})").Rows
|
||||
If Row("TipoDocto").ToString = "Ing" Or Row("TipoDocto").ToString = "Rem" Or (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble > 0) Then 'Ingresos
|
||||
ContaIng = ContaIng + 1
|
||||
If Row("CveMoneda").ToString.ToEntero = 1 Then
|
||||
SaldoIngPesos = SaldoIngPesos + Row("Saldo").ToString.ToDouble
|
||||
ElseIf Row("CveMoneda").ToString.ToEntero = 2 Then
|
||||
SaldoIngDolares = SaldoIngDolares + Row("Saldo").ToString.ToDouble
|
||||
SaldoIngDolaresPesos = SaldoIngDolaresPesos + (Row("Saldo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble)
|
||||
End If
|
||||
Dim TipoDocto2 As String = "'Ing','NC','Dev'"
|
||||
Dim FechaVencimientoI As String = "-1"
|
||||
Dim FechaVencimientoF As String = "-1"
|
||||
Dim FI As String = "-1"
|
||||
Dim FF As String = "-1"
|
||||
Dim dtt As DataTable = Nothing
|
||||
|
||||
ElseIf (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble = 0) Or Row("TipoDocto").ToString = "IxC" Or Row("TipoDocto").ToString = "NC" Or Row("TipoDocto").ToString = "Dev" Then 'Anticipos, NC, IxC
|
||||
ContaAnt = ContaAnt + 1
|
||||
If Row("CveMoneda").ToString.ToEntero = 1 Then
|
||||
If Row("TipoDocto").ToString = "Dev" Then
|
||||
SaldoAntPesos = SaldoAntPesos + Row("Saldo").ToString.ToDouble
|
||||
Else
|
||||
SaldoAntPesos = SaldoAntPesos + Row("SaldoAnticipo").ToString.ToDouble
|
||||
End If
|
||||
ElseIf Row("CveMoneda").ToString.ToEntero = 2 Then
|
||||
SaldoAntDolares = SaldoAntDolares + Row("Saldo").ToString.ToDouble
|
||||
SaldoAntDolaresPesos = SaldoAntDolaresPesos + (Row("SaldoAnticipo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble)
|
||||
Try
|
||||
Using ObjMovtos As New ClsMovimientos()
|
||||
If ObjMovtos.GetCxCClienteDetalle(Cliente.CveCliente, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, CveClienteSucursal:=-1) Then
|
||||
DtCxCFact = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'", "TipoDocto")
|
||||
'cargo los anticipos NC
|
||||
DtCxCFact.Columns.Add("SaldoAnticipo", GetType(Decimal))
|
||||
If ObjMovtos.GetAnticiposNCIxCCliente(Cliente.CveCliente, -1, -1) Then
|
||||
dtt = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0 AND SaldoVentaAnticipo = 0 AND ((Tipo = 'IxC' AND CveIE > 0) OR (Tipo = 'Ant' AND CveVenta > 0) OR (Tipo = 'NC' AND CveVenta > 0) OR (Tipo = 'Egs' AND CveVenta > 0) )")
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
TotalIng = SaldoIngPesos + SaldoIngDolaresPesos
|
||||
TotalAnt = SaldoAntPesos + SaldoAntDolaresPesos
|
||||
|
||||
If TotalIng.RoundSQL(2) = 0 AndAlso TotalAnt.RoundSQL(2) = 0 Then
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
Retorno = False
|
||||
dtt = Nothing
|
||||
GuardaLog("Ocurrió un erro al obtener el CxC. " + ex.ToString())
|
||||
End Try
|
||||
|
||||
If Not Retorno Then
|
||||
Return Retorno
|
||||
End If
|
||||
|
||||
Dim DtCxCFact2 As DataTable = DtCxCFact.FiltraParametros($"TipoDocto IN ({TipoDocto2})")
|
||||
|
||||
'INGRESOS
|
||||
If SaldoIngPesos > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Ing Pesos"
|
||||
drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Saldo") = SaldoIngPesos
|
||||
drr("CveMoneda") = 1
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
If SaldoIngDolares > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Ing Dólares"
|
||||
drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Saldo") = SaldoIngDolares
|
||||
drr("CveMoneda") = 2
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
|
||||
'ANTICIPOS
|
||||
If SaldoAntPesos > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Pesos"
|
||||
drr("SaldoAnticipo") = SaldoAntPesos
|
||||
drr("CveMoneda") = 1
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
If SaldoAntDolares > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Dólares"
|
||||
drr("SaldoAnticipo") = SaldoAntDolares
|
||||
drr("CveMoneda") = 2
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
|
||||
If DtCxCFact2 IsNot Nothing AndAlso DtCxCFact2.Rows.Count > 0 Then
|
||||
Dim dr As DataRow = DtCxCFact2.Rows(0)
|
||||
Dim lista = New List(Of CrystalParametro)
|
||||
lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa))
|
||||
lista.Add(New CrystalParametro("TipoCuentas", "Con Saldo"))
|
||||
lista.Add(New CrystalParametro("NombreCliente", Cliente.Nombre))
|
||||
lista.Add(New CrystalParametro("FechaInicio", If(FI = "-1", "-", FI)))
|
||||
lista.Add(New CrystalParametro("FechaFin", If(FF = "-1", DateTime.Now.ToShortDateString, FF)))
|
||||
lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
lista.Add(New CrystalParametro("DireccionCliente", String.Format("Calle {0} #{1} Colonia {2}", Cliente.Direccion, If(Cliente.NoExt = "", "S/N", Cliente.NoExt), Cliente.Colonia)))
|
||||
lista.Add(New CrystalParametro("ClienteCP", Cliente.CP))
|
||||
lista.Add(New CrystalParametro("ClienteCiudad", Cliente.Ciudad))
|
||||
lista.Add(New CrystalParametro("ClienteRFC", Cliente.RFC))
|
||||
lista.Add(New CrystalParametro("ClienteTelefono", Cliente.Telefono))
|
||||
lista.Add(New CrystalParametro("DiasCredito", Cliente.PlazoCobranza))
|
||||
lista.Add(New CrystalParametro("LimiteCredito", Cliente.LimiteCredito))
|
||||
lista.Add(New CrystalParametro("SaldoDisponible", (Cliente.LimiteCredito - DtCxCFact2(0)("Saldo").ToString.ToDouble).FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoIngDolares", SaldoIngDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoIngPesos", SaldoIngPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalIng", TotalIng.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntDolares", SaldoAntDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntPesos", SaldoAntPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalAnt", TotalAnt.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("ContaIng", ContaIng))
|
||||
lista.Add(New CrystalParametro("ContaAnt", ContaAnt))
|
||||
|
||||
If Imagen.Exists Then
|
||||
lista.Add(New CrystalParametro("LogoPath", logouri))
|
||||
Else
|
||||
lista.Add(New CrystalParametro("LogoPath", ""))
|
||||
Try
|
||||
If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then
|
||||
For Each drt As DataRow In dtt.Rows
|
||||
Dim drr As DataRow = DtCxCFact.NewRow
|
||||
drr("TipoDocto") = drt("Tipo")
|
||||
drr("SerieFolio") = drt("Folio")
|
||||
drr("Original") = drt("Original")
|
||||
drr("TipoCambio") = drt("TipoCambio")
|
||||
drr("Saldo") = 0
|
||||
drr("SaldoAnticipo") = drt("Saldo")
|
||||
drr("Fecha") = drt("Fecha")
|
||||
drr("Moneda") = drt("Moneda")
|
||||
drr("CveMoneda") = drt("CveMoneda")
|
||||
DtCxCFact.Rows.Add(drr)
|
||||
Next
|
||||
End If
|
||||
|
||||
Try
|
||||
If DtCxCFact IsNot Nothing Then
|
||||
For Each Row As DataRow In DtCxCFact.FiltraParametros($"TipoDocto IN ({TipoDocto2})").Rows
|
||||
If Row("TipoDocto").ToString = "Ing" Or Row("TipoDocto").ToString = "Rem" Or (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble > 0) Then 'Ingresos
|
||||
ContaIng = ContaIng + 1
|
||||
If Row("CveMoneda").ToString.ToEntero = 1 Then
|
||||
SaldoIngPesos = SaldoIngPesos + Row("Saldo").ToString.ToDouble
|
||||
ElseIf Row("CveMoneda").ToString.ToEntero = 2 Then
|
||||
SaldoIngDolares = SaldoIngDolares + Row("Saldo").ToString.ToDouble
|
||||
SaldoIngDolaresPesos = SaldoIngDolaresPesos + (Row("Saldo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble)
|
||||
End If
|
||||
|
||||
ElseIf (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble = 0) Or Row("TipoDocto").ToString = "IxC" Or Row("TipoDocto").ToString = "NC" Or Row("TipoDocto").ToString = "Dev" Then 'Anticipos, NC, IxC
|
||||
ContaAnt = ContaAnt + 1
|
||||
If Row("CveMoneda").ToString.ToEntero = 1 Then
|
||||
If Row("TipoDocto").ToString = "Dev" Then
|
||||
SaldoAntPesos = SaldoAntPesos + Row("Saldo").ToString.ToDouble
|
||||
Else
|
||||
SaldoAntPesos = SaldoAntPesos + Row("SaldoAnticipo").ToString.ToDouble
|
||||
End If
|
||||
ElseIf Row("CveMoneda").ToString.ToEntero = 2 Then
|
||||
SaldoAntDolares = SaldoAntDolares + Row("Saldo").ToString.ToDouble
|
||||
SaldoAntDolaresPesos = SaldoAntDolaresPesos + (Row("SaldoAnticipo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
TotalIng = SaldoIngPesos + SaldoIngDolaresPesos
|
||||
TotalAnt = SaldoAntPesos + SaldoAntDolaresPesos
|
||||
|
||||
If TotalIng.RoundSQL(2) = 0 AndAlso TotalAnt.RoundSQL(2) = 0 Then
|
||||
Retorno = False
|
||||
Return Retorno
|
||||
End If
|
||||
|
||||
Dim DtCxCFact2 As DataTable = DtCxCFact.FiltraParametros($"TipoDocto IN ({TipoDocto2})")
|
||||
|
||||
'INGRESOS
|
||||
If SaldoIngPesos > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Ing Pesos"
|
||||
drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Saldo") = SaldoIngPesos
|
||||
drr("CveMoneda") = 1
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
If SaldoIngDolares > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Ing Dólares"
|
||||
drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Saldo") = SaldoIngDolares
|
||||
drr("CveMoneda") = 2
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
|
||||
'ANTICIPOS
|
||||
If SaldoAntPesos > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Pesos"
|
||||
drr("SaldoAnticipo") = SaldoAntPesos
|
||||
drr("CveMoneda") = 1
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
If SaldoAntDolares > 0 Then
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Dólares"
|
||||
drr("SaldoAnticipo") = SaldoAntDolares
|
||||
drr("CveMoneda") = 2
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
End If
|
||||
|
||||
If DtCxCFact2 IsNot Nothing AndAlso DtCxCFact2.Rows.Count > 0 Then
|
||||
Dim dr As DataRow = DtCxCFact2.Rows(0)
|
||||
Dim lista = New List(Of CrystalParametro)
|
||||
lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa))
|
||||
lista.Add(New CrystalParametro("TipoCuentas", "Con Saldo"))
|
||||
lista.Add(New CrystalParametro("NombreCliente", Cliente.Nombre))
|
||||
lista.Add(New CrystalParametro("FechaInicio", If(FI = "-1", "-", FI)))
|
||||
lista.Add(New CrystalParametro("FechaFin", If(FF = "-1", DateTime.Now.ToShortDateString, FF)))
|
||||
lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
lista.Add(New CrystalParametro("DireccionCliente", String.Format("Calle {0} #{1} Colonia {2}", Cliente.Direccion, If(Cliente.NoExt = "", "S/N", Cliente.NoExt), Cliente.Colonia)))
|
||||
lista.Add(New CrystalParametro("ClienteCP", Cliente.CP))
|
||||
lista.Add(New CrystalParametro("ClienteCiudad", Cliente.Ciudad))
|
||||
lista.Add(New CrystalParametro("ClienteRFC", Cliente.RFC))
|
||||
lista.Add(New CrystalParametro("ClienteTelefono", Cliente.Telefono))
|
||||
lista.Add(New CrystalParametro("DiasCredito", Cliente.PlazoCobranza))
|
||||
lista.Add(New CrystalParametro("LimiteCredito", Cliente.LimiteCredito))
|
||||
lista.Add(New CrystalParametro("SaldoDisponible", (Cliente.LimiteCredito - DtCxCFact2(0)("Saldo").ToString.ToDouble).FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoIngDolares", SaldoIngDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoIngPesos", SaldoIngPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalIng", TotalIng.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntDolares", SaldoAntDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntPesos", SaldoAntPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalAnt", TotalAnt.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("ContaIng", ContaIng))
|
||||
lista.Add(New CrystalParametro("ContaAnt", ContaAnt))
|
||||
|
||||
If Imagen.Exists Then
|
||||
lista.Add(New CrystalParametro("LogoPath", logouri))
|
||||
Else
|
||||
lista.Add(New CrystalParametro("LogoPath", ""))
|
||||
End If
|
||||
|
||||
Try
|
||||
If Archivo.Exists Then
|
||||
ArchivoPDF = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||
Else
|
||||
ArchivoPDF = ImprimirPDFCrystal(HttpContext.Current.Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
ArchivoPDF = Nothing
|
||||
GuardaLog("Ocurrió un erro al obtener el CxC" + ex.ToString())
|
||||
End Try
|
||||
Else
|
||||
Dim lista = New List(Of CrystalParametro)
|
||||
lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa))
|
||||
lista.Add(New CrystalParametro("TipoCuentas", "Con Saldo"))
|
||||
lista.Add(New CrystalParametro("NombreCliente", Cliente.Nombre))
|
||||
lista.Add(New CrystalParametro("FechaInicio", If(FI = "-1", "-", FI)))
|
||||
lista.Add(New CrystalParametro("FechaFin", If(FF = "-1", DateTime.Now.ToShortDateString, FF)))
|
||||
lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
lista.Add(New CrystalParametro("DireccionCliente", String.Format("Calle {0} #{1} Colonia {2}", Cliente.Direccion, If(Cliente.NoExt = "", "S/N", Cliente.NoExt), Cliente.Colonia)))
|
||||
lista.Add(New CrystalParametro("ClienteCP", Cliente.CP))
|
||||
lista.Add(New CrystalParametro("ClienteCiudad", Cliente.Ciudad))
|
||||
lista.Add(New CrystalParametro("ClienteRFC", Cliente.RFC))
|
||||
lista.Add(New CrystalParametro("ClienteTelefono", Cliente.Telefono))
|
||||
lista.Add(New CrystalParametro("DiasCredito", Cliente.PlazoCobranza))
|
||||
lista.Add(New CrystalParametro("LimiteCredito", Cliente.LimiteCredito))
|
||||
lista.Add(New CrystalParametro("SaldoDisponible", (Cliente.LimiteCredito).FormatoNumero))
|
||||
|
||||
lista.Add(New CrystalParametro("SaldoIngDolares", SaldoIngDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoIngPesos", SaldoIngPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalIng", TotalIng.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntDolares", SaldoAntDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntPesos", SaldoAntPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalAnt", TotalAnt.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("ContaIng", ContaIng))
|
||||
lista.Add(New CrystalParametro("ContaAnt", ContaAnt))
|
||||
|
||||
If Imagen.Exists Then
|
||||
lista.Add(New CrystalParametro("LogoPath", logouri))
|
||||
Else
|
||||
lista.Add(New CrystalParametro("LogoPath", ""))
|
||||
End If
|
||||
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Ing Pesos"
|
||||
drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Saldo") = 0
|
||||
drr("SaldoAnticipo") = 0
|
||||
drr("CveMoneda") = 1
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
|
||||
If Archivo.Exists Then
|
||||
ArchivoPDF = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||
Else
|
||||
ArchivoPDF = ImprimirPDFCrystal(HttpContext.Current.Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió error al mandar MAIL de Orden de Compra", ex)
|
||||
End Try
|
||||
Else
|
||||
Dim lista = New List(Of CrystalParametro)
|
||||
lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa))
|
||||
lista.Add(New CrystalParametro("TipoCuentas", "Con Saldo"))
|
||||
lista.Add(New CrystalParametro("NombreCliente", Cliente.Nombre))
|
||||
lista.Add(New CrystalParametro("FechaInicio", If(FI = "-1", "-", FI)))
|
||||
lista.Add(New CrystalParametro("FechaFin", If(FF = "-1", DateTime.Now.ToShortDateString, FF)))
|
||||
lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
lista.Add(New CrystalParametro("DireccionCliente", String.Format("Calle {0} #{1} Colonia {2}", Cliente.Direccion, If(Cliente.NoExt = "", "S/N", Cliente.NoExt), Cliente.Colonia)))
|
||||
lista.Add(New CrystalParametro("ClienteCP", Cliente.CP))
|
||||
lista.Add(New CrystalParametro("ClienteCiudad", Cliente.Ciudad))
|
||||
lista.Add(New CrystalParametro("ClienteRFC", Cliente.RFC))
|
||||
lista.Add(New CrystalParametro("ClienteTelefono", Cliente.Telefono))
|
||||
lista.Add(New CrystalParametro("DiasCredito", Cliente.PlazoCobranza))
|
||||
lista.Add(New CrystalParametro("LimiteCredito", Cliente.LimiteCredito))
|
||||
lista.Add(New CrystalParametro("SaldoDisponible", (Cliente.LimiteCredito).FormatoNumero))
|
||||
|
||||
lista.Add(New CrystalParametro("SaldoIngDolares", SaldoIngDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoIngPesos", SaldoIngPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalIng", TotalIng.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntDolares", SaldoAntDolares.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("SaldoAntPesos", SaldoAntPesos.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("TotalAnt", TotalAnt.FormatoNumero))
|
||||
lista.Add(New CrystalParametro("ContaIng", ContaIng))
|
||||
lista.Add(New CrystalParametro("ContaAnt", ContaAnt))
|
||||
|
||||
If Imagen.Exists Then
|
||||
lista.Add(New CrystalParametro("LogoPath", logouri))
|
||||
Else
|
||||
lista.Add(New CrystalParametro("LogoPath", ""))
|
||||
End If
|
||||
|
||||
Dim drr As DataRow = DtCxCFact2.NewRow
|
||||
drr("SerieFolio") = "Total Ing Pesos"
|
||||
drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)")
|
||||
drr("Saldo") = 0
|
||||
drr("SaldoAnticipo") = 0
|
||||
drr("CveMoneda") = 1
|
||||
DtCxCFact2.Rows.Add(drr)
|
||||
Catch ex As Exception
|
||||
GuardaLog("Ocurrió un error al generar el pdf" + ex.ToString())
|
||||
ArchivoPDF = Nothing
|
||||
End Try
|
||||
|
||||
If Archivo.Exists Then
|
||||
ArchivoPDF = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||
Else
|
||||
ArchivoPDF = ImprimirPDFCrystal(HttpContext.Current.Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||
End If
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al generar el pdf", ex)
|
||||
ArchivoPDF = Nothing
|
||||
End Try
|
||||
|
||||
If ArchivoPDF IsNot Nothing Then
|
||||
Try
|
||||
Dim Cuerpo As String = String.Format("Estimado cliente {0}, al presente del correo se anexa su estado actual de cartera en {1}.<br />
|
||||
If ArchivoPDF IsNot Nothing Then
|
||||
Try
|
||||
Dim Cuerpo As String = String.Format("Estimado cliente {0}, al presente del correo se anexa su estado actual de cartera en {1}.<br />
|
||||
<br />
|
||||
Quedamos a sus ordenes para cualquier duda o aclaración con su agente de Ventas.<br />
|
||||
<br />
|
||||
@@ -668,16 +729,18 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
<br />
|
||||
<b>ESTE CORREO SE GENERO EN FORMA AUTOMATICA.</b>", Cliente.NombreComercial, UsuarioActual.Empresa.Empresa)
|
||||
|
||||
Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(ArchivoPDF, Correo, $"Estado Actual de Cartera {UsuarioActual.Empresa.Empresa}", Cuerpo))
|
||||
Hilo.Start()
|
||||
Retorno = True
|
||||
Catch ex As Exception
|
||||
Retorno = MandaCorreo(ArchivoPDF, Correo, $"Estado Actual de Cartera {UsuarioActual.Empresa.Empresa}", Cuerpo)
|
||||
Catch ex As Exception
|
||||
Retorno = False
|
||||
GuardaLog("Ocurrió error al mandar el correo de estado de cuenta. " + ex.ToString())
|
||||
End Try
|
||||
Else
|
||||
Retorno = False
|
||||
OnError("Ocurrió error al mandar el correo de estado de cuenta", ex)
|
||||
End Try
|
||||
Else
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Retorno = False
|
||||
End If
|
||||
GuardaLog("Ocurrió error al mandar el correo de estado de cuenta" + ex.ToString())
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
@@ -749,7 +812,7 @@ Public Class TareasProgramadas : Implements IHttpHandler
|
||||
|
||||
Return Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, Archivos:=LSRutasMail)
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al enviar el correo de edo cuenta", ex)
|
||||
GuardaLog("Ocurrió error al mandar el correo de estado de cuenta. " + ex.ToString())
|
||||
Return False
|
||||
End Try
|
||||
|
||||
|
||||
Reference in New Issue
Block a user