diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 5e970d841..1dac5ec5c 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -5270,6 +5270,24 @@ Public Class ClsVentas Return Retorno End Function + Public Function GetRNCSaldoNCRelacionadas(CveVentaRNC As Integer) As Boolean + Dim Retorno As Boolean = False + DataAdapter("PA_Vta_RNCSaldoNCRelacionadas") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveVentaRNC", SqlDbType.Int).Value = CveVentaRNC + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch ex As Exception + OnError("Ocurrió un error al obtener el saldo de la RNC.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + #End Region #Region "P O R C E N T A J E - C O M I S I O N E S" diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 1a35efe6f..7ad1dd517 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -313,6 +313,7 @@ Namespace Modelos Public CveMarca As Integer = -1 Public ObsDescuento As String = "" End Class + Public Class VentasBonificaciones Public CveVentaRNCCargo As Integer = -1 @@ -335,6 +336,22 @@ Namespace Modelos Public Property CveVentaDetalle As Integer Public Property Cantidad As Decimal End Class + + Public Class MConceptoUsado + Public Property Consecutivo As Integer + Public Property ConsecutivoUsado As Integer + Public Property CvePS As Integer + End Class + + Public Class MFolioGarantiaMensaje + Public Property CvePS As Integer + Public Property CveClasificacionPS As Integer + Public Property ClasificacionPS As String + Public Property CveFolioGarantia As Integer + Public Property TipoFolio As String + + Public Property Valido As Boolean + End Class Public Enum TipoMensajeRespuesta TextoLimpio = 0 HTML = 1 @@ -4838,6 +4855,25 @@ Namespace Modelos Dim TieneAlmacen As Boolean = False Dim AplicaRefacturacionConPagos As Boolean = False + 'VALIDA QUE LA RNC NO TENGA EGS CON SALDO + If ObjFactura.TipoDocto = "RNC" Then + Dim TotalRNC As Decimal = ObjFactura.Total + Dim SaldoRNC As Decimal = 0 + Using ObjRNC As New ClsVentas + If ObjRNC.GetRNCSaldoNCRelacionadas(ObjFactura.CveVenta) AndAlso ObjRNC.DtResultados.Rows.Count > 0 Then + SaldoRNC = ObjRNC.DtResultados.FiltroPrimeroValor("SaldoRNC", "CveVentaEGS IS NULL").ToDecimal() + End If + End Using + + 'SI TIENE SALDO PENDIENTE POR CANCELAR DE LAS NOTAS DE CREDITO, NO PERMITIR CANCELAR + If SaldoRNC <= 0 OrElse (SaldoRNC <> TotalRNC) Then + Retorno.Mensaje = "La remisión no se puede cancelar debido a que tiene notas de credito vigentes" + Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia + + Return Retorno + End If + End If + Dim CveEstatusRefacturacion As Integer = If(ObjFactura.CveEstatusRefacturacion <= 0, 0, ObjFactura.CveEstatusRefacturacion) 'SI YA FUE MARCADA COMO REFACTURACION Y FUE SEPARADA, MANTENER EL COMPORTAMIENTO DE CANCELACION COMO REFACTURACION diff --git a/Ventas/PV.aspx.vb b/Ventas/PV.aspx.vb index 15461fbff..fb2eae807 100644 --- a/Ventas/PV.aspx.vb +++ b/Ventas/PV.aspx.vb @@ -4261,7 +4261,7 @@ Partial Class PV End If 'Descuento por clasificación - Dim ObjDescuento As New Descuentos + Dim ObjDescuento As New Modelos.VentaDescuentos ObjDescuento = CalcularDescuentos(CvePSParametro, TxtCantidad.Text.Trim.ToDecimal, PrecioSugerido) If ObjDescuento.EsPUModificado Then @@ -4310,15 +4310,7 @@ Partial Class PV UPPDescuento.Update() End Sub - Partial Class Descuentos - Public ImporteDescuento As Decimal = 0 - Public CvePromocionDetalle As Integer = -1 - Public PU As Decimal = 0 - Public EsPUModificado As Boolean = False - Public ImporteProntoPago As Decimal = 0 - End Class - - Private Function CalcularDescuentos(CvePS As Integer, Cantidad As Decimal, PU As Decimal) As Descuentos + Private Function CalcularDescuentos(CvePS As Integer, Cantidad As Decimal, PU As Decimal) As Modelos.VentaDescuentos Dim Descuento As Decimal = HdnDescuento.Value.ToDecimal If HdnTipoDescuento.Value = "0" Then @@ -4341,7 +4333,7 @@ Partial Class PV Dim CvePromocionDetalle As Integer = 0 Dim IncluyeImpuestos As Boolean = False Dim TipoAplicacion As Integer = 1 ' 1 - descuento, 2 en PU - Dim ObjDescuento As New Descuentos + Dim ObjDescuento As New Modelos.VentaDescuentos If DdlSubProyectoDatos.SelectedValue = "11842" Then '' E141, el subproyecto: Franquicia, no proceden las promociones Return ObjDescuento @@ -5483,7 +5475,7 @@ Partial Class PV Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlPS.SelectedValue.ToEntero).FiltroPrimero("") If ChkAjuste.Checked Then - Dim FolioGarantia As MFolioGarantiaMensaje = ValidaFolioGarantia(DdlPSAjuste.SelectedValue.ToEntero(), DdlFolioGarantia.SelectedValue.ToEntero()) + Dim FolioGarantia As Modelos.MFolioGarantiaMensaje = ValidaFolioGarantia(DdlPSAjuste.SelectedValue.ToEntero(), DdlFolioGarantia.SelectedValue.ToEntero()) If Not FolioGarantia.Valido Then Alert($"El folio de garantía no es valido.
Clasificacion del Producto:{FolioGarantia.ClasificacionPS}.
Tipo Folio:{FolioGarantia.TipoFolio}", TipoMensaje.MsgAdvertencia) @@ -5571,7 +5563,7 @@ Partial Class PV Descuento = HdnDescuento.Value.ToDecimal * TxtCantidad.Text.ToDecimal End If - Dim ObjDescuento As New Descuentos + Dim ObjDescuento As New Modelos.VentaDescuentos If DrPS("CveClasificacion").ToString.ToEntero.Contiene(20516, 20515) Then ObjDescuento.ImporteDescuento = ((Cantidad * PU) * ClasificacionesDescuentos(DrPS("CveClasificacion").ToString.ToEntero)) End If @@ -5595,7 +5587,7 @@ Partial Class PV CveProyecto, Proyecto, DdlSubProyectoDatos.SelectedValue.ToEntero, DdlSubProyectoDatos.SelectedItem.Text, Serie:="", TiempoEntrega:="", CuentaPredial:="", RegeneraIEPS:=ClienteDesglosaIEPS, CveVentaDetalle:=CveVentaDetalle, EsCargo:=EsCargo) - Dim ListaPSCargo As List(Of MConceptoUsado) = Nothing + Dim ListaPSCargo As List(Of Modelos.MConceptoUsado) = Nothing If CveVentaDetalle <= 0 AndAlso Not EsCargo Then ListaPSCargo = CalculaUsados(Consec) ElseIf CveVentaDetalle > 0 AndAlso Not EsCargo Then @@ -5605,7 +5597,7 @@ Partial Class PV If ListaPSCargo IsNot Nothing AndAlso ListaPSCargo.Count > 0 Then CalculaRecepcionUsados(CvePS, ListaPSCargo, Cantidad, Consec) - For Each Usado As MConceptoUsado In ListaPSCargo + For Each Usado As Modelos.MConceptoUsado In ListaPSCargo AddPolizaVirtual(DdlPS.SelectedValue.ToEntero(), Usado.Consecutivo) Next End If @@ -7422,7 +7414,7 @@ Partial Class PV Alert("No se ha especificado producto de ajuste a entregar") Exit Sub End If - If TxtEtiqueta.Text <> "" OrElse TxtEtiqueta.Text.Length <> 4 Then + If TxtEtiqueta.Text = "" OrElse TxtEtiqueta.Text.Length <> 4 Then Alert("No se ha especificado la etiqueta.") Exit Sub End If @@ -7441,8 +7433,8 @@ Partial Class PV If ObjAcum.GarantiasMesesGet(-1, UsuarioActual.CveEmpresa, CveMarca, DdlTipoUso.SelectedValue.ToEntero, TxtMesesUso.Text.ToEntero) Then If ObjAcum.DtResultados.Rows.Count > 0 Then ''obtener siempre y cuando la fecha de inicio sea mayor - Dim strDate As Date = ($"01/{TxtEtiqueta.Text.Substring(0, 2)}/{TxtEtiqueta.Text.Substring(2, 2)}").ToDate - Dim drg As DataRow = ObjAcum.DtResultados.FiltroPrimero($" #{strDate.ToString("yyyy/MM/dd")}# > FechaInicioVigencia ", "FechaInicioVigencia") + Dim strDate As Date = ($"20{TxtEtiqueta.Text.Substring(2, 2)}/{TxtEtiqueta.Text.Substring(0, 2)}/01").ToDate + Dim drg As DataRow = ObjAcum.DtResultados.FiltroPrimero($" #{strDate.ToString("yyyy/MM/dd")}# >= FechaInicioVigencia ", "FechaInicioVigencia DESC") If drg IsNot Nothing Then TxtPorcentajeAjuste.Text = (drg("Valor").ToString.ToDouble / 100).ToString @@ -7699,7 +7691,7 @@ Partial Class PV End If ObjAcumuladores.Dispose() - Dim FolioGarantia As MFolioGarantiaMensaje = ValidaFolioGarantia(DdlPSAjuste.SelectedValue.ToEntero(), DdlFolioGarantia.SelectedValue.ToEntero()) + Dim FolioGarantia As Modelos.MFolioGarantiaMensaje = ValidaFolioGarantia(DdlPSAjuste.SelectedValue.ToEntero(), DdlFolioGarantia.SelectedValue.ToEntero()) If Not FolioGarantia.Valido Then Alert($"El folio de garantía no es valido.
Clasificacion del Producto:{FolioGarantia.ClasificacionPS}.
Tipo Folio:{FolioGarantia.TipoFolio}", TipoMensaje.MsgAdvertencia) @@ -7855,7 +7847,7 @@ Partial Class PV EmitirImprimirNew() End Sub - Private Sub CalculaRecepcionUsados(CvePS As Integer, ListaPSCargo As List(Of MConceptoUsado), CantidadUsado As Decimal, ConsecPSPadre As Integer) + Private Sub CalculaRecepcionUsados(CvePS As Integer, ListaPSCargo As List(Of Modelos.MConceptoUsado), CantidadUsado As Decimal, ConsecPSPadre As Integer) If Modalidad = "U" Then If TmpDTRecepcionUsados.Rows.Count > 0 Then @@ -7934,7 +7926,7 @@ Partial Class PV End If Dim StrCargos As New StringBuilder - For Each Usado As MConceptoUsado In ListaPSCargo + For Each Usado As Modelos.MConceptoUsado In ListaPSCargo StrCargos.AppendFormat(" {0},", Usado.CvePS) Next StrCargos.Remove(StrCargos.Length - 1, 1) @@ -8052,17 +8044,13 @@ Partial Class PV CalculaTotalesVenta() End Sub - Public Class MConceptoUsado - Public Property Consecutivo As Integer - Public Property ConsecutivoUsado As Integer - Public Property CvePS As Integer - End Class - Private Function CalculaUsados(Consec As Integer, Optional LimpiarUsados As Boolean = True) As List(Of MConceptoUsado) + + Private Function CalculaUsados(Consec As Integer, Optional LimpiarUsados As Boolean = True) As List(Of Modelos.MConceptoUsado) If Modalidad = "U" AndAlso LimpiarUsados Then EliminarUsados(Consec) End If - Dim ListaPScargo As New List(Of MConceptoUsado) + Dim ListaPScargo As New List(Of Modelos.MConceptoUsado) Dim DTTamanios As DataTable = GlobalDTAcumTamaños(UsuarioActual.CveEmpresa) Dim DTCvePSCostos = DTTamanios.FiltraParametros("", "", {"CvePSCargo"}) @@ -8167,7 +8155,7 @@ Partial Class PV drowPsTamaños("PS").ToString, "", drowPsTamaños("PU").ToString.ToDecimal, 0, -1, "", drowPsTamaños("CveSubProyecto").ToString.ToEntero, drowPsTamaños("SubProyecto").ToString, EsCargo:=True, ConsecPSPadre:=drowPsTamaños("ConsecPSPadre").ToString.ToEntero, EliminarDB:=CBool(drowPsTamaños("EliminarDB").ToString())) If Consec > 0 Then - ListaPScargo.Add(New MConceptoUsado() With {.Consecutivo = Consec, .ConsecutivoUsado = ConsecutivoUsado, .CvePS = drowPsTamaños("CvePS").ToString.ToEntero}) + ListaPScargo.Add(New Modelos.MConceptoUsado() With {.Consecutivo = Consec, .ConsecutivoUsado = ConsecutivoUsado, .CvePS = drowPsTamaños("CvePS").ToString.ToEntero}) End If End If Next @@ -8328,8 +8316,8 @@ Partial Class PV End Sub - Private Function ValidaFolioGarantia(CvePS As Integer, CveFolioGarantia As Integer) As MFolioGarantiaMensaje - Dim Retorno As New MFolioGarantiaMensaje + Private Function ValidaFolioGarantia(CvePS As Integer, CveFolioGarantia As Integer) As Modelos.MFolioGarantiaMensaje + Dim Retorno As New Modelos.MFolioGarantiaMensaje Dim Valido As Boolean = False Dim TipoFolio As String = "" @@ -8382,15 +8370,7 @@ Partial Class PV Return Retorno End Function - Partial Class MFolioGarantiaMensaje - Public Property CvePS As Integer - Public Property CveClasificacionPS As Integer - Public Property ClasificacionPS As String - Public Property CveFolioGarantia As Integer - Public Property TipoFolio As String - Public Property Valido As Boolean - End Class Protected Sub DdlMarcaPS_SelectedIndexChanged(sender As Object, e As EventArgs) CargaPS(DdlClasificacion.SelectedValue.ToEntero(), DdlPS, CveMarca:=DdlMarcaPS.SelectedValue.ToEntero()) UpModalVenta.Update() diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 45e3ad0ea..124bdc6fa 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -1675,12 +1675,7 @@ - - - - Almacen - - + <%-- diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 7028d4086..e030db63d 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2354,7 +2354,10 @@ Partial Class Ventas Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - If UsuarioActual.CveEmpresa.Contiene(141, 152, 153, 160, 161, 162) Then System.Threading.Thread.Sleep(2000) + If EsProduccion Then + If UsuarioActual.CveEmpresa.Contiene(141, 152, 153, 160, 161, 162) Then System.Threading.Thread.Sleep(2000) + End If + If Not IsPostBack Then If IfNull(Request("Opcionx"), "").ToString = "Saldar" And UsuarioActual.CveUsuario = 100 Then @@ -2847,7 +2850,7 @@ Partial Class Ventas If CveVenta <= 0 Then 'REMOVER EVENTO PARA RECARGAR ALMACEN HdnCargarInventario.Value = "False" - spanAlmacen.Attributes.Remove("onclick") + 'spanAlmacen.Attributes.Remove("onclick") Tab.ActiveTabIndex = 1 Updatetabs.Update() End If @@ -15323,6 +15326,22 @@ Partial Class Ventas End If End If + Dim ModalidadRefacturacion As Integer = UsuarioActual.Empresa.Funcionalidad(586).ToEntero() + + 'REFACTURACION CON PAGOS, DEBE CANCELAR SALDOS DEL DOCUMENTO ANTERIOR Y TRASPASAR PAGOS AL NUEVO + If ModalidadRefacturacion = 2 AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Ant") AndAlso ObjFactura.NuevaFactura = 1 Then + If Not ObjConta.TraspasarSaldosPrePolizasRefacturacion(ObjFacturaNC.CveVenta, ObjFactura.CveVenta, ObjFactura.CvePrePoliza, CvePlantilaPoliza, UsuarioActual.CveEmpresa) Then + ErrorList.Add("Ocurrió un error al traspasos saldos en refacturación") + End If + Else + 'EN CASO DE SER REFACTURACION DE ANTICIPO SE ACTUALIZAN LAS VENTAS APLICADAS HACIA EL NUEVO + If NuevaFactura = 1 AndAlso CveDevolucion > 0 AndAlso ObjFactura.TipoDocto.Contiene("Ant") Then + If Not ObjVentas.TraspasaVentasAplicadasAnt(ObjFactura.CveVenta, CveDevolucion, UsuarioActual.CveEmpresa, ObjFactura.CvePrePoliza) Then + ErrorPrepoliza = True + End If + End If + End If + If ObjConta.ValidacionPrePolizaCuadre(ObjFactura.CvePrePoliza, 2) Then If ObjConta.ValorPolizaDescuadre > 0 Then If ObjConta.ValorPolizaDescuadre = 2 Then @@ -15339,21 +15358,6 @@ Partial Class Ventas End If End If - 'EN CASO DE SER REFACTURACION DE ANTICIPO SE ACTUALIZAN LAS VENTAS APLICADAS HACIA EL NUEVO - If NuevaFactura = 1 AndAlso CveDevolucion > 0 AndAlso ObjFactura.TipoDocto.Contiene("Ant") Then - If Not ObjVentas.TraspasaVentasAplicadasAnt(ObjFactura.CveVenta, CveDevolucion, UsuarioActual.CveEmpresa, ObjFactura.CvePrePoliza) Then - ErrorPrepoliza = True - End If - End If - - Dim ModalidadRefacturacion As Integer = UsuarioActual.Empresa.Funcionalidad(586).ToEntero() - - 'REFACTURACION CON PAGOS, DEBE CANCELAR SALDOS DEL DOCUMENTO ANTERIOR Y TRASPASAR PAGOS AL NUEVO - If ModalidadRefacturacion = 2 AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Ant") AndAlso ObjFactura.NuevaFactura = 1 Then - If Not ObjConta.TraspasarSaldosPrePolizasRefacturacion(ObjFacturaNC.CveVenta, ObjFactura.CveVenta, ObjFactura.CvePrePoliza, CvePlantilaPoliza, UsuarioActual.CveEmpresa) Then - ErrorList.Add("Ocurrió un error al traspasos saldos en refacturación") - End If - End If Return ErrorPrepoliza Catch ex As Exception @@ -23103,7 +23107,7 @@ Partial Class Ventas Dim TienePagos As Boolean = ((Not (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0)) AndAlso (DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0)) OrElse AmortizacionNC > 0 'SI LA VENTA ES NUEVA VALIDAR TAMBIEN LOS PAGOS DE CONTADO - If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso CveVenta <= 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then + If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso ((CveVenta <= 0 OrElse EsCreaApartirDe OrElse TipoDoctoViejo = "Cot") AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant")) Then If Not PermiteCredito AndAlso Not TienePagos AndAlso TxtTotal.Text.ToDecimal > 0 Then If MostrarAlertas Then @@ -23576,6 +23580,13 @@ Partial Class Ventas DivDevAlm.Visible = True TieneAlmacen = True End If + If DdlTipoComprobante.SelectedValue.Contiene("Rem", "Dev") Then + ChkDevAlm.Checked = True + LiDevolucionAlmacen.Visible = True + If DdlTipoComprobante.SelectedValue = "Dev" Then + LblDevAlm.Text = "Salida de almacen" + End If + End If CargaGVInv(ObjInv.DtResultados) End If End If @@ -24748,14 +24759,6 @@ Partial Class Ventas Dim RowVenta As DataRow = ObjVentas.DtResultados.Rows(0) SaldoAlmacen = RowVenta("SaldoAlmacen").ToString().ToDecimal() - - If DdlTipoComprobante.SelectedValue.Contiene("Rem", "Dev") AndAlso SaldoAlmacen <> 0 Then - ChkDevAlm.Checked = True - LiDevolucionAlmacen.Visible = True - If DdlTipoComprobante.SelectedValue = "Dev" Then - LblDevAlm.Text = "Salida de almacen" - End If - End If Else PermiteCancelar = False End If @@ -24763,19 +24766,26 @@ Partial Class Ventas PermiteCancelar = False End If - If PermiteCancelar And SaldoVenta <> 0 Then - If UsuarioActual.TienePermisoProceso(269) AndAlso Not DevolucionAlmacen = 2 Then - DivDevAlm.Visible = True - TieneAlmacen = True - End If - End If - End Using If Not PermiteCancelar Then Alert("La venta no se puede cancelar si no ha sido surtida previamente", TipoMensaje.MsgAdvertencia) Exit Sub End If + + If SaldoVenta <> 0 Then + + If UsuarioActual.TienePermisoProceso(269) AndAlso Not DevolucionAlmacen = 2 Then + DivDevAlm.Visible = True + TieneAlmacen = True + + If UsuarioActual.Empresa.Funcionalidad(567) = "1" Then + ChkDevAlm.Checked = True + ChkDevAlm.Enabled = False + End If + End If + End If + End If If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Dev", "Egs") Then @@ -32899,7 +32909,7 @@ Partial Class Ventas End If 'REMOVER EVENTO PARA RECARGAR ALMACEN - spanAlmacen.Attributes.Remove("onclick") + 'spanAlmacen.Attributes.Remove("onclick") Tab.ActiveTabIndex = 1 HdnCargarInventario.Value = "False" Updatetabs.Update() @@ -36587,10 +36597,11 @@ Partial Class Ventas End If 'REMOVER EVENTO PARA RECARGAR ALMACEN - spanAlmacen.Attributes.Remove("onclick") - Tab.ActiveTabIndex = 1 + 'spanAlmacen.Attributes.Remove("onclick") + 'Tab.ActiveTabIndex = 1 HdnCargarInventario.Value = "False" - Updatetabs.Update() + 'Updatetabs.Update() + UpINV.Update() End Sub Protected Sub LBAplicaDevolucion_Click(sender As Object, e As EventArgs)