Concepto de NC E140

This commit is contained in:
2020-12-03 11:09:36 -07:00
parent 7d655d3e13
commit b89799d777
3 changed files with 91 additions and 76 deletions

View File

@@ -47,6 +47,25 @@ Public Class E141 : Implements IHttpHandler
End If
End Get
End Property
Public ReadOnly Property TokenAutorizacion As String
Get
If EsProduccion Then
Return "$2y$10$AGCCDbEoGEpd0ys89fuBXedtWlunwUeLRlo4MdeLyxDvJF4GwpL7a"
Else
Return "$2y$10$8Mk3YeIkJESilIwD.U5dG.SsA4JloycJKbaGls8TNEw/AKBE1qane"
End If
End Get
End Property
Public ReadOnly Property URLBase As String
Get
If EsProduccion Then
Return "https://services.fidelityapps.mx/"
Else
Return "https://econollantas-pruebas.fidelityapps.mx/"
End If
End Get
End Property
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "application/json"
@@ -66,20 +85,22 @@ Public Class E141 : Implements IHttpHandler
Dim Metodo = If(context.Request("Metodo") = Nothing, "", context.Request("Metodo").ToString())
Dim FiltrarTodos = If(context.Request("FiltrarTodos") = Nothing, "", context.Request("FiltrarTodos").ToString())
If Metodo = "CrearActualizarProductos" Then
retorno = CrearActualizarProductos()
retorno = CrearActualizarProductos(If(FiltrarTodos = "1", True, False))
End If
If Metodo = "ActualizarPrecios" Then
retorno = ActualizarPrecios()
retorno = ActualizarPrecios(If(FiltrarTodos = "1", True, False))
End If
If Metodo = "ActualizarExistencias" Then
retorno = ActualizarExistencias()
retorno = ActualizarExistencias(If(FiltrarTodos = "1", True, False))
End If
If Metodo = "ActualizarVendedores" Then
retorno = ActualizarVendedores()
retorno = ActualizarVendedores(If(FiltrarTodos = "1", True, False))
End If
If Metodo = "GetExistencia" Then
@@ -162,7 +183,7 @@ Public Class E141 : Implements IHttpHandler
Try
Using httpClient = New HttpClient()
Using request = New HttpRequestMessage(HttpMethod.Post, New Uri(url))
request.Headers.Add("token", "$2y$10$LGqtRWUloKQmAt.jcUldc.PmS5LJ6l.WU2w1G4PBOTLMVKZRNQFPS")
request.Headers.Add("token", TokenAutorizacion)
Using content = New StringContent(payload, Encoding.UTF8, "application/json")
request.Content = content
@@ -184,63 +205,45 @@ Public Class E141 : Implements IHttpHandler
Return Retorno
End Function
Private Function EnviarInformacion2(url As String, payload As String) As String
Dim Retorno As String = "{}"
Try
Dim Request As WebRequest = WebRequest.Create(url)
Request.Method = "post"
Request.ContentType = "application/json"
Request.Headers.Add("token", "$2y$10$LGqtRWUloKQmAt.jcUldc.PmS5LJ6l.WU2w1G4PBOTLMVKZRNQFPS")
'Private Function EnviarInformacion2(url As String, payload As String) As String
' Dim Retorno As String = "{}"
' Try
' Dim Request As WebRequest = WebRequest.Create(url)
' Request.Method = "post"
' Request.ContentType = "application/json"
' Request.Headers.Add("token", TokenAutorizacion)
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(payload)
Request.ContentLength = byteArray.Length
' Dim byteArray As Byte() = Encoding.UTF8.GetBytes(payload)
' Request.ContentLength = byteArray.Length
Using dataStream As Stream = Request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
Using tResponse As WebResponse = Request.GetResponse()
Using dataStreamResponse As Stream = tResponse.GetResponseStream()
Using tReader As New StreamReader(dataStreamResponse)
Retorno = tReader.ReadToEnd()
End Using
End Using
End Using
End Using
Catch ex As Exception
Retorno = New JObject(New JProperty("Error", ex.ToString())).ToString()
OnError("Ocurrió un error al enviar la informacion", ex)
End Try
Return Retorno
End Function
' var httpWebRequest = (httpWebRequest)WebRequest.Create("http://url");
'httpWebRequest.ContentType = "application/json";
'httpWebRequest.Method = "POST";
'Using (var streamWriter = New StreamWriter(httpWebRequest.GetRequestStream()))
'{
' String json = "{\"user\":\"test\"," +
' "\"password\":\"bla\"}";
' streamWriter.Write(json);
'}
'var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
'Using (var streamReader = New StreamReader(httpResponse.GetResponseStream()))
'{
' var result = StreamReader.ReadToEnd();
'}
' Using dataStream As Stream = Request.GetRequestStream()
' dataStream.Write(byteArray, 0, byteArray.Length)
' Using tResponse As WebResponse = Request.GetResponse()
' Using dataStreamResponse As Stream = tResponse.GetResponseStream()
' Using tReader As New StreamReader(dataStreamResponse)
' Retorno = tReader.ReadToEnd()
' End Using
' End Using
' End Using
' End Using
' Catch ex As Exception
' Retorno = New JObject(New JProperty("Error", ex.ToString())).ToString()
' OnError("Ocurrió un error al enviar la informacion", ex)
' End Try
' Return Retorno
'End Function
#Region "C R E A C I Ó N / A C T U A L I Z A C I Ó N - P R O D U C T O S"
Private Function CrearActualizarProductos() As String
Return EnviarInformacion("https://services.fidelityapps.mx/api/services/products/import", GetProductosModificados())
Private Function CrearActualizarProductos(Todos As Boolean) As String
Return EnviarInformacion($"{Me.URLBase}api/services/products/import", GetProductosModificados(Todos))
End Function
Private Function GetProductosModificados() As String
Private Function GetProductosModificados(Todos As Boolean) As String
Dim Retorno As String = "{}"
Dim DtPS As DataTable = Nothing
Using ObjPS As New ClsProductosServicios
'OBTERNER PRECIOS DE PUBLICO GENERAL
If ObjPS.GetProductosModificados(CveEmpresa, 44) Then
If ObjPS.GetProductosModificados(CveEmpresa, 44, If(Todos, -1, 1)) Then
DtPS = ObjPS.DtResultados.Copy()
End If
End Using
@@ -294,17 +297,17 @@ Public Class E141 : Implements IHttpHandler
#Region "A C T U A L I Z A R - P R E C I O S"
Private Function ActualizarPrecios() As String
Return EnviarInformacion("https://services.fidelityapps.mx/api/services/products/price-import", GetPreciosModificados())
Private Function ActualizarPrecios(Todos As Boolean) As String
Return EnviarInformacion($"{Me.URLBase}api/services/products/price-import", GetPreciosModificados(Todos))
End Function
Private Function GetPreciosModificados() As String
Private Function GetPreciosModificados(Todos As Boolean) As String
Dim Retorno As String = "{}"
Dim DtPS As DataTable = Nothing
Using ObjPS As New ClsProductosServicios
'OBTERNER PRECIOS DE PUBLICO GENERAL
If ObjPS.GetPreciosModificados(CveEmpresa, 44) Then
If ObjPS.GetPreciosModificados(CveEmpresa, 44, If(Todos, -1, 1)) Then
DtPS = ObjPS.DtResultados.Copy()
End If
End Using
@@ -332,7 +335,7 @@ Public Class E141 : Implements IHttpHandler
#Region "A C T U A L I Z A R - E X I S T E N C I A S"
Private Function ActualizarExistencias() As String
Return EnviarInformacion("https://services.fidelityapps.mx/api/services/products/stock", GetPSExistencias())
Return EnviarInformacion($"{Me.URLBase}api/services/products/stock", GetPSExistencias())
End Function
Private Function GetPSExistencias() As String
@@ -369,17 +372,17 @@ Public Class E141 : Implements IHttpHandler
#Region "A C T U A L I Z A R - E X I S T E N C I A S"
Private Function ActualizarVendedores() As String
Return EnviarInformacion("https://services.fidelityapps.mx/api/v1/sellers/import", GetVendedores())
Private Function ActualizarVendedores(Todos As Boolean) As String
Return EnviarInformacion($"{Me.URLBase}api/v1/sellers/import", GetVendedores(Todos))
End Function
Private Function GetVendedores() As String
Private Function GetVendedores(Todos As Boolean) As String
Dim Retorno As String = "{}"
Dim DtVendedores As DataTable = Nothing
Using ObjPS As New ClsProductosServicios
'OBTERNER PRECIOS DE PUBLICO GENERAL
If ObjPS.GetVendedoresModificados(CveEmpresa) Then
If ObjPS.GetVendedoresModificados(CveEmpresa, If(Todos, -1, 1)) Then
DtVendedores = ObjPS.DtResultados.Copy()
End If
End Using

View File

@@ -6314,7 +6314,7 @@
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="ChkAplicar" runat="server" AutoPostBack="true" OnCheckedChanged="ChkAplicarNCBon_CheckedChanged" />
<asp:CheckBox ID="ChkAplicar" runat="server"/>
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField DataNavigateUrlFields="CveVenta" Target="_blank" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" DataTextField="Folio" HeaderText="Folio" ItemStyle-Width="150px" ItemStyle-HorizontalAlign="Left" />

View File

@@ -14778,7 +14778,7 @@ Partial Class Ventas
TmpDT = ObjVentas.DtResultados
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
End If
ErrorCancelar = ProcesoPrepolizaBtnAplicaNuevaNC_Clicks(ObjConta, ObjFacturaDevolucion, -1, TmpDT, ObjAC, -1, ObjBancos, ObjVentas)
ErrorCancelar = ProcesoPrepolizas(ObjConta, ObjFacturaDevolucion, -1, TmpDT, ObjAC, -1, ObjBancos, ObjVentas)
Else
ErrorCancelar = ProcesoPrepolizas(ObjConta, ObjFacturaDevolucion, -1, TmpDT, ObjAC, -1, ObjBancos, ObjVentas)
End If
@@ -27569,6 +27569,18 @@ Partial Class Ventas
Dim TotalRemNCAplicado As Decimal = 0
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
Dim NCConcepto As Integer = -1
Select Case RblRNCTipo.SelectedValue
Case "1" 'CARGOS
NCConcepto = ArrayNC(3).ToEntero()
Case "2" 'BONIFICACIONES
NCConcepto = ArrayNC(4).ToEntero()
Case "3" 'AJUSTE/GARANTIAS
NCConcepto = ArrayNC(1).ToEntero()
End Select
If ChkMostarProductosRNC.Checked Then
Me.AplicaRNCXDetalle = True
@@ -27651,24 +27663,18 @@ Partial Class Ventas
For Each RNC In ListaRemisionesNC.Where(Function(x) x.Num2 = 1)
Dim Salir As Boolean = False
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
Dim NCAjuste As Integer = -1
Dim NCGarantiaTotal As Integer = -1
If ArrayNC.Length > 2 Then
NCAjuste = ArrayNC(1).ToEntero()
NCGarantiaTotal = ArrayNC(2).ToEntero()
End If
Using ObjAcum As New ClsAcumuladores
If ObjAcum.GetGarantiasDetalle(RNC.CveVenta) Then
'SI ES GARANTIA TOTAL
If ObjAcum.DtResultados.MAX("PorcentajeAjuste") = "1" Then
DdlNCPS.SelectedValueExist(NCGarantiaTotal)
DdlNCPS.Enabled = False
If ArrayNC.Length > 2 Then
NCConcepto = ArrayNC(2).ToEntero()
End If
Salir = True
Else
DdlNCPS.SelectedValueExist(NCAjuste)
DdlNCPS.Enabled = False
If ArrayNC.Length > 2 Then
NCConcepto = ArrayNC(1).ToEntero()
End If
End If
End If
End Using
@@ -27681,7 +27687,6 @@ Partial Class Ventas
DdlNCPS.Enabled = True
End If
For Each GvRow As GridViewRow In GvRemisionesNCBon.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
If GvRow.FCCheckBox("ChkAplicar").Checked Then
@@ -27709,6 +27714,13 @@ Partial Class Ventas
End If
Dim DrPSSeleccionado As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCConcepto).FiltroPrimero("")
If DrPSSeleccionado IsNot Nothing Then
DdlNCPS.SelectedValueExistInsert(NCConcepto, DrPSSeleccionado("PS").ToString())
DdlNCPS.Enabled = False
End If
TxtImportesRemisionesNC.Text = TotalRemNCAplicado.FormatoNumero
TxtNCImporte.Text = TotalRemNCAplicado.FormatoNumero