diff --git a/Sistemas/UsuarioDetalle.aspx.vb b/Sistemas/UsuarioDetalle.aspx.vb index 6daf7065a..1794f951d 100644 --- a/Sistemas/UsuarioDetalle.aspx.vb +++ b/Sistemas/UsuarioDetalle.aspx.vb @@ -1288,12 +1288,14 @@ Partial Class Sistemas_UsuarioDetalle Private Sub RecargaGlobales(TieneError As Boolean, ObjSubProyectos As ClsSubProyectos, ObjBancos As ClsBancos, ObjOC As ClsOC, ObjUsuarios As ClsSisUsuarios) 'RECARGA GLOBAL SUBPROYECTOS If Not TieneError Then - If ObjSubProyectos.GetSubProyectosUsuarios Then - Application("GlobalDTSubProyectosUsuarios") = ObjSubProyectos.DtResultados - Else - Application("GlobalDTSubProyectosUsuarios") = Nothing - TieneError = True - End If + GlobalDTSubProyectosUsuarios(-1, -1, UsuarioActual.CveEmpresa) = Nothing + + 'If ObjSubProyectos.GetSubProyectosUsuarios Then + ' Application("GlobalDTSubProyectosUsuarios") = ObjSubProyectos.DtResultados + 'Else + ' Application("GlobalDTSubProyectosUsuarios") = Nothing + ' TieneError = True + 'End If End If If Not TieneError Then diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 840c535f4..d05f330be 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -3355,7 +3355,7 @@ - + @@ -3364,8 +3364,7 @@ - - + diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 52b6db6e6..657193607 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2418,18 +2418,21 @@ Partial Class Ventas LblSubProyecto.Text = "" divProyectoPyME.Visible = False LblSubProyectoPyME.InnerText = "Sucursal" + Dim dttSub As New DataTable + dttSub = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) DdlSubProyecto.Items.Clear() - DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyecto.DataSource = dttSub 'DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}) DdlSubProyecto.DataBind() DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlSubProyectoPyME.Items.Clear() - DdlSubProyectoPyME.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoPyME.DataSource = dttSub 'DdlSubProyectoPyME.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}) DdlSubProyectoPyME.DataBind() DdlSubProyectoPyME.Items.Insert(0, New ListItem("Seleccione", "-1")) + dttSub.Dispose() ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then DdlProyecto.Visible = False @@ -2439,18 +2442,21 @@ Partial Class Ventas LblSubProyecto.Text = "" divProyectoPyME.Visible = False LblSubProyectoPyME.InnerText = "Proyecto" + Dim dttSub As New DataTable + dttSub = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) DdlSubProyecto.Items.Clear() - DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyecto.DataSource = dttSub 'DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}) DdlSubProyecto.DataBind() DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlSubProyectoPyME.Items.Clear() - DdlSubProyectoPyME.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoPyME.DataSource = dttSub 'DdlSubProyectoPyME.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubProyecto", "SubProyecto"}) DdlSubProyectoPyME.DataBind() DdlSubProyectoPyME.Items.Insert(0, New ListItem("Seleccione", "-1")) + dttSub.Dispose() ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then LblProyectoHeader.Text = "Sucursal" @@ -2603,8 +2609,6 @@ Partial Class Ventas End If TxtFecha.Enabled = True - CargaPorcentajeMarcas() - BloqueaCondiconesPago() BloqueaClasificaciones() @@ -3538,13 +3542,17 @@ Partial Class Ventas Dim DbRowVenta As DataRow = ObjVentas.DtResultados.Rows(0) Dim CveCliente As Integer = DbRowVenta("CveCliente").ToString.ToEntero HdnCveVenta.Value = CveVenta.ToString - - Dim ObjUsados As New ClsVentas Dim DtUsados As DataTable = Nothing - If ObjUsados.GetVentasUsados(CveVenta, DdlSubProyectoDatos.SelectedValue.ToEntero(), DbRowVenta("Fecha").ToString.ToDateTime, UsuarioActual.CveEmpresa) Then - DtUsados = ObjUsados.DtResultados + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + Dim ObjUsados As New ClsVentas + + If ObjUsados.GetVentasUsados(CveVenta, DdlSubProyectoDatos.SelectedValue.ToEntero(), DbRowVenta("Fecha").ToString.ToDateTime, UsuarioActual.CveEmpresa) Then + DtUsados = ObjUsados.DtResultados + End If + ObjUsados.Dispose() End If - ObjUsados.Dispose() + Me.CveEstatusFacturaPadre = DbRowVenta("CveEstatusFacturaPadre").ToString.ToEntero 'CargaEncabezado @@ -3605,6 +3613,19 @@ Partial Class Ventas End If End If + 'CargaDetalle + If ObjVentas.GetVentaDetalle(CveVenta) Then + TmpDT = ObjVentas.DtResultados + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) + GvPS.DataSource = ObjVentas.DtResultados + GvPS.DataBind() + + 'IEPS A NIVEL DETALLE + 'TxtIEPS.Text = If(TmpDT.SUM("IEPS") > 0, TmpDT.SUM("IEPS").FormatoNumero, TxtIEPS.Text) + End If + + If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso LblFolioFiscal.Text.Trim = "" Then HplFolioFiscalModal.Visible = True Select Case DbRowVenta("TipoDocto").ToString @@ -3622,7 +3643,7 @@ Partial Class Ventas If TienePermiso <> "" Then ' si tiene acceso en el subproyecto 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) If UsuarioActual.TienePermisoProceso(264) Then - InicializaAplicaDevolucion() + InicializaAplicaDevolucion(TmpDT) End If End If @@ -3754,11 +3775,11 @@ Partial Class Ventas End If 'contado 0, credito 1, terminal 2 - If ObjVentas.DtResultados(0)("CondicionesPago").ToString.ToEntero = 1 Then + If DbRowVenta("CondicionesPago").ToString.ToEntero = 1 Then RBLPago.SelectedValue = "1" RBLPago_SelectedIndexChanged(Nothing, Nothing) UPCondicionesPago.Update() - ElseIf ObjVentas.DtResultados(0)("CondicionesPago").ToString.ToEntero = 0 Then + ElseIf DbRowVenta("CondicionesPago").ToString.ToEntero = 0 Then RBLPago.SelectedValue = "2" RBLPago.Items(0).Enabled = False RBLPago_SelectedIndexChanged(Nothing, Nothing) @@ -3771,17 +3792,6 @@ Partial Class Ventas UPCondicionesPago.Update() End If - 'CargaDetalle - If ObjVentas.GetVentaDetalle(CveVenta) Then - TmpDT = ObjVentas.DtResultados - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) - GvPS.DataSource = ObjVentas.DtResultados - GvPS.DataBind() - - 'IEPS A NIVEL DETALLE - 'TxtIEPS.Text = If(TmpDT.SUM("IEPS") > 0, TmpDT.SUM("IEPS").FormatoNumero, TxtIEPS.Text) - End If 'ESCONDE ACCIONES LnkRemisiones.Visible = False @@ -5151,6 +5161,10 @@ Partial Class Ventas CargaRestriccionesCreditoCliente(True, Me.CveVenta) End If + ' si es empresa acumuladores + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + CargaPorcentajeMarcas() + End If UpFacturar.Update() UpEstatus.Update() @@ -5205,124 +5219,122 @@ Partial Class Ventas End Sub Private Sub CargaRestriccionesCreditoCliente(Optional Alertas As Boolean = False, Optional CveVenta As Integer = -1) - Dim ObjCliente As New ClsClientes() - If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then - If ObjCliente.DtResultados.Rows.Count > 0 Then - If UsuarioActual.Empresa.Funcionalidad(570) = "1" AndAlso ObjCliente.DtResultados.Rows(0)("PermiteCredito").ToString = "False" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta < 1 Then - RBLPago.SelectedValue = "2" - RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - If UsuarioActual.CveEmpresa.Contiene(119) AndAlso Not UsuarioActual.TienePermisoProceso(268) Then + + If UsuarioActual.Empresa.Funcionalidad(570) = "1" AndAlso Me.PermiteCredito = False AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta < 1 Then + RBLPago.SelectedValue = "2" + RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + If UsuarioActual.CveEmpresa.Contiene(119) AndAlso Not UsuarioActual.TienePermisoProceso(268) Then + DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") + DdlTipoComprobante.SelectedValue = "PA" + TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString + 'si llegó por la opción de cotización no debe de restringuir + If IfNull(Request("Op"), "").ToString = "Cot" Then DdlTipoComprobante.SelectedValue = "Cot" + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + LnkPedido2SinFacturar.Visible = False + LnkCotizaciones.Visible = False + End If + UPCondicionesPago.Update() + ElseIf UsuarioActual.CveEmpresa.Contiene(72, 119) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso CveVenta < 1 Then + RBLPago.SelectedValue = "1" + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() + Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero) + + If CreditoDispo > 0 Then + TrCreditoDisponible.Visible = True + LblCreditoDisponible.Text = CreditoDispo.FormatoNumero + If PorcentajeCredito > 80 Then TrPorcentajeCredito.Visible = True : LblPorcentajeCredito.Text = $"{PorcentajeCredito.FormatoNumero}%" + If UsuarioActual.CveEmpresa = 119 AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "PA") Then + + 'If LblRFC.Text.Trim <> "XAXX010101000" 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 + 'si la cotización no debe de existir este canddado + If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) + 'RBLPago.SelectedValue = "2" + 'RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") DdlTipoComprobante.SelectedValue = "PA" TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString 'si llegó por la opción de cotización no debe de restringuir If IfNull(Request("Op"), "").ToString = "Cot" Then DdlTipoComprobante.SelectedValue = "Cot" + 'quito remisión y factura DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) - LnkPedido2SinFacturar.Visible = False - LnkCotizaciones.Visible = False - End If - UPCondicionesPago.Update() - ElseIf UsuarioActual.CveEmpresa.Contiene(72, 119) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") AndAlso CveVenta < 1 Then - RBLPago.SelectedValue = "1" - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero) - - If CreditoDispo > 0 Then - TrCreditoDisponible.Visible = True - LblCreditoDisponible.Text = CreditoDispo.FormatoNumero - If PorcentajeCredito > 80 Then TrPorcentajeCredito.Visible = True : LblPorcentajeCredito.Text = $"{PorcentajeCredito.FormatoNumero}%" - If UsuarioActual.CveEmpresa = 119 AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "PA") Then - - 'If LblRFC.Text.Trim <> "XAXX010101000" 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 - 'si la cotización no debe de existir este canddado - If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) - 'RBLPago.SelectedValue = "2" - 'RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") - DdlTipoComprobante.SelectedValue = "PA" - TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString - 'si llegó por la opción de cotización no debe de restringuir - If IfNull(Request("Op"), "").ToString = "Cot" Then DdlTipoComprobante.SelectedValue = "Cot" - 'quito remisión y factura - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) - If Opcion = 1 Then - BtnEmitirImprimir.Visible = False - BtnsFacturar.Visible = False - BtnGenerarRemision.Visible = False - LnkPedido2SinFacturar.Visible = False - LnkCotizaciones.Visible = False - LnkOCs.Visible = False - End If - Else - ' el cliente tiene crédito disponible, no tiene bloqueo - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("PA")) - - If UsuarioActual.TienePermisoProceso(60) Then DdlTipoComprobante.SelectedValueExistInsert("Ing", "Ingresos") 'puede facturar - If UsuarioActual.TienePermisoProceso(199) Then DdlTipoComprobante.SelectedValueExistInsert("Rem", "Remisión") ' puede remisionar - DdlTipoComprobante.SelectedValueExist(UsuarioActual.CveTipoDocumento) - - TxtFechaPago.Text = If(DdlTipoComprobante.SelectedValue = "Rem", Now.AddDays(PlazoCobranzaRemision), Now.AddDays(PlazoCobranza)).ToShortDateString - End If - - 'Else - ' 'que no de crédito, solo contado - ' RBLPago.SelectedValue = "2" - ' RBLPago.Items(0).Enabled = False - 'End If - - End If - Else - - If UsuarioActual.CveEmpresa = 119 AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "Ant", "PA") 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 - If Opcion = 1 Then - BtnEmitirImprimir.Visible = False - End If - If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) - Else - If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia) - End If - - 'RBLPago.SelectedValue = "2" - 'RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") - DdlTipoComprobante.SelectedValue = "PA" - TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString - 'si llegó por la opción de cotización no debe de restringuir - If IfNull(Request("Op"), "").ToString = "Cot" Then DdlTipoComprobante.SelectedValue = "Cot" - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) - DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + If Opcion = 1 Then + BtnEmitirImprimir.Visible = False BtnsFacturar.Visible = False BtnGenerarRemision.Visible = False LnkPedido2SinFacturar.Visible = False LnkCotizaciones.Visible = False LnkOCs.Visible = False End If + Else + ' el cliente tiene crédito disponible, no tiene bloqueo + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("PA")) + + If UsuarioActual.TienePermisoProceso(60) Then DdlTipoComprobante.SelectedValueExistInsert("Ing", "Ingresos") 'puede facturar + If UsuarioActual.TienePermisoProceso(199) Then DdlTipoComprobante.SelectedValueExistInsert("Rem", "Remisión") ' puede remisionar + DdlTipoComprobante.SelectedValueExist(UsuarioActual.CveTipoDocumento) + + TxtFechaPago.Text = If(DdlTipoComprobante.SelectedValue = "Rem", Now.AddDays(PlazoCobranzaRemision), Now.AddDays(PlazoCobranza)).ToShortDateString End If - UPPCreditoDisponible.Update() - ElseIf UsuarioActual.CveEmpresa.Contiene(119, 1) AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso CveVenta > 0 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Pd2", "Cot") Or (DdlTipoComprobante.SelectedValue = "Rem" And ModalidadEdicion And ViewState("CveClienteAnterior").ToString.ToEntero > 0 And LblRFC.Text.Trim <> "XAXX010101000")) Then - Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero) + + 'Else + ' 'que no de crédito, solo contado + ' RBLPago.SelectedValue = "2" + ' RBLPago.Items(0).Enabled = False + 'End If + + End If + Else + + If UsuarioActual.CveEmpresa = 119 AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "Ant", "PA") 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 + If Opcion = 1 Then + BtnEmitirImprimir.Visible = False + End If + If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) + Else + If Alertas Then Alert("El cliente tiene su límite de crédito agotado.", TipoMensaje.MsgAdvertencia) + End If + + 'RBLPago.SelectedValue = "2" + 'RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() + DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización") + DdlTipoComprobante.SelectedValue = "PA" + TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString + 'si llegó por la opción de cotización no debe de restringuir + If IfNull(Request("Op"), "").ToString = "Cot" Then DdlTipoComprobante.SelectedValue = "Cot" + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) + DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem")) + BtnsFacturar.Visible = False + BtnGenerarRemision.Visible = False + LnkPedido2SinFacturar.Visible = False + LnkCotizaciones.Visible = False + LnkOCs.Visible = False + End If + End If + UPPCreditoDisponible.Update() + ElseIf UsuarioActual.CveEmpresa.Contiene(119, 1) AndAlso Not UsuarioActual.TienePermisoProceso(268) AndAlso CveVenta > 0 AndAlso (DdlTipoComprobante.SelectedValue.Contiene("Pd2", "Cot") Or (DdlTipoComprobante.SelectedValue = "Rem" And ModalidadEdicion And ViewState("CveClienteAnterior").ToString.ToEntero > 0 And LblRFC.Text.Trim <> "XAXX010101000")) Then + Dim CreditoDispo As Decimal = CargaCreditoDisponible(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero) If CreditoDispo > 0 Then Dim Vta As New ClsVentas Dim Opcion As Integer = Vta.ObtenerClienteLimitesVenta(CveCliente, UsuarioActual.CveEmpresa) @@ -5331,8 +5343,8 @@ Partial Class Ventas If Opcion > 0 Then If ModalidadEdicion AndAlso ViewState("CveCliente").ToString.ToEntero <> ViewState("CveClienteAnterior").ToString.ToEntero And DdlTipoComprobante.SelectedValue = "Rem" And ViewState("CveClienteAnterior").ToString.ToEntero > 0 And LblRFC.Text.Trim <> "XAXX010101000" Then ViewState("CveCliente") = ViewState("CveClienteAnterior").ToString.ToEntero - ObjCliente.Dispose() - CargaCliente(ViewState("CveCliente").ToString.ToEntero) + + CargaCliente(ViewState("CveCliente").ToString.ToEntero) If Opcion > 0 Then If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia) Else @@ -5382,9 +5394,7 @@ Partial Class Ventas End If End If End If - End If - End If - ObjCliente.Dispose() + End Sub @@ -5516,14 +5526,17 @@ Partial Class Ventas Return Retorno End Function Private Sub CargaDdlSubProyectos() - DdlSubProyectoDatos.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True ") + Dim dtt As New DataTable + dtt = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoDatos.DataSource = dtt.FiltraParametros("EsSucursal = True ") DdlSubProyectoDatos.DataBind() - DdlSubProyectoCobranza.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True ") + DdlSubProyectoCobranza.DataSource = dtt.FiltraParametros("EsSucursal = True ") DdlSubProyectoCobranza.DataBind() - DdlSubProyectoEjecucion.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True ") + DdlSubProyectoEjecucion.DataSource = dtt.FiltraParametros("EsSucursal = True ") DdlSubProyectoEjecucion.DataBind() - DdlSubProyectoPyME.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoPyME.DataSource = dtt DdlSubProyectoPyME.DataBind() + dtt.Dispose() End Sub Private Sub CargaClasificaciones() If UsuarioActual.Empresa.UsaAC Then @@ -5618,13 +5631,16 @@ Partial Class Ventas Public Sub CargaDdlNCPS() Dim CveSATNC = "84111506" - DdlNCPS.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC + Dim dtt As New DataTable + dtt = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC + DdlNCPS.DataSource = dtt DdlNCPS.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlNCPS.DataBind() - DdlNCPSAnt.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC + DdlNCPSAnt.DataSource = dtt DdlNCPSAnt.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlNCPSAnt.DataBind() + dtt.Dispose() End Sub #End Region @@ -15780,7 +15796,7 @@ Partial Class Ventas If ConSalida AndAlso Not OcurrioError Then If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then - OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura) + OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura, ObjConta:=ObjConta) End If If Not OcurrioError Then @@ -16136,7 +16152,7 @@ Partial Class Ventas Return Not OcurrioError End Function - Private Function GenerarMovimientoAlmacenVirtual(CveRemision As Integer, ByRef ObjInventario As ClsInventarios, ObjFactura As Modelos.Factura) As Boolean + Private Function GenerarMovimientoAlmacenVirtual(CveRemision As Integer, ByRef ObjInventario As ClsInventarios, ObjFactura As Modelos.Factura, Optional ByRef ObjConta As ClsContabilidad = Nothing) As Boolean Dim OcurrioError As Boolean = False Try @@ -16190,6 +16206,57 @@ Partial Class Ventas OcurrioError = True End If + 'Agregamos las PrePolizas + If Not OcurrioError Then + If CveMovimientoVirtual > 0 Then + 'OcurrioError = Not GeneraPrePolizaMovimientoAlmacen(ObjInventario, ObjConta, ObjContPaq, ObjFactura, ObjFactura.CvePrePoliza, CveMovimientoInventario, CveAlmacen) + If ObjInventario.GetMovimientosDetalle(CveMovimientoVirtual, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + Dim DtCostos = ObjInventario.DtResultados.Copy + Dim DtCostosDistinct As DataTable = ObjInventario.DtResultados.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + Dim ValorInventario As Decimal + Dim TotalCostoAcumulado As Decimal = 0D + Dim Cont As Integer = 1 + Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL + + For Each RowInv As DataRow In DtCostosDistinct.Rows + ValorInventario = DtCostos.SUMD("Total", String.Format("CveClasificacion = {0}", RowInv("CveClasificacion"))).RoundSQL + IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + TotalCostoAcumulado += ValorInventario + + 'cuando es el último movimiento y hay diferencias en los importes + If Cont = DtCostosDistinct.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then + ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) + End If + + Try + 'If ValorInventario <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ValorInventario, ObjFactura.SerieFolio, 69, ObjFactura.SerieFolio, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoVirtual, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta, CveSubProyecto:=ObjFactura.CveSubProyecto) Then + OcurrioError = True + Exit For + End If + 'End If + Catch ex As Exception + OcurrioError = True + Alert("Error inesperado (15148). Por favor comuniquese con atención SIG.", TipoMensaje.ToastError) + End Try + Cont += 1 + Next + + If Not OcurrioError Then + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacenVirtual)).ToEntero + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, TotalCosto, ObjFactura.SerieFolio, 68, ObjFactura.SerieFolio, ObjFactura.Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=ObjFactura.CveCliente, CveMovimientoAlmacen:=CveMovimientoVirtual, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=ObjFactura.CveSubProyecto) Then + OcurrioError = True + End If + End If + Else + OcurrioError = True + End If + End If + End If + End If Catch ex As Exception @@ -21953,7 +22020,7 @@ Partial Class Ventas #End Region #Region " APLICA DEVOLUCION " - Private Sub InicializaAplicaDevolucion() + Private Sub InicializaAplicaDevolucion(DtDetalle As DataTable) 'If Not UsuarioActual.CveUsuario = 100 Then ' If Not UsuarioActual.CveEmpresa.Contiene(72, 80, 119, 140, 141, 146) Then ' Exit Sub @@ -21967,13 +22034,13 @@ Partial Class Ventas LBAplicaDevolucion.Visible = True Dim SeEsconde As Boolean = False - Dim ObjVenta As New ClsVentas - If ObjVenta.GetVentaDetalle(CveVenta) Then - If Not ObjVenta.DtResultados.SUM("CantSur").ToString.ToDecimal > 0 Then SeEsconde = True + + If DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0 Then + If Not DtDetalle.SUM("CantSur").ToString.ToDecimal > 0 Then SeEsconde = True 'NO MOSTRAR LOS PRODUCTOS CON LA CLASIFICACION DE USADOS - GvAplicaDevolucion.DataSource = ObjVenta.DtResultados.FiltraParametros("CantRes > 0 AND CveClasificacion <> 20519") + GvAplicaDevolucion.DataSource = DtDetalle.FiltraParametros("CantRes > 0 AND CveClasificacion <> 20519") End If - ObjVenta.Dispose() + 'activo el permiso para registrar el importe diferente a la devolución GvAplicaDevolucion.Columns(9).Visible = UsuarioActual.TienePermisoProceso(253) @@ -24903,4 +24970,25 @@ Partial Class Ventas Protected Sub LnkGenerarOC_Click(sender As Object, e As EventArgs) Response.Redirect($"~/OC/OC.aspx?CveCotizacion={Me.CveVenta}&Tipo=OC") End Sub + + 'Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click + ' Dim ObjVentas As New ClsVentas + ' ObjVentas.IniciaTransacSQL() + + ' Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL()) + ' Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL()) + ' Dim ObjCGame As New ClsCGame(ObjVentas.IniciaTransacSQL()) + ' Dim ObjAC As ClsContPAQi = Nothing + + ' If Not RegeneracionPolizas(ObjVentas, ObjAC, ObjConta, ObjBancos) Then + ' ObjVentas.Commit() + ' If ObjAC IsNot Nothing Then ObjAC.Commit() + ' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, JSBtnAceptar:="BtnRefrescarPagina();") + ' End If + + ' ObjVentas.Dispose() + ' ObjConta.Dispose() + ' ObjBancos.Dispose() + ' If ObjAC IsNot Nothing Then ObjAC.Dispose() + 'End Sub End Class \ No newline at end of file