From 2e3348bdb39238a819a22f61f2951a8c889a0267 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 1 Jun 2021 10:14:37 -0700 Subject: [PATCH 01/15] Reporte de unidades --- App_Code/ClsGPS.vb | 19 +++ App_Code/ClsPaginas.vb | 37 +++++- App_Code/ClsVentas.vb | 28 +++++ GPS/RepUnidades.aspx | 264 ++++++++++++++++++++++++++++++++++++++++ GPS/RepUnidades.aspx.vb | 97 +++++++++++++++ 5 files changed, 439 insertions(+), 6 deletions(-) create mode 100644 GPS/RepUnidades.aspx create mode 100644 GPS/RepUnidades.aspx.vb diff --git a/App_Code/ClsGPS.vb b/App_Code/ClsGPS.vb index 6ef6a9114..568713257 100644 --- a/App_Code/ClsGPS.vb +++ b/App_Code/ClsGPS.vb @@ -1996,6 +1996,25 @@ Public Class ClsGPS #End Region #Region "V E H I C U L O S" + Public Function GetRepUnidades(CveEmpresa As Integer, CveCliente As Integer, Optional FechaI As DateTime = MinFecha, Optional FechaF As DateTime = MaxFecha, Optional CveEstatus As Integer = -1) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_GPS_RepUnidades") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@FechaI", SqlDbType.DateTime).Value = FechaI + .Add("@FechaF", SqlDbType.DateTime).Value = FechaF + .Add("@CveEstatus", SqlDbType.Int).Value = CveEstatus + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el reporte de los vehículos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function Public Function VehiculoAdd(Modelo As String, Color As String, Serie As String, Nombre As String, NoEconomico As String, CveUsuario As Integer, CveCliente As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_GPS_VehiculoAdd") diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 15411ebe9..deb3d0fa4 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4609,6 +4609,7 @@ Public Class ClsPaginas PaginaDict.Add("/GPS/RepGastos.aspx".ToUpper(), 685) PaginaDict.Add("/GPS/RecursoConfiableTracking.aspx".ToUpper(), 692) PaginaDict.Add("/GPS/KimberlyClarkTracking.aspx".ToUpper(), -1) + PaginaDict.Add("/GPS/RepUnidades.aspx".ToUpper(), 780) #End Region 'INVENTARIOS #Region "Inventarios" @@ -5942,6 +5943,19 @@ Public Class ClsPaginas Dim TipoDocumentoRef As String = "" Dim AplicaPagare As String = "1" + Dim RFCReceptor As String = "" + + If String.IsNullOrEmpty(Vta.RFCReceptor) Then + RFCReceptor = Vta.Cliente.RFC + If Vta.FacturarSucursal Then + If Vta.ClienteSucursal IsNot Nothing Then + RFCReceptor = Vta.ClienteSucursal.RFC + End If + End If + Else + RFCReceptor = Vta.RFCReceptor + End If + Dim RutaCBB As String = String.Format("{0}CBB\{1}.jpg", Ruta, Vta.SerieFolio) Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) Dim ImgCBB As String '= String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) @@ -6071,7 +6085,7 @@ Public Class ClsPaginas 'Si no tiene CBB, SE GENERA If Not ImagenCBB.Exists Then Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Vta.Cliente.RFC, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFCReceptor, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) End If ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) @@ -6086,7 +6100,7 @@ Public Class ClsPaginas 'CLIENTE params.Add(New CrystalParametro("ClienteCodigo", Vta.Cliente.Codigo)) - params.Add(New CrystalParametro("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) + params.Add(New CrystalParametro("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso RFCReceptor = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) params.Add(New CrystalParametro("ClienteDireccion", ClienteDireccion)) params.Add(New CrystalParametro("ClienteLugar", ClienteLugar)) @@ -6118,7 +6132,7 @@ Public Class ClsPaginas params.Add(New CrystalParametro("SelloSAT", Vta.SelloSAT)) params.Add(New CrystalParametro("QR", ImgCBB)) - params.Add(New CrystalParametro("ClienteRFC", Vta.Cliente.RFC)) + params.Add(New CrystalParametro("ClienteRFC", RFCReceptor)) params.Add(New CrystalParametro("FormaPago", Vta.FormaPagoText)) params.Add(New CrystalParametro("Moneda", Vta.Moneda)) params.Add(New CrystalParametro("TipoCambio", Vta.TipoCambio.ToString)) @@ -6453,7 +6467,18 @@ Public Class ClsPaginas Dim NombreArchivoDescarga As String = "" Dim TipoDocumento As String = "" Dim TipoDocumentoRef As String = "" + Dim RFCReceptor As String = "" + If String.IsNullOrEmpty(Vta.RFCReceptor) Then + RFCReceptor = Vta.Cliente.RFC + If Vta.FacturarSucursal Then + If Vta.ClienteSucursal IsNot Nothing Then + RFCReceptor = Vta.ClienteSucursal.RFC + End If + End If + Else + RFCReceptor = Vta.RFCReceptor + End If Dim RutaCBB As String = String.Format("{0}CBB\{1}.jpg", Ruta, Vta.SerieFolio) Dim ImagenCBB As New System.IO.FileInfo(RutaCBB) @@ -6608,7 +6633,7 @@ Public Class ClsPaginas 'Si no tiene CBB, SE GENERA If Not ImagenCBB.Exists AndAlso Vta.CveCliente.ToEntero > 0 Then Dim CBB As New ClbNegBICFDv3_2.ClsNegCBBGenerar() - CBB.GenerarCBB(UsuarioActual.Empresa.RFC, Vta.Cliente.RFC, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) + CBB.GenerarCBB(UsuarioActual.Empresa.RFC, RFCReceptor, Vta.Total.ToString.ToDecimal, Vta.FolioFiscal, RutaCBB) End If ImgCBB = String.Format("{0}://{1}:{2}/Empresas/{3}/CBB/{4}.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa, Vta.SerieFolio) @@ -6629,14 +6654,14 @@ Public Class ClsPaginas params.Add(New ReportParameter("ClienteNombre", If(Vta.ClienteSucursal.ImprimeNombreSucursal = "True", If(Vta.CveClienteSucursal > 0, Vta.ClienteSucursal.Sucursal, Vta.Cliente.Nombre), If(Vta.AtencionA <> "" AndAlso Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", $"{Vta.Cliente.Nombre}({Vta.AtencionA})", Vta.Cliente.Nombre)))) params.Add(New ReportParameter("ClienteDireccion", ClienteDireccion)) params.Add(New ReportParameter("ClienteLugar", ClienteLugar)) - params.Add(New ReportParameter("ClienteRFC", Vta.Cliente.RFC)) + params.Add(New ReportParameter("ClienteRFC", RFCReceptor)) End If If Vta.CveEmpresaCRM.ToEntero > 0 Then params.Add(New ReportParameter("ClienteCodigo", Vta.Cliente.Codigo)) params.Add(New ReportParameter("ClienteNombre", Vta.Cliente.Nombre)) params.Add(New ReportParameter("ClienteDireccion", ClienteDireccion)) params.Add(New ReportParameter("ClienteLugar", ClienteLugar)) - params.Add(New ReportParameter("ClienteRFC", Vta.Cliente.RFC)) + params.Add(New ReportParameter("ClienteRFC", RFCReceptor)) End If 'TOTALES diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 996adb595..c34d80562 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -1686,6 +1686,34 @@ Public Class ClsVentas Return Retorno End Function + Public Function GetRepPSDiario(CveSubProyecto As Integer, CvePS As Integer, FechaConsulta As Date, CveEmpresa As Integer, Optional CveUsuarioConsulta As Integer = -1, Optional GPO As Integer = -1, + Optional CveMoneda As Integer = -1, Optional TipoCambio As Integer = -1, Optional TCEspecifico As Double = 0) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RepPSDiarioGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CvePS", SqlDbType.Int).Value = CvePS + .Add("@FechaConsulta", SqlDbType.Date).Value = FechaConsulta + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuarioConsulta + .Add("@GPO", SqlDbType.Int).Value = GPO + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@TipoCambio", SqlDbType.Int).Value = TipoCambio + .Add("@TCEspecifico", SqlDbType.Float).Value = TCEspecifico + End With + + Try + Dataset = New DataSet() + SqlAdapter.Fill(Dataset) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte diario.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function GetRepNCxAplicar(CveClienteSucursal As Integer, CveSubProyecto As Integer, CveCliente As Integer, FechaInicio As DateTime, FechaFin As DateTime, ConSaldo As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False diff --git a/GPS/RepUnidades.aspx b/GPS/RepUnidades.aspx new file mode 100644 index 000000000..cc8e5f70a --- /dev/null +++ b/GPS/RepUnidades.aspx @@ -0,0 +1,264 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepUnidades.aspx.vb" Inherits="GPS_RepUnidades" %> + + + + + + + + Reporte de Unidades + + + + + + + + + + +
+
+
+ +
+
+
    +
  • Empresa: + + +
  • +
  • Cliente: + + +
  • +
  • Fecha Inicio: + +
    + +
    +
  • +
  • Fecha Fin: + +
    + +
    +
  • +
  • Estatus: + + + + + +
  • +
+
+
+
+
+
+ + +
+
+
+

Total Unidades

+
+ +
+
+
+ + + +
+
+
+
+
+
+
+
+

Unidades Activas

+
+ +
+
+
+ + + +
+
+
+
+
+
+
+
+

Unidades Inactivas

+
+ +
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+ + Unidades +
+
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + diff --git a/GPS/RepUnidades.aspx.vb b/GPS/RepUnidades.aspx.vb new file mode 100644 index 000000000..afcad6b0f --- /dev/null +++ b/GPS/RepUnidades.aspx.vb @@ -0,0 +1,97 @@ +Option Strict On +Option Explicit On +Imports System.Data +Imports Extensiones + +Partial Class GPS_RepUnidades + Inherits ClsPaginas + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + CargaCombos() + End If + End Sub + + Private Sub CargaCombos() + If UsuarioActual.CveRol = 1 Then + DdlEmpresa.DataSource = GlobalDTEmpresas().FiltraParametros("CvePlataforma = 3") + DdlEmpresa.DataBind() + DdlEmpresa.Items.Insert(0, New ListItem("Todas", "-1")) + + DdlCliente.Items.Insert(0, New ListItem("Seleccione", "-1")) + Else + DdlEmpresa.DataSource = GlobalDTEmpresas().FiltraParametros($"CvePlataforma = 3 AND CveEmpresa = {UsuarioActual.CveEmpresa}") + DdlEmpresa.DataBind() + + CargaClientes() + End If + + UPFiltros.Update() + End Sub + + + + Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + Select Case e.Row.DBCampo("TipoFila") + Case "1" + e.Row.CssClass = "Totales" + Case "2" + e.Row.CssClass = "SubTotales" + Case "3" + If e.Row.DBCampo("CveEstatus") = "0" Then + e.Row.FCLabel("LblEstatus").CssClass = "badge badge-danger" + Else + e.Row.FCLabel("LblEstatus").CssClass = "badge badge-success" + End If + End Select + End If + End Sub + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + CargaDatos() + End Sub + + Private Sub CargaDatos() + Dim FechaI As DateTime = MinFecha, FechaF As DateTime = MaxFecha + + If Not String.IsNullOrEmpty(txtFechaI.Text) Then + FechaI = txtFechaI.Text.ToDateTime() + End If + + If Not String.IsNullOrEmpty(txtFechaF.Text) Then + FechaF = txtFechaF.Text.ToDateTime() + End If + + Using ObjGPS As New ClsGPS + If ObjGPS.GetRepUnidades(DdlEmpresa.SelectedValue.ToEntero(), DdlCliente.SelectedValue.ToEntero(), FechaI:=FechaI, FechaF:=FechaF, CveEstatus:=DdlEstatus.SelectedValue.ToEntero()) Then + GvDatos.DataSource = ObjGPS.DtResultados + + Dim DtUnidades As DataTable = ObjGPS.DtResultados.FiltraParametros("CveDispositivo > 0", DistinctColumns:={"CveDispositivo", "CveEstatus"}) + + LtlTotalUnidades.Text = DtUnidades.Rows.Count.ToString() + LtlActivas.Text = DtUnidades.COUNT("CveDispositivo", "CveEstatus = 1").ToString() + LtlInactivas.Text = DtUnidades.COUNT("CveDispositivo", "CveEstatus = 0").ToString() + + End If + End Using + + GvDatos.DataBind() + + UpDatos.Update() + End Sub + + Protected Sub DdlEmpresa_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaClientes() + UpDatos.Update() + End Sub + + Private Sub CargaClientes() + If DdlEmpresa.SelectedValue.ToEntero() > 0 Then + DdlCliente.DataSource = GlobalDTCliente(DdlEmpresa.SelectedValue.ToEntero()) + Else + DdlCliente.DataSource = Nothing + End If + DdlCliente.DataBind() + DdlCliente.Items.Insert(0, New ListItem("Todos", "-1")) + End Sub +End Class From 4f5592a0eceb2e2f6014c8b75681a7ede50adfb1 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 1 Jun 2021 10:15:03 -0700 Subject: [PATCH 02/15] Cancelar movimientos de usados --- App_Code/Modelos.vb | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index c7f5e4a9d..420e86ef7 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -2058,24 +2058,36 @@ Namespace Modelos End Sub Private Function CancelarMovimientosUsados(factura As Modelos.Factura, UsuarioActual As Usuario, ByRef ObjAcum As ClsAcumuladores) As Boolean Dim Retorno As Boolean = True - If ObjAcum.DistribuidorMovtosGet(factura.CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=factura.CveVenta, CveConcepto:=2) Then - Dim CveConceptoSalida As Integer = 2 - Dim DtSalidas As DataTable = ObjAcum.DtResultados.FiltraParametros("Cantidad > 0") - If DtSalidas IsNot Nothing AndAlso DtSalidas.Rows.Count > 0 Then - For Each RowSalida As DataRow In DtSalidas.Rows + Dim CveConcepto As Integer = -1 + + Select Case factura.TipoDocto + Case "Ing" + CveConcepto = 2 + Case "Dev" + CveConcepto = 1 + Case "RNC" + CveConcepto = 1 + Case "Egs" + CveConcepto = 6 + End Select + + If ObjAcum.DistribuidorMovtosGet(factura.CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=factura.CveVenta, CveConcepto:=CveConcepto) Then + Dim DtMovimientos As DataTable = ObjAcum.DtResultados.FiltraParametros("Cantidad > 0") + If DtMovimientos IsNot Nothing AndAlso DtMovimientos.Rows.Count > 0 Then + For Each RowSalida As DataRow In DtMovimientos.Rows Dim Cantidad As Decimal = RowSalida("Cantidad").ToString().ToDecimal() * -1 - If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, Cantidad, RowSalida("CveTamaño").ToString.ToEntero, CveConceptoSalida, factura.CveVenta, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0D, "") Then + If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, Cantidad, RowSalida("CveTamaño").ToString.ToEntero, CveConcepto, factura.CveVenta, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0D, "") Then Retorno = False Exit For End If Next - DtSalidas.Dispose() + DtMovimientos.Dispose() End If - End If Return Retorno + End Function Private Function GuardarUsados(ByRef ObjAcum As ClsAcumuladores, ByRef ObjVentas As ClsVentas, ByRef ObjInventario As ClsInventarios, factura As Modelos.Factura, ByRef Optional Resp As MMensajeFactura = Nothing) As Boolean Dim Resultado As Boolean = True @@ -5420,7 +5432,7 @@ Namespace Modelos 'CANCELA MOVIMIENTOS DE USADOS If Not ErrorCancelar Then - If ObjFactura.TipoDocto = "Ing" Then + If ObjFactura.TipoDocto.Contiene("Ing", "Dev", "RNC", "Egs") Then If Not CancelarMovimientosUsados(ObjFactura, UsuarioActual, ObjAcum) Then ErrorCancelar = True MensajeError = "Ocurrió un error al cancelar los movimientos de usados" From 8ad48a33946cc73fb45fcde9aa8177a55a8439a8 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 1 Jun 2021 11:01:43 -0700 Subject: [PATCH 03/15] Cancelacion PAC 5 --- App_Code/Timbrado.vb | 315 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 252 insertions(+), 63 deletions(-) diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index c50f0c354..48e9586ba 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -8,6 +8,7 @@ Imports System.Net.Http Imports System.Xml Imports System.Data Imports System.Xml.Serialization +Imports System.Net Public Class Timbrado @@ -495,6 +496,84 @@ Public Class Timbrado End If MsgCancelacion.AppendFormat("{0} --Código:{1} -- XML: {2}", objCan.MensajeError, objCan.CodigoError, objCan.Xml) + Case 5 + CancelacionAcuse = "" + Retorno = False + + MsgCancelacion.AppendFormat("5.1-") + Dim TimbraProduccion As Boolean = True + + Dim EmisorRFC As String = Empresa.RFC + Dim ArchivoLLave As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoKey}" + Dim ArchivoCertificado As String = $"{Empresa.Ruta}Certificados\{Empresa.ArchivoCer}" + Dim Clave As String = Empresa.ContraseñaKey + + Dim UsuarioServicio As String = "rene.molina@adssistemas.mx" + Dim ClaveServicio As String = "Facturacion2021#" + + If Not Empresa.FacturaProduccion OrElse Empresa.CveEmpresa = 1 Then + EmisorRFC = "ZUÑ920208KL4" + ArchivoLLave = $"{Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.key" + ArchivoCertificado = $"{Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.cer" + Clave = "12345678a" + TimbraProduccion = False + End If + + Dim llaveByte As Byte(), certByte As Byte() + Dim llaveBase64 As String = "", certBase64 As String = "" + + Try + llaveByte = System.IO.File.ReadAllBytes(ArchivoLLave) + llaveBase64 = Convert.ToBase64String(llaveByte) + Catch ex As Exception + Alert($"Error al leer la llave privada: {ex.Message}", TipoMensaje.MsgError) + Return False + End Try + + Try + certByte = System.IO.File.ReadAllBytes(ArchivoCertificado) + certBase64 = Convert.ToBase64String(certByte) + Catch ex As Exception + Alert($"Error al leer el certificado: {ex.Message}", TipoMensaje.MsgError) + Return False + End Try + + Dim Contrato As String = "72330711-cac6-4106-8051-cbcda1aef495" + + Dim Respuesta As String = EnviarInformacionCancelacionPADESOAP("https://timbrado.pade.mx/servicio/Timbrado3.3?wsdl", UsuarioServicio, ClaveServicio, Contrato, EmisorRFC, RFCReceptor, certBase64, llaveBase64, Clave, FolioFiscal, Total, TimbraProduccion) + + If Not String.IsNullOrEmpty(Respuesta) Then + Dim result As PADEServicioCancelacionResp = Nothing + Dim serializer As XmlSerializer = New XmlSerializer(GetType(PADEServicioCancelacionResp)) + + Try + Using reader As TextReader = New StringReader(Respuesta) + result = CType(serializer.Deserialize(reader), PADEServicioCancelacionResp) + End Using + Catch ex As Exception + OnError("Ocurrió un error al obtener los resultados", ex) + End Try + + If result IsNot Nothing Then + If result.statusOk Then + Dim cancelacion = result.cancelaciones.First() + If cancelacion IsNot Nothing Then + 'EN PROCESO, CANCELABLE SIN ACEPTACION,CANCEALDO PREVIAMENTE + If cancelacion.codigo.Contiene("96", "201", "202") Then + CancelacionFecha = Now + Retorno = True + CancelacionAcuse = result.acuseCancelBase64 + End If + CancelacionMensaje = cancelacion.mensaje + Else + CancelacionMensaje = result.mensaje + End If + + End If + End If + Else + + End If End Select @@ -504,6 +583,99 @@ Public Class Timbrado Return Retorno End Function + + + Public Class PADEServicioCancelacionResp + + Public Property statusOk As Boolean + + Public Property codigo As String + + Public Property mensaje As String + + Public Property procesados As Integer + + Public Property cancelados As Integer + + + Public Property cancelaciones As List(Of PADECancelacion) + + Public Property acuseCancelBase64 As String + End Class + + + Public Class PADECancelacion + + Public Property uuid As String + + Public Property codigo As String + + Public Property mensaje As String + End Class + + Private Function EnviarInformacionCancelacionPADESOAP(ByVal url As String, UsuarioServicio As String, PassServicio As String, contrato As String, rfcEmisor As String, rfcReceptor As String, + certBase64 As String, keyBase64 As String, keyPass As String, arregloUUID As String, Total As Decimal, TimbraProduccion As Boolean) As String + Dim retorno = "" + Try + + Dim request As HttpWebRequest = CType(WebRequest.Create($"{url}"), HttpWebRequest) + 'request.Headers.Add("SOAPAction:http://tempuri.org/TestCfd33 ") + request.ContentType = "text/xml;charset=""utf-8""" + request.Accept = "text/xml" + request.Method = "POST" + + Dim XMLString As String = $" + + + {contrato} + {UsuarioServicio} + {PassServicio} + {rfcEmisor} + {arregloUUID}|{rfcReceptor}|{rfcEmisor}|{Total} + {certBase64} + {keyBase64} + {keyPass} + {If(TimbraProduccion, "", "MODO_PRUEBA:3")} + + + " + + Dim SOAPReqBody As XmlDocument = New XmlDocument() + SOAPReqBody.LoadXml(XMLString) + + Using stream As Stream = request.GetRequestStream() + SOAPReqBody.Save(stream) + End Using + + Dim response As String = "" + + Using Serviceres As WebResponse = request.GetResponse() + Using rd As StreamReader = New StreamReader(Serviceres.GetResponseStream()) + response = rd.ReadToEnd() + End Using + End Using + + If Not String.IsNullOrEmpty(response) Then + Dim xmlRetorno = New XmlDocument() + xmlRetorno.LoadXml(response) + Dim elemList As XmlNodeList = xmlRetorno.GetElementsByTagName("return") + + If elemList.Count > 0 Then + If elemList(0).ChildNodes.Count > 0 Then + retorno = elemList(0).ChildNodes(0).Value + End If + End If + + End If + + Catch ex As Exception + retorno = "" + OnError("Ocurrió un error al cancelar", ex) + End Try + + Return retorno + End Function + Public Function PreparaTimbrePago(EmisorRFC As String, EmisorNombre As String, EmisorRegimenFiscal As String, ReceptorRFC As String, ReceptorNombre As String, Serie As String, Folio As String, FechaTimbrado As DateTime, CuentaPago As String, FechaPago As DateTime, FormaPago As String, MonedaPago As String, Monto As Double, LugarExpedicion As String, @@ -2026,19 +2198,19 @@ Public Class Timbrado If ObjCFDITimbre.Nomina IsNot Nothing Then 'If cfdi.Nomina12SeparacionIndemnizacion Then If ObjCFDITimbre.Nomina.Percepciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Percepciones.Count > 0 Then - cfdi.Nomina12Percepciones(ObjCFDITimbre.Nomina.TotalSueldos, ObjCFDITimbre.Nomina.TotalIndemnizacion, ObjCFDITimbre.Nomina.TotalJubilacion, ObjCFDITimbre.Nomina.TotalPercepcionesGravado, ObjCFDITimbre.Nomina.TotalPercepcionesExento) - For Each percep As CFDINominaPercepciones In ObjCFDITimbre.Nomina.Percepciones - cfdi.Nomina12Percepcion(percep.TipoPercepcion, percep.Clave, percep.Concepto, Math.Round(percep.ImporteGravado, 2), Math.Round(percep.ImporteExento, 2)) - If percep.TipoPercepcion.ToEntero() = 19 Then + cfdi.Nomina12Percepciones(ObjCFDITimbre.Nomina.TotalSueldos, ObjCFDITimbre.Nomina.TotalIndemnizacion, ObjCFDITimbre.Nomina.TotalJubilacion, ObjCFDITimbre.Nomina.TotalPercepcionesGravado, ObjCFDITimbre.Nomina.TotalPercepcionesExento) + For Each percep As CFDINominaPercepciones In ObjCFDITimbre.Nomina.Percepciones + cfdi.Nomina12Percepcion(percep.TipoPercepcion, percep.Clave, percep.Concepto, Math.Round(percep.ImporteGravado, 2), Math.Round(percep.ImporteExento, 2)) + If percep.TipoPercepcion.ToEntero() = 19 Then - If ObjCFDITimbre.Nomina.HorasExtras IsNot Nothing AndAlso ObjCFDITimbre.Nomina.HorasExtras.Count > 0 Then - For Each HoraExtra As CFDINominaHorasExtras In ObjCFDITimbre.Nomina.HorasExtras - cfdi.Nomina12HorasExtra(HoraExtra.Dias.ToEntero, HoraExtra.TipoHoras, HoraExtra.HorasExtra, HoraExtra.ImportePagado) - Next - End If + If ObjCFDITimbre.Nomina.HorasExtras IsNot Nothing AndAlso ObjCFDITimbre.Nomina.HorasExtras.Count > 0 Then + For Each HoraExtra As CFDINominaHorasExtras In ObjCFDITimbre.Nomina.HorasExtras + cfdi.Nomina12HorasExtra(HoraExtra.Dias.ToEntero, HoraExtra.TipoHoras, HoraExtra.HorasExtra, HoraExtra.ImportePagado) + Next End If - Next - End If + End If + Next + End If If ObjCFDITimbre.IStimbreFiniquito Then 'ObjCFDITimbre.Nomina. @@ -2051,39 +2223,39 @@ Public Class Timbrado End If 'deducciones al final If ObjCFDITimbre.Nomina.Deducciones IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Deducciones.Count > 0 Then - cfdi.Nomina12Deducciones(ObjCFDITimbre.Nomina.TotalDeduccionesOtras, Math.Round(ObjCFDITimbre.Nomina.TotalDeduccionesImpuestosRetenidos, 2)) - For Each deduc As CFDINominaDeducciones In ObjCFDITimbre.Nomina.Deducciones - cfdi.Nomina12Deduccion(deduc.TipoDeduccion, deduc.Clave, deduc.Concepto, Math.Round(deduc.Importe, 2)) - Next - End If - If ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing Then - ' cfdi.agregarNominaOtrosPagosOtroPago12("002", "002", "Subsidio", "10.00"); - ' cfdi.agregarNominaOtrosPagosOtroPagoSubsidioAlEmpleo12("10.00"); - If ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing AndAlso ObjCFDITimbre.Nomina.OtrosPagos.Count > 0 Then - For Each otpag As CFDINominaOtrosPagos In ObjCFDITimbre.Nomina.OtrosPagos - cfdi.Nomina12OtroPago(otpag.TipoOtroPago, otpag.Clave, otpag.Concepto, otpag.Importe) - If otpag.TipoOtroPago = "002" Then - cfdi.Nomina12SubsidioAlEmpleo(otpag.Subsidiocausado) - End If + cfdi.Nomina12Deducciones(ObjCFDITimbre.Nomina.TotalDeduccionesOtras, Math.Round(ObjCFDITimbre.Nomina.TotalDeduccionesImpuestosRetenidos, 2)) + For Each deduc As CFDINominaDeducciones In ObjCFDITimbre.Nomina.Deducciones + cfdi.Nomina12Deduccion(deduc.TipoDeduccion, deduc.Clave, deduc.Concepto, Math.Round(deduc.Importe, 2)) + Next + End If + If ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing Then + ' cfdi.agregarNominaOtrosPagosOtroPago12("002", "002", "Subsidio", "10.00"); + ' cfdi.agregarNominaOtrosPagosOtroPagoSubsidioAlEmpleo12("10.00"); + If ObjCFDITimbre.Nomina.OtrosPagos IsNot Nothing AndAlso ObjCFDITimbre.Nomina.OtrosPagos.Count > 0 Then + For Each otpag As CFDINominaOtrosPagos In ObjCFDITimbre.Nomina.OtrosPagos + cfdi.Nomina12OtroPago(otpag.TipoOtroPago, otpag.Clave, otpag.Concepto, otpag.Importe) + If otpag.TipoOtroPago = "002" Then + cfdi.Nomina12SubsidioAlEmpleo(otpag.Subsidiocausado) + End If - If otpag.TipoOtroPago = "004" AndAlso otpag.Importe > 0 Then - If otpag.ejercicio > 0 Then - cfdi.CompensacionSaldosAFavor(otpag.SaldoAFavor, otpag.ejercicio, otpag.RemanenteSalFav) 'otpag.SaldoAFavor - End If + If otpag.TipoOtroPago = "004" AndAlso otpag.Importe > 0 Then + If otpag.ejercicio > 0 Then + cfdi.CompensacionSaldosAFavor(otpag.SaldoAFavor, otpag.ejercicio, otpag.RemanenteSalFav) 'otpag.SaldoAFavor End If + End If - Next - End If - End If - If ObjCFDITimbre.Nomina.Incapacidades IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Incapacidades.Count > 0 Then - For Each Incap As CFDINominaIncapacidades In ObjCFDITimbre.Nomina.Incapacidades - cfdi.Nomina12Incapacidad(Incap.DiasIncapacidad.ToEntero, Incap.TipoIncapacidad, Incap.Importe) Next End If End If + If ObjCFDITimbre.Nomina.Incapacidades IsNot Nothing AndAlso ObjCFDITimbre.Nomina.Incapacidades.Count > 0 Then + For Each Incap As CFDINominaIncapacidades In ObjCFDITimbre.Nomina.Incapacidades + cfdi.Nomina12Incapacidad(Incap.DiasIncapacidad.ToEntero, Incap.TipoIncapacidad, Incap.Importe) + Next + End If + End If #End Region - sw.Stop() + sw.Stop() swTiempo.AppendFormat("Armado: ({0}) {1} ", sw.ElapsedMilliseconds - swmili, sw.ElapsedMilliseconds) swmili = sw.ElapsedMilliseconds sw.Start() @@ -2683,27 +2855,27 @@ Public Class Timbrado swmili = sw.ElapsedMilliseconds sw.Start() + Dim msgErrorGeneracion As String = If(String.IsNullOrEmpty(cfdi.MensajeError), "", cfdi.MensajeError) + #Region "Timbra" If ArchivoGenerado Then - 'Dim opciones As String() = New String(0) {""} - 'Dim pade = New PADETimbrado.PadeTimbradoServiceClient + Dim Respuesta As String = "" - 'Dim Respuesta As String = pade.timbradoConCSD("72330711-cac6-4106-8051-cbcda1aef495", UsuarioServicio, ClaveServicio, cfdi.Xml, certByte, llaveByte, Clave, Not TimbraProduccion, opciones) + If String.IsNullOrEmpty(msgErrorGeneracion) Then + Dim TokenAuth As String = $"{UsuarioServicio}:{ClaveServicio}".ToBase64Encode() - Dim TokenAuth As String = $"{UsuarioServicio}:{ClaveServicio}".ToBase64Encode() - - Dim payload As New JObject( - New JProperty("contrato", "72330711-cac6-4106-8051-cbcda1aef495"), - New JProperty("certBase64", certBase64), - New JProperty("keyBase64", llaveBase64), - New JProperty("keyPass", Clave), - New JProperty("xmlBase64", cfdi.Xml.ToBase64Encode()), - New JProperty("prueba", (Not TimbraProduccion).ToString().ToLower), - New JProperty("opciones", New String(0) {""}) - ) - - Dim Respuesta = EnviarInformacionPADE("https://timbrado.pade.mx/servicio/rest/timbrado/timbrarConCSD", payload.ToString(), TokenAuth) + Dim payload As New JObject( + New JProperty("contrato", "72330711-cac6-4106-8051-cbcda1aef495"), + New JProperty("certBase64", certBase64), + New JProperty("keyBase64", llaveBase64), + New JProperty("keyPass", Clave), + New JProperty("xmlBase64", cfdi.Xml.ToBase64Encode()), + New JProperty("prueba", (Not TimbraProduccion).ToString().ToLower), + New JProperty("opciones", New String(0) {""}) + ) + Respuesta = EnviarInformacionPADE("https://timbrado.pade.mx/servicio/rest/timbrado/timbrarConCSD", payload.ToString(), TokenAuth) + End If ' Aumentamos el timeout de la operación If Not String.IsNullOrEmpty(Respuesta) Then @@ -2722,8 +2894,8 @@ Public Class Timbrado If result IsNot Nothing Then If result.timbradoOk Then Dim FolioFiscal As String = result.UUID - - cfdi.EscribirXML(cfdi.Xml, RutaArchivo, NombreArchivoXML) + 'GUARDA EL XML RETORNADO POR EL PAC + cfdi.EscribirXML(result.xmlBase64.ToBase64Decode(), RutaArchivo, NombreArchivoXML) If ObjCFDITimbre.Comprobante.TipoComprobante <> "P" Then @@ -2786,14 +2958,13 @@ Public Class Timbrado Retorno = "" Else If String.IsNullOrEmpty(result.mensaje) Then - Retorno = Respuesta + Retorno = Respuesta + msgErrorGeneracion MensajeErrorCFDI = "" Else Retorno = result.mensaje MensajeErrorCFDI = result.codigo If cfdi.Xml <> "" Then cfdi.EscribirXML(cfdi.Xml, RutaArchivo, NombreArchivoXML) End If - End If Else If String.IsNullOrEmpty(Respuesta) Then @@ -2805,12 +2976,22 @@ Public Class Timbrado End If End If Else - Retorno = "Ocurrió un error al obtener la respuesta" - MensajeErrorCFDI = "" + If String.IsNullOrEmpty(msgErrorGeneracion) Then + Retorno = "Ocurrió un error al obtener la respuesta" + MensajeErrorCFDI = "" + Else + Retorno = msgErrorGeneracion + MensajeErrorCFDI = "" + End If End If Else - Retorno = "Ocurrió un error al generar el xml" - MensajeErrorCFDI = "" + If String.IsNullOrEmpty(msgErrorGeneracion) Then + Retorno = "Ocurrió un error al generar el xml" + MensajeErrorCFDI = "" + Else + Retorno = msgErrorGeneracion + MensajeErrorCFDI = "" + End If End If #End Region @@ -2854,6 +3035,10 @@ Public Class Timbrado Public Property mensaje As String Public Property UUID As String + + Public Property FechaTimbrado As DateTime + + Public Property xmlBase64 As String End Class @@ -2907,9 +3092,13 @@ Public Class Timbrado UsuarioServicio = "fgomez" ClaveServicio = "12121212" Clave = "12345678a" - EmisorRFC = "AAA010101AAA" - ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" - ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + 'EmisorRFC = "AAA010101AAA" + 'ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" + 'ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + EmisorRFC = "ZUÑ920208KL4" + ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.key" + ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.cer" + UrlServicio = "http://generacfdi.com.mx/rvltimbrado/service1.asmx?WSDL" '"http://108.60.211.43/rvltimbrado/service1.asmx" End If From 8252d8365b2147c097ccc755643f01f3f0bf641f Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 1 Jun 2021 11:02:31 -0700 Subject: [PATCH 04/15] Cambios estatus de trayectos --- Ashx/SIGPolizaVirtual.ashx | 283 +++++++++++++++++++++++++++++++++++- GPS/TrayectoDetalle.aspx | 12 +- GPS/TrayectoDetalle.aspx.vb | 61 +++++++- GPS/Trayectos.aspx | 34 +++++ GPS/Trayectos.aspx.vb | 12 +- 5 files changed, 389 insertions(+), 13 deletions(-) diff --git a/Ashx/SIGPolizaVirtual.ashx b/Ashx/SIGPolizaVirtual.ashx index 1ea9302b0..5119765e9 100644 --- a/Ashx/SIGPolizaVirtual.ashx +++ b/Ashx/SIGPolizaVirtual.ashx @@ -3,6 +3,7 @@ Imports Fluent Imports System Imports System.Web +Imports System.Net Imports System.Net.Http Imports System.Web.Http Imports System.Data @@ -11,6 +12,9 @@ Imports Newtonsoft.Json.Linq Imports Extensiones Imports System.IO Imports System.Runtime.CompilerServices +Imports System.Xml +Imports System.Xml.Serialization +Imports System.Linq Public Class SIGPolizaVirtual : Implements IHttpHandler, IRequiresSessionState @@ -56,11 +60,19 @@ Public Class SIGPolizaVirtual : Implements IHttpHandler, IRequiresSessionState #End Region Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest - context.Response.ContentType = "application/json" + context.Response.ContentType = "application/xml" Dim UsuarioActual = ValidaUsuarioSistema(1, 100) 'Dim ObjFactura As New Modelos.Factura(usuario, 898028, 140) + CancelarFacturaPADE(context, UsuarioActual) + + + End Sub + + + Private Sub TimbrarFacturaPADE(ByVal context As HttpContext, UsuarioActual As Usuario) + Dim UsuarioServicio As String = "rene.molina@adssistemas.mx" Dim ClaveServicio As String = "Facturacion2021#" @@ -125,11 +137,189 @@ Public Class SIGPolizaVirtual : Implements IHttpHandler, IRequiresSessionState New JProperty("opciones", New String(0) {""}) ) - Dim resp = EnviarInformacionPADE("https://timbrado.pade.mx/servicio/rest/timbrado/timbrarConCSD", payload.ToString(), TokenAuth) + Dim Respuesta = EnviarInformacionPADE("https://timbrado.pade.mx/servicio/rest/timbrado/timbrarConCSD", payload.ToString(), TokenAuth) - context.Response.Write(resp) + If Not String.IsNullOrEmpty(Respuesta) Then + Dim result As PADEServicioTimbradoResp = Nothing + Dim serializer As XmlSerializer = New XmlSerializer(GetType(PADEServicioTimbradoResp)) + + Try + Using reader As TextReader = New StringReader(Respuesta) + result = CType(serializer.Deserialize(reader), PADEServicioTimbradoResp) + End Using + Catch ex As Exception + OnError("Ocurrió un error al obtener los resultados", ex) + End Try + + If result IsNot Nothing Then + Dim xmlGuardar = result.xmlBase64.ToBase64Decode() + context.Response.Write(xmlGuardar) + Else + context.Response.Write(Respuesta) + End If + Else + context.Response.Write(Respuesta) + End If End Sub + Private Sub CancelarFacturaPADE(ByVal context As HttpContext, UsuarioActual As Usuario) + + Dim UsuarioServicio As String = "rene.molina@adssistemas.mx" + Dim ClaveServicio As String = "Facturacion2021#" + + Dim EmisorRFC As String = "ZUÑ920208KL4" + Dim ArchivoLLave As String = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.key" + Dim ArchivoCertificado As String = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.cer" + Dim Clave = "12345678a" + Dim TimbraProduccion = False + + If Not File.Exists(ArchivoCertificado) Then + context.Response.Write("El archivo de llave privada no existe") + Exit Sub + End If + If Not File.Exists(ArchivoLLave) Then + context.Response.Write("El archivo de llave privada no existe") + Exit Sub + End If + If UsuarioActual.Empresa.ContraseñaKey = "" Then + context.Response.Write("La clave no puede ser vacía") + Exit Sub + End If + + Dim llaveByte As Byte(), certByte As Byte() + Dim llaveBase64 As String = "", certBase64 As String = "" + Dim cfdi As New GoFac.GoCfdi() + Dim complemento As String = "" + Dim complementoConcepto As String = "" + + + Try + llaveByte = System.IO.File.ReadAllBytes(ArchivoLLave) + llaveBase64 = Convert.ToBase64String(llaveByte) + Catch ex As Exception + context.Response.Write($"Error al leer la llave privada: {ex.Message}") + Exit Sub + End Try + + + Try + certByte = System.IO.File.ReadAllBytes(ArchivoCertificado) + certBase64 = Convert.ToBase64String(certByte) + Catch ex As Exception + context.Response.Write($"Error al leer el certificado: {ex.Message}") + Exit Sub + End Try + + Dim TokenAuth As String = ToBase64Encode($"{UsuarioServicio}:{ClaveServicio}") + + Dim Contrato As String = "72330711-cac6-4106-8051-cbcda1aef495" + + Dim FolioFiscal As String = "9A46AD71-560B-4048-8B40-80ADC57C1CDC" + + 'Dim Respuesta As String = EnviarInformacionCancelacionPADE("https://timbrado.pade.mx/servicio/rest/cancelacion/cancelar", TokenAuth, Contrato, EmisorRFC, certBase64, llaveBase64, Clave, FolioFiscal) + + 'context.Response.Write(Respuesta) + + Dim Respuesta As String = EnviarInformacionCancelacionPADESOAP("https://timbrado.pade.mx/servicio/Timbrado3.3?wsdl", UsuarioServicio, ClaveServicio, Contrato, EmisorRFC, certBase64, llaveBase64, Clave, FolioFiscal, TimbraProduccion) + + If Not String.IsNullOrEmpty(Respuesta) Then + Dim result As PADEServicioCancelacionResp = Nothing + Dim serializer As XmlSerializer = New XmlSerializer(GetType(PADEServicioCancelacionResp)) + + Try + Using reader As TextReader = New StringReader(Respuesta) + result = CType(serializer.Deserialize(reader), PADEServicioCancelacionResp) + End Using + Catch ex As Exception + OnError("Ocurrió un error al obtener los resultados", ex) + End Try + + If result IsNot Nothing Then + context.Response.ContentType = "application/json" + context.Response.Write(JsonConvert.SerializeObject(result)) + Else + context.Response.Write(Respuesta) + End If + Else + context.Response.Write(Respuesta) + End If + + 'Dim arrayFolioFiscal = New String(0) {FolioFiscal} + 'Dim arrayOpciones = New List(Of String) + 'If Not TimbraProduccion Then + ' arrayOpciones.Add("MODO_PRUEBA:1") + 'End If + + 'Dim pade = New PADE33.PadeTimbradoServiceClient() + + 'Dim Res = pade.cancelarConOpciones(Contrato, UsuarioServicio, ClaveServicio, EmisorRFC, arrayFolioFiscal, certByte, llaveByte, Clave, arrayOpciones.ToArray()) + + 'context.Response.Write(Res) + End Sub + + + Private Function EnviarInformacionCancelacionPADESOAP(ByVal url As String, UsuarioServicio As String, PassServicio As String, contrato As String, rfcEmisor As String, + certBase64 As String, keyBase64 As String, keyPass As String, arregloUUID As String, TimbraProduccion As Boolean) As String + Dim retorno = "" + Try + + Dim request As HttpWebRequest = CType(WebRequest.Create($"{url}"), HttpWebRequest) + 'request.Headers.Add("SOAPAction:http://tempuri.org/TestCfd33 ") + request.ContentType = "text/xml;charset=""utf-8""" + request.Accept = "text/xml" + request.Method = "POST" + + Dim XMLString As String = $" + + + {contrato} + {UsuarioServicio} + {PassServicio} + {rfcEmisor} + {arregloUUID} + {certBase64} + {keyBase64} + {keyPass} + {If(TimbraProduccion, "", "MODO_PRUEBA:3")} + + + " + + Dim SOAPReqBody As XmlDocument = New XmlDocument() + SOAPReqBody.LoadXml(XMLString) + + Using stream As Stream = request.GetRequestStream() + SOAPReqBody.Save(stream) + End Using + + Dim response As String = "" + + Using Serviceres As WebResponse = request.GetResponse() + Using rd As StreamReader = New StreamReader(Serviceres.GetResponseStream()) + response = rd.ReadToEnd() + End Using + End Using + + If Not String.IsNullOrEmpty(response) Then + Dim xmlRetorno = New XmlDocument() + xmlRetorno.LoadXml(response) + Dim elemList As XmlNodeList = xmlRetorno.GetElementsByTagName("return") + + If elemList.Count > 0 Then + If elemList(0).ChildNodes.Count > 0 Then + retorno = elemList(0).ChildNodes(0).Value + End If + End If + + End If + + Catch ex As Exception + retorno = "" + OnError("Ocurrió un error al cancelar", ex) + End Try + + Return retorno + End Function Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get @@ -159,6 +349,46 @@ Public Class SIGPolizaVirtual : Implements IHttpHandler, IRequiresSessionState End Function + Private Function EnviarInformacionCancelacionPADE(url As String, tokenAuth As String, contrato As String, rfcEmisor As String, + certBase64 As String, keyBase64 As String, keyPass As String, arregloUUID As String) As String + Dim Retorno As String = "" + Try + Dim urlParametros As String = String.Format("contrato={0}&rfcEmisor={1}&certBase64={2}&keyBase64={3}&keyPass={4}&arregloUUID={5}&opciones={6}", contrato, rfcEmisor, certBase64, keyBase64, keyPass, arregloUUID, "MODO_PRUEBA:1") + + Dim urlRequest As String = String.Format("{0}?{1}", url, urlParametros) + + Using httpClient = New HttpClient() + httpClient.Timeout = New TimeSpan(0, 1, 0) + Using request = New HttpRequestMessage(HttpMethod.Post, New Uri(urlRequest)) + request.Headers.Add("Authorization", $"Basic {tokenAuth}") + + Dim response = httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).Result + Retorno = response.Content.ReadAsStringAsync().Result + 'Dim Parametros = New List(Of KeyValuePair(Of String, String)) + + 'Parametros.Add(New KeyValuePair(Of String, String)("contrato", contrato)) + 'Parametros.Add(New KeyValuePair(Of String, String)("rfcEmisor", rfcEmisor)) + 'Parametros.Add(New KeyValuePair(Of String, String)("certBase64", certBase64)) + 'Parametros.Add(New KeyValuePair(Of String, String)("keyBase64", keyBase64)) + 'Parametros.Add(New KeyValuePair(Of String, String)("keyPass", keyPass)) + 'Parametros.Add(New KeyValuePair(Of String, String)("arregloUUID", arregloUUID)) + + 'Using content = New FormUrlEncodedContent(Parametros) + ' request.Content = content + + + 'End Using + + End Using + End Using + Catch ex As Exception + Retorno = "" + OnError("Ocurrió un error al enviar la informacion", ex) + End Try + Return Retorno + End Function + + Public Function ToBase64Encode(ByVal plainText As String) As String Dim plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText) Return System.Convert.ToBase64String(plainTextBytes) @@ -170,6 +400,53 @@ Public Class SIGPolizaVirtual : Implements IHttpHandler, IRequiresSessionState Return System.Text.Encoding.UTF8.GetString(base64EncodedBytes) End Function + + Public Class PADEServicioTimbradoResp + + Public Property id As String + + Public Property timbradoOk As Boolean + + Public Property contrato As String + + Public Property codigo As String + + Public Property mensaje As String + + Public Property UUID As String + + Public Property FechaTimbrado As DateTime + + Public Property xmlBase64 As String + End Class + + + Public Class PADEServicioCancelacionResp + + Public Property statusOk As Boolean + + Public Property codigo As String + + Public Property mensaje As String + + Public Property procesados As Integer + + Public Property cancelados As Integer + + + Public Property cancelaciones As List(Of PADECancelacion) + End Class + + + Public Class PADECancelacion + + Public Property uuid As String + + Public Property codigo As String + + Public Property mensaje As String + End Class + Public Property XMLPrueba As String = "" diff --git a/GPS/TrayectoDetalle.aspx b/GPS/TrayectoDetalle.aspx index a10fc8071..c977aaab9 100644 --- a/GPS/TrayectoDetalle.aspx +++ b/GPS/TrayectoDetalle.aspx @@ -644,7 +644,10 @@ }, 250); } - function creaPoligono(coords, color, Geocerca, Estatus, InicioFin, CveEstatus, CveEstatusAnterior, cruzo) { + var geoReferenciaSeguir = ''; + var estatusSiguiente = ''; + + function creaPoligono(coords, color, Geocerca, Estatus, InicioFin, CveEstatus, CveEstatusAnterior, cruzo, geocercaASeguir, estatusaSeguir) { var polygon = new google.maps.Polygon({ paths: coords, strokeColor: color, @@ -656,6 +659,11 @@ polygon.setMap(map); polygons.push(polygon); + if (geocercaASeguir != '') { + geoReferenciaSeguir = geocercaASeguir; + estatusSiguiente = estatusaSeguir; + } + CreaMarcadorPoligono(coords, Geocerca, Estatus, InicioFin, CveEstatus, CveEstatusAnterior, cruzo) } @@ -935,7 +943,7 @@ } } - LblETA.innerText = formatETA(duracionTotal); + LblETA.innerHTML = formatETA(duracionTotal) + '
Geocerca: ' + geoReferenciaSeguir + '.
Estatus: ' + estatusSiguiente; }) .catch((error) => { alert('Error:' + error); diff --git a/GPS/TrayectoDetalle.aspx.vb b/GPS/TrayectoDetalle.aspx.vb index dc4fc125d..7153f6f10 100644 --- a/GPS/TrayectoDetalle.aspx.vb +++ b/GPS/TrayectoDetalle.aspx.vb @@ -50,6 +50,15 @@ Partial Class GPS_TrayectoDetalle ViewState("CveEstatusActual") = value End Set End Property + + Private Property OrdenActual As Integer + Get + Return CType(ViewState("OrdenActual"), Integer) + End Get + Set(value As Integer) + ViewState("OrdenActual") = value + End Set + End Property #End Region @@ -148,6 +157,7 @@ Partial Class GPS_TrayectoDetalle LblTitulo.Text = $"Trayecto: {RowEstatus("Trayecto")}" LtlEstatusActual.Text = RowEstatus("Estatus").ToString() CveEstatusActual = RowEstatus("CveEstatusActual").ToString().ToEntero() + OrdenActual = RowEstatus("OrdenActual").ToString().ToEntero() If CBool(RowEstatus("EsFin")) Then BtnTerminarTrayeto.Visible = False @@ -158,7 +168,7 @@ Partial Class GPS_TrayectoDetalle LtlDispositivo.Text = RowEstatus("Vehiculo").ToString() LtlFechaI.Text = If(String.IsNullOrEmpty(RowEstatus("FechaInicio").ToString()), "No ha ingresado a la geocerca de inicio", String.Format("{0:dd/MM/yyyy HH:mm tt}", RowEstatus("FechaInicio").ToString().ToDateTime())) - LtlFechaF.Text = If(String.IsNullOrEmpty(RowEstatus("FechaFin").ToString()), "No ha Terminado", String.Format("{0:dd/MM/yyyy HH:mm tt}", RowEstatus("FechaFin").ToString().ToDateTime())) + LtlFechaF.Text = If(String.IsNullOrEmpty(RowEstatus("FechaFin").ToString()), "No ha terminado", String.Format("{0:dd/MM/yyyy HH:mm tt}", RowEstatus("FechaFin").ToString().ToDateTime())) LtlVMedia.Text = String.Format("{0:N2} KM/H", RowEstatus("VMedia")) LtlVMax.Text = String.Format("{0:N2} KM/H", RowEstatus("VMax")) LtlTiempo.Text = String.Format("{0}", RowEstatus("TiempoOperativo")) @@ -214,18 +224,41 @@ Partial Class GPS_TrayectoDetalle Dim CoordAnterior As String = "" Dim CveEstatus As Integer = -1 Dim CveEstatusAnterior As Integer = -1 + Dim GeoreferenciaASeguir As String = "" + Dim EstatusSiguiente As String = "" + Dim OrdenEstatus As Integer = 0 + 'GEOCERCAS For Each Row As DataRow In DtGeocercas.Rows count += 1 Coord = SQLToGmaps(Row("Geom").ToString, "POLYGON") CveEstatus = Row("CveEstatusTrayecto").ToString.ToEntero CveEstatusAnterior = Row("CveEstatusAnterior").ToString.ToEntero + OrdenEstatus = Row("OrdenEstatus").ToString.ToEntero + Dim EsInicio As Boolean = CBool(IfNull(Row("EsInicio"), 0)) Dim EsFin As Boolean = CBool(IfNull(Row("EsFin"), 0)) Dim InicioFin As Integer = If(EsInicio, 1, If(EsFin, 2, 0)) Dim Cruzo As String = IfNull(Row("Cruzo"), "0").ToString() - RegistraScript($"creaPoligono({Coord}, '{Row("Color").ToString}', '{Row("GeoReferencia")}', '{Row("EstatusTrayecto")}',{InicioFin},{CveEstatus},{CveEstatusAnterior},{Cruzo})", count.ToString()) + 'MARCA PARA QUE NO CALCULE EL TIEMPO DE LAS GEOCERCAS RESTANTES + If Not String.IsNullOrEmpty(GeoreferenciaASeguir) Then + Cruzo = "1" + End If + + 'VERIFICA SI SE ACTUALIZO MANUALMENTE + If Cruzo = "0" Then + If OrdenEstatus <= OrdenActual Then + Cruzo = "1" + End If + End If + + If Cruzo = "0" Then + GeoreferenciaASeguir = Row("GeoReferencia").ToString() + EstatusSiguiente = Row("EstatusTrayecto").ToString() + End If + + RegistraScript($"creaPoligono({Coord}, '{Row("Color").ToString}', '{Row("GeoReferencia")}', '{Row("EstatusTrayecto")}',{InicioFin},{CveEstatus},{CveEstatusAnterior},{Cruzo},'{GeoreferenciaASeguir}','{EstatusSiguiente}')", count.ToString()) Next End If @@ -324,11 +357,16 @@ Partial Class GPS_TrayectoDetalle Dim ObjGPS As New ClsGPS Try - If ObjGPS.GetEstatusTrayectos(-1, UsuarioActual.CveCliente) Then - DtEstatus = ObjGPS.DtResultados.Copy() + Dim CveEstatusFinal As Integer = -1 + If ObjGPS.GetTrayectosGeoReferencias(CveTrayecto) Then + 'TOMA LA GEOCERCA FINAL + Dim Row As DataRow = ObjGPS.DtResultados.FiltroPrimero($"EsFin = True") + If Row IsNot Nothing Then + CveEstatusFinal = Row("CveEstatusTrayecto").ToString().ToEntero() + End If + End If - Dim CveEstatusFinal As Integer = DtEstatus.FiltroPrimeroValor("CveEstatusTrayecto", "EsFin = True").ToEntero() If CveEstatusFinal > 0 Then If ObjGPS.UpdateTrayectoEstatus(CveTrayecto, CveEstatusFinal) Then Alert("El trayecto se finalizo correctamente", JSBtnAceptar:="RefrescarPagina();", ShowCloseButton:=False) @@ -336,6 +374,19 @@ Partial Class GPS_TrayectoDetalle Else Alert("No se pudo obtener el estatus final", TipoMensaje.MsgError) End If + + 'If ObjGPS.GetEstatusTrayectos(-1, UsuarioActual.CveCliente) Then + ' DtEstatus = ObjGPS.DtResultados.Copy() + 'End If + + 'Dim CveEstatusFinal As Integer = DtEstatus.FiltroPrimeroValor("CveEstatusTrayecto", "EsFin = True").ToEntero() + 'If CveEstatusFinal > 0 Then + ' If ObjGPS.UpdateTrayectoEstatus(CveTrayecto, CveEstatusFinal) Then + ' Alert("El trayecto se finalizo correctamente", JSBtnAceptar:="RefrescarPagina();", ShowCloseButton:=False) + ' End If + 'Else + ' Alert("No se pudo obtener el estatus final", TipoMensaje.MsgError) + 'End If Catch ex As Exception OnError("Ocurrió un error al actualizar el trayecto", ex) End Try diff --git a/GPS/Trayectos.aspx b/GPS/Trayectos.aspx index 89eba625b..c07974719 100644 --- a/GPS/Trayectos.aspx +++ b/GPS/Trayectos.aspx @@ -322,6 +322,40 @@ +
+ Notificar: + +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + + + + + +
+
+
+
+ Enviar Liga: + +
+
+
+
+
" style="display: inline-block; margin-right: -20px; width: 150px;" /> diff --git a/GPS/Trayectos.aspx.vb b/GPS/Trayectos.aspx.vb index cfae9a0d3..e473a0319 100644 --- a/GPS/Trayectos.aspx.vb +++ b/GPS/Trayectos.aspx.vb @@ -113,8 +113,8 @@ Partial Class GPS_Trayectos Dim ObjGPS As New ClsGPS If ObjGPS.GetEstatusTrayectos(-1, UsuarioActual.CveCliente) Then GvEstatus.DataSource = ObjGPS.DtResultados.FiltraParametros("CveCliente > 0") - GvEstatusNuevo.DataSource = ObjGPS.DtResultados - DdlEstatusTrayecto.DataSource = ObjGPS.DtResultados + GvEstatusNuevo.DataSource = ObjGPS.DtResultados.FiltraParametros("CveCliente > 0") + DdlEstatusTrayecto.DataSource = ObjGPS.DtResultados.FiltraParametros("CveCliente > 0") End If ObjGPS.Dispose() GvEstatus.DataBind() @@ -237,7 +237,9 @@ Partial Class GPS_Trayectos Dim Nombre As String = TxtNombreNuevo.Text Dim CveDispositivo As Integer = DdlDispositivoNuevo.SelectedValue.ToEntero If CveDispositivo > 0 Then - Dim CveTrayectoNuevo As Integer = ObjGPS.AddTrayecto(Nombre, DateTime.Now, "", CveDispositivo, UsuarioActual.CveCliente) + Dim CveTrayectoNuevo As Integer = ObjGPS.AddTrayecto(Nombre, DateTime.Now, "", CveDispositivo, UsuarioActual.CveCliente, EnviarNotificacion:=ChkNotificarApartirDe.Checked, + CorreosNotificacion:=TxtCorreNotApartidDe.Text, Intervalo:=If(ChkNotificarApartirDe.Checked, DdlIntervaloAPartirDe.SelectedValue.ToEntero(), 0), + EnviarLiga:=ChkEnviarLigaApartirDe.Checked) If CveTrayectoNuevo > 0 Then For Each Row As GridViewRow In GvEstatusNuevo.Rows If Row.RowType = DataControlRowType.DataRow Then @@ -413,6 +415,10 @@ Partial Class GPS_Trayectos DivNotificaciones.Visible = ChkNotificacion.Checked UpAgregar.Update() End Sub + Protected Sub ChkNotificacionApartirDe_CheckedChanged(sender As Object, e As EventArgs) + DivNotificarApartirDe.Visible = ChkNotificarApartirDe.Checked + UpDdlTrayecto.Update() + End Sub Protected Sub LnkEnviar_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) From 5edf6c69bc7c55fdf050abc6d97a62c00b183499 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 1 Jun 2021 11:03:00 -0700 Subject: [PATCH 05/15] Descarga de Reporte Diario en Excel E141 --- Ventas/RepPS.aspx | 61 ++++--- Ventas/RepPS.aspx.vb | 424 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 444 insertions(+), 41 deletions(-) diff --git a/Ventas/RepPS.aspx b/Ventas/RepPS.aspx index 1d4e762d4..7c3aeed05 100644 --- a/Ventas/RepPS.aspx +++ b/Ventas/RepPS.aspx @@ -67,6 +67,9 @@
  • Excel
  • +
  • + Reporte Diario +
  • @@ -134,33 +137,32 @@
    - + + +
    @@ -180,7 +182,7 @@
    --%> -
    + @@ -190,14 +192,13 @@ - + - - - + + diff --git a/Ventas/RepPS.aspx.vb b/Ventas/RepPS.aspx.vb index 66fb8aea5..5ae077225 100644 --- a/Ventas/RepPS.aspx.vb +++ b/Ventas/RepPS.aspx.vb @@ -4,10 +4,12 @@ Option Strict On Imports Extensiones Imports System.Data Imports Microsoft.Reporting.WebForms - +Imports GemBox.Spreadsheet +Imports System.Globalization + Partial Class Ventas_RepPS - Inherits ClsPaginas - + Inherits ClsPaginas + #Region "P R O P I E D A D E S" Private Property DtReporte As DataTable Get @@ -16,9 +18,9 @@ Partial Class Ventas_RepPS Set(value As DataTable) ViewState("DtReporte") = value End Set - End Property + End Property #End Region - + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then pnlOrden.Visible = False @@ -34,6 +36,10 @@ Partial Class Ventas_RepPS 'DdlMarca.Items.Insert(0, New ListItem("Todos", "-1")) End If + If UsuarioActual.TienePermisoProceso(320) Then + LnkRepDiario.Visible = True + End If + CargaDatosIniciales() CargaCombos() @@ -179,9 +185,9 @@ Partial Class Ventas_RepPS End Sub Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) CargaDatos() - End Sub - - + End Sub + + #Region " IMPRIMIR " Protected Sub LnkPdf_Click(sender As Object, e As EventArgs) Handles LnkPdf.Click If GvDatos.Rows.Count > 0 Then @@ -227,8 +233,404 @@ Partial Class Ventas_RepPS Alert("No hay información para mostrar.", TipoMensaje.MsgAdvertencia) End If - End Sub - + End Sub + #End Region - + + Protected Sub LnkRepDiario_Click(sender As Object, e As EventArgs) + Dim CveMoneda As Integer = -1 + Dim TC As Integer = 1 + Dim TCEspecifico As Decimal = -1 + + Dim DataSet As DataSet = New DataSet + Dim ObjVentas As New ClsVentas() + If ObjVentas.GetRepPSDiario(-1, -1, Now, UsuarioActual.CveEmpresa, CveUsuarioConsulta:=UsuarioActual.CveUsuario, GPO:=-1, CveMoneda:=CveMoneda, TipoCambio:=TC, TCEspecifico:=TCEspecifico) Then + DataSet = ObjVentas.DataSetResultados.Copy() + End If + ObjVentas.Dispose() + + If DataSet IsNot Nothing Then + SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) + + Dim FileExcel As New ExcelFile() + + Dim worksheetName As String = $"{ToShortMonthName(Now).ToUpper()}{Now.Day}" + Const invalidCharsRegex As String = "[/\\*'?[\]:]+" + Const maxLength As Integer = 31 + Dim safeName As String = Regex.Replace(worksheetName, invalidCharsRegex, " ").Replace(" ", " ").Trim() + + If String.IsNullOrEmpty(safeName) Then + safeName = "RepPSDiario" ' cannot be empty + ElseIf safeName.Length > maxLength Then + safeName = safeName.Substring(0, maxLength) + End If + + Dim worksheet = FileExcel.Worksheets.Add(safeName) + + Dim CellRangeTitulo = worksheet.Cells.GetSubrangeAbsolute(0, 0, 0, 12) + CellRangeTitulo.Merged = True + CellRangeTitulo.Value = $"{UsuarioActual.Empresa.Empresa}. VENTA DEL DIA {Now.Day} DE {ToMonthName(Now).ToUpper()} DEL {Now.Year}." + CellRangeTitulo.Style.VerticalAlignment = VerticalAlignmentStyle.Center + CellRangeTitulo.Style.HorizontalAlignment = HorizontalAlignmentStyle.Center + +#Region "V E N T A S - L L A N T A S, R I N E S, A L I N E A C I O N E S" + worksheet.Cells(2, 0).Value = "Sucursal" + 'TITULO DE LLANTAS + worksheet.Cells.GetSubrangeAbsolute(1, 1, 1, 3).Merged = True + worksheet.Cells(1, 3).Value = "LLANTAS" + worksheet.Cells(2, 1).Value = "Ant" + worksheet.Cells(2, 2).Value = "Dia" + worksheet.Cells(2, 3).Value = "Acum" + 'TITULO DE RINES + worksheet.Cells.GetSubrangeAbsolute(1, 4, 1, 6).Merged = True + worksheet.Cells(1, 6).Value = "RINES" + worksheet.Cells(2, 4).Value = "Ant" + worksheet.Cells(2, 5).Value = "Dia" + worksheet.Cells(2, 6).Value = "Acum" + 'TITULO DE ALINEACIONES + worksheet.Cells.GetSubrangeAbsolute(1, 7, 1, 9).Merged = True + worksheet.Cells(1, 9).Value = "ALINEACIONES" + worksheet.Cells(2, 7).Value = "Ant" + worksheet.Cells(2, 8).Value = "Dia" + worksheet.Cells(2, 9).Value = "Acum" + 'TITULO DE VENTAS DEL DIA + worksheet.Cells.GetSubrangeAbsolute(1, 10, 1, 12).Merged = True + worksheet.Cells(1, 12).Value = "VENTA EN PESOS" + worksheet.Cells(2, 10).Value = "Ant" + worksheet.Cells(2, 11).Value = "Dia" + worksheet.Cells(2, 12).Value = "Acum" + + Dim StyleTitleTable1 = worksheet.Cells.GetSubrangeAbsolute(1, 1, 1, 12).Style + StyleTitleTable1.Font.Weight = ExcelFont.BoldWeight + StyleTitleTable1.Font.Name = "Calibri" + StyleTitleTable1.Font.Size = 8 * 20 + StyleTitleTable1.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleTitleTable1.VerticalAlignment = VerticalAlignmentStyle.Center + StyleTitleTable1.HorizontalAlignment = HorizontalAlignmentStyle.Center + + Dim StyleSubTitleTable1 = worksheet.Cells.GetSubrangeAbsolute(2, 0, 2, 12).Style + StyleSubTitleTable1.Font.Weight = ExcelFont.BoldWeight + StyleSubTitleTable1.Font.Name = "Calibri" + StyleSubTitleTable1.Font.Size = 8 * 20 + StyleSubTitleTable1.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleSubTitleTable1.VerticalAlignment = VerticalAlignmentStyle.Center + StyleSubTitleTable1.HorizontalAlignment = HorizontalAlignmentStyle.Center + + Dim DtSucursalesLLantasAlin As DataTable = DataSet.Tables(0) + + 'INICIA DESDE LA CUARTA FILA + Dim IdxSucursalesLlantasAlin As Integer = 3 + For Each Row As DataRow In DtSucursalesLLantasAlin.Rows + worksheet.Cells(IdxSucursalesLlantasAlin, 0).Value = Row("SubProyecto") + + worksheet.Cells(IdxSucursalesLlantasAlin, 1).Value = Row("LlantasCantidadAnterior") + worksheet.Cells(IdxSucursalesLlantasAlin, 2).Value = Row("LlantasCantidadDia") + 'worksheet.Cells(IdxSucursalesLlantasAlin, 3).Value = Row("LlantasCantidadAcumulada") + worksheet.Cells(IdxSucursalesLlantasAlin, 3).Formula = $"=SUM({worksheet.Cells(IdxSucursalesLlantasAlin, 1).Name}:{worksheet.Cells(IdxSucursalesLlantasAlin, 2).Name})" + + worksheet.Cells(IdxSucursalesLlantasAlin, 4).Value = Row("RinCantidadAnterior") + worksheet.Cells(IdxSucursalesLlantasAlin, 5).Value = Row("RinCantidadDia") + 'worksheet.Cells(IdxSucursalesLlantasAlin, 6).Value = Row("RinCantidadAcumulada") + worksheet.Cells(IdxSucursalesLlantasAlin, 6).Formula = $"=SUM({worksheet.Cells(IdxSucursalesLlantasAlin, 4).Name}:{worksheet.Cells(IdxSucursalesLlantasAlin, 5).Name})" + + worksheet.Cells(IdxSucursalesLlantasAlin, 7).Value = Row("AlinCantidadAnterior") + worksheet.Cells(IdxSucursalesLlantasAlin, 8).Value = Row("AlinCantidadDia") + 'worksheet.Cells(IdxSucursalesLlantasAlin, 9).Value = Row("AlinCantidadAcumulada") + worksheet.Cells(IdxSucursalesLlantasAlin, 9).Formula = $"=SUM({worksheet.Cells(IdxSucursalesLlantasAlin, 7).Name}:{worksheet.Cells(IdxSucursalesLlantasAlin, 8).Name})" + + worksheet.Cells(IdxSucursalesLlantasAlin, 10).Value = Row("VentaAnterior") + worksheet.Cells(IdxSucursalesLlantasAlin, 11).Value = Row("VentaDia") + 'worksheet.Cells(IdxSucursalesLlantasAlin, 12).Value = Row("VentaAcumulada") + worksheet.Cells(IdxSucursalesLlantasAlin, 12).Formula = $"=SUM({worksheet.Cells(IdxSucursalesLlantasAlin, 10).Name}:{worksheet.Cells(IdxSucursalesLlantasAlin, 11).Name})" + + Dim StyleData = worksheet.Cells.GetSubrangeAbsolute(IdxSucursalesLlantasAlin, 0, IdxSucursalesLlantasAlin, 12).Style + StyleData.Font.Weight = ExcelFont.BoldWeight + StyleData.Font.Name = "Calibri" + StyleData.Font.Size = 8 * 20 + StyleData.VerticalAlignment = VerticalAlignmentStyle.Center + StyleData.HorizontalAlignment = HorizontalAlignmentStyle.Center + StyleData.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleData.NumberFormat = "_-* #,##0.00_-;-* #,##0.00_-;_-* ""-""??_-;_-@_-" + + 'LAS VENTAS DEL DIA NO DEBEN ESTAR EN NEGRITAS + worksheet.Cells(IdxSucursalesLlantasAlin, 0).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxSucursalesLlantasAlin, 0).Style.HorizontalAlignment = HorizontalAlignmentStyle.Left + + worksheet.Cells(IdxSucursalesLlantasAlin, 2).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxSucursalesLlantasAlin, 5).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxSucursalesLlantasAlin, 8).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxSucursalesLlantasAlin, 11).Style.Font.Weight = ExcelFont.NormalWeight + + IdxSucursalesLlantasAlin += 1 + Next + 'LA FILA DE LOS TOTALES DEBE ESTAR EN NEGITAS + worksheet.Cells.GetSubrangeAbsolute(IdxSucursalesLlantasAlin - 1, 0, IdxSucursalesLlantasAlin - 1, 12).Style.Font.Weight = ExcelFont.BoldWeight + + DtSucursalesLLantasAlin.Dispose() +#End Region + +#Region "V E N T A S - S E R V I C I O S D E I N S T A L A C I O N, A M O R T I G U A D O R E S, P O L I Z A S" + Dim IdxRefSucursalesServiciosAmortPolizas As Integer = IdxSucursalesLlantasAlin + 3 + + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 0).Value = "Sucursal" + 'TITULO SERVICIOS DE INSTALACION + worksheet.Cells.GetSubrangeAbsolute(IdxRefSucursalesServiciosAmortPolizas - 1, 1, IdxRefSucursalesServiciosAmortPolizas - 1, 3).Merged = True + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas - 1, 3).Value = "SERVICIOS DE INSTALACION" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 1).Value = "Ant" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 2).Value = "Dia" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 3).Value = "Acum" + 'TITULO AMORTIGUADORES + worksheet.Cells.GetSubrangeAbsolute(IdxRefSucursalesServiciosAmortPolizas - 1, 4, IdxRefSucursalesServiciosAmortPolizas - 1, 6).Merged = True + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas - 1, 6).Value = "AMORTIGUADORES" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 4).Value = "Ant" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 5).Value = "Dia" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 6).Value = "Acum" + 'TITULO DE POLIZAS + worksheet.Cells.GetSubrangeAbsolute(IdxRefSucursalesServiciosAmortPolizas - 1, 7, IdxRefSucursalesServiciosAmortPolizas - 1, 9).Merged = True + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas - 1, 9).Value = "POLIZAS" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 7).Value = "Ant" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 8).Value = "Dia" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 9).Value = "Acum" + 'TITULO DE VENTAS DEL DIA + worksheet.Cells.GetSubrangeAbsolute(IdxRefSucursalesServiciosAmortPolizas - 1, 10, IdxRefSucursalesServiciosAmortPolizas - 1, 12).Merged = True + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas - 1, 12).Value = "MANO DE OBRA PESOS" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 10).Value = "Ant" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 11).Value = "Dia" + worksheet.Cells(IdxRefSucursalesServiciosAmortPolizas, 12).Value = "Acum" + + Dim StyleTitleTable2 = worksheet.Cells.GetSubrangeAbsolute(IdxRefSucursalesServiciosAmortPolizas - 1, 1, IdxRefSucursalesServiciosAmortPolizas - 1, 12).Style + StyleTitleTable2.Font.Weight = ExcelFont.BoldWeight + StyleTitleTable2.Font.Name = "Calibri" + StyleTitleTable2.Font.Size = 8 * 20 + StyleTitleTable2.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleTitleTable2.VerticalAlignment = VerticalAlignmentStyle.Center + StyleTitleTable2.HorizontalAlignment = HorizontalAlignmentStyle.Center + + Dim StyleSubTitleTable2 = worksheet.Cells.GetSubrangeAbsolute(IdxRefSucursalesServiciosAmortPolizas, 0, IdxRefSucursalesServiciosAmortPolizas, 12).Style + StyleSubTitleTable2.Font.Weight = ExcelFont.BoldWeight + StyleSubTitleTable2.Font.Name = "Calibri" + StyleSubTitleTable2.Font.Size = 8 * 20 + StyleSubTitleTable2.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleSubTitleTable2.VerticalAlignment = VerticalAlignmentStyle.Center + StyleSubTitleTable2.HorizontalAlignment = HorizontalAlignmentStyle.Center + + Dim DtSucursalesServiciosAmortPolizas As DataTable = DataSet.Tables(1) + + 'INICIA DESDE LA CUARTA FILA + Dim IdxSucursalesServiciosAmortPolizas As Integer = IdxRefSucursalesServiciosAmortPolizas + 1 + + For Each Row As DataRow In DtSucursalesServiciosAmortPolizas.Rows + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 0).Value = Row("SubProyecto") + + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 1).Value = Row("ServiciosCantidadAnterior") + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 2).Value = Row("ServiciosCantidadDia") + 'worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 3).Value = Row("ServiciosCantidadAcumulada") + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 3).Formula = $"=SUM({worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 1).Name}:{worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 2).Name})" + + + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 4).Value = Row("AmortCantidadAnterior") + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 5).Value = Row("AmortCantidadDia") + 'worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 6).Value = Row("AmortCantidadAcumulada") + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 6).Formula = $"=SUM({worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 4).Name}:{worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 5).Name})" + + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 7).Value = Row("PolizasCantidadAnterior") + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 8).Value = Row("PolizasCantidadDia") + 'worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 9).Value = Row("PolizasCantidadAcumulada") + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 9).Formula = $"=SUM({worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 7).Name}:{worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 8).Name})" + + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 10).Value = Row("VentaAnterior") + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 11).Value = Row("VentaDia") + 'worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 12).Value = Row("VentaAcumulada") + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 12).Formula = $"=SUM({worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 10).Name}:{worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 11).Name})" + + Dim StyleData = worksheet.Cells.GetSubrangeAbsolute(IdxSucursalesServiciosAmortPolizas, 0, IdxSucursalesServiciosAmortPolizas, 12).Style + StyleData.Font.Weight = ExcelFont.BoldWeight + StyleData.Font.Name = "Calibri" + StyleData.Font.Size = 8 * 20 + StyleData.VerticalAlignment = VerticalAlignmentStyle.Center + StyleData.HorizontalAlignment = HorizontalAlignmentStyle.Center + StyleData.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleData.NumberFormat = "_-* #,##0.00_-;-* #,##0.00_-;_-* ""-""??_-;_-@_-" + + 'LAS VENTAS DEL DIA NO DEBEN ESTAR EN NEGRITAS + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 0).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 0).Style.HorizontalAlignment = HorizontalAlignmentStyle.Left + + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 2).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 5).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 8).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxSucursalesServiciosAmortPolizas, 11).Style.Font.Weight = ExcelFont.NormalWeight + + IdxSucursalesServiciosAmortPolizas += 1 + Next + 'LA FILA DE LOS TOTALES DEBE ESTAR EN NEGITAS + worksheet.Cells.GetSubrangeAbsolute(IdxSucursalesServiciosAmortPolizas - 1, 0, IdxSucursalesServiciosAmortPolizas - 1, 12).Style.Font.Weight = ExcelFont.BoldWeight + + DtSucursalesServiciosAmortPolizas.Dispose() +#End Region + +#Region "P O R C E N T A J E S" + Dim IdxRefPorcentajes As Integer = IdxSucursalesServiciosAmortPolizas + 3 + + worksheet.Cells(IdxRefPorcentajes, 0).Value = "Sucursal" + 'TITULO SERVICIOS + worksheet.Cells.GetSubrangeAbsolute(IdxRefPorcentajes - 1, 1, IdxRefPorcentajes - 1, 2).Merged = True + worksheet.Cells(IdxRefPorcentajes - 1, 2).Value = "INSTALACION" + worksheet.Cells(IdxRefPorcentajes, 1).Value = "Cant" + worksheet.Cells(IdxRefPorcentajes, 2).Value = "%" + 'TITULO POLIZAS + worksheet.Cells.GetSubrangeAbsolute(IdxRefPorcentajes - 1, 3, IdxRefPorcentajes - 1, 4).Merged = True + worksheet.Cells(IdxRefPorcentajes - 1, 4).Value = "POLIZAS" + worksheet.Cells(IdxRefPorcentajes, 3).Value = "Cant" + worksheet.Cells(IdxRefPorcentajes, 4).Value = "%" + 'TITULO DE ALINEACIONES + worksheet.Cells.GetSubrangeAbsolute(IdxRefPorcentajes - 1, 5, IdxRefPorcentajes - 1, 6).Merged = True + worksheet.Cells(IdxRefPorcentajes - 1, 6).Value = "ALINEACIONES" + worksheet.Cells(IdxRefPorcentajes, 5).Value = "Cant" + worksheet.Cells(IdxRefPorcentajes, 6).Value = "%" + + + Dim StyleTitleTable3 = worksheet.Cells.GetSubrangeAbsolute(IdxRefPorcentajes - 1, 1, IdxRefPorcentajes - 1, 6).Style + StyleTitleTable3.Font.Weight = ExcelFont.BoldWeight + StyleTitleTable3.Font.Name = "Calibri" + StyleTitleTable3.Font.Size = 8 * 20 + StyleTitleTable3.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleTitleTable3.VerticalAlignment = VerticalAlignmentStyle.Center + StyleTitleTable3.HorizontalAlignment = HorizontalAlignmentStyle.Center + + Dim StyleSubTitleTable3 = worksheet.Cells.GetSubrangeAbsolute(IdxRefPorcentajes, 0, IdxRefPorcentajes, 6).Style + StyleSubTitleTable3.Font.Weight = ExcelFont.BoldWeight + StyleSubTitleTable3.Font.Name = "Calibri" + StyleSubTitleTable3.Font.Size = 8 * 20 + StyleSubTitleTable3.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleSubTitleTable3.VerticalAlignment = VerticalAlignmentStyle.Center + StyleSubTitleTable3.HorizontalAlignment = HorizontalAlignmentStyle.Center + + Dim DtPorcentajes As DataTable = DataSet.Tables(2) + + 'INICIA DESDE LA CUARTA FILA + Dim IdxPorcentajes As Integer = IdxRefPorcentajes + 1 + + For Each Row As DataRow In DtPorcentajes.Rows + worksheet.Cells(IdxPorcentajes, 0).Value = Row("SubProyecto") + + worksheet.Cells(IdxPorcentajes, 1).Value = Row("Servicios") + worksheet.Cells(IdxPorcentajes, 2).Value = Row("ServiciosPorcentaje") + + worksheet.Cells(IdxPorcentajes, 3).Value = Row("Polizas") + worksheet.Cells(IdxPorcentajes, 4).Value = Row("PolizasPorcentaje") + + worksheet.Cells(IdxPorcentajes, 5).Value = Row("Alineaciones") + worksheet.Cells(IdxPorcentajes, 6).Value = Row("AlinPorcentaje") + + Dim StyleData = worksheet.Cells.GetSubrangeAbsolute(IdxPorcentajes, 0, IdxPorcentajes, 6).Style + StyleData.Font.Weight = ExcelFont.BoldWeight + StyleData.Font.Name = "Calibri" + StyleData.Font.Size = 8 * 20 + StyleData.VerticalAlignment = VerticalAlignmentStyle.Center + StyleData.HorizontalAlignment = HorizontalAlignmentStyle.Center + StyleData.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleData.NumberFormat = "_-* #,##0.00_-;-* #,##0.00_-;_-* ""-""??_-;_-@_-" + + 'LAS VENTAS DEL DIA NO DEBEN ESTAR EN NEGRITAS + worksheet.Cells(IdxPorcentajes, 0).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxPorcentajes, 0).Style.HorizontalAlignment = HorizontalAlignmentStyle.Left + + worksheet.Cells(IdxPorcentajes, 1).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxPorcentajes, 3).Style.Font.Weight = ExcelFont.NormalWeight + worksheet.Cells(IdxPorcentajes, 5).Style.Font.Weight = ExcelFont.NormalWeight + + IdxPorcentajes += 1 + Next + 'LA FILA DE LOS TOTALES DEBE ESTAR EN NEGITAS + worksheet.Cells.GetSubrangeAbsolute(IdxPorcentajes - 1, 0, IdxPorcentajes - 1, 6).Style.Font.Weight = ExcelFont.BoldWeight + + DtPorcentajes.Dispose() +#End Region + +#Region "A Ñ O A N T E R I O R" + Dim IdxRefAnioAnteriorLlantas As Integer = IdxPorcentajes + 3 + + worksheet.Cells(IdxRefAnioAnteriorLlantas, 0).Value = "Sucursal" + worksheet.Cells(IdxRefAnioAnteriorLlantas, 1).Value = (Now.Year - 1).ToString() + worksheet.Cells(IdxRefAnioAnteriorLlantas, 2).Value = Now.Year.ToString() + worksheet.Cells(IdxRefAnioAnteriorLlantas, 3).Value = "Dif" + + Dim StyleTitleTable4 = worksheet.Cells.GetSubrangeAbsolute(IdxRefAnioAnteriorLlantas, 0, IdxRefAnioAnteriorLlantas, 3).Style + StyleTitleTable4.Font.Weight = ExcelFont.BoldWeight + StyleTitleTable4.Font.Name = "Calibri" + StyleTitleTable4.Font.Size = 8 * 20 + StyleTitleTable4.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleTitleTable4.VerticalAlignment = VerticalAlignmentStyle.Center + StyleTitleTable4.HorizontalAlignment = HorizontalAlignmentStyle.Center + + Dim DtAnioAnteriorLLantas As DataTable = DataSet.Tables(3) + 'INICIA DESDE LA CUARTA FILA + Dim IdxAnioAnteriorLlantas As Integer = IdxRefAnioAnteriorLlantas + 1 + + For Each Row As DataRow In DtAnioAnteriorLLantas.FiltraParametros("TipoFila > 1").Rows + worksheet.Cells(IdxAnioAnteriorLlantas, 0).Value = Row("Grupo") + worksheet.Cells(IdxAnioAnteriorLlantas, 1).Value = Row("LLantasAnioAnterior") + worksheet.Cells(IdxAnioAnteriorLlantas, 2).Value = Row("LLantas") + worksheet.Cells(IdxAnioAnteriorLlantas, 3).Formula = $"=({worksheet.Cells(IdxAnioAnteriorLlantas, 1).Name} - {worksheet.Cells(IdxAnioAnteriorLlantas, 2).Name})" + + + Dim StyleData = worksheet.Cells.GetSubrangeAbsolute(IdxAnioAnteriorLlantas, 0, IdxAnioAnteriorLlantas, 3).Style + StyleData.Font.Weight = ExcelFont.NormalWeight + StyleData.Font.Name = "Calibri" + StyleData.Font.Size = 8 * 20 + StyleData.VerticalAlignment = VerticalAlignmentStyle.Center + StyleData.HorizontalAlignment = HorizontalAlignmentStyle.Center + StyleData.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleData.NumberFormat = "_-* #,##0.00_-;-* #,##0.00_-;_-* ""-""??_-;_-@_-" + + If Row("TipoFila").ToString() = "2" Then + StyleData.Font.Weight = ExcelFont.BoldWeight + StyleData.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(255, 215, 0), SpreadsheetColor.FromArgb(255, 255, 255)) + End If + + IdxAnioAnteriorLlantas += 1 + Next + + For Each Row As DataRow In DtAnioAnteriorLLantas.FiltraParametros("TipoFila = 1").Rows + worksheet.Cells(IdxAnioAnteriorLlantas, 0).Value = Row("Grupo") + worksheet.Cells(IdxAnioAnteriorLlantas, 1).Value = Row("LLantasAnioAnterior") + worksheet.Cells(IdxAnioAnteriorLlantas, 2).Value = Row("LLantas") + worksheet.Cells(IdxAnioAnteriorLlantas, 3).Formula = $"=(+{worksheet.Cells(IdxAnioAnteriorLlantas, 1).Name} - {worksheet.Cells(IdxAnioAnteriorLlantas, 2).Name})" + + + Dim StyleData = worksheet.Cells.GetSubrangeAbsolute(IdxAnioAnteriorLlantas, 0, IdxAnioAnteriorLlantas, 3).Style + StyleData.Font.Weight = ExcelFont.BoldWeight + StyleData.Font.Name = "Calibri" + StyleData.Font.Size = 8 * 20 + StyleData.VerticalAlignment = VerticalAlignmentStyle.Center + StyleData.HorizontalAlignment = HorizontalAlignmentStyle.Center + StyleData.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleData.NumberFormat = "_-* #,##0.00_-;-* #,##0.00_-;_-* ""-""??_-;_-@_-" + StyleData.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromArgb(255, 215, 0), SpreadsheetColor.FromArgb(255, 255, 255)) + + IdxAnioAnteriorLlantas += 1 + Next + DtAnioAnteriorLLantas.Dispose() +#End Region + + Dim columnCount = worksheet.CalculateMaxUsedColumns() + + For i = 0 To columnCount + worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1)) + Next + + FileExcel.Save(Response, $"DIARIO_{Now.ToString("dd_MM_yyyy")}.xlsx", SaveOptions.XlsxDefault) + + End If + + End Sub + + Public Function ToMonthName(ByVal dateTime As DateTime) As String + Return New CultureInfo("es-MX").DateTimeFormat.GetMonthName(dateTime.Month) + End Function + + Public Function ToShortMonthName(ByVal dateTime As DateTime) As String + Return New CultureInfo("es-MX").DateTimeFormat.GetAbbreviatedMonthName(dateTime.Month) + End Function End Class From 9b1a3be20a1d8e6cfb5b57a0a5506e740e7a9e61 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 3 Jun 2021 17:42:41 -0700 Subject: [PATCH 06/15] Correcion de filtro de fechas en grupos --- Ventas/RepVentas.aspx.vb | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Ventas/RepVentas.aspx.vb b/Ventas/RepVentas.aspx.vb index c2bcf48ee..f681e842e 100644 --- a/Ventas/RepVentas.aspx.vb +++ b/Ventas/RepVentas.aspx.vb @@ -453,7 +453,21 @@ Partial Class Ventas_RepVentas FechaInicial = New DateTime(Anio, Mes, 1).ToString("dd/MM/yyyy") End If - FechaFinal = New DateTime(Anio, Mes, Dia).ToString("dd/MM/yyyy") + Dim FechaFinalRef = New DateTime(Anio, Mes, Dia) + + 'ASIGNAR LA FECHA FINAL DEL GRUPO, SI ES MENOR A LA FECHA DEL FILTRO + If FechaF <> "-1" Then + If FechaFRef < FechaFinalRef Then + FechaFinal = FechaFRef.ToString("dd/MM/yyyy") + Else + FechaFinal = FechaFinalRef.ToString("dd/MM/yyyy") + End If + Else + FechaFinal = FechaFinalRef.ToString("dd/MM/yyyy") + End If + + + End If Case 3 ' AÑO/MES @@ -479,7 +493,19 @@ Partial Class Ventas_RepVentas FechaInicial = New DateTime(Anio, Mes, 1).ToString("dd/MM/yyyy") End If - FechaFinal = New DateTime(Anio, Mes, Dia).ToString("dd/MM/yyyy") + Dim FechaFinalRef = New DateTime(Anio, Mes, Dia) + + 'ASIGNAR LA FECHA FINAL DEL GRUPO, SI ES MENOR A LA FECHA DEL FILTRO + If FechaF <> "-1" Then + If FechaFRef < FechaFinalRef Then + FechaFinal = FechaFRef.ToString("dd/MM/yyyy") + Else + FechaFinal = FechaFinalRef.ToString("dd/MM/yyyy") + End If + Else + FechaFinal = FechaFinalRef.ToString("dd/MM/yyyy") + End If + End If Case 4 ' FECHA From fc5c70142f1c2b88876d8ad4aca1b95e3b3d0b61 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 3 Jun 2021 17:43:18 -0700 Subject: [PATCH 07/15] Actualizar estatus de factura si esta vigente --- Ventas/RepCancelacionesPorRespuesta.aspx.cs | 27 ++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Ventas/RepCancelacionesPorRespuesta.aspx.cs b/Ventas/RepCancelacionesPorRespuesta.aspx.cs index 05451a07f..b17a3a246 100644 --- a/Ventas/RepCancelacionesPorRespuesta.aspx.cs +++ b/Ventas/RepCancelacionesPorRespuesta.aspx.cs @@ -176,7 +176,7 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas } sb.AppendFormat("Folio Fiscal: {0}
    ", uuid); - sb.AppendFormat("Codigo Estado: {0}
    ", resp.CodigoEstatus); + sb.AppendFormat("Código Estado: {0}
    ", resp.CodigoEstatus); sb.AppendFormat("Estado: {0}
    ", resp.Estado); sb.AppendFormat("Es Cancelable: {0}
    ", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EsCancelable); sb.AppendFormat("Estatus de Cancelación: {0}

    ", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EstatusCancelacion); @@ -225,6 +225,16 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas { retorno.EnviarAcuse = true; CveEstatus = respCancelacion.CveEstatus; + var ObjVentas = new ClsVentas(); + if (ObjVentas.UpdateEstatusVenta(CveVenta, CveEstatus, UsuarioActual.CveEmpresa)) + { + sb.Append("El estatus de la factura fue cambiado a 'Cancelada'."); + } + else + { + sb.Append("Ocurrió un error al cambiar el estatus de la factura."); + } + ObjVentas.Dispose(); sb.Append("El documento se canceló correctamente."); sb.Append($"
    Imprimir Acuse"); if (!EsRefacturacion) @@ -254,6 +264,21 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas } ObjVentas.Dispose(); } + else if (resp.Estado.ToUpper().Trim() == "VIGENTE" && string.IsNullOrEmpty(resp.EstatusCancelacion)) + { + //ASIGNAMOS ESTATUS EMITIDA + CveEstatus = 3; + var ObjVentas = new ClsVentas(); + if (ObjVentas.UpdateEstatusVenta(CveVenta, CveEstatus, UsuarioActual.CveEmpresa)) + { + sb.Append("El estatus de la factura fue cambiado a 'Emitida'."); + } + else + { + sb.Append("Ocurrió un error al cambiar el estatus de la factura."); + } + ObjVentas.Dispose(); + } } } else From b383cfe564ea6448232c7f50c6c4f38011836f3f Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 3 Jun 2021 17:50:21 -0700 Subject: [PATCH 08/15] Folios Ficales en ventas relacionadas, correciones en limite de credito, rfc en ventas, amortizaciones, carga de sucursal al crear a partir de, tipos de retenciones --- App_Code/ClsVentas.vb | 3 +- Ventas/Ventas.aspx | 37 ++++++-- Ventas/Ventas.aspx.vb | 191 ++++++++++++++++++++++++++++++++++++------ 3 files changed, 198 insertions(+), 33 deletions(-) diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index c34d80562..5a6f2fb6d 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -2537,12 +2537,13 @@ Public Class ClsVentas Return Retorno End Function - Public Function AddVentasRelacionadas(CveVenta As Integer, CveVentaRelacionada As Integer) As Boolean + Public Function AddVentasRelacionadas(CveVenta As Integer, CveVentaRelacionada As Integer, Optional FolioFiscal As String = "") As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_VentasRelacionadasAdd") With SqlAdapter.SelectCommand.Parameters .Add("@CveVenta", SqlDbType.Int).Value = CveVenta .Add("@CveVentaRelacionada", SqlDbType.Int).Value = CveVentaRelacionada + .Add("@FolioFiscal", SqlDbType.VarChar).Value = FolioFiscal End With Try SqlAdapter.Fill(Data) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 91e5df9dd..8bf6b895a 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -353,7 +353,7 @@ Asignar Cuenta de Terminal
  • - Asignar Folio Fiscal + Asignar Folio Fiscal
  • Imprimir Formato Cicovisa @@ -4764,10 +4764,19 @@ - + +
    +
    +
    + + +
    +
    +
    +
    @@ -6182,7 +6191,7 @@
    -
    diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 4b9eb526c..545637366 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2217,6 +2217,7 @@ Partial Class Ventas CargaClasificaciones() CargaPS(-1, DdlPS) + CargaPSRemision(-1, DdlPSRemision) CargaPSPyME(-1, DdlPSPyME) CreaDTVentas() @@ -2303,7 +2304,7 @@ Partial Class Ventas End If 'MUESTRA EL MODAL PARA PODER RELACIONAR FACTURAS - If UsuarioActual.Empresa.Funcionalidad(592) = "1" Then + If UsuarioActual.TienePermisoProceso(321) Then HlFacturasRelaciondas.Visible = True End If @@ -2313,7 +2314,7 @@ Partial Class Ventas ViewState("CveVenta") = Request("CveVenta") If CargaVenta() Then - If UsuarioActual.Empresa.Funcionalidad(592) = "1" Then + If UsuarioActual.TienePermisoProceso(321) Then CargaRelacionadasPendientes() End If @@ -4088,8 +4089,9 @@ Partial Class Ventas 'TxtIEPS.Text = If(TmpDT.SUM("IEPS") > 0, TmpDT.SUM("IEPS").FormatoNumero, TxtIEPS.Text) End If - - If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso LblFolioFiscal.Text.Trim = "" Then HplFolioFiscalModal.Visible = True + If UsuarioActual.TienePermisoProceso(318) Then + If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso String.IsNullOrEmpty(LblFolioFiscal.Text.Trim) Then HplFolioFiscalModal.Visible = True + End If Select Case DbRowVenta("TipoDocto").ToString() Case "Ing" @@ -5939,7 +5941,7 @@ Partial Class Ventas Private Sub CargaRelacionadasPendientes() - If CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(592) = "1" Then + If CveVenta > 0 AndAlso UsuarioActual.TienePermisoProceso(321) Then Me.TmpDTFacturasRelacionadas = New DataTable() Me.TmpDTFacturasRelacionadas.Columns.Add(New DataColumn("CveVenta", GetType(Integer))) Me.TmpDTFacturasRelacionadas.Columns.Add(New DataColumn("SerieFolio", GetType(String))) @@ -6027,6 +6029,37 @@ Partial Class Ventas UpFacturasRelacionadas.Update() End If + End Sub + + Protected Sub LnkAgregarFolioFiscalRelacionada_Click(sender As Object, e As EventArgs) + If CveVenta <= 0 OrElse EsCreaApartirDe Then + If Me.TmpDTFacturasRelacionadas Is Nothing Then + CreaTmpFacturasRelacionadas() + End If + + 'If TmpDTFacturasRelacionadas.COUNT("CveVenta", $"CveVenta ={DdlFacturaARelacionar.SelectedValue.ToEntero()}") > 0 Then + ' Alert("La factura ya fue agregada", TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If + + Dim idx As Integer = TmpDTFacturasRelacionadas.MIN("CveVenta", $"CveVenta <= 0").ToEntero() + If idx = 0 Then + idx = -1 + End If + Dim Row As DataRow = TmpDTFacturasRelacionadas.NewRow() + + Row("CveVenta") = idx - 1 + Row("SerieFolio") = "SIN ASIGNAR" + Row("FolioFiscal") = TxtFolioFiscalRelacionar.Text + + Me.TmpDTFacturasRelacionadas.Rows.Add(Row) + + GvFacturasRelacionadas.DataSource = Me.TmpDTFacturasRelacionadas + GvFacturasRelacionadas.DataBind() + + UpFacturasRelacionadas.Update() + End If + End Sub Protected Sub BtnAgregarFacturasRelaciondas_Click(sender As Object, e As EventArgs) If CveVenta <= 0 OrElse EsCreaApartirDe Then @@ -6453,6 +6486,9 @@ Partial Class Ventas ElseIf LimiteRestanteSucursal < LimiteRestanteCliente Then Retorno = LimiteRestanteSucursal PorcentajeCredito = PorcentajeSaldoSucursal + ElseIf LimiteRestanteSucursal = LimiteRestanteCliente Then + Retorno = LimiteRestanteSucursal + PorcentajeCredito = PorcentajeSaldoSucursal End If Else @@ -6522,6 +6558,29 @@ Partial Class Ventas Objeto.ddlWS.Attributes.Add("data-AplicaparaVenta", "1") End If + End Sub + + Private Sub CargaPSRemision(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost) + + Objeto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(141).ToString() = "1") + + If Not UsuarioActual.Empresa.Funcionalidad(141).ToString() = "1" Then + Objeto.ddl.Items.Clear() + 'Objeto.ddl.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, AplicaParaVenta:=1, Estatus:=1) + Objeto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacion, Estatus:=1, AplicaParaVenta:=1) + Objeto.ddl.DataBind() + Objeto.ddl.Items.Insert(0, New ListItem("*** Actualizar listado de Productos o Servicios ***", "-2")) + Objeto.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) + Else + Dim cvesubproyecto As String = "-1" + + Objeto.Attributes.Add("data-cvesubproyecto", cvesubproyecto) + Objeto.ddlWS.Attributes.Add("data-cveclasificacion", CveClasificacion.ToString()) + Objeto.ddlWS.Attributes.Add("data-pagina", "ventas/ventas") + Objeto.ddlWS.Attributes.Add("data-Estatus", "1") + Objeto.ddlWS.Attributes.Add("data-AplicaparaVenta", "1") + End If + End Sub Private Sub CargaNC(pCveVenta As Integer) If pCveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev") Or DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") Then @@ -9088,6 +9147,13 @@ Partial Class Ventas DtVentasNC.AcceptChanges() End If + 'ASIGNAR RFC RECEPTOR + If ObjFacturaBonificacion.Timbre IsNot Nothing Then + If ObjFacturaBonificacion.Timbre.Receptor IsNot Nothing Then + ObjFacturaBonificacion.RFCReceptor = ObjFacturaBonificacion.Timbre.Receptor.RFC + End If + End If + End Sub @@ -9957,6 +10023,13 @@ Partial Class Ventas ObjFactura.DescuentoProntoPago = HdnProntoPago.Value.ToDecimal() ObjFactura.NuevaFactura = Me.NuevaFactura + + 'ASIGNAR RFC RECEPTOR + If ObjFactura.Timbre IsNot Nothing Then + If ObjFactura.Timbre.Receptor IsNot Nothing Then + ObjFactura.RFCReceptor = ObjFactura.Timbre.Receptor.RFC + End If + End If End Sub Private Sub CreaObjetosVentaDevolucion() @@ -10249,6 +10322,13 @@ Partial Class Ventas End If ObjFacturaDevolucion.Timbre = PreParaTimbre(ObjFacturaDevolucion) + + 'ASIGNAR RFC RECEPTOR + If ObjFacturaDevolucion.Timbre IsNot Nothing Then + If ObjFacturaDevolucion.Timbre.Receptor IsNot Nothing Then + ObjFacturaDevolucion.RFCReceptor = ObjFacturaDevolucion.Timbre.Receptor.RFC + End If + End If End Sub Private Function PreParaTimbre(Obj As Modelos.Factura) As CFDITimbre @@ -10354,7 +10434,7 @@ Partial Class Ventas End If 'SI LAS FACTURAS SE RELACIONARAN MANUALMENTE SE AGREGAN - If UsuarioActual.Empresa.Funcionalidad(592) = "1" AndAlso Me.AplicaRelacionManual AndAlso DdlTipoRelacionARelacionar.SelectedValue.ToEntero() > 0 Then + If UsuarioActual.TienePermisoProceso(321) AndAlso Me.AplicaRelacionManual AndAlso DdlTipoRelacionARelacionar.SelectedValue.ToEntero() > 0 Then Dim CveTipoRelacion As Integer = DdlTipoRelacionARelacionar.SelectedValue.ToEntero() @@ -10408,7 +10488,7 @@ Partial Class Ventas Dim concepto As New CFDIConceptos With {.Cantidad = drr("Cantidad").ToString().ToDecimal, .Descripcion = tPS, .ValorUnitario = drr("PU").ToString().ToDecimal, - .Importe = drr("TotalImporte").ToString().ToDecimal, + .Importe = If(UsuarioActual.Empresa.CvePAC = 3, drr("Total").ToString().ToDecimal, drr("TotalImporte").ToString().ToDecimal), .Descuento = drr("Descuento").ToString().ToDecimal.RoundSQL(2), .Unidad = drr("UM").ToString(), .ClaveUnidad = drr("SATClaveUM").ToString(), @@ -11001,11 +11081,20 @@ Partial Class Ventas End If End If - If UsuarioActual.Empresa.Funcionalidad(592) = "1" AndAlso Me.AplicaRelacionManual Then + If UsuarioActual.TienePermisoProceso(321) AndAlso Me.AplicaRelacionManual Then For Each GvRow As GridViewRow In GvFacturasRelacionadas.Rows If GvRow.RowType = DataControlRowType.DataRow Then - If Not ObjVentas.AddVentasRelacionadas(ObjVentas.CveVenta, GvRow.DataKey("CveVenta").ToEntero()) Then - ErrorList.Add("Ocurrió un error al relacionar las ventas entre si comuníquese a Soporte Técnico") + If GvRow.DataKey("CveVenta").ToEntero() > 0 Then + If Not ObjVentas.AddVentasRelacionadas(ObjVentas.CveVenta, GvRow.DataKey("CveVenta").ToEntero()) Then + ErrorList.Add("Ocurrió un error al relacionar las ventas entre si comuníquese a Soporte Técnico") + End If + Else + Dim FolioFiscalRelacionado As String = GvRow.DataKey("FolioFiscal") + If Not String.IsNullOrEmpty(FolioFiscalRelacionado) Then + If Not ObjVentas.AddVentasRelacionadas(ObjVentas.CveVenta, -1, FolioFiscal:=FolioFiscalRelacionado) Then + ErrorList.Add("Ocurrió un error al relacionar las ventas entre si comuníquese a Soporte Técnico") + End If + End If End If End If Next @@ -14809,6 +14898,19 @@ Partial Class Ventas Alert("La amortización no se pudo realizar ya que los importes no cubren la totalidad del documento. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) End If + End If + + If Amortizacion > SubTotalRef Then + + '[IPP] LIMPIA LO SELECCIONADO EN CASO DE QUE NO SEA AMORTIZACIÓN DEL 100% 15Junio2018 + Amortizacion = 0 + For Each gvr As GridViewRow In GVAnticipos.Rows + gvr.FCCheckBox($"Chk{gvr.RowIndex}").Checked = False + Next + If CveVenta <= 0 Then + Alert($"La amortización no se pudo realizar ya que los importes exceden la totalidad del documento.
    Importe sugerido para amortizar:{SubTotalRef.FormatoNumero(2)}.
    Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia) + End If + End If LblAmortizacion.Text = Amortizacion.FormatoNumero(2) @@ -16144,7 +16246,7 @@ Partial Class Ventas Private Sub DdlSubProyectoDatos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSubProyectoDatos.SelectedIndexChanged CambiaSucursalGeneral() End Sub - Private Sub CambiaSucursalGeneral() + Private Sub CambiaSucursalGeneral(Optional RecargarPartidas As Boolean = True) Dim ObjSubProyectos As New ClsSubProyectos 'Dim ObjSucursal As New ClsSucursales If ObjSubProyectos.GetSubProyectos() Then @@ -16158,7 +16260,7 @@ Partial Class Ventas 'DdlSubProyecto.SelectedValue = "-1" DdlSubProyecto.DataBind() DdlSubProyecto.SelectedValueExist(DdlSubProyectoDatos.SelectedValue) - CambiaSucursal() + CambiaSucursal(RecargarPartidas) DdlSubProyectoEjecucion.SelectedValueExist(DdlSubProyectoDatos.SelectedValue) DdlSubProyectoCobranza.SelectedValueExist(DdlSubProyectoDatos.SelectedValue) @@ -16176,12 +16278,16 @@ Partial Class Ventas UpDetalle.Update() End Sub - Private Sub CambiaSucursal() + Private Sub CambiaSucursal(Optional RecargarPartidas As Boolean = True) CargaFormatoSucursal() CargaFolios() CargaVendedores() CargarAlmacenes() - RecargaSucursalPartidas() + + If RecargarPartidas Then + RecargaSucursalPartidas() + End If + DdlPS.Attributes.Remove("data-cvesubproyecto") DdlPS.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue) @@ -16191,6 +16297,7 @@ Partial Class Ventas UpPS.Update() End Sub Private Sub RecargaSucursalPartidas() + Dim CveSubProyecto As Integer = DdlSubProyectoDatos.SelectedValue.ToEntero() Dim SubProyecto As String = "" If CveSubProyecto > 0 Then @@ -23283,12 +23390,12 @@ Partial Class Ventas Private Sub CargaPSPyME(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost) - DdlPSPyME.setEsWebService(True) + Objeto.setEsWebService(True) - DdlPSPyME.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue) - DdlPSPyME.ddlWS.Attributes.Add("data-cveclasificacion", CveClasificacion.ToString()) - DdlPSPyME.ddlWS.Attributes.Add("data-pagina", "ventas/ventas") - DdlPSPyME.ddlWS.Attributes.Add("data-Estatus", "1") + Objeto.Attributes.Add("data-cvesubproyecto", DdlSubProyectoDatos.SelectedValue) + Objeto.ddlWS.Attributes.Add("data-cveclasificacion", CveClasificacion.ToString()) + Objeto.ddlWS.Attributes.Add("data-pagina", "ventas/ventas") + Objeto.ddlWS.Attributes.Add("data-Estatus", "1") End Sub @@ -24015,6 +24122,7 @@ Partial Class Ventas Dim FileExtension As String = "-1" Dim Filesgral As List(Of Archivo) = TxtFileCliente.getfiles().Archivos Dim Filename As String = "" + Dim ErrorCarga As Boolean = False For Each fileItem As Archivo In Filesgral Try @@ -24033,6 +24141,17 @@ Partial Class Ventas Count = +1 Next End If + + If fileItem Is Nothing Then + ErrorCarga = True + Exit For + Else + If fileItem.FileUrl Is Nothing Then + ErrorCarga = True + Exit For + End If + End If + DtDocumentacionCliente(IndexDocumentoCliente)("RutaArchivo") = fileItem.FileUrl DtDocumentacionCliente(IndexDocumentoCliente)("UpArchivo") = "1" @@ -24045,6 +24164,11 @@ Partial Class Ventas Next + If ErrorCarga Then + Alert("No se pudo cargar el archivo", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + GvDocumentosCliente.DataSource = DtDocumentacionCliente GvDocumentosCliente.DataBind() @@ -28319,8 +28443,11 @@ Partial Class Ventas HuboCambioRemi = Not HuboCambioRemi 'TOTAL X CONCEPTO If RblTipo.SelectedValue = "3" Then + 'DivPSRemision.Visible = False ChkRemProductos.Visible = True Else + 'DivPSRemision.Visible = True + CargaPSRemision(-1, DdlPSRemision) ChkRemProductos.Visible = False ChkRemProductos.Checked = False End If @@ -28329,6 +28456,12 @@ Partial Class Ventas End Sub Protected Sub BtnGuardarRemisiones_Click(sender As Object, e As EventArgs) Handles BtnGuardarRemisiones.Click If GvRem.Rows.Count > 0 Or GvRemPS.Rows.Count > 0 Then + + If RblTipo.SelectedValue.Contiene("1", "2") AndAlso DdlPSRemision.SelectedValue.ToEntero() <= 0 Then + Alert("Debe seleccionar un producto para facturar la remisión", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + 'Checa las facturas selecionadas If Not VerificaRemisiones(DTRemisiones) Then Alert("La cantidad/total debe ser mayor que 0", TipoMensaje.MsgAdvertencia) @@ -28430,9 +28563,9 @@ Partial Class Ventas Next IsTotalxConcepto = False Dim PU As Decimal = dtSeleccionadas.SUM("SubTotal").ToDecimal - Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa)(0) + Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPSRemision.SelectedValue.ToEntero())(0) Dim IVA As Double = If(dtSeleccionadas.SUM("Iva") > 0, dtSeleccionadas.SUM("Iva") / dtSeleccionadas.SUM("SubTotal"), 0.16) - Dim rowSP As DataRow = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa)(0) + Dim rowSP As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa)(0) AgregarProductoServicio(1, PS("CveUM").ToString().ToEntero(), PS("UnidadMedida").ToString(), PS("CveClasificacion").ToString().ToEntero(), PS("Clasificacion").ToString(), PS("CvePS").ToString().ToEntero(), PS("PS").ToString(), "", PU, 0, @@ -28458,8 +28591,8 @@ Partial Class Ventas End If Next - Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa)(0) - Dim rowSP As DataRow = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa)(0) + Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPSRemision.SelectedValue.ToEntero())(0) + Dim rowSP As DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa)(0) Dim IVA As Double = If(dtSeleccionadas.SUM("Iva") > 0, dtSeleccionadas.SUM("Iva") / dtSeleccionadas.SUM("SubTotal"), 0.16) For Each gvr As GridViewRow In GvRem.Rows If gvr.FCCheckBox("Chk").Checked Then @@ -29245,7 +29378,7 @@ Partial Class Ventas End If End If ObjCliente.Dispose() - DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty) + 'DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty) TrVistaPrevia.Visible = True TxtFechaVencimientoCotizacion.Text = Now.ToShortDateString @@ -29255,7 +29388,7 @@ Partial Class Ventas GvPS.Columns(18).Visible = True CambiaTipoDocto() - CambiaSucursalGeneral() + CambiaSucursalGeneral(RecargarPartidas:=False) CargaAnticipos(CveCliente) CargaRestriccionesCreditoCliente(CveVenta:=-1) @@ -29276,6 +29409,14 @@ Partial Class Ventas CalculaTotalesVenta() + Dim PorcentajeRetIVA = (TmpDT.MAX("PorcentajeRetIVA").ToDecimal() * 100) + + If PorcentajeRetIVA > 0 Then + TrRetIVA.Style.Add("display", "") + UsuarioActual.Empresa.MostrarRetIVA = True + DdlTipoRetencion.Visible = True + End If + UpnTools.Update() UpCliente.Update() UpParametros.Update() From 49288c54a27dfac927e214cfd8210b6042ea5fb2 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Thu, 3 Jun 2021 17:50:41 -0700 Subject: [PATCH 09/15] Timbrado de prueba con nuevos certificados --- App_Code/Timbrado.vb | 36 +- Inventarios/EntregaAlmacen.aspx | 2078 +++++++++++----------- Inventarios/EntregaAlmacen.aspx.vb | 205 ++- Sistemas/PopUpSeleccionarEmpresa.aspx | 113 +- Sistemas/PopUpSeleccionarEmpresa.aspx.vb | 198 +-- Sistemas/UsuarioDetalle.aspx.vb | 12 +- vwd.webinfo | 10 + 7 files changed, 1307 insertions(+), 1345 deletions(-) diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index 48e9586ba..3b94f4849 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -872,9 +872,15 @@ Public Class Timbrado UsuarioServicio = UsuarioActual.Empresa.BIUsuario ClaveServicio = UsuarioActual.Empresa.BIContraseña Clave = "12345678a" - EmisorRFC = "AAA010101AAA" - ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" - ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + + 'EmisorRFC = "AAA010101AAA" + 'ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" + 'ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + + EmisorRFC = "ZUÑ920208KL4" + ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.key" + ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.cer" + UrlServicio = "http://portalmacropro.com.mx/srvCFDi33prueba/service1.asmx" TimbraProduccion = False End If @@ -1224,9 +1230,14 @@ Public Class Timbrado If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1 Then - EmisorRFC = "AAA010101AAA" - ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" - ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + 'EmisorRFC = "AAA010101AAA" + 'ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" + 'ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + + EmisorRFC = "ZUÑ920208KL4" + ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.key" + ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.cer" + Clave = "12345678a" TimbraProduccion = False Select Case UsuarioActual.Empresa.CvePAC @@ -1805,9 +1816,14 @@ Public Class Timbrado If Not UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1 Then - EmisorRFC = "AAA010101AAA" - ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" - ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + 'EmisorRFC = "AAA010101AAA" + 'ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" + 'ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + + EmisorRFC = "ZUÑ920208KL4" + ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.key" + ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.cer" + Clave = "12345678a" TimbraProduccion = False Select Case CvePACEspecial @@ -3092,9 +3108,11 @@ Public Class Timbrado UsuarioServicio = "fgomez" ClaveServicio = "12121212" Clave = "12345678a" + 'EmisorRFC = "AAA010101AAA" 'ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.key" 'ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_AAA010101AAA.cer" + EmisorRFC = "ZUÑ920208KL4" ArchivoLLave = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.key" ArchivoCertificado = $"{UsuarioActual.Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.cer" diff --git a/Inventarios/EntregaAlmacen.aspx b/Inventarios/EntregaAlmacen.aspx index 69a853562..d4466bbaa 100644 --- a/Inventarios/EntregaAlmacen.aspx +++ b/Inventarios/EntregaAlmacen.aspx @@ -1,1039 +1,1039 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="EntregaAlmacen.aspx.vb" Inherits="Inventarios_EntregaAlmacen" EnableEventValidation="false" %> - - - - - - - - Entrega Almacén (Surtir Mercancia) - - - - -
  • -   -
  • - - - - - <%--FILTROS--%> - - - -
    -
    -
    -
      -
    • Cliente: - - - - - - - - - <%----%> -
    • -
    • Serie-Folio: - - - - - - - - - - -
    • -
    -
    -
    - - <%----%> -
    -
    - -
    -
    -
    -
    - - - -
    - -
    - - <%--DATOS DE LA VENTA--%> -
    - - -
    -
    -
    -
    - - Venta a surtir -
    -
    -
    -
    -
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - -
    Cliente: - -
    Folio: - - <%----%> -
    Observaciones Grales: - -
    Observaciones Almacén: - -
    -
    -
    -
    -
    -
    -
    - - - <%--DATOS DEL MOVIMIENTO--%> -
    - - -
    -
    -
    -
    - - Datos del movimiento -
    -
    -
    -
    -
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Almacén: - - - -
    Fecha: -
    -
    - - - - - - - - - - - - -
    -
    -
    Guía: - -
    Observaciones: - -
    Transitorio: - -
    - -
    - -
    - -
    - - - -
    -
    - - - - - - - ver detalle de entrega - -
    -
    -
    -
    -
    -
    -
    - -
    - - - - -
    -
    - - <%--PENDIENTES DE SURTIR--%> -
    -
    -
    -
    - - Ventas por surtir -
    -
    -
    -
    -
    -
    - - - - -   - - - - - - - - Sucursal: - - - - - - - - - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    - - - <%--ADVERTENCIA--%> -
    -
    -
    - - Información: - -
    -
    -
    - <%--ADVERTENCIA--%> -
    -
    -
    - - Información: - -
    -
    -
    -
    - - - - - - - - - - - - - - -
    - - <%--PERSONAL ENTREGA--%> -
    -
    -
    -
    - - PERSONAL AUTORIZADO PARA ENTREGAS EN ALMACÉN: -
    -
    -
    - - - - - - <%----%> - <%-- - - - - - --%> - - - - - -
    - -
    -
    -
    -
    -
    -
    - -
    - - - -
    -
    -
    - - Salida de Inventario -
    -
    -
    -
    -
    -
    - -
    -
    -
    - - <%--AGREGAR POR CODIGO DE BARRAS--%> - - -
    - -
    -
    - -
    -
    -
    - - - - - - -
    - - - - - - - -
    -
    -
    -
    -
    - - - <%--GV DATOS--%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - -
    -
    -
    - - - - - - -
    -
    - -
    -
    - -
    -
    - - - <%--BOTON GUARDAR--%> - - -
    - -
    -
    - -
    -
    -
    - - - <%--AGREGA POR SERIE--%> - - - - - - - - <%--CANTIDAD ESPECIAL--%> - - - - - - - - - - - <%--CANTIDAD ESPECIAL 2--%> - - - - - - - <%--NUMERO DE GUIA--%> - - - - - - - - - - - -
    - - - - - - - +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="EntregaAlmacen.aspx.vb" Inherits="Inventarios_EntregaAlmacen" EnableEventValidation="false" %> + + + + + + + + Entrega Almacén (Surtir Mercancia) + + + + +
  • +   +
  • +
    + + + + <%--FILTROS--%> + + + +
    +
    +
    +
      +
    • Cliente: + + + + + + + + + <%----%> +
    • +
    • Serie-Folio: + + + + + + + + + + +
    • +
    +
    +
    + + <%----%> +
    +
    + +
    +
    +
    +
    + + + +
    + +
    + + <%--DATOS DE LA VENTA--%> +
    + + +
    +
    +
    +
    + + Venta a surtir +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + +
    Cliente: + +
    Folio: + + <%----%> +
    Observaciones Grales: + +
    Observaciones Almacén: + +
    +
    +
    +
    +
    +
    +
    + + + <%--DATOS DEL MOVIMIENTO--%> +
    + + +
    +
    +
    +
    + + Datos del movimiento +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Almacén: + + + +
    Fecha: +
    +
    + + + + + + + + + + + + +
    +
    +
    Guía: + +
    Observaciones: + +
    Transitorio: + +
    + +
    + +
    + +
    + + + +
    +
    + + + + + + + ver detalle de entrega + +
    +
    +
    +
    +
    +
    +
    + +
    + + + + +
    +
    + + <%--PENDIENTES DE SURTIR--%> +
    +
    +
    +
    + + Ventas por surtir +
    +
    +
    +
    +
    +
    + + + + +   + + + + + + + + Sucursal: + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + <%--ADVERTENCIA--%> +
    +
    +
    + + Información: + +
    +
    +
    + <%--ADVERTENCIA--%> +
    +
    +
    + + Información: + +
    +
    +
    +
    + + + + + + + + + + + + + + +
    + + <%--PERSONAL ENTREGA--%> +
    +
    +
    +
    + + PERSONAL AUTORIZADO PARA ENTREGAS EN ALMACÉN: +
    +
    +
    + + + + + + <%----%> + <%-- + + + + + --%> + + + + + +
    + +
    +
    +
    +
    +
    +
    + +
    + + + +
    +
    +
    + + Salida de Inventario +
    +
    +
    +
    +
    +
    + +
    +
    +
    + + <%--AGREGAR POR CODIGO DE BARRAS--%> + + +
    + +
    +
    + +
    +
    +
    + + + + + + +
    + + + + + + + +
    +
    +
    +
    +
    + + + <%--GV DATOS--%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + +
    +
    +
    + + + + + + +
    +
    + +
    +
    + +
    +
    + + + <%--BOTON GUARDAR--%> + + +
    + +
    +
    + +
    +
    +
    + + + <%--AGREGA POR SERIE--%> + + + + + + + + <%--CANTIDAD ESPECIAL--%> + + + + + + + + + + + <%--CANTIDAD ESPECIAL 2--%> + + + + + + + <%--NUMERO DE GUIA--%> + + + + + + + + + + + +
    + + + + + + + diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index a64e7c2db..bcfd3d3ea 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -644,8 +644,14 @@ Partial Class Inventarios_EntregaAlmacen End If End If - If UsuarioActual.CveEmpresa = 119 AndAlso CveSubProyecto = 10276 Then - ValidaLoteCaducidad = True + If UsuarioActual.CveEmpresa = 119 Then + Dim CveSubProyectoAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacen).FiltroPrimeroValor("CveSubProyecto", "").ToEntero + If CveSubProyectoAlmacen = 10276 Then + ValidaLoteCaducidad = True + Else + ValidaLoteCaducidad = False + End If + End If If Not DtDatos.Columns.Contains("Serie") Then DtDatos.Columns.Add("Serie", GetType(String)) @@ -966,7 +972,8 @@ Partial Class Inventarios_EntregaAlmacen If CBool(e.Row.DBCampo("AplicaCaducidad")) Then e.Row.FCTextBox("TxtCaducidad").Visible = True e.Row.FCLinkButton("LnkCaducidad").Visible = True - e.Row.FCTextBox("TxtCaducidad").readonly = True + e.Row.FCTextBox("TxtCaducidad").ReadOnly = True + CType(e.Row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = False ' e.Row.FCTextBox("TxtCaducidad").enabled = True Else e.Row.FCTextBox("TxtCaducidad").Visible = False @@ -975,7 +982,7 @@ Partial Class Inventarios_EntregaAlmacen If CBool(e.Row.DBCampo("AplicaLote")) Then e.Row.FCTextBox("TxtLote").Visible = True - e.Row.FCTextBox("TxtLote").readonly = True + e.Row.FCTextBox("TxtLote").ReadOnly = True 'e.Row.FCTextBox("TxtLote").enabled = True Else e.Row.FCTextBox("TxtLote").Visible = False @@ -2253,6 +2260,8 @@ Partial Class Inventarios_EntregaAlmacen Next If ErrorMovInv Then Exit For + + Else ErrorMovInv = True End If @@ -2300,6 +2309,7 @@ Partial Class Inventarios_EntregaAlmacen End If End If '' TERMINA: APARTADOS + Dim TotalGarantia As Decimal = 0 ' COMIENZA: GARANTIAS If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoMovimiento = 1 Then @@ -2326,6 +2336,7 @@ Partial Class Inventarios_EntregaAlmacen TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.") Exit For End If + TotalGarantia += (RowGarantia("Cantidad").ToString().ToDecimal() * PU) Next End If End If @@ -2576,83 +2587,97 @@ Partial Class Inventarios_EntregaAlmacen Dim CveAlmacenApartado = -1 Dim CveAlmacenOrigen = If(CveAlmacenTraspasoDestino > 0, CveAlmacenTraspasoDestino, DdlAlmacen.SelectedValue.ToEntero()) Dim CveSeccionAlmacen As Integer = 0 - For Each Dr As DataRow In DtTempApartados.Rows + Dim ValorTraspaso As Decimal = 0 - If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString().ToEntero() Then - CveMovimientoSalidaApartado = ObjInventario.AddMovimiento(CveAlmacenOrigen, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, - Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, - CveAlmacenDestino:=Dr("CveAlmacen").ToString().ToEntero(), Modulo:="RE/G9") - FolioSalida = ObjInventario.Folio - CveAlmacenApartado = Dr("CveAlmacen").ToString().ToEntero() - - Dim DrMovto = DtTraspasos.NewRow - DrMovto("Almacen") = Dr("Almacen").ToString().ToEntero() - DrMovto("CveAlmacen") = Dr("CveAlmacen").ToString().ToEntero() - DrMovto("CveMovimientoSalida") = CveMovimientoSalidaApartado - DrMovto("FolioSalida") = FolioSalida - DtTraspasos.Rows.Add(DrMovto) - End If - - If Not CveMovimientoSalidaApartado > 0 Then - ErrorMovInv = True - TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de control de apartados") - Exit For - End If - 'If CBool(Dr("AplicaSeccion")) Then - ' CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, CveAlmacenOrigen, Dr("CvePS").ToString().ToEntero()).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero() - ' Dim a As String = String.Format("CveAlmacen={0}-CvePS:{1}-CveseccionAlmacen={2}", CveAlmacenOrigen, Dr("CvePS"), CveSeccionAlmacen) - 'Else - ' CveSeccionAlmacen = -1 - 'End If - CveSeccionAlmacen = -3 - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString().ToDecimal, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), Serie:=Dr("Serie").ToString(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), Lote:=Dr("Lote").ToString(), CveSeccionAlmacen:=CveSeccionAlmacen) Then - ErrorMovInv = True - TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de control de apartados") - Exit For - End If - Next - - If Not ErrorMovInv Then - For Each Dr1 As DataRow In DtTraspasos.Rows - CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString().ToEntero() - - CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString().ToEntero(), 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, - -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero(), - CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, - CveCliente:=CveCliente, Modulo:="RE/G10") - FolioEntrada = ObjInventario.Folio - - If Not CveMovimientoEntradaApartado > 0 Then - ErrorMovInv = True - TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.") - Exit For - End If - - Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado - Dr1("FolioEntrada") = FolioEntrada - - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - 'If CBool(Dr("AplicaSeccion")) Then - ' CveSeccionAlmacen = GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, Dr1("CveAlmacen").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero()).FiltroPrimeroValor("CveSeccionAlmacen").ToEntero() - ' Dim a As String = String.Format("CveAlmacen={0}-CvePS:{1}-CveseccionAlmacen={2}", Dr1("CveAlmacen").ToString().ToEntero(), Dr("CvePS"), CveSeccionAlmacen) - 'Else - ' CveSeccionAlmacen = -1 - 'End If - CveSeccionAlmacen = -3 - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString().ToDecimal, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), Serie:=Dr("Serie").ToString(), CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString().ToEntero(), Lote:=Dr("Lote").ToString(), CveSeccionAlmacen:=CveSeccionAlmacen) Then - ErrorMovInv = True - TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.") - Exit For - End If - Next - End If - - If ErrorMovInv Then Exit For - - Next + 'SI TIENE APARTADOS DEBE GENERAR LOS TRASPASOS + If DtTempApartados.Rows.Count > 0 Then + + For Each Dr As DataRow In DtTempApartados.Rows + + If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString().ToEntero() Then + CveMovimientoSalidaApartado = ObjInventario.AddMovimiento(CveAlmacenOrigen, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, + Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, + CveAlmacenDestino:=Dr("CveAlmacen").ToString().ToEntero(), Modulo:="RE/G9") + FolioSalida = ObjInventario.Folio + CveAlmacenApartado = Dr("CveAlmacen").ToString().ToEntero() + + Dim DrMovto = DtTraspasos.NewRow + DrMovto("Almacen") = Dr("Almacen").ToString().ToEntero() + DrMovto("CveAlmacen") = Dr("CveAlmacen").ToString().ToEntero() + DrMovto("CveMovimientoSalida") = CveMovimientoSalidaApartado + DrMovto("FolioSalida") = FolioSalida + DtTraspasos.Rows.Add(DrMovto) + End If + + If Not CveMovimientoSalidaApartado > 0 Then + ErrorMovInv = True + TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de control de apartados") + Exit For + End If + CveSeccionAlmacen = -3 + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString().ToDecimal, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), Serie:=Dr("Serie").ToString(), CveVentaDetalle:=Dr("CveVentaDetalle").ToString().ToEntero(), Lote:=Dr("Lote").ToString(), CveSeccionAlmacen:=CveSeccionAlmacen) Then + ErrorMovInv = True + TextoError.AppendFormat("Ocurrió un error al guardar los movimientos de control de apartados") + Exit For + End If + Next + + If Not ErrorMovInv Then + + Dim CvePrePolizaTraspaso As Integer = ObjConta.AddPrePolizas("EA/Apart", 53, 0, 0, 1, TxtFecha.Text.ToDate, "Traspaso Apartado", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CvePrePolizaTraspaso > 0 Then + + For Each Dr1 As DataRow In DtTraspasos.Rows + CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString().ToEntero() + + CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString().ToEntero(), 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, + -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero(), + CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, + CveCliente:=CveCliente, Modulo:="RE/G10") + FolioEntrada = ObjInventario.Folio + + If Not CveMovimientoEntradaApartado > 0 Then + ErrorMovInv = True + TextoError.AppendFormat("Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar.") + Exit For + End If + + Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado + Dr1("FolioEntrada") = FolioEntrada + + If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then + ValorTraspaso = ObjInventario.DtResultados.SUMD("Total").RoundSQL + For Each Dr As DataRow In ObjInventario.DtResultados.Rows + + CveSeccionAlmacen = -3 + + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString().ToDecimal, Dr("CveUM").ToString().ToEntero(), Dr("CvePS").ToString().ToEntero(), Dr("PU").ToString().ToDecimal, CveAF:=Dr("CveAF").ToString().ToEntero(), Serie:=Dr("Serie").ToString(), CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString().ToEntero(), Lote:=Dr("Lote").ToString(), CveSeccionAlmacen:=CveSeccionAlmacen) Then + ErrorMovInv = True + TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.") + Exit For + End If + Next + End If + + If ErrorMovInv Then Exit For + + + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTraspaso, True, ValorTraspaso, TxtObservaciones.Text, 68, TxtObservaciones.Text, TxtFecha.Text.ToDate, -1, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=False, ImporteMX:=ValorTraspaso) Then + ErrorMovInv = True + End If + + If Not ErrorMovInv AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTraspaso, False, ValorTraspaso, TxtObservaciones.Text, 68, TxtObservaciones.Text, TxtFecha.Text.ToDate, -1, -1, CveMovimientoAlmacen:=CveMovimientoEntradaApartado, Contabilizable:=False, ImporteMX:=ValorTraspaso) Then + ErrorMovInv = True + End If + Next + + + Else + ErrorMovInv = True + End If + End If + End If End If @@ -2701,6 +2726,7 @@ Partial Class Inventarios_EntregaAlmacen ErrorMovInv = True End If End If + Dim TotalVirtual As Decimal = 0 ' COMIENZA: VIRTUAL If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Dev") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" AndAlso CveMovimiento > 0 Then @@ -2758,7 +2784,7 @@ Partial Class Inventarios_EntregaAlmacen If CveMovimientoVirtual > 0 Then For Each RowUsado As DataRow In DtPSVirtual.Rows Dim CvePS = RowUsado("CvePS").ToString().ToEntero() - Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() + Dim CantidadUsado As Decimal = RowUsado("Cantidad").ToString().ToDecimal() Dim PU As Decimal = RowUsado("Cargo").ToString().ToDecimal() Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() @@ -2767,7 +2793,14 @@ Partial Class Inventarios_EntregaAlmacen TextoError.AppendFormat("Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar.") Exit For End If - Next + TotalVirtual += (CantidadUsado * PU) + Next + 'insertar en prepóliza de la salida virtual + If Not ErrorMovInv Then + ErrorMovInv = Not GenerarPrePoliza(ObjInventario, ObjVentas, ObjConta, CveMovimientoVirtual, TextoError) + + End If + Else ErrorMovInv = True End If @@ -2920,7 +2953,6 @@ Partial Class Inventarios_EntregaAlmacen Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero() 'Dim CveCuentaAlmacen As Integer = 0 'GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero() Dim IdCtaContable As Integer = 0 - Dim CveCuenta As Integer = 0 If tmpCostos.Rows.Count > 0 Then @@ -2929,7 +2961,7 @@ Partial Class Inventarios_EntregaAlmacen Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString().ToEntero() Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString() Dim Serie As String = ObjVentas.DtResultados(0)("SerieFolio").ToString() - Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundAD() + Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL() Dim TotalCostoAcumulado As Decimal = 0 Dim cont As Integer = 1 @@ -2949,7 +2981,7 @@ Partial Class Inventarios_EntregaAlmacen If CvePrePoliza > 0 Then For Each RowInv As DataRow In tmpCostos.Rows - ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundAD() + ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL() TotalCostoAcumulado += ValorInventario 'cuando es el último movimiento y hay diferencias en los importes @@ -2959,10 +2991,9 @@ Partial Class Inventarios_EntregaAlmacen 'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString(), Row2("SubProyecto").ToString()) IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero() - CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero() If Not ErrorMovInv Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorMultiplicador * ValorInventario, Serie, 69, Serie, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * ValorInventario, CveCuenta:=CveCuenta, CveClasificacion:=RowInv("CveClasificacion").ToString().ToEntero()) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorMultiplicador * ValorInventario, Serie, 69, Serie, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * ValorInventario, CveClasificacion:=RowInv("CveClasificacion").ToString().ToEntero()) Then ErrorMovInv = True End If End If diff --git a/Sistemas/PopUpSeleccionarEmpresa.aspx b/Sistemas/PopUpSeleccionarEmpresa.aspx index efd3192d7..e6dffd21a 100644 --- a/Sistemas/PopUpSeleccionarEmpresa.aspx +++ b/Sistemas/PopUpSeleccionarEmpresa.aspx @@ -21,7 +21,7 @@