diff --git a/App_Code/CFDITimbre.vb b/App_Code/CFDITimbre.vb index b1aa67145..2aad60555 100644 --- a/App_Code/CFDITimbre.vb +++ b/App_Code/CFDITimbre.vb @@ -842,6 +842,7 @@ End Class Public Class CFDICartaPorte Public Property TranspInternac As String = "No" Public Property EntradaSalidaMercancia As String = "" + Public Property PaisOrigenDestino As String = "" Public Property ViaEntradaSalida As String = "" Public Property RegimenAduanero As String = "" Public Property RegistroISTMO As String = "" diff --git a/App_Code/CalendarEvent.vb b/App_Code/CalendarEvent.vb index f5f94aaee..db77a2884 100644 --- a/App_Code/CalendarEvent.vb +++ b/App_Code/CalendarEvent.vb @@ -7,6 +7,7 @@ Public Class CalendarEvent Public Property description As String Public Property start As String Public Property [end] As String + Public Property FechaFinal As String Public Property allDay As Boolean Public Property CveEventoEstatus As Integer Public Property cveagendatipo As String @@ -36,6 +37,7 @@ Public Class CalendarEvent Public Property CvePersonal As Integer Public Property CvePersonal2 As Integer Public Property CveCliente As Integer + Public Property NombreComercial As String Public Property CveProveedor As Integer Public Property CveOS As Integer Public Property CveOSDetalle As Integer diff --git a/App_Code/ClsBancos.vb b/App_Code/ClsBancos.vb index 9e1e30aa8..40d578ba6 100644 --- a/App_Code/ClsBancos.vb +++ b/App_Code/ClsBancos.vb @@ -133,6 +133,7 @@ Public Class ClsBancos Public Property UsaTarjeta As Boolean Public Property TieneTerminal As Boolean Public Property CveCuentaPadre As Integer + Public Property CveSubProyecto As Integer #End Region @@ -418,10 +419,10 @@ Public Class ClsBancos Me.UsaTarjeta = If(Data.Rows(0)("UsaTarjeta").ToString = "True", True, False) Me.TieneTerminal = If(Data.Rows(0)("TieneTerminal").ToString = "True", True, False) Me.CveCuentaPadre = Data.Rows(0)("CveCuentaPadre").ToString.ToEntero + Me.CveSubProyecto = Data.Rows(0)("CveSubProyecto").ToString.ToEntero End If - Retorno = True Catch ex As SqlException OnError("Ocurrió un error al consultar las Cuentas de los Bancos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) @@ -452,7 +453,8 @@ Public Class ClsBancos Public Function AddBancosCuentas(CveBanco As Integer, CveTipoCuenta As Integer, NumCuenta As String, CLABE As String, CveMoneda As Integer, DiaCorte As Integer, FInicial As Integer, FActual As Integer, FFinal As Integer, LimiteCredito As Double, FormatoCheque As String, CveUsuario As Integer, CveEmpresa As Integer, ConvenioPagoElectronico As String, - UsaLayout As Boolean, UsaTarjeta As Boolean, Optional SaldoInicial As Double = 0, Optional UsaLayoutGrupos As Boolean = False, Optional TieneTerminal As Boolean = False, Optional CveCuentaPadre As Integer = Nothing) As Boolean + UsaLayout As Boolean, UsaTarjeta As Boolean, Optional SaldoInicial As Double = 0, Optional UsaLayoutGrupos As Boolean = False, Optional TieneTerminal As Boolean = False, + Optional CveCuentaPadre As Integer = Nothing, Optional CveSubProyecto As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Banc_BancosCuentasAdd") @@ -479,7 +481,7 @@ Public Class ClsBancos .Add("@UsaLayoutGrupos", SqlDbType.Bit).Value = UsaLayoutGrupos .Add("@TieneTerminal", SqlDbType.Bit).Value = TieneTerminal .Add("@CveCuentaPadre", SqlDbType.Int).Value = CveCuentaPadre - + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto End With @@ -502,7 +504,8 @@ Public Class ClsBancos Public Function UpdateBancosCuentas(CveBanco As Integer, CveTipoCuenta As Integer, NumCuenta As String, CLABE As String, CveMoneda As Integer, DiaCorte As Integer, FInicial As Integer, FActual As Integer, FFinal As Integer, LimiteCredito As Double, FormatoCheque As String, Estatus As Boolean, CveCuenta As Integer, ConvenioPagoElectronico As String, - UsaLayout As Boolean, UsaTarjeta As Boolean, Optional UsaLayoutGrupos As Boolean = False, Optional TieneTerminal As Boolean = False, Optional CveCuentaPadre As Integer = Nothing) As Boolean + UsaLayout As Boolean, UsaTarjeta As Boolean, Optional UsaLayoutGrupos As Boolean = False, Optional TieneTerminal As Boolean = False, + Optional CveCuentaPadre As Integer = Nothing, Optional CveSubProyecto As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Banc_BancosCuentasUpdate") @@ -527,7 +530,7 @@ Public Class ClsBancos .Add("@UsaLayoutGrupos", SqlDbType.Bit).Value = UsaLayoutGrupos .Add("@TieneTerminal", SqlDbType.Bit).Value = TieneTerminal .Add("@CveCuentaPadre", SqlDbType.Int).Value = CveCuentaPadre - + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto End With @@ -1099,7 +1102,7 @@ Public Class ClsBancos Dim Timbrado As New Timbrado Dim CFDIVersion As String = "4.0" - If GetComplementoPagosImpuestos(CveIE, UsuarioActual.CveEmpresa) Then + If GetComplementoPagosImpuestos(CveIE, UsuarioActual.CveEmpresa, CvePrePoliza:=CvePrePoliza) Then dttpagosimpuestos = DtResultados End If @@ -1386,7 +1389,7 @@ Public Class ClsBancos Return Retorno End Function - Public Function GetComplementoPagosImpuestos(CveIE As Integer, CveEmpresa As Integer) As Boolean + Public Function GetComplementoPagosImpuestos(CveIE As Integer, CveEmpresa As Integer, Optional CvePrePoliza As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Banc_ComplementoPagoImpuestosGet") @@ -1394,6 +1397,7 @@ Public Class ClsBancos With SqlAdapter.SelectCommand.Parameters .Add("@CveIE", SqlDbType.Int).Value = CveIE .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/ClsClasificaciones.vb b/App_Code/ClsClasificaciones.vb index fb2c585bf..5c81d9f0c 100644 --- a/App_Code/ClsClasificaciones.vb +++ b/App_Code/ClsClasificaciones.vb @@ -421,6 +421,59 @@ Public Class ClsClasificaciones Return Retorno End Function + Public Function UpdateClasificacionFranquicia(CveClasificacion As Integer, Clasificacion As String, CveEmpresaActual As Integer, CveEmpresaFranquicia As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_ClasificacionFranquiciaUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@Clasificacion", SqlDbType.VarChar).Value = Clasificacion + .Add("@CveEmpresaActual", SqlDbType.Int).Value = CveEmpresaActual + .Add("@CveEmpresaFranquicia", SqlDbType.Int).Value = CveEmpresaFranquicia + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("La clasificación no se guardo debido a que actualmente se encuentra registrado", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al intentar actualizar los datos de la clasificación.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al intentar Actualizar los datos de la clasificación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + + Public Function RemoveClasificacionFranquicia(CveClasificacion As Integer, CveEmpresaActual As Integer, CveEmpresaFranquicia As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Vta_ClasificacionFranquiciaRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion + .Add("@CveEmpresaActual", SqlDbType.Int).Value = CveEmpresaActual + .Add("@CveEmpresaFranquicia", SqlDbType.Int).Value = CveEmpresaFranquicia + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + If Ex1.Message.Contains("Número: 2627;") Then + Alert("La clasificación no se guardo debido a que actualmente se encuentra registrado", TipoMensaje.MsgAdvertencia) + Else + Me.OnError("Ocurrió un error al intentar actualizar los datos de la clasificación.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End If + Catch ex As Exception + OnError("Ocurrió un error al intentar Actualizar los datos de la clasificación.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + 'Public Function UpdateClasificacionCunetas(CveClasificacion As Integer, CveCuentaContableIngreso As Integer, CveCuentaContableGasto As Integer, CveEmpresa As Object) As Boolean 'End Function diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index 5764b4f20..0ae7b54da 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -159,6 +159,7 @@ Public Class ClsClientes Public Property RepresentanteLegal As String Public Property CveAlmacenAsignado As Integer = -1 Public Property CveAlmacenAlterno As Integer = -1 + Public Property CveAlmacenConsignacion As Integer = -1 Public Property UsaProductoAlterno As Boolean = False @@ -409,6 +410,8 @@ Public Class ClsClientes _RepresentanteLegal = Data(0)("RepresentanteLegal").ToString _CveAlmacenAsignado = Data(0)("CveAlmacenAsignado").ToString.ToEntero _CveAlmacenAlterno = Data(0)("CveAlmacenAlterno").ToString.ToEntero + _CveAlmacenConsignacion = Data(0)("CveAlmacenConsignacion").ToString.ToEntero + _UsaProductoAlterno = CBool(Data(0)("UsaProductoAlterno")) End If @@ -527,7 +530,7 @@ Public Class ClsClientes Optional CveMotivoTraslado As Integer = 0, Optional NumRegIdTrib As String = "", Optional ComExtEstado As String = "-1", Optional ComExtMunicipio As String = "-1", Optional ComExtColonia As String = "-1", Optional RequiereOC As Boolean = False, Optional LT As String = "0", Optional LG As String = "0", Optional EsDistribuidor As Boolean = False, Optional TipoCliente As Integer = 1, Optional CargoUsado As Boolean = False, Optional BonificacionUsado As Boolean = False, Optional CveTipoRetencion As Integer = 0, Optional CorreoEntregaCompras As String = "-1", Optional CorreoEntregaAlmacen As String = "-1", Optional CveSATEstado As Integer = -1, Optional CveAdminTrayecto As Integer = -1, Optional CveRegimenFiscal As Integer = 0, Optional RegimenSociedad As String = "-1", Optional TipoPersona As Boolean = False, - Optional RepresentanteLegal As String = "", Optional FechaLimiteCredito As Date = MinFecha, Optional ComExtCalle As String = "-1", Optional ComExtNumExt As String = "-1", Optional ComExtCP As String = "-1", Optional Genero As Boolean = True, Optional CveAlmacenAsignado As Integer = -1, Optional CveAlmacenAlterno As Integer = -1, Optional UsaProductoAlterno As Boolean = False) As Boolean + Optional RepresentanteLegal As String = "", Optional FechaLimiteCredito As Date = MinFecha, Optional ComExtCalle As String = "-1", Optional ComExtNumExt As String = "-1", Optional ComExtCP As String = "-1", Optional Genero As Boolean = True, Optional CveAlmacenAsignado As Integer = -1, Optional CveAlmacenConsignacion As Integer = -1, Optional CveAlmacenAlterno As Integer = -1, Optional UsaProductoAlterno As Boolean = False) As Boolean Dim Retorno As Boolean = False @@ -657,6 +660,7 @@ Public Class ClsClientes .Add("@Genero", SqlDbType.Bit).Value = Genero .Add("@CveAlmacenAsignado", SqlDbType.Int).Value = CveAlmacenAsignado .Add("@CveAlmacenAlterno", SqlDbType.Int).Value = CveAlmacenAlterno + .Add("@CveAlmacenConsignacion", SqlDbType.Int).Value = CveAlmacenConsignacion .Add("@UsaProductoAlterno", SqlDbType.Bit).Value = UsaProductoAlterno End With Try @@ -703,7 +707,7 @@ Public Class ClsClientes Optional ApellidoPaternoPF As String = "-1", Optional ApellidoMaternoPF As String = "-1", Optional NombresPF As String = "-1", Optional RequiereOC As Boolean = False, Optional LT As String = "0", Optional LG As String = "0", Optional EsDistribuidor As Boolean = False, Optional TipoCliente As Integer = 1, Optional CargoUsado As Boolean = False, Optional BonificacionUsado As Boolean = False, Optional CveTipoRetencion As Integer = 0, Optional CorreoEntregaCompras As String = "-1", Optional CorreoEntregaAlmacen As String = "-1", Optional CveSATEstado As Integer = -1, Optional CveAdminTrayecto As Integer = -1, Optional NoDesglosaIVA As Boolean = False, Optional CveRegimenFiscal As Integer = 0, Optional RegimenSociedad As String = "-1", Optional TipoPersona As Boolean = False, - Optional RepresentanteLegal As String = "", Optional FechaLimiteCredito As Date = MinFecha, Optional ComExtCalle As String = "-1", Optional ComExtNumExt As String = "-1", Optional ComExtCP As String = "-1", Optional Genero As Boolean = True, Optional CveAlmacenAsignado As Integer = -1, Optional CveAlmacenAlterno As Integer = -1, Optional UsaProductoAlterno As Boolean = False) As Boolean + Optional RepresentanteLegal As String = "", Optional FechaLimiteCredito As Date = MinFecha, Optional ComExtCalle As String = "-1", Optional ComExtNumExt As String = "-1", Optional ComExtCP As String = "-1", Optional Genero As Boolean = True, Optional CveAlmacenAsignado As Integer = -1, Optional CveAlmacenAlterno As Integer = -1, Optional CveAlmacenConsignacion As Integer = -1, Optional UsaProductoAlterno As Boolean = False) As Boolean Dim Retorno As Boolean = False @@ -842,6 +846,7 @@ Public Class ClsClientes .Add("@ComExtCP", SqlDbType.VarChar).Value = ComExtCP .Add("@Genero", SqlDbType.Bit).Value = Genero .Add("@CveAlmacenAsignado", SqlDbType.Int).Value = CveAlmacenAsignado + .Add("@CveAlmacenConsignacion", SqlDbType.Int).Value = CveAlmacenConsignacion .Add("@CveAlmacenAlterno", SqlDbType.Int).Value = CveAlmacenAlterno .Add("@UsaProductoAlterno", SqlDbType.Bit).Value = UsaProductoAlterno @@ -984,9 +989,12 @@ Public Class ClsClientes Dim Retorno As Boolean = False DataAdapter("PA_Vta_SucursalClienteGet") - SqlAdapter.SelectCommand.Parameters.Add("@CveCliente", SqlDbType.Int).Value = CveCliente - SqlAdapter.SelectCommand.Parameters.Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal - SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try SqlAdapter.Fill(Data) Retorno = True @@ -1001,10 +1009,13 @@ Public Class ClsClientes Dim Retorno As Boolean = False DataAdapter("PA_Vta_ClientesSucursalesGet") - SqlAdapter.SelectCommand.Parameters.Add("@RFC", SqlDbType.VarChar).Value = RFC - SqlAdapter.SelectCommand.Parameters.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa - SqlAdapter.SelectCommand.Parameters.Add("@CveCliente", SqlDbType.Int).Value = CveCliente - SqlAdapter.SelectCommand.Parameters.Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + With SqlAdapter.SelectCommand.Parameters + .Add("@RFC", SqlDbType.VarChar).Value = RFC + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + End With + Try SqlAdapter.Fill(Data) Retorno = True @@ -1052,7 +1063,7 @@ Public Class ClsClientes 'End Function Public Function AddSucursal(CveCliente As Integer, Sucursal As String, CveUsuario As Integer, Ciudad As String, Colonia As String, CP As String, Direccion As String, Estado As String, Localidad As String, Pais As String, NoExt As String, NoInt As String, Telefono As String, Correo As String, CorreoCotizacion As String, Contacto As String, CveVendedor As Integer, NumCtaPago As String, CveMetodoPago As Integer, LimiteCredito As Decimal, CveResponsableSucursal As Integer, CveUsoCFDI As Integer, CveFormaPago33 As Integer, CveMetodoPago33 As Integer, Optional LT As String = "0", Optional LG As String = "0", Optional RFC As String = "", - Optional CveAlmacenAsignado As Integer = -1, Optional CveAlmacenAlterno As Integer = -1) As Boolean + Optional CveAlmacenAsignado As Integer = -1, Optional CveAlmacenConsignacion As Integer = -1, Optional CveAlmacenAlterno As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_SucursalClienteAdd") @@ -1088,6 +1099,7 @@ Public Class ClsClientes .Add("@RFC", SqlDbType.VarChar).Value = RFC .Add("@CveAlmacenAsignado", SqlDbType.Int).Value = CveAlmacenAsignado + .Add("@CveAlmacenConsignacion", SqlDbType.Int).Value = CveAlmacenConsignacion .Add("@CveAlmacenAlterno", SqlDbType.Int).Value = CveAlmacenAlterno End With @@ -1109,7 +1121,7 @@ Public Class ClsClientes End Function Public Function UpdateSucursal(Sucursal As String, Estatus As Boolean, CveCliente As Integer, CveClienteSucursal As Integer, Ciudad As String, Colonia As String, CP As String, Direccion As String, Estado As String, Localidad As String, Pais As String, NoExt As String, NoInt As String, Telefono As String, Correo As String, CorreoCotizacion As String, Contacto As String, CveVendedor As Integer, NumCtaPago As String, CveMetodoPago As Integer, LimiteCredito As Decimal, CveResponsableSucursal As Integer, CveUsoCFDI33 As Integer, CveFormaPago33 As Integer, CveMetodoPago33 As Integer, Optional LT As String = "0", Optional LG As String = "0", Optional RFC As String = "-1", - Optional CveAlmacenAsignado As Integer = -1, Optional CveAlmacenAlterno As Integer = -1) As Boolean + Optional CveAlmacenAsignado As Integer = -1, Optional CveAlmacenConsignacion As Integer = -1, Optional CveAlmacenAlterno As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_SucursalClienteUpdate") @@ -1142,12 +1154,12 @@ Public Class ClsClientes .Add("@CveFormaPago33", SqlDbType.Int).Value = CveFormaPago33 .Add("@CveMetodoPago33", SqlDbType.Int).Value = CveMetodoPago33 - .Add("@LT", SqlDbType.VarChar).Value = LT .Add("@LG", SqlDbType.VarChar).Value = LG .Add("@RFC", SqlDbType.VarChar).Value = RFC .Add("@CveAlmacenAsignado", SqlDbType.Int).Value = CveAlmacenAsignado + .Add("@CveAlmacenConsignacion", SqlDbType.Int).Value = CveAlmacenConsignacion .Add("@CveAlmacenAlterno", SqlDbType.Int).Value = CveAlmacenAlterno End With diff --git a/App_Code/ClsCompProveedores.vb b/App_Code/ClsCompProveedores.vb index d30f714a2..23044581c 100644 --- a/App_Code/ClsCompProveedores.vb +++ b/App_Code/ClsCompProveedores.vb @@ -524,6 +524,29 @@ Public Class ClsCompProveedores Return Retorno End Function + Public Function UpdateProveedorLimiteCredito(CveProveedor As Integer, LimiteCredito As Decimal, PlazoPago As Integer, UsaLimiteCredito As Boolean, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Comp_ProveedorLimiteCreditoUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor + .Add("@LimiteCredito", SqlDbType.Money).Value = LimiteCredito + .Add("@PlazoPago", SqlDbType.Int).Value = PlazoPago + .Add("@UsaLimiteCredito", SqlDbType.Bit).Value = UsaLimiteCredito + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al Actualizar el limite de crédito del Proveedor.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + Public Function UpdateProveedorPagoElectronico(EstatusPagoElectronico As Boolean, CveUsuario As Integer, CveProveedor As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Comp_ProveedorUpdatePagoElectronico") diff --git a/App_Code/ClsCompras.vb b/App_Code/ClsCompras.vb index 83ee9fe20..4f4417e6d 100644 --- a/App_Code/ClsCompras.vb +++ b/App_Code/ClsCompras.vb @@ -1792,7 +1792,7 @@ Public Class ClsCompras StrSQL.Append(" INSERT INTO Comp_Facturas (Serie, Folio, FechaFactura, NombreProveedor, RFCDe, Total, UUID, RFCPara, XML, PDF, FueValidado, CveEmpresa, TipoFactura,Version, TipoComprobante) ") StrSQL.Append(" VALUES (@Serie, @Folio, @FechaFactura, @NombreProveedor, @RFCDe, @Total, @UUID, @RFCPara, @XML, @PDF, @FueValidado, @CveEmpresa, @PreFijo, @Version,@TipodeComprobante); ") StrSQL.Append(" SET @Retorno = 1; ") - StrSQL.Append(" SET @CveFactura = IDENT_CURRENT('Comp_Facturas'); ") + StrSQL.Append(" SET @CveFactura = SCOPE_IDENTITY(); ") StrSQL.Append(" UPDATE Comp_Facturas SET XML = CONCAT(@CveFactura,'.xml'), PDF = CONCAT(@CveFactura ,'.pdf') WHERE CveFactura = @CveFactura; ") StrSQL.Append(" END ") StrSQL.Append(" ELSE BEGIN SET @CveFactura = @tTotal; END ") diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index 9afc08dcc..e9fd6f6d5 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -1004,11 +1004,13 @@ Public Class ClsContabilidad If ex1.Message.Contains("50015;") Then OnError("No se puede registrar una póliza en un ejercicio Cerrado", ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) ElseIf ex1.Message.Contains("50024; La Cuenta no fue detectada") Then - Dim dtt As DataTable = ClsPaginas.GlobalDTContaConceptosContables(CveConceptoContable) + Dim dr As Data.DataRow = ClsPaginas.GlobalDTContaConceptosContables(CveConceptoContable).FiltroPrimero("") Dim StrMsg As String = "" - If dtt IsNot Nothing Then + If dr IsNot Nothing Then + If CveConceptoContable <> dr("CveConceptoContable").ToString.ToEntero Then 'si el concepto pareja no es principal, lo obtengo + dr = ClsPaginas.GlobalDTContaConceptosContables(dr("CveParejaContable").ToString.ToEntero).FiltroPrimero("") + End If Dim tCveEmp As Integer = CType(HttpContext.Current.Session("UsuarioSIG"), Usuario).CveEmpresa - Dim dr As Data.DataRow = dtt.FiltroPrimero("") If dr IsNot Nothing Then StrMsg = dr("ConceptoContable").ToString If dr("AplicaClasificacion").ToString = "True" Then @@ -4603,7 +4605,7 @@ Public Class ClsContabilidad Public Function AddCuenta(CvePadre As Integer, Codigo As String, Nombre As String, Tipo As String, CtaMayor As Integer, CveMoneda As Integer, Optional DigAgrupador As Integer = -1, Optional CveAgrupadorSAT As Integer = -1, Optional NomIdioma As String = "", Optional CveEmpresaParam As Integer = -1, Optional CveConceptoAdmin As Integer = -1, Optional CveProveedor As Integer = -1, Optional CveCliente As Integer = -1, Optional CveClasificacion As Integer = -1, Optional PorcentajeImpuesto As Decimal = -1, - Optional CveBancoCuenta As Integer = -1, Optional IdCompaq As Integer = -1) As Integer + Optional CveBancoCuenta As Integer = -1, Optional IdCompaq As Integer = -1, Optional CodigoVinculacion As String = "") As Integer Dim Retorno As Integer = 0 DataAdapter("PA_Conta_CuentasAdd") @@ -4625,6 +4627,7 @@ Public Class ClsContabilidad .Add("@PorcentajeImpuesto", SqlDbType.Money).Value = PorcentajeImpuesto .Add("@CveBancoCuenta", SqlDbType.Int).Value = CveBancoCuenta .Add("@IdCompaq", SqlDbType.Int).Value = IdCompaq + .Add("@CodigoVinculacion", SqlDbType.VarChar).Value = CodigoVinculacion '.Add("@CveCuenta", SqlDbType.Int).Value = 0 '.Add("@Error", SqlDbType.VarChar).Value = "" diff --git a/App_Code/ClsContratos.vb b/App_Code/ClsContratos.vb index a5899031b..3c0f7b656 100644 --- a/App_Code/ClsContratos.vb +++ b/App_Code/ClsContratos.vb @@ -3246,7 +3246,7 @@ Public Class ClsContratos Return Retorno End Function - Public Function GetPresupuestosRepDetalleCompras(CveProyecto As Integer, CveSubProyecto As Integer, CveAgrupador As Integer, CveTipoGasto As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, CveUsuario As Integer) As Boolean + Public Function GetPresupuestosRepDetalleCompras(CveProyecto As Integer, CveSubProyecto As Integer, CveAgrupador As Integer, CveTipoGasto As Integer, FechaI As Date, FechaF As Date, CveEmpresa As Integer, CveUsuario As Integer, Optional Comprometido As Boolean = False) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Con_PresupuestosRepDetalleCompra") @@ -3259,6 +3259,7 @@ Public Class ClsContratos .Add("@FechaF", SqlDbType.Date).Value = FechaF .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveUsuarioConsulta", SqlDbType.Int).Value = CveUsuario + .Add("@Comprometido", SqlDbType.Bit).Value = Comprometido End With Try diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb index ef9e785c4..0792aa609 100644 --- a/App_Code/ClsGenerales.vb +++ b/App_Code/ClsGenerales.vb @@ -76,7 +76,7 @@ Public Class ClsGenerales If TransaccionCompartida Is Nothing Then SqlConexion = New SqlConnection - SqlConexion.ConnectionString = ClsPaginas.UsuarioActualRutaDB + SqlConexion.ConnectionString = ClsPaginas.UsuarioActualRutaDB Try SqlConexion.Open() Catch ex As Exception @@ -4160,14 +4160,15 @@ Public Class ClsGenerales End Function - Public Function GetEntregaAlmacenRutaDetalle(CveEntregaAlmacen As Integer) As Boolean + Public Function GetEntregaAlmacenRutaDetalle(CveEntregaAlmacen As Integer, Optional ValidaEntrega As Boolean = False) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Inv_EntregaAlmacenRutaDetalleGet") With SqlAdapter.SelectCommand.Parameters - .Add("@CveEntregaAlmacen", SqlDbType.Int).Value = CveEntregaAlmacen + .Add("@CveEntregaAlmacen", SqlDbType.Int).Value = CveEntregaAlmacen + .Add("@ValidaEntrega", SqlDbType.Bit).Value = ValidaEntrega End With Try diff --git a/App_Code/ClsInventarios.vb b/App_Code/ClsInventarios.vb index e1327629c..cb986fc36 100644 --- a/App_Code/ClsInventarios.vb +++ b/App_Code/ClsInventarios.vb @@ -78,6 +78,7 @@ Public Class ClsInventarios Public Property CveVenta As Integer Public Property TipoEstatus As Integer Public Property EsDevolucionVenta As Integer + Public Property CantidadVenta As Decimal Public Property CvePersonal As Integer Public Property NombreCompleto As String Public Property NombreCapturo As String @@ -1608,6 +1609,7 @@ Public Class ClsInventarios .Add("@Serie", SqlDbType.VarChar).Value = Serie .Add("@CveAlmacenes", SqlDbType.VarChar).Value = CveAlmacenes + End With Try @@ -1626,7 +1628,8 @@ Public Class ClsInventarios End Function Public Function GetKardexPSNavegacion(Entrada As Boolean, Salida As Boolean, CvePS As Integer, FechaI As String, FechaF As String, CveAlmacen As Integer, CveTiposAlmacen As String, CveUnidadMedida As Integer, CveUsuario As Integer, CveEmpresa As Integer, - Optional CveAlmacenes As String = "-1", Optional Siguiente As Boolean = True, Optional CodigoInicio As String = "-1", Optional CodigoFin As String = "-1") As Boolean + Optional CveAlmacenes As String = "-1", Optional Siguiente As Boolean = True, Optional CodigoInicio As String = "-1", Optional CodigoFin As String = "-1", Optional CveMarca As Integer = -1, + Optional CveProveedor As Integer = -1) As Boolean Dim Retorno As Boolean = False @@ -1647,6 +1650,8 @@ Public Class ClsInventarios .Add("@Siguiente", SqlDbType.Bit).Value = Siguiente .Add("@CodigoInicio", SqlDbType.VarChar).Value = CodigoInicio .Add("@CodigoFin", SqlDbType.VarChar).Value = CodigoFin + .Add("@CveMarca", SqlDbType.Int).Value = CveMarca + .Add("@CveProveedor", SqlDbType.Int).Value = CveProveedor End With @@ -3572,8 +3577,9 @@ Public Class ClsInventarios If Data IsNot Nothing AndAlso Data.Rows.Count = 1 Then Dim dr As DataRow = Data.Rows(0) - TipoEstatus = dr("TipoEstatus").ToString.ToEntero - EsDevolucionVenta = dr("EsVentaDevolucion").ToString.ToEntero + TipoEstatus = dr("TipoEstatus").ToString().ToEntero + EsDevolucionVenta = dr("EsVentaDevolucion").ToString().ToEntero + CantidadVenta = dr("CantidadVenta").ToString().ToDecimal() Retorno = True End If @@ -4463,6 +4469,25 @@ Public Class ClsInventarios Return Retorno End Function + Public Function UpdateOSEstatusInventario(CveOS As Integer, Estatus As Boolean, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_OS_OSEstatusInventarioUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOS", SqlDbType.Int).Value = CveOS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el estatus de OS.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function #End Region #Region " INVENTARIOS - SOLICITUD DE TRASPASOS " diff --git a/App_Code/ClsMovimientos.vb b/App_Code/ClsMovimientos.vb index 90618ea70..4fe89fa64 100644 --- a/App_Code/ClsMovimientos.vb +++ b/App_Code/ClsMovimientos.vb @@ -777,6 +777,7 @@ Public Class ClsMovimientos End With Try + SqlAdapter.SelectCommand.CommandTimeout = 0 SqlAdapter.Fill(Data) Retorno = True Catch ex As Exception @@ -1393,6 +1394,7 @@ Public Class ClsMovimientos End With Try + SqlAdapter.SelectCommand.CommandTimeout = 0 SqlAdapter.Fill(Data) Retorno = True Catch ex As Exception diff --git a/App_Code/ClsNominas.vb b/App_Code/ClsNominas.vb index 18cdb0f79..fcb9f0653 100644 --- a/App_Code/ClsNominas.vb +++ b/App_Code/ClsNominas.vb @@ -2297,6 +2297,23 @@ Public Class ClsNominas Return Retorno End Function + Public Function UpdatePeriodoEnvioPrenomina(CvePeriodo As Integer, CveEmpresa As Integer, PreAsistenciaEnviada As Boolean) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Nom_PeriodoEnvioPrenominaUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CvePeriodo", SqlDbType.Int).Value = CvePeriodo + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@PreAsistenciaEnviada", SqlDbType.Int).Value = PreAsistenciaEnviada + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el envio de Pre asistencia del periodo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function RemovePeriodo(CvePeriodo As Integer) As Boolean Dim Retorno As Boolean = False diff --git a/App_Code/ClsOIEventos.vb b/App_Code/ClsOIEventos.vb index 0e19ccc6d..43dadaa3d 100644 --- a/App_Code/ClsOIEventos.vb +++ b/App_Code/ClsOIEventos.vb @@ -87,6 +87,7 @@ Public Class ClsOIEventos End Property #Region "Propiedades de la tabla OI_Eventos" Public Property CveEvento As Integer + Public Property CveIndicador As Integer Public Property CveTipoEvento As Integer Public Property Folio As Integer Public Property TipoEvento As String @@ -153,11 +154,11 @@ Public Class ClsOIEventos #End Region #End Region - Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) + Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing, Optional UsuarioActual As Usuario = Nothing) If TransaccionCompartida Is Nothing Then SqlConexion = New SqlConnection - SqlConexion.ConnectionString = ClsPaginas.UsuarioActualRutaDB + SqlConexion.ConnectionString = If(UsuarioActual IsNot Nothing, UsuarioActual.RutaDB, ClsPaginas.UsuarioActualRutaDB) Try SqlConexion.Open() Catch ex As Exception @@ -965,7 +966,7 @@ Public Class ClsOIEventos Optional CveOS As Integer = -1, Optional CveOC As Integer = -1, Optional CvePersonal As Integer = -1, Optional CveProveedor As Integer = -1, Optional CveCompra As Integer = -1, Optional CveVenta As Integer = -1, Optional CveContrato As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional CveMovimientoAlmacen As Integer = -1, Optional CorreoExterno As String = "", Optional CveTableroLista As Integer = -1, Optional Lugar As String = "", - Optional Asistencia As String = "", Optional Duracion As String = "", Optional CveAcercamiento As Integer = -1) As Boolean + Optional Asistencia As String = "", Optional Duracion As String = "", Optional CveAcercamiento As Integer = -1, Optional CveIndicador As Integer = -1) As Boolean Dim retorno As Boolean = False Dim xmlMiembros As System.Xml.Linq.XDocument = Nothing @@ -1028,6 +1029,7 @@ Public Class ClsOIEventos .Add("@Lugar", SqlDbType.VarChar).Value = Lugar .Add("@CveTableroLista", SqlDbType.VarChar).Value = CveTableroLista .Add("@CveAcercamiento", SqlDbType.VarChar).Value = CveAcercamiento + .Add("@CveIndicador", SqlDbType.VarChar).Value = CveIndicador '.Add("@mailPara", SqlDbType.VarChar).Direction = ParameterDirection.Output @@ -3216,8 +3218,66 @@ Public Class ClsOIEventos Return Retorno End Function + #End Region + + +#Region "I N D I C A D O R E S " + +#End Region + + Public Function AddIndicador(Indicador As Integer, CveSubProyecto As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + CveIndicador = -1 + + DataAdapter("PA_Dir_IndicadorAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Indicador", SqlDbType.Int).Value = Indicador + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveIndicador", SqlDbType.Int).Direction = ParameterDirection.Output + End With + + Try + SqlAdapter.Fill(Data) + CveIndicador = SqlAdapter.SelectCommand.Parameters("@CveIndicador").Value.ToString().ToEntero() + If CveIndicador > 0 Then + Retorno = True + End If + + Catch ex As Exception + OnError("Ocurrió un error al agregar el indicador", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + Public Function UpdateIndicador(CveIndicador As Integer, Valor As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Dir_IndicadorUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveIndicador", SqlDbType.Int).Value = CveIndicador + .Add("@Valor", SqlDbType.Int).Value = Valor + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el indicador", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + + Return Retorno + End Function + + #End Region ' IDisposable diff --git a/App_Code/ClsOS.vb b/App_Code/ClsOS.vb index 1263b38d9..376513ad8 100644 --- a/App_Code/ClsOS.vb +++ b/App_Code/ClsOS.vb @@ -458,12 +458,12 @@ Public Class ClsOS End Try Return Retorno - End Function - + End Function + #End Region - + #Region "ClsOSOrdenesServicios" - 'Reporte de Ventas + 'Reporte de Ventas Public Function GetRepOrdenesServicio(FechaI As Date, FechaF As Date, FechaTerminado As String, CveCliente As Integer, CveSubProyecto As Integer, CveUsuarioRecibio As Integer, CveTecnico As Integer, CveEstatusOrdenServicio As Integer, CveEmpresa As Integer, Optional Opcion As Integer = -1, Optional CveUsuarioAsignado As Integer = -1) As Boolean Dim Retorno As Boolean = False @@ -492,12 +492,32 @@ Public Class ClsOS OnError("Ocurrió un error al obtener el Reporte de Ordenes de Servicio.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try + Return Retorno + End Function + + Public Function GetRepOSEstatus(CveOS As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_OS_OSEstatusRepGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveOS", SqlDbType.Int).Value = CveOS + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el Reporte de estatus de OS.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno End Function Public Function GetRepOrdenesServicioMedicasRep(FechaI As Date, FechaF As Date, CveCliente As Integer, CveVendedor As Integer, CveEstatusOrdenServicio As Integer, CveUsuarioAtendio As Integer, CveSubProyecto As Integer, CveEmpresa As Integer, - Optional CveMedico As Integer = -1, Optional CveProcedimiento As Integer = -1, Optional CveEspecialidad As Integer = -1, Optional CveClienteSucursal As Integer = -1) As Boolean + Optional CveMedico As Integer = -1, Optional CveProcedimiento As Integer = -1, Optional CveEspecialidad As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional CveUsuario As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_OS_OrdenesServiciosMedicasRepGet") @@ -516,6 +536,7 @@ Public Class ClsOS .Add("@CveProcedimiento", SqlDbType.Int).Value = CveProcedimiento .Add("@CveEspecialidad", SqlDbType.Int).Value = CveEspecialidad .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario End With diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index ae4459a62..277b6fbf5 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -1965,7 +1965,7 @@ Public Class ClsPaginas End Set End Property - Property GlobalDTGralCartaPorteConfigAutoTransportes() As DataTable + Property GlobalDTGralCartaPorteConfigAutoTransportes As DataTable Get Dim AppNombre As String = "GetCartaPorteConfigAutoTransportes" If Application(AppNombre) Is Nothing Then @@ -5966,8 +5966,6 @@ Public Class ClsPaginas Dim PermisoSCTR2 As String = "" Dim ConfATR1 As String = "" Dim ConfATR2 As String = "" - - Dim ObjInv As New ClsGenerales If ObjInv.GetGralTimbre(CveTimbre, "-1", MinFecha, MaxFecha, -1, UsuarioActual.CveEmpresa, -1) Then @@ -5984,7 +5982,6 @@ Public Class ClsPaginas ConfATR1 = Dr("ConfATR1").ToString ConfATR2 = Dr("ConfATR2").ToString End If - End If End If End If @@ -6078,22 +6075,6 @@ Public Class ClsPaginas Dim VersionCCP As String = "" Dim PrefijoCCP As String = "" - 'Try - - ' 'XDocument doc = XDocument.Parse(Xml); - ' 'String Version = doc.Descendants("cartaporte30:CartaPorte").First().Attribute("version").Value; - - ' Dim NodoVersionCCP As XmlNode = XMLDoc.Descendants("cartaporte30:CartaPorte") - ' If NodoVersionCCP IsNot Nothing Then - ' VersionCCP = ValorXML(NodoVersionCCP, "version") - ' Else - ' VersionCCP = "2.0" - ' End If - 'Catch ex As Exception - - 'End Try - - If Version = "3.3" Then cfdVer = "http://www.sat.gob.mx/cfd/3" Else ' se considera que es la version 4.0 @@ -6160,6 +6141,9 @@ Public Class ClsPaginas Dim nodeCartaPorte As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:CartaPorte", PrefijoCCP), namespaces) If nodeCartaPorte IsNot Nothing Then TransporteInternacional = ValorXML(nodeCartaPorte, "TranspInternac", "") + Dim CveTransporte As String = ValorXML(nodeCartaPorte, "ViaEntradaSalida", "") + 'Dim nodeFiguraTransporte As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:FiguraTransporte", "cartaporte20"), namespaces) + If CveTransporte <> "" Then MedioTransporte = String.Format("{0} - {1}", CveTransporte, HtTransporte(CveTransporte).ToString()) End If Dim nodeAutotransporteFederal As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:Autotransporte", PrefijoCCP), namespaces) @@ -6202,12 +6186,6 @@ Public Class ClsPaginas End If End If - 'Dim nodeFiguraTransporte As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:FiguraTransporte", "cartaporte20"), namespaces) - 'If nodeFiguraTransporte IsNot Nothing Then - ' Dim CveTransporte As String = ValorXML(nodeFiguraTransporte, "TipoFigura", "") - ' MedioTransporte = String.Format("{0} - {1}", CveTransporte, HtTransporte(CveTransporte).ToString()) - 'End If - Dim nodeMercancias As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:Mercancia", PrefijoCCP), namespaces) For Each node As XmlNode In nodeMercancias Dim Row As DataRow = DtMercancias.NewRow @@ -6293,8 +6271,6 @@ Public Class ClsPaginas End If Row("Direccion") = String.Format("{0} Col.{1},{2},{3}. CP {4}", calle, Colonia, Municipio, Estado, CP) End If - - DtUbicaciones.Rows.Add(Row) Next @@ -6438,11 +6414,6 @@ Public Class ClsPaginas params.Add(New ReportParameter("ConfATR2", ConfATR2)) End If - - - ' [@CertificadoContribuyente] - '[@CadenaOriginal] - Dim lrds As New List(Of ReportDataSource) Dim rds As New ReportDataSource @@ -6482,7 +6453,6 @@ Public Class ClsPaginas retorno.DataSources.AddRange(lrds) End If - End If Catch ex As Exception OnError("Ocurrió un error al generar el pdf de la carta porte", ex) @@ -7145,7 +7115,7 @@ Public Class ClsPaginas params.Add(New ReportParameter("CveVenta", Vta.CveVenta.ToString)) End If 'COMPU DN DIFUSA - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119, 137, 132, 144, 177) Then + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119, 137, 132, 144, 177, 186) Then Dim FirmaVendedor As New System.IO.FileInfo(String.Format("{0}Firmas\{1}.png", UsuarioActual.Empresa.Ruta, Vta.CveVendedor)) params.Add(New ReportParameter("FirmaVendedor", If(FirmaVendedor.Exists, New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Firmas/{1}.png", UsuarioActual.CveEmpresa, Vta.CveVendedor))).AbsoluteUri, ""))) params.Add(New ReportParameter("Entrega", Vta.Entrega)) @@ -8831,7 +8801,7 @@ Public Class ClsPaginas If File.Exists($"{UsuarioActual.Empresa.Ruta}Formatos\ReciboDePago.rdlc") Then rutaArchivo = $"{UsuarioActual.Empresa.Ruta}Formatos\ReciboDePago.rdlc" Else - rutaArchivo = " \Empresas\Grales\Formatos\ReciboDePago.rdlc" + rutaArchivo = "\Empresas\Grales\Formatos\ReciboDePago.rdlc" End If If Not Directory.Exists($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\") Then Directory.CreateDirectory($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\") Dim ArchivoPDF As New System.IO.FileInfo($"{Ruta}PDF\Pag\{Serie}-{Folio}.pdf") @@ -8843,7 +8813,7 @@ Public Class ClsPaginas Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) End Try Else - File.WriteAllBytes($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\{SerieFolio}.pdf", StreamPDF(rutaArchivo, lrds, params, "Pago", "PDF")) + File.WriteAllBytes($"{UsuarioActual.Empresa.Ruta}PDF\Pag\{SerieFolio}.pdf", StreamPDF(rutaArchivo, lrds, params, "Pago", "PDF")) End If If imprimir Then ImprimirPDF(rutaArchivo, lrds, params, SerieFolio, "PDF") @@ -10493,6 +10463,7 @@ Public Class ClsPaginas PaginaDict.Add("/OS/Asignaciones.aspx".ToUpper(), 125) PaginaDict.Add("/OS/RepServicioDomicilio.aspx".ToUpper(), 1330) PaginaDict.Add("/OS/RepOSMedicas.aspx".ToUpper(), 1345) + PaginaDict.Add("/OS/RepOSEstatus.aspx".ToUpper(), 1349) #End Region #Region "OC" PaginaDict.Add("/OC/OC.aspx".ToUpper(), 155) @@ -10547,6 +10518,7 @@ Public Class ClsPaginas PaginaDict.Add("/OI/CatDocumentoSubCategoria.aspx".ToUpper(), -1) PaginaDict.Add("/OI/Documentos.aspx".ToUpper(), -1) PaginaDict.Add("/OI/DocumentoDetalle.aspx".ToUpper(), -1) + PaginaDict.Add("/OI/RepIndicadoresEMD.aspx".ToUpper(), 1348) #End Region #Region "Planeacion" PaginaDict.Add("/Planeacion/CatSucursales.aspx".ToUpper(), 17) @@ -10698,7 +10670,6 @@ Public Class ClsPaginas PaginaDict.Add("/Sistemas/CatProcesos.aspx".ToUpper(), 69) PaginaDict.Add("/Sistemas/CatParametros.aspx".ToUpper(), 143) PaginaDict.Add("/Sistemas/PopUpCargaCertificados.aspx".ToUpper(), 144) - PaginaDict.Add("/Sistemas/CatNotificaciones.aspx".ToUpper(), 146) PaginaDict.Add("/Sistemas/EmpresasModulos.aspx".ToUpper(), 346) PaginaDict.Add("/Sistemas/CatSesiones.aspx".ToUpper(), 374) PaginaDict.Add("/Sistemas/CatFuncionalidades.aspx".ToUpper(), 568) @@ -10817,10 +10788,7 @@ Public Class ClsPaginas PaginaDict.Add("/Ventas/CatEspecialidadesSubEspecialidades.aspx".ToUpper(), 1346) PaginaDict.Add("/Ventas/FacturacionGlobal.aspx".ToUpper(), 546) PaginaDict.Add("/Ventas/RepComisionesSMS.aspx".ToUpper(), 1347) - - - - + PaginaDict.Add("/Ventas/RepVencimientosCredito.aspx".ToUpper(), 146) diff --git a/App_Code/ClsRH.vb b/App_Code/ClsRH.vb index c9290bf53..259de04bf 100644 --- a/App_Code/ClsRH.vb +++ b/App_Code/ClsRH.vb @@ -2054,12 +2054,10 @@ Public Class ClsRH .Add("@NetoPeriodo", SqlDbType.Money).Value = NetoPeriodo .Add("@TipoSangre", SqlDbType.VarChar).Value = TipoSangre .Add("@AreaGeografica", SqlDbType.VarChar).Value = AreaGeografica - .Add("@CveSubTipoPeriodo", SqlDbType.Int).Value = CveSubTipoPeriodo - .Add("@ErrorMostrarADS", SqlDbType.VarChar).Direction = ParameterDirection.Output - - .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.Output + '.Add("@ErrorMostrarADS", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output + .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue End With @@ -2789,12 +2787,12 @@ Public Class ClsRH End Function - Public Function AddPreAsistencia(CvePersonal As Integer, Fecha As Date, CveAsistenciasInasistencias As Integer, PorcentajePago As Double, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Public Function AddPreAsistencia(CvePersonal As Integer, Fecha As Date, CveAsistenciasInasistencias As Integer, PorcentajePago As Double, CveUsuario As Integer, CveEmpresa As Integer, Optional HorasDobles As Decimal = 0, + Optional HorasTriples As Decimal = 0, Optional CveMotivoHoraExtra As Integer = -1, Optional Observacion As String = "") As Boolean Dim Retorno As Boolean = False - Data = New DataTable - 'SqlAdapter = New SqlDataAdapter("PA_RH_PersonalAsistenciasAddUpd", SqlConexion) - 'SqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure + Data = New DataTable + SqlDataAdapter("PA_RH_PersonalPreAsistenciasAddUpd") With SqlAdapter.SelectCommand.Parameters .Add("@CvePersonal", SqlDbType.Int).Value = CvePersonal @@ -2803,6 +2801,10 @@ Public Class ClsRH .Add("@PorcentajePago", SqlDbType.Float).Value = PorcentajePago .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@HorasDobles", SqlDbType.Money).Value = HorasDobles + .Add("@HorasTriples", SqlDbType.Money).Value = HorasTriples + .Add("@CveMotivoHoraExtra", SqlDbType.Int).Value = CveMotivoHoraExtra + .Add("@Observacion", SqlDbType.VarChar).Value = Observacion .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue End With @@ -6704,7 +6706,7 @@ Public Class ClsRH End Function - Public Function PreAsistenciaRegistrosGet(InicioPeriodo As Date, FinPeriodo As Date, CveTurno As Integer, CveEmpresa As Integer) As Boolean + Public Function PreAsistenciaRegistrosGet(InicioPeriodo As Date, FinPeriodo As Date, CveTurno As Integer, CveEmpresa As Integer, IncluyePreAsistencia As Boolean) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_RH_ChecadorPreasistenciaRegistrosGet") @@ -6714,6 +6716,7 @@ Public Class ClsRH .Add("@FinPeriodo", SqlDbType.Date).Value = FinPeriodo .Add("@CveTurno", SqlDbType.Int).Value = CveTurno .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@IncluyePreAsistencia", SqlDbType.Bit).Value = IncluyePreAsistencia End With Try diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index ff6047d0b..844dbb8db 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -76,11 +76,12 @@ Public Class ClsVentas SqlTransacc.Rollback() End Sub - Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) + Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing, Optional UsuarioActual As Usuario = Nothing) If TransaccionCompartida Is Nothing Then SqlConexion = New SqlConnection - SqlConexion.ConnectionString = ClsPaginas.UsuarioActualRutaDB + SqlConexion.ConnectionString = If(UsuarioActual IsNot Nothing, UsuarioActual.RutaDB, ClsPaginas.UsuarioActualRutaDB) + Try SqlConexion.Open() Catch ex As Exception @@ -595,7 +596,7 @@ Public Class ClsVentas Optional CveCliente As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional OrdenCompra As String = "-1", Optional RetIVA As Decimal = -1, Optional RetISR As Decimal = -1, Optional Kilometraje As Decimal = 0, Optional CveUsoCFDi As Integer = -1, Optional ServicioDomicilio As Boolean = False, Optional CveVendedor As Integer = -1, Optional RequiereOS As Boolean = False, Optional CveMedico As Integer = -1, Optional CveProcedimiento As Integer = -1, Optional FechaParaSurtir As DateTime = MinFecha, - Optional Paciente As String = "-1", Optional Episodio As String = "-1") As Boolean + Optional Paciente As String = "-1", Optional Episodio As String = "-1", Optional CveCondicionEntrega As Integer = -1, Optional FolioRemision As String = "-1") As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_VentasUpdate") @@ -634,6 +635,8 @@ Public Class ClsVentas .Add("@FechaParaSurtir", SqlDbType.DateTime).Value = FechaParaSurtir .Add("@Paciente", SqlDbType.VarChar).Value = Paciente .Add("@Episodio", SqlDbType.VarChar).Value = Episodio + .Add("@CveCondicionEntrega", SqlDbType.Int).Value = CveCondicionEntrega + .Add("@FolioRemision", SqlDbType.VarChar).Value = FolioRemision End With Try @@ -732,6 +735,22 @@ Public Class ClsVentas Return Retorno End Function + Public Function UpdateVentaTicketImpreso(CveVenta As Integer, Num2 As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_VentasTicketImpresoUpdate") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVenta", SqlDbType.Int).Value = CveVenta + .Add("@Num2", SqlDbType.Int).Value = Num2 + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al actualizar el estatus de la venta.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + Return Retorno + End Function + Public Function UpdateFechaVencimientoVenta(CveVenta As Integer, FechaVencimiento As Date) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_VentasFechaVencimientoUpdate") @@ -5964,6 +5983,30 @@ Public Class ClsVentas End Function + Public Function GetLineasAdicionalesVencimientos(CveCliente As Integer, TipoLinea As Integer, FechaInicio As Date, FechaFin As Date, CveMoneda As Integer, CveEmpresa As Integer) As Boolean + + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_LineasAdicionalesVencimientosGet") + With SqlAdapter.SelectCommand.Parameters + .Add("@CveCliente", SqlDbType.Int).Value = CveCliente + .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio + .Add("@FechaFin", SqlDbType.Date).Value = FechaFin + .Add("@TipoLinea", SqlDbType.Int).Value = TipoLinea + .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error obtener las lineas de adicionales.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + End Try + Return Retorno + + + End Function + + Public Function CambioClientesVendedor(CveCliente As Integer, CveVendedor As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False @@ -6178,7 +6221,8 @@ Public Class ClsVentas End Function Public Function AddMedico(Nombre As String, Apellidos As String, CedulaProfesional As String, FechaNacimiento As Date, Notas As String, Estatus As Boolean, CveUsuario As Integer, - CveEmpresa As Integer, Telefono As String, Mail As String, CveMedicoEspecialidad As Integer, Celular As String, Optional CveMedicoSubEspecialidad As Integer = -1, Optional CveVendedor As Integer = -1) As Integer + CveEmpresa As Integer, Telefono As String, Mail As String, CveMedicoEspecialidad As Integer, Celular As String, Optional CveMedicoSubEspecialidad As Integer = -1, + Optional CveVendedor As Integer = -1, Optional CvePeriodoPago As Integer = 1) As Integer Dim Retorno As Boolean = False CveMedicoNuevo = -1 @@ -6199,6 +6243,7 @@ Public Class ClsVentas .Add("@Celular", SqlDbType.VarChar).Value = Celular .Add("@CveMedicoSubEspecialidad", SqlDbType.Int).Value = CveMedicoSubEspecialidad .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CvePeriodoPago", SqlDbType.Int).Value = CvePeriodoPago .Add("@CveMedicoNuevo", SqlDbType.Int).Direction = ParameterDirection.Output End With @@ -6215,7 +6260,8 @@ Public Class ClsVentas End Function Public Function UpdateMedico(CveMedico As Integer, Nombre As String, Apellidos As String, CedulaProfesional As String, FechaNacimiento As Date, Notas As String, Estatus As Boolean, CveUsuario As Integer, - CveEmpresa As Integer, Telefono As String, Mail As String, CveMedicoEspecialidad As Integer, Celular As String, Optional CveMedicoSubEspecialidad As Integer = -1, Optional CveVendedor As Integer = -1) As Boolean + CveEmpresa As Integer, Telefono As String, Mail As String, CveMedicoEspecialidad As Integer, Celular As String, Optional CveMedicoSubEspecialidad As Integer = -1, + Optional CveVendedor As Integer = -1, Optional CvePeriodoPago As Integer = 1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_MedicosUpdate") @@ -6240,6 +6286,7 @@ Public Class ClsVentas '.Add("@Consultorio", SqlDbType.VarChar).Value = Consultorio .Add("@CveMedicoSubEspecialidad", SqlDbType.Int).Value = CveMedicoSubEspecialidad .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor + .Add("@CvePeriodoPago", SqlDbType.Int).Value = CvePeriodoPago '.Add("@Torre", SqlDbType.VarChar).Value = Torre @@ -6721,7 +6768,8 @@ Public Class ClsVentas End Function - Public Function GetProcedimientoProducto(CveProcedimiento As Integer, Estatus As Integer, CveEmpresa As Integer, CveCliente As Integer, CveSubProyecto As Integer) As Boolean + Public Function GetProcedimientoProducto(CveProcedimiento As Integer, Estatus As Integer, CveEmpresa As Integer, CveCliente As Integer, CveSubProyecto As Integer, + Optional CveClienteSucursal As Integer = -1, Optional CveTipoVenta As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_ProcedimientosProductosGet") @@ -6732,6 +6780,8 @@ Public Class ClsVentas .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveCliente", SqlDbType.Int).Value = CveCliente .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto + .Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal + .Add("@CveTipoVenta", SqlDbType.Int).Value = CveTipoVenta End With Try SqlAdapter.Fill(Data) @@ -6808,7 +6858,7 @@ Public Class ClsVentas End Function - Public Function AddUpdateComisionesMedicas(CvePS As Integer, CveEmpresa As Integer, ComisionMedico As Decimal, ComisionVendedor As Decimal, ComisionTecnico As Decimal) As Boolean + Public Function AddUpdateComisionesMedicas(CvePS As Integer, CveEmpresa As Integer, ComisionMedico As Decimal, ComisionVendedor As Decimal, ComisionTecnico As Decimal, ComisionGerente As Decimal) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_ComisionesMedicasAddUpdate") @@ -6819,6 +6869,7 @@ Public Class ClsVentas .Add("@ComisionMedico", SqlDbType.Money).Value = ComisionMedico .Add("@ComisionVendedor", SqlDbType.Money).Value = ComisionVendedor .Add("@ComisionTecnico", SqlDbType.Money).Value = ComisionTecnico + .Add("@ComisionGerente", SqlDbType.Money).Value = ComisionGerente End With Try @@ -6832,7 +6883,7 @@ Public Class ClsVentas End Function - Public Function GetComisionesMedicasRep(FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CveSubProyecto As Integer, CveProcedimiento As Integer, CveMedico As Integer, CveVendedor As Integer, CveUsuario As Integer, CveTipoVenta As Integer) As Boolean + Public Function GetComisionesMedicasRep(FechaInicio As Date, FechaFin As Date, CveEmpresa As Integer, CveSubProyecto As Integer, CveProcedimiento As Integer, CveMedico As Integer, CveVendedor As Integer, CveUsuario As Integer, CveTipoVenta As Integer, Opcion As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_ComisionesMedicasRepGet") @@ -6847,6 +6898,7 @@ Public Class ClsVentas .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario .Add("@CveTipoVenta", SqlDbType.Int).Value = CveTipoVenta + .Add("@Opcion", SqlDbType.Int).Value = Opcion End With @@ -6912,7 +6964,7 @@ Public Class ClsVentas #End Region - Public Function GetVentasMedicasIndicadoresRep(Grupo As Integer, FechaI As Date, FechaF As Date, CveCliente As Integer, CveMedico As Integer, CveProcedimiento As Integer, CveEmpresa As Integer) As Boolean + Public Function GetVentasMedicasIndicadoresRep(Grupo As Integer, FechaI As Date, FechaF As Date, CveCliente As Integer, CveMedico As Integer, CveProcedimiento As Integer, CveEmpresa As Integer, CveVendedor As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Vta_VentasMedicasIndicadoresRepGet") @@ -6924,6 +6976,7 @@ Public Class ClsVentas .Add("@CveMedico", SqlDbType.Int).Value = CveMedico .Add("@CveProcedimiento", SqlDbType.Int).Value = CveProcedimiento .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CveVendedor", SqlDbType.Int).Value = CveVendedor End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index 28c10e7e6..60c6dc724 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -355,9 +355,7 @@ Public Class Timbrado Dim UsuarioServicio As String = If(CvePACCancelacion = 2, Empresa.RFC, "rene.molina@adsistemas.mx") Dim ClaveServicio As String = If(CvePACCancelacion = 2, Empresa.RFC.ToLower, "rene2018") Dim Clave As String = Empresa.ContraseñaKey - Dim UrlServicio As String = "" ' Produccion - - UrlServicio = "https://cfdi.gofac.com.mx/timbrado.asmx?WSDL" + Dim UrlServicio As String = "https://cfdi.gofac.com.mx/timbrado.asmx?WSDL" ' Produccion If Not Empresa.FacturaProduccion Then ArchivoLLave = $"{Empresa.Ruta}Certificados\CSD01_ZUÑ920208KL4.key" @@ -365,7 +363,6 @@ Public Class Timbrado UsuarioServicio = "UserTest" ClaveServicio = "1234567890" - 'UrlServicio = "http://juancalderon-001-site6.ftempurl.com/cancelacion.asmx?WSDL" End If #Region "Valida" If Not File.Exists(ArchivoCertificado) Then @@ -1714,8 +1711,19 @@ Public Class Timbrado Dim Carta As CFDICartaPorte = ObjCFDITimbre.Complementos.CartaPorte Dim ComCartaPorte As ProfactCartaPorte.CartaPorte = New ProfactCartaPorte.CartaPorte ComCartaPorte.TranspInternac = CType([Enum].Parse(GetType(ProfactCartaPorte.CartaPorteTranspInternac), Carta.TranspInternac), ProfactCartaPorte.CartaPorteTranspInternac) - ComCartaPorte.EntradaSalidaMercSpecified = False - ComCartaPorte.ViaEntradaSalidaSpecified = False + + ComCartaPorte.RegimenAduaneroSpecified = Carta.RegimenAduanero <> "" + If Carta.RegimenAduanero <> "" Then ComCartaPorte.RegimenAduanero = ProfactCartaPorte.c_RegimenAduanero.EXD + + ComCartaPorte.EntradaSalidaMercSpecified = Carta.EntradaSalidaMercancia <> "" + If Carta.EntradaSalidaMercancia <> "" Then ComCartaPorte.EntradaSalidaMerc = ProfactCartaPorte.CartaPorteEntradaSalidaMerc.Salida + + ComCartaPorte.ViaEntradaSalidaSpecified = Carta.ViaEntradaSalida <> "" + If Carta.ViaEntradaSalida <> "" Then ComCartaPorte.ViaEntradaSalida = ProfactCartaPorte.c_CveTransporte.Item01 + + ComCartaPorte.PaisOrigenDestinoSpecified = Carta.PaisOrigenDestino <> "" + If Carta.PaisOrigenDestino <> "" Then ComCartaPorte.PaisOrigenDestino = ProfactCartaPorte.c_Pais.USA + ComCartaPorte.TotalDistRecSpecified = True ComCartaPorte.TotalDistRec = Carta.TotalDistanciaRecorrida @@ -1797,6 +1805,11 @@ Public Class Timbrado ComCartaPorte.Mercancias.Mercancia(i).MonedaSpecified = False ComCartaPorte.Mercancias.Mercancia(i).FraccionArancelariaSpecified = False If concep.UUIDComercioExt <> "" Then ComCartaPorte.Mercancias.Mercancia(i).UUIDComercioExt = concep.UUIDComercioExt + If concep.TipoMateria <> "" Then + ComCartaPorte.Mercancias.Mercancia(i).TipoMateriaSpecified = True + ComCartaPorte.Mercancias.Mercancia(i).TipoMateria = ProfactCartaPorte.c_TipoMateria.Item01 + If concep.TipoMateria = "05" Then ComCartaPorte.Mercancias.Mercancia(i).DescripcionMateria = concep.TipoMateriaDescripcion + End If If concep.SectorCOFEPRIS <> "" Then 'ComCartaPorte.Mercancias.Mercancia(i).SectorCOFEPRIS = concep.SectorCOFEPRIS @@ -2270,7 +2283,7 @@ Public Class Timbrado Dim sbMsgLog As New StringBuilder sbMsgLog.Append(xmlPrevio) sbMsgLog.Append("------------") - For Each msg As JProperty In Resultados + For Each msg As JObject In Resultados sbMsg.AppendFormat("{0}.
", msg("Value")) sbMsgLog.AppendFormat("{0}-{1}
", msg("Key"), msg("Value")) Next @@ -2448,7 +2461,7 @@ Public Class Timbrado cfdi.Ine11(Ventas.ComplementoINE.INETipoProceso, "", "") cfdi.IneEntidad(Ventas.ComplementoINE.INEEntidad, Ventas.ComplementoINE.INETipoComite) - 'If Ventas.ComplementoINE.INEIdContabilidad > 0 Then cfdi.IneContabilidad(Ventas.ComplementoINE.INEIdContabilidad) + If Ventas.ComplementoINE.INEIdContabilidad > 0 Then cfdi.IneContabilidad(Ventas.ComplementoINE.INEIdContabilidad) End Select End If @@ -2540,7 +2553,7 @@ concep.DescripcionesEspecificas.NumeroSerie) Dim Carta As CFDICartaPorte = ObjCFDITimbre.Complementos.CartaPorte ''DATOS GENERALES - cfdi.CartaPorte30("", Carta.TranspInternac, Carta.RegimenAduanero, Carta.EntradaSalidaMercancia, "", Carta.ViaEntradaSalida, Carta.TotalDistanciaRecorrida, Carta.RegistroISTMO, Carta.UbicacionPoloOrigen, Carta.UbicacionPoloDestino) + cfdi.CartaPorte30("", Carta.TranspInternac, Carta.RegimenAduanero, Carta.EntradaSalidaMercancia, Carta.PaisOrigenDestino, Carta.ViaEntradaSalida, Carta.TotalDistanciaRecorrida, Carta.RegistroISTMO, Carta.UbicacionPoloOrigen, Carta.UbicacionPoloDestino) 'UBICACIONES If Carta.Ubicaciones IsNot Nothing AndAlso Carta.Ubicaciones.Count > 0 Then @@ -2561,7 +2574,7 @@ concep.DescripcionesEspecificas.NumeroSerie) cfdi.CartaPorte30Mercancia(concep.BienesTransp, concep.ClaveSTCC, concep.Descripción, concep.Cantidad, concep.ClaveUnidad, concep.Unidad, concep.Dimensiones, concep.MaterialPeligroso, concep.ClaveMaterialPeligroso, If(concep.ClaveMaterialPeligroso <> "", concep.Embalaje, ""), If(concep.ClaveMaterialPeligroso <> "", concep.DescripEmbalaje, ""), concep.SectorCOFEPRIS, concep.NombreIngredienteActivo, concep.NomQuimico, concep.DenominacionGenericaProd, concep.DenominacionDistintivaProd, concep.Fabricante, concep.FechaCaducidad, concep.LoteMedicamento, concep.FormaFarmaceutica, concep.CondicionesEspTransp, concep.RegistroSanitarioFolioAutorizacion, If(Carta.TranspInternac <> "No", concep.PermisoImportacion, ""), If(Carta.TranspInternac <> "No", concep.FolioImpoVUCEM, ""), concep.NumCAS, If(Carta.TranspInternac <> "No", concep.RazonSocialEmpImp, ""), concep.NumRegSanPlagCOFEPRIS, concep.DatosFabricante, concep.DatosFormulador, concep.DatosMaquilador, concep.UsoAutorizado, - concep.PesoenKg, concep.ValorMercancia, concep.Moneda, concep.FraccionArrancelaria, concep.UUIDComercioExt) + concep.PesoenKg, concep.ValorMercancia, concep.Moneda, concep.FraccionArrancelaria, concep.UUIDComercioExt, concep.TipoMateria, If(concep.TipoMateria = "05", concep.TipoMateriaDescripcion, "")) For Each transp As CFDICartaPorteMercanciaTransporta In concep.MercanciasCantidadTransporta cfdi.CartaPorte30CantidadTransporta(transp.Cantidad, transp.IDOrigen, transp.IDDestino, transp.CvesTransportes) Next diff --git a/App_Code/Timbres.vb b/App_Code/Timbres.vb index dd3934601..c03537ec2 100644 --- a/App_Code/Timbres.vb +++ b/App_Code/Timbres.vb @@ -105,6 +105,7 @@ Public Class Timbres Dim CartaPorte As New CFDICartaPorte CartaPorte.TranspInternac = "No" + CartaPorte.RegimenAduanero = "" CartaPorte.EntradaSalidaMercancia = "" CartaPorte.ViaEntradaSalida = "" @@ -125,6 +126,16 @@ Public Class Timbres Dim DtMovimientos As DataTable = Nothing Dim drT As DataRow = ObjGrales.DtResultados.Rows(0) + CartaPorte.TranspInternac = drT("TranspInternacional").ToString + + If CartaPorte.TranspInternac = "Sí" Then + CartaPorte.RegimenAduanero = drT("RegimenAduanero").ToString + CartaPorte.EntradaSalidaMercancia = drT("EntradaSalidaMercancia").ToString + CartaPorte.ViaEntradaSalida = drT("ViaEntradaSalida").ToString + CartaPorte.PaisOrigenDestino = drT("DirDesClaveSATPais").ToString + End If + + Timbre.Receptor.RFC = drT("EmpresaRFC").ToString Timbre.Receptor.Nombre = drT("EmpresaNombre").ToString Timbre.Receptor.DomicilioFiscalReceptor = drT("DomicilioFiscalReceptor").ToString diff --git a/App_Code/modExtensiones.vb b/App_Code/modExtensiones.vb index 854ab6997..5bb948f6b 100644 --- a/App_Code/modExtensiones.vb +++ b/App_Code/modExtensiones.vb @@ -681,6 +681,49 @@ Namespace Extensiones directorioNew.Clear() Return retorno End Function + + + Public Function FilesCopy(oldName As String, newName As String, newDirectorio As String, Optional Sobreescribir As Boolean = False, Optional ConcatenarDirectorioBase As Boolean = True) As Boolean + Dim retorno As Boolean = True + Dim directorioOld As New StringBuilder + Dim directorioNew As New StringBuilder + directorioOld.AppendFormat("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, oldName) + If newName = "" Then + newName = oldName + Else + newName = String.Format("{0}{1}", newName, System.IO.Path.GetExtension(directorioOld.ToString())) + End If + + 'SI VA A LA CARPETA DE EMPRESAS TIENE QUE TOMAR LA RUTA DE EMPRESAS + If ConcatenarDirectorioBase Then + If newDirectorio.Contains("Empresas") Then + directorioNew.AppendFormat("{0}{1}\", ModExtensiones.DirectorioBaseEmpresas, newDirectorio) + Else + directorioNew.AppendFormat("{0}{1}\", AppDomain.CurrentDomain.BaseDirectory, newDirectorio) + End If + Else + 'SI YA TIENE EL DIRECTORIO COMPLETO NO CONCANTENA EL DIRECTORIO + directorioNew.AppendFormat("{0}\", newDirectorio) + End If + + + If Not Directory.Exists(directorioNew.ToString) Then + Directory.CreateDirectory(directorioNew.ToString) + End If + + directorioNew.Append(newName) + Try + My.Computer.FileSystem.CopyFile(directorioOld.ToString, directorioNew.ToString, Sobreescribir) + + Catch ex As Exception + Alert("", String.Format("{0} code[FilesMove]", ex.Message), TipoMensaje.MsgAdvertencia) + retorno = False + End Try + directorioOld.Clear() + directorioNew.Clear() + Return retorno + End Function + Public Function DirectoryExistsCreate(ByRef NombreDirectorio As String) As Boolean diff --git a/Ashx/CargaEventos.ashx b/Ashx/CargaEventos.ashx index 0513bd853..9777b70b6 100644 --- a/Ashx/CargaEventos.ashx +++ b/Ashx/CargaEventos.ashx @@ -461,9 +461,11 @@ Public Class CargaEventos : Implements IHttpHandler, IRequiresSessionState cevent.title = dr("DescripcionContrato").ToString cevent.start = String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime) cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime)) + cevent.FechaFinal = String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime) cevent.allDay = False cevent.NombreAcercamiento = dr("Ubicacion").ToString cevent.CveCliente = dr("CveCliente").ToString.ToEntero + cevent.NombreComercial = dr("NombreComercial").ToString cevent.CvePersonal = dr("CveChofer").ToString.ToEntero cevent.CvePersonal2 = dr("CveChofer2").ToString.ToEntero cevent.CveEventoEstatus = dr("CveContratosEstatus").ToString.ToEntero @@ -530,6 +532,7 @@ Public Class CargaEventos : Implements IHttpHandler, IRequiresSessionState cevent.end = If(tipoVista = "fecha", String.Format("{0:s}", dr("FechaInicial").ToString.ToDateTime.AddHours(1)), String.Format("{0:s}", dr("FechaFinal").ToString.ToDateTime)) cevent.allDay = False cevent.CveCliente = dr("CveCliente").ToString.ToEntero + cevent.NombreComercial = dr("NombreComercial").ToString cevent.NombreAcercamiento = dr("Ubicacion").ToString cevent.CveActivoFijo = dr("CveAF").ToString.ToEntero cevent.CvePersonal = dr("CveChofer").ToString.ToEntero diff --git a/Ashx/E119.ashx b/Ashx/E119.ashx index a774331de..a14a437ef 100644 --- a/Ashx/E119.ashx +++ b/Ashx/E119.ashx @@ -9,7 +9,7 @@ Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Imports Extensiones -Public Class E119 : Implements IHttpHandler +Public Class E119 : Implements IHttpHandler, System.Web.SessionState.IRequiresSessionState Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get @@ -59,6 +59,7 @@ Public Class E119 : Implements IHttpHandler Dim Contrasenia As String = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString() UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, CveEmpresa:=CveEmpresa) UsuarioActual.CveEmpresa = CveEmpresa + HttpContext.Current.Session("UsuarioSIG") = UsuarioActual CreaObjetoEmpresa(UsuarioActual) End If End If @@ -79,7 +80,7 @@ Public Class E119 : Implements IHttpHandler End If UsuarioActual.Empresa = ObjEmpresa.Empresa - If UsuarioActual.Empresa.RutaDB = "" Then UsuarioActual.Empresa.RutaDB = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString + End If ObjEmpresa.Dispose() End Sub @@ -267,7 +268,7 @@ Public Class E119 : Implements IHttpHandler End If Dim Productos As JArray = Nothing - + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Using ObjInventario As New ClsInventarios If ObjInventario.GetJAM_APIs(1, CveClasificacion:=CveClasificacion.ToEntero()) AndAlso ObjInventario.DtResultados IsNot Nothing Then Productos = JArray.Parse(ObjInventario.DtResultados.FiltroPrimeroValor("JsonTexto")) @@ -302,6 +303,7 @@ Public Class E119 : Implements IHttpHandler Dim TieneError As Boolean = False Dim Clasificaciones As JArray = Nothing + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Try 'Clasificaciones = JArray.Parse(ClsPaginas.GlobalDTClasificaciones(CveEmpresa).FiltraParametros("", DistinctColumns:={"CveClasificacion", "Clasificacion"}).DataTableToJSONIPP()) diff --git a/Ashx/E141.ashx b/Ashx/E141.ashx index d173221f0..4c914b2eb 100644 --- a/Ashx/E141.ashx +++ b/Ashx/E141.ashx @@ -10,7 +10,7 @@ Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Imports Extensiones -Public Class E141 : Implements IHttpHandler +Public Class E141 : Implements IHttpHandler, System.Web.SessionState.IRequiresSessionState Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get @@ -69,6 +69,7 @@ Public Class E141 : Implements IHttpHandler Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString() UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, CveEmpresa:=CveEmpresa) UsuarioActual.CveEmpresa = CveEmpresa + HttpContext.Current.Session("UsuarioSIG") = UsuarioActual CreaObjetoEmpresa(UsuarioActual) End If End If @@ -459,7 +460,7 @@ Public Class E141 : Implements IHttpHandler Dim data As New JArray Dim DtSucursalesExistencias As DataTable = Nothing - + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Using ObjInv As New ClsInventarios If ObjInv.GetExistenciasSucursales(JsonRequest("products").ToString(), CveEmpresa) Then DtSucursalesExistencias = ObjInv.DtResultados.Copy() @@ -1671,6 +1672,21 @@ Public Class E141 : Implements IHttpHandler Return JsonConvert.SerializeObject(respuesta) End If + + Dim UsuarioActual As Usuario = Nothing + Dim ObjUsuarios As New ClsSisUsuarios + If ObjUsuarios.GetUsuarios(100) Then + If ObjUsuarios.DtResultados.Rows.Count > 0 Then + Dim Usuario As String = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString() + Dim Contrasenia As String = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString() + UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, CveEmpresa:=CveEmpresa) + UsuarioActual.CveEmpresa = CveEmpresa + HttpContext.Current.Session("UsuarioSIG") = UsuarioActual + CreaObjetoEmpresa(UsuarioActual) + End If + End If + ObjUsuarios.Dispose() + Using ObjPS As New ClsProductosServicios() If ObjPS.GetExistenciasEmpresa(Codigo, CveEmpresa) Then Dim ArrayPS As New JArray @@ -1964,6 +1980,7 @@ Public Class E141 : Implements IHttpHandler Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios 'OBTERNER PRECIOS DE PUBLICO GENERAL @@ -2054,6 +2071,7 @@ Public Class E141 : Implements IHttpHandler Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios 'OBTERNER PRECIOS DE PUBLICO GENERAL @@ -2101,7 +2119,7 @@ Public Class E141 : Implements IHttpHandler Retorno = True Return Retorno End If - + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios 'OBTERNER PRECIOS DE PUBLICO GENERAL @@ -2191,7 +2209,7 @@ Public Class E141 : Implements IHttpHandler Dim payload = New JObject() Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 - + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios If ObjPS.GetExistenciasEmpresa("-1", CveEmpresa) Then @@ -2231,6 +2249,7 @@ Public Class E141 : Implements IHttpHandler Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 Dim DtVendedores As DataTable = Nothing + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Using ObjPS As New ClsProductosServicios 'OBTERNER PRECIOS DE PUBLICO GENERAL If ObjPS.GetVendedoresModificados(CveEmpresa, If(Todos, -1, 1)) Then diff --git a/Ashx/SIGWeb.ashx b/Ashx/SIGWeb.ashx index fdf93a213..498665467 100644 --- a/Ashx/SIGWeb.ashx +++ b/Ashx/SIGWeb.ashx @@ -940,6 +940,10 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState MostrarTodosAlmacenes = True End If + If (usuario.Empresa.Funcionalidad(578) = "1") AndAlso Pagina.Contiene("ventas/ventas") Then 'sms + MostrarTodosAlmacenes = True + End If + Dim objInv As New ClsInventarios Try If objInv.GetExistenciasProductosLike(Name, CveClasificacion, CveSubProyecto, Estatus.ToEntero, AplicaParaVenta, CveEmpresa, CveMarca, MostrarTodosAlmacenes:=MostrarTodosAlmacenes, CveAlmacen:=CveAlmacen) Then diff --git a/Ashx/TareasProgramadas.ashx b/Ashx/TareasProgramadas.ashx index 38dde9ef3..706130f8d 100644 --- a/Ashx/TareasProgramadas.ashx +++ b/Ashx/TareasProgramadas.ashx @@ -353,7 +353,8 @@ Public Class TareasProgramadas : Implements IHttpHandler Dim Usuario As String = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString() Dim Contrasenia As String = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString() UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, CveEmpresa:=CveEmpresa) - UsuarioActual.CveEmpresa = CveEmpresa + UsuarioActual.CveEmpresa = CveEmpresa + HttpContext.Current.Session("UsuarioSIG") = UsuarioActual CreaObjetoEmpresa(UsuarioActual) End If End If diff --git a/Bancos/CuentasBancariasDetalle.aspx b/Bancos/CuentasBancariasDetalle.aspx index e14ad0fb8..a5bf33e69 100644 --- a/Bancos/CuentasBancariasDetalle.aspx +++ b/Bancos/CuentasBancariasDetalle.aspx @@ -160,6 +160,19 @@ + + + + + + + + +
+ +
+ + Estatus: diff --git a/Bancos/CuentasBancariasDetalle.aspx.vb b/Bancos/CuentasBancariasDetalle.aspx.vb index f6a001b2e..2a64a3b22 100644 --- a/Bancos/CuentasBancariasDetalle.aspx.vb +++ b/Bancos/CuentasBancariasDetalle.aspx.vb @@ -121,8 +121,11 @@ Partial Class Bancos_CuentasBancariasDetalle Private Sub CargarBanco() DdlBanco.DataSource = GlobalDTBancos.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) DdlBanco.DataBind() - - DdlBanco.Items.Add(New ListItem("Empresa", "0")) + DdlBanco.Items.Add(New ListItem("Empresa", "0")) + + DdlSubProyectos.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) + DdlSubProyectos.DataBind() + DdlSubProyectos.Items.Insert(0, New ListItem("-", "-1")) End Sub Private Sub CargarMoneda() DdlMoneda.DataSource = GlobalDTMonedas @@ -227,10 +230,10 @@ Partial Class Bancos_CuentasBancariasDetalle TxtLimiteCredito.Text = ObjCuentasBancariasDetalle.LimiteCredito.ToString DdlTipoCuenta.SelectedValue = ObjCuentasBancariasDetalle.CveTipoCuenta.ToString + DdlSubProyectos.SelectedValueExist(ObjCuentasBancariasDetalle.CveSubProyecto.ToString) DdlTipoCuenta_SelectedIndexChanged(DdlTipoCuenta, EventArgs.Empty) - If UsuarioActual.Empresa.TipoContabilizacion = 1 Then DDlCuentaContable.SelectedValueExist(ObjCuentasBancariasDetalle.CveCuentaConta.ToString) DdlCuentaContableComplementaria.SelectedValueExist(ObjCuentasBancariasDetalle.CveCuentaContaComplementaria.ToString) @@ -289,7 +292,8 @@ Partial Class Bancos_CuentasBancariasDetalle If ObjCuentasBancariasDetalle.AddBancosCuentas(DdlBanco.SelectedValue.ToEntero, DdlTipoCuenta.SelectedValue.ToEntero, TxtNumCuenta.Text.Trim, TxtCLABE.Text.Trim, DdlMoneda.SelectedValue.ToEntero, 0, TxtFInicial.Text.Trim.ToEntero, 0, 0, TxtLimiteCredito.Text.Trim.ToDouble, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, If(ChkLayout.Checked, TxtConvenio.Text, ""), ChkLayout.Checked, ChkUsaTarjeta.Checked, UsaLayoutGrupos:=ChkLayoutGrupos.Checked, - TieneTerminal:=ChkTieneTerminal.Checked, CveCuentaPadre:=DdlCuentaPadre.SelectedValue.ToEntero) Then + TieneTerminal:=ChkTieneTerminal.Checked, + CveCuentaPadre:=DdlCuentaPadre.SelectedValue.ToEntero, CveSubProyecto:=DdlSubProyectos.SelectedValue.ToEntero) Then ViewState("CveCuenta") = ObjCuentasBancariasDetalle.TCveCuenta Else ErrorUsuarios = True @@ -322,7 +326,8 @@ Partial Class Bancos_CuentasBancariasDetalle Else If ObjCuentasBancariasDetalle.UpdateBancosCuentas(DdlBanco.SelectedValue.ToEntero, DdlTipoCuenta.SelectedValue.ToEntero, TxtNumCuenta.Text.Trim, TxtCLABE.Text.Trim, DdlMoneda.SelectedValue.ToEntero, 0, TxtFInicial.Text.Trim.ToEntero, 0, 0, TxtLimiteCredito.Text.Trim.ToDouble, "", ChkEstatus.Checked, CveCuenta, TxtConvenio.Text, - ChkLayout.Checked, ChkUsaTarjeta.Checked, UsaLayoutGrupos:=ChkLayoutGrupos.Checked, TieneTerminal:=ChkTieneTerminal.Checked, CveCuentaPadre:=DdlCuentaPadre.SelectedValue.ToEntero) Then + ChkLayout.Checked, ChkUsaTarjeta.Checked, UsaLayoutGrupos:=ChkLayoutGrupos.Checked, TieneTerminal:=ChkTieneTerminal.Checked, + CveCuentaPadre:=DdlCuentaPadre.SelectedValue.ToEntero, CveSubProyecto:=DdlSubProyectos.SelectedValue.ToEntero) Then 'CargaDatos() GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa) = Nothing 'If ObjCuentasBancariasDetalle.GetBancosCuentasUsuarios(-1) Then @@ -409,6 +414,11 @@ Partial Class Bancos_CuentasBancariasDetalle TxtLimiteCredito.Visible = False RFVLimiteCredito.Enabled = False VCELimiteCredito.Enabled = False + If DdlTipoCuenta.SelectedValue = "1" Then + trSubProyecto.Visible = True + Else + trSubProyecto.Visible = False + End If End If CargaCuentasContables() diff --git a/Bancos/DepositosCaja.aspx b/Bancos/DepositosCaja.aspx index 45747d1ea..ec3f491a6 100644 --- a/Bancos/DepositosCaja.aspx +++ b/Bancos/DepositosCaja.aspx @@ -147,9 +147,9 @@
- +
-
+
@@ -171,6 +171,18 @@
+
+ +
+
+ + + + + + + +
diff --git a/Bancos/DepositosCaja.aspx.vb b/Bancos/DepositosCaja.aspx.vb index ca047fa89..9551eba19 100644 --- a/Bancos/DepositosCaja.aspx.vb +++ b/Bancos/DepositosCaja.aspx.vb @@ -61,6 +61,8 @@ Partial Class Bancos_DepositosCaja DivRowCuenta.Visible = True End If + If UsuarioActual.CveEmpresa.Contiene(140, 141) Then divTipoPago.Visible = False : divTipoPago1.Visible = False + DdlSubProyectos.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa) DdlSubProyectos.DataBind() DdlSubProyectos.Items.Insert(0, New ListItem("Todos", "-1")) @@ -284,15 +286,15 @@ Partial Class Bancos_DepositosCaja End If End If - Dim CveTransaccionBanco As Integer = 13 + Dim CveTransaccionBanco As Integer = DdlTipoDeposito.SelectedValue.ToEntero If TotalImporte < 0 Then 'que es una devolución, entonces como es negativo, se cambia el concetpo de bancos, por condición de trigger CveTransaccionBanco = 6 End If - If DdlTipoPago.SelectedValue.Contiene("11", "12") Then ' cuando son pagos con tarjetas - CveTransaccionBanco = DdlTipoPago.SelectedValue.ToEntero - End If + 'If DdlTipoPago.SelectedValue.Contiene("11", "12") Then ' cuando son pagos con tarjetas + ' CveTransaccionBanco = DdlTipoPago.SelectedValue.ToEntero + 'End If 'código temporal, para claudia y toñita, monge, anadelia, alba,patricia If UsuarioActual.CveUsuario.Contiene(1937, 2452, 3358, 3033, 2897, 2560) Then diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index e48061d12..b91ea0f79 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -646,7 +646,7 @@ Partial Class Bancos_IE If UsuarioActual.Empresa.Funcionalidad(590) = "1" Then DivOtrosIngresosEgresos.Visible = True End If - If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso UsuarioActual.CveRol = 1 Then + If UsuarioActual.CveRol = 1 Then ChkAnticipoPuntual.Visible = True End If @@ -5212,8 +5212,9 @@ Partial Class Bancos_IE Private Sub EnviarCorreoNotificacion(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario, MostarAlert As Boolean) Try - Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) - Hilo.Start() + EnviarCorreoNotificacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar) + 'Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) + 'Hilo.Start() If MostarAlert Then Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) RegistraScript("$('#ModalDivMail').modal('hide');") @@ -5226,7 +5227,7 @@ Partial Class Bancos_IE End Sub - Private Sub EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario) + Private Sub EnviarCorreoNotificacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario) Try Dim ObjBancos As New ClsBancos() @@ -5548,8 +5549,8 @@ Partial Class Bancos_IE UpEliminarCotizacion.Update() End Sub Private Sub RVTxtFechaDocumento_Init(sender As Object, e As EventArgs) Handles RVTxtFechaDocumento.Init - RVTxtFechaDocumento.MaximumValue = NowADS().ToShortDateString - Calendario.EndDate = NowADS() + RVTxtFechaDocumento.MaximumValue = NowADS.AddDays(3).ToShortDateString + Calendario.EndDate = NowADS.AddDays(3) End Sub Private Sub CargaOCRelacionadas() diff --git a/Bancos/PagoElectronicoGrupos.aspx.vb b/Bancos/PagoElectronicoGrupos.aspx.vb index 801a3d737..f3cac6682 100644 --- a/Bancos/PagoElectronicoGrupos.aspx.vb +++ b/Bancos/PagoElectronicoGrupos.aspx.vb @@ -2999,9 +2999,10 @@ Partial Class Bancos_PagoElectronicoGrupos Private Sub EnviarCorreoNotificacion(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario, MostarAlert As Boolean) Try - Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) - Hilo.Start() + 'Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) + 'Hilo.Start() + EnviarCorreoNotificacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar) If MostarAlert Then Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) @@ -3017,7 +3018,7 @@ Partial Class Bancos_PagoElectronicoGrupos End Try End Sub - Private Sub EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario) + Private Sub EnviarCorreoNotificacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario) Try Dim ObjBancos As New ClsBancos() diff --git a/Bancos/PopIECompras.aspx b/Bancos/PopIECompras.aspx index 94086dd01..48e01ca67 100644 --- a/Bancos/PopIECompras.aspx +++ b/Bancos/PopIECompras.aspx @@ -47,7 +47,7 @@ Viaticos - Personal Deudores Acreedores - Ventas + Ventas
diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb index 0ecfd9ef6..4362fffd8 100644 --- a/Bancos/PopIECompras.aspx.vb +++ b/Bancos/PopIECompras.aspx.vb @@ -337,11 +337,11 @@ Partial Class Bancos_PopIECompras CargaTipoTransaccion(TipoTransaccion) CargaCuentas() - Dim ObjVentas As New ClsVentas - If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -1, -1, "-1", "-1", "-1", ClienteRFC:=RFCProveedor, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then - RBLContado.Items(4).Enabled = True - End If - ObjVentas.Dispose() + 'Dim ObjVentas As New ClsVentas + 'If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -1, -1, "-1", "-1", "-1", ClienteRFC:=RFCProveedor, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then + ' RBLContado.Items(4).Enabled = True + 'End If + 'ObjVentas.Dispose() If CveMoneda = 2 Then ChkPagarPesos.Visible = True @@ -1522,9 +1522,10 @@ Partial Class Bancos_PopIECompras Private Sub EnviarCorreoNotificacion(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario, MostarAlert As Boolean) Try - Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) - 'Dim Hilo As New Threading.Thread( EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) - Hilo.Start() + EnviarCorreoNotificacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar) + 'Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotificacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) + ''Dim Hilo As New Threading.Thread( EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) + 'Hilo.Start() If MostarAlert Then @@ -1541,7 +1542,7 @@ Partial Class Bancos_PopIECompras End Try End Sub - Private Sub EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario) + Private Sub EnviarCorreoNotificacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario) Try Dim ObjBancos As New ClsBancos() diff --git a/Bancos/ProveedoresAbonar.aspx b/Bancos/ProveedoresAbonar.aspx index 1b1028021..1e7945306 100644 --- a/Bancos/ProveedoresAbonar.aspx +++ b/Bancos/ProveedoresAbonar.aspx @@ -338,13 +338,8 @@ - - - - - - - + + diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index f4c14812e..a1791b726 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -317,9 +317,6 @@ Partial Class Bancos_ProveedoresAbonar chkaplicaDescuento.Visible = True End If - - tmpValida() - End If End Sub @@ -1383,36 +1380,32 @@ Partial Class Bancos_ProveedoresAbonar Private Sub EnviarCorreoNotificacion(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario, MostarAlert As Boolean) Try - Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) + EnviarCorreoNotificacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar) + 'Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotificacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) 'Dim Hilo As New Threading.Thread( EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar)) - Hilo.Start() + 'Hilo.Start() If MostarAlert Then - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + Alert("El correo se envió correctamente", TipoMensaje.ToastInformacion) End If Catch ex As Exception - If MostarAlert Then Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) End If - - End Try End Sub - Private Sub EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario) - + Private Sub EnviarCorreoNotificacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario) Try Dim ObjBancos As New ClsBancos() If ObjBancos.NotificacionPago(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar) Then - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + Alert("El correo se envió correctamente", TipoMensaje.ToastInformacion) Else Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) End If - ObjBancos.Dispose() Catch ex As Exception GuardaLog("Error al enviar notificación de pago ProveedoresAbonar --> " & ex.StackTrace.ToString) @@ -1714,9 +1707,5 @@ Partial Class Bancos_ProveedoresAbonar End If End Sub - - Protected Sub Button1_Click(sender As Object, e As EventArgs) - tmpValida() - End Sub End Class diff --git a/Bancos/RepCortes.aspx b/Bancos/RepCortes.aspx index f04019057..9f9830a38 100644 --- a/Bancos/RepCortes.aspx +++ b/Bancos/RepCortes.aspx @@ -243,7 +243,7 @@ - + diff --git a/Bancos/RepCortes.aspx.vb b/Bancos/RepCortes.aspx.vb index ea4d9efb6..bd784469f 100644 --- a/Bancos/RepCortes.aspx.vb +++ b/Bancos/RepCortes.aspx.vb @@ -65,7 +65,9 @@ Partial Class Bancos_RepCortes txtFechaVI.Text = NowADS().ToShortDateString txtFechaVF.Text = NowADS().ToShortDateString Me.Form.DefaultButton = BtnConsultar.UniqueID - CargarCentrosDeCosto(Nothing, DdlSubProyectos, Nothing, LblSubProyecto) + Dim AplicaTodos As String = "" + If UsuarioActual.CveEmpresa.Contiene(140, 141) Then AplicaTodos = "Todos" + CargarCentrosDeCosto(Nothing, DdlSubProyectos, Nothing, LblSubProyecto, AplicaTodos:=AplicaTodos) End If End Sub @@ -86,12 +88,18 @@ Partial Class Bancos_RepCortes If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then GvDatos.Columns(3).Visible = True GvDatos.Columns(4).Visible = True - GvDatos.Columns(13).Visible = True End If + GvP.DataBind() + GvDep.DataBind() + GvPorIVA.DataBind() + GvAnexo.DataBind() + GvD.DataBind() + GvDatos.DataSource = DtCortes GvDatos.DataBind() UPDatos.Update() + UPPDetalle.Update() End Sub #End Region @@ -232,10 +240,17 @@ Partial Class Bancos_RepCortes GvDep.DataBind() GvPorIVA.DataBind() - If UsuarioActual.CveEmpresa = 193 Then + If UsuarioActual.CveEmpresa.Contiene(189, 193, 195, 196, 197) Then DivAnexo.Visible = True + Dim CveCuenta As Integer = 0 + CveCuenta = If(UsuarioActual.CveEmpresa = 193, 186367, 0) + If DdlSubProyectos.SelectedValue = "12756" Then 'nav + CveCuenta = 188796 + End If + If DdlSubProyectos.SelectedValue = "12755" Then 'hillo + CveCuenta = 188795 + End If - Dim CveCuenta As Integer = 186367 Using ObjConta As New ClsContabilidad If ObjConta.GetAnexoCatalogo(CveCuenta, Fecha.ToDate(), Fecha.ToDate(), -1, -1, -1, UsuarioActual.CveEmpresa, 1) Then GvAnexo.DataSource = ObjConta.DtResultados diff --git a/Bin/ClbNegBICFDv3_2.dll b/Bin/ClbNegBICFDv3_2.dll deleted file mode 100644 index 8ccf14b8c..000000000 Binary files a/Bin/ClbNegBICFDv3_2.dll and /dev/null differ diff --git a/Bin/GoCfdi.dll b/Bin/GoCfdi.dll index 12e6171e5..5ef366436 100644 Binary files a/Bin/GoCfdi.dll and b/Bin/GoCfdi.dll differ diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index ace5f8509..7d5dc99d7 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -10,10 +10,8 @@ Imports System.Threading.Tasks Imports Newtonsoft.Json Imports Extensiones Imports MoreLinq -Imports ClsPaginas Imports System.Data.SqlClient - - +Imports ClsPaginas Partial Class Compras_Compras Inherits ClsPaginas @@ -1857,7 +1855,8 @@ Partial Class Compras_Compras If Validada And Not EnListadoEFOS Then Try - XMLDoc.LoadXml(File.ReadAllText(Archivo).Replace("<br>", "").Replace("<", "").Replace("o;?", "")) + ' &HFEFF, es el código ZERO WIDTH NO-BREAK SPACE + XMLDoc.LoadXml(File.ReadAllText(Archivo).Replace("<br>", "").Replace("<", "").Replace("o;?", "").Replace(ChrW(&HFEFF), "")) Catch ex As Exception Try Dim oReader As New StreamReader(Archivo, Encoding.GetEncoding("ISO-8859-1")) @@ -1867,411 +1866,416 @@ Partial Class Compras_Compras GuardaLog("Error al intentar leer el XML del SAT. Error:" & ex2.ToString()) End Try End Try + + If XMLDoc.InnerXml = "" Then + Alert("No se pudo procesar el archivo xml.", TipoMensaje.MsgError) + Return "" + End If + CreaDTConceptos() CargaComprobanteXML(XMLDoc) - If NuevaValidacionXML = 1 OrElse (Version = "3.3" OrElse Version = "4.0") Then - Dim Xml As String - Dim nodo As XmlNode = XMLDoc.DocumentElement - Dim Version As String = ValorXML(nodo, "version") - Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) - Dim cfdVer As String = "" - Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) + Dim Xml As String + Dim nodo As XmlNode = XMLDoc.DocumentElement + Dim Version As String = ValorXML(nodo, "version") + Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) + Dim cfdVer As String = "" + Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) - If Version = "3.2" Then - Prefijo = "cfd" - cfdVer = "http://www.sat.gob.mx/cfd/2" - ElseIf Version = "3.3" Then - cfdVer = "http://www.sat.gob.mx/cfd/3" - Else ' se considera que es la version 4.0 - cfdVer = "http://www.sat.gob.mx/cfd/4" + If Version = "3.2" Then + Prefijo = "cfd" + cfdVer = "http://www.sat.gob.mx/cfd/2" + ElseIf Version = "3.3" Then + cfdVer = "http://www.sat.gob.mx/cfd/3" + Else ' se considera que es la version 4.0 + cfdVer = "http://www.sat.gob.mx/cfd/4" + End If + + 'If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2" + + namespaces.AddNamespace(Prefijo, cfdVer) + namespaces.AddNamespace("aerolineas", "http://www.sat.gob.mx/aerolineas") + namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital") + namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") + namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") + + Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces) + Xml = Replace(nodeconceptos.OuterXml, "", "") 'salto de linea html + Xml = Xml.Replace("<br>", "") + Xml = Xml.Replace("<", "") + Xml = Xml.Replace("&", "") 'adicional, si hay otros + + If ObjeFacturas.GetFacturasComparacionXML(Version, Xml, UsuarioActual.CveEmpresa) Then + TmpDT = ObjeFacturas.DtResultados + TmpDT.Columns.Add("CveSATPSActualizado") + SubTotalConceptos = TmpDT.SUMD("Total").RoundSQL + + If Not TmpDT.Columns.Contains("Amortizacion") Then + TmpDT.Columns.Add("Amortizacion", GetType(Decimal)) + End If + + AddPS2(False) + + 'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101 + Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") + For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows + ProductosCodigoSATNoPermitidos.AppendFormat("{0}
", drr("PS")) + Next + + If TmpDT.MAX("RetISRPorcentaje").ToDecimal = 0.0125 Then RetISRResico = True + If TmpDT.MAX("RetIVAPorcentaje").ToDecimal = 0.04 Then RetIVAFlete = True + + If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then + Dim mensajeAdvertencia As String = String.Format("El XML que intenta registrar contiene partidas o artículos con código SAT ‘01010101’ el cual no es aceptado, hable con su proveedor para cancelar y/o refacturar un XML válido.
Partidas o artículos con código ‘01010101’:

{0}", ProductosCodigoSATNoPermitidos.ToString) + Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia) + If UsuarioActual.CveEmpresa.Contiene(119, 158) AndAlso Not UsuarioActual.CveUsuario.Contiene(1719, 1721) Then BtnGuardar.Enabled = False '' solo se activa para el usuario Sara.JAM + BtnGuardar.ToolTip = "No se permite registrar facturas con conceptos con código '01010101'. Solicite al proveedor un nuevo comprobante." + End If + + End If + + + + Dim SbValRet As New StringBuilder + For Each concepto As XmlNode In nodeconceptos + ' Obtener la descripción del concepto + Dim descripcion As String = ValorXML(concepto, "Descripcion") + Dim importeValue As Decimal = Decimal.Parse(ValorXML(concepto, "Importe")) + + ' Seleccionar el nodo de Impuestos dentro de Concepto, si existe + Dim impuestosNode As XmlNode = concepto.SelectSingleNode("cfdi:Impuestos", namespaces) + + If Not impuestosNode Is Nothing Then + ' Seleccionar los nodos de Retencion dentro de Impuestos + Dim retenciones As XmlNodeList = impuestosNode.SelectNodes("cfdi:Retenciones/cfdi:Retencion", namespaces) + For Each retencion As XmlNode In retenciones + ' Obtener los valores de los atributos Base e Importe + Dim baseValue As Decimal = Decimal.Parse(ValorXML(retencion, "Base")) + Dim impuesto As String = ValorXML(retencion, "Impuesto") + + If impuesto = "001" Then + impuesto = "Retención ISR" + ElseIf impuesto = "002" Then + impuesto = "Retención IVA" + ElseIf impuesto = "003" Then + impuesto = "IEPS" + End If + + + ' Validar si Base coincide con Importe + If baseValue <> importeValue Then + 'SbValRet.Append($"La base e importe de la retención del impuesto {impuesto} no coinciden para {descripcion}. Base: {baseValue.ToString()}, Importe: {importeValue.ToString()}
") + SbValRet.Append($"Producto: {descripcion} La base e importe del impuesto {impuesto} no coincide Base: {baseValue.ToString()}, Importe Producto: {importeValue.ToString()}
") + End If + Next + End If + Next + + If SbValRet.ToString.Trim.Length > 0 Then + Alert(SbValRet.ToString, TipoMensaje.MsgAdvertencia) + End If + + + + Else + CargaConceptosXML(XMLDoc) End If - 'If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2" + Select Case TipoComprobante + Case "ingreso" : DdlTipoComprobante.SelectedValue = "Fac" : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC")) : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV")) + Case "egreso" : DdlTipoComprobante.SelectedValue = "NC" : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Fac")) : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) : ChkAplicaNotaCredito.Enabled = False + Case "I" + DdlTipoComprobante.SelectedValue = "Fac" + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV")) + DdlTipoCompra.Items.Remove(DdlTipoCompra.Items.FindByValue("6")) + DdlTipoCompra.Items.Remove(DdlTipoCompra.Items.FindByValue("11")) + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then DdlTipoCompra.Items.Add(New ListItem("Recolección", "14")) + Case "E" + DdlTipoComprobante.SelectedValue = "NC" + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Fac")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) + ChkAplicaNotaCredito.Enabled = False - namespaces.AddNamespace(Prefijo, cfdVer) - namespaces.AddNamespace("aerolineas", "http://www.sat.gob.mx/aerolineas") - namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital") - namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal") - namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal") + DdlTipoCompra.Items.Clear() + DdlTipoCompra.Items.Add(New ListItem("Seleccione", "-1")) + DdlTipoCompra.Items.Add(New ListItem("NC Con Productos", "6")) + DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9")) + DdlTipoCompra.Items.Add(New ListItem("NC Por Devolución", "11")) + DdlTipoCompra.Items.Add(New ListItem("Garantía", "12")) + Case "T" + DdlTipoCompra.Items.Clear() + DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9")) + DdlTipoComprobante.SelectedValue = "Fac" + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV")) - Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces) - Xml = Replace(nodeconceptos.OuterXml, "", "") 'salto de linea html - Xml = Xml.Replace("<br>", "") - Xml = Xml.Replace("<", "") - Xml = Xml.Replace("&", "") 'adicional, si hay otros + End Select - If ObjeFacturas.GetFacturasComparacionXML(Version, Xml, UsuarioActual.CveEmpresa) Then - TmpDT = ObjeFacturas.DtResultados - TmpDT.Columns.Add("CveSATPSActualizado") - SubTotalConceptos = TmpDT.SUMD("Total").RoundSQL + 'DIV ALIAS + CargaPSAlias() + + RFC = dr("RFCDe").ToString + RFCProveedor = RFC + TxtFecha.Text = dr("FechaFactura").ToString.ToDate.ToShortDateString + TxtSerie.Text = dr("Serie").ToString + TxtFolio.Text = dr("Folio").ToString + DdlValidadaSAT.SelectedValue = If(dr("FueValidado").ToString.Contiene("Si", "1"), "Si", "No") + DdlValidadaSAT.Enabled = False + LblTipoFact.Text = dr("TipoFactura").ToString + SerieVieja = dr("Serie").ToString + LblMetodoPago.Text = MetodoPago + + Dim SubTotal2, IVA, IEPS As Decimal + IVA = TrasladoIVA + + If Not UsuarioActual.TienePermisoProceso(130) Then + TxtFolio.Enabled = False + TxtSerie.Enabled = False + End If + + 'PERMISO PARA MODIFICACIÓN DE FECHA AUN CON FACTURA + TxtFecha.Enabled = UsuarioActual.TienePermisoProceso(216) + ImgFecha.Enabled = UsuarioActual.TienePermisoProceso(216) + CEFecha.Enabled = UsuarioActual.TienePermisoProceso(216) + + TxtSubTotal.Enabled = False + TxtDescuento.Enabled = False + TxtSubTotal2.Enabled = False + TxtIVA.Enabled = False + TxtTotal.Enabled = False + DdlProveedor.Enabled = False + + If TxtFolio.Text.Trim = "" Then TxtFolio.Enabled = True : TxtSerie.Enabled = True + + If UsuarioActual.TienePermisoProceso(112) Then + PermisoEdicionManual = True + TxtSubTotal.Enabled = True + TxtDescuento.Enabled = True + TxtSubTotal2.Enabled = True + TxtIVA.Enabled = True + TxtTotal.Enabled = True + End If + + If UsuarioActual.Empresa.Funcionalidad(118) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Fac" Then + VerVales.Visible = True + End If + + If TieneAnticiposXML Then 'si tiene anticipos, limpia los descuentos + 'LblAmortizacion.Text = ImporteAnticipo.FormatoNumero + TxtDescuento.Text = "0.00" + LblAmortizacion.Text = Descuentos.FormatoNumero + 'limpia los descuentos + For Each drr As DataRow In TmpDT.Rows + 'drr("Total") = drr("Total").ToString.ToDecimal + drr("Descuento").ToString.ToDecimal + drr("Amortizacion") = drr("Descuento") 'pasamos el importe de descuento a amortizacion + drr("Descuento") = 0.00 + Next + Amortizaciones = Descuentos + Descuentos = 0 + End If + + Dim Msg As String = "" + If Version = "3.3" Or Version = "4.0" Then If Not TmpDT.Columns.Contains("Amortizacion") Then TmpDT.Columns.Add("Amortizacion", GetType(Decimal)) End If + TmpDT.AcceptChanges() + ValidacionesTotalesXml() + Else + 'PRUEBA + 'http://rm/Compras/Compras.aspx?CveFactura=122518 Emp: 48 - AddPS2(False) + 'tTotal = Math.Round(SubTotal2 + IVA - RetencionIVA - RetencionISR + IEPS + OtrosImpuestos, 2) + HdnCompraSaldo.Value = Total.ToString + CompraSaldo = Total + Dim AjustaUltimoConcepto As Boolean = False - 'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101 - Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") - For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows - ProductosCodigoSATNoPermitidos.AppendFormat("{0}
", drr("PS")) - Next - - If TmpDT.MAX("RetISRPorcentaje").ToDecimal = 0.0125 Then RetISRResico = True - If TmpDT.MAX("RetIVAPorcentaje").ToDecimal = 0.04 Then RetIVAFlete = True - - If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then - Dim mensajeAdvertencia As String = String.Format("El XML que intenta registrar contiene partidas o artículos con código SAT ‘01010101’ el cual no es aceptado, hable con su proveedor para cancelar y/o refacturar un XML válido.
Partidas o artículos con código ‘01010101’:

{0}", ProductosCodigoSATNoPermitidos.ToString) - Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia) - If UsuarioActual.CveEmpresa.Contiene(119, 158) AndAlso Not UsuarioActual.CveUsuario.Contiene(1719, 1721) Then BtnGuardar.Enabled = False '' solo se activa para el usuario Sara.JAM - BtnGuardar.ToolTip = "No se permite registrar facturas con conceptos con código '01010101'. Solicite al proveedor un nuevo comprobante." + 'AGREGA IEPS COMO CONCEPTO + If TrasladoIEPS > 0 And UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0 Then + AgregarConceptoIEPS(TrasladoIEPS, UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero) + ' TrasladoIEPS = 0 + End If + 'en otro impuesto lo esta registrando en ajuste en automatico + If OtrosImpuestos > 0 Then + AjustaUltimoConcepto = True End If - End If - - - - Dim SbValRet As New StringBuilder - For Each concepto As XmlNode In nodeconceptos - ' Obtener la descripción del concepto - Dim descripcion As String = ValorXML(concepto, "Descripcion") - Dim importeValue As Decimal = Decimal.Parse(ValorXML(concepto, "Importe")) - - ' Seleccionar el nodo de Impuestos dentro de Concepto, si existe - Dim impuestosNode As XmlNode = concepto.SelectSingleNode("cfdi:Impuestos", namespaces) - - If Not impuestosNode Is Nothing Then - ' Seleccionar los nodos de Retencion dentro de Impuestos - Dim retenciones As XmlNodeList = impuestosNode.SelectNodes("cfdi:Retenciones/cfdi:Retencion", namespaces) - For Each retencion As XmlNode In retenciones - ' Obtener los valores de los atributos Base e Importe - Dim baseValue As Decimal = Decimal.Parse(ValorXML(retencion, "Base")) - Dim impuesto As String = ValorXML(retencion, "Impuesto") - - If impuesto = "001" Then - impuesto = "Retención ISR" - ElseIf impuesto = "002" Then - impuesto = "Retención IVA" - ElseIf impuesto = "003" Then - impuesto = "IEPS" - End If - - - ' Validar si Base coincide con Importe - If baseValue <> importeValue Then - 'SbValRet.Append($"La base e importe de la retención del impuesto {impuesto} no coinciden para {descripcion}. Base: {baseValue.ToString()}, Importe: {importeValue.ToString()}
") - SbValRet.Append($"Producto: {descripcion} La base e importe del impuesto {impuesto} no coincide Base: {baseValue.ToString()}, Importe Producto: {importeValue.ToString()}
") - End If - Next + If RFC = "CFE370814QI0" Then ' RFC de CFE, se hace un ajuste por diferencia para sacar el DAP + 'OtrosImpuestos = Total - (SubTotal2 + IVA) + 'este importe lo vamos a meter al gasto + 'AjustaImporteUltimoConcepto(OtrosImpuestos) + OtrosImpuestos = 1 + AjustaUltimoConcepto = True + 'SubTotal2 = SubTotal End If - Next - If SbValRet.ToString.Trim.Length > 0 Then - Alert(SbValRet.ToString, TipoMensaje.MsgAdvertencia) - End If + Dim SubTotalReal As Decimal = 0 + SubTotalReal = Math.Round(Total + RetencionISR + RetencionIVA - IVA + Descuentos - TrasladoIEPS, 2) ' NO se incluye otros impuestos para ajustar esa cifra + Dim DiferenciaTotales As Decimal = SubTotalReal - Math.Round(SubTotalConceptos, 2) + If DiferenciaTotales <> 0 Then + 'Verificamos IEPS y Otros Impuestos + 'restricccion general, que si el subtotal de los conceptos no cuadra con Total + RetISR + RetIVA - IVA <> SubTotalConeptos, ajuste al final + If TrasladoIEPS > 0 OrElse OtrosImpuestos > 0 OrElse Math.Abs(DiferenciaTotales) < 1 Then + 'Condicion necesaria cuando hay IVA pero no hay diferencia + If DiferenciaTotales <> 0 Then - Else - CargaConceptosXML(XMLDoc) - End If + If DiferenciaTotales < 50 OrElse AjustaUltimoConcepto = True Then + Dim IA As Decimal = Total + RetencionISR + RetencionIVA - IVA - SubTotalConceptos - TrasladoIEPS + Descuentos + AjustaImporteUltimoConcepto(IA, True) - Select Case TipoComprobante - Case "ingreso" : DdlTipoComprobante.SelectedValue = "Fac" : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC")) : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV")) - Case "egreso" : DdlTipoComprobante.SelectedValue = "NC" : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Fac")) : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) : ChkAplicaNotaCredito.Enabled = False - Case "I" - DdlTipoComprobante.SelectedValue = "Fac" - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV")) - DdlTipoCompra.Items.Remove(DdlTipoCompra.Items.FindByValue("6")) - DdlTipoCompra.Items.Remove(DdlTipoCompra.Items.FindByValue("11")) - If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then DdlTipoCompra.Items.Add(New ListItem("Recolección", "14")) - Case "E" - DdlTipoComprobante.SelectedValue = "NC" - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Fac")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) - ChkAplicaNotaCredito.Enabled = False + ElseIf DiferenciaTotales > 50 Then + PnlAjusteProductos.Visible = True + Dim Porcentaje As Double = Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2) + TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero + Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") + ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False - DdlTipoCompra.Items.Clear() - DdlTipoCompra.Items.Add(New ListItem("Seleccione", "-1")) - DdlTipoCompra.Items.Add(New ListItem("NC Con Productos", "6")) - DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9")) - DdlTipoCompra.Items.Add(New ListItem("NC Por Devolución", "11")) - DdlTipoCompra.Items.Add(New ListItem("Garantía", "12")) - Case "T" - DdlTipoCompra.Items.Clear() - DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9")) - DdlTipoComprobante.SelectedValue = "Fac" - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV")) - - End Select - - 'DIV ALIAS - CargaPSAlias() - - RFC = dr("RFCDe").ToString - RFCProveedor = RFC - TxtFecha.Text = dr("FechaFactura").ToString.ToDate.ToShortDateString - TxtSerie.Text = dr("Serie").ToString - TxtFolio.Text = dr("Folio").ToString - DdlValidadaSAT.SelectedValue = If(dr("FueValidado").ToString.Contiene("Si", "1"), "Si", "No") - DdlValidadaSAT.Enabled = False - LblTipoFact.Text = dr("TipoFactura").ToString - SerieVieja = dr("Serie").ToString - LblMetodoPago.Text = MetodoPago - - Dim SubTotal2, IVA, IEPS As Decimal - IVA = TrasladoIVA - - If Not UsuarioActual.TienePermisoProceso(130) Then - TxtFolio.Enabled = False - TxtSerie.Enabled = False - End If - - 'PERMISO PARA MODIFICACIÓN DE FECHA AUN CON FACTURA - TxtFecha.Enabled = UsuarioActual.TienePermisoProceso(216) - ImgFecha.Enabled = UsuarioActual.TienePermisoProceso(216) - CEFecha.Enabled = UsuarioActual.TienePermisoProceso(216) - - TxtSubTotal.Enabled = False - TxtDescuento.Enabled = False - TxtSubTotal2.Enabled = False - TxtIVA.Enabled = False - TxtTotal.Enabled = False - DdlProveedor.Enabled = False - - If TxtFolio.Text.Trim = "" Then TxtFolio.Enabled = True : TxtSerie.Enabled = True - - If UsuarioActual.TienePermisoProceso(112) Then - PermisoEdicionManual = True - TxtSubTotal.Enabled = True - TxtDescuento.Enabled = True - TxtSubTotal2.Enabled = True - TxtIVA.Enabled = True - TxtTotal.Enabled = True - End If - - If UsuarioActual.Empresa.Funcionalidad(118) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Fac" Then - VerVales.Visible = True - End If - - If TieneAnticiposXML Then 'si tiene anticipos, limpia los descuentos - 'LblAmortizacion.Text = ImporteAnticipo.FormatoNumero - TxtDescuento.Text = "0.00" - LblAmortizacion.Text = Descuentos.FormatoNumero - 'limpia los descuentos - For Each drr As DataRow In TmpDT.Rows - 'drr("Total") = drr("Total").ToString.ToDecimal + drr("Descuento").ToString.ToDecimal - drr("Amortizacion") = drr("Descuento") 'pasamos el importe de descuento a amortizacion - drr("Descuento") = 0.00 - Next - Amortizaciones = Descuentos - Descuentos = 0 - End If - - Dim Msg As String = "" - If Version = "3.3" Or Version = "4.0" Then - - If Not TmpDT.Columns.Contains("Amortizacion") Then - TmpDT.Columns.Add("Amortizacion", GetType(Decimal)) - End If - TmpDT.AcceptChanges() - ValidacionesTotalesXml() - Else - 'PRUEBA - 'http://rm/Compras/Compras.aspx?CveFactura=122518 Emp: 48 - - 'tTotal = Math.Round(SubTotal2 + IVA - RetencionIVA - RetencionISR + IEPS + OtrosImpuestos, 2) - HdnCompraSaldo.Value = Total.ToString - CompraSaldo = Total - Dim AjustaUltimoConcepto As Boolean = False - - 'AGREGA IEPS COMO CONCEPTO - If TrasladoIEPS > 0 And UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0 Then - AgregarConceptoIEPS(TrasladoIEPS, UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero) - ' TrasladoIEPS = 0 - End If - 'en otro impuesto lo esta registrando en ajuste en automatico - If OtrosImpuestos > 0 Then - AjustaUltimoConcepto = True - End If - - If RFC = "CFE370814QI0" Then ' RFC de CFE, se hace un ajuste por diferencia para sacar el DAP - 'OtrosImpuestos = Total - (SubTotal2 + IVA) - 'este importe lo vamos a meter al gasto - 'AjustaImporteUltimoConcepto(OtrosImpuestos) - OtrosImpuestos = 1 - AjustaUltimoConcepto = True - 'SubTotal2 = SubTotal - End If - - Dim SubTotalReal As Decimal = 0 - SubTotalReal = Math.Round(Total + RetencionISR + RetencionIVA - IVA + Descuentos - TrasladoIEPS, 2) ' NO se incluye otros impuestos para ajustar esa cifra - Dim DiferenciaTotales As Decimal = SubTotalReal - Math.Round(SubTotalConceptos, 2) - - If DiferenciaTotales <> 0 Then - 'Verificamos IEPS y Otros Impuestos - 'restricccion general, que si el subtotal de los conceptos no cuadra con Total + RetISR + RetIVA - IVA <> SubTotalConeptos, ajuste al final - If TrasladoIEPS > 0 OrElse OtrosImpuestos > 0 OrElse Math.Abs(DiferenciaTotales) < 1 Then - - 'Condicion necesaria cuando hay IVA pero no hay diferencia - If DiferenciaTotales <> 0 Then - - If DiferenciaTotales < 50 OrElse AjustaUltimoConcepto = True Then - Dim IA As Decimal = Total + RetencionISR + RetencionIVA - IVA - SubTotalConceptos - TrasladoIEPS + Descuentos - AjustaImporteUltimoConcepto(IA, True) - - ElseIf DiferenciaTotales > 50 Then - PnlAjusteProductos.Visible = True - Dim Porcentaje As Double = Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2) - TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero - Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") - ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False - - 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias - For Each Row As GridViewRow In GvPS.Rows - Row.FCLinkButton("imgE").Visible = False - Row.FCLinkButton("imgD").Visible = False - Next + 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias + For Each Row As GridViewRow In GvPS.Rows + Row.FCLinkButton("imgE").Visible = False + Row.FCLinkButton("imgD").Visible = False + Next + End If End If + TrasladoIEPS = 0 : OtrosImpuestos = 0 : SubTotal2 = SubTotal + Else + PnlAjusteProductos.Visible = True + Dim Porcentaje As Double = If(SubTotalConceptos > 0, Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2), 0) + TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero + Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") + ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False + + 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias + For Each Row As GridViewRow In GvPS.Rows + Row.FCLinkButton("imgE").Visible = False + Row.FCLinkButton("imgD").Visible = False + Next End If - TrasladoIEPS = 0 : OtrosImpuestos = 0 : SubTotal2 = SubTotal - Else - PnlAjusteProductos.Visible = True - Dim Porcentaje As Double = If(SubTotalConceptos > 0, Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2), 0) - TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero - Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") - ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False - - 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias - For Each Row As GridViewRow In GvPS.Rows - Row.FCLinkButton("imgE").Visible = False - Row.FCLinkButton("imgD").Visible = False - Next End If - End If - 'Si no hay diferencias pero tenemos descuento, se ofrece la opcion para ajustar el gasto - If Descuentos > 0 Then + 'Si no hay diferencias pero tenemos descuento, se ofrece la opcion para ajustar el gasto + If Descuentos > 0 Then - '[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018 - If CveFactura = 286290 Then + '[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018 + If CveFactura = 286290 Then - Else - PnlAjusteProductos.Visible = True - Dim Porcentaje As Double = Math.Round((Descuentos) / (SubTotalConceptos) * 100, 4) - TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero(4) - Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") - ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False + Else + PnlAjusteProductos.Visible = True + Dim Porcentaje As Double = Math.Round((Descuentos) / (SubTotalConceptos) * 100, 4) + TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero(4) + Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente
") + ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False - 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias - For Each Row As GridViewRow In GvPS.Rows - Row.FCLinkButton("imgE").Visible = False - Row.FCLinkButton("imgD").Visible = False - Next + 'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias + For Each Row As GridViewRow In GvPS.Rows + Row.FCLinkButton("imgE").Visible = False + Row.FCLinkButton("imgD").Visible = False + Next + End If End If + + SubTotal2 = SubTotalReal - Descuentos + + If Descuentos > 0 Then + TrDescuento.Visible = True + End If + + If Msg <> "" Then + Alert(Msg, TipoMensaje.MsgAdvertencia) + BtnGuardar.Enabled = False + End If + 'AJUSTAMOS SUBTOTAL EN CASO DE SER DIFERENTE AL SUBTOTAL2 DEL XML (TOTAL - IVA) + If SubTotal2 <> SubTotal Then + SubTotal = SubTotalConceptos + End If + + TxtSubTotal.Text = SubTotal.FormatoNumero + TxtDescuento.Text = Descuentos.FormatoNumero + TxtSubTotal2.Text = SubTotal2.FormatoNumero + TxtIVA.Text = IVA.FormatoNumero + TxtTotal.Text = Total.ToString.FormatoNumero + + HfTotalCompra.Value = Total.ToString + CompraSaldo = Total + + CalculaTotalPorDevengar() + TxtDocumentoImporteFE.Text = Total.ToString + RVDocumentoImporte.MaximumValue = Math.Round(Total, 2).ToString + RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue + RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue + TxtDocumentoImporte.Text = Total.FormatoNumero + TxtDocumentoImporteCaja.Text = Total.FormatoNumero + TxtRetIVA.Text = RetencionIVA.FormatoNumero + TxtRetISR.Text = RetencionISR.FormatoNumero + TxtIEPS.Text = IEPS.FormatoNumero + If IEPS > 0 Then TrIEPS.Visible = True + If RetencionIVA > 0 Then TrRetIVA.Visible = True + If RetencionISR > 0 Then TrRetISR.Visible = True + TxtOtrosImpuestos.Text = OtrosImpuestos.FormatoNumero + If OtrosImpuestos > 0 Then TrOtrosImpuestos.Visible = True + + HFDiferenciaCompra.Value = TxtTotal.Text + 'ASIGNA VALORES ORIGINALES PARA GUARDAR + AsignaValoresOriginales(SubTotal, SubTotal2, IVA, RetencionIVA, RetencionISR, Total) + End If + TxtFechaPago.Text = (TxtFecha.Text.ToDate.AddDays(LblDiasCredito.Text.ToEntero)).ToShortDateString - SubTotal2 = SubTotalReal - Descuentos - - If Descuentos > 0 Then - TrDescuento.Visible = True - End If - - If Msg <> "" Then - Alert(Msg, TipoMensaje.MsgAdvertencia) - BtnGuardar.Enabled = False - End If - 'AJUSTAMOS SUBTOTAL EN CASO DE SER DIFERENTE AL SUBTOTAL2 DEL XML (TOTAL - IVA) - If SubTotal2 <> SubTotal Then - SubTotal = SubTotalConceptos - End If - - TxtSubTotal.Text = SubTotal.FormatoNumero - TxtDescuento.Text = Descuentos.FormatoNumero - TxtSubTotal2.Text = SubTotal2.FormatoNumero - TxtIVA.Text = IVA.FormatoNumero - TxtTotal.Text = Total.ToString.FormatoNumero - - HfTotalCompra.Value = Total.ToString - CompraSaldo = Total - - CalculaTotalPorDevengar() - TxtDocumentoImporteFE.Text = Total.ToString - RVDocumentoImporte.MaximumValue = Math.Round(Total, 2).ToString - RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue - RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue - TxtDocumentoImporte.Text = Total.FormatoNumero - TxtDocumentoImporteCaja.Text = Total.FormatoNumero - TxtRetIVA.Text = RetencionIVA.FormatoNumero - TxtRetISR.Text = RetencionISR.FormatoNumero - TxtIEPS.Text = IEPS.FormatoNumero - If IEPS > 0 Then TrIEPS.Visible = True - If RetencionIVA > 0 Then TrRetIVA.Visible = True - If RetencionISR > 0 Then TrRetISR.Visible = True - TxtOtrosImpuestos.Text = OtrosImpuestos.FormatoNumero - If OtrosImpuestos > 0 Then TrOtrosImpuestos.Visible = True - - HFDiferenciaCompra.Value = TxtTotal.Text - 'ASIGNA VALORES ORIGINALES PARA GUARDAR - AsignaValoresOriginales(SubTotal, SubTotal2, IVA, RetencionIVA, RetencionISR, Total) - - End If - TxtFechaPago.Text = (TxtFecha.Text.ToDate.AddDays(LblDiasCredito.Text.ToEntero)).ToShortDateString - - Dim drMon As DataRow = GlobalDTMonedas.FiltroPrimero(String.Format(" (Abreviatura LIKE '%{0}%' OR Moneda LIKE '%{0}%' )", Moneda)) - - If drMon IsNot Nothing Then - DdlMoneda.SelectedValue = drMon("CveMoneda").ToString - CveMoneda = drMon("CveMoneda").ToString.ToEntero - Else - 'sino busco en la tabla de alias - drMon = GlobalDTMonedasAlias.FiltroPrimero(String.Format("MonedaAlias LIKE '%{0}%' ", Moneda)) + Dim drMon As DataRow = GlobalDTMonedas.FiltroPrimero(String.Format(" (Abreviatura LIKE '%{0}%' OR Moneda LIKE '%{0}%' )", Moneda)) If drMon IsNot Nothing Then DdlMoneda.SelectedValue = drMon("CveMoneda").ToString CveMoneda = drMon("CveMoneda").ToString.ToEntero Else - LblMoneda.Text = Moneda - LblMoneda.ForeColor = Drawing.Color.Red - End If - End If + 'sino busco en la tabla de alias + drMon = GlobalDTMonedasAlias.FiltroPrimero(String.Format("MonedaAlias LIKE '%{0}%' ", Moneda)) - If DdlMoneda.SelectedValue.ToEntero > 1 Then - If TipoCambio <= 10 Then - TipoCambio = GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal + If drMon IsNot Nothing Then + DdlMoneda.SelectedValue = drMon("CveMoneda").ToString + CveMoneda = drMon("CveMoneda").ToString.ToEntero + Else + LblMoneda.Text = Moneda + LblMoneda.ForeColor = Drawing.Color.Red + End If End If - TxtFecha.Attributes.Remove("onblur") - If UsuarioActual.Empresa.UsaAC Then - TxtFecha.Attributes.Add("onblur", "CambiaFecha();CambiaFechaTC();") - Else - TxtFecha.Attributes.Add("onblur", "CambiaFechaTC();") + If DdlMoneda.SelectedValue.ToEntero > 1 Then + If TipoCambio <= 10 Then + TipoCambio = GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal + End If + + TxtFecha.Attributes.Remove("onblur") + If UsuarioActual.Empresa.UsaAC Then + TxtFecha.Attributes.Add("onblur", "CambiaFecha();CambiaFechaTC();") + Else + TxtFecha.Attributes.Add("onblur", "CambiaFechaTC();") + End If + End If + + If TipoCambio > 0 And DdlMoneda.SelectedValue.ToEntero > 1 Then LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4")) + + 'DF - 10-04-17 + If UsuarioActual.TienePermisoProceso(187) Then + TxtSerie.Enabled = True + End If + + If LblMetodoPago.Text = "" AndAlso TipoComprobante <> "T" Then + Alert("El xml no contiene la etiqueta 'método de pago', favor de verificar la emisión con el proveedor.", TipoMensaje.MsgAdvertencia) + BtnGuardar.Visible = False End If End If - - If TipoCambio > 0 And DdlMoneda.SelectedValue.ToEntero > 1 Then LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4")) - - 'DF - 10-04-17 - If UsuarioActual.TienePermisoProceso(187) Then - TxtSerie.Enabled = True - End If - - If LblMetodoPago.Text = "" AndAlso TipoComprobante <> "T" Then - Alert("El xml no contiene la etiqueta 'método de pago', favor de verificar la emisión con el proveedor.", TipoMensaje.MsgAdvertencia) - BtnGuardar.Visible = False - End If - End If - Else + Else Alert("No se Encontró la Factura", TipoMensaje.MsgAdvertencia) BtnGuardar.Visible = False End If @@ -3148,7 +3152,6 @@ Partial Class Compras_Compras LtlGvAnticiposSel.Visible = True End If - '' VALIDA ELIMINAR COMPRA, QUE NO TENGA PAGOS CONCILIADOS If (UsuarioActual.TienePermisoProceso(77) OrElse UsuarioActual.TienePermisoProceso(135)) AndAlso dr("NumPagosConciliados").ToString.ToEntero = 0 Then ' Eliminar compra @@ -3168,7 +3171,6 @@ Partial Class Compras_Compras End If End If - Dim StrInventario As String = "" If dr("Inventario").ToString = "1" Then StrInventario = "los Movimientos de Inventario relacionados" @@ -4185,20 +4187,17 @@ Partial Class Compras_Compras Protected Sub BtnGuardar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnGuardar.Click - - If Not ValidaPresupuesto(2) Then Exit Sub End If '------------------ INICIA VALIDACIONES ------------------ - If MetodoPagoOC = 0 AndAlso RBLPago.SelectedValue.ToEntero <> 2 Then + If MetodoPagoOC = 0 AndAlso RBLPago.SelectedValue.ToEntero <> 2 AndAlso LblSaldoFactura.Text.ToDecimal > 0 Then Alert("La orden de compra se definió de contado, favor de especificar la compra de contado.", TipoMensaje.MsgAdvertencia) Exit Sub End If - Dim CveSubProyectoPrincipal As Integer = AsignarSubProyectoPrincipal() If Not CveSubProyectoPrincipal > 0 Then @@ -4206,7 +4205,7 @@ Partial Class Compras_Compras End If If Not ValidaVinculacionNotaFactura() Then - Alert("Se requiere que la nota este aplciada a las facturas", TipoMensaje.MsgAdvertencia) + Alert("Se requiere que la nota este aplicada a las facturas", TipoMensaje.MsgAdvertencia) Exit Sub End If @@ -5682,7 +5681,7 @@ Partial Class Compras_Compras Dim CveConceptoAfectacion As Integer = 5 'Proveedores Dim CveConceptoOriginal As Integer - If CveTipoConcepto = 2 Then CveConceptoAfectacion = 305 'cuando es acreedor + If CveTipoConcepto <> 1 Then CveConceptoAfectacion = 305 'cuando es acreedor If CveMoneda <> 1 Then Select Case CveConceptoAfectacion Case 5 @@ -5694,7 +5693,7 @@ Partial Class Compras_Compras End If Dim CveConceptoAfectacionContado As Integer = 17 'Pago Proveedores - If CveTipoConcepto = 2 Then CveConceptoAfectacionContado = 308 'cuando es acreedor + If CveTipoConcepto <> 1 Then CveConceptoAfectacionContado = 308 'cuando es acreedor If CveMoneda <> 1 Then Select Case CveConceptoAfectacionContado Case 17 @@ -6014,7 +6013,7 @@ Partial Class Compras_Compras Case 17 'Pago Proveedores - If CveTipoConcepto = 2 Then ConceptoContable = 308 'cuando es acreedor + If CveTipoConcepto <> 1 Then ConceptoContable = 308 'cuando es acreedor If CveMoneda <> 1 Then Select Case ConceptoContable Case 17 @@ -6118,7 +6117,7 @@ Partial Class Compras_Compras If importeMovimiento <> 0 Then 'Cuando tiene complementaria lo dividimos en dos Dim CveConceptoContableComplementaria As Integer = 206 - If CveTipoConcepto = 2 Then CveConceptoContableComplementaria = 310 'cuando es acreedor + If CveTipoConcepto <> 1 Then CveConceptoContableComplementaria = 310 'cuando es acreedor importeMN = importeMovimiento If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento * TipoCambioCompra - importeMovimiento, importeMovimiento * TipoCambioCompra - importeMovimiento, CveConceptoContableComplementaria, Referencia, Concepto, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, ImporteME:=importeMovimiento, Contabilizable:=SeContabiliza, TipoCambio:=TipoCambioCompra) Then @@ -6288,21 +6287,22 @@ Partial Class Compras_Compras Case 6 'Compra Dim AgregaMercanciaInventario As Boolean = UsuarioActual.Empresa.UsaInventarios + If UsuarioActual.CveEmpresa.Contiene(13, 83, 7, 11, 12, 122) Then AgregaMercanciaInventario = False - Dim RegistraConcepto225 As Boolean = UsuarioActual.Empresa.UsaInventarios AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") + Dim RegistraConcepto225 As Boolean = AgregaMercanciaInventario AndAlso DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV") Dim Insertado205 As Boolean = False If RBLPago.SelectedValue.ToEntero = 4 Then Exit Select 'Es credito el concepto 6 se agrega en CASE 17 End If - Dim DifSubTotatles As Decimal = 0D + Dim DifSubTotales As Decimal = 0D If CveCompraRefacturacion > 0 Then - DifSubTotatles = Math.Abs(SubTotalRefacturacion - TxtSubTotal2.Text.ToDecimal) + DifSubTotales = Math.Abs(SubTotalRefacturacion - TxtSubTotal2.Text.ToDecimal) End If - If DifSubTotatles > 0 Or (Not CveCompraRefacturacion > 0 OrElse (ChkRefacNC.Checked)) Then + If DifSubTotales > 0 Or (Not CveCompraRefacturacion > 0 OrElse (ChkRefacNC.Checked)) Then 'AF TipoAF 2 Es para las compras DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2 And ISNULL(AplicaCostoIndirecto,0) <> 1 ") If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then @@ -6323,7 +6323,7 @@ Partial Class Compras_Compras 'COSTO ALMACEN Dim DtAlmacenes As DataTable = GlobalDTAlmacen(UsuarioActual.CveEmpresa) - If UsuarioActual.Empresa.UsaInventarios Then + If AgregaMercanciaInventario Then DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen"}) 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN 'SI LA COMPRA ES DE TIPO GASTO CON ALMACEN DEBE REGISTRAR MOVIMIENTO @@ -6347,8 +6347,6 @@ Partial Class Compras_Compras DT = DT.FiltraParametros("ISNULL(CveAlmacen,0) > 0") If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then - - 'SI ES GASTO CON ALMACEN If DdlTipoCompra.SelectedValue = "10" Then For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen", "CveClasificacion", "CveSubProyecto"}).Rows @@ -6449,6 +6447,9 @@ Partial Class Compras_Compras ConceptoContabilizacion = 6 End If + If UsuarioActual.CveEmpresa.Contiene(7, 11, 12, 122, 145, 13, 83) AndAlso ConceptoContabilizacion = 205 Then + ConceptoContabilizacion = 6 + End If Select Case ConceptoContabilizacion Case 6 @@ -6713,10 +6714,32 @@ Partial Class Compras_Compras For Each Gvr As GridViewRow In GvFacturaNC.Rows If Gvr.FCCheckBox("ChkFacturaNC").Checked Then ' recorro la seleccion y tomo el TC de cada aplicación AplicadoenFactura = True - Dim timporteMovimientoNC As Decimal = (Gvr.FCTextBox("TxtImporte").Text.ToDecimal * Gvr.DataKey("SubTotal").ToDecimal / Gvr.DataKey("Saldo").ToDecimal).RoundSQL + Dim timporteMovimientoNC As Decimal = (Gvr.FCTextBox("TxtImporte").Text.ToDecimal) '* Gvr.DataKey("SubTotal").ToDecimal / Gvr.DataKey("Saldo").ToDecimal).RoundSQL Dim TCNC As Decimal = Gvr.DataKey("TipoCambio").ToDecimal If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, timporteMovimientoNC, (timporteMovimientoNC * TCNC * Multiplicador).RoundSQL, ConceptoContabilizacionNC, Referencia, Concepto, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=TCNC, CveMovimientoAlmacen:=CveMovimientoDevolucion, CveClasificacion:=tCveClasif, CveSubProyecto:=tCveSubProyecto, Contabilizable:=SeContabiliza) Then ErrorPrepoliza = True + Else + 'validación de flcutuacción + If CompraActual.TC <> TCNC Then + Dim tConceptoContable As Integer + Dim tTipoMovimiento As Boolean + Dim Diferencia As Decimal = 0 + + If CompraActual.TC > TCNC Then + tConceptoContable = 64 + tTipoMovimiento = True + Else + tConceptoContable = 65 + tTipoMovimiento = False + End If + Diferencia = (timporteMovimientoNC * (CompraActual.TC - TCNC)).RoundSQL 'Añadimos la diferencia de perdida en la venta + + If Diferencia <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, tTipoMovimiento, Diferencia, Diferencia, tConceptoContable, Referencia, Concepto, CveCompra:=CveCompra, CveSubProyecto:=CompraActual.CveSubProyecto, CveProveedor:=CompraActual.CveProveedor) Then + ErrorPrepoliza = True + End If + End If + End If End If End If Next @@ -6796,6 +6819,7 @@ Partial Class Compras_Compras ' DTDistinct = DTDistinct.FiltraParametros("ISNULL(TipoAF, 0) <> 2", "", {"CveClasificacion", "Clasificacion", "SubProyecto", "CveSubProyecto", "CveTipoGasto", "TipoGasto"}) 'Else + For Each drowdis As DataRow In DTDistinct.Rows If drowdis("CveTipoGasto").ToString = "" Then drowdis("CveTipoGasto") = 0 @@ -6869,7 +6893,7 @@ Partial Class Compras_Compras importeMovimiento = 0 End If Case 5 'Proveedores - If CveTipoConcepto = 2 Then ConceptoContable = 305 'cuando es acreedor + If CveTipoConcepto <> 1 Then ConceptoContable = 305 'cuando es acreedor Dim UsaComplementaria As Boolean = True If UsuarioActual.CveEmpresa.Contiene(13, 83) Then UsaComplementaria = False @@ -6890,7 +6914,7 @@ Partial Class Compras_Compras If tipoCambioActual > 1 Then Concepto += $" TC{tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}" Dim CveConceptoContableComplementaria As Integer = 201 - If CveTipoConcepto = 2 Then CveConceptoContableComplementaria = 307 + If CveTipoConcepto <> 1 Then CveConceptoContableComplementaria = 307 If tipoCambioActual <> 1 Then @@ -8588,7 +8612,6 @@ Partial Class Compras_Compras 'PORCENTAJE IVA Dim PorcentajeIVA As Decimal = TmpDT.MAX("IVAPorcentaje").ToDecimal - Dim TmpCveRetIVAConcepto As Integer = If(CveRetIVAConceptoOriginal <> DdlRetIVAConcepto.SelectedValue.ToEntero, DdlRetIVAConcepto.SelectedValue.ToEntero, -1) Dim TmpCveRetISRConcepto As Integer = If(CveRetISRConceptoOriginal <> DdlRetISRConcepto.SelectedValue.ToEntero, DdlRetISRConcepto.SelectedValue.ToEntero, -1) Dim tNoDeducible As Integer = If(ChkEsNoDeducible.Checked, 1, 0) @@ -9207,15 +9230,10 @@ Partial Class Compras_Compras End If Dim CveMovimientoInventario As Integer = CveMovimientoAlmacen - - Dim DT As DataTable Dim tipoCambioActual, tipoCambioPago As Decimal Dim FechaMovimiento As Date = TxtFecha.Text.ToDate - - - If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then tipoCambioActual = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal tipoCambioActual = If(DivTC.Visible Or TipoCambio > 0, TipoCambio, tipoCambioActual) @@ -9248,17 +9266,20 @@ Partial Class Compras_Compras Dim CveProveedorConcepto As Integer = 0, CveIE As Integer = 0, CveCreditoDetalle As Integer = 0 Dim ConceptoPersonal As String = "", Concepto As String = "" + Dim tUsaInventarios As Boolean = UsuarioActual.Empresa.UsaInventarios + If (UsuarioActual.CveEmpresa.Contiene(13, 83, 7, 11, 12, 122, 145)) Then tUsaInventarios = False If Not ObjConta.GetPrePolizasDetalleCompra(CveCompra, UsuarioActual.CveEmpresa) Then ErrorPrepoliza = True Else - DtPrePolizas = ObjConta.DtResultados.FiltraParametros("CveConceptoContable IN (6,68,49,205,176)") + DtPrePolizas = ObjConta.DtResultados.FiltraParametros("CveConceptoContable IN (6,68,49,205,176,5,305,311)") If DtPrePolizas.Rows.Count > 0 Then - CveProveedorConcepto = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveProveedor").ToString.ToEntero - CveIE = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveIE").ToString.ToEntero - CveCreditoDetalle = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("CveCreditoDetalle").ToString.ToEntero - Concepto = ObjConta.DtResultados.FiltraParametros("CveConceptoContable = 6 OR CveConceptoContable = 68 OR CveConceptoContable = 49 OR CveConceptoContable = 205 OR CveConceptoContable = 176").Rows(0)("Concepto").ToString + Dim drr As DataRow = ObjConta.DtResultados.FiltraParametros("CveConceptoContable in(6,68,49,205,176,5,305,311)").FiltroPrimero("") + CveProveedorConcepto = drr("CveProveedor").ToString.ToEntero + CveIE = drr("CveIE").ToString.ToEntero + CveCreditoDetalle = drr("CveCreditoDetalle").ToString.ToEntero + Concepto = drr("Concepto").ToString End If End If @@ -9297,7 +9318,7 @@ Partial Class Compras_Compras If ObjCompra.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then CveConceptoContableAlmacen = ObjCompra.DtResultados.FiltroPrimeroValor("CveConceptoContableAlmacen").ToEntero - If CveConceptoContableAlmacen = 0 Then + If CveConceptoContableAlmacen = 0 AndAlso tUsaInventarios Then If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then If (CveImportacion > 0 Or CveFlete > 0) Then CveConceptoContableAlmacen = CveConceptoContableAlmacen @@ -9335,7 +9356,7 @@ Partial Class Compras_Compras importeMovimiento = 0 'COSTO ALMACEN Dim DtAlmacenes As DataTable = GlobalDTAlmacen(UsuarioActual.CveEmpresa) - If UsuarioActual.Empresa.UsaInventarios And CveConceptoContableAlmacen = 0 Or DdlTipoCompra.SelectedValue.ToEntero = 10 Then + If tUsaInventarios And CveConceptoContableAlmacen = 0 Or DdlTipoCompra.SelectedValue.ToEntero = 10 Then DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen"}) 'RECORREMOS PARA DETECTAR LA MODALIDAD DEL ALMACEN, EN CASO DE SER SOLO EXISTENCIA LIMPIAMOS CVEALMACEN @@ -9366,7 +9387,7 @@ Partial Class Compras_Compras importeMovimiento = 0 'INV [MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA) ] - If DdlTipoCompra.SelectedValue.ToEntero <> 10 AndAlso UsuarioActual.Empresa.UsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And CveConceptoContableAlmacen.Contiene(176, 205) Then + If DdlTipoCompra.SelectedValue.ToEntero <> 10 AndAlso tUsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") And CveConceptoContableAlmacen.Contiene(176, 205) Then importeMovimiento = TmpDT.SUM("Total", $"ISNULL(TipoAF,0) <> 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal importeMN = importeMovimiento * tipoCambioActual * Multiplicador @@ -9380,7 +9401,7 @@ Partial Class Compras_Compras 'NC CON PRODUCTOS - CUENTA PUENTE - If UsuarioActual.Empresa.UsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("Ant") And CveConceptoContableAlmacen.Contiene(225) Then + If tUsaInventarios And Not DdlTipoComprobante.SelectedValue.Contiene("Ant") And CveConceptoContableAlmacen.Contiene(225) Then importeMovimiento = TmpDT.SUM("Total", $"ISNULL(TipoAF,0) <> 2 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal importeMN = importeMovimiento * tipoCambioActual * Multiplicador @@ -9409,7 +9430,7 @@ Partial Class Compras_Compras If DdlTipoCompra.SelectedValue.ToEntero <> 10 Then 'QUITA 1-[MERCANCIA RECIBIDA POR ADELANTADO (OC) | MERCANCIA PENDIENTE POR RECIBIR (COMPRA)] 2-[NC CON PRODUCTOS] - If UsuarioActual.Empresa.UsaInventarios And CveConceptoContableAlmacen > 0 Then + If tUsaInventarios And CveConceptoContableAlmacen > 0 Then DT = DT.FiltraParametros("CveTipoPS <> 2") End If End If @@ -18514,7 +18535,9 @@ Partial Class Compras_Compras If ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 49, CveCompra, 1) Then If ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 68, CveCompra, 1) Then If ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 6, CveCompra, 1) Then - TieneError = False + If ObjConta.RemovePrePolizasDetalle(CvePrePoliza, 205, CveCompra, 1) Then + TieneError = False + End If End If End If End If @@ -21131,9 +21154,9 @@ Public Class ClsCompraManagerCompras Public Property CveRetISRConcepto As Integer = -1 Public Property CveSubProyecto As Integer = -1 Public Property UsuarioActual As Usuario - Public ReadOnly Property ConceptoPrePolizaIVA As ConceptosRetenciones + Public ReadOnly Property ConceptoPrePolizaIVA As ClsPaginas.ConceptosRetenciones Get - Dim Ret As New ConceptosRetenciones + Dim Ret As New ClsPaginas.ConceptosRetenciones If EsImportacion Then Ret.CveConceptoAcreditable = 288 Ret.CveConceptoxAcreditar = 287 @@ -21144,9 +21167,9 @@ Public Class ClsCompraManagerCompras Return Ret End Get End Property - Public ReadOnly Property ConceptoPrePolizaRetIVA As ConceptosRetenciones + Public ReadOnly Property ConceptoPrePolizaRetIVA As ClsPaginas.ConceptosRetenciones Get - Dim Ret As New ConceptosRetenciones + Dim Ret As New ClsPaginas.ConceptosRetenciones Dim Funcionalidad, FuncionalidadxAcred As Integer If CveRetIVAConcepto = 1 Then Funcionalidad = 308 : FuncionalidadxAcred = 307 @@ -21176,9 +21199,9 @@ Public Class ClsCompraManagerCompras Return Ret End Get End Property - Public ReadOnly Property ConceptoPrePolizaRetISR As ConceptosRetenciones + Public ReadOnly Property ConceptoPrePolizaRetISR As ClsPaginas.ConceptosRetenciones Get - Dim Ret As New ConceptosRetenciones + Dim Ret As New ClsPaginas.ConceptosRetenciones Dim Funcionalidad, FuncionalidadxAcred As Integer If CveRetISRConcepto = 1 Then Funcionalidad = 316 : FuncionalidadxAcred = 315 @@ -21376,7 +21399,7 @@ Public Class ClsCompraManagerCompras Descuento = ValorXML(nodo, "descuento").ToDecimal Moneda = ValorXML(nodo, "Moneda") - CveMoneda = GlobalDTMonedas().FiltroPrimeroValor("CveMoneda", $" AbreviaturaSAT = '{Moneda}' ").ToEntero + CveMoneda = ClsPaginas.GlobalDTMonedas().FiltroPrimeroValor("CveMoneda", $" AbreviaturaSAT = '{Moneda}' ").ToEntero If Not CveMoneda > 0 Then GuardaLog($"Moneda {Moneda} no se obtuvo la clabe") Errores.AppendLine($"Moneda {Moneda} no se obtuvo la clabe") @@ -21388,7 +21411,7 @@ Public Class ClsCompraManagerCompras TipoCambio = ValorXML(nodo, "TipoCambio", "1").ToDecimal If CFDIVersion = EnumCFDIVersion.v33 Or CFDIVersion = EnumCFDIVersion.v40 Then - Dim drm As DataRow = GlobalDTVtaMetodoPago.FiltroPrimero(String.Format("ClaveMetodoPagoSAT = '{0}'", ValorXML(nodo, "MetodoPago"))) + Dim drm As DataRow = ClsPaginas.GlobalDTVtaMetodoPago.FiltroPrimero(String.Format("ClaveMetodoPagoSAT = '{0}'", ValorXML(nodo, "MetodoPago"))) If drm IsNot Nothing Then CveMetodoPago = drm("CveMetodoPago").ToString.ToEntero MetodoPago = drm("MetodoPagoSAT").ToString diff --git a/Compras/Importaciones.aspx b/Compras/Importaciones.aspx index a25eade62..cb2d69d6a 100644 --- a/Compras/Importaciones.aspx +++ b/Compras/Importaciones.aspx @@ -143,7 +143,7 @@ - + diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb index 427b1e733..4ba4d6a1c 100644 --- a/Compras/PopUpVerFactura.aspx.vb +++ b/Compras/PopUpVerFactura.aspx.vb @@ -2,14 +2,10 @@ Option Explicit On Imports System.Data -Imports System.Data.Entity.Core.Metadata.Edm Imports System.IO Imports System.Xml Imports Extensiones -Imports iText.Barcodes.Dmcode Imports Microsoft.Reporting.WebForms -Imports Modelos -Imports Stimulsoft.Base.Context Imports ZXing @@ -244,7 +240,6 @@ Partial Class PopUpVerFactura End If End Sub - Private Sub DescargaArchivoDirecto(RutaArchivo As String) If RutaArchivo <> "" Then @@ -351,7 +346,7 @@ Partial Class PopUpVerFactura Dim totalPallets As String = "" Dim totalBachas As String = "" Dim dfec As DateTime = fecha.ToDateTime() - Dim fechas As String = String.Format(New System.Globalization.CultureInfo("es-MX"), "{0:dd} DE {0:MMMM} DEL {0:yyyy}", dfec).ToUpper() + Dim fechas As String = String.Format(New System.Globalization.CultureInfo("es-MX"), "{0dd} DE {0:MMMM} DEL {0:yyyy}", dfec).ToUpper() Dim totalcajas As String = "" Dim TotalBins As String = "" @@ -385,7 +380,7 @@ Partial Class PopUpVerFactura Dim rds2 As New ReportDataSource With {.Name = "DataSetBins", .Value = tablaReporteBins} lrds.Add(rds2) - '"D:\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" + '"D\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" Dim rutardlc As String = "Formatos\RepAgroInventarioDiario.rdlc" If EnviarCorrreo Then Dim para As String = "" @@ -523,7 +518,6 @@ Partial Class PopUpVerFactura params.Add(New ReportParameter("CAAT", CAAT)) params.Add(New ReportParameter("NumeroTrailer", NumeroTrailer)) - params.Add(New ReportParameter("NoFactura", NoFactura)) params.Add(New ReportParameter("Mercado", Mercado)) params.Add(New ReportParameter("NoBultos", NoBultos)) @@ -531,16 +525,11 @@ Partial Class PopUpVerFactura params.Add(New ReportParameter("NoKgManifiesto", NoKgManifiesto)) - - - - - Dim lrds As New List(Of ReportDataSource) Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = tablaReporte} lrds.Add(rds) - '"D:\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" + '"D\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" Dim rutardlc As String = "Formatos\Agro\EmbarqueManifiesto.rdlc" If Not IsNothing(tablaReporte.FiltroPrimero("TipoManifiesto=1")) Then rutardlc = "Formatos\Agro\EmbarqueManifiesto2.rdlc" @@ -698,7 +687,7 @@ Partial Class PopUpVerFactura Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = tablaReporte} lrds.Add(rds) '"Empresas/Grales/Formatos/EquiposGPS.rdlc" - '"D:\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" + '"D\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" ImprimirPDF("Formatos\Agro\EmbarqueManifiestoRemision.rdlc", lrds, params, "Remisión") ', Content_Disposition:="Inline") End Sub @@ -754,7 +743,7 @@ Partial Class PopUpVerFactura Cliente = row("Cliente").ToString() Direccion = row("Direccion").ToString() Correo = row("Correo").ToString() - Fecha = String.Format("{0:dd/MM/yyyy}", row("Fecha")) + Fecha = String.Format("{0dd/MM/yyyy}", row("Fecha")) DivisoresdeCarton = String.Format("{0:N0}", row("DivisoresdeCarton")) BolsasdePlastico = String.Format("{0:N0}", row("BolsasdePlastico")) TapaderasdeCarton = String.Format("{0:N0}", row("TapaderasdeCarton")) @@ -769,7 +758,7 @@ Partial Class PopUpVerFactura AgenciaAduanalUSA = row("AgenciaAduanalUSA").ToString() AgenciaAduanalMEX = row("AgenciaAduanalMEX").ToString() Temperatura = row("Temperatura").ToString() - Hora = String.Format("{0:hh }:{0:mm }:{0:ss tt}:", row("FechaIng")) + Hora = String.Format("{0hh }:{0:mm }:{0:ss tt}:", row("FechaIng")) Chofer = row("Chofer").ToString() CamPlaca = row("CamPlaca").ToString() Camion = String.Format("{0} {1}", row("CamEspecificacion"), row("CamAnio")) @@ -850,7 +839,7 @@ Partial Class PopUpVerFactura Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = tablaReporte} lrds.Add(rds) '"Empresas/Grales/Formatos/EquiposGPS.rdlc" - '"D:\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" + '"D\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" Dim pdf As Byte() = StreamPDF("Formatos\Agro\EmbarqueManifiestoCartaPorte.rdlc", lrds, params, "DatosCartaPorte") Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) @@ -932,7 +921,7 @@ Partial Class PopUpVerFactura lrds.Add(rds2) 'endimg '"Empresas/Grales/Formatos/EquiposGPS.rdlc" - '"D:\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" + '"D\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" ImprimirPDF("Formatos\Agro\PalletEtiqueta2.rdlc", lrds, params, "Pallet") ', Content_Disposition:="Inline") End Sub @@ -973,8 +962,8 @@ Partial Class PopUpVerFactura Fecha = String.Format("{0:MMM dd}", row("Fecha")).Replace(".", "").ToUpper() CvetypeImpresion = row("CvetypeImpresion").ToString().ToEntero() NumberOfCode = String.Format("(00)00000000000000(00){1:ddMMyy}(00){0}00", Right(String.Format("0{0}", Regex.Match(row("Cuadro").ToString(), "\d+")), 2), row("Fecha")) - 'NumberSmall = String.Format("{0:00}", noPallet.ToEntero()) - 'NumberBig = String.Format("{0:00}", row("Consecutivo").ToString().ToEntero()) ' String.Format("{0:dd}", row("Fecha")) + 'NumberSmall = String.Format("{000}", noPallet.ToEntero()) + 'NumberBig = String.Format("{000}", row("Consecutivo").ToString().ToEntero()) ' String.Format("{0:dd}", row("Fecha")) NumberSmall = row("NumberSmall").ToString() @@ -1058,7 +1047,7 @@ Partial Class PopUpVerFactura lrds.Add(rds) '"Empresas/Grales/Formatos/EquiposGPS.rdlc" - '"D:\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" + '"D\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" Dim ruta As String = "Formatos\Agro\PalletEtiquetaWalmart.rdlc" 'If CvetypeImpresion = 2 Then ' ruta = "Formatos\Agro\PalletEtiqueta_2.rdlc" @@ -1098,8 +1087,8 @@ Partial Class PopUpVerFactura Fecha = String.Format("{0:MMM dd}", row("Fecha")).Replace(".", "").ToUpper() CvetypeImpresion = row("CvetypeImpresion").ToString().ToEntero() NumberOfCode = String.Format("(00)00000000000000(00){1:ddMMyy}(00){0}00", Right(String.Format("0{0}", Regex.Match(row("Cuadro").ToString(), "\d+")), 2), row("Fecha")) - NumberSmall = String.Format("{0:00}", noPallet.ToEntero()) - NumberBig = String.Format("{0:00}", row("Consecutivo").ToString().ToEntero()) ' String.Format("{0:dd}", row("Fecha")) + NumberSmall = String.Format("{000}", noPallet.ToEntero()) + NumberBig = String.Format("{000}", row("Consecutivo").ToString().ToEntero()) ' String.Format("{0:dd}", row("Fecha")) End If End Using Dim params As New List(Of ReportParameter) @@ -1156,7 +1145,7 @@ Partial Class PopUpVerFactura lrds.Add(rds) '"Empresas/Grales/Formatos/EquiposGPS.rdlc" - '"D:\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" + '"D\\ADSistemas\\Proyectos\\SIG\\SIGIT\\GPS\\PalletEtiqueta.rdlc" Dim ruta As String = "Formatos\Agro\PalletEtiquetaCaja.rdlc" 'If CvetypeImpresion = 2 Then ' ruta = "Formatos\Agro\PalletEtiqueta_2.rdlc" @@ -1574,7 +1563,7 @@ Partial Class PopUpVerFactura Dim Fecha As String = "", Nombre As String = "" Dim OpcionDetallado As Integer = 1 - If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then OpcionDetallado = 2 + If UsuarioActual.Empresa.Funcionalidad(109) = "1" OrElse UsuarioActual.CveEmpresa = 197 Then OpcionDetallado = 2 Dim ObjVenta As New ClsVentas Dim ObjPuntoVenta As New ClsPuntoVenta @@ -1593,7 +1582,7 @@ Partial Class PopUpVerFactura End If End If - If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + If UsuarioActual.Empresa.Funcionalidad(109) = "1" OrElse UsuarioActual.CveEmpresa = 197 Then If ObjPuntoVenta.GetVta_ReporteCortes(UsuarioActual.CveEmpresa, MinFecha, MaxFecha, CveSubProyecto, CveCorte:=CveCorte) Then DtReporteCorte = ObjPuntoVenta.DtResultados.FiltraParametros("CveCorte > 0") End If @@ -1602,7 +1591,7 @@ Partial Class PopUpVerFactura DtIngresosRetiros = ObjPuntoVenta.DtResultados.Copy() End If - If Not UsuarioActual.CveEmpresa.Contiene(140, 141) AndAlso ObjVenta.GetCortesDetalleDepositosCaja(CveCorte, -1, UsuarioActual.CveEmpresa) Then + If Not UsuarioActual.CveEmpresa.Contiene(140, 141) AndAlso ObjVenta.GetCortesDetalleDepositosCaja(CveCorte, CveSubProyecto, UsuarioActual.CveEmpresa) Then DtDepositos = ObjVenta.DtResultados.Copy() End If End If @@ -1610,8 +1599,8 @@ Partial Class PopUpVerFactura ObjVenta.Dispose() ObjPuntoVenta.Dispose() - Dim FechaCorte As String = $" Fecha fin: {Fecha}" - Dim Usuario As String = $" Usuario: {Nombre}" + Dim FechaCorte As String = $" Fecha fin {Fecha}" + Dim Usuario As String = $" Usuario {Nombre}" If DtCortesVentas.Rows.Count > 0 Or DtCortesVentasResumen.Rows.Count > 0 Then Dim lrds As New List(Of ReportDataSource) @@ -1621,7 +1610,6 @@ Partial Class PopUpVerFactura If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then DtMetodosPago = DtCortesVentasResumen.FiltraParametros("MetodoPago <> 'Crédito'") End If - Dim DirFormato As String = "Empresas/Grales/Formatos/RepCortes.rdlc" If File.Exists(UsuarioActual.Empresa.Ruta + "\Formatos\RepCortes.rdlc") Then DirFormato = UsuarioActual.Empresa.Ruta + "\Formatos\RepCortes.rdlc" @@ -1634,7 +1622,7 @@ Partial Class PopUpVerFactura params.Add(New ReportParameter("AgrupoPor", $"{FechaCorte}{Usuario}")) params.Add(New ReportParameter("LogoPath", RutaImagenLogo)) - If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + If UsuarioActual.Empresa.Funcionalidad(109) = "1" OrElse UsuarioActual.CveEmpresa = 197 Then If DtReporteCorte IsNot Nothing Then Dim DtTT = GenerateTransposedTable(DtReporteCorte) Dim DtDatosVentas As New DataTable() @@ -1674,9 +1662,13 @@ Partial Class PopUpVerFactura Orden = 5 TipoTabla = 1 Case "VentaTotalRemision" - rowData("Columna") = "Ventas Remisiones" - Orden = 6 - TipoTabla = 1 + If UsuarioActual.CveEmpresa.Contiene(190, 192) Then + rowData("Columna") = "Ventas Remisiones" + Orden = 6 + TipoTabla = 1 + Else + Orden = 0 + End If Case "TotalEfectivo" rowData("Columna") = "Total Efectivo" Orden = 7 @@ -1739,13 +1731,13 @@ Partial Class PopUpVerFactura DtDatosCajas.Rows.Add(rowData.ItemArray) End If - If row(0).ToString() = "SaldoAnteriorAplicado" Then - Dim RowMP As DataRow = DtMetodosPago.NewRow - RowMP("MetodoPago") = "Saldo Aplicado" - RowMP("Importe") = Total.ToDecimal() + 'If row(0).ToString() = "SaldoAnteriorAplicado" Then + ' Dim RowMP As DataRow = DtMetodosPago.NewRow + ' RowMP("MetodoPago") = "Saldo Aplicado" + ' RowMP("Importe") = Total.ToDecimal() - DtMetodosPago.Rows.Add(RowMP) - End If + ' DtMetodosPago.Rows.Add(RowMP) + 'End If End If Next @@ -1768,15 +1760,30 @@ Partial Class PopUpVerFactura lrds.Add(rds5) - If UsuarioActual.CveEmpresa = 193 Then + If UsuarioActual.CveEmpresa.Contiene(197, 193) Then + Dim CveCuenta As Integer = -1 + If UsuarioActual.CveEmpresa = 193 Then + CveCuenta = 186367 + Else + CveCuenta = 0 - Dim CveCuenta As Integer = 186367 - Using ObjConta As New ClsContabilidad - If ObjConta.GetAnexoCatalogo(CveCuenta, Fecha.ToDate(), Fecha.ToDate(), -1, -1, -1, UsuarioActual.CveEmpresa, 1) Then - Dim rdsConta As New ReportDataSource With {.Name = "DsContabilidad", .Value = ObjConta.DtResultados} - lrds.Add(rdsConta) + If CveSubProyecto = 12756 Then 'nav + CveCuenta = 188796 End If - End Using + + If CveSubProyecto = 12755 Then 'hillo + CveCuenta = 188795 + End If + End If + + If CveCuenta >= 0 Then + Using ObjConta As New ClsContabilidad + If ObjConta.GetAnexoCatalogo(CveCuenta, Fecha.ToDate(), Fecha.ToDate(), -1, -1, -1, UsuarioActual.CveEmpresa, 1) Then + Dim rdsConta As New ReportDataSource With {.Name = "DsContabilidad", .Value = ObjConta.DtResultados} + lrds.Add(rdsConta) + End If + End Using + End If If DtDepositos IsNot Nothing Then Dim rdsDepositos As New ReportDataSource With {.Name = "DsDepositos", .Value = DtDepositos} @@ -4693,7 +4700,7 @@ Partial Class PopUpVerFactura Dim ObjAcum As New ClsAcumuladores Dim DatosEntradasUsados As New DataTable Dim CveAlmacen As String = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", String.Format("Almacen = '{0}'", Almacen)) - If ObjAcum.EntradasUsadosGet(UsuarioActual.CveEmpresa, CveAlmacen.ToEntero, Convert.ToDateTime(Fecha.ToString), Convert.ToDateTime(Today.ToString)) Then + If ObjAcum.EntradasUsadosGet(UsuarioActual.CveEmpresa, CveAlmacen.ToEntero, Fecha.ToDate, Today.ToDate) Then DatosEntradasUsados = ObjAcum.DtResultados End If @@ -5751,18 +5758,22 @@ Partial Class PopUpVerFactura If ObjIE.GetBancosIEFacturasPagadas(CveIE, UsuarioActual.CveEmpresa) Then dtMovs = ObjIE.DtResultados.FiltraParametros("CveConceptoContable IN (17,2,308,309,312,292 )") - CvePrePoliza = dtMovs.Rows(0)("CVePrePoliza").ToString.ToEntero - If Not UsuarioActual.CveEmpresa.Contiene(13, 83) Then - 'CONVIERTO A PESOS CUANDO SE PAGA CON PESOS FACTURAS DE DOLARES - For Each Dr As DataRow In dtMovs.Rows - Dr("Importe") = Dr("ImporteMN").ToString.ToDecimal - Dr("ImporteNC") = Dr("ImporteNC").ToString.ToDecimal * Dr("TC").ToString.ToDecimal - Dr("Total") = Dr("Total").ToString.ToDecimal * Dr("TC").ToString.ToDecimal - Dr("Saldo") = Dr("Saldo").ToString.ToDecimal * Dr("TC").ToString.ToDecimal - Next + If dtMovs IsNot Nothing AndAlso dtMovs.Rows.Count > 0 Then + CvePrePoliza = dtMovs.Rows(0)("CVePrePoliza").ToString.ToEntero + + If Not UsuarioActual.CveEmpresa.Contiene(13, 83) Then + 'CONVIERTO A PESOS CUANDO SE PAGA CON PESOS FACTURAS DE DOLARES + For Each Dr As DataRow In dtMovs.Rows + Dr("Importe") = Dr("ImporteMN").ToString.ToDecimal + Dr("ImporteNC") = Dr("ImporteNC").ToString.ToDecimal * Dr("TC").ToString.ToDecimal + Dr("Total") = Dr("Total").ToString.ToDecimal * Dr("TC").ToString.ToDecimal + Dr("Saldo") = Dr("Saldo").ToString.ToDecimal * Dr("TC").ToString.ToDecimal + Next + End If End If + End If Dim rds As New ReportDataSource("DataSet1", dtMovs) @@ -5794,7 +5805,7 @@ Partial Class PopUpVerFactura End With dtMovs.Dispose() - If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 Then + If UsuarioActual.Empresa.Funcionalidad(574).ToEntero = 1 And CvePrePoliza > 0 Then Dim ObjContabilidad As New ClsContabilidad @@ -5959,7 +5970,7 @@ Partial Class PopUpVerFactura Dim QrDescarga As String = "" Dim Cfdi As New RVCFDI33.GeneraCFDI() Dim b As Byte() = Cfdi.ConvertirQrCode(String.Format("?CvePS={0}&Lote={1}&Fecha={2}", CvePS, Lote, Format(FechaCaducidad, "dd/MM/yyyy").ToString())) - QrDescarga = Convert.ToBase64String(b) + QrDescarga = System.Convert.ToBase64String(b) Dim params As New List(Of ReportParameter) params.Add(New ReportParameter("QR", QrDescarga)) params.Add(New ReportParameter("PS", PS)) @@ -6286,7 +6297,7 @@ Partial Class PopUpVerFactura DtPrecios.Columns.Add(New DataColumn("CBBase64", GetType(String))) For Each Row As DataRow In DtPrecios.Rows - Row("CBBase64") = Convert.ToBase64String(GeneraCodigoQR(Row("CodigoBarras").ToString(), 40, 150, 0, "CODE_39", True)) + Row("CBBase64") = System.Convert.ToBase64String(GeneraCodigoQR(Row("CodigoBarras").ToString(), 40, 150, 0, "CODE_39", True)) Next Dim DirectorioArchivo As String = "Empresas/Grales/Formatos/Etiqueta.mrt" @@ -6383,7 +6394,7 @@ Partial Class PopUpVerFactura Else params.Add(New ReportParameter("Fecha", Fecha.ToShortDateString)) End If - If UsuarioActual.CveEmpresa.Contiene(119, 141) Then + If UsuarioActual.CveEmpresa.Contiene(119, 141, 193, 195, 197, 189) Then params.Add(New ReportParameter("UsuarioRegistro", GlobalDTUsuarios(drp("CveUsuario").ToString.ToEntero).FiltroPrimeroValor("Nombre"))) End If If UsuarioActual.CveEmpresa.Contiene(140, 141) Then diff --git a/Compras/Proveedores.aspx.vb b/Compras/Proveedores.aspx.vb index ea2e659fe..9835bc81d 100644 --- a/Compras/Proveedores.aspx.vb +++ b/Compras/Proveedores.aspx.vb @@ -1309,7 +1309,7 @@ Partial Class Compras_Proveedores e.Row.FCHyperLink("HplCheque").Visible = True HLSendMail.Visible = True - HLSendMail.HRef = String.Format("javascript:$get('HdnCveIE').value='{0}';$get('HdnSerieFolio').value='{1}';$get('HdnFolioPago').value='{2}';$get('TxtParaMail').value='{3}';$('#ModalDivMail').modal();", e.Row.DBCampo("CveIE"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("FolioPago"), TxtCorreoCobranza.Text) + HLSendMail.HRef = String.Format("javascript:$get('HdnCveIE').value='{0}';$get('HdnSerieFolio').value='{1}';$get('HdnFolioPago').value='{2}';$get('TxtParaMail').value='{3}';$('#ModalDivMail').modal();void(0);", e.Row.DBCampo("CveIE"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("FolioPago"), TxtCorreoCobranza.Text) If ObjCompra.GetCompraComplementoPago(-1, UsuarioActual.CveEmpresa, e.Row.DBCampo("CveIE").ToString.ToEntero) Then If ObjCompra.DtResultados.Rows.Count > 0 Then @@ -4139,8 +4139,10 @@ Partial Class Compras_Proveedores End Sub Private Sub LnkAddParametros_Click(sender As Object, e As EventArgs) Handles LnkAddParametros.Click + LblLimiteCredito.Text = TxtLimiteCredito.Text.FormatoNumero LblPlazoCobranza.Text = TxtPlazoCobranza.Text + If LblLimiteCredito.Text.ToDouble > 0 Then TdSaldo.Visible = True TdSaldo2.Visible = True @@ -4149,9 +4151,24 @@ Partial Class Compras_Proveedores TdSaldo.Visible = False TdSaldo2.Visible = False End If + + If CveProveedor > 0 Then + Dim ObjPro As New ClsCompProveedores + If ObjPro.UpdateProveedorLimiteCredito(CveProveedor, TxtLimiteCredito.Text.ToDecimal, TxtPlazoCobranza.Text.ToEntero, ChkUsaLimiteCredito.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + Alert("Limite de crédito modificado correctamente.") + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddParametros")) + End If + ObjPro.Dispose() + Else + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddParametros")) + End If + + + + UPPCxP.Update() UpParametros.Update() - RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddParametros")) + End Sub Private Sub LnkCuentasBancarias_Click(sender As Object, e As EventArgs) Handles LnkCuentasBancarias.Click @@ -5493,35 +5510,47 @@ Partial Class Compras_Proveedores Private Sub BtnSendMail_Click(sender As Object, e As EventArgs) Handles BtnSendMail.Click 'NotificacionPago(HdnCveIE.Value.ToEntero, Txt) - Dim ObjMail As New ClsSisMail() - Dim Body As String = GeneraCorreo(HdnCveIE.Value.ToEntero) - Dim ListaArchivos As New List(Of ClsSisMail.ArchivoMail) + Dim ObjBancos As New ClsBancos() - Dim ObjIE As New ClsBancos() - Dim ComprobanteIE As String - If ObjIE.GetBancosIE(HdnCveIE.Value.ToEntero, UsuarioActual.CveEmpresa) Then - If ObjIE.DtResultados.Rows.Count > 0 Then - If ObjIE.Comprobante <> "" Then - ComprobanteIE = String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ObjIE.Comprobante.ToString) - - If IO.File.Exists(ComprobanteIE) Then - ListaArchivos.Add(New ClsSisMail.ArchivoMail With {.Ruta = ComprobanteIE.ToString}) - End If - End If + If ObjBancos.NotificacionPago(HdnCveIE.Value.ToEntero, TxtParaMail.Text.Trim, TxtCC.Text.Trim, UsuarioActual) Then + Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + Else + Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) End If - End If - ObjIE.Dispose() - If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Notificaciones de pago", Body, TxtCC.Text.Trim, Displayname:="Notificaciones de pago", Archivos:=ListaArchivos) Then - 'ResultadoMail = 1 - TxtCC.Text = "" - TxtBody.Text = "" - RegistraScript("$('#ModalDivMail').modal('hide');") - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) - Else - Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) - End If + ObjBancos.Dispose() + + + 'Dim ObjMail As New ClsSisMail() + 'Dim Body As String = GeneraCorreo(HdnCveIE.Value.ToEntero) + + 'Dim ListaArchivos As New List(Of ClsSisMail.ArchivoMail) + + 'Dim ObjIE As New ClsBancos() + 'Dim ComprobanteIE As String + 'If ObjIE.GetBancosIE(HdnCveIE.Value.ToEntero, UsuarioActual.CveEmpresa) Then + ' If ObjIE.DtResultados.Rows.Count > 0 Then + ' If ObjIE.Comprobante <> "" Then + ' ComprobanteIE = String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ObjIE.Comprobante.ToString) + + ' If IO.File.Exists(ComprobanteIE) Then + ' ListaArchivos.Add(New ClsSisMail.ArchivoMail With {.Ruta = ComprobanteIE.ToString}) + ' End If + ' End If + ' End If + 'End If + 'ObjIE.Dispose() + + 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Notificaciones de pago", Body, TxtCC.Text.Trim, Displayname:="Notificaciones de pago", Archivos:=ListaArchivos) Then + ' 'ResultadoMail = 1 + ' TxtCC.Text = "" + ' TxtBody.Text = "" + ' RegistraScript("$('#ModalDivMail').modal('hide');") + ' Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + 'Else + ' Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) + 'End If End Sub #End Region diff --git a/Contabilidad/PlantillasPolizasDetalle.aspx.vb b/Contabilidad/PlantillasPolizasDetalle.aspx.vb index f87298a0c..41359a5ee 100644 --- a/Contabilidad/PlantillasPolizasDetalle.aspx.vb +++ b/Contabilidad/PlantillasPolizasDetalle.aspx.vb @@ -138,7 +138,6 @@ Partial Class Contabilidad_PlantillasPolizasDetalle Private Sub CargaCuenta() DdlCtaContable.Items.Clear() - DdlCtaContable.Items.Insert(0, New ListItem("Seleccione", "-1")) If UsuarioActual.Empresa.TipoContabilidad = 1 Then @@ -148,7 +147,6 @@ Partial Class Contabilidad_PlantillasPolizasDetalle If Conta.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then dtt = Conta.DtResultados End If - Conta.Dispose() DdlCuentas.Items.Clear() @@ -156,14 +154,12 @@ Partial Class Contabilidad_PlantillasPolizasDetalle DdlCuentas.DataBind() DdlCuentas.Visible = True DdlCtaContable.Visible = False + DdlCuentas.Items.Insert(0, New ListItem("-", "-1")) Else - DdlCtaContable.DataSource = DTCuentasContables DdlCtaContable.DataBind() End If - - DdlCuentas.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub Private Sub CargarConcepto() diff --git a/Contabilidad/RegPrePolizaS.aspx b/Contabilidad/RegPrePolizaS.aspx index 4856937c2..23a848b8a 100644 --- a/Contabilidad/RegPrePolizaS.aspx +++ b/Contabilidad/RegPrePolizaS.aspx @@ -69,37 +69,27 @@ - - -
  • - Cargar Excel -
  • -
  • - Crear Complemento de Pago -
  • +
  • Imprimir Poliza -
  • - - <%--
  • - Imprimir PDF Resumen -
  • --%> - <%--
  • - Imprimir Excel Resumen -
  • --%> - - +
  • - Agregar Concepto
  • Crear a partir de
  • +
  • + Complemento de Pago +
  • +
  • + Cargar Excel +
  • -
    + +
    @@ -328,7 +318,7 @@ Cuenta -
    +
    @@ -389,7 +379,7 @@ - + @@ -631,7 +621,7 @@
    - +
    @@ -1008,6 +998,52 @@
    + + diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb index bbf936287..8fa667a29 100644 --- a/Contabilidad/RegPrePolizaS.aspx.vb +++ b/Contabilidad/RegPrePolizaS.aspx.vb @@ -6,7 +6,6 @@ Imports GemBox.Spreadsheet Partial Class ContabilidadC_RegPrePolizaS Inherits ClsPaginas - #Region "Propiedades" Public Property ArregloMovs As ArrayList Get @@ -322,7 +321,7 @@ Partial Class ContabilidadC_RegPrePolizaS TxtFechaDocumento.Text = NowADS().ToString("dd/MM/yyyy") TxtFechaelaboracion.Text = NowADS().ToString("dd/MM/yyyy") TxtConcepto.Enabled = True - TxtUsuarioElaboro.Text = UsuarioActual.Usuario + TxtUsuarioElaboro.Text = UsuarioActual.Nombre End If @@ -449,7 +448,7 @@ Partial Class ContabilidadC_RegPrePolizaS Folio = dr("FolioPoliza").ToString TxtFolio.Text = dr("FolioPoliza").ToString - TxtUsuarioElaboro.Text = dr("Usuario").ToString + TxtUsuarioElaboro.Text = dr("UsuarioNombre").ToString TxtFechaelaboracion.Text = dr("FechaIng").ToString.ToDate.ToString("dd/MM/yyyy") TxtFechaelaboracion.ToolTip = dr("FechaIng").ToString.ToDate.ToString("HH:mm:ss") CvePlantillaPoliza = dr("CvePlantillaPoliza").ToString.ToEntero @@ -504,7 +503,7 @@ Partial Class ContabilidadC_RegPrePolizaS GvPrePoliza.Columns(7).Visible = True End If - If DtMovimientos.FiltraParametros("CveConceptoContable IN (2,17,292,308)").Rows.Count > 0 Then + If DtMovimientos.FiltraParametros("CveConceptoContable IN (2,292)").Rows.Count > 0 AndAlso DtMovimientos.FiltraParametros("CveConceptoContable IN (30)").Rows.Count = 0 Then LnkComplementoPago.Visible = True End If @@ -769,7 +768,7 @@ Partial Class ContabilidadC_RegPrePolizaS Dim dr As DataRow = DtMovimientos.NewRow dr("CodigoNombreCuenta") = drt("Codigo").ToString & "
    " & drt("Nombre").ToString - 'dr("Cuenta") = drt("ConceptoContable").ToString + dr("ConceptoContable") = drt("ConceptoContable").ToString dr("Referencia") = If(drt("CveConceptoContable").ToString.Contiene("29", "130"), drt("Personal"), drt("RazonSocial")) dr("Concepto") = TxtConcepto.Text dr("TipoMovto") = If(drt("TipoMovto").ToString = "False", 0, 1) @@ -1022,7 +1021,7 @@ Partial Class ContabilidadC_RegPrePolizaS End If 'Registra movimieno bancario - If gvr.DataKey("CveConceptoContable") = "30" AndAlso Importe <> 0 Then + If gvr.DataKey("CveConceptoContable") = "30" AndAlso (Importe <> 0 OrElse DdlPlantilla.SelectedValue = "53") Then Dim tFolio As String = gvr.DataKey("ContadoNumeroFolio").ToString If tFolio.ToEntero = 0 Then tFolio = SiguienteFolioBancos(gvr.DataKey("ContadoCuenta").ToEntero, gvr.DataKey("ContadoTipoTransaccion").ToEntero) @@ -2073,6 +2072,36 @@ Partial Class ContabilidadC_RegPrePolizaS #Region "COMPLEMENTO DE PAGO" + Private Sub LnkComplementoPago_Click(sender As Object, e As EventArgs) Handles LnkComplementoPago.Click + CargaComplementosPago() + RegistraScript("$('#ModalComplementoPagos').modal('show');") + End Sub + + Private Sub CargaComplementosPago() + + Dim ObjBancos As New ClsBancos + DVGenerarComplementoModal.Visible = False + + If ObjBancos.GetComplementoPagosRep(-1, MinFecha, MaxFecha, -1, -1, 1, UsuarioActual.CveEmpresa, 2, CvePrePoliza:=CvePrePoliza) Then + Dim dtt As DataTable = Nothing + dtt = ObjBancos.DtResultados + If dtt.Rows.Count > 0 Then + UpComplementoPagos.Visible = True + 'GvComplementoPagos.Columns(7).Visible = True + ' si tiene el permiso para eliminar IE o editar IE + 'If UsuarioActual.TienePermisoProceso(85) OrElse UsuarioActual.TienePermisoProceso(99) Then GvComplementoPagos.Columns(8).Visible = True + Else + DVGenerarComplementoModal.Visible = True + End If + GvComplementoPagos.DataSource = ObjBancos.DtResultados.FiltraParametros("", DistinctColumns:={"CveComplementoPago", "FolioFiscal", "SerieFolioPago", "FechaComplemento", "Importe", "CveIE"}) + + End If + ObjBancos.Dispose() + GvComplementoPagos.DataBind() + UpComplementoPagos.Update() + + End Sub + Private Sub GeneraTimbre(CvePrePoliza As Integer) Dim Str As New StringBuilder Dim Banco As New ClsBancos @@ -2094,6 +2123,18 @@ Partial Class ContabilidadC_RegPrePolizaS Alert(Str.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();") End Sub + Protected Sub GvComplementoPagos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvComplementoPagos.RowDataBound + + If e.Row.RowType = DataControlRowType.DataRow Then + + 'If e.Row.DataKey("Tipo") = "Ing" Then + e.Row.Cells(3).Text = String.Format("", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CVECOMPLEMENTOPAGO={1}&CVEIE={2}", e.Row.DBCampo("SerieFolioPago"), e.Row.DBCampo("CveComplementoPago"), e.Row.DBCampo("CveIE")))) + e.Row.Cells(4).Text = String.Format("", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CVECOMPLEMENTOPAGO={1}&CVEIE={2}", e.Row.DBCampo("SerieFolioPago"), e.Row.DBCampo("CveComplementoPago"), e.Row.DBCampo("CveIE")))) + + 'End If + End If + End Sub + Private Sub MandaCorreo(NombreArchivo As String, Correo As String, Optional ConAlerta As Boolean = True) Try Dim Msg As String = "" @@ -2127,13 +2168,9 @@ Partial Class ContabilidadC_RegPrePolizaS End Try End Sub - Protected Sub LnkComplementoPago_Click(sender As Object, e As EventArgs) - GeneraTimbre(CvePrePoliza) - End Sub #End Region - #Region "E X C E L" @@ -2709,5 +2746,9 @@ Partial Class ContabilidadC_RegPrePolizaS End If UpModalConcepto.Update() End Sub + + Protected Sub LnkEmitirComplemento_Click(sender As Object, e As EventArgs) + GeneraTimbre(CvePrePoliza) + End Sub End Class diff --git a/Contabilidad/RepBalanceGeneral.aspx.vb b/Contabilidad/RepBalanceGeneral.aspx.vb index 2d320e959..1828a1d0c 100644 --- a/Contabilidad/RepBalanceGeneral.aspx.vb +++ b/Contabilidad/RepBalanceGeneral.aspx.vb @@ -293,6 +293,11 @@ Partial Class Contabilidad_RepBalanceGeneral Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then + If UsuarioActual.Empresa.TipoContabilidad = 1 Then + Response.Redirect($"/Contabilidad2/RepSituacionFinanciera.aspx") + End If + + If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then BtnConsultar.Enabled = True TabNormal.Enabled = True diff --git a/Contabilidad/RepEstadoResultados.aspx.vb b/Contabilidad/RepEstadoResultados.aspx.vb index fabfe41ef..c38cf3d20 100644 --- a/Contabilidad/RepEstadoResultados.aspx.vb +++ b/Contabilidad/RepEstadoResultados.aspx.vb @@ -145,6 +145,9 @@ Partial Class Contabilidad_RepEstadoResultados Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then + If UsuarioActual.Empresa.TipoContabilidad = 1 Then + Response.Redirect($"/Contabilidad2/RepEstadoActividades.aspx") + End If If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then diff --git a/Contabilidad2/RepBalanzaComprobacion.aspx b/Contabilidad2/RepBalanzaComprobacion.aspx index faff6a40a..9d0440a3a 100644 --- a/Contabilidad2/RepBalanzaComprobacion.aspx +++ b/Contabilidad2/RepBalanzaComprobacion.aspx @@ -116,75 +116,89 @@
    - - + +
    + + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> - - - - - - - - - - - - - - - - - - - - - - - - -
    Saldos Iniciales
    DeudorAcreedor
    -
    - - - - -
    - - - - - - - - - - - - - - - - - - - - - - -
    Saldos Actuales
    DeudorAcreedor
    -
    - - - - - -
    -
    - -
    - - +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Saldos Iniciales
    DeudorAcreedor
    +
    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    Saldos Actuales
    DeudorAcreedor
    +
    + + + + + +
    +
    + +
    +
    +
    +
    +
    +
    diff --git a/Contratos/RepPresupuestos.aspx b/Contratos/RepPresupuestos.aspx index e62242dae..62963dcf3 100644 --- a/Contratos/RepPresupuestos.aspx +++ b/Contratos/RepPresupuestos.aspx @@ -208,7 +208,7 @@
    Agrupador:
    - +
    @@ -231,7 +231,7 @@ -
    Clasificacion:
    +
    Clasificación:
    @@ -329,7 +329,8 @@ - + + @@ -340,8 +341,9 @@ <%-- - - + + + @@ -377,9 +379,11 @@
    AgrupadorAutorizadoAutorizadoComprometido Ejercido Por Ejercer PagadoTotal
    + - + + @@ -459,15 +463,19 @@ <%-- --%> - + <%-- --%> - + + + + +
    diff --git a/Contratos/RepPresupuestos.aspx.vb b/Contratos/RepPresupuestos.aspx.vb index 072b886aa..50555e6cb 100644 --- a/Contratos/RepPresupuestos.aspx.vb +++ b/Contratos/RepPresupuestos.aspx.vb @@ -30,9 +30,14 @@ Partial Class Contratos_RepPresupuestos #Region " INICIALIZA VALORES " Private Sub InicializaValores() - TxtFiltrosFechaInicio.Text = $"01/08/{NowADS().Year - 1}" - TxtFiltrosFechaFin.Text = $"31/07/{NowADS().Year}" - + If UsuarioActual.Empresa.Funcionalidad(267) = "1" Then 'emp citrícola + TxtFiltrosFechaInicio.Text = $"01/08/{NowADS().Year - 1}" + TxtFiltrosFechaFin.Text = $"31/07/{NowADS().Year}" + Else + TxtFiltrosFechaInicio.Text = NowADS.FirstDayOfMonth.ToShortDateString + TxtFiltrosFechaFin.Text = NowADS.LastDayOfMonth.ToShortDateString + End If + DdlTipoGasto.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa) DdlTipoGasto.DataBind() diff --git a/Contratos/RepPresupuestosDetalle.aspx b/Contratos/RepPresupuestosDetalle.aspx index 35ed80fe3..799be4123 100644 --- a/Contratos/RepPresupuestosDetalle.aspx +++ b/Contratos/RepPresupuestosDetalle.aspx @@ -201,7 +201,7 @@
    Agrupador:
    - +
    @@ -224,7 +224,7 @@ -
    Clasificacion:
    +
    Clasificación:
    @@ -247,7 +247,8 @@ - + + @@ -258,8 +259,9 @@ <%-- - - + + + @@ -297,7 +299,7 @@
    AgrupadorAutorizadoAutorizadoComprometido Ejercido Por Ejercer Pagado
    - + diff --git a/Contratos/RepPresupuestosDetalle.aspx.vb b/Contratos/RepPresupuestosDetalle.aspx.vb index 06966b86a..5788852bb 100644 --- a/Contratos/RepPresupuestosDetalle.aspx.vb +++ b/Contratos/RepPresupuestosDetalle.aspx.vb @@ -87,14 +87,15 @@ Partial Class Contratos_RepPresupuestosDetalle Gpo = IfNull(Request("CveAgrupador"), -1).ToString.ToEntero Dim Mensual = CBool(IfNull(Request("Mensual"), False)) Dim EsProyecto = CBool(IfNull(Request("EsProyecto"), False)) - If Agrupador = 1 Then Agrupador = 2 Else Agrupador = 1 + 'If Agrupador = 1 Then Agrupador = 2 Else Agrupador = 1 DdlAgrupador.SelectedValueExist(Agrupador) - DdlClasificacion.SelectedValueExist(CveClasificacion) - If DdlAgrupador.SelectedValue.ToEntero = 2 Then + DdlClasificacion.SelectedValueExist(CveClasificacion) + + If DdlAgrupador.SelectedValue.ToEntero = 1 Then DdlClasificacion.SelectedValueExist(Gpo) DdlProyecto.SelectedValueExist(CveProyecto) DdlSubProyecto.SelectedValueExist(CveSubProyecto) - ElseIf DdlAgrupador.SelectedValue.ToEntero = 1 Then + ElseIf DdlAgrupador.SelectedValue.ToEntero = 2 Then If Not EsProyecto Then Dim Dr As DataRow = GlobalDTSubProyectos(-1, Gpo)(0) DdlProyecto.SelectedValueExist(Dr("CveProyecto")) @@ -158,20 +159,20 @@ Partial Class Contratos_RepPresupuestosDetalle e.Row.Cells(1).Text = "-" End If If e.Row.DBCampo("Ejercido").ToDecimal = 0 Then - e.Row.Cells(2).Text = "-" - End If - If e.Row.DBCampo("EjercidoPorcentaje").ToDecimal = 0 Then e.Row.Cells(3).Text = "-" End If - If e.Row.DBCampo("PorEjercer").ToDecimal = 0 Then + If e.Row.DBCampo("EjercidoPorcentaje").ToDecimal = 0 Then e.Row.Cells(4).Text = "-" End If - If e.Row.DBCampo("PorEjercerPorcentaje").ToDecimal = 0 Then + If e.Row.DBCampo("PorEjercer").ToDecimal = 0 Then e.Row.Cells(5).Text = "-" End If - If e.Row.DBCampo("Pagado").ToDecimal = 0 Then + If e.Row.DBCampo("PorEjercerPorcentaje").ToDecimal = 0 Then e.Row.Cells(6).Text = "-" End If + If e.Row.DBCampo("Pagado").ToDecimal = 0 Then + e.Row.Cells(7).Text = "-" + End If If e.Row.RowIndex > 0 Then Dim CveAgrupador = e.Row.DBCampo("CveAgrupador").ToEntero Dim EsProyecto = False @@ -185,9 +186,13 @@ Partial Class Contratos_RepPresupuestosDetalle End If EsProyecto = True End If - Dim Css = "Texto" + Dim Css = "Texto" + Dim Liga = $"/Contratos/RepPresupuestosDetalleCompras.aspx?&CveAgrupador={CveAgrupador}&CveClasificacion={e.Row.DBCampo("CveClasificacionFiltro")}&CveConceptoContableNom={e.Row.DBCampo("CveConceptoContableNomFiltro")}&CveProyecto={e.Row.DBCampo("CveProyectoFiltro")}&CveSubProyecto={e.Row.DBCampo("CveSubProyectoFiltro")}&CveTipoGasto={e.Row.DBCampo("CveTipoGastoFiltro")}&Agrupador={e.Row.DBCampo("AgrupadorFiltro")}&Mensual={False}&EsProyecto={EsProyecto}&FechaFin={FechaFin}&FechaInicio={FechaInicio}" e.Row.Cells(0).Text = "" + e.Row.Cells(0).Text + "" + + Dim LigaComprometido = $"/Contratos/RepPresupuestosDetalleCompras.aspx?&CveAgrupador={CveAgrupador}&CveClasificacion={e.Row.DBCampo("CveClasificacionFiltro")}&CveConceptoContableNom={e.Row.DBCampo("CveConceptoContableNomFiltro")}&CveProyecto={e.Row.DBCampo("CveProyectoFiltro")}&CveSubProyecto={e.Row.DBCampo("CveSubProyectoFiltro")}&CveTipoGasto={e.Row.DBCampo("CveTipoGastoFiltro")}&Agrupador={e.Row.DBCampo("AgrupadorFiltro")}&Mensual={False}&EsProyecto={EsProyecto}&FechaFin={FechaFin}&FechaInicio={FechaInicio}&Comprometido=1" + e.Row.Cells(2).Text = "" + e.Row.Cells(2).Text + "" End If End If End Sub diff --git a/Contratos/RepPresupuestosDetalleCompras.aspx b/Contratos/RepPresupuestosDetalleCompras.aspx index a6f50fb94..f251ca390 100644 --- a/Contratos/RepPresupuestosDetalleCompras.aspx +++ b/Contratos/RepPresupuestosDetalleCompras.aspx @@ -219,7 +219,7 @@
    - Fecha de Cirugia: + Fecha de Cirugía:
    @@ -8830,7 +8830,7 @@
    - + @@ -9619,10 +9619,11 @@ TxtImporte.value = FormatoNumero(ImporteRestante, 2); $get('TxtNCImporte').value = FormatoNumero(ToDouble($get('TxtNCImporte').value) + ToDouble(TxtImporte.value), 2); }else { - $get('TxtNCImporte').value = FormatoNumero(ToDouble($get('TxtNCImporte').value) + Importe, 2); + $get('TxtNCImporte').value = FormatoNumero(ToDouble($get('TxtNCImporte').value) + Importe, 2); + TxtImporte.value = FormatoNumero(Importe, 2); } - if (ToDouble(TxtImporte.value) <= 0) { + if (ToDouble(TxtImporte.value.replace(",", "")) <= 0) { Chk.checked = false; } @@ -10773,7 +10774,7 @@ function CalculaPorcentajeNC() { var ImporteReferencia = (($('#C_DdlNCNivelImporte').val() == "1") ? ToDouble($get('TxtTotal').value) : ToDouble($get('TxtSubTotal').value)); //var ImporteReferencia = ToDouble($get('TxtTotal').value); - $get('TxtNCPorcentaje').value = FormatoNumero(ToDouble($get('TxtNCImporte').value * 100.00) / ImporteReferencia,4) ; + $get('TxtNCPorcentaje').value = (ToDouble($get('TxtNCImporte').value * 100.00) / ImporteReferencia).toFixed(4) ; } function CambioTipoMoneda(chk, saldo, txt, tipocambio, CveMoneda) { diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 121b91ca6..b3ccd8f77 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2,9 +2,7 @@ Option Strict On Option Infer On -Imports System.Activities.Expressions Imports System.Data -Imports System.Data.SqlClient Imports System.Diagnostics Imports System.IO Imports System.Net.Http @@ -996,12 +994,20 @@ Partial Class Ventas Private Property CveOSVentaMedica As Integer Get - Return ViewState("CveOSVentaMedica").ToString().ToEntero() + Return IfNull(ViewState("CveOSVentaMedica"), "-1").ToString().ToEntero() End Get Set(value As Integer) ViewState("CveOSVentaMedica") = value End Set End Property + Private Property FolioOSVentaMedica As Integer + Get + Return IfNull(ViewState("FolioOSVentaMedica"), "0").ToString().ToEntero() + End Get + Set(value As Integer) + ViewState("FolioOSVentaMedica") = value + End Set + End Property Private ReadOnly Property SaldoVenta As Decimal Get Return If(IsNothing(ViewState("SaldoVenta")), 0, ViewState("SaldoVenta").ToString().ToDecimal) @@ -2280,6 +2286,15 @@ Partial Class Ventas End Set End Property + Private Property TieneBloqueoPorCreditoVencimiento As Integer + Get + Return IfNull(ViewState("TieneBloqueoPorCreditoVencimiento"), "0", ViewState("TieneBloqueoPorCreditoVencimiento")).ToString().ToEntero() + End Get + Set(value As Integer) + ViewState("TieneBloqueoPorCreditoVencimiento") = value + End Set + End Property + Private Property EsNCDevolucionEfectivo As Boolean Get Return If(IsNothing(ViewState("EsNCDevolucionEfectivo")), False, CType(ViewState("EsNCDevolucionEfectivo"), Boolean)) @@ -2433,6 +2448,8 @@ Partial Class Ventas Me.CveVendedorContrato = -1 Me.CveVendedorEmpresaCRM = -1 Me.EsGarantia = False + Me.TieneBloqueoPorCreditoVencimiento = 0 + Me.ClienteEsDistribuidor = False CveEmpresaCRM = 0 CveAcercamientoCRM = 0 EstatusCliente = False @@ -2699,6 +2716,23 @@ Partial Class Ventas RBLPago.SelectedValue = "2" CargaCliente(CveCliente) End If + + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + 'SI ES COTIZACION CARGAR CLIENTE PUBLICO GENERAL + If Opcion = "Cot" Then + Dim CveClientePG As Integer = -1 + If UsuarioActual.CveEmpresa = 186 Then + CveClientePG = 1151377 + ViewState("CveCliente") = CveClientePG + HdnCveCliente.Value = CveClientePG.ToString() + CargaCliente(CveCliente) + + TrVentasMedicas2.Visible = False + TrVentasMedicas3.Visible = False + End If + End If + End If + End If 'Carga empresa CRM @@ -2846,8 +2880,7 @@ Partial Class Ventas BtnCrearApartirDe.Visible = True If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then BtnCrearApartirDe.Visible = False - If UsuarioActual.TienePermisoProceso(302) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Egs") Then BtnEditar.Visible = True - If UsuarioActual.TienePermisoProceso(302) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ped") Then BtnPermisoEditarRemision.Visible = True + If DdlTipoComprobante.SelectedValue = "Ped" Then BtnPermisoEditarRemision.Text = "Editar Pedido" @@ -3747,7 +3780,7 @@ Partial Class Ventas If ObjPVenta.DtResultados.Rows.Count > 0 Then CveCorte = ObjPVenta.CveCorte Dim FechaICorte As Date = ObjPVenta.FechaInicial.Date '.AddDays(-5) - If (UsuarioActual.Empresa.Funcionalidad(531) = "1" OrElse UsuarioActual.Empresa.Funcionalidad(109) = "1") AndAlso FechaICorte < NowADS().Date Then + If (UsuarioActual.Empresa.Funcionalidad(180) = "1") AndAlso FechaICorte < NowADS().Date Then DebeCerrarCorte = True LblMotivoBloqueo.Text = $"Existe un corte del día {FechaICorte.ToString("dd/MM/yyyy")}. Favor de cerrarlo para iniciar un nuevo corte." Else @@ -4947,1220 +4980,1229 @@ Partial Class Ventas If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then TxtAlfa1.Text = DbRowVenta("Alfa1").ToString End If - End If - End Using - End If - If DbRowVenta IsNot Nothing Then - 'CARGAR PS - GvPS.DataSource = TmpDT - GvPS.DataBind() + 'CARGAR PS + GvPS.DataSource = TmpDT + GvPS.DataBind() - Dim CveCliente As Integer = DbRowVenta("CveCliente").ToString().ToEntero() - HdnCveVenta.Value = CveVenta.ToString() + Dim CveCliente As Integer = DbRowVenta("CveCliente").ToString().ToEntero() + HdnCveVenta.Value = CveVenta.ToString() - Me.EsGarantia = CBool(DbRowVenta("EsGarantia")) - Me.TipoCambioOriginal = DbRowVenta("TipoCambioOriginal").ToString().ToDecimal() + Me.EsGarantia = CBool(DbRowVenta("EsGarantia")) + Me.TipoCambioOriginal = DbRowVenta("TipoCambioOriginal").ToString().ToDecimal() - 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 - End If - - ViewState("CveSubProyectoVenta") = DbRowVenta("CveSubProyecto").ToString().ToEntero() - - If DbRowVenta("CveCondicionEntrega").ToString().ToEntero() > 0 Then - DdlFormaEntrega.SelectedValueExist(DbRowVenta("CveCondicionEntrega").ToString()) - DdlFormaEntrega.Enabled = False - End If - - Me.CveEstatusFacturaPadre = DbRowVenta("CveEstatusFacturaPadre").ToString().ToEntero() - - If UsuarioActual.Empresa.Funcionalidad(705) = "1" Then - Me.CveLineaAdicionalVenta = DbRowVenta("CveLineaAdicional").ToString().ToEntero() - End If - TxtDescripcionVenta.Text = DbRowVenta("DescripcionVenta").ToString() - - 'CargaEncabezado - If Not (CveRemision > 0 Or CveCotizacion > 0) Then - DdlTipoComprobante.SelectedValue = DbRowVenta("TipoDocto").ToString() - - If UsuarioActual.TienePermisoProceso(274) Then - TrAntEspecial.Visible = DdlTipoComprobante.SelectedValue = "Ant" - End If - - If TrAntEspecial.Visible Then - ChkAntEspecial.Enabled = False - ChkAntEspecial.Checked = If(DbRowVenta("AnticipoEspecial").ToString() = "True", True, False) - End If - CargaEstatusFactura(DdlTipoComprobante.SelectedValue) - CveEstatus = DbRowVenta("CveEstatusFactura").ToString().ToEntero() - LbEstatus.Text = DbRowVenta("EstatusFactura").ToString() - ViewState("SaldoVenta") = DbRowVenta("Saldo").ToString() - AplicaCancelarRemision = CBool(DbRowVenta("AplicaCancelarRemision").ToString()) - If AplicaCancelarRemision AndAlso CveEstatus.Contiene(2, 3) AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then DivCanRem.Visible = True - - - If CveEstatus = 5 Then LbCancelarDocumento.Enabled = False - 'If CveEstatus = 20 Then - ' LbCancelarDocumentoManual.Visible = True - 'End If - - - If (Not CveEstatus.Contiene(4, 5, 12, 13, 20, 23) OrElse (CveEstatus = 5 AndAlso DbRowVenta("CveEstatusRefacturacion").ToString().ToEntero() = 4)) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Ant") AndAlso UsuarioActual.TienePermisoProceso(159) Then - Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) - If TienePermiso <> "" Then - LkRefacturacion.Visible = True - If (CveEstatus = 5 AndAlso DbRowVenta("CveEstatusRefacturacion").ToString().ToEntero() = 4) Then - RefacturarCancelada = True - 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 End If - End If - If DbRowVenta("CveVentaRelacionada").ToString().ToEntero() > 0 Then - TrRefacturadaa.Visible = True - HplRefacturadaEn.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", DbRowVenta("CveVentaRelacionada")) - HplRefacturadaEn.Text = DbRowVenta("SerieFolioRelacionada").ToString() - LblAlertRefacInv.Visible = True - End If - - If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev", "Rem", "DPe", "RNC", "Ped", "Cot") AndAlso Not CveEstatus.Contiene(4, 5, 10, 12, 13, 20, 23) Then - If UsuarioActual.TienePermisoProceso(159) Then - Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) - If TienePermiso <> "" Then - LbCancelarDocumento.Visible = True - 'If UsuarioActual.CveEmpresa = 119 And Not UsuarioActual.CveUsuario.Contiene(100, 1703) Then '[IPP] AD y Jesus de JAM - ' 'si es del mes anterior no permita cancelar - ' If Not DdlTipoComprobante.SelectedValue.Contiene("Rem") Then - ' If DbRowVenta("Fecha").ToString().ToDate <= NowADS().AddMonths(-1).LastDayOfMonth Then - ' LbCancelarDocumento.Visible = False - ' End If - ' End If - 'End If - End If + ViewState("CveSubProyectoVenta") = DbRowVenta("CveSubProyecto").ToString().ToEntero() + If DbRowVenta("CveCondicionEntrega").ToString().ToEntero() > 0 Then + DdlFormaEntrega.SelectedValueExist(DbRowVenta("CveCondicionEntrega").ToString()) + DdlFormaEntrega.Enabled = False End If - End If - Dim TipoEstatus As Integer = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {CveEstatus}").ToEntero() + Me.CveEstatusFacturaPadre = DbRowVenta("CveEstatusFacturaPadre").ToString().ToEntero() - If UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") AndAlso DdlTipoComprobante.SelectedValue.Contiene("Cot") Then - If UsuarioActual.TienePermisoProceso(116) Then - LbCancelarDocumento.Visible = True - If TipoEstatus = 2 Then - LbCancelarDocumento.Visible = False - ElseIf TipoEstatus = 5 Then - LbCancelarDocumento.Visible = False - End If + If UsuarioActual.Empresa.Funcionalidad(705) = "1" Then + Me.CveLineaAdicionalVenta = DbRowVenta("CveLineaAdicional").ToString().ToEntero() End If - End If + TxtDescripcionVenta.Text = DbRowVenta("DescripcionVenta").ToString() - If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CBool(DbRowVenta("ServicioDomicilio")) Then - TrServicioDomicilio.Visible = True - End If + 'CargaEncabezado + If Not (CveRemision > 0 Or CveCotizacion > 0) Then + DdlTipoComprobante.SelectedValue = DbRowVenta("TipoDocto").ToString() - If UsuarioActual.TienePermisoProceso(318) Then - If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso String.IsNullOrEmpty(DbRowVenta("FolioFiscal").ToString.Trim) Then HplFolioFiscalModal.Visible = True - End If - - Select Case DbRowVenta("TipoDocto").ToString() - Case "Ing" - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then - HLPagar.Visible = True - HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" - HlCuentaTerminal.Visible = True + If UsuarioActual.TienePermisoProceso(274) Then + TrAntEspecial.Visible = DdlTipoComprobante.SelectedValue = "Ant" End If - TabAuxiliarConta.Visible = UsuarioActual.TienePermisoProceso(306) - Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) - If TienePermiso <> "" Then ' si tiene acceso en el subproyecto - 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) - If UsuarioActual.TienePermisoProceso(264) Then - InicializaAplicaDevolucion(TmpDT) - End If + If TrAntEspecial.Visible Then + ChkAntEspecial.Enabled = False + ChkAntEspecial.Checked = If(DbRowVenta("AnticipoEspecial").ToString() = "True", True, False) End If + CargaEstatusFactura(DdlTipoComprobante.SelectedValue) + CveEstatus = DbRowVenta("CveEstatusFactura").ToString().ToEntero() + LbEstatus.Text = DbRowVenta("EstatusFactura").ToString() + ViewState("SaldoVenta") = DbRowVenta("Saldo").ToString() + AplicaCancelarRemision = CBool(DbRowVenta("AplicaCancelarRemision").ToString()) + If AplicaCancelarRemision AndAlso CveEstatus.Contiene(2, 3) AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then DivCanRem.Visible = True - If UsuarioActual.Empresa.Funcionalidad(163) = "1" Then - TrDescripcionVenta.Visible = True - End If - HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) - Case "Egs" - HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) - HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + If CveEstatus = 5 Then LbCancelarDocumento.Enabled = False + 'If CveEstatus = 20 Then + ' LbCancelarDocumentoManual.Visible = True + 'End If - 'SI NO TIENE INGRESOS RELACIONADOS, SE TOMARA COMO DEVOLUCION DE EFECTIVO - If DtVentasRelacionadas IsNot Nothing AndAlso DtVentasRelacionadas.Rows.Count = 0 Then - EsNCDevolucionEfectivo = True - End If - Case "Rem" - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then - HLPagar.Visible = True - HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" - HlCuentaTerminal.Visible = True - End If - - If UsuarioActual.CveEmpresa = 80 Then - LtlImprimir.Text = String.Format("
  • Imprimir
  • ", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=0", CveVenta))) - End If - DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero() - EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString()) - If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + If (Not CveEstatus.Contiene(4, 5, 12, 13, 20, 23) OrElse (CveEstatus = 5 AndAlso DbRowVenta("CveEstatusRefacturacion").ToString().ToEntero() = 4)) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Ant") AndAlso UsuarioActual.TienePermisoProceso(159) Then Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) - If TienePermiso <> "" Then ' si tiene acceso en el subproyecto - 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) - If UsuarioActual.TienePermisoProceso(264) Then - InicializaAplicaRNCDevolucion(TmpDT) + If TienePermiso <> "" Then + LkRefacturacion.Visible = True + If (CveEstatus = 5 AndAlso DbRowVenta("CveEstatusRefacturacion").ToString().ToEntero() = 4) Then + RefacturarCancelada = True End If End If End If - Case "RNC" - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - If DdlTipoComprobante.Items.FindByValue("RNC") Is Nothing Then - DdlTipoComprobante.Items.Add(New ListItem("Remisión de nota de crédito", "RNC")) - End If - DdlTipoComprobante.SelectedValueExist("RNC") - Case "OP" - TdOrdenPago.Visible = True - DdlOrdenPago.SelectedValue = DbRowVenta("Num3").ToString() - DdlOrdenPago.Enabled = False - Case "Cot" - TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() - TxtFechaVencimientoCotizacion.Text = DbRowVenta("Vigencia").ToString() - PnlImprimir.Visible = True - HLOrdendeCompra.Visible = True - HLOrdendeCompra.NavigateUrl = String.Format("/OC/OC.aspx?Tipo=Req&CveCotizacion={0}", CveVenta) - Dim ObjOS As New ClsOS() - If ObjOS.GetCotizacionOS(CveVenta) Then - If ObjOS.DtResultados.Rows.Count > 0 Then - Dim DbRowOS As DataRow = ObjOS.DtResultados.Rows(0) - ViewState("CveOS") = DbRowOS("CveOS").ToString().ToEntero() - CargaOS(CveOS) - End If - - Else - HLOrdenServicio.Visible = True - HLOrdenServicio.NavigateUrl = String.Format("/OS/OrdenesServicios.aspx?CveCotizacion={0}", CveVenta) - End If - ObjOS.Dispose() - - If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 145) Then PnlImprimir.Visible = True : LnkImprimir.OnClientClick = "javascript:ImprimirCotizacion();return false;" - 'Deshabilitar impresión cuando no esté supervisada - If DbRowVenta("TipoEstatus").ToString().ToEntero() = 2 Or UsuarioActual.Empresa.Funcionalidad(113) = "1" Then - PnlImprimir.Visible = True - Else - HplDownPDF.Visible = False - PnlImprimir.Visible = False + If DbRowVenta("CveVentaRelacionada").ToString().ToEntero() > 0 Then + TrRefacturadaa.Visible = True + HplRefacturadaEn.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", DbRowVenta("CveVentaRelacionada")) + HplRefacturadaEn.Text = DbRowVenta("SerieFolioRelacionada").ToString() + LblAlertRefacInv.Visible = True End If - - 'SI LA AUTORIZACION ES POR SUPERVISOR, BUSCA EL SUPERVISOR QUE TIENE EL VENDEDOR - If UsuarioActual.Empresa.Funcionalidad(135) = "1" Then - 'Reviso cuales son los supervisores - Dim Objeto As New ClsVtaVendedores - - If Objeto.GetVendedores(UsuarioActual.CveEmpresa) Then - Dim DTVendedores As New DataTable - If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then - DTVendedores = Objeto.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor)) - End If - - 'Verifico si es su supervisor asignado - If DTVendedores.Rows.Count > 0 Then - LkCotizacionAutorizar.Visible = True - - If TipoEstatus = 2 Then - LkCotizacionAutorizar.Visible = False - ElseIf TipoEstatus = 5 Then - LkCotizacionAutorizar.Visible = False + If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev", "Rem", "DPe", "RNC", "Ped", "Cot") AndAlso Not CveEstatus.Contiene(4, 5, 10, 12, 13, 20, 23) Then + If UsuarioActual.TienePermisoProceso(159) Then + Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) + If TienePermiso <> "" Then + LbCancelarDocumento.Visible = True + 'If UsuarioActual.CveEmpresa = 119 And Not UsuarioActual.CveUsuario.Contiene(100, 1703) Then '[IPP] AD y Jesus de JAM + ' 'si es del mes anterior no permita cancelar + ' If Not DdlTipoComprobante.SelectedValue.Contiene("Rem") Then + ' If DbRowVenta("Fecha").ToString().ToDate <= NowADS().AddMonths(-1).LastDayOfMonth Then + ' LbCancelarDocumento.Visible = False + ' End If + ' End If + 'End If + 'si utiliza cortes, y cajas, no permitir cancelar de días anteriores + If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso DbRowVenta("Fecha").ToString.ToDate.ToShortDateString.ToDate < Now.ToShortDateString.ToDate Then + LbCancelarDocumento.Visible = False End If End If - DTVendedores.Dispose() + End If - Objeto.Dispose() End If - 'SI LA AUTORIZACION ES POR PERMISO, BUSCA QUE EL USUARIO TENGA EL PERMISO PARA AUTORIZAR - If UsuarioActual.Empresa.Funcionalidad(135) = "2" Then - 'Reviso cuales son los supervisores + Dim TipoEstatus As Integer = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {CveEstatus}").ToEntero() + + If UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") AndAlso DdlTipoComprobante.SelectedValue.Contiene("Cot") Then If UsuarioActual.TienePermisoProceso(116) Then - LkCotizacionAutorizar.Visible = True + LbCancelarDocumento.Visible = True If TipoEstatus = 2 Then - LkCotizacionAutorizar.Visible = False + LbCancelarDocumento.Visible = False ElseIf TipoEstatus = 5 Then - LkCotizacionAutorizar.Visible = False + LbCancelarDocumento.Visible = False End If End If End If - Case "Ant" - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - 'LkNotaCredito.Visible = True - HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) - 'visualizo el saldo de anticipos, para cuando se aplique una Nota de crédito, decida si afecta anticipos o a DSV - LblNCSaldoAnticipo.Visible = True - ChkAplicaNCAnticipo.Visible = True - ChkAplicaNCAnticipo.Checked = True - If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then - HLPagar.Visible = True - HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" - HlCuentaTerminal.Visible = True + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CBool(DbRowVenta("ServicioDomicilio")) Then + TrServicioDomicilio.Visible = True End If - Me.SaldoAnticipo = DbRowVenta("SaldoAnticipo").ToString().ToDecimal - If SaldoAnticipo > 0 Then - InicializaDTAnticiposAmortizacion() - ChkAplicaNCAnticipo.Enabled = False - Else - ChkAplicaNCAnticipo.Enabled = False - ChkAplicaNCAnticipo.Checked = False - End If - 'If DbRowVenta("SaldoAnticipo").ToString().ToDouble <= 0 Then ChkAplicaNCAnticipo.Checked = False : ChkAplicaNCAnticipo.Enabled = False - LblNCSaldoAnticipo.Text = String.Format("Saldo Anticipo: $ {0}", DbRowVenta("SaldoAnticipo").ToString().ToDouble.FormatoNumero) - Case "Dev" - DdlTipoComprobante.Items.Insert(0, New ListItem("Devolucion", "Dev")) - HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) - HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() - 'ViewState("CveDevolucion") = DbRowVenta("CveVentaPadre").ToString().ToEntero() - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - Case "Ped" - DdlTipoComprobante.Items.Insert(0, New ListItem("Pedido", "Ped")) - CvePedido = CveVenta - If UsuarioActual.Empresa.Funcionalidad(595) = "1" Then - If DdlTipoComprobante.Items.FindByValue("PA") Is Nothing Then - BtnGeneraAutorizacion.Visible = If(CveEstatus <> 21, True, False) - End If + + If UsuarioActual.TienePermisoProceso(318) Then + If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso String.IsNullOrEmpty(DbRowVenta("FolioFiscal").ToString.Trim) Then HplFolioFiscalModal.Visible = True End If + Select Case DbRowVenta("TipoDocto").ToString() + Case "Ing" + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then + HLPagar.Visible = True + HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" + HlCuentaTerminal.Visible = True + End If + + TabAuxiliarConta.Visible = UsuarioActual.TienePermisoProceso(306) + Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) + If TienePermiso <> "" Then ' si tiene acceso en el subproyecto + 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) + If UsuarioActual.TienePermisoProceso(264) Then + InicializaAplicaDevolucion(TmpDT) + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(163) = "1" Then + TrDescripcionVenta.Visible = True + End If + + HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) + Case "Egs" + HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) + HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + + 'SI NO TIENE INGRESOS RELACIONADOS, SE TOMARA COMO DEVOLUCION DE EFECTIVO + If DtVentasRelacionadas IsNot Nothing AndAlso DtVentasRelacionadas.Rows.Count = 0 Then + EsNCDevolucionEfectivo = True + End If + + Case "Rem" + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then + HLPagar.Visible = True + HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" + HlCuentaTerminal.Visible = True + End If + + If UsuarioActual.CveEmpresa = 80 Then + LtlImprimir.Text = String.Format("
  • Imprimir
  • ", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=0", CveVenta))) + End If + DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero() + EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString()) + + 'If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + ' Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) + ' If TienePermiso <> "" Then ' si tiene acceso en el subproyecto + ' 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) + ' If UsuarioActual.TienePermisoProceso(264) Then + ' InicializaAplicaRNCDevolucion(TmpDT) + ' End If + ' End If + 'End If + + Case "RNC" + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + If DdlTipoComprobante.Items.FindByValue("RNC") Is Nothing Then + DdlTipoComprobante.Items.Add(New ListItem("Remisión de nota de crédito", "RNC")) + End If + DdlTipoComprobante.SelectedValueExist("RNC") + Case "OP" + TdOrdenPago.Visible = True + DdlOrdenPago.SelectedValue = DbRowVenta("Num3").ToString() + DdlOrdenPago.Enabled = False + Case "Cot" + TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() + TxtFechaVencimientoCotizacion.Text = DbRowVenta("Vigencia").ToString() + PnlImprimir.Visible = True + HLOrdendeCompra.Visible = True + HLOrdendeCompra.NavigateUrl = String.Format("/OC/OC.aspx?Tipo=Req&CveCotizacion={0}", CveVenta) + + Dim ObjOS As New ClsOS() + If ObjOS.GetCotizacionOS(CveVenta) Then + If ObjOS.DtResultados.Rows.Count > 0 Then + Dim DbRowOS As DataRow = ObjOS.DtResultados.Rows(0) + ViewState("CveOS") = DbRowOS("CveOS").ToString().ToEntero() + CargaOS(CveOS) + End If + + Else + HLOrdenServicio.Visible = True + HLOrdenServicio.NavigateUrl = String.Format("/OS/OrdenesServicios.aspx?CveCotizacion={0}", CveVenta) + End If + ObjOS.Dispose() + + If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 145) Then PnlImprimir.Visible = True : LnkImprimir.OnClientClick = "javascript:ImprimirCotizacion();return false;" + 'Deshabilitar impresión cuando no esté supervisada + If DbRowVenta("TipoEstatus").ToString().ToEntero() = 2 Or UsuarioActual.Empresa.Funcionalidad(113) = "1" Then + PnlImprimir.Visible = True + Else + HplDownPDF.Visible = False + PnlImprimir.Visible = False + End If + + + 'SI LA AUTORIZACION ES POR SUPERVISOR, BUSCA EL SUPERVISOR QUE TIENE EL VENDEDOR + If UsuarioActual.Empresa.Funcionalidad(135) = "1" Then + 'Reviso cuales son los supervisores + Dim Objeto As New ClsVtaVendedores + + If Objeto.GetVendedores(UsuarioActual.CveEmpresa) Then + Dim DTVendedores As New DataTable + If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then + DTVendedores = Objeto.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor)) + End If + + 'Verifico si es su supervisor asignado + If DTVendedores.Rows.Count > 0 Then + LkCotizacionAutorizar.Visible = True + + If TipoEstatus = 2 Then + LkCotizacionAutorizar.Visible = False + ElseIf TipoEstatus = 5 Then + LkCotizacionAutorizar.Visible = False + End If + End If + DTVendedores.Dispose() + End If + Objeto.Dispose() + End If + + 'SI LA AUTORIZACION ES POR PERMISO, BUSCA QUE EL USUARIO TENGA EL PERMISO PARA AUTORIZAR + If UsuarioActual.Empresa.Funcionalidad(135) = "2" Then + 'Reviso cuales son los supervisores + If UsuarioActual.TienePermisoProceso(116) Then + LkCotizacionAutorizar.Visible = True + If TipoEstatus = 2 Then + LkCotizacionAutorizar.Visible = False + ElseIf TipoEstatus = 5 Then + LkCotizacionAutorizar.Visible = False + End If + End If + End If + + Case "Ant" + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + 'LkNotaCredito.Visible = True + HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) + 'visualizo el saldo de anticipos, para cuando se aplique una Nota de crédito, decida si afecta anticipos o a DSV + LblNCSaldoAnticipo.Visible = True + ChkAplicaNCAnticipo.Visible = True + ChkAplicaNCAnticipo.Checked = True + If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then + HLPagar.Visible = True + HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" + HlCuentaTerminal.Visible = True + End If + Me.SaldoAnticipo = DbRowVenta("SaldoAnticipo").ToString().ToDecimal + If SaldoAnticipo > 0 Then + InicializaDTAnticiposAmortizacion() + ChkAplicaNCAnticipo.Enabled = False + Else + ChkAplicaNCAnticipo.Enabled = False + ChkAplicaNCAnticipo.Checked = False + End If + 'If DbRowVenta("SaldoAnticipo").ToString().ToDouble <= 0 Then ChkAplicaNCAnticipo.Checked = False : ChkAplicaNCAnticipo.Enabled = False + LblNCSaldoAnticipo.Text = String.Format("Saldo Anticipo: $ {0}", DbRowVenta("SaldoAnticipo").ToString().ToDouble.FormatoNumero) + Case "Dev" + DdlTipoComprobante.Items.Insert(0, New ListItem("Devolucion", "Dev")) + HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) + HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() + 'ViewState("CveDevolucion") = DbRowVenta("CveVentaPadre").ToString().ToEntero() + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + Case "Ped" + DdlTipoComprobante.Items.Insert(0, New ListItem("Pedido", "Ped")) + CvePedido = CveVenta + If UsuarioActual.Empresa.Funcionalidad(595) = "1" Then + If DdlTipoComprobante.Items.FindByValue("PA") Is Nothing Then + BtnGeneraAutorizacion.Visible = If(CveEstatus <> 21, True, False) + End If + End If + 'If UsuarioActual.TienePermisoProceso(199) Then ' BtnGenerarRemision.Visible = If(CveEstatus <> 21, True, False) 'Else ' BtnGenerarRemision.Visible = False 'End If - Case "DPe" - DdlTipoComprobante.Items.Insert(5, New ListItem("Devolución de perdido", "DPe")) - Case "PeC" - DdlTipoComprobante.Items.Insert(5, New ListItem("Pedido de Consignación", "PeC")) - Case "PA" - If UsuarioActual.TienePermisoProceso(199) Then - BtnGenerarRemision.Visible = If(CveEstatus = 16, True, False) - Else - BtnGenerarRemision.Visible = False - End If - CvePedidoA = CveVenta - DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero() - EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString()) - End Select + Case "DPe" + DdlTipoComprobante.Items.Insert(5, New ListItem("Devolución de perdido", "DPe")) + Case "PeC" + DdlTipoComprobante.Items.Insert(5, New ListItem("Pedido de Consignación", "PeC")) + Case "PA" + If UsuarioActual.TienePermisoProceso(199) Then + BtnGenerarRemision.Visible = If(CveEstatus = 16, True, False) + Else + BtnGenerarRemision.Visible = False + End If + CvePedidoA = CveVenta + DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero() + EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString()) + End Select + + DdlTipoComprobante.SelectedValue = DbRowVenta("TipoDocto").ToString() - DdlTipoComprobante.SelectedValue = DbRowVenta("TipoDocto").ToString() - - End If - - If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then - TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() - End If - - DdlTipoRelacionARelacionar.SelectedValueExist(DbRowVenta("CveTipoRelacion").ToString()) - - 'contado 0, credito 1, terminal 2 - If DbRowVenta("CondicionesPago").ToString().ToEntero() = 1 Then - RBLPago.SelectedValue = "1" - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - ElseIf DbRowVenta("CondicionesPago").ToString().ToEntero() = 0 Then - RBLPago.SelectedValue = "2" - RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - Else - DdlCuentasTerminal.SelectedValue = DbRowVenta("CveCuentaTerminal").ToString() - RBLPago.SelectedValue = "3" - RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - End If - - - 'ESCONDE ACCIONES - LnkRemisiones.Visible = False - LnkPedido2SinFacturar.Visible = False - LnkCotizaciones.Visible = False - LnkOCs.Visible = False - UpnTools.Update() - - DivEstatusFac.Visible = True - HdnCveCliente.Value = CveCliente.ToString() - ViewState("CveCliente") = CveCliente - ViewState("CveEmpresaCRM") = DbRowVenta("CveEmpresaCRM").ToString().ToEntero() - ViewState("CveAcercamientoCRM") = DbRowVenta("CveAcercamientoCRM").ToString().ToEntero() - Entrega = DbRowVenta("Entrega").ToString() - Vigencia = DbRowVenta("Vigencia").ToString().ToDate.ToShortDateString - HplSaldoAuxiliar.Text = DbRowVenta("Saldo").ToString().FormatoNumero(2) - If Not HplSaldoAuxiliar.Text.ToDouble > 0 Then - HplSaldoAuxiliar.Visible = False - HplPagado.Visible = True - Dim EsCancelado As Boolean = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {CveEstatus}").ToEntero() = 5 - If EsCancelado Then - HplPagado.Text = "CANCELADO" - End If - If ViewState("CveCotizacion") IsNot Nothing AndAlso ViewState("CveCotizacion").ToString().ToEntero() > 0 AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then - ImgAntiPend.Visible = True - Else - ImgAntiPend.Visible = False - End If - - End If - HdnPagado.Value = DbRowVenta("Pagado").ToString() - TxtTotal.Text = DbRowVenta("Total").ToString().FormatoNumero(2) - HdnVentaSaldo.Value = (SaldoVenta).ToString() - CvePrePoliza = DbRowVenta("CvePrePoliza").ToString().ToEntero() - CveVentaFacturada = DbRowVenta("CveVentaFacturada").ToString().ToEntero() - - CveVentaRelacion = DbRowVenta("CveVentaRelacion").ToString().ToEntero() - ImporteRelacion = DbRowVenta("ImporteRelacion").ToString().ToDouble - - DdlMoneda.SelectedValue = DbRowVenta("CveMoneda").ToString() - CambiaMoneda() - - If DbRowVenta("TipoDocto").ToString() = "Ped" Then - 'CANTIDAD FACTURADA - If TmpDT.SUM("CantidadFacturadaPed2") > 0 Then - GvPS.Columns(7).Visible = True - ThCantidadFacturada.Visible = True - ThCantidadFacturada2.Visible = True - Else - GvPS.Columns(7).Visible = False - ThCantidadFacturada.Visible = False - ThCantidadFacturada2.Visible = False - End If - - ''ACTIVA EDITAR - ''SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA - 'If (UsuarioActual.CveUsuario = DbRowVenta("CveUsuario").ToString().ToEntero() Or UsuarioActual.CveVendedor = DdlVendedor.SelectedValue.ToEntero()) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") - ' BtnPermisoEditarCotizacion.Visible = True - 'End If - - 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR - 'If TmpDT.SUM("CantidadFacturadaPed2") < TmpDT.SUM("Cantidad") Then - ' BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) - ' BtnsFacturar.Visible = True - 'End If - ElseIf DbRowVenta("TipoDocto").ToString() = "Cot" AndAlso CveCotizacion > 0 Then - CveEstatusCotizacion = DbRowVenta("CveEstatusFactura").ToString().ToEntero() - End If - - - If CveEmpresaCRM > 0 And Not CveCliente > 0 Then - CargaEmpresaCRM(CveEmpresaCRM) - Else - CveEmpresaCRM = IIf(CveEmpresaCRM > 0, CveEmpresaCRM, 0).ToString().ToEntero() - CargaCliente(CveCliente, -1) 'Estatus activo, se requiere para cargar una factura en la que el cliente a sido eliminado - End If - - ViewState("CveAlmacenTransitorio") = DbRowVenta("CveAlmacenTraspasoDestino").ToString().ToEntero() - DevolucionAlmacen = DbRowVenta("EsDevolucionVenta").ToString().ToEntero() - - 'sino esta cargada la información del metodo de pago que le corresponde, la recarga para que se le pueda asignar - If DdlMetodoPago33.SelectedValue <> DbRowVenta("CveMetodoPago33").ToString() Then - CargaFormaPago(DbRowVenta("CveMetodoPago33").ToString().ToEntero()) - End If - DdlMetodoPago33.SelectedValueExist(DbRowVenta("CveMetodoPago33").ToString()) - DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString().ToEntero()) - - Me.CveMetodoPago33Venta = DbRowVenta("CveMetodoPago33").ToString().ToEntero() - Me.CveFormaPago33Venta = DbRowVenta("CveFormaPago33").ToString().ToEntero() - Me.CveVendedorVenta = DbRowVenta("CveVendedor").ToString().ToEntero() - - 'SI YA TIENE UN VALOR ASIGNADO SELECCIONA EL GUARDADO - 'If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Me.CveVenta > 0 AndAlso Me.CveVendedorVenta > 0 Then - ' Dim Vendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=1).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Me.CveVendedorVenta)) - ' 'SI NO ENCUENTRA BUSCA EN LOS VENDEDORES DEL PV - ' If String.IsNullOrEmpty(Vendedor) Then - ' Vendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=4).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Me.CveVendedorVenta)) - ' End If - ' DdlVendedor.SelectedValueExistInsert(Me.CveVendedorVenta, Vendedor) - 'End If - - If DdlFormaPago33.SelectedValue <> DbRowVenta("CveFormaPago33").ToString() And DbRowVenta("CveFormaPago33").ToString() <> "" Then - 'sino está seleccionada la asginada la debe de cargar - Dim Nombre As String = GlobalDTVtaFormaPago().FiltroPrimeroValor("FormaPagoSAT", String.Format("CveFormaPago={0}", DbRowVenta("CveFormaPago33"))) - DdlFormaPago33.Items.Add(New ListItem(Nombre, DbRowVenta("CveFormaPago33").ToString())) - DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString().ToEntero()) - End If - - If DbRowVenta("CveUsoCFDI").ToString().ToEntero() > 0 Then - Dim UsoCFDI As String = GlobalDTSATUsosCFDI().FiltroPrimeroValor("UsoCFDIDescripcion", $"CveUsoCFDI={DbRowVenta("CveUsoCFDI").ToString()}") - DdlUsoCFDI.SelectedValueExistInsert(DbRowVenta("CveUsoCFDI").ToString(), UsoCFDI) - End If - - - If UsuarioActual.CveEmpresa = 126 Then CargaOrdenProduccion(2, CveVenta) - - If DbRowVenta("CveTipoRelacion").ToString().ToEntero() > 0 Then - TrTipoRelacion.Visible = True - DdlTiposRelacion.SelectedValueExist(DbRowVenta("CveTipoRelacion").ToString().ToEntero()) - - 'RELACIONAR ANTICIPOS APLICADOS - If DbRowVenta("CveTipoRelacion").ToString().ToEntero() = 7 AndAlso DtAntRelacionados IsNot Nothing AndAlso DtAntRelacionados.Rows.Count > 0 Then - DdlTipoRelacionAnticipo.SelectedValueExist(7) - ListaAnticiposAplicados = New List(Of Modelos.MAnticipoRelacionado)() - For Each RowAnt As DataRow In DtAntRelacionados.Rows - ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = RowAnt("CveVentaRelacionada").ToString().ToEntero(), .FolioFiscal = RowAnt("FolioFiscal").ToString()}) - Next - Else - HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() - End If - End If - - If DbRowVenta("Saldo").ToString().ToDouble < 0.01 Then - If ViewState("CveCotizacion") IsNot Nothing AndAlso ViewState("CveCotizacion").ToString().ToEntero() > 0 AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then - ImgAntiPend.Visible = True - Else - ImgAntiPend.Visible = False - End If - ElseIf Opcion <> "Op" Then - ImgAntiPend.Visible = True - End If - If UsuarioActual.CveRol.Contiene(1, 1155) Then LiLnkGuias.Visible = True - - LiComplementoPago.Visible = True - - - ViewState("FolioFiscal") = DbRowVenta("FolioFiscal").ToString() - - SerieVenta = DbRowVenta("Serie").ToString() - LblSerie.Text = SerieVenta - ViewState("Serie") = DbRowVenta("Serie").ToString() - ViewState("Folio") = DbRowVenta("Folio").ToString().ToEntero() - TxtFolio.Text = DbRowVenta("Folio").ToString() - 'TxtDocto.Text = DbRowVenta("Ref").ToString() - 'TxtNumCtaPago.Text = DbRowVenta("NumeroCuenta").ToString() - LblFolioFiscal.Text = DbRowVenta("FolioFiscal").ToString() - TxtFecha.Text = DbRowVenta("Fecha").ToString() - TxtSubTotal.Text = DbRowVenta("SubTotal").ToString().FormatoNumero(2) - LblDescuentos.Text = DbRowVenta("Descuento").ToString().FormatoNumero(2) - LblAmortizacion.Text = DbRowVenta("Amortizacion").ToString().FormatoNumero(2) - TxtSubTotal2.Text = (TxtSubTotal.Text.Replace(",", "").Trim.Trim.ToDouble - LblDescuentos.Text.Replace(",", "").Trim.Trim.ToDouble - LblAmortizacion.Text.Replace(",", "").Trim.Trim.ToDouble).FormatoNumero(2) - TxtIVA.Text = DbRowVenta("IVA").ToString().FormatoNumero(2) - TxtRetIVA.Text = DbRowVenta("RetIVA").ToString().FormatoNumero(2) - TxtCorreoNotificaciones.Text = DbRowVenta("CorreoNotificacion").ToString() - - If TxtRetIVA.Text.ToDecimal() > 0 Then - TrRetIVA.Style.Add("display", "") - UsuarioActual.Empresa.MostrarRetIVA = True - If DdlTipoRetencion.SelectedValue.ToEntero() > 0 Then - DdlTipoRetencion.Visible = True - End If - If TmpDT IsNot Nothing Then - Dim PorcentajeRetIVA As Decimal = (TmpDT.MAX("PorcentajeRetIVA").ToDecimal() * 100) - LblRetIVA.Text = PorcentajeRetIVA.FormatoNumero(2) - End If - - End If - TxtRetISR.Text = DbRowVenta("RetISR").ToString().FormatoNumero(2) - TxtIEPS.Text = DbRowVenta("IEPS").ToString().FormatoNumero(2) - TrIEPS.Visible = TxtIEPS.Text.ToDouble > 0 - TxtTotal.Text = DbRowVenta("Total").ToString().FormatoNumero(2) - HdnTotalVenta.Value = DbRowVenta("Total").ToString().FormatoNumero(2) - TxtMotivoDescuento.Text = DbRowVenta("MotivoDescuento").ToString() - TxtObsFact.Text = DbRowVenta("Observaciones").ToString() - LblUsuario.Text = DbRowVenta("Nombre").ToString().SubStringADS(30) - LblFechaRegistro.Text = DbRowVenta("FechaIng").ToString().ToDate.ToShortDateString - LblSeTimbro.Text = DbRowVenta("SeTimbro").ToString() - LblMail.Text = DbRowVenta("EnvioMail").ToString() - TxtFechaPago.Text = DbRowVenta("FechaVencimiento").ToString() - TxtFechaVencimientoCotizacion.Text = Vigencia - TxtDet_OrdenCompra.Text = DbRowVenta("Det_OrdenCompra").ToString() - TxtDet_FechaOrdenCompra.Text = DbRowVenta("Det_FechaOrdenCompra").ToString() - HdnIVAOriginal.Value = TxtIVA.Text - TxtPedidoContrato.Text = DbRowVenta("PedidoContrato").ToString() - TxtPedidoContrato.Enabled = False - TxtKilometraje.Text = DbRowVenta("Kilometraje").ToString().PadLeft(6, "0"c) - - - VentaActual = New Venta(UsuarioActual) - VentaActual.CveVenta = CveVenta - VentaActual.Fecha = DbRowVenta("Fecha").ToString.ToDate - VentaActual.CveCliente = DbRowVenta("CveCliente").ToString.ToEntero - VentaActual.CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero - VentaActual.SerieFolio = DbRowVenta("SerieFolio").ToString - VentaActual.ClienteNombre = DbRowVenta("ClienteNombre").ToString - VentaActual.TC = DbRowVenta("TipoCambio").ToString.ToDecimal - VentaActual.Total = DbRowVenta("Total").ToString.ToDecimal - VentaActual.IVA = DbRowVenta("IVA").ToString.ToDecimal - VentaActual.IEPS = DbRowVenta("IEPS").ToString.ToDecimal - VentaActual.RetIVA = DbRowVenta("RetIVA").ToString.ToDecimal - VentaActual.RetISR = DbRowVenta("RetISR").ToString.ToDecimal - - VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal - VentaActual.UsuarioActual = UsuarioActual - VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero - - HdnAmortizacion.Value = LblAmort.Text.ToDouble.ToString() - HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2) - 'DdlAmortizacionConceptos.SelectedValue = DbRowVenta("AnticipoPosicion").ToString() - 'ChkAnticipoEnSubTotal.Checked = DbRowVenta("AnticipoEnSubTotal").ToString() = "True" - DdlTipoAmortizacionAnticipo.SelectedValueExist(DbRowVenta("CveTipoAmortizacionAnticipo")) - DdlTiposRelacion.SelectedValueExist(DbRowVenta("CveTipoRelacion")) - - 'Si es AMORTIZACIÓN ANTICIPO SOBRE FACTURA EN CERO no debe timbrar - If DbRowVenta("CveTipoAmortizacionAnticipo").ToString().ToEntero() = 3 Then - BtnEmitir.Visible = False - End If - - 'HdnAmortizacion.Value = LblAmort.Text.ToDouble.ToString() - 'HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2) - 'DdlAmortizacionConceptos.SelectedValue = DbRowVenta("AnticipoPosicion").ToString() - 'ChkAnticipoEnSubTotal.Checked = DbRowVenta("AnticipoEnSubTotal").ToString() = "True" - - - If DbRowVenta("CveTipoRelacion").ToString().ToEntero() > 0 Then - TrTipoRelacion2.Visible = True - LblTipoRelacion.Text = DbRowVenta("TipoRelacion").ToString() - HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() - End If - - - TxtOrdenCompra.Text = DbRowVenta("OrdenCompra").ToString() - TxtOrdenCompra.Enabled = False - - TxtObsAlmacen.Text = DbRowVenta("ObservacionesAlmacen").ToString() - CvePAC = DbRowVenta("CvePAC").ToString().ToEntero() - - If DbRowVenta("Saldo").ToString().ToDecimal > 0 AndAlso UsuarioActual.TienePermisoProceso(204) AndAlso Not UsuarioActual.CveEmpresa.Contiene(119) Then - TxtFechaSaldarVenta.Text = TxtFecha.Text - CEFechaSaldarVenta.StartDate = TxtFecha.Text.ToDate - HLSaldarVenta.Visible = True - End If - - - If (UsuarioActual.TienePermisoProceso(166) Or UsuarioActual.CveRol = 1) AndAlso (LblFolioFiscal.Text = "" Or LblFolioFiscal.Text = "test") Then - LkEliminarFactura.Visible = True - End If - If (UsuarioActual.CveRol = 1) AndAlso (LblFolioFiscal.Text <> "") Then - LnkUUIDRelacionados.Visible = True - End If - - 'Envio Direccion - If DbRowVenta("CveDireccionEnvio").ToString().ToEntero() > 0 AndAlso DbRowVenta("CveDireccionEnvio").ToString() IsNot Nothing Then - ChkDireccionEnvio.Checked = True - DdlDireccionEnvio.SelectedValueExist(DbRowVenta("CveDireccionEnvio").ToString().ToEntero()) - 'DdlDireccionEnvio_SelectedIndexChanged(DdlDireccionEnvio, EventArgs.Empty) - DdlDireccionEnvio.Enabled = False - ChkDireccionEnvio.Enabled = False - DdlDireccionEnvio.Visible = True - trDireccionEnvio.Visible = True - End If - If UsuarioActual.TienePermisoProceso(333) Then LnkEditarDir.Visible = True - - 'ESTATUS FACTURA - If Not (CveRemision > 0 Or CveCotizacion > 0) Then - CveEstatus = DbRowVenta("CveEstatusFactura").ToString().ToEntero() - End If - - TxtTipoCambio.Text = DbRowVenta("TipoCambio").ToString() - If DbRowVenta("UltimasFluctuaciones").ToString() <> "" Then - LblTCValuacion.Text = String.Format("Ult. Val:{0}", DbRowVenta("UltimasFluctuaciones").ToString()) - LblTCValuacion.Visible = True - End If - - ViewState("SelloCancelacion") = DbRowVenta("SelloCancelacion").ToString() - ViewState("FechaCancelacion") = DbRowVenta("FechaCancelacion").ToString().ToDateTime - TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() - TxtTelefonoGenerico.Text = DbRowVenta("TelefonoGenerico").ToString() - CveVentaPadre = DbRowVenta("CveVentaPadre").ToString().ToEntero() - SerieFolioPadre = DbRowVenta("SerieFolioPadre").ToString() - - If DdlVendedor.SelectedValue.ToEntero() > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then - DdlVendedor.Enabled = False - End If - - 'PERMITIR EDITAR EL VENDEDOR ANTES DE FACTURAR - If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso TmpDT IsNot Nothing AndAlso TmpDT.SUM("CantidadFacturadaCot") = 0) Then - DdlVendedor.Enabled = True - End If - - If CveVentaPadre > 0 Then - If IsNothing(Request("CveDevolucion")) AndAlso IsNumeric(Request("CveDevolucion")) Then - DdlNCFactura.Visible = True - Else - DdlNCFactura.Visible = False - End If - trNCFactura.Visible = True - LblSerieFolioPadre.Visible = True - LblSerieFolioPadre.Text = String.Format("{1}", CveVentaPadre, SerieFolioPadre) - - End If - - If DbRowVenta("CveMedico").ToString.ToEntero > 0 AndAlso DbRowVenta("CveProcedimiento").ToString.ToEntero > 0 Then - TxtFechaEjecucion.Text = DbRowVenta("FechaEjecucion").ToString().ToDateTime.ToString("dd/MM/yyyy HH:mm") - DVMEEFechaEje.Visible = False - Else - TxtFechaEjecucion.Text = DbRowVenta("FechaEjecucion").ToString().ToDateTime.ToString("dd/MM/yyyy") - End If - - 'DdlSucursalEjecucion.SelectedValueExist(DbRowVenta("CveSucursalEjecucion").ToString()) - 'DdlSucursalCobranza.SelectedValueExist(DbRowVenta("CveSucursalCobranza").ToString()) - DdlSucursalCliente.SelectedValueExist(DbRowVenta("CveClienteSucursal").ToString()) - 'DdlSucursal.SelectedValueExist(DbRowVenta("CveSucursal").ToString()) - 'DdlSubProyectoDatos.SelectedValueExist(DbRowVenta("CveSubProyecto").ToString()) - - If DdlSubProyectoDatos.Items.Count = 0 Then - DdlSubProyectoDatos.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - DdlSubProyectoDatos.SelectedValueExistInsert(DbRowVenta("CveSubProyecto").ToString(), DbRowVenta("SubProyecto").ToString()) - DdlSubProyecto.SelectedValueExist(DbRowVenta("CveSubProyecto").ToString()) - - CargarAlmacenes() - - If DdlSubProyectoCobranza.Items.Count = 0 Then - DdlSubProyectoCobranza.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - DdlSubProyectoCobranza.SelectedValueExistInsert(DbRowVenta("CveSubProyectoCobranza").ToString(), GlobalDTSubProyectos(-1, DbRowVenta("CveSubProyectoCobranza").ToString().ToEntero()).FiltroPrimeroValor("SubProyecto").ToString()) - - If DdlSubProyectoEjecucion.Items.Count = 0 Then - DdlSubProyectoEjecucion.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - DdlSubProyectoEjecucion.SelectedValueExistInsert(DbRowVenta("CveSubProyectoEjecucion").ToString(), GlobalDTSubProyectos(-1, DbRowVenta("CveSubProyectoEjecucion").ToString().ToEntero()).FiltroPrimeroValor("SubProyecto").ToString()) - - CargaClienteSucursal(DbRowVenta("CveClienteSucursal").ToString().ToEntero()) - - If DbRowVenta("CveContrato").ToString().ToEntero() > 0 Then - CveContrato = DbRowVenta("CveContrato").ToString().ToEntero() - NumeroContrato = DbRowVenta("NumeroContrato").ToString() - DescripcionContrato = DbRowVenta("DescripcionContrato").ToString() - DdlContrato.Visible = False - HLContrato.Text = $"{DbRowVenta("NumeroContrato")} - {DbRowVenta("DescripcionContrato")}" - HLContrato.NavigateUrl = $"/Contratos/Contrato.aspx?CveContrato={CveContrato}" - 'trPresupuesto.Visible = True - 'HplPresupuesto.NavigateUrl = String.Format(" / Presupuestos / Presupuesto.aspx?CvePresupuesto={0}", DbRowVenta("CveContrato").ToString()) - Else - NumeroContrato = "" - DescripcionContrato = "" - End If - - 'DdlEstatus.Items.Remove(DdlEstatus.Items.FindByText("Cotización")) - - If DbRowVenta("SeTimbro").ToString() <> "No" Then - HplDownXML.Visible = True - 'If HLImprimir.Visible = False Then - HplDownPDF.Visible = True - 'End If - ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" OrElse DdlTipoComprobante.SelectedValue = "Cot" Then - 'If drv("TipoEstatus").ToString().ToEntero() = 2 AndAlso drv("TipoDocto").ToString() = "Cot" Then - ' ImgDownPDF.Visible = True - 'Else - HplDownPDF.Visible = False - 'End If - ElseIf UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso DbRowVenta("SeTimbro").ToString() = "No" AndAlso DbRowVenta("CveEstatusFactura").ToString() = "2" AndAlso DbRowVenta("TipoDocto").ToString().Contiene("Ing", "Egs", "Dev", "Ant") Then - TrEmitir.Visible = True - If TxtFecha.Text.ToDate < NowADS().AddDays(-3) Then - TxtFecha.Enabled = True - End If - End If - - 'NO DEBE IMPRIMIR PDF DE COTIZACION - If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DbRowVenta("TipoDocto").ToString() = "Cot" Then - HplDownPDF.Visible = False - End If - - If DbRowVenta("SeTimbro").ToString() = "Si" Then - TrEmitir.Visible = False - End If - - 'CargaAcuseCancelacion - If DbRowVenta("CveEstatusFactura").ToString().Contiene("5", "20") Then - ImgDownCancelacion.Visible = True - ImgDownCancelacion.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CAN&CVEVTA={0}", CveVenta))) - End If - IdPoliza = DbRowVenta("IdPoliza").ToString().ToEntero() - - 'Carga si es Contabilizada - If IdPoliza > 0 Then - HLContabilizada.Text = "Si" - HLContabilizada.NavigateUrl = $"/Contabilidad/RegPoliza.aspx?IdPoliza={DbRowVenta("IdPoliza")}" - trContabilizada.Visible = True - If UsuarioActual.TienePermisoProceso(107) Then BtnDescontabilizar.Visible = True - - Else - 'cuando no este contabilizada y usa AC, habilita el boton para generar la poliza - If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC AndAlso UsuarioActual.CveRol = 1 Then - BtnGenerarPoliza.Visible = True - End If - If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then - BtnContabilizar.Visible = True - End If - End If - - If DbRowVenta("IdPolizaCancelacion").ToString().ToEntero() > 0 Then - HPLContaCancelacion.Text = "Cancelación" - HPLContaCancelacion.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", DbRowVenta("IdPolizaCancelacion")) - trContabilizada.Visible = True - End If - - - If UsuarioActual.Empresa.UsaOS AndAlso DbRowVenta("CveOS").ToString().ToEntero() = 0 Then - BtnGenerarOS.Visible = True - BtnGenerarOS.OnClientClick = String.Format("javascriptwindow.location.href = '/OS/OrdenesServicios.aspx?CveVenta={0}'; return false;", CveVenta) - ' BtnGenerarOS.OnClientClick = String.Format("/OS/OrdenesServicios.aspx?CveVenta={0}", CveVenta) - End If - - - '[IPP] COMENTADO 12/MARZO/2018 -SABRA QUE SE QUERIA ESCONDER - 'If DbRowVenta("TipoDocto").ToString() = "Rem" Then - ' GvPS.Columns(11).Visible = False - ' GvPS.Columns(12).Visible = False - 'End If - - - 'Ocultamos los botones Clonar y Ordenar - GvPS.Columns(19).Visible = False - GvPS.Columns(20).Visible = False - - GvFirmas.DataSource = DTmpF - GvFirmas.DataBind() - - If TmpDTImpuestos IsNot Nothing AndAlso TmpDTImpuestos.Rows.Count > 0 Then - TrOtros.Visible = True - GvImpuestosLocales2.DataSource = TmpDTImpuestos - GvImpuestosLocales2.DataBind() - - GvImpuestosLocales2.Enabled = False - GvImpuestosLocales2.Visible = True - End If - - DdlVendedor.SelectedValue = If(DbRowVenta("CveVendedor").ToString = "", "0", DbRowVenta("CveVendedor").ToString) 'si viene dbnull, que ponga cero. - DdlTipoComprobante.Enabled = False - 'TxtDocto.Enabled = False - - 'PORLET CLIENTE - 'DESACTIVA CAMBIO DE CLIENTE - HlCliente.Attributes.Remove("class") - HlCliente.Attributes.Add("class", "Texto disabled") - TxtCodigo.ReadOnly = True - ChkEnviarFactura.Enabled = False - ChkDireccionEnvio.Enabled = False - TxtAtencionA.Enabled = False - TxtFechaVencimientoCotizacion.Enabled = False - - TxtCantidad.Enabled = False - DdlClasificacion.Enabled = False - - DdlPS.Enabled = False - TxtObsPS.Enabled = False - DdlProyecto.Enabled = False - DdlSubProyecto.Enabled = False - TxtPrecio.Enabled = False - ImgDescPU.Attributes.Clear() - ImgDescTotal.Attributes.Clear() - ImgDescConcepto.Attributes.Clear() - LbAgregar.Enabled = False - DdlCuentasTerminal.Enabled = False - - For Each Row As GridViewRow In GvPS.Rows - Row.FCLiteral("LtlConsecutivo").Text = (Row.RowIndex + 1).ToString() - Next - GvPS.Columns(ColumnaEditar).HeaderText = "" - GvPS.Columns(ColumnaEliminar).HeaderText = "" - 'GvPS.Columns(ColumnaEliminar).Visible = False - - TxtObsFact.Enabled = False - TxtObsAlmacen.Enabled = False - TxtMotivoDescuento.Enabled = False - 'GvLeyendasFiscales.Enabled = False - TxtSubTotal.ReadOnly = True - TxtIVA.ReadOnly = True - TxtRetIVA.ReadOnly = True - TxtRetISR.ReadOnly = True - TxtIEPS.ReadOnly = True - TxtTotal.ReadOnly = True - - 'Sección Detalle - DdlMoneda.Enabled = False - DdlTipoRetencion.Enabled = False - TxtFechaEjecucion.ReadOnly = True - ImgCalendarFechaEje.Enabled = False - 'DdlSucursalEjecucion.Enabled = False - 'DdlSucursalCobranza.Enabled = False - DdlVendedor.Enabled = False - 'PERMITIR EDITAR EL VENDEDOR ANTES DE FACTURAR - If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso TmpDT IsNot Nothing AndAlso TmpDT.SUM("CantidadFacturadaCot") = 0) Then - DdlVendedor.Enabled = True - End If - DdlSucursalCliente.Enabled = False - TxtTiempoEntrega.Enabled = False - TxtAlfa1.ReadOnly = True - TxtAlfa2.ReadOnly = True - TxtAlfa3.ReadOnly = True - TxtNum1.ReadOnly = True - TxtNum2.ReadOnly = True - TxtNum3.ReadOnly = True - TxtFech1.ReadOnly = True : ImgFech1.Enabled = False - TxtFech2.ReadOnly = True : ImgFech2.Enabled = False - TxtFech3.ReadOnly = True : ImgFech3.Enabled = False - ChkConvertirDoctoPesos.Enabled = False - ChkConvertirDolares.Enabled = False - - TxtTipoCambio.Enabled = UsuarioActual.CveEmpresa.Contiene(13, 83) - TxtTipoCambioDlls.Enabled = UsuarioActual.CveEmpresa.Contiene(13, 83) - TxtTipoCambio.ReadOnly = Not UsuarioActual.CveEmpresa.Contiene(13, 83) - TxtTipoCambioDlls.ReadOnly = Not UsuarioActual.CveEmpresa.Contiene(13, 83) - - 'Condiciones de Pago - RBLPago.Enabled = False - DdlFormaPago33.Enabled = False - DdlUsoCFDI.Enabled = False - DdlMetodoPago33.Enabled = False - 'TxtNumCtaPago.Enabled = False - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") Then - TxtFechaPago.ReadOnly = Not UsuarioActual.TienePermisoProceso(260) - LnkUpdateFechaVencimiento.Visible = UsuarioActual.TienePermisoProceso(260) - Else - TxtFechaPago.ReadOnly = False - End If - - imgCalendario.Enabled = False - DdlFuenteRecaudacion.Enabled = False - - TrVistaPrevia.Visible = False - BtnEmitirImprimir.Visible = False - 'CargaLeyendasFiscales - ViewState("VentaFolio") = If(LblSerie.Text.Trim.Length = 0, TxtFolio.Text.Trim, LblSerie.Text.Trim & "-" & TxtFolio.Text.Trim) - - CalculaTotalesVenta(False) - - 'JJMQ 20160506: Se agrego para la validacion de pago de contado. - 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") - - tdVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot") - tdFechaVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot") - - If DbRowVenta("TipoDocto").ToString() = "Rem" Then - 'CANTIDAD FACTURADA - If TmpDT.SUM("CantidadFacturadaRem") > 0 Then - GvPS.Columns(6).Visible = True - ThCantidadFacturadaRem.Visible = True - ThCantidadFacturadaRem2.Visible = True - Else - GvPS.Columns(6).Visible = False - ThCantidadFacturadaRem.Visible = False - ThCantidadFacturadaRem2.Visible = False - End If - - 'ACTIVA EDITAR - 'SOLO LA PUEDE EDITAR CON PROCESO | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR - If UsuarioActual.TienePermisoProceso(202) And TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad") Then - BtnPermisoEditarRemision.Visible = True - End If - - 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR - If TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad") Then - BtnsFacturar.Visible = True - - 'E119, bloquear la facturación de remisiones que no estén surtidas - If UsuarioActual.CveEmpresa = 119 Then - If TmpDT.SUM("Cantidad") <> TmpDT.SUM("CantidadInventario") Then 'que ya esté surtida totalmente - BtnsFacturar.Visible = False - End If End If - LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274) - 'ACTIVA CONVERSION DE MONEDA - If DdlMoneda.SelectedValue.ToEntero() = 1 Then - TrConversionDolares.Visible = True - ChkConvertirDolares.Enabled = Not UsuarioActual.TienePermisoProceso(324) - TxtTipoCambioDlls.Enabled = True + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() + End If + + DdlTipoRelacionARelacionar.SelectedValueExist(DbRowVenta("CveTipoRelacion").ToString()) + + 'contado 0, credito 1, terminal 2 + If DbRowVenta("CondicionesPago").ToString().ToEntero() = 1 Then + RBLPago.SelectedValue = "1" + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() + ElseIf DbRowVenta("CondicionesPago").ToString().ToEntero() = 0 Then + RBLPago.SelectedValue = "2" + RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() Else - TrConversionTipoCambio.Visible = True - ChkConvertirDoctoPesos.Enabled = Not UsuarioActual.TienePermisoProceso(324) - TxtTipoCambio.Enabled = True + DdlCuentasTerminal.SelectedValue = DbRowVenta("CveCuentaTerminal").ToString() + RBLPago.SelectedValue = "3" + RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() End If - If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then - TrVistaPrevia.Visible = True + + 'ESCONDE ACCIONES + LnkRemisiones.Visible = False + LnkPedido2SinFacturar.Visible = False + LnkCotizaciones.Visible = False + LnkOCs.Visible = False + UpnTools.Update() + + UpEstatus.Visible = True + HdnCveCliente.Value = CveCliente.ToString() + ViewState("CveCliente") = CveCliente + ViewState("CveEmpresaCRM") = DbRowVenta("CveEmpresaCRM").ToString().ToEntero() + ViewState("CveAcercamientoCRM") = DbRowVenta("CveAcercamientoCRM").ToString().ToEntero() + Entrega = DbRowVenta("Entrega").ToString() + Vigencia = DbRowVenta("Vigencia").ToString().ToDate.ToShortDateString + HplSaldoAuxiliar.Text = DbRowVenta("Saldo").ToString().FormatoNumero(2) + If Not HplSaldoAuxiliar.Text.ToDouble > 0 Then + HplSaldoAuxiliar.Visible = False + HplPagado.Visible = True + Dim EsCancelado As Boolean = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {CveEstatus}").ToEntero() = 5 + If EsCancelado Then + HplPagado.Text = "CANCELADO" + End If + If ViewState("CveCotizacion") IsNot Nothing AndAlso ViewState("CveCotizacion").ToString().ToEntero() > 0 AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then + ImgAntiPend.Visible = True + Else + ImgAntiPend.Visible = False + End If + End If - End If + HdnPagado.Value = DbRowVenta("Pagado").ToString() + TxtTotal.Text = DbRowVenta("Total").ToString().FormatoNumero(2) + HdnVentaSaldo.Value = (SaldoVenta).ToString() + CvePrePoliza = DbRowVenta("CvePrePoliza").ToString().ToEntero() + CveVentaFacturada = DbRowVenta("CveVentaFacturada").ToString().ToEntero() - 'Si es Empresa de Acumuladores - If CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DbRowVenta("TipoDocto").ToString() = "Rem" AndAlso (GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() <> 5) Then + CveVentaRelacion = DbRowVenta("CveVentaRelacion").ToString().ToEntero() + ImporteRelacion = DbRowVenta("ImporteRelacion").ToString().ToDouble - BtnsFacturar.Visible = False + DdlMoneda.SelectedValue = DbRowVenta("CveMoneda").ToString() + CambiaMoneda() - Dim DtUsadosPendientes As DataTable = Nothing - Dim DtGarantiasPendientes As DataTable = Nothing + If DbRowVenta("TipoDocto").ToString() = "Ped" Then + 'CANTIDAD FACTURADA + If TmpDT.SUM("CantidadFacturadaPed2") > 0 Then + GvPS.Columns(7).Visible = True + ThCantidadFacturada.Visible = True + ThCantidadFacturada2.Visible = True + Else + GvPS.Columns(7).Visible = False + ThCantidadFacturada.Visible = False + ThCantidadFacturada2.Visible = False + End If - Dim ObjUsados As New ClsVentas + ''ACTIVA EDITAR + ''SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA + 'If (UsuarioActual.CveUsuario = DbRowVenta("CveUsuario").ToString().ToEntero() Or UsuarioActual.CveVendedor = DdlVendedor.SelectedValue.ToEntero()) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") + ' BtnPermisoEditarCotizacion.Visible = True + 'End If - If ObjUsados.GetVentasUsados(CveVenta, -1, DbRowVenta("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then - DtUsadosPendientes = ObjUsados.DtResultados.Copy() + 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + 'If TmpDT.SUM("CantidadFacturadaPed2") < TmpDT.SUM("Cantidad") Then + ' BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) + ' BtnsFacturar.Visible = True + 'End If + ElseIf DbRowVenta("TipoDocto").ToString() = "Cot" AndAlso CveCotizacion > 0 Then + CveEstatusCotizacion = DbRowVenta("CveEstatusFactura").ToString().ToEntero() End If - If ObjUsados.GetVentasGarantiaPendiente(CveVenta, NowADS(), UsuarioActual.CveEmpresa) Then - DtGarantiasPendientes = ObjUsados.DtResultados.Copy() + + If CveEmpresaCRM > 0 And Not CveCliente > 0 Then + CargaEmpresaCRM(CveEmpresaCRM) + Else + CveEmpresaCRM = IIf(CveEmpresaCRM > 0, CveEmpresaCRM, 0).ToString().ToEntero() + CargaCliente(CveCliente, -1) 'Estatus activo, se requiere para cargar una factura en la que el cliente a sido eliminado End If - 'If ObjUsados.GetVentasGarantiaPendiente(CveVenta, -1, NowADS(), UsuarioActual.CveEmpresa) Then - ' DtGarantiasPendientes = ObjUsados.DtResultados.Copy() + ViewState("CveAlmacenTransitorio") = DbRowVenta("CveAlmacenTraspasoDestino").ToString().ToEntero() + DevolucionAlmacen = DbRowVenta("EsDevolucionVenta").ToString().ToEntero() + + 'sino esta cargada la información del metodo de pago que le corresponde, la recarga para que se le pueda asignar + If DdlMetodoPago33.SelectedValue <> DbRowVenta("CveMetodoPago33").ToString() Then + CargaFormaPago(DbRowVenta("CveMetodoPago33").ToString().ToEntero()) + End If + DdlMetodoPago33.SelectedValueExist(DbRowVenta("CveMetodoPago33").ToString()) + DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString().ToEntero()) + + Me.CveMetodoPago33Venta = DbRowVenta("CveMetodoPago33").ToString().ToEntero() + Me.CveFormaPago33Venta = DbRowVenta("CveFormaPago33").ToString().ToEntero() + Me.CveVendedorVenta = DbRowVenta("CveVendedor").ToString().ToEntero() + + 'SI YA TIENE UN VALOR ASIGNADO SELECCIONA EL GUARDADO + 'If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Me.CveVenta > 0 AndAlso Me.CveVendedorVenta > 0 Then + ' Dim Vendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=1).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Me.CveVendedorVenta)) + ' 'SI NO ENCUENTRA BUSCA EN LOS VENDEDORES DEL PV + ' If String.IsNullOrEmpty(Vendedor) Then + ' Vendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=4).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Me.CveVendedorVenta)) + ' End If + ' DdlVendedor.SelectedValueExistInsert(Me.CveVendedorVenta, Vendedor) 'End If - ObjUsados.Dispose() - - BtnsFacturar.Visible = True - - 'VERIFICA SI YA SE FACTURO COMPLETAMENTE - If TmpDT.SUM("CantidadFacturadaRem") = TmpDT.SUM("Cantidad") Then - BtnsFacturar.Visible = False + If DdlFormaPago33.SelectedValue <> DbRowVenta("CveFormaPago33").ToString() And DbRowVenta("CveFormaPago33").ToString() <> "" Then + 'sino está seleccionada la asginada la debe de cargar + Dim Nombre As String = GlobalDTVtaFormaPago().FiltroPrimeroValor("FormaPagoSAT", String.Format("CveFormaPago={0}", DbRowVenta("CveFormaPago33"))) + DdlFormaPago33.Items.Add(New ListItem(Nombre, DbRowVenta("CveFormaPago33").ToString())) + DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString().ToEntero()) End If - 'VERIFICA SI TIENE USADOS O GARANTIAS PENDIENTES - If BtnsFacturar.Visible Then - If (Not EsGarantia AndAlso (DtUsadosPendientes IsNot Nothing AndAlso DtUsadosPendientes.Rows.Count > 0)) Then - BtnsFacturar.Visible = False - Alert("Tiene usados pendiente de recibir", TipoMensaje.MsgAdvertencia) - End If + If DbRowVenta("CveUsoCFDI").ToString().ToEntero() > 0 Then + Dim UsoCFDI As String = GlobalDTSATUsosCFDI().FiltroPrimeroValor("UsoCFDIDescripcion", $"CveUsoCFDI={DbRowVenta("CveUsoCFDI").ToString()}") + DdlUsoCFDI.SelectedValueExistInsert(DbRowVenta("CveUsoCFDI").ToString(), UsoCFDI) + End If - If (EsGarantia AndAlso (DtGarantiasPendientes IsNot Nothing AndAlso DtGarantiasPendientes.Rows.Count > 0)) Then - Alert("Tiene garantías pendientes de recibir", TipoMensaje.MsgAdvertencia) - BtnsFacturar.Visible = False + + If UsuarioActual.CveEmpresa = 126 Then CargaOrdenProduccion(2, CveVenta) + + If DbRowVenta("CveTipoRelacion").ToString().ToEntero() > 0 Then + TrTipoRelacion.Visible = True + DdlTiposRelacion.SelectedValueExist(DbRowVenta("CveTipoRelacion").ToString().ToEntero()) + + 'RELACIONAR ANTICIPOS APLICADOS + If DbRowVenta("CveTipoRelacion").ToString().ToEntero() = 7 AndAlso DtAntRelacionados IsNot Nothing AndAlso DtAntRelacionados.Rows.Count > 0 Then + DdlTipoRelacionAnticipo.SelectedValueExist(7) + ListaAnticiposAplicados = New List(Of Modelos.MAnticipoRelacionado)() + For Each RowAnt As DataRow In DtAntRelacionados.Rows + ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = RowAnt("CveVentaRelacionada").ToString().ToEntero(), .FolioFiscal = RowAnt("FolioFiscal").ToString()}) + Next + Else + HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() End If End If - - LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274) - End If - - 'SI ES COMPLEMENTARIA, NO DEBE PERMITIR FACTURAR - If UsuarioActual.Empresa.Funcionalidad(706) = "1" AndAlso DbRowVenta("TipoContable").ToString() <> "-1" Then - If DbRowVenta("TipoContable").ToString() = "0" Then - BtnsFacturar.Visible = False - End If - - TrTipoContable.Visible = True - DdlTipoContable.SelectedValueExist(DbRowVenta("TipoContable").ToString()) - DdlTipoContable.Enabled = False - End If - - End If - - If DbRowVenta("TipoDocto").ToString().Contiene("Cot") Then - 'CANTIDAD FACTURADA - If TmpDT.SUM("CantidadFacturadaCot") > 0 Then - GvPS.Columns(7).Visible = True - ThCantidadFacturada.Visible = True - ThCantidadFacturada2.Visible = True - Else - GvPS.Columns(7).Visible = False - ThCantidadFacturada.Visible = False - ThCantidadFacturada2.Visible = False - End If - - 'ACTIVA EDITAR - 'SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA - If (UsuarioActual.CveUsuario = DbRowVenta("CveUsuario").ToString().ToEntero() Or UsuarioActual.CveVendedor = DdlVendedor.SelectedValue.ToEntero()) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") - BtnPermisoEditarCotizacion.Visible = True - End If - - 'SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA - If UsuarioActual.TienePermisoProceso(281) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") - BtnPermisoEditarCotizacion.Visible = True - End If - - 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR - VerificarBtnFacturarCotizacion(DbRowVenta("CveVendedor").ToString().ToEntero()) - End If - - - If DbRowVenta("TipoDocto").ToString().Contiene("Ped") Then - 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR - If TmpDT.SUM("CantidadFacturadaPed2") < TmpDT.SUM("Cantidad") Then - BtnsFacturar.Visible = True - - 'bloquear la facturación de remisiones que no estén surtidas - If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then - If TmpDT.SUM("Cantidad") <> TmpDT.SUM("CantidadInventario") Then 'que ya esté surtida totalmente - BtnsFacturar.Visible = False + If DbRowVenta("Saldo").ToString().ToDouble < 0.01 Then + If ViewState("CveCotizacion") IsNot Nothing AndAlso ViewState("CveCotizacion").ToString().ToEntero() > 0 AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then + ImgAntiPend.Visible = True + Else + ImgAntiPend.Visible = False End If + ElseIf Opcion <> "Op" Then + ImgAntiPend.Visible = True + End If + If UsuarioActual.CveRol.Contiene(1, 1155) Then LiLnkGuias.Visible = True + + LiComplementoPago.Visible = True + + + ViewState("FolioFiscal") = DbRowVenta("FolioFiscal").ToString() + + SerieVenta = DbRowVenta("Serie").ToString() + LblSerie.Text = SerieVenta + ViewState("Serie") = DbRowVenta("Serie").ToString() + ViewState("Folio") = DbRowVenta("Folio").ToString().ToEntero() + TxtFolio.Text = DbRowVenta("Folio").ToString() + 'TxtDocto.Text = DbRowVenta("Ref").ToString() + 'TxtNumCtaPago.Text = DbRowVenta("NumeroCuenta").ToString() + LblFolioFiscal.Text = DbRowVenta("FolioFiscal").ToString() + TxtFecha.Text = DbRowVenta("Fecha").ToString() + TxtSubTotal.Text = DbRowVenta("SubTotal").ToString().FormatoNumero(2) + LblDescuentos.Text = DbRowVenta("Descuento").ToString().FormatoNumero(2) + LblAmortizacion.Text = DbRowVenta("Amortizacion").ToString().FormatoNumero(2) + TxtSubTotal2.Text = (TxtSubTotal.Text.Replace(",", "").Trim.Trim.ToDouble - LblDescuentos.Text.Replace(",", "").Trim.Trim.ToDouble - LblAmortizacion.Text.Replace(",", "").Trim.Trim.ToDouble).FormatoNumero(2) + TxtIVA.Text = DbRowVenta("IVA").ToString().FormatoNumero(2) + TxtRetIVA.Text = DbRowVenta("RetIVA").ToString().FormatoNumero(2) + TxtCorreoNotificaciones.Text = DbRowVenta("CorreoNotificacion").ToString() + + If TxtRetIVA.Text.ToDecimal() > 0 Then + TrRetIVA.Style.Add("display", "") + UsuarioActual.Empresa.MostrarRetIVA = True + If DdlTipoRetencion.SelectedValue.ToEntero() > 0 Then + DdlTipoRetencion.Visible = True + End If + If TmpDT IsNot Nothing Then + Dim PorcentajeRetIVA As Decimal = (TmpDT.MAX("PorcentajeRetIVA").ToDecimal() * 100) + LblRetIVA.Text = PorcentajeRetIVA.FormatoNumero(2) + End If + + End If + TxtRetISR.Text = DbRowVenta("RetISR").ToString().FormatoNumero(2) + TxtIEPS.Text = DbRowVenta("IEPS").ToString().FormatoNumero(2) + TrIEPS.Visible = TxtIEPS.Text.ToDouble > 0 + TxtTotal.Text = DbRowVenta("Total").ToString().FormatoNumero(2) + HdnTotalVenta.Value = DbRowVenta("Total").ToString().FormatoNumero(2) + TxtMotivoDescuento.Text = DbRowVenta("MotivoDescuento").ToString() + TxtObsFact.Text = DbRowVenta("Observaciones").ToString() + LblUsuario.Text = DbRowVenta("Nombre").ToString().SubStringADS(30) + LblFechaRegistro.Text = DbRowVenta("FechaIng").ToString().ToDate.ToShortDateString + LblSeTimbro.Text = DbRowVenta("SeTimbro").ToString() + LblMail.Text = DbRowVenta("EnvioMail").ToString() + TxtFechaPago.Text = DbRowVenta("FechaVencimiento").ToString() + TxtFechaVencimientoCotizacion.Text = Vigencia + TxtDet_OrdenCompra.Text = DbRowVenta("Det_OrdenCompra").ToString() + TxtDet_FechaOrdenCompra.Text = DbRowVenta("Det_FechaOrdenCompra").ToString() + HdnIVAOriginal.Value = TxtIVA.Text + TxtPedidoContrato.Text = DbRowVenta("PedidoContrato").ToString() + TxtPedidoContrato.Enabled = False + TxtKilometraje.Text = DbRowVenta("Kilometraje").ToString().PadLeft(6, "0"c) + + + VentaActual = New Venta(UsuarioActual) + VentaActual.CveVenta = CveVenta + VentaActual.Fecha = DbRowVenta("Fecha").ToString.ToDate + VentaActual.CveCliente = DbRowVenta("CveCliente").ToString.ToEntero + VentaActual.CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero + VentaActual.SerieFolio = DbRowVenta("SerieFolio").ToString + VentaActual.ClienteNombre = DbRowVenta("ClienteNombre").ToString + VentaActual.TC = DbRowVenta("TipoCambio").ToString.ToDecimal + VentaActual.Total = DbRowVenta("Total").ToString.ToDecimal + VentaActual.IVA = DbRowVenta("IVA").ToString.ToDecimal + VentaActual.IEPS = DbRowVenta("IEPS").ToString.ToDecimal + VentaActual.RetIVA = DbRowVenta("RetIVA").ToString.ToDecimal + VentaActual.RetISR = DbRowVenta("RetISR").ToString.ToDecimal + + VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal + VentaActual.UsuarioActual = UsuarioActual + VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero + + HdnAmortizacion.Value = LblAmort.Text.ToDouble.ToString() + HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2) + 'DdlAmortizacionConceptos.SelectedValue = DbRowVenta("AnticipoPosicion").ToString() + 'ChkAnticipoEnSubTotal.Checked = DbRowVenta("AnticipoEnSubTotal").ToString() = "True" + DdlTipoAmortizacionAnticipo.SelectedValueExist(DbRowVenta("CveTipoAmortizacionAnticipo")) + DdlTiposRelacion.SelectedValueExist(DbRowVenta("CveTipoRelacion")) + + 'Si es AMORTIZACIÓN ANTICIPO SOBRE FACTURA EN CERO no debe timbrar + If DbRowVenta("CveTipoAmortizacionAnticipo").ToString().ToEntero() = 3 Then + BtnEmitir.Visible = False End If - LBFacturarAnticipo.Visible = False + 'HdnAmortizacion.Value = LblAmort.Text.ToDouble.ToString() + 'HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2) + 'DdlAmortizacionConceptos.SelectedValue = DbRowVenta("AnticipoPosicion").ToString() + 'ChkAnticipoEnSubTotal.Checked = DbRowVenta("AnticipoEnSubTotal").ToString() = "True" - 'ACTIVA CONVERSION DE MONEDA - If DdlMoneda.SelectedValue.ToEntero() = 1 Then - TrConversionDolares.Visible = True - ChkConvertirDolares.Enabled = Not UsuarioActual.TienePermisoProceso(324) - TxtTipoCambioDlls.Enabled = True + + If DbRowVenta("CveTipoRelacion").ToString().ToEntero() > 0 Then + TrTipoRelacion2.Visible = True + LblTipoRelacion.Text = DbRowVenta("TipoRelacion").ToString() + HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() + End If + + + TxtOrdenCompra.Text = DbRowVenta("OrdenCompra").ToString() + TxtOrdenCompra.Enabled = False + + TxtObsAlmacen.Text = DbRowVenta("ObservacionesAlmacen").ToString() + CvePAC = DbRowVenta("CvePAC").ToString().ToEntero() + + If DbRowVenta("Saldo").ToString().ToDecimal > 0 AndAlso UsuarioActual.TienePermisoProceso(204) AndAlso Not UsuarioActual.CveEmpresa.Contiene(119) Then + TxtFechaSaldarVenta.Text = TxtFecha.Text + CEFechaSaldarVenta.StartDate = TxtFecha.Text.ToDate + HLSaldarVenta.Visible = True + End If + + + If (UsuarioActual.TienePermisoProceso(166) Or UsuarioActual.CveRol = 1) AndAlso (LblFolioFiscal.Text = "" Or LblFolioFiscal.Text = "test") Then + LkEliminarFactura.Visible = True + End If + If (UsuarioActual.CveRol = 1) AndAlso (LblFolioFiscal.Text <> "") Then + LnkUUIDRelacionados.Visible = True + End If + + 'Envio Direccion + If DbRowVenta("CveDireccionEnvio").ToString().ToEntero() > 0 AndAlso DbRowVenta("CveDireccionEnvio").ToString() IsNot Nothing Then + ChkDireccionEnvio.Checked = True + DdlDireccionEnvio.SelectedValueExist(DbRowVenta("CveDireccionEnvio").ToString().ToEntero()) + 'DdlDireccionEnvio_SelectedIndexChanged(DdlDireccionEnvio, EventArgs.Empty) + DdlDireccionEnvio.Enabled = False + ChkDireccionEnvio.Enabled = False + DdlDireccionEnvio.Visible = True + trDireccionEnvio.Visible = True + End If + If UsuarioActual.TienePermisoProceso(333) Then LnkEditarDir.Visible = True + + 'ESTATUS FACTURA + If Not (CveRemision > 0 Or CveCotizacion > 0) Then + CveEstatus = DbRowVenta("CveEstatusFactura").ToString().ToEntero() + End If + + TxtTipoCambio.Text = DbRowVenta("TipoCambio").ToString() + If DbRowVenta("UltimasFluctuaciones").ToString() <> "" Then + LblTCValuacion.Text = String.Format("Ult. Val:{0}", DbRowVenta("UltimasFluctuaciones").ToString()) + LblTCValuacion.Visible = True + End If + + ViewState("SelloCancelacion") = DbRowVenta("SelloCancelacion").ToString() + ViewState("FechaCancelacion") = DbRowVenta("FechaCancelacion").ToString().ToDateTime + TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() + TxtTelefonoGenerico.Text = DbRowVenta("TelefonoGenerico").ToString() + CveVentaPadre = DbRowVenta("CveVentaPadre").ToString().ToEntero() + SerieFolioPadre = DbRowVenta("SerieFolioPadre").ToString() + + If DdlVendedor.SelectedValue.ToEntero() > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then + DdlVendedor.Enabled = False + End If + + 'PERMITIR EDITAR EL VENDEDOR ANTES DE FACTURAR + If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso TmpDT IsNot Nothing AndAlso TmpDT.SUM("CantidadFacturadaCot") = 0) Then + DdlVendedor.Enabled = True + End If + + If CveVentaPadre > 0 Then + If IsNothing(Request("CveDevolucion")) AndAlso IsNumeric(Request("CveDevolucion")) Then + DdlNCFactura.Visible = True + Else + DdlNCFactura.Visible = False + End If + trNCFactura.Visible = True + LblSerieFolioPadre.Visible = True + LblSerieFolioPadre.Text = String.Format("{1}", CveVentaPadre, SerieFolioPadre) + + End If + + If DbRowVenta("CveMedico").ToString.ToEntero > 0 AndAlso DbRowVenta("CveProcedimiento").ToString.ToEntero > 0 Then + TxtFechaEjecucion.Text = DbRowVenta("FechaEjecucion").ToString().ToDateTime.ToString("dd/MM/yyyy HH:mm") + DVMEEFechaEje.Visible = False Else - TrConversionTipoCambio.Visible = True - ChkConvertirDoctoPesos.Enabled = Not UsuarioActual.TienePermisoProceso(324) - TxtTipoCambio.Enabled = True + TxtFechaEjecucion.Text = DbRowVenta("FechaEjecucion").ToString().ToDateTime.ToString("dd/MM/yyyy") End If - End If - End If - If UsuarioActual.Empresa.Funcionalidad(280) = "1" Then - RblPaqueteria.SelectedValue = If(DbRowVenta("FormaPaqueteria").ToString = "", "1", DbRowVenta("FormaPaqueteria").ToString) - RblPaqueteria.Enabled = False - End If + 'DdlSucursalEjecucion.SelectedValueExist(DbRowVenta("CveSucursalEjecucion").ToString()) + 'DdlSucursalCobranza.SelectedValueExist(DbRowVenta("CveSucursalCobranza").ToString()) + DdlSucursalCliente.SelectedValueExist(DbRowVenta("CveClienteSucursal").ToString()) + 'DdlSucursal.SelectedValueExist(DbRowVenta("CveSucursal").ToString()) + 'DdlSubProyectoDatos.SelectedValueExist(DbRowVenta("CveSubProyecto").ToString()) - If UsuarioActual.CveEmpresa = 48 Then - TxtFecha.AutoPostBack = True - End If + If DdlSubProyectoDatos.Items.Count = 0 Then + DdlSubProyectoDatos.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + DdlSubProyectoDatos.SelectedValueExistInsert(DbRowVenta("CveSubProyecto").ToString(), DbRowVenta("SubProyecto").ToString()) + DdlSubProyecto.SelectedValueExist(DbRowVenta("CveSubProyecto").ToString()) - CargaCodigoUnico() + CargarAlmacenes() - DdlTipoRetencion.SelectedValueExist(DbRowVenta("CveTipoRetencion").ToString()) + If DdlSubProyectoCobranza.Items.Count = 0 Then + DdlSubProyectoCobranza.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + DdlSubProyectoCobranza.SelectedValueExistInsert(DbRowVenta("CveSubProyectoCobranza").ToString(), GlobalDTSubProyectos(-1, DbRowVenta("CveSubProyectoCobranza").ToString().ToEntero()).FiltroPrimeroValor("SubProyecto").ToString()) - Me.FacturarSucursal = CBool(DbRowVenta("FacturarSucursal").ToString()) + If DdlSubProyectoEjecucion.Items.Count = 0 Then + DdlSubProyectoEjecucion.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + DdlSubProyectoEjecucion.SelectedValueExistInsert(DbRowVenta("CveSubProyectoEjecucion").ToString(), GlobalDTSubProyectos(-1, DbRowVenta("CveSubProyectoEjecucion").ToString().ToEntero()).FiltroPrimeroValor("SubProyecto").ToString()) - If Me.FacturarSucursal Then - HabilitarFacturacionSucursal() - End If + CargaClienteSucursal(DbRowVenta("CveClienteSucursal").ToString().ToEntero()) - CargaPS(-1, DdlPS) + If DbRowVenta("CveContrato").ToString().ToEntero() > 0 Then + CveContrato = DbRowVenta("CveContrato").ToString().ToEntero() + NumeroContrato = DbRowVenta("NumeroContrato").ToString() + DescripcionContrato = DbRowVenta("DescripcionContrato").ToString() + DdlContrato.Visible = False + HLContrato.Text = $"{DbRowVenta("NumeroContrato")} - {DbRowVenta("DescripcionContrato")}" + HLContrato.NavigateUrl = $"/Contratos/Contrato.aspx?CveContrato={CveContrato}" + 'trPresupuesto.Visible = True + 'HplPresupuesto.NavigateUrl = String.Format(" / Presupuestos / Presupuesto.aspx?CvePresupuesto={0}", DbRowVenta("CveContrato").ToString()) + Else + NumeroContrato = "" + DescripcionContrato = "" + End If - 'Verifico si tiene la funcionalidad (135) - If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then + 'DdlEstatus.Items.Remove(DdlEstatus.Items.FindByText("Cotización")) - Select Case UsuarioActual.Empresa.Funcionalidad(135) - Case "1" ' POR SUPERVISOR - Dim ObjVendedores As New ClsVtaVendedores + If DbRowVenta("SeTimbro").ToString() <> "No" Then + HplDownXML.Visible = True + 'If HLImprimir.Visible = False Then + HplDownPDF.Visible = True + 'End If + ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" OrElse DdlTipoComprobante.SelectedValue = "Cot" Then + 'If drv("TipoEstatus").ToString().ToEntero() = 2 AndAlso drv("TipoDocto").ToString() = "Cot" Then + ' ImgDownPDF.Visible = True + 'Else + HplDownPDF.Visible = False + 'End If + ElseIf UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso DbRowVenta("SeTimbro").ToString() = "No" AndAlso DbRowVenta("CveEstatusFactura").ToString() = "2" AndAlso DbRowVenta("TipoDocto").ToString().Contiene("Ing", "Egs", "Dev", "Ant") Then + TrEmitir.Visible = True + If TxtFecha.Text.ToDate < NowADS().AddDays(-3) Then + TxtFecha.Enabled = True + End If + End If - If ObjVendedores.GetVendedores(UsuarioActual.CveEmpresa) Then - Dim DTVendedores As New DataTable - If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then - DTVendedores = ObjVendedores.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor)) + 'NO DEBE IMPRIMIR PDF DE COTIZACION + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DbRowVenta("TipoDocto").ToString() = "Cot" Then + HplDownPDF.Visible = False + End If + + If DbRowVenta("SeTimbro").ToString() = "Si" Then + TrEmitir.Visible = False + End If + + 'CargaAcuseCancelacion + If DbRowVenta("CveEstatusFactura").ToString().Contiene("5", "20") Then + ImgDownCancelacion.Visible = True + ImgDownCancelacion.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CAN&CVEVTA={0}", CveVenta))) + End If + IdPoliza = DbRowVenta("IdPoliza").ToString().ToEntero() + + 'Carga si es Contabilizada + If IdPoliza > 0 Then + HLContabilizada.Text = "Si" + HLContabilizada.NavigateUrl = $"/Contabilidad/RegPoliza.aspx?IdPoliza={DbRowVenta("IdPoliza")}" + trContabilizada.Visible = True + If UsuarioActual.TienePermisoProceso(107) Then BtnDescontabilizar.Visible = True + + Else + 'cuando no este contabilizada y usa AC, habilita el boton para generar la poliza + If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC AndAlso UsuarioActual.CveRol = 1 Then + BtnGenerarPoliza.Visible = True + End If + If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + BtnContabilizar.Visible = True + End If + End If + + If DbRowVenta("IdPolizaCancelacion").ToString().ToEntero() > 0 Then + HPLContaCancelacion.Text = "Cancelación" + HPLContaCancelacion.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", DbRowVenta("IdPolizaCancelacion")) + trContabilizada.Visible = True + End If + + + If UsuarioActual.Empresa.UsaOS AndAlso DbRowVenta("CveOS").ToString().ToEntero() = 0 Then + BtnGenerarOS.Visible = True + BtnGenerarOS.OnClientClick = String.Format("javascriptwindow.location.href = '/OS/OrdenesServicios.aspx?CveVenta={0}'; return false;", CveVenta) + ' BtnGenerarOS.OnClientClick = String.Format("/OS/OrdenesServicios.aspx?CveVenta={0}", CveVenta) + End If + + + '[IPP] COMENTADO 12/MARZO/2018 -SABRA QUE SE QUERIA ESCONDER + 'If DbRowVenta("TipoDocto").ToString() = "Rem" Then + ' GvPS.Columns(11).Visible = False + ' GvPS.Columns(12).Visible = False + 'End If + + + 'Ocultamos los botones Clonar y Ordenar + GvPS.Columns(19).Visible = False + GvPS.Columns(20).Visible = False + + GvFirmas.DataSource = DTmpF + GvFirmas.DataBind() + + If TmpDTImpuestos IsNot Nothing AndAlso TmpDTImpuestos.Rows.Count > 0 Then + TrOtros.Visible = True + GvImpuestosLocales2.DataSource = TmpDTImpuestos + GvImpuestosLocales2.DataBind() + + GvImpuestosLocales2.Enabled = False + GvImpuestosLocales2.Visible = True + End If + + DdlVendedor.SelectedValue = If(DbRowVenta("CveVendedor").ToString = "", "0", DbRowVenta("CveVendedor").ToString) 'si viene dbnull, que ponga cero. + DdlTipoComprobante.Enabled = False + 'TxtDocto.Enabled = False + + 'PORLET CLIENTE + 'DESACTIVA CAMBIO DE CLIENTE + HlCliente.Attributes.Remove("class") + HlCliente.Attributes.Add("class", "Texto disabled") + TxtCodigo.ReadOnly = True + ChkEnviarFactura.Enabled = False + ChkDireccionEnvio.Enabled = False + TxtAtencionA.Enabled = False + TxtFechaVencimientoCotizacion.Enabled = False + + TxtCantidad.Enabled = False + DdlClasificacion.Enabled = False + + DdlPS.Enabled = False + TxtObsPS.Enabled = False + DdlProyecto.Enabled = False + DdlSubProyecto.Enabled = False + TxtPrecio.Enabled = False + ImgDescPU.Attributes.Clear() + ImgDescTotal.Attributes.Clear() + ImgDescConcepto.Attributes.Clear() + LbAgregar.Enabled = False + DdlCuentasTerminal.Enabled = False + + For Each Row As GridViewRow In GvPS.Rows + Row.FCLiteral("LtlConsecutivo").Text = (Row.RowIndex + 1).ToString() + Next + GvPS.Columns(ColumnaEditar).HeaderText = "" + GvPS.Columns(ColumnaEliminar).HeaderText = "" + 'GvPS.Columns(ColumnaEliminar).Visible = False + + TxtObsFact.Enabled = False + TxtObsAlmacen.Enabled = False + TxtMotivoDescuento.Enabled = False + 'GvLeyendasFiscales.Enabled = False + TxtSubTotal.ReadOnly = True + TxtIVA.ReadOnly = True + TxtRetIVA.ReadOnly = True + TxtRetISR.ReadOnly = True + TxtIEPS.ReadOnly = True + TxtTotal.ReadOnly = True + + 'Sección Detalle + DdlMoneda.Enabled = False + DdlTipoRetencion.Enabled = False + TxtFechaEjecucion.ReadOnly = True + ImgCalendarFechaEje.Enabled = False + 'DdlSucursalEjecucion.Enabled = False + 'DdlSucursalCobranza.Enabled = False + DdlVendedor.Enabled = False + 'PERMITIR EDITAR EL VENDEDOR ANTES DE FACTURAR + If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso TmpDT IsNot Nothing AndAlso TmpDT.SUM("CantidadFacturadaCot") = 0) Then + DdlVendedor.Enabled = True + End If + DdlSucursalCliente.Enabled = False + TxtTiempoEntrega.Enabled = False + TxtAlfa1.ReadOnly = True + TxtAlfa2.ReadOnly = True + TxtAlfa3.ReadOnly = True + TxtNum1.ReadOnly = True + TxtNum2.ReadOnly = True + TxtNum3.ReadOnly = True + TxtFech1.ReadOnly = True : ImgFech1.Enabled = False + TxtFech2.ReadOnly = True : ImgFech2.Enabled = False + TxtFech3.ReadOnly = True : ImgFech3.Enabled = False + ChkConvertirDoctoPesos.Enabled = False + ChkConvertirDolares.Enabled = False + + TxtTipoCambio.Enabled = UsuarioActual.CveEmpresa.Contiene(13, 83) + TxtTipoCambioDlls.Enabled = UsuarioActual.CveEmpresa.Contiene(13, 83) + TxtTipoCambio.ReadOnly = Not UsuarioActual.CveEmpresa.Contiene(13, 83) + TxtTipoCambioDlls.ReadOnly = Not UsuarioActual.CveEmpresa.Contiene(13, 83) + + 'Condiciones de Pago + RBLPago.Enabled = False + DdlFormaPago33.Enabled = False + DdlUsoCFDI.Enabled = False + DdlMetodoPago33.Enabled = False + 'TxtNumCtaPago.Enabled = False + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") Then + TxtFechaPago.ReadOnly = Not UsuarioActual.TienePermisoProceso(260) + LnkUpdateFechaVencimiento.Visible = UsuarioActual.TienePermisoProceso(260) + Else + TxtFechaPago.ReadOnly = False + End If + + imgCalendario.Enabled = False + DdlFuenteRecaudacion.Enabled = False + + TrVistaPrevia.Visible = False + BtnEmitirImprimir.Visible = False + 'CargaLeyendasFiscales + ViewState("VentaFolio") = If(LblSerie.Text.Trim.Length = 0, TxtFolio.Text.Trim, LblSerie.Text.Trim & "-" & TxtFolio.Text.Trim) + + CalculaTotalesVenta(False) + + 'JJMQ 20160506: Se agrego para la validacion de pago de contado. + 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") + + tdVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot") + tdFechaVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot") + + If DbRowVenta("TipoDocto").ToString() = "Rem" Then + 'CANTIDAD FACTURADA + If TmpDT.SUM("CantidadFacturadaRem") > 0 Then + GvPS.Columns(6).Visible = True + ThCantidadFacturadaRem.Visible = True + ThCantidadFacturadaRem2.Visible = True + Else + GvPS.Columns(6).Visible = False + ThCantidadFacturadaRem.Visible = False + ThCantidadFacturadaRem2.Visible = False + End If + + 'ACTIVA EDITAR + 'SOLO LA PUEDE EDITAR CON PROCESO | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + If UsuarioActual.TienePermisoProceso(202) And TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad") Then + BtnPermisoEditarRemision.Visible = True + End If + + + 'si es de FNC contado. bloquear edición si está pagada o en proceso de cobro + If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (DbRowVenta("CveCobranzaEstatus").ToString = "1" OrElse DbRowVenta("Saldo").ToString.ToDecimal = 0) Then + BtnPermisoEditarRemision.Visible = False + End If + + 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + If (TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad")) AndAlso TieneBloqueoPorCreditoVencimiento = 0 Then + BtnsFacturar.Visible = True + + 'E119, bloquear la facturación de remisiones que no estén surtidas + If UsuarioActual.CveEmpresa = 119 Then + If TmpDT.SUM("Cantidad") <> TmpDT.SUM("CantidadInventario") Then 'que ya esté surtida totalmente + BtnsFacturar.Visible = False + End If + End If + LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274) + + 'ACTIVA CONVERSION DE MONEDA + If DdlMoneda.SelectedValue.ToEntero() = 1 Then + TrConversionDolares.Visible = True + ChkConvertirDolares.Enabled = Not UsuarioActual.TienePermisoProceso(324) + TxtTipoCambioDlls.Enabled = True + Else + TrConversionTipoCambio.Visible = True + ChkConvertirDoctoPesos.Enabled = Not UsuarioActual.TienePermisoProceso(324) + TxtTipoCambio.Enabled = True End If - 'Verifico si es su supervisor asignado - If DTVendedores.Rows.Count > 0 Then + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + TrVistaPrevia.Visible = True + End If + End If + + 'Si es Empresa de Acumuladores + If CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DbRowVenta("TipoDocto").ToString() = "Rem" AndAlso (GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() <> 5) Then + + If TieneBloqueoPorCreditoVencimiento = 0 Then + BtnsFacturar.Visible = False + + Dim DtUsadosPendientes As DataTable = Nothing + Dim DtGarantiasPendientes As DataTable = Nothing + + Dim ObjUsados As New ClsVentas + + If ObjUsados.GetVentasUsados(CveVenta, -1, DbRowVenta("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then + DtUsadosPendientes = ObjUsados.DtResultados.Copy() + End If + + If ObjUsados.GetVentasGarantiaPendiente(CveVenta, NowADS(), UsuarioActual.CveEmpresa) Then + DtGarantiasPendientes = ObjUsados.DtResultados.Copy() + End If + + 'If ObjUsados.GetVentasGarantiaPendiente(CveVenta, -1, NowADS(), UsuarioActual.CveEmpresa) Then + ' DtGarantiasPendientes = ObjUsados.DtResultados.Copy() + 'End If + + ObjUsados.Dispose() + + BtnsFacturar.Visible = True + + 'VERIFICA SI YA SE FACTURO COMPLETAMENTE + If TmpDT.SUM("CantidadFacturadaRem") = TmpDT.SUM("Cantidad") Then + BtnsFacturar.Visible = False + End If + + 'VERIFICA SI TIENE USADOS O GARANTIAS PENDIENTES + If BtnsFacturar.Visible Then + If (Not EsGarantia AndAlso (DtUsadosPendientes IsNot Nothing AndAlso DtUsadosPendientes.Rows.Count > 0)) Then + BtnsFacturar.Visible = False + Alert("Tiene usados pendiente de recibir", TipoMensaje.MsgAdvertencia) + End If + + If (EsGarantia AndAlso (DtGarantiasPendientes IsNot Nothing AndAlso DtGarantiasPendientes.Rows.Count > 0)) Then + Alert("Tiene garantías pendientes de recibir", TipoMensaje.MsgAdvertencia) + BtnsFacturar.Visible = False + End If + End If + + LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274) + End If + + End If + + 'SI ES COMPLEMENTARIA, NO DEBE PERMITIR FACTURAR + If UsuarioActual.Empresa.Funcionalidad(706) = "1" AndAlso DbRowVenta("TipoContable").ToString() <> "-1" Then + If DbRowVenta("TipoContable").ToString() = "0" Then + BtnsFacturar.Visible = False + End If + + TrTipoContable.Visible = True + DdlTipoContable.SelectedValueExist(DbRowVenta("TipoContable").ToString()) + DdlTipoContable.Enabled = False + End If + + End If + + If DbRowVenta("TipoDocto").ToString().Contiene("Cot") Then + 'CANTIDAD FACTURADA + If TmpDT.SUM("CantidadFacturadaCot") > 0 Then + GvPS.Columns(7).Visible = True + ThCantidadFacturada.Visible = True + ThCantidadFacturada2.Visible = True + Else + GvPS.Columns(7).Visible = False + ThCantidadFacturada.Visible = False + ThCantidadFacturada2.Visible = False + End If + + 'ACTIVA EDITAR + 'SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA + If (UsuarioActual.CveUsuario = DbRowVenta("CveUsuario").ToString().ToEntero() Or UsuarioActual.CveVendedor = DdlVendedor.SelectedValue.ToEntero()) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") + BtnPermisoEditarCotizacion.Visible = True + End If + + 'SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA + If UsuarioActual.TienePermisoProceso(281) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") + BtnPermisoEditarCotizacion.Visible = True + End If + + 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + VerificarBtnFacturarCotizacion(DbRowVenta("CveVendedor").ToString().ToEntero()) + End If + + If DbRowVenta("TipoDocto").ToString().Contiene("Ped") Then + 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + If TmpDT.SUM("CantidadFacturadaPed2") < TmpDT.SUM("Cantidad") Then + BtnsFacturar.Visible = True + + 'bloquear la facturación de remisiones que no estén surtidas + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + If TmpDT.SUM("Cantidad") <> TmpDT.SUM("CantidadInventario") Then 'que ya esté surtida totalmente + BtnsFacturar.Visible = False + End If + End If + + LBFacturarAnticipo.Visible = False + + 'ACTIVA CONVERSION DE MONEDA + If DdlMoneda.SelectedValue.ToEntero() = 1 Then + TrConversionDolares.Visible = True + ChkConvertirDolares.Enabled = Not UsuarioActual.TienePermisoProceso(324) + TxtTipoCambioDlls.Enabled = True + Else + TrConversionTipoCambio.Visible = True + ChkConvertirDoctoPesos.Enabled = Not UsuarioActual.TienePermisoProceso(324) + TxtTipoCambio.Enabled = True + End If + End If + End If + + If UsuarioActual.TienePermisoProceso(302) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ped") Then BtnPermisoEditarRemision.Visible = True + If UsuarioActual.TienePermisoProceso(302) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Egs") Then BtnEditar.Visible = True + + If UsuarioActual.Empresa.Funcionalidad(280) = "1" Then + RblPaqueteria.SelectedValue = If(DbRowVenta("FormaPaqueteria").ToString = "", "1", DbRowVenta("FormaPaqueteria").ToString) + RblPaqueteria.Enabled = False + End If + + If UsuarioActual.CveEmpresa = 48 Then + TxtFecha.AutoPostBack = True + End If + + CargaCodigoUnico() + + DdlTipoRetencion.SelectedValueExist(DbRowVenta("CveTipoRetencion").ToString()) + + Me.FacturarSucursal = CBool(DbRowVenta("FacturarSucursal").ToString()) + + If Me.FacturarSucursal Then + HabilitarFacturacionSucursal() + End If + + CargaPS(-1, DdlPS) + + 'Verifico si tiene la funcionalidad (135) + If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") AndAlso TieneBloqueoPorCreditoVencimiento = 0 Then + + Select Case UsuarioActual.Empresa.Funcionalidad(135) + Case "1" ' POR SUPERVISOR + Dim ObjVendedores As New ClsVtaVendedores + + If ObjVendedores.GetVendedores(UsuarioActual.CveEmpresa) Then + Dim DTVendedores As New DataTable + If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then + DTVendedores = ObjVendedores.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor)) + End If + + 'Verifico si es su supervisor asignado + If DTVendedores.Rows.Count > 0 Then + If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then + BtnsFacturar.Visible = True + BtnGenerarRemision.Visible = True + Else + BtnsFacturar.Visible = False + BtnGenerarRemision.Visible = False + End If + End If + + DTVendedores.Dispose() + End If + ObjVendedores.Dispose() + + Case "2" ' POR PERMISO If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then - BtnsFacturar.Visible = True - BtnGenerarRemision.Visible = True + BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) + If UsuarioActual.TienePermisoProceso(199) Then + BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) + Else + BtnGenerarRemision.Visible = False + End If Else BtnsFacturar.Visible = False BtnGenerarRemision.Visible = False End If - End If - DTVendedores.Dispose() - End If - ObjVendedores.Dispose() + End Select - Case "2" ' POR PERMISO - If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then - BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) - If UsuarioActual.TienePermisoProceso(199) Then - BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) - Else - BtnGenerarRemision.Visible = False - End If - Else + + End If + + If DdlTipoComprobante.SelectedValue = "Cot" Then + If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 5 Then BtnsFacturar.Visible = False BtnGenerarRemision.Visible = False End If - - End Select - - - End If - - If DdlTipoComprobante.SelectedValue = "Cot" Then - If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 5 Then - BtnsFacturar.Visible = False - BtnGenerarRemision.Visible = False - End If - End If - - If DdlTipoComprobante.SelectedValue = "Rem" Then - If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 5 Then - BtnsFacturar.Visible = False - BtnEmitirImprimir.Visible = False - BtnPermisoEditarRemision.Visible = False - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(705) = "1" AndAlso Me.CveLineaAdicionalVenta > 0 Then - CalculaLineasAdicionales() - End If - - UpPS.Update() - UpContado.Update() - UpEstatus.Update() - Retorno = True - - If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then - - CveTipoVenta = If(DbRowVenta("CveTipoVenta").ToString.ToEntero > 0, DbRowVenta("CveTipoVenta").ToString.ToEntero, -1) - - TrVentasMedicas3.Visible = True - - If DbRowVenta("CveMedico").ToString.ToEntero > 0 AndAlso CveTipoVenta.Contiene(1, 2, 3, 5) Then - TrVentasMedicas1.Visible = True - - DdlMedico.SelectedValueExist(DbRowVenta("CveMedico").ToString) - DdlProcedimiento.SelectedValueExist(DbRowVenta("CveProcedimiento").ToString) - TxtPaciente.Text = DbRowVenta("Paciente").ToString - TxtEpisodio.Text = DbRowVenta("Episodio").ToString - - DdlMedico.Enabled = False - DdlProcedimiento.Enabled = False - TxtPaciente.Enabled = False - TxtEpisodio.Enabled = False - - - If DbRowVenta("FechaParaSurtir").ToString().ToDate() > DateTime.MinValue Then - TrVentasMedicas2.Visible = True - ChkRequiereTecnico.Enabled = False - TxtFechaOS.Enabled = False - - TxtFechaOS.Text = DbRowVenta("FechaParaSurtir").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm").Replace(" ", "T") End If + If DdlTipoComprobante.SelectedValue = "Rem" Then + If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 5 Then + BtnsFacturar.Visible = False + BtnEmitirImprimir.Visible = False + BtnPermisoEditarRemision.Visible = False + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(705) = "1" AndAlso Me.CveLineaAdicionalVenta > 0 Then + CalculaLineasAdicionales() + End If + + UpPS.Update() + UpContado.Update() + UpEstatus.Update() + Retorno = True + + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + + CveTipoVenta = If(DbRowVenta("CveTipoVenta").ToString.ToEntero > 0, DbRowVenta("CveTipoVenta").ToString.ToEntero, -1) + + TrVentasMedicas3.Visible = True + + If DbRowVenta("CveMedico").ToString.ToEntero > 0 AndAlso CveTipoVenta.Contiene(1, 2, 3, 5) Then + TrVentasMedicas1.Visible = True + + DdlMedico.SelectedValueExist(DbRowVenta("CveMedico").ToString) + DdlProcedimiento.SelectedValueExist(DbRowVenta("CveProcedimiento").ToString) + TxtPaciente.Text = DbRowVenta("Paciente").ToString + TxtEpisodio.Text = DbRowVenta("Episodio").ToString + + DdlMedico.Enabled = False + DdlProcedimiento.Enabled = False + TxtPaciente.Enabled = False + TxtEpisodio.Enabled = False + + + If DbRowVenta("FechaParaSurtir").ToString().ToDate() > DateTime.MinValue Then + TrVentasMedicas2.Visible = True + ChkRequiereTecnico.Enabled = False + TxtFechaOS.Enabled = False + + TxtFechaOS.Text = DbRowVenta("FechaParaSurtir").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm").Replace(" ", "T") + End If + End If + + If DdlTipoDocto.SelectedValue.Contiene("Ing", "Rem") Then + TrVentasMedicas4.Visible = True + TxtFolioRemision.Text = DbRowVenta("Alfa1").ToString + End If + End If End If - - - If DdlTipoDocto.SelectedValue.Contiene("Ing", "Rem") Then - TrVentasMedicas4.Visible = True - TxtFolioRemision.Text = DbRowVenta("Alfa1").ToString - End If - - - End If - + End Using End If + Return Retorno End Function Private Sub VerificarBtnFacturarCotizacion(CveVendedor As Integer, Optional MostrarGenerarRemision As Boolean = True) - If TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") AndAlso DdlTipoComprobante.SelectedValue.Contiene("Cot") Then + If TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") AndAlso DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso TieneBloqueoPorCreditoVencimiento = 0 Then If UsuarioActual.TienePermisoProceso(199) Then BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) Else BtnGenerarRemision.Visible = False End If - If UsuarioActual.TienePermisoProceso(60) Then BtnsFacturar.Visible = True 'puede facturar If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso UsuarioActual.TienePermisoProceso(60) Then @@ -6185,7 +6227,6 @@ Partial Class Ventas Else BtnGenerarRemision.Visible = False End If - Else BtnsFacturar.Visible = False BtnGenerarRemision.Visible = False @@ -6700,7 +6741,7 @@ Partial Class Ventas Me.PermiteCredito = ObjCliente.PermiteCredito LnkAgregarCliente.Visible = False - If UsuarioActual.Empresa.Funcionalidad(714) = "1" Then 'cuando inicia cargado con el cliente. publico general + If UsuarioActual.Empresa.Funcionalidad(714) <> "" Then 'cuando inicia cargado con el cliente. publico general LnkAgregarCliente.Visible = True End If @@ -7488,7 +7529,7 @@ Partial Class Ventas Dim ValorAutorizacion As String = UsuarioActual.Empresa.Funcionalidad(595) 'OBLIGAR PAGO DE CONTADO SI EL CLIENTE NO PERMITE CREDITO - If (Not UsuarioActual.Empresa.Funcionalidad(702).Contiene("1", "2")) AndAlso Me.PermiteCredito = False AndAlso ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") AndAlso CveVenta < 1) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso EsCreaApartirDe) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) Then + If (Not UsuarioActual.Empresa.Funcionalidad(702).Contiene("1")) AndAlso Me.PermiteCredito = False AndAlso ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") AndAlso CveVenta < 1) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso EsCreaApartirDe) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) Then RBLPago.SelectedValue = "2" RBLPago.Items(0).Enabled = False RBLPago_SelectedIndexChanged(Nothing, Nothing) @@ -7520,6 +7561,11 @@ Partial Class Ventas 'CARGAR CREDITO DISPONIBLE AL GENERAR UNA FACTURA End If + ''SI NO PERMITE CREDITO, SUGIERE CONTADO + 'If (UsuarioActual.Empresa.Funcionalidad(702).Contiene("1")) AndAlso Not PermiteCredito AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso (CveVenta <= 0 OrElse EsCreaApartirDe)) Then + ' RBLPago.SelectedValue = "2" + 'End If + If ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso CveVenta <= 0) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso CveVenta > 0)) AndAlso RBLPago.SelectedValue = "1" AndAlso PermiteCredito Then 'FUNCIONALIDAD 702 - NO VERIFICAR LIMITE DE CRÉDITO Y CANDADOS DE VENTA If Not UsuarioActual.Empresa.Funcionalidad(702) = "1" Then @@ -7562,7 +7608,7 @@ Partial Class Ventas If Not EsCreaApartirDe AndAlso (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then DdlTipoComprobante.SelectedValueExist("Cot") Else - If UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then + If UsuarioActual.Empresa.Funcionalidad(595) = "1" Then DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") DdlTipoComprobante.SelectedValue = "PA" @@ -7583,19 +7629,18 @@ Partial Class Ventas DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) End If + Dim Bloqueo As Boolean = False - 'SI ES AUTORIZACION DEBE PERMITIR GENERARLA - If (Not DdlTipoComprobante.SelectedValue.Contiene("PA")) AndAlso UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then - BtnEmitirImprimir.Visible = False - BtnsFacturar.Visible = False - LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274) - BtnGenerarRemision.Visible = False - LnkPedido2SinFacturar.Visible = False - LnkCotizaciones.Visible = False - LnkOCs.Visible = False + If Not DdlTipoComprobante.SelectedValue.Contiene("PA") AndAlso UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then + Bloqueo = True End If - If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + 'SI EL CLIENTE ES DISTRIBUIDOR Y TIENE FACTURAS VENCIDAS, DEBE BLOQUEAR + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso ClienteEsDistribuidor AndAlso Opcion.Contiene(2, 3) Then + Bloqueo = True + End If + + If Bloqueo AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" Then Dim Autorizacion As Integer = 0 Dim ObjVentas As New ClsVentas @@ -7616,10 +7661,30 @@ Partial Class Ventas 'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO If Autorizacion > 0 Then - BtnsFacturar.Visible = True + Bloqueo = False + TieneBloqueoPorCreditoVencimiento = 0 + Alert("El cliente tiene una autorización aprobada") End If End If + 'SI ES AUTORIZACION DEBE PERMITIR GENERARLA + If Bloqueo Then + If DdlTipoComprobante.SelectedValue <> "Cot" Then + BtnEmitirImprimir.Visible = False + End If + BtnsFacturar.Visible = False + LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274) + BtnGenerarRemision.Visible = False + LnkPedido2SinFacturar.Visible = False + LnkCotizaciones.Visible = False + LnkOCs.Visible = False + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + TieneBloqueoPorCreditoVencimiento = 1 + End If + + End If + Else ' el cliente tiene crédito disponible, no tiene bloqueo @@ -7660,6 +7725,7 @@ Partial Class Ventas 'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO If Autorizacion > 0 Then BtnsFacturar.Visible = True + TieneBloqueoPorCreditoVencimiento = 0 End If End If @@ -7730,6 +7796,10 @@ Partial Class Ventas BtnsFacturar.Visible = False BtnGenerarRemision.Visible = False Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso ClienteEsDistribuidor AndAlso Opcion.Contiene(2, 3) Then + TieneBloqueoPorCreditoVencimiento = 1 + End If End If End If End If @@ -7745,45 +7815,62 @@ Partial Class Ventas End If ObjVentas.Dispose() Case Else 'SI NO TIENE NINGUN TIPO DE AUTORIZACION CONFIGURADO - 'RMF. codigo temporal para pruebas - If Alertas AndAlso UsuarioActual.CveEmpresa = 140 Then + 'VERIFICAR CANDADOS DE VENTA + If DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0 Then Dim Vta As New ClsVentas Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

    {0}", Vta.SerieVenta) Vta.Dispose() If Opcion > 0 Then - LnkSolicitarCredito.Visible = True + BtnsFacturar.Visible = False + BtnGenerarRemision.Visible = False Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso ClienteEsDistribuidor AndAlso Opcion.Contiene(2, 3) Then + TieneBloqueoPorCreditoVencimiento = 1 + End If End If + End If + + If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then + RBLPago.SelectedValue = "2" + RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() Else - 'VERIFICAR CANDADOS DE VENTA - If DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0 Then - Dim Vta As New ClsVentas - Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) - Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

    {0}", Vta.SerieVenta) - Vta.Dispose() - If Opcion > 0 Then - BtnsFacturar.Visible = False - BtnGenerarRemision.Visible = False - Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) + 'este codigo no es temporal + If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia) + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + LnkSolicitarCredito.Visible = True + DdlTipoAutorizacion.SelectedValueExist("1") + + If Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "PA") Then + Dim Autorizacion As Integer = 0 + + Dim ObjVentas As New ClsVentas + If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero, "Ing", CveEstatus:=1) Then + Dim RowAutorizacion As DataRow = Nothing + 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO + If TieneDiasVencidos Then + RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC") + Else + RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC") + End If + + If RowAutorizacion IsNot Nothing Then + Autorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero() + End If + End If + ObjVentas.Dispose() + + 'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO + If Autorizacion <= 0 Then + BtnEmitirImprimir.Visible = False + TieneBloqueoPorCreditoVencimiento = 1 + End If + End If End If - - If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then - RBLPago.SelectedValue = "2" - RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - Else - 'este codigo no es temporal - If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia) - If UsuarioActual.CveEmpresa = 140 Then - LnkSolicitarCredito.Visible = True - DdlTipoAutorizacion.SelectedValueExist("1") - End If - End If - - End If End Select @@ -7794,49 +7881,104 @@ Partial Class Ventas 'VERIFICAR RESTRICCIONES DEL CLIENTE If Not UsuarioActual.Empresa.Funcionalidad(702).ToEntero() > 0 Then - If (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0 AndAlso RBLPago.SelectedValue = "2") Then - Dim Valida As Boolean = True - If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (Me.CveCliente = UsuarioActual.Empresa.Funcionalidad(714).ToEntero() OrElse Me.PermiteCredito) Then - Valida = False + + Dim ValidaRemision As Boolean = False + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + ValidaRemision = True + End If + + Dim ValidaCondicionesCredito As Boolean = False + + 'SI ES UNA VENTA EXISTENTE + If CveVenta > 0 Then + If (DdlTipoComprobante.SelectedValue = "Cot") AndAlso RBLPago.SelectedValue = "2" Then + ValidaCondicionesCredito = True End If - If Valida Then + If (ValidaRemision AndAlso DdlTipoComprobante.SelectedValue = "Rem") AndAlso RBLPago.SelectedValue = "1" Then + ValidaCondicionesCredito = True + End If + Else + 'SI ES VENTA NUEVA VALIDA AUNQUE NO PERMITA CREDITO + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") Then + ValidaCondicionesCredito = True + End If + End If + End If + + If ValidaCondicionesCredito Then + Dim ValidaCliente As Boolean = True + If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (Me.CveCliente = UsuarioActual.Empresa.Funcionalidad(714).ToEntero() OrElse Me.PermiteCredito) Then + ValidaCliente = False + End If + + If ValidaCliente Then Dim Vta As New ClsVentas Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

    {0}", Vta.SerieVenta) Vta.Dispose() If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then - Dim Autorizacion As Integer = 0 - Dim ObjVentas As New ClsVentas - If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero, "Ing", CveEstatus:=1) Then - Dim RowAutorizacion As DataRow = Nothing - 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO - If TieneDiasVencidos Then - RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC") - Else - RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC") + Dim BloquearCliente As Boolean = False + + 'CREDITO NO SUFICIENTE + If Opcion = 3 Then + 'Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) + 'If CreditoDispo < 0 AndAlso RBLPago.SelectedValue = "1" Then + ' BloquearCliente = True + 'End If + BloquearCliente = True + 'FACTURAS CON VENCIMIENTO + ElseIf Opcion = 2 Then + BloquearCliente = True + End If + + If BloquearCliente Then + Dim Autorizacion As Integer = 0 + + Dim ObjVentas As New ClsVentas + If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero, "Ing", CveEstatus:=1) Then + Dim RowAutorizacion As DataRow = Nothing + 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO + If TieneDiasVencidos Then + RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC") + Else + RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC") + End If + + If RowAutorizacion IsNot Nothing Then + Autorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero() + End If End If + ObjVentas.Dispose() - If RowAutorizacion IsNot Nothing Then - Autorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero() + 'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO + If Opcion > 0 AndAlso Autorizacion <= 0 Then + Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) + BtnsFacturar.Visible = False + BtnGenerarRemision.Visible = False + If DdlTipoComprobante.SelectedValue <> "Cot" Then + BtnEmitirImprimir.Visible = False + End If + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso ClienteEsDistribuidor AndAlso Opcion.Contiene(2, 3) Then + TieneBloqueoPorCreditoVencimiento = 1 + End If End If End If - ObjVentas.Dispose() - 'SI NO TIENE AUTORIZACION, MANTIENE EL BLOQUEO POR CONDICIONES DE CREDITO - If Opcion > 0 AndAlso Autorizacion <= 0 Then - Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) - BtnsFacturar.Visible = False - BtnGenerarRemision.Visible = False - End If Else If Opcion > 0 Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) BtnsFacturar.Visible = False BtnGenerarRemision.Visible = False + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso ClienteEsDistribuidor AndAlso Opcion.Contiene(2, 3) Then + TieneBloqueoPorCreditoVencimiento = 1 + End If End If End If End If @@ -7844,11 +7986,43 @@ Partial Class Ventas End If End If - End If UPPCreditoDisponible.Update() + 'SOLO VERIFICA VENCIMIENTOS + If UsuarioActual.Empresa.Funcionalidad(702).Contiene("2") Then + + Dim ValidaCliente As Boolean = False + + If (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") AndAlso (Me.CveVenta <= 0 OrElse EsCreaApartirDe)) OrElse ((DdlTipoComprobante.SelectedValue.Contiene("Cot") AndAlso (Me.CveVenta > 0 AndAlso Not EsCreaApartirDe))) Then + ValidaCliente = True + End If + + If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (Me.CveCliente = UsuarioActual.Empresa.Funcionalidad(714).ToEntero()) Then + ValidaCliente = False + End If + + 'SI ES FACTURA, REMISION o FACTURACION DE COTIZACIONES + If ValidaCliente Then + Dim Vta As New ClsVentas + Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa, TipoVerificacion:=2) + Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

    {0}", Vta.SerieVenta) + Vta.Dispose() + + If Opcion = 2 Then + Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) + RBLPago.SelectedValue = "2" + RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + 'BtnEmitirImprimir.Visible = False + 'BtnsFacturar.Visible = False + 'BtnGenerarRemision.Visible = False + 'TieneBloqueoPorCreditoVencimiento = 1 + End If + End If + End If + 'Puede hacer pedido If CveVenta <= 0 Then If Not UsuarioActual.TienePermisoProceso(177) And Not EsVentaMedica Then @@ -8157,8 +8331,6 @@ Partial Class Ventas End If - - End Sub Private Sub CargaPSRemision(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost) @@ -8440,7 +8612,6 @@ Partial Class Ventas 'If UsuarioActual.CveEmpresa = 119 Then ' e.Row.FCTextBox("TxtDescuento").Enabled = False 'End If - Else 'MODO NORMAL @@ -8590,6 +8761,10 @@ Partial Class Ventas If EsVentaMedica Then GvPS.Rows(e.NewEditIndex).FCTextBox("TxtPrecio").Enabled = False + + If DdlTipoComprobante.SelectedValue = "Cot" Then + GvPS.Rows(e.NewEditIndex).FCTextBox("TxtPrecio").Enabled = True + End If End If If CveCicloComercial > 0 Then @@ -8622,6 +8797,11 @@ Partial Class Ventas Cantidad = GvPS.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.ToDecimal PU = (GvPS.Rows(e.RowIndex).FCTextBox("TxtPrecio").Text.ToDecimal).RoundSQL(6) + If Cantidad <= 0 Then + Alert("La cantidad debe ser mayor a cero", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Dim DescuentoManual As Decimal = (GvPS.Rows(e.RowIndex).FCTextBox("TxtDescuento").Text.ToDecimal).RoundSQL(NumeroDecimales) ObjDescuento.ImporteDescuento = DescuentoManual @@ -9487,7 +9667,7 @@ Partial Class Ventas Me.CveAutorizacion = -1 'SI ES A CREDITO DEBE VERIFICAR SI TIENE AUTORIZACIONES - If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs") AndAlso RBLPago.SelectedValue = "1" Then + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing") AndAlso RBLPago.SelectedValue = "1" Then Dim TipoDocumentoAutorizacion As String = "" Dim ImporteAutorizacion As Decimal = 0 Dim TipoAutorizacion As Integer = 0 @@ -9495,13 +9675,13 @@ Partial Class Ventas Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero() Dim ObjVentas As New ClsVentas Try - If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, DdlTipoDocto.SelectedValue, CveEstatus:=1) Then + If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, "Ing", CveEstatus:=1) Then Dim RowAutorizacion As DataRow = Nothing 'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO If TieneDiasVencidos Then - RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='{DdlTipoComprobante.SelectedValue}'", Orderby:="Importe DESC") + RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC") Else - RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='{DdlTipoComprobante.SelectedValue}'", Orderby:="Importe DESC") + RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Ing'", Orderby:="Importe DESC") End If If RowAutorizacion IsNot Nothing Then @@ -9521,11 +9701,11 @@ Partial Class Ventas If TipoDocumentoAutorizacion = "Ing" Then If TipoAutorizacion = 1 Then - If TieneDiasVencidos Then - CveAutorizacion = -1 - Alert($"El crédito no esta autorizado. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia) - Exit Sub - End If + 'If TieneDiasVencidos Then + ' CveAutorizacion = -1 + ' Alert($"El crédito no esta autorizado. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then Dim BloquearCredito As Boolean = True @@ -9575,79 +9755,23 @@ Partial Class Ventas End If End If - If TieneDiasVencidos AndAlso DdlTipoComprobante.SelectedValue = "Egs" AndAlso CveAutorizacion <= 0 Then - CveAutorizacion = -1 - Alert($"El crédito no esta autorizado. No tiene autorización para generar notas de crédito. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia) - Exit Sub - End If + 'If TieneDiasVencidos AndAlso DdlTipoComprobante.SelectedValue = "Egs" AndAlso CveAutorizacion <= 0 Then + ' CveAutorizacion = -1 + ' Alert($"El crédito no esta autorizado. No tiene autorización para generar notas de crédito. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If - If TipoDocumentoAutorizacion = "Egs" Then - If TipoAutorizacion = 1 Then - If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then - CveAutorizacion = -1 - Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - End If + 'If TipoDocumentoAutorizacion = "Egs" Then + ' If TipoAutorizacion = 1 Then + ' If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then + ' CveAutorizacion = -1 + ' Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia) + ' Exit Sub + ' End If + ' End If + 'End If End If - 'SI TIENE LINEA ADICIONAL NO VERIFICAR LIMITE DE CREDITO - 'SI NO TIENE AUTORIZACION VERIFICAR LIMITE DE CREDITO Y CANDADOS DE VENTA - 'No exceder el limite de credito, Si no tiene contrato limita el credito, si tiene no hace nada. Si no tiene remisiones tampoco hace nada. - 'If DdlLineaAdicional.SelectedValue.ToEntero() <= 0 AndAlso Me.CveAutorizacion <= 0 AndAlso (Not CveContrato > 0 Or CveContratoTipo.Contiene(28)) AndAlso (Not NuevaFactura = 1) AndAlso RBLPago.SelectedValue = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso RemisionesLista.Count <= 0 AndAlso TxtTotal.Text.ToDecimal > 0 AndAlso Not CvePedidoA > 0 Then - ' 'If UsuarioActual.Empresa.Funcionalidad(518) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(185) Then - - ' If Not UsuarioActual.Empresa.Funcionalidad(702) = "1" Then - ' Dim ObjVentas As New ClsVentas - - ' If ObjVentas.ObtenerCreditoRestante(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) Then - ' If ObjVentas.DtResultados.Rows.Count > 0 Then - - ' If DdlSucursalCliente.SelectedValue.ToEntero() > 0 Then - ' If ObjVentas.DtResultados(0)("LimiteRestanteSucursal").ToString().ToDecimal - If(TxtTipoCambio.Visible, TxtTotal.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal, TxtTotal.Text.ToDecimal) < 0 Then - ' ObjVentas.Dispose() - ' Alert("Se está excediendo el límite de credito permitido de la Sucursal del Cliente.", TipoMensaje.MsgInformacion) - ' Exit Sub - ' End If - ' Else - ' If ObjVentas.DtResultados(0)("LimiteRestanteCliente").ToString().ToDecimal - If(TxtTipoCambio.Visible, TxtTotal.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal, TxtTotal.Text.ToDecimal) < 0 Then - ' ObjVentas.Dispose() - ' Alert("Se está excediendo el límite de credito permitido del Cliente.", TipoMensaje.MsgInformacion) - ' Exit Sub - ' End If - ' End If - - ' Else - ' ObjVentas.Dispose() - ' Alert("Ocurrio un error al obtener el limite de credito del cliente", TipoMensaje.MsgError) - ' Exit Sub - ' End If - ' Else - ' ObjVentas.Dispose() - ' Alert("Ocurrio un error al obtener el limite de credito del cliente", TipoMensaje.MsgError) - ' Exit Sub - ' End If - ' ObjVentas.Dispose() - - ' 'VERIFICA SI TIENE BLOQUEO POR DIAS VENCIDOS - ' If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then - ' Dim Vta As New ClsVentas - ' Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa, TipoVerificacion:=2) - ' Dim OpcionMsg As String = String.Format("El Cliente se encuentra bloqueado por la siguiente razón:

    {0}", Vta.SerieVenta) - ' Vta.Dispose() - - ' If Opcion = 2 Then - ' Alert(OpcionMsg, TipoMensaje.MsgError) - ' Exit Sub - ' End If - ' End If - - ' End If - - ' 'End If - 'End If - 'VALIDAR LINEAS ADICIONALES If UsuarioActual.Empresa.Funcionalidad(705) = "1" AndAlso DdlLineaAdicional.SelectedValue.ToEntero() > 0 Then 'VERIFICA QUE LA CATEGORIA DE LOS PRODUCTOS DEBE SER LA MISMA DE LA LINEA ADICIONAL @@ -10773,7 +10897,7 @@ Partial Class Ventas Else Dim capturedContext = HttpContext.Current Dim strURLHOST As String = String.Format("{0}://{1}:{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port) - Dim Hilo As New System.Threading.Thread(Sub() GeneraPDFFactura(ChkEnviarFactura.Checked, Factura, UsuarioActual, strURLHOST, EsHilo:=True, Contexto:=capturedContext)) + Dim Hilo As New System.Threading.Thread(Sub() GeneraPDFFactura(ChkEnviarFactura.Checked, Factura, UsuarioActual, strURLHOST, UsarDescargaDesdePopUpVerFactura:=True)) Hilo.Start() End If Catch ex As Exception @@ -10906,10 +11030,6 @@ Partial Class Ventas GeneraPDFCotizacion(ChkEnviarFactura.Checked) ' MANDA CORREO End If - ElseIf DdlTipoComprobante.SelectedValue = "Rem" Then - If UsuarioActual.CveEmpresa.Contiene(81, 109) Then - EnviaPDFRemision(ChkEnviarFactura.Checked) - End If End If 'ENVIA CORREO CON DETALLE DEL CONTRATO @@ -11062,7 +11182,7 @@ Partial Class Ventas End If End Sub - Private Function CRMActualizaImporteBitacora(CveAcercamientoCRMActualizar As Integer, ImporteCRM As Decimal, SerieFolioVenta As String, ByRef ObjTRansaccion As SqlTransaction) As Boolean + Private Function CRMActualizaImporteBitacora(CveAcercamientoCRMActualizar As Integer, ImporteCRM As Decimal, SerieFolioVenta As String, ByRef ObjTransaccion As SqlClient.SqlTransaction) As Boolean Dim cRMService As ICRMService = New CRMService(System.Configuration.ConfigurationManager.ConnectionStrings("Conexion").ConnectionString) Dim AcercamientoModel As RequestAcercamiento = New RequestAcercamiento(UsuarioActual.CveEmpresa, CveAcercamientoCRMActualizar) @@ -11072,8 +11192,8 @@ Partial Class Ventas Dim CveTipoProcesoCRM As Integer = objAcercamiento.Result(0).CveTipoProceso.ToEntero Dim Respuesta As Boolean = False - Dim ObjCRM As New ClsCRM(ObjTRansaccion) - Dim ObjEventoBitacora As New ClsOIEventos(ObjTRansaccion) + Dim ObjCRM As New ClsCRM(ObjTransaccion) + Dim ObjEventoBitacora As New ClsOIEventos(ObjTransaccion) If objAcercamiento.Result.Count > 0 Then If ObjCRM.UpdateAcercamientoCotizacion(CveAcercamientoCRMActualizar, ImporteCRM, UsuarioActual.CveEmpresa) Then @@ -11221,7 +11341,6 @@ Partial Class Ventas ObjFacturaDevolucion.CveSucursalCobranza = DdlSucursalCobranza.SelectedValue.ToEntero() If UsuarioActual.Empresa.Funcionalidad(578) = "1" AndAlso DvModalRequiereOSFecha.Visible Then - ObjFacturaDevolucion.Alfa1 = TxtFechaOS.Text.Trim ObjFacturaDevolucion.FechaEjecucion = TxtFechaOS.Text.Trim.ToDateTime Else ObjFacturaDevolucion.Alfa1 = TxtAlfa1.Text.Trim @@ -11978,6 +12097,12 @@ Partial Class Ventas ObjFactura.Num1 = TxtNum1.Text.Trim.ToDouble ObjFactura.Num2 = TxtNum2.Text.Trim.ToDouble ObjFactura.Num3 = If(ObjFactura.TipoDocto = "OP", DdlOrdenPago.SelectedValue.ToDouble, TxtNum3.Text.Trim.ToDouble) + 'VALOR DE MARCA PARA IMPRESION DE TICKES EN FACTURAS PAGADAS + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + If DdlTipoAmortizacionAnticipo.SelectedValue = "4" Then + ObjFactura.Num2 = 800 + End If + End If If divcondicionespago.Visible Then ObjFactura.FechaPago = TxtFechaPago.Text.ToDate @@ -12036,7 +12161,6 @@ Partial Class Ventas ObjFactura.MonedaAbreviatura = "" If UsuarioActual.Empresa.Funcionalidad(578) = "1" AndAlso DvModalRequiereOSFecha.Visible Then - ObjFactura.Alfa1 = TxtFechaOS.Text.Trim ObjFactura.FechaEjecucion = TxtFechaOS.Text.Trim.ToDateTime ObjFactura.FechaParaSurtir = TxtFechaOS.Text.Trim.ToDateTime Else @@ -12714,7 +12838,6 @@ Partial Class Ventas ObjFacturaDevolucion.MonedaAbreviatura = "" If UsuarioActual.Empresa.Funcionalidad(578) = "1" AndAlso DvModalRequiereOSFecha.Visible Then - ObjFacturaDevolucion.Alfa1 = TxtFechaOS.Text.Trim ObjFacturaDevolucion.FechaEjecucion = TxtFechaOS.Text.Trim.ToDateTime Else ObjFacturaDevolucion.Alfa1 = TxtAlfa1.Text.Trim @@ -13667,18 +13790,23 @@ Partial Class Ventas If UsuarioActual.Empresa.Funcionalidad(578) = "1" AndAlso EsVentaMedica Then If DdlSucursalCliente.SelectedValue.ToEntero > 0 Then - Dim objclientes As New ClsClientes - If objclientes.GetSucursales(CveCliente, -1) Then - CveAlmacenTraspasoDestino = objclientes.DtResultados.FiltroPrimeroValor("CveAlmacenAsignado", $" CveClienteSucursal = {DdlSucursalCliente.SelectedValue.ToEntero}").ToEntero + Dim drr As DataRow = GlobalDTClientesSucursales(UsuarioActual.CveEmpresa, CveCliente).FiltroPrimero($" CveClienteSucursal = {DdlSucursalCliente.SelectedValue.ToEntero}") + If drr IsNot Nothing Then + If RBLTipoVenta.SelectedValue.Contiene("3") Then 'cuando es A-vista + CveAlmacenTraspasoDestino = drr("CveAlmacenAlterno").ToString.ToEntero + ElseIf RBLTipoVenta.SelectedValue.Contiene("4") Then 'cuando es Consignación + CveAlmacenTraspasoDestino = drr("CveAlmacenConsignacion").ToString.ToEntero + Else + CveAlmacenTraspasoDestino = drr("CveAlmacenAsignado").ToString.ToEntero '' cuando Fuera de Línea + End If End If - objclientes.Dispose() End If - If Not CveAlmacenTraspasoDestino > 0 Then + If Not CveAlmacenTraspasoDestino > 0 Then ' para consignación es salida directa CveAlmacenTraspasoDestino = CveAlmacenAsignado End If - If RBLTipoVenta.SelectedValue.ToEntero = 2 Then + If RBLTipoVenta.SelectedValue = "2" Then If Not ChkRequiereTecnico.Checked Then CveAlmacenTraspasoDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 10 AND CveSubProyecto = {DdlSubProyectoDatos.SelectedValue}").ToString().ToEntero() End If @@ -13693,7 +13821,6 @@ Partial Class Ventas End If End If - End If Dim TotalImpuestoLocal As Double = 0 @@ -13909,6 +14036,11 @@ Partial Class Ventas End If Dim EsatusAlmacen As Integer = If(RBLTipoVenta.SelectedValue.Contiene("5", "6") AndAlso EsVentaMedica AndAlso DdlTipoComprobante.SelectedValue = "Ped", 1, 0) ', EstatusAlmacen:=EsatusAlmacen + + If TmpDTDetalle Is Nothing OrElse TmpDTDetalle.Rows.Count = 0 Then + ErrorList.Add("Ocurrió un error al registrar la factura. No se encontraron productos y/o servicios.
    Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + End If + 'Se agregan los PS For Each Row As DataRow In TmpDTDetalle.Rows If Not ObjVentas.AddVentaDetalle(ObjVentas.CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("CveUM").ToString().ToEntero(), @@ -14157,6 +14289,19 @@ Partial Class Ventas End If End If + If EsVentaMedica AndAlso ErrorList.Count = 0 AndAlso ObjEventos IsNot Nothing Then + Dim CveOSAgenda As Integer = -1 + Dim FolioOSAgenda As Integer = 0 + If Me.CveOSVentaMedica > 0 Then + CveOSAgenda = Me.CveOSVentaMedica + FolioOSAgenda = Me.FolioOSVentaMedica + End If + + If Not AgendarCirugia(ObjEventos, CveOSAgenda, FolioOSAgenda) Then + ErrorList.Add("Ocurrió un error al guardar la agenda") + End If + End If + 'Contratos If factura.CveContrato > 0 AndAlso Me.CveContratoTipo <> 33 Then If factura.CveContrato > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing") Then @@ -16309,13 +16454,7 @@ Partial Class Ventas ''' ''' ''' - Private Sub GeneraPDFFactura(EnviaCorreo As Boolean, Factura As Modelos.Factura, UsuarioActual As Usuario, strURLHOST As String, Optional CorreoCRM As String = "", Optional UsarDescargaDesdePopUpVerFactura As Boolean = True, - Optional EsHilo As Boolean = False, Optional Contexto As HttpContext = Nothing) - - If EsHilo Then - HttpContext.Current = Contexto - HttpContext.Current.Session("UsuarioSIG") = UsuarioActual - End If + Private Sub GeneraPDFFactura(EnviaCorreo As Boolean, Factura As Modelos.Factura, UsuarioActual As Usuario, strURLHOST As String, Optional CorreoCRM As String = "", Optional UsarDescargaDesdePopUpVerFactura As Boolean = True) 'GUARDA PDF Dim LocalSerieFolio As String = String.Empty @@ -16367,7 +16506,7 @@ Partial Class Ventas End If If ErrorCorreo Then - Dim ObjVentas As New ClsVentas + Dim ObjVentas As New ClsVentas(UsuarioActual:=UsuarioActual) If EnviaCorreo Then ObjVentas.UpdateVentaMail(3, CveVenta) Else @@ -16426,6 +16565,7 @@ Partial Class Ventas Try ' BytesPdfCotizacion(CveVenta) + Dim capturedContext = HttpContext.Current Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto, CorreoContactoCRM:=CorreoContactoCRM)) Hilo.Start() Catch ex As Exception @@ -16441,53 +16581,6 @@ Partial Class Ventas End If End Sub - Private Sub EnviaPDFRemision(EnviaCorreo As Boolean) - 'MANDA CORREO - If EnviaCorreo Then - - 'GUARDA PDF - Dim pdf As Byte() = Nothing - Dim LocalSerieFolio As String = String.Empty - Dim LocalTipoDocto As String = String.Empty - - 'TIMBRADO NUEVO - Try - pdf = PdfFactura(ObjFactura, AplicaPagare:="1") - Catch ex As Exception - Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgError) - End Try - - If CveVenta > 0 Then - ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False, CargaDTDetalle:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False) - End If - - LocalSerieFolio = ObjFactura.SerieFolio - LocalTipoDocto = ObjFactura.TipoDocto - Dim ArchivoAdjunto As String = "" - - Dim ArchivoXML As String = String.Format("{0}XML\{1}\{2}.xml", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio) - Dim ArchivoPDF As String = 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, ArchivoAdjunto)) - Hilo.Start() - Catch ex As Exception - OnError("Ocurrió error al mandar Mail", ex) - Dim ObjVentas As New ClsVentas - If ChkEnviarFactura.Checked Then - ObjVentas.UpdateVentaMail(3, CveVenta) - Else - ObjVentas.UpdateVentaMail(0, CveVenta) - End If - ObjVentas.Dispose() - End Try - End If - End Sub - #End Region #Region " ANTICIPOS " @@ -17110,13 +17203,26 @@ Partial Class Ventas 'cuando es PAGO CON DEVOLUCION If DdlTipoAmortizacionAnticipo.SelectedValue = "4" Then - + Dim SbObs As New StringBuilder For Each gvr As GridViewRow In GVAnticipos.Rows If gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked AndAlso gvr.DataKey("CveConceptoContable").ToEntero().Contiene(12, 66, 277) Then - Amortizacion += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal ' - ((gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("TotalAnticipo").ToDecimal) * gvr.DataKey("IVAAnticipo").ToDecimal) + Amortizacion += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal + + Dim SaldoPendiente = (gvr.FCLiteral("LtlAnticipos").Text.ToDecimal - gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal).RoundSQL(2) + If SaldoPendiente > 0 Then + SbObs.AppendFormat("Folio: {0} Saldo: {1:N2} ,", gvr.DataKey("Folio").Trim(), SaldoPendiente) + End If + End If Next + 'AGREGA EN LAS OBS EL SALDO PENDIENTE + If SbObs.Length > 0 Then + SbObs.Remove(SbObs.Length - 1, 1) + TxtObsFact.Text = SbObs.ToString() + UPObservaciones.Update() + End If + LblAntAplicados.Text = String.Format("Pago con devolución: {0:C}", Amortizacion) : LblAntAplicados.Visible = True HdnAnticipos.Value = Amortizacion.RoundSQL(2).ToString() Amortizacion = 0 @@ -17308,7 +17414,7 @@ Partial Class Ventas Dim capturedContext = HttpContext.Current Dim strURLHOST As String = String.Format("{0}://{1}:{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port) Dim Factura As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, EsCancelacion:=False, CargaDTDetalle:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False, VerificaAlmacen:=False) - Dim Hilo As New System.Threading.Thread(Sub() GeneraPDFFactura(ChkEnviarFactura.Checked, Factura, UsuarioActual, strURLHOST, EsHilo:=True, Contexto:=capturedContext)) + Dim Hilo As New System.Threading.Thread(Sub() GeneraPDFFactura(ChkEnviarFactura.Checked, Factura, UsuarioActual, strURLHOST, UsarDescargaDesdePopUpVerFactura:=True)) Hilo.Start() Catch ex As Exception OnError("Ocurrió un error al enviar el PDF", ex) @@ -17573,6 +17679,10 @@ Partial Class Ventas If UsuarioActual.CveUsuario = 3986 Then TxtPrecio.Enabled = True End If + + If DdlTipoComprobante.SelectedValue = "Cot" Then + TxtPrecio.Enabled = True + End If Else If drPS("CveTipoPS").ToString() = "1" Then 'Si es servicio If UsuarioActual.Empresa.Funcionalidad(558).ToString() = "1" Then 'Si es Empresa llantera @@ -17912,7 +18022,7 @@ Partial Class Ventas TrAlmacenOrigen.Visible = False If DdlTipoComprobante.SelectedValue = "Cot" And UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then - Alert("Se ocupa una autorización.", TipoMensaje.MsgAdvertencia) + Alert("Se requiere una autorización.", TipoMensaje.MsgAdvertencia) TrDireccion.Visible = False TrCiudad.Visible = False TrRFC.Visible = False @@ -18070,11 +18180,11 @@ Partial Class Ventas Alert("El Cliente seleccionado no esta activo", TipoMensaje.MsgAdvertencia) End If If Not CveEmpresaCRM > 0 Then - BtnEmitirImprimir.Visible = EstatusCliente - TrVistaPrevia.Visible = EstatusCliente + BtnEmitirImprimir.Visible = EstatusCliente AndAlso TieneBloqueoPorCreditoVencimiento = 0 + TrVistaPrevia.Visible = EstatusCliente AndAlso TieneBloqueoPorCreditoVencimiento = 0 Else - BtnEmitirImprimir.Visible = True - TrVistaPrevia.Visible = True + BtnEmitirImprimir.Visible = TieneBloqueoPorCreditoVencimiento = 0 + TrVistaPrevia.Visible = TieneBloqueoPorCreditoVencimiento = 0 End If End If @@ -18307,14 +18417,14 @@ Partial Class Ventas If Not CveEmpresaCRM > 0 Then 'SI ES UNA REMISION EXISTENTE, NO MOSTRAR LOS BOTONES If Not (CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Rem") Then - BtnCrearApartirDe.Enabled = EstatusCliente - BtnEmitirImprimir.Visible = EstatusCliente + BtnCrearApartirDe.Enabled = EstatusCliente AndAlso TieneBloqueoPorCreditoVencimiento = 0 + BtnEmitirImprimir.Visible = EstatusCliente AndAlso TieneBloqueoPorCreditoVencimiento = 0 TrVistaPrevia.Visible = EstatusCliente End If Else If TipoDoctoConsulta.Contiene("Ing", "Egs", "Ant", "Dev") Then - BtnCrearApartirDe.Enabled = EstatusCliente - BtnEmitirImprimir.Visible = EstatusCliente + BtnCrearApartirDe.Enabled = EstatusCliente AndAlso TieneBloqueoPorCreditoVencimiento = 0 + BtnEmitirImprimir.Visible = EstatusCliente AndAlso TieneBloqueoPorCreditoVencimiento = 0 TrVistaPrevia.Visible = EstatusCliente Else BtnCrearApartirDe.Enabled = True @@ -18550,6 +18660,14 @@ Partial Class Ventas Return False End If + 'SI NO VIENE DESDE EL MODAL + If CantidadModal = 0 Then + If TxtCantidad.Text.ToDecimal() <= 0 Then + Alert("La cantidad debe ser mayor a cero", TipoMensaje.MsgAdvertencia) + Return False + End If + End If + 'VALIDA PROMOCIONES Dim ObjVentas As New ClsVentas If ObjVentas.GetPromocionesPS(-1, TxtFecha.Text.ToDateTime, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveCliente, DdlVendedor.SelectedValue.ToEntero(), 1, UsuarioActual.CveEmpresa) Then @@ -22055,7 +22173,7 @@ Partial Class Ventas OnError("Ocurrió error al mandar el Mail", ex) ResultadoMail = 3 Finally - Dim ObjVentas As New ClsVentas + Dim ObjVentas As New ClsVentas(UsuarioActual:=UsuarioActual) ObjVentas.UpdateVentaMail(ResultadoMail, CveVenta) ObjVentas.Dispose() End Try @@ -22607,6 +22725,7 @@ Partial Class Ventas DdlProcedimiento.Enabled = True TxtPaciente.Enabled = True TxtEpisodio.Enabled = True + TxtFolioRemision.Enabled = True End If @@ -22660,6 +22779,9 @@ Partial Class Ventas TxtPrecio.Enabled = True End If + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + DdlFormaEntrega.Enabled = True + End If LbAgregar.Enabled = True ImgDescTotal.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '2'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = ''; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = 'none'; $get('BtnAplicarDescG').style.display = ''; $get('TrMotivoDescuento').style.display = '';") @@ -22677,6 +22799,8 @@ Partial Class Ventas End If End If + + UPPVentas.Update() UpPS.Update() UpCliente.Update() @@ -22684,6 +22808,12 @@ Partial Class Ventas End Sub Private Sub BtnEditarRemision_Click(sender As Object, e As EventArgs) Handles BtnEditarRemision.Click + + If TmpDT Is Nothing OrElse TmpDT.Rows.Count = 0 Then + Alert("Es necesario tener al menos 1 producto y/o servicio", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Dim OcurrioError As Boolean = False Dim ObjVentas As New ClsVentas ObjVentas.IniciaTransacSQL() @@ -22775,6 +22905,7 @@ Partial Class Ventas FechaParaSurtir = TxtFechaOS.Text.Replace(",", "").ToDateTime() End If + If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDecimal, LblDescuentos.Text.ToDecimal, TxtIVA.Text.ToDecimal, TxtIEPS.Text.ToDecimal, TxtTotal.Text.ToDecimal, Moneda, TipoCambio, TxtFecha.Text.Trim.ToDate, TxtObsFact.Text.Trim, UsuarioActual.CveEmpresa, CveVenta, Vigencia:=TxtFechaVencimientoCotizacion.Text.Trim.ToDate, CondicionesPago:=If(RBLPago.SelectedValue = "2", 0, 1), @@ -22782,7 +22913,7 @@ Partial Class Ventas CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero(), TipoDocto:=DdlTipoComprobante.SelectedValue, CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, Kilometraje:=TxtKilometraje.Text.ToDecimal, CveUsoCFDi:=DdlUsoCFDI.SelectedValue.ToEntero(), CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), ServicioDomicilio:=TrServicioDomicilio.Visible, CveMedico:=DdlMedico.SelectedValue.ToEntero, CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero, - FechaParaSurtir:=FechaParaSurtir, Paciente:=TxtPaciente.Text, Episodio:=TxtEpisodio.Text) Then + FechaParaSurtir:=FechaParaSurtir, Paciente:=TxtPaciente.Text, Episodio:=TxtEpisodio.Text, CveCondicionEntrega:=DdlFormaEntrega.SelectedValue.ToEntero(), FolioRemision:=TxtFolioRemision.Text.Trim) Then OcurrioError = True End If @@ -23342,8 +23473,11 @@ Partial Class Ventas ' DdlCuentaTarjetaDebito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND (CveTipoCuenta <> 1 OR TieneTerminal = 1)", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) 'End If - DdlCuentaTransferencia.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) - + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + DdlCuentaTransferencia.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0}", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) + Else + DdlCuentaTransferencia.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) + End If DtCC.Dispose() DdlCuentaEfectivo.DataBind() @@ -29441,6 +29575,11 @@ Partial Class Ventas UpCliente.Update() End If + 'SI NO ESTA VISIBLE, HABILITAR PARA GENERAR LA NC + If Not BtnEmitirImprimir.Visible Then + BtnEmitirImprimir.Visible = True + End If + Catch ex As Exception OnError("Ocurrió un error al aplicar NC", ex) End Try @@ -30238,7 +30377,7 @@ Partial Class Ventas Private Sub LimpiaDocumentoNC() EsCreaApartirDe = True - DivEstatusFac.Visible = False + UpEstatus.Visible = False TabAlmacen.Visible = False 'LIMPIA ACCIONES @@ -30644,7 +30783,7 @@ Partial Class Ventas TxtTipoCambio.Text = GlobalTipoCambio(NowADS()).ToString() End If - DivEstatusFac.Visible = False + UpEstatus.Visible = False 'REINICIALIZA TABS TabAlmacen.Enabled = False @@ -31347,6 +31486,12 @@ Partial Class Ventas End Sub Private Sub BtnEditarCotizacion_Click(sender As Object, e As EventArgs) Handles BtnEditarCotizacion.Click + + If TmpDT Is Nothing OrElse TmpDT.Rows.Count = 0 Then + Alert("Es necesario tener al menos 1 producto y/o servicio", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Dim VaFacturarCotizacion As Boolean = False 'SI CARGA UNA COTIZACION DEBE GUARDAR TAMBIEN If IfNull(ViewState("CveCotizacion"), 0).ToString().ToEntero() > 0 Then @@ -31447,8 +31592,6 @@ Partial Class Ventas Moneda = 1 End If - - 'ACTUALIZA VENTA 'ACTUALIZA VENTA If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDecimal, LblDescuentos.Text.ToDecimal(), TxtIVA.Text.ToDecimal(), TxtIEPS.Text.ToDecimal(), TxtTotal.Text.ToDecimal(), Moneda, TipoCambio, TxtFecha.Text.Trim.ToDate, TxtObsFact.Text.Trim, @@ -31462,7 +31605,6 @@ Partial Class Ventas End If - 'ELIMINA DETALLES If Not ObjVentas.RemoveVentasDetalle(CveVenta) Then MensajeError = "Ocurrió un error al actualizar las partidas de la cotización" @@ -32637,8 +32779,12 @@ Partial Class Ventas DrRemision(0)("Aplicado") = "True" End If DTRemisiones.AcceptChanges() - RemisionesLista.Add(CveVenta) - CargaConceptosRemisionPorFacturar(CveVenta.ToString(), 1) + + If RemisionesLista IsNot Nothing Then + RemisionesLista.Clear() + RemisionesLista.Add(CveVenta) + CargaConceptosRemisionPorFacturar(CveVenta.ToString(), 1) + End If If TmpDT.Rows.Count = 0 Then Alert("No hay conceptos por facturar de esta remisión. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) @@ -32933,7 +33079,7 @@ Partial Class Ventas BtnCrearApartirDe.Visible = False '[IPP-2Novimebre2018] REEMPLAZA LO COMENTADO ARRIBA EsCreaApartirDe = True ModalidadEdicion = True - DivEstatusFac.Visible = False + UpEstatus.Visible = False TabAlmacen.Visible = False 'CUANDO ES CREAR APARTIR DE SE LIMPIAN FUNCIONALIDADES DE DOCUMENTOS YA REGISTRADOS @@ -35765,6 +35911,10 @@ Partial Class Ventas Protected Sub LnkEditarDir_Click(sender As Object, e As EventArgs) DdlDireccionEnvio.Enabled = True + ChkDireccionEnvio.Enabled = True + ChkDireccionEnvio.Checked = True + ChkDireccionEnvio_CheckedChanged(ChkDireccionEnvio, EventArgs.Empty) + 'DdlDireccionEnvio.Visible = True LnkEditarDir.Visible = False LnkAplicarDir.Visible = True End Sub @@ -35779,7 +35929,7 @@ Partial Class Ventas ObjVentas.Dispose() If ProcesoOK Then - Alert("Dirección Actualizada correctamente.", ModExtensiones.TipoMensaje.ToastInformacion) + Alert("La dirección se ha actualizado correctamente.", TipoMensaje.MsgInformacion) LnkAplicarDir.Visible = False LnkEditarDir.Visible = True End If @@ -37216,7 +37366,13 @@ Partial Class Ventas item.Text = $"  {item.Text}" Next - RegistraScript("$('#DvModalTipoVenta').modal({ backdrop: 'static', keyboard: false });") + If Opcion <> "Cot" Then + RegistraScript("$('#DvModalTipoVenta').modal({ backdrop: 'static', keyboard: false });") + Else + TrVentasMedicas2.Visible = False + TrVentasMedicas3.Visible = False + End If + End Sub Private Sub CargaProcedimientos(Optional CveProcedimientSeleccion As Integer = -1) @@ -37244,10 +37400,10 @@ Partial Class Ventas DdlMedicoModal.ClearSelection() DdlMedicoModal.SelectedValue = Nothing - DdlMedico.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") + DdlMedico.DataSource = If(UsuarioActual.CveVendedor > 0, GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros($" Estatus = 'True' AND CveVendedor = {UsuarioActual.CveVendedor} "), GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")) DdlMedico.DataBind() - DdlMedicoModal.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ") + DdlMedicoModal.DataSource = If(UsuarioActual.CveVendedor > 0, GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros($" Estatus = 'True' AND CveVendedor = {UsuarioActual.CveVendedor} "), GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")) DdlMedicoModal.DataBind() If CveMedicoSeleccion > 0 Then @@ -37358,7 +37514,7 @@ Partial Class Ventas Protected Sub DdlClienteSucursal_SelectedIndexChanged(sender As Object, e As EventArgs) Dim CveClienteSplit As Integer = -1 - CargaPSProcedimiento(DdlProcedimiento.SelectedValue.ToEntero, DdlClienteSucursalCliente, DdlSubProyectoDatos.SelectedValue.ToEntero) + CargaPSProcedimiento(DdlProcedimiento.SelectedValue.ToEntero, DdlClienteSucursalCliente, DdlSubProyectoDatos.SelectedValue.ToEntero, CveClienteSucursalL:=DdlClienteSucursalSucursal, CveTipoVentaL:=RBLTipoVenta.SelectedValue.ToEntero) End Sub Private Function DdlClienteSucursalCliente() As Integer @@ -37458,7 +37614,6 @@ Partial Class Ventas End If End If - If DdlClienteSucursalCliente() > 0 Then CveClienteOS = DdlClienteSucursalCliente() Else @@ -37520,6 +37675,7 @@ Partial Class Ventas DdlMedico.SelectedValueExist(DdlMedicoModal.SelectedValue) DdlProcedimiento.SelectedValueExist(DdlProcedimientoModal.SelectedValue) + Dim tCveAlmacenExistencia As Integer = -1 If RBLTipoVenta.SelectedValue.Contiene("2") Then 'si es pago directo es factura 'DdlTipoComprobante.SelectedValueExist("Ing") @@ -37565,20 +37721,17 @@ Partial Class Ventas TdFechaOS1.Visible = ChkRequiereTecnicoModal.Checked TdFechaOS2.Visible = ChkRequiereTecnicoModal.Checked - End If - - DdlTipoComprobante.Enabled = False CargaCliente(CveCliente) - ' Si es pago directo no asigna la sucurasl al dll If RBLTipoVenta.SelectedValue.ToEntero <> 2 Then - If DdlClienteSucursalSucursal() > 0 Then - DdlSucursalCliente.SelectedValueExist(DdlClienteSucursalSucursal()) + Dim tcveclientesucursal As Integer = DdlClienteSucursalSucursal() + If tcveclientesucursal > 0 Then + DdlSucursalCliente.SelectedValueExist(tcveclientesucursal) Else If DdlSucursalCliente.Items.Count >= 2 Then DdlSucursalCliente.SelectedIndex = 1 @@ -37586,8 +37739,8 @@ Partial Class Ventas End If End If - DdlTipoComprobante_SelectedIndexChanged(sender, Nothing) + DdlTipoComprobante_SelectedIndexChanged(sender, Nothing) Dim CountPsAgregados As Integer = 0 @@ -37622,17 +37775,15 @@ Partial Class Ventas UpParametros.Update() End If - If RBLTipoVenta.SelectedValue.Contiene("5", "6") Then - AsignaAlamacenWS() - CargaPS(-1, DdlPS) + If RBLTipoVenta.SelectedValue.Contiene("5", "6") Then ' 3.avista,4.consig,5.consig mat, 6. avista mat. + AsignaAlmacenWS() + 'CargaPS(-1, DdlPS) End If RegistraScript("$('#DvModalTipoVenta').modal('hide');") UpCliente.Update() End Sub - - Protected Sub GvProductosProcedimiento_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DataKey("Precio").ToDecimal = 0 Then @@ -37649,13 +37800,13 @@ Partial Class Ventas End Sub Protected Sub DdlProcedimientoModal_SelectedIndexChanged(sender As Object, e As EventArgs) - CargaPSProcedimiento(DdlProcedimientoModal.SelectedValue.ToEntero, DdlClienteSucursalCliente, DdlSubProyectoDatos.SelectedValue.ToEntero) + CargaPSProcedimiento(DdlProcedimientoModal.SelectedValue.ToEntero, DdlClienteSucursalCliente, DdlSubProyectoDatos.SelectedValue.ToEntero, CveClienteSucursalL:=DdlClienteSucursalSucursal, CveTipoVentaL:=RBLTipoVenta.SelectedValue.ToEntero) End Sub - Private Sub CargaPSProcedimiento(CveProcedimiento As Integer, CveClienteL As Integer, CveSubProyectoL As Integer) + Private Sub CargaPSProcedimiento(CveProcedimiento As Integer, CveClienteL As Integer, CveSubProyectoL As Integer, Optional CveClienteSucursalL As Integer = -1, Optional CveTipoVentaL As Integer = -1) If CveProcedimiento > 0 Then Dim objVenta As New ClsVentas - If objVenta.GetProcedimientoProducto(CveProcedimiento, 1, UsuarioActual.CveEmpresa, CveClienteL, CveSubProyectoL) Then + If objVenta.GetProcedimientoProducto(CveProcedimiento, 1, UsuarioActual.CveEmpresa, CveClienteL, CveSubProyectoL, CveClienteSucursalL, CveTipoVentaL) Then GvProductosProcedimiento.DataSource = objVenta.DtResultados End If objVenta.Dispose() @@ -37701,7 +37852,7 @@ Partial Class Ventas End Sub - Private Function GeneraOS(ByRef TransacSQL As SqlTransaction, ByRef errorList As List(Of String), CveVentaOS As Integer, SerieFolioOS As String) As Boolean + Private Function GeneraOS(ByRef TransacSQL As SqlClient.SqlTransaction, ByRef errorList As List(Of String), CveVentaOS As Integer, SerieFolioOS As String) As Boolean Dim Errores As Boolean = False @@ -37723,6 +37874,7 @@ Partial Class Ventas CveProcedimiento:=DdlProcedimiento.SelectedValue.ToEntero, CveTipoVenta:=RBLTipoVenta.SelectedValue.ToEntero, FechaCita:=TxtFechaOS.Text.Replace(",", "").ToDateTime, Paciente:=TxtPaciente.Text, IdentificadorCliente:=TxtEpisodio.Text) Then CveOSVentaMedica = ObjOrdenServicio.CveOS + FolioOSVentaMedica = ObjOrdenServicio.Folio Else errorList.Add("Se presento un error al guardar la orden de servicio.") Errores = True @@ -37792,21 +37944,29 @@ Partial Class Ventas CargaProcedimientos(HdnCveProcedimientoNuevo.Value.ToEntero) End Sub - Private Sub AsignaAlamacenWS() + Private Sub AsignaAlmacenWS() CveAlamcenFiltroDdl = -1 + Dim tCveAlmacenExistencia As Integer = -1 If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then If DdlSucursalCliente.SelectedValue.ToEntero > 0 Then - Dim objclientes As New ClsClientes - If objclientes.GetSucursales(CveCliente, -1) Then - CveAlamcenFiltroDdl = objclientes.DtResultados.FiltroPrimeroValor("CveAlmacenAsignado", $" CveClienteSucursal = {DdlSucursalCliente.SelectedValue.ToEntero}").ToEntero + Dim drr As DataRow = GlobalDTClientesSucursales(UsuarioActual.CveEmpresa, CveCliente).FiltroPrimero($"CveClienteSucursal={DdlSucursalCliente.SelectedValue}") + If drr IsNot Nothing Then + If RBLTipoVenta.SelectedValue.Contiene("6") Then + tCveAlmacenExistencia = drr("CveAlmacenAlterno").ToString.ToEntero + ElseIf RBLTipoVenta.SelectedValue.Contiene("5") Then + tCveAlmacenExistencia = drr("CveAlmacenConsignacion").ToString.ToEntero + Else + tCveAlmacenExistencia = drr("CveAlmacenAsignado").ToString.ToEntero + End If End If - objclientes.Dispose() End If If Not CveAlamcenFiltroDdl > 0 Then CveAlamcenFiltroDdl = If(CveAlmacenAsignado > 0, CveAlmacenAsignado, -1) End If + DdlPS.ddlWS.Attributes.Remove("data-CveAlmacen") + DdlPS.ddlWS.Attributes.Add("data-CveAlmacen", tCveAlmacenExistencia.ToString) End If @@ -38142,7 +38302,76 @@ Partial Class Ventas End Sub + Protected Function AgendarCirugia(ByRef ObjEventos As ClsOIEventos, CveOS As Integer, FolioOS As Integer) As Boolean + Dim TieneError As Boolean = False + Try + If DdlMedico.SelectedValue.ToEntero() > 0 AndAlso TrVentasMedicas2.Visible AndAlso TdFechaOS1.Visible AndAlso TdFechaOS2.Visible Then + Dim FechaCirugia As DateTime = MinFecha + If TxtFechaOS.Text.Replace(",", "").ToDateTime() > MinFecha Then + FechaCirugia = TxtFechaOS.Text.Replace(",", "").ToDateTime() + If FechaCirugia > MinFecha Then + + Dim CveUsuarioAgendar = -1 + Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero() + + If CveVendedor > 0 Then + Dim strVendedores = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvesUsuariosAsignados", $"CveVendedor = {CveVendedor}") + If strVendedores.Split(","c).Length > 0 Then + CveUsuarioAgendar = strVendedores.Split(","c)(0).ToEntero() + End If + End If + + If CveUsuarioAgendar > 0 Then + + Dim Descripcion As New StringBuilder + + If DdlMedico.SelectedValue.ToEntero() > 0 Then + Descripcion.AppendFormat("Dr {0} {1}", DdlMedico.SelectedItem.Text, "
    ") + End If + + If DdlProcedimiento.SelectedValue.ToEntero() > 0 Then + Descripcion.AppendFormat("Cirugía {0} {1}", DdlProcedimiento.SelectedItem.Text, "
    ") + End If + + Descripcion.AppendFormat("Fecha de Cirugía {0} {1}", FechaCirugia.ToString("dd/MM/yyyy HH:mm"), "
    ") + + Dim Hospital As String = "" + + If DdlClienteSucursal.SelectedValue.ToEntero() > 0 Then + Hospital = DdlClienteSucursal.SelectedItem.Text + ElseIf DdlSucursalCliente.SelectedValue.ToEntero() > 0 Then + Hospital = DdlSucursalCliente.SelectedItem.Text + Else + Hospital = Me.NombreCliente + End If + + Descripcion.AppendFormat("{0} {1}", Hospital, "
    ") + + Dim Asunto As String = $"Cirugía - {Hospital}" + + If CveOS > 0 Then + Dim OIDescripcion As String = $"Orden de servicio {FolioOS} " + Descripcion.AppendFormat("{0} {1}", OIDescripcion, "
    ") + End If + + If Not ObjEventos.AddEventoAgenda(4, Asunto, Descripcion.ToString(), 3, FechaCirugia, FechaCirugia.AddHours(1), CveUsuarioAgendar, UsuarioActual.CveEmpresa, RecurrenciaTipo:=0, CveTipoEvento:=2, CveOS:=CveOS) Then + TieneError = True + End If + + End If + + End If + End If + + End If + Catch ex As Exception + TieneError = True + OnError("Ocurrió un error al generar la agenda", ex) + End Try + + Return Not TieneError + End Function diff --git a/asmx/WSApp.asmx b/asmx/WSApp.asmx index 3d4d064e3..d58e8eef0 100644 --- a/asmx/WSApp.asmx +++ b/asmx/WSApp.asmx @@ -350,9 +350,10 @@ Public Class WSApp Return JsonConvert.SerializeObject(Retorno) End Function Private Sub EnviarCorreo(Correo As String, Factura As Modelos.Factura, Retorno As Modelos.Factura.MMensajeFactura, DireccionEnvio As String, UsuarioActual As Usuario) - Try - Dim Hilo As New System.Threading.Thread(Sub() EnviarCorreoFactura(Correo, Factura, Retorno, DireccionEnvio, UsuarioActual)) - Hilo.Start() + Try + EnviarCorreoFactura(Correo, Factura, Retorno, DireccionEnvio, UsuarioActual) + 'Dim Hilo As New System.Threading.Thread(Sub() EnviarCorreoFactura(Correo, Factura, Retorno, DireccionEnvio, UsuarioActual)) + 'Hilo.Start() Catch ex As Exception OnError("Ocurrió error al mandar el correo de facturación", ex) End Try