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/30] 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/30] 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/30] 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/30] 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/30] 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 2a1cbf53f9660f1ba36a9dc07221ad9e7d015793 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 1 Jun 2021 16:20:49 -0700 Subject: [PATCH 06/30] =?UTF-8?q?se=20cambi=C3=B3=20combo=20de=20clientes?= =?UTF-8?q?=20de=20contratos=20a=20dropdownlost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OC/OC.aspx | 2 +- OC/OC.aspx.vb | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/OC/OC.aspx b/OC/OC.aspx index fd95b1c4d..b4968ba52 100644 --- a/OC/OC.aspx +++ b/OC/OC.aspx @@ -2545,7 +2545,7 @@
    - +
    diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index 5d6ca8ded..95c8204f9 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -677,7 +677,7 @@ Partial Class OC TipoOS = True End If - BtnGeneraContrato.Visible = True : CargaClientes() + BtnGeneraContrato.Visible = True : CargaClientesContrato() CargaEstatusInicialFinal() CargaEstatusUsuarios() @@ -6770,7 +6770,7 @@ Partial Class OC BtnSolicitudAnticipo.Visible = False HlAgregarExcel.Visible = True LbDescargarExcel.Visible = True - BtnGeneraContrato.Visible = True : CargaClientes() + BtnGeneraContrato.Visible = True : CargaClientesContrato() LbVerificarExistencia.Visible = True LnkAgregarGuia.Visible = False @@ -7387,10 +7387,11 @@ Partial Class OC #Region "CONTRATOS" - Private Sub CargaClientes() - DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) - DdlClientes.DataBind() - DdlClientes.Items.Insert(0, New ListItem("Seleccione", "-1")) + Private Sub CargaClientesContrato() + 'DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) + 'DdlClientes.DataBind() + 'DdlClientes.Items.Insert(0, New ListItem("Seleccione", "-1")) + 'DdlClienteContrato End Sub Private Sub CargaContratos() @@ -7403,20 +7404,20 @@ Partial Class OC UpContrato.Update() End Sub - Private Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClientes.SelectedIndexChanged + Private Sub DdlClienteContrato_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClienteContrato.selectedindexchange DdlContratos.Items.Clear() ' DdlContratos.DataSource = GlobalDTContratos().FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCliente = {DdlClientes.SelectedValue.ToEntero} AND Estatus = True AND FechaFinal >= '{Now.ToShortDateString}' AND FechaInicial <= '{Now.ToShortDateString}'") Dim ObjContratos As New ClsContratos - If ObjContratos.GetContratos(-1, UsuarioActual.CveEmpresa, DdlClientes.SelectedValue.ToEntero, -1, 1) Then + If ObjContratos.GetContratos(-1, UsuarioActual.CveEmpresa, DdlClienteContrato.SelectedValue.ToEntero, -1, 1) Then If ObjContratos.DtResultados.FiltraParametros("Estatus = True").Rows.Count > 0 Then DdlContratos.DataSource = ObjContratos.DtResultados.FiltraParametros($"Estatus = True AND FechaFinal >= '{Now.ToShortDateString}' AND FechaInicial <= '{Now.ToShortDateString}'") - DdlContratos.DataBind() End If End If - + ObjContratos.Dispose() + DdlContratos.DataBind() DdlContratos.Items.Insert(0, New ListItem("Seleccione", "-1")) @@ -7492,7 +7493,7 @@ Partial Class OC End If Next TxtGrid.Text = If(DtDetalle.Rows.Count = 0, "", DtDetalle.Rows.Count.ToString) - Ddlcliente.txtValue.Value = DdlClientes.SelectedValue + Ddlcliente.txtValue.Value = DdlClienteContrato.SelectedValue CargaSuperior() CargaDatosDetalles() From ab74b09054c614ca3d5f5ed503eab8362b3209d7 Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 2 Jun 2021 19:16:11 -0700 Subject: [PATCH 07/30] impuestos locales --- General/SaldosIniciales.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index 2590c9fb1..c6cce12bd 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -1109,7 +1109,7 @@ Partial Class General_SaldosIniciales Dim CveMoneda As Integer = 1 Dim CveProveedorSucursal As Integer = Row("CveProveedorSucursal").ToString.ToEntero Dim PorcentajeIVA As String = Row("PorcentajeIVA").ToString - Dim ImpuestosLocales As Decimal = If(dt.Columns.Contains("ImpuestosLocalesl"), Row("ImpuestosLocales").ToString, "0").ToDecimal + Dim ImpuestosLocales As Decimal = If(dt.Columns.Contains("ImpuestosLocales"), Row("ImpuestosLocales").ToString, "0").ToDecimal If Not CvePS > 0 Then Alert(String.Format("No se encontró el Producto Servicio"), TipoMensaje.MsgError) : ErrorCompras = True From 764084ce3b9f83d7a864233f2d3b929d64e1b386 Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 2 Jun 2021 19:16:28 -0700 Subject: [PATCH 08/30] mejora visual y manejo de la carga en excel --- Contabilidad/RegPrePolizaS.aspx | 9 ++++----- Contabilidad/RegPrePolizaS.aspx.vb | 20 ++++++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Contabilidad/RegPrePolizaS.aspx b/Contabilidad/RegPrePolizaS.aspx index 7fdbf74da..fde03b86f 100644 --- a/Contabilidad/RegPrePolizaS.aspx +++ b/Contabilidad/RegPrePolizaS.aspx @@ -145,7 +145,7 @@
    - +
    @@ -159,7 +159,7 @@
    - +
    @@ -202,9 +202,8 @@

    - -
    -
    + + diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb index 2c44b33e0..d8ace96b3 100644 --- a/Contabilidad/RegPrePolizaS.aspx.vb +++ b/Contabilidad/RegPrePolizaS.aspx.vb @@ -1963,8 +1963,15 @@ Partial Class ContabilidadC_RegPrePolizaS Exit For End If - If Row("SubProyecto").ToString <> "" Then - CveSubProyecto = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", String.Format("SubProyecto = '{0}'", Row("SubProyecto"))) 'Row("CveSubProyecto").ToString.ToEntero + If Row("SubProyecto").ToString.Trim <> "" Then + CveSubProyecto = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa, Estatus:=-1).FiltroPrimeroValor("CveSubProyecto", String.Format("SubProyecto = '{0}'", Row("SubProyecto").ToString.Trim)).ToEntero 'Row("CveSubProyecto").ToString.ToEntero + + If CveSubProyecto = 0 Then + Alert(String.Format("El subproyecto {0} no se reconoció, favor de verificar el archivo.", Row("SubProyecto"))) + DtMovimientos.Clear() + Exit For + End If + End If If CveConceptoContable = 69 Then @@ -1983,8 +1990,8 @@ Partial Class ContabilidadC_RegPrePolizaS dr("CveConcepto") = CveConceptoContable dr("CveConceptoContable") = CveConceptoContable dr("ConceptoContable") = Row("ConceptoAdministrativo").ToString - dr("Cargo") = Row("Cargo").ToString.ToDecimal - dr("Abono") = Row("Abono").ToString.ToDecimal + dr("Cargo") = Row("Cargo").ToString.ToDecimal.RoundSQL + dr("Abono") = Row("Abono").ToString.ToDecimal.RoundSQL dr("Descripcion") = Row("Concepto").ToString dr("CveSubProyecto") = CveSubProyecto dr("CveProveedor") = -1 @@ -1995,12 +2002,13 @@ Partial Class ContabilidadC_RegPrePolizaS dr("CveVenta") = -1 dr("CveCuenta") = CveCuenta - TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDouble + TxtAbono.Text.ToDouble).ToString.FormatoNumero - TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDouble + TxtCargo.Text.ToDouble).ToString.FormatoNumero + DtMovimientos.Rows.Add(dr) DtMovimientos.AcceptChanges() Next + TxtTotalCargos.Text = DtMovimientos.SUMD("Cargo").ToString.FormatoNumero + TxtTotalAbonos.Text = DtMovimientos.SUMD("Abono").ToString.FormatoNumero GvMov.DataSource = DtMovimientos GvMov.DataBind() From 3d042799c9fb400d1d7ba16222c380bbf7f78bd5 Mon Sep 17 00:00:00 2001 From: HECTOR RODRIGUEZ Date: Wed, 2 Jun 2021 19:26:31 -0700 Subject: [PATCH 09/30] Refrecar el grid al momento de actualizar y cambio de icono de eliminar --- Contabilidad/RegPrePolizaS.aspx | 3 ++- Contabilidad/RegPrePolizaS.aspx.vb | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Contabilidad/RegPrePolizaS.aspx b/Contabilidad/RegPrePolizaS.aspx index 7fdbf74da..6bb72ae7d 100644 --- a/Contabilidad/RegPrePolizaS.aspx +++ b/Contabilidad/RegPrePolizaS.aspx @@ -405,7 +405,8 @@ - + + diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb index 2c44b33e0..4b37f6583 100644 --- a/Contabilidad/RegPrePolizaS.aspx.vb +++ b/Contabilidad/RegPrePolizaS.aspx.vb @@ -787,7 +787,7 @@ Partial Class ContabilidadC_RegPrePolizaS If DdlPlantilla.SelectedValue.ToEntero = 53 Then 'Plantilla Personalizada e.Row.FCDropDownList("DdlSubProyecto").Enabled = True - e.Row.FCImageButton("imgD").Visible = True + e.Row.FCLinkButton("imgD").Visible = True Else e.Row.FCDropDownList("DdlSubProyecto").Enabled = False End If @@ -1443,7 +1443,10 @@ Partial Class ContabilidadC_RegPrePolizaS dr("CveCliente") = DdlClientes.SelectedValue.ToEntero dr("CveVenta") = DdlVentas.SelectedValue.ToEntero dr("CveCuenta") = DdlCtaContable.SelectedValue.ToEntero - End If + End If + GvMov.DataSource = DtMovimientos + GvMov.DataBind() + UPMovs.Update() LbCancelarEdicion.Visible = False LbAgregar.Text = "Agregar" From 0c40bf9b216d52559a9e9f8ae10e8966cf0ac28f Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 3 Jun 2021 09:27:27 -0700 Subject: [PATCH 10/30] mejora en registro y considera importes negativos --- Contabilidad/RegPrePolizaS.aspx.vb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb index d8ace96b3..193be8c97 100644 --- a/Contabilidad/RegPrePolizaS.aspx.vb +++ b/Contabilidad/RegPrePolizaS.aspx.vb @@ -911,7 +911,7 @@ Partial Class ContabilidadC_RegPrePolizaS If idCuentaContabilizacion = 1 AndAlso (IdCtaContable = 0) Then idCuentaContabilizacion = 0 End If - If Importe > 0 Then + If Importe <> 0 Then Dim tCveCuenta As Integer = gvr.DataKey("CveCuenta").ToEntero 'If gvr.datakey("CveConcepto") = "299" Then @@ -929,15 +929,9 @@ Partial Class ContabilidadC_RegPrePolizaS Exit For End If End If - Next - - 'If CvePeriodo > 0 Then - ' If Not ObjNom.UpdateProvisionNomina(CvePeriodo, CvePrePoliza, UsuarioActual.CveEmpresa) Then - ' MsgError = "No se pudo actualizar el periodo de la nómina" - ' End If - 'End If - - If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 1) Then + Next + + If MsgError = "" AndAlso ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 1) Then If ObjMov.ValorPolizaDescuadre > 0 Then GuardaLogAD($"Contabilidad/RegPrePolizas | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") MsgError = ObjMov.MensajePolizaDescuadre @@ -986,7 +980,8 @@ Partial Class ContabilidadC_RegPrePolizaS GvMov.DataBind() TxtFecha.Text = "" TxtObservaciones.Text = "" - Else + Else + Alert(MsgError.ToString, ModExtensiones.TipoMensaje.MsgError) ObjIE.RollBack() If Conta IsNot Nothing Then Conta.RollBack() End If From 2053bd2dbbf6a02bdeedc123c03bfeca1ee85018 Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 3 Jun 2021 10:38:13 -0700 Subject: [PATCH 11/30] mejoras en carga de excel --- Contabilidad/RegPrePolizaS.aspx.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb index add9383be..44f50b925 100644 --- a/Contabilidad/RegPrePolizaS.aspx.vb +++ b/Contabilidad/RegPrePolizaS.aspx.vb @@ -1952,6 +1952,7 @@ Partial Class ContabilidadC_RegPrePolizaS Dim ObjConta2 As New ClsContabilidad If ObjConta2.GetCuentas(-1, Row("Cuenta").ToString, 1, UsuarioActual.CveEmpresa) Then CveCuenta = ObjConta2.DtResultados.FiltroPrimeroValor("CveCuenta", "").ToEntero + NombreCuenta = ObjConta2.DtResultados.FiltroPrimeroValor("CtaCodigo", "") End If ObjConta2.Dispose() 'sino viene el cveconcepto, busca por le nombre del concepto 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 12/30] 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 13/30] 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 14/30] 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 15/30] 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 @@
    + + <%--MODAL ADJUNTAR--%> + + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 8df4b4fdf..49bedbb5d 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -1308,6 +1308,15 @@ Partial Class Ventas ViewState("RFCReceptorVenta") = value End Set End Property + Private Property Adjunto As String + Get + Return If(IsNothing(ViewState("Adjunto")), "", ViewState("Adjunto").ToString()) + End Get + + Set(value As String) + ViewState("Adjunto") = value + End Set + End Property #End Region #Region "Propiedades PuntoVenta" @@ -3994,6 +4003,21 @@ Partial Class Ventas End If RFCReceptorVenta = DbRowVenta("RFCReceptor").ToString() + 'Adjuntar archivo + Adjunto = DbRowVenta("Adjunto").ToString() + If Adjunto <> "" Then + BtnArchivoAdjunto.Text = Adjunto + BtnArchivoAdjunto.Visible = True + BtnEliminarAdjunto.Visible = False + BtnAdjuntar.Visible = False + + tdAdjuntar.Style.Item("display") = "none" + tdAdjunto.Style.Item("display") = "block" + + Else + DivAdjuntar.Visible = False + + End If ViewState("CveSubProyectoVenta") = DbRowVenta("CveSubProyecto").ToString().ToEntero() @@ -10980,7 +11004,7 @@ Partial Class Ventas CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM, DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False), Kilometraje:=TxtKilometraje.Text.ToDouble, EsAmortizacion:=EsNCAmortizacion, CveTipoRetencion:=factura.CveTipoRetencion, CorreoNotificacion:=TxtCorreoNotificaciones.Text, - FormaPaqueteria:=RblPaqueteria.SelectedValue.ToEntero, FacturarSucursal:=factura.FacturarSucursal, VentaDesglosaIEPS:=factura.VentaDesglosaIEPS, RFCReceptor:=RFCReceptor) Then + FormaPaqueteria:=RblPaqueteria.SelectedValue.ToEntero, FacturarSucursal:=factura.FacturarSucursal, VentaDesglosaIEPS:=factura.VentaDesglosaIEPS, RFCReceptor:=RFCReceptor, Adjunto:=Adjunto) Then ErrorList.Add("Ocurrió un error al Generar la Venta.
    Revise su factura y cualquier detalle comuníquese a Soporte Técnico") Else If factura.TipoDocto.Contiene("Dev", "Egs") Or DtVentasNC IsNot Nothing Or CveEstatusRefacturacion = 1 Then @@ -13748,13 +13772,16 @@ Partial Class Ventas 'MANDA CORREO If EnviaCorreo Then - + Dim ArchivoAdjunto As String = "" Dim ArchivoXML = String.Format("{0}XML\{1}\{2}.xml", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio) Dim ArchivoPDF = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio) + If Adjunto <> "" Then + ArchivoAdjunto = String.Format("{0}Ventas\{1}", UsuarioActual.Empresa.Ruta, Adjunto) + End If Try ' BytesPdfCotizacion(CveVenta) - Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF)) + Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto)) Hilo.Start() Catch ex As Exception OnError("Ocurrió error al mandar Mail", ex) @@ -13792,13 +13819,16 @@ Partial Class Ventas 'MANDA CORREO If EnviaCorreo Then - + Dim ArchivoAdjunto As String = "" Dim ArchivoXML = "" Dim ArchivoPDF = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio) + If Adjunto <> "" Then + ArchivoAdjunto = String.Format("{0}Ventas\{1}", UsuarioActual.Empresa.Ruta, Adjunto) + End If Try ' BytesPdfCotizacion(CveVenta) - Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF)) + Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto)) Hilo.Start() Catch ex As Exception OnError("Ocurrió error al mandar Mail", ex) @@ -13835,13 +13865,17 @@ Partial Class Ventas LocalSerieFolio = ObjFactura.SerieFolio LocalTipoDocto = ObjFactura.TipoDocto + Dim ArchivoAdjunto As String = "" Dim ArchivoXML = String.Format("{0}XML\{1}\{2}.xml", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio) Dim ArchivoPDF = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio) + If Adjunto <> "" Then + ArchivoAdjunto = String.Format("{0}Ventas\{1}", UsuarioActual.Empresa.Ruta, Adjunto) + End If Try ' BytesPdfCotizacion(CveVenta) - Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF)) + Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto)) Hilo.Start() Catch ex As Exception OnError("Ocurrió error al mandar Mail", ex) @@ -19464,7 +19498,7 @@ Partial Class Ventas #End Region #Region " MANDA CORREO " - Private Sub MandaMails(UsuarioActual As Usuario, CveVenta As Integer, TipoDocto As String, SerieFolio As String, EnviarFactura As Boolean, XML As String, PDF As String) + Private Sub MandaMails(UsuarioActual As Usuario, CveVenta As Integer, TipoDocto As String, SerieFolio As String, EnviarFactura As Boolean, XML As String, PDF As String, Adjunto As String) Dim ObjMail As New ClsSisMail() Dim ObjVentas As New ClsVentas @@ -19514,6 +19548,10 @@ Partial Class Ventas LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = XML}) End If + If Adjunto <> "" Then + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = Adjunto}) + End If + Dim DisplayName As String = "" If UsuarioActual.CveEmpresa = 119 Then DisplayName = "Facturación Agroquímicos JAM" @@ -31416,5 +31454,101 @@ Partial Class Ventas RegistraScript("$('#ModalAplicaRNCDevolucion').modal('hide');") End Sub + + Protected Sub btnGuardarAdjunto_Click(sender As Object, e As System.EventArgs) Handles btnGuardarAdjunto.Click + If Not txtAdjuntar.getfiles().Archivos.Count > 0 Then + Alert("Tiene que cargar un archivo.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If LblSerie.Text = "" Or TxtFolio.Text = "" Then + Alert("Debe asignar una serie un folio antes de subir el archivo.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Dim FileExtension As String = "-1" + Dim Filesgral As List(Of Archivo) = txtAdjuntar.getfiles().Archivos + Dim Filename As String = "" + Dim fileItem As Archivo = Filesgral(0) + Try + FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + Adjunto = String.Format("{0}-{1}.{2}", LblSerie.Text, TxtFolio.Text, FileExtension) + Dim objVentas As New ClsVentas + Dim Path As String + Path = Extensiones.DirectorioBaseEmpresas + Path += String.Format("Empresas/{0}/Ventas", UsuarioActual.CveEmpresa) + If Not Directory.Exists(Path) Then + Directory.CreateDirectory(Path) + End If + Path += $"/{Adjunto}" + If File.Exists(Path) Then + File.Delete(Path) + End If + My.Computer.FileSystem.MoveFile(fileItem.FileUrl, Path) + BtnAdjuntar.Visible = False + BtnArchivoAdjunto.Text = Adjunto + BtnArchivoAdjunto.Visible = True + BtnEliminarAdjunto.Visible = True + tdAdjuntar.Style.Item("display") = "none" + tdAdjunto.Style.Item("display") = "block" + UpAdjuntar.Update() + Alert("Documento cargado", TipoMensaje.MsgInformacion) + objVentas.Dispose() + + Catch ex As Exception + OnError("Error al cargar archivo", ex) + End Try + + End Sub + + Protected Sub BtnArchivoAdjunto_Click(sender As Object, e As System.EventArgs) Handles BtnArchivoAdjunto.Click + Dim ruta As String = HttpContext.Current.Request.ApplicationPath + ruta = Extensiones.DirectorioBaseEmpresas + ruta += String.Format("Empresas/{0}/Ventas", UsuarioActual.CveEmpresa) + ruta += $"/{Adjunto}" + + Dim Archivo As New System.IO.FileInfo(ruta) + + Try + If Archivo IsNot Nothing Then + If Archivo.Exists Then + + HttpContext.Current.Response.Clear() + HttpContext.Current.Response.ClearContent() + HttpContext.Current.Response.ContentType = "application/octet-stream" + HttpContext.Current.Response.AppendHeader("Content-disposition", String.Format("attachment; filename={0}", Archivo.Name)) + HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString()) + HttpContext.Current.Response.TransmitFile(ruta) + Response.Flush() ' send it to the client to download + HttpContext.Current.Response.SuppressContent = True + HttpContext.Current.ApplicationInstance.CompleteRequest() + Response.End() + + Else + Alert("El archivo no existe", TipoMensaje.MsgAdvertencia) + End If + + End If + Catch ex As Exception + End Try + + + + End Sub + + Protected Sub BtnEliminarAdjunto_Click(sender As Object, e As System.EventArgs) Handles BtnEliminarAdjunto.Click + Dim objVentas As New ClsVentas + Dim Path As String + Path = String.Format("{0}Empresas/{1}/Ventas/{2}", Extensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, Adjunto) + If File.Exists(Path) Then + File.Delete(Path) + End If + BtnAdjuntar.Visible = True + tdAdjuntar.Style.Item("display") = "block" + BtnArchivoAdjunto.Text = "" + BtnArchivoAdjunto.Visible = False + tdAdjunto.Style.Item("display") = "none" + BtnEliminarAdjunto.Visible = False + UpAdjuntar.Update() + End Sub End Class From 096ed6a6d1718a7809e3f3b7fce67c336ae1081d Mon Sep 17 00:00:00 2001 From: HECTOR RODRIGUEZ Date: Fri, 4 Jun 2021 03:26:11 -0700 Subject: [PATCH 21/30] --- Contabilidad/RegPrePolizaS.aspx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Contabilidad/RegPrePolizaS.aspx b/Contabilidad/RegPrePolizaS.aspx index 4ba12dac4..fa0bebecb 100644 --- a/Contabilidad/RegPrePolizaS.aspx +++ b/Contabilidad/RegPrePolizaS.aspx @@ -224,9 +224,11 @@ + + - + From 00a967e2532e08e116645cf4345b9f28f587b9e9 Mon Sep 17 00:00:00 2001 From: rrene Date: Fri, 4 Jun 2021 11:37:55 -0700 Subject: [PATCH 22/30] =?UTF-8?q?-creaci=C2=B4n=20de=20cuenta,=20debe=20se?= =?UTF-8?q?r=20afectable=20de=20inicio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Contabilidad2/CatCuentas.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contabilidad2/CatCuentas.aspx.vb b/Contabilidad2/CatCuentas.aspx.vb index 261c1bd8a..c49923db5 100644 --- a/Contabilidad2/CatCuentas.aspx.vb +++ b/Contabilidad2/CatCuentas.aspx.vb @@ -504,7 +504,7 @@ Partial Class Contabilidad2_CatCuentas End If If IdPadre > 0 Then - Dim idnew2 As Integer = ObjConta2.AddCuenta(TxtCuenta.Text.Replace("-", ""), Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero, CuentaEfectivo, DdlMoneda.SelectedValue.ToEntero, TxtDigAgrup.Text.ToEntero, TxtNomIngles.Text.Trim, Afectable, IdPadre, IdAgrupador) + Dim idnew2 As Integer = ObjConta2.AddCuenta(TxtCuenta.Text.Replace("-", ""), Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero, CuentaEfectivo, DdlMoneda.SelectedValue.ToEntero, TxtDigAgrup.Text.ToEntero, TxtNomIngles.Text.Trim, 1, IdPadre, IdAgrupador) If idnew2 > 0 Then If Not ObjConta.UpdateCuentaCompaq(idnew, idnew2, UsuarioActual.CveEmpresa) Then From 91d2ccd40fd586cec7a1e8865a7c173ebe635733 Mon Sep 17 00:00:00 2001 From: rrene Date: Fri, 4 Jun 2021 11:38:19 -0700 Subject: [PATCH 23/30] =?UTF-8?q?ajustes=20de=20inventario,=20considerar?= =?UTF-8?q?=20que=20solo=20est=C3=A1n=20en=20hillo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inventarios/EntradasSalidas.aspx.vb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb index 397f87575..11ada3319 100644 --- a/Inventarios/EntradasSalidas.aspx.vb +++ b/Inventarios/EntradasSalidas.aspx.vb @@ -4444,6 +4444,13 @@ Partial Class Inventarios_EntradasSalidas TrSerieEntrada.Visible = AplicaSerie TxtnSerie.Visible = AplicaSerie + Dim CveSubProyectoAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenInventarioFisico.SelectedValue.ToEntero).FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero + + If UsuarioActual.CveEmpresa = 119 AndAlso Not CveSubProyectoAlmacen.ToString.Contiene(UsuarioActual.Empresa.Funcionalidad(347)) Then + AplicaLote = False + AplicaCaducidad = False + End If + 'activa seccion ThSeccionEntrada.Visible = AplicaSeccion TrSeccionEntrada.Visible = AplicaSeccion @@ -4468,6 +4475,7 @@ Partial Class Inventarios_EntradasSalidas If DdlPSSalida.SelectedValue.ToEntero > 0 Then Dim drp As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPSSalida.SelectedValue.ToEntero).FiltroPrimero("") + If drp IsNot Nothing Then Dim AplicaSerie As Boolean = CBool(drp("AplicaSerie")) Dim AplicaSeccion As Boolean = CBool(drp("AplicaSeccion")) @@ -4478,6 +4486,12 @@ Partial Class Inventarios_EntradasSalidas TrSerieSalida.Visible = AplicaSerie TxtnSerie.Visible = AplicaSerie + Dim CveSubProyectoAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=DdlAlmacenInventarioFisico.SelectedValue.ToEntero).FiltroPrimeroValor("CveSubProyecto").ToString.ToEntero + + If UsuarioActual.CveEmpresa = 119 AndAlso Not CveSubProyectoAlmacen.ToString.Contiene(UsuarioActual.Empresa.Funcionalidad(347)) Then + AplicaLote = False + AplicaCaducidad = False + End If 'activa seccion ThSeccionSalida.Visible = AplicaSeccion TrSeccionSalida.Visible = AplicaSeccion From a84eeffd8b4ced1635e5f58481bfe8c0fa45eb5d Mon Sep 17 00:00:00 2001 From: rrene Date: Fri, 4 Jun 2021 17:17:47 -0700 Subject: [PATCH 24/30] -- mensaje para validar que no existe la cuenta --- Contabilidad/RegPrePolizaS.aspx.vb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb index 44f50b925..2b9d9ec0a 100644 --- a/Contabilidad/RegPrePolizaS.aspx.vb +++ b/Contabilidad/RegPrePolizaS.aspx.vb @@ -952,7 +952,9 @@ Partial Class ContabilidadC_RegPrePolizaS End If Else Alert("No se puede contabilizar la Prepoliza debido a que una o mas cuentas son inválidas") - End If + End If + Else + MensajeAlert.AppendFormat("

    Folio: {1}", CvePrePoliza, ObjMov.ContaFolio) End If Else @@ -1946,15 +1948,22 @@ Partial Class ContabilidadC_RegPrePolizaS Dim CveSubProyecto As Integer = -1 Dim TipoMovto As Boolean = If(Row("Cargo").ToString.ToDecimal <> 0, False, True) Dim CveConceptoContable As Integer = GlobalDTContaConceptosContables(-1).FiltroPrimeroValor("CveConceptoContable", String.Format("ConceptoContable ='{0}'", Row("ConceptoAdministrativo"))).ToEntero ' Row("CveConceptoContable").ToString.ToEntero - Dim IdCtaContable As Integer = Row("IdCtaContable").ToString.ToEntero + 'Dim IdCtaContable As Integer = Row("IdCtaContable").ToString.ToEntero Dim CveClasificacion As Integer = -1 Dim CveCuenta As Integer = -1 Dim ObjConta2 As New ClsContabilidad - If ObjConta2.GetCuentas(-1, Row("Cuenta").ToString, 1, UsuarioActual.CveEmpresa) Then + If ObjConta2.GetCuentas(-1, Row("Cuenta").ToString.Replace("-", ""), 1, UsuarioActual.CveEmpresa) Then CveCuenta = ObjConta2.DtResultados.FiltroPrimeroValor("CveCuenta", "").ToEntero NombreCuenta = ObjConta2.DtResultados.FiltroPrimeroValor("CtaCodigo", "") End If ObjConta2.Dispose() + + If CveCuenta <= 0 Then + Alert(String.Format("La cuenta {0} no se reconoció, favor de verificar el archivo.", Row("Cuenta").ToString)) + DtMovimientos.Clear() + Exit For + End If + 'sino viene el cveconcepto, busca por le nombre del concepto If CveConceptoContable = 0 Then Alert(String.Format("El concepto {0} no se reconoció, favor de verificar el archivo.", Row("ConceptoAdministrativo"))) From 299e10aa0ad4981ad27f2d7c1598b3278ae89e5e Mon Sep 17 00:00:00 2001 From: rrene Date: Sat, 5 Jun 2021 14:46:18 -0700 Subject: [PATCH 25/30] =?UTF-8?q?mejoras=20en=20manejo=20de=20errores=20de?= =?UTF-8?q?=20liberaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RH/Personal.aspx.vb | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index d0dea5f49..c5bac7099 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -5304,14 +5304,38 @@ Partial Class RH_Personal Dim Cantidad As Double = TxtCantidadResguardo.Text.ToDouble() Dim Serie As String = TxtLiberarSerie.Text.Trim + Dim MsgError As String = "" Dim CveResultadoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacenUniforme, 3, 1, Date.Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CveAlmacenDestino:=DdlAlmacenDestinoLiberarUniforme.SelectedValue.ToEntero, CvePersonal:=CvePersonal, Observaciones:=DescripcionUniforme) - Dim ResultadoDetalleSalida As Boolean = ObjInventario.AddMovimientoDetalle(CveResultadoSalida, Cantidad, CveUM, CvePS, PU, CveSeccionAlmacen:=CveSeccionAlmacenUniforme, Serie:=Serie, CveMovimientoDetalleEntrada:=CveMovimientoDetalleUniforme) - Dim CveSeccionAlmacen As Integer = DdlSeccionAlmacen.SelectedValue.ToEntero - Dim CveResultadoEntrada As Integer = ObjInventario.AddMovimiento(DdlAlmacenDestinoLiberarUniforme.SelectedValue.ToEntero, 2, 1, Date.Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CvePersonal:=CvePersonal, Observaciones:=DescripcionUniforme, CveMovimientoRelacionado:=CveMovimientoUniforme) - Dim ResultadoDetalleEntrada As Boolean = ObjInventario.AddMovimientoDetalle(CveResultadoEntrada, Cantidad, CveUM, CvePS, PU, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie) + If CveResultadoSalida > 0 Then + If CveSeccionAlmacenUniforme = 0 Then CveSeccionAlmacenUniforme = -3 'que lo tome por default + Dim ResultadoDetalleSalida As Boolean = ObjInventario.AddMovimientoDetalle(CveResultadoSalida, Cantidad, CveUM, CvePS, PU, CveSeccionAlmacen:=CveSeccionAlmacenUniforme, Serie:=Serie, CveMovimientoDetalleEntrada:=CveMovimientoDetalleUniforme) + Dim CveSeccionAlmacen As Integer = DdlSeccionAlmacen.SelectedValue.ToEntero + If ResultadoDetalleSalida Then - If ResultadoDetalleSalida And ResultadoDetalleEntrada Then + Dim CveResultadoEntrada As Integer = ObjInventario.AddMovimiento(DdlAlmacenDestinoLiberarUniforme.SelectedValue.ToEntero, 2, 1, Date.Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, CvePersonal:=CvePersonal, Observaciones:=DescripcionUniforme, CveMovimientoRelacionado:=CveMovimientoUniforme) + If CveResultadoEntrada > 0 Then + Dim ResultadoDetalleEntrada As Boolean = ObjInventario.AddMovimientoDetalle(CveResultadoEntrada, Cantidad, CveUM, CvePS, PU, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie) + If ResultadoDetalleSalida And ResultadoDetalleEntrada Then + MsgError = "" + Else + Alert("No se pudo registrar la liberación.", TipoMensaje.MsgError) + MsgError = "Error1" + End If + Else + MsgError = "Error1" + End If + + Else + MsgError = "Error1" + End If + Else + MsgError = "Error" + + End If + + + If MsgError = "" Then ObjInventario.Commit() Alert("El resguardo se liberó correctamente") RegistraScript(String.Format("$('#{0}').modal('hide');", "ModalUniforme")) @@ -5320,6 +5344,7 @@ Partial Class RH_Personal Alert("No se pudo registrar la liberación.", TipoMensaje.MsgError) ObjInventario.RollBack() End If + ObjInventario.Dispose() End Sub From b8c1c44f78b02935779110fc826c4e796de85629 Mon Sep 17 00:00:00 2001 From: rrene Date: Sat, 5 Jun 2021 15:32:15 -0700 Subject: [PATCH 26/30] =?UTF-8?q?consulta=20directo=20la=20informaci=C3=B3?= =?UTF-8?q?n=20de=20globaldtPS=20SAT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/ClsPaginas.vb | 27 ++++++++++++++++++--------- Ashx/SIGWeb.ashx | 19 ++++++++++++------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 0e4c53628..da7cfdf70 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -293,19 +293,28 @@ Public Class ClsPaginas Application("Directorio") = value End Set End Property - Property GlobalDTPSATPS() As DataTable + Public Shared ReadOnly Property GlobalDTPSATPS(SATClaveProductoServicio As String) As DataTable Get - If Application("GlobalDTPSATPS") Is Nothing Then - Dim ObjGrales As New ClsGenerales - If ObjGrales.GetSATProductosServicios Then Application("GlobalDTPSATPS") = ObjGrales.DtResultados.AsEnumerable() Else Application("GlobalDTPSATPS") = Nothing - ObjGrales.Dispose() + 'If Application("GlobalDTPSATPS") Is Nothing Then + ' Dim ObjGrales As New ClsGenerales + ' If ObjGrales.GetSATProductosServicios Then Application("GlobalDTPSATPS") = ObjGrales.DtResultados.AsEnumerable() Else Application("GlobalDTPSATPS") = Nothing + ' ObjGrales.Dispose() + 'End If + + 'GlobalDTPSATPS = DirectCast(Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow)).CopyToDataTable + + Dim ObjGrales As New ClsGenerales + If ObjGrales.GetSATProductosServicios(SATClaveProductoServicio) Then + GlobalDTPSATPS = ObjGrales.DtResultados + Else + GlobalDTPSATPS = Nothing End If + ObjGrales.Dispose() - GlobalDTPSATPS = DirectCast(Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow)).CopyToDataTable End Get - Set(value As DataTable) - Application("GlobalDTPSATPS") = value - End Set + 'Set(value As DataTable) + ' Application("GlobalDTPSATPS") = value + 'End Set End Property #Region "GLOBALES DE SAT COMERCIO EXTERIOR" diff --git a/Ashx/SIGWeb.ashx b/Ashx/SIGWeb.ashx index de2c67ba8..43e27b789 100644 --- a/Ashx/SIGWeb.ashx +++ b/Ashx/SIGWeb.ashx @@ -701,7 +701,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState 'verifica existencias If Pagina.Contiene("ventas/ventas", "oc/oc", "inv/traspaso") AndAlso CveEmpresa.Contiene(72, 80, 119, 140, 141, 152, 153, 159, 160, 161, 162, 163) Then UsaGlobal = False - + Dim objInv As New ClsInventarios If objInv.GetExistenciasProductosLike(Name, CveClasificacion, CveSubProyecto, Estatus.ToEntero, AplicaParaVenta, CveEmpresa, CveMarca) Then @@ -933,20 +933,25 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState Private Function GETPSSAT(ByVal context As HttpContext) As String Dim retorno As String = "" - Dim DTPS = DirectCast(context.Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow)) + 'Dim DTPS = DirectCast(context.Application("GlobalDTPSATPS"), EnumerableRowCollection(Of DataRow)) Dim DtPSRetorno As DataTable Dim Name = IfNull(context.Request("Name"), "-1").ToString - If Name <> "-1" Then - DTPS = DTPS.Where((Function(a) a!SATClaveProductoServicio.ToString.ToLower Like ($"*{Name.ToLower}*"))) - End If - - DtPSRetorno = New DataView(DTPS.OrderBy(Function(a) a!SATClavePS).CopyToDataTable).ToTable(True, {"CveSATPS", "SATClaveProductoServicio"}) + 'If Name <> "-1" Then + ' DTPS = DTPS.Where((Function(a) a!SATClaveProductoServicio.ToString.ToLower Like ($"*{Name.ToLower}*"))) + 'End If + 'DtPSRetorno = New DataView(DTPS.OrderBy(Function(a) a!SATClavePS).CopyToDataTable).ToTable(True, {"CveSATPS", "SATClaveProductoServicio"}) + DtPSRetorno = ClsPaginas.GlobalDTPSATPS(Name.ToLower) If DtPSRetorno IsNot Nothing AndAlso DtPSRetorno.Rows.Count > 0 Then DtPSRetorno.Columns("CveSATPS").ColumnName = "id" DtPSRetorno.Columns("SATClaveProductoServicio").ColumnName = "text" + 'limpia las columnas + For Each dc As DataColumn In DtPSRetorno.Clone.Columns + If Not dc.ColumnName.Contiene("id", "text") Then DtPSRetorno.Columns.Remove(dc.ColumnName) + Next + retorno = JsonConvert.SerializeObject(DtPSRetorno).ToString context.Response.Write(retorno) Else From 6756370475111e4d0a567c9d2d1bd68faa3993d9 Mon Sep 17 00:00:00 2001 From: rrene Date: Sat, 5 Jun 2021 15:33:44 -0700 Subject: [PATCH 27/30] =?UTF-8?q?--=20especificar=20lote/cad,=20si=20viene?= =?UTF-8?q?=20vac=C3=ADo,=20en=20las=20devoluciones?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inventarios/EntregaAlmacen.aspx.vb | 179 ++++++++++++++++------------- 1 file changed, 97 insertions(+), 82 deletions(-) diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index 1c4ce6bbf..f0df0fce3 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -646,7 +646,8 @@ Partial Class Inventarios_EntregaAlmacen If UsuarioActual.CveEmpresa = 119 Then Dim CveSubProyectoAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacen).FiltroPrimeroValor("CveSubProyecto", "").ToEntero - If CveSubProyectoAlmacen = 10276 Then + + If CveSubProyectoAlmacen.ToString.Contiene(UsuarioActual.Empresa.Funcionalidad(347)) Then ValidaLoteCaducidad = True Else ValidaLoteCaducidad = False @@ -974,16 +975,29 @@ Partial Class Inventarios_EntregaAlmacen e.Row.FCLinkButton("LnkCaducidad").Visible = True e.Row.FCTextBox("TxtCaducidad").readonly = True CType(e.row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = False - ' e.Row.FCTextBox("TxtCaducidad").enabled = True + + 'si aplica caducidad y viene vacía (posible por venta anterior), que se active su registro + If e.Row.FCTextBox("TxtCaducidad").Text = "" OrElse e.Row.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha Then + e.Row.FCTextBox("TxtCaducidad").ReadOnly = False + CType(e.Row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = True + e.Row.FCTextBox("TxtCaducidad").Enabled = True + End If Else e.Row.FCTextBox("TxtCaducidad").Visible = False e.Row.FCLinkButton("LnkCaducidad").Visible = False + e.Row.FCTextBox("TxtCaducidad").Enabled = True End If If CBool(e.Row.DBCampo("AplicaLote")) Then e.Row.FCTextBox("TxtLote").Visible = True - e.Row.FCTextBox("TxtLote").readonly = True - 'e.Row.FCTextBox("TxtLote").enabled = True + 'si aplica caducidad y viene vacía (posible por venta anterior), que se active su registro + If e.Row.FCTextBox("TxtLote").Text = "" Then + e.Row.FCTextBox("TxtLote").ReadOnly = False + e.Row.FCTextBox("TxtLote").Enabled = True + Else + e.Row.FCTextBox("TxtLote").ReadOnly = True + End If + Else e.Row.FCTextBox("TxtLote").Visible = False End If @@ -2588,97 +2602,98 @@ Partial Class Inventarios_EntregaAlmacen Dim CveAlmacenOrigen = If(CveAlmacenTraspasoDestino > 0, CveAlmacenTraspasoDestino, DdlAlmacen.SelectedValue.ToEntero()) Dim CveSeccionAlmacen As Integer = 0 Dim ValorTraspaso As Decimal = 0 - 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 - '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 + If DtTempApartados IsNot Nothing AndAlso DtTempApartados.Rows.Count > 0 Then + For Each Dr As DataRow In DtTempApartados.Rows - 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 + 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() - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTraspaso, True, ValorTraspaso, TxtObservaciones.Text, 68, TxtObservaciones.Text, TxtFecha.Text.ToDate, -1, -1, CveMovimientoAlmacen:=CveMovimientoSalidaApartado, Contabilizable:=False, ImporteMX:=ValorTraspaso) Then - ErrorMovInv = True + 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 - For Each Dr1 As DataRow In DtTraspasos.Rows - CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString().ToEntero() + 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 - 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 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 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 + If Not ErrorMovInv Then - Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado - Dr1("FolioEntrada") = FolioEntrada + 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 - 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 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 + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaTraspaso, True, ValorTraspaso, TxtObservaciones.Text, 68, TxtObservaciones.Text, TxtFecha.Text.ToDate, -1, -1, CveMovimientoAlmacen:=CveMovimientoSalidaApartado, Contabilizable:=False, ImporteMX:=ValorTraspaso) Then ErrorMovInv = True End If - Next + + 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 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 + Else + ErrorMovInv = True + End If End If - End If - + End If End If End If End If From 5dee8c7f1a03b407ea6e9ac3b28a2f34c67a4241 Mon Sep 17 00:00:00 2001 From: rrene Date: Sat, 5 Jun 2021 15:57:17 -0700 Subject: [PATCH 28/30] --manejo de lote/cad --- Inventarios/EntregaAlmacen.aspx.vb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Inventarios/EntregaAlmacen.aspx.vb b/Inventarios/EntregaAlmacen.aspx.vb index f0df0fce3..ff33b654d 100644 --- a/Inventarios/EntregaAlmacen.aspx.vb +++ b/Inventarios/EntregaAlmacen.aspx.vb @@ -973,8 +973,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 - CType(e.row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = False + e.Row.FCTextBox("TxtCaducidad").ReadOnly = True + CType(e.Row.FindControl("RFVCaducidad"), RequiredFieldValidator).Enabled = False 'si aplica caducidad y viene vacía (posible por venta anterior), que se active su registro If e.Row.FCTextBox("TxtCaducidad").Text = "" OrElse e.Row.FCTextBox("TxtCaducidad").Text.ToDate <= MinFecha Then @@ -3275,8 +3275,8 @@ Partial Class Inventarios_EntregaAlmacen 'sino es transitorio, los transitorios, ya no se hace otro movimiento ConceptoMovimiento = If(ChkTransitorio.Checked, 2, 27) - Almacen2 = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero(), CveAlmacenTraspasoDestino) - CveMovimientoEntrada = ObjInventario.AddMovimiento(Almacen2, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, + Almacen2 = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero(), CveAlmacenTraspasoDestino) + CveMovimientoEntrada = ObjInventario.AddMovimiento(Almacen2, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:="", CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimientoSalida, CveAlmacenDestino:=CveAlmacenTraspasoDestino, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT1", CveOP:=CveOP) FolioEntrada = ObjInventario.Folio From d38234eff878088bead490e2f9482827a4fa765a Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Mon, 7 Jun 2021 12:53:32 -0700 Subject: [PATCH 29/30] Correcion en actualizacion de alias en PS --- Compras/Compras.aspx.vb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 0fe63b649..67bc0ef80 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -18674,17 +18674,15 @@ Partial Class Compras_Compras TmpDT.Rows(HdnAliasInd.Value.ToEntero)("Obs") = TxtPSAlias.Text.Trim 'busco si el producto está en otros renglones QUE NO LO TENGAN ASIGNADO, LO VINCULE - If UsuarioActual.CveEmpresa <> 141 Then - For Each drt As DataRow In TmpDT.Select($"PS ='{TxtPSAlias.Text.Trim}' and ISNULL(CvePS,0) = 0") - drt("CvePS") = CvePS - drt("PS") = tPS - drt("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero - drt("UM") = DdlUnidadAlias.SelectedItem.Text - drt("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero - drt("Clasificacion") = HdnPSAliasClasificacion.Value - drt("Obs") = TxtPSAlias.Text.Trim - Next - End If + For Each drt As DataRow In TmpDT.Select($"PS ='{TxtPSAlias.Text.Trim}' and ISNULL(CvePS,0) = 0") + drt("CvePS") = CvePS + drt("PS") = tPS + drt("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero + drt("UM") = DdlUnidadAlias.SelectedItem.Text + drt("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero + drt("Clasificacion") = HdnPSAliasClasificacion.Value + drt("Obs") = TxtPSAlias.Text.Trim + Next TmpDT.AcceptChanges() From e5c47a7c9ac81da22866071a87e2392de05a333c Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Mon, 7 Jun 2021 12:53:51 -0700 Subject: [PATCH 30/30] Resumen del mes en reporte diario en excel --- Ventas/RepPS.aspx.vb | 120 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 113 insertions(+), 7 deletions(-) diff --git a/Ventas/RepPS.aspx.vb b/Ventas/RepPS.aspx.vb index 5ae077225..55f38afb9 100644 --- a/Ventas/RepPS.aspx.vb +++ b/Ventas/RepPS.aspx.vb @@ -36,7 +36,7 @@ Partial Class Ventas_RepPS 'DdlMarca.Items.Insert(0, New ListItem("Todos", "-1")) End If - If UsuarioActual.TienePermisoProceso(320) Then + If UsuarioActual.TienePermisoProceso(320) OrElse UsuarioActual.CveRol = 1 Then LnkRepDiario.Visible = True End If @@ -242,9 +242,11 @@ Partial Class Ventas_RepPS Dim TC As Integer = 1 Dim TCEspecifico As Decimal = -1 + Dim FechaConsulta As DateTime = Now + 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 + If ObjVentas.GetRepPSDiario(-1, -1, FechaConsulta, UsuarioActual.CveEmpresa, CveUsuarioConsulta:=UsuarioActual.CveUsuario, GPO:=-1, CveMoneda:=CveMoneda, TipoCambio:=TC, TCEspecifico:=TCEspecifico) Then DataSet = ObjVentas.DataSetResultados.Copy() End If ObjVentas.Dispose() @@ -254,7 +256,7 @@ Partial Class Ventas_RepPS Dim FileExcel As New ExcelFile() - Dim worksheetName As String = $"{ToShortMonthName(Now).ToUpper()}{Now.Day}" + Dim worksheetName As String = $"{ToShortMonthName(FechaConsulta).ToUpper()}{FechaConsulta.Day}" Const invalidCharsRegex As String = "[/\\*'?[\]:]+" Const maxLength As Integer = 31 Dim safeName As String = Regex.Replace(worksheetName, invalidCharsRegex, " ").Replace(" ", " ").Trim() @@ -269,7 +271,7 @@ Partial Class Ventas_RepPS 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.Value = $"{UsuarioActual.Empresa.Empresa}. VENTA DEL DIA {FechaConsulta.Day} DE {ToMonthName(FechaConsulta).ToUpper()} DEL {FechaConsulta.Year}." CellRangeTitulo.Style.VerticalAlignment = VerticalAlignmentStyle.Center CellRangeTitulo.Style.HorizontalAlignment = HorizontalAlignmentStyle.Center @@ -552,8 +554,8 @@ Partial Class Ventas_RepPS 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, 1).Value = (FechaConsulta.Year - 1).ToString() + worksheet.Cells(IdxRefAnioAnteriorLlantas, 2).Value = FechaConsulta.Year.ToString() worksheet.Cells(IdxRefAnioAnteriorLlantas, 3).Value = "Dif" Dim StyleTitleTable4 = worksheet.Cells.GetSubrangeAbsolute(IdxRefAnioAnteriorLlantas, 0, IdxRefAnioAnteriorLlantas, 3).Style @@ -614,13 +616,117 @@ Partial Class Ventas_RepPS DtAnioAnteriorLLantas.Dispose() #End Region +#Region "L L A N T A S M E S A Ñ O A N T E R I O R" + Dim IdxRefMesAnioAnteriorLlantas As Integer = IdxAnioAnteriorLlantas + 3 + + worksheet.Cells.GetSubrangeAbsolute(IdxRefMesAnioAnteriorLlantas - 1, 1, IdxRefMesAnioAnteriorLlantas - 1, 3).Merged = True + worksheet.Cells.GetSubrangeAbsolute(IdxRefMesAnioAnteriorLlantas - 1, 4, IdxRefMesAnioAnteriorLlantas - 1, 6).Merged = True + worksheet.Cells(IdxRefMesAnioAnteriorLlantas - 1, 1).Value = "LLANTAS" + worksheet.Cells(IdxRefMesAnioAnteriorLlantas - 1, 4).Value = "%" + + worksheet.Cells(IdxRefMesAnioAnteriorLlantas, 0).Value = "Sucursal" + worksheet.Cells(IdxRefMesAnioAnteriorLlantas, 1).Value = String.Format("{0} {1}", ToShortMonthName(FechaConsulta).ToUpper(), (FechaConsulta.Year - 1)) + worksheet.Cells(IdxRefMesAnioAnteriorLlantas, 2).Value = String.Format("{0} {1}", ToShortMonthName(FechaConsulta).ToUpper(), (FechaConsulta.Year)) + worksheet.Cells(IdxRefMesAnioAnteriorLlantas, 3).Value = "DIF %" + worksheet.Cells(IdxRefMesAnioAnteriorLlantas, 4).Value = String.Format("{0} - %", (FechaConsulta.Year - 1)) + worksheet.Cells(IdxRefMesAnioAnteriorLlantas, 5).Value = String.Format("{0} - %", (FechaConsulta.Year)) + worksheet.Cells(IdxRefMesAnioAnteriorLlantas, 6).Value = "DIF %" + + Dim StyleTitleTable5 = worksheet.Cells.GetSubrangeAbsolute(IdxRefMesAnioAnteriorLlantas - 1, 0, IdxRefMesAnioAnteriorLlantas - 1, 6).Style + StyleTitleTable5.Font.Weight = ExcelFont.BoldWeight + StyleTitleTable5.Font.Name = "Calibri" + StyleTitleTable5.Font.Size = 8 * 20 + StyleTitleTable5.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleTitleTable5.VerticalAlignment = VerticalAlignmentStyle.Center + StyleTitleTable5.HorizontalAlignment = HorizontalAlignmentStyle.Center + + Dim StyleSubTitleTable5 = worksheet.Cells.GetSubrangeAbsolute(IdxRefMesAnioAnteriorLlantas, 0, IdxRefMesAnioAnteriorLlantas, 6).Style + StyleSubTitleTable5.Font.Weight = ExcelFont.BoldWeight + StyleSubTitleTable5.Font.Name = "Calibri" + StyleSubTitleTable5.Font.Size = 8 * 20 + StyleSubTitleTable5.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleSubTitleTable5.VerticalAlignment = VerticalAlignmentStyle.Center + StyleSubTitleTable5.HorizontalAlignment = HorizontalAlignmentStyle.Center + + Dim DtMesAnioAnteriorLLantas As DataTable = DataSet.Tables(4) + 'INICIA DESDE LA CUARTA FILA + Dim IdxMesAnioAnteriorLlantas As Integer = IdxRefMesAnioAnteriorLlantas + 1 + + For Each Row As DataRow In DtMesAnioAnteriorLLantas.Rows + worksheet.Cells(IdxMesAnioAnteriorLlantas, 0).Value = Row("Sucursal") + worksheet.Cells(IdxMesAnioAnteriorLlantas, 1).Value = Row("LLantasAnioAnterior") + worksheet.Cells(IdxMesAnioAnteriorLlantas, 2).Value = Row("LLantas") + worksheet.Cells(IdxMesAnioAnteriorLlantas, 3).Formula = $"=({worksheet.Cells(IdxMesAnioAnteriorLlantas, 2).Name} - {worksheet.Cells(IdxMesAnioAnteriorLlantas, 1).Name})" + worksheet.Cells(IdxMesAnioAnteriorLlantas, 4).Formula = $"=+(({worksheet.Cells(IdxMesAnioAnteriorLlantas, 1).Name} * 1.07) - {worksheet.Cells(IdxMesAnioAnteriorLlantas, 2).Name}) /12" + worksheet.Cells(IdxMesAnioAnteriorLlantas, 5).Formula = $"=+(({worksheet.Cells(IdxMesAnioAnteriorLlantas, 1).Name} * 1) - {worksheet.Cells(IdxMesAnioAnteriorLlantas, 2).Name}) /12" + worksheet.Cells(IdxMesAnioAnteriorLlantas, 6).Formula = $"=+({worksheet.Cells(IdxMesAnioAnteriorLlantas, 2).Name} / {worksheet.Cells(IdxMesAnioAnteriorLlantas, 1).Name}) - 1" + + Dim StyleData = worksheet.Cells.GetSubrangeAbsolute(IdxMesAnioAnteriorLlantas, 0, IdxMesAnioAnteriorLlantas, 6).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_-;_-* ""-""??_-;_-@_-" + + IdxMesAnioAnteriorLlantas += 1 + Next + + DtMesAnioAnteriorLLantas.Dispose() +#End Region + +#Region "L L A N T A S M E S A Ñ O A N T E R I O R" + Dim IdxRefMesAnioAnteriorLlantasResumen As Integer = IdxMesAnioAnteriorLlantas + 2 + + worksheet.Cells(IdxRefMesAnioAnteriorLlantasResumen, 0).Value = "Mes" + worksheet.Cells(IdxRefMesAnioAnteriorLlantasResumen, 1).Value = String.Format("{0}", (FechaConsulta.Year - 1)) + worksheet.Cells(IdxRefMesAnioAnteriorLlantasResumen, 2).Value = String.Format("{0}", (FechaConsulta.Year)) + worksheet.Cells(IdxRefMesAnioAnteriorLlantasResumen, 3).Value = "DIF UDS" + worksheet.Cells(IdxRefMesAnioAnteriorLlantasResumen, 4).Value = "DIF %" + + Dim StyleTitleTable6 = worksheet.Cells.GetSubrangeAbsolute(IdxRefMesAnioAnteriorLlantasResumen, 0, IdxRefMesAnioAnteriorLlantasResumen, 4).Style + StyleTitleTable6.Font.Weight = ExcelFont.BoldWeight + StyleTitleTable6.Font.Name = "Calibri" + StyleTitleTable6.Font.Size = 8 * 20 + StyleTitleTable6.Borders.SetBorders(MultipleBorders.All, SpreadsheetColor.FromName(ColorName.Black), LineStyle.Thin) + StyleTitleTable6.VerticalAlignment = VerticalAlignmentStyle.Center + StyleTitleTable6.HorizontalAlignment = HorizontalAlignmentStyle.Center + + + Dim DtMesAnioAnteriorLLantasResumen As DataTable = DataSet.Tables(5) + 'INICIA DESDE LA CUARTA FILA + Dim IdxMesAnioAnteriorLlantasResumen As Integer = IdxRefMesAnioAnteriorLlantasResumen + 1 + + For Each Row As DataRow In DtMesAnioAnteriorLLantasResumen.Rows + worksheet.Cells(IdxMesAnioAnteriorLlantasResumen, 0).Value = ToMonthName(FechaConsulta).ToUpper() + worksheet.Cells(IdxMesAnioAnteriorLlantasResumen, 1).Value = Row("LLantasAnioAnterior") + worksheet.Cells(IdxMesAnioAnteriorLlantasResumen, 2).Value = Row("LLantas") + worksheet.Cells(IdxMesAnioAnteriorLlantasResumen, 3).Formula = $"=({worksheet.Cells(IdxMesAnioAnteriorLlantasResumen, 1).Name} - {worksheet.Cells(IdxMesAnioAnteriorLlantasResumen, 2).Name})" + worksheet.Cells(IdxMesAnioAnteriorLlantasResumen, 4).Formula = $"=+({worksheet.Cells(IdxMesAnioAnteriorLlantasResumen, 2).Name} / {worksheet.Cells(IdxMesAnioAnteriorLlantasResumen, 1).Name})" + + Dim StyleData = worksheet.Cells.GetSubrangeAbsolute(IdxMesAnioAnteriorLlantasResumen, 0, IdxMesAnioAnteriorLlantasResumen, 4).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_-;_-* ""-""??_-;_-@_-" + + IdxMesAnioAnteriorLlantasResumen += 1 + Next + + DtMesAnioAnteriorLLantasResumen.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) + FileExcel.Save(Response, $"DIARIO_{FechaConsulta.ToString("dd_MM_yyyy")}.xlsx", SaveOptions.XlsxDefault) End If