--Cambios en los tipos de venta

This commit is contained in:
2025-03-29 16:44:23 -07:00
parent 2bf9dde3fa
commit 32ef9142e1
5 changed files with 278 additions and 125 deletions

View File

@@ -5275,6 +5275,13 @@ Partial Class Ventas
EsNCDevolucionEfectivo = True
End If
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
If Not String.IsNullOrEmpty(DbRowVenta("TipoVenta").ToString()) Then
TrTipoVentaEgs.Visible = True
LblTipoVentaEGS.Text = DbRowVenta("TipoVenta").ToString()
End If
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"))
@@ -10210,45 +10217,10 @@ Partial Class Ventas
End If
If PermiteAutorizacion Then
Dim ImporteAutorizacion As Decimal = 0
Dim TipoAutorizacion As Integer = 0
Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero()
Dim ObjVentas As New ClsVentas
If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, "Egs", CveEstatus:=1) Then
Dim RowAutorizacion As DataRow = Nothing
'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Egs'", Orderby:="Importe DESC")
If RowAutorizacion IsNot Nothing Then
ImporteAutorizacion = RowAutorizacion("Importe").ToString().ToDecimal()
CveAutorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
TipoAutorizacion = RowAutorizacion("TipoAutorizacion").ToString().ToEntero()
End If
End If
ObjVentas.Dispose()
If TipoAutorizacion = 1 Then
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
Dim BloquearCredito As Boolean = True
CveAutorizacion = -1
If BloquearCredito Then
Alert($"El importe autorizado es insuficiente. Importe autorizado:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
Else
CveAutorizacion = -1
Alert($"No se encontro una autorización de crédito.", TipoMensaje.MsgAdvertencia)
VerificaAutorizacionEgs(VerificarImportes:=True)
If Me.CveAutorizacion <= 0 Then
Exit Sub
End If
End If
End If
@@ -10532,6 +10504,50 @@ Partial Class Ventas
EmitirImprimirNew(TipoDoctoViejo)
End Sub
Private Sub VerificaAutorizacionEgs(Optional VerificarImportes As Boolean = True)
Dim ImporteAutorizacion As Decimal = 0
Dim TipoAutorizacion As Integer = 0
Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero()
Dim ObjVentas As New ClsVentas
If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, "Egs", CveEstatus:=1) Then
Dim RowAutorizacion As DataRow = Nothing
'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='Egs'", Orderby:="Importe DESC")
If RowAutorizacion IsNot Nothing Then
ImporteAutorizacion = RowAutorizacion("Importe").ToString().ToDecimal()
CveAutorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
TipoAutorizacion = RowAutorizacion("TipoAutorizacion").ToString().ToEntero()
End If
End If
ObjVentas.Dispose()
If TipoAutorizacion = 1 Then
If VerificarImportes Then
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
Dim BloquearCredito As Boolean = True
CveAutorizacion = -1
If BloquearCredito Then
Alert($"El importe autorizado es insuficiente. Importe autorizado:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
Else
CveAutorizacion = -1
Alert($"No se encontro una autorización de crédito.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End Sub
#End Region
#Region " NNNNEEEEEEEWWWWWW "
@@ -14644,31 +14660,49 @@ Partial Class Ventas
End If
End If
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso factura.TipoDocto = "Egs" AndAlso Not factura.EsGarantia Then
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
CveTipoVentaGuardar = -1
If NCDescuento Then
If ListaNCDescuento IsNot Nothing AndAlso ListaNCDescuento.Count > 0 Then
'VERIFICA SI BONIFICACION
If ListaNCDescuento.Any(Function(RNC) (RNC.Num1 = 2)) Then
CveTipoVentaGuardar = 7 ' BONIFICACION
ElseIf ListaNCDescuento.Any(Function(RNC) (RNC.Num1 = 1)) Then
CveTipoVentaGuardar = 9 ' CANCELACION DE USADOS
If factura.TipoDocto = "Egs" AndAlso Not factura.EsGarantia Then
If NCDescuento Then
If ListaNCDescuento IsNot Nothing AndAlso ListaNCDescuento.Count > 0 Then
'VERIFICA SI BONIFICACION
If ListaNCDescuento.Any(Function(RNC) (RNC.Num1 = 2)) Then
CveTipoVentaGuardar = 7 ' BU - BONIFICACION DE USADO
ElseIf ListaNCDescuento.Any(Function(RNC) (RNC.Num1 = 1)) Then
CveTipoVentaGuardar = 9 ' CU - CANCELACION DE USADO
End If
End If
End If
Else
If ListaRemisionesNC IsNot Nothing AndAlso ListaRemisionesNC.Count > 0 Then
'VERIFICA SI BONIFICACION
If ListaRemisionesNC.Any(Function(RNC) (RNC.Num1 = 2)) Then
CveTipoVentaGuardar = 7 ' BONIFICACION
ElseIf ListaRemisionesNC.Any(Function(RNC) (RNC.Num1 = 1)) Then
CveTipoVentaGuardar = 9 ' CANCELACION DE USADOS
Else
If ListaRemisionesNC IsNot Nothing AndAlso ListaRemisionesNC.Count > 0 Then
'VERIFICA SI BONIFICACION
If ListaRemisionesNC.Any(Function(RNC) (RNC.Num1 = 2)) Then
CveTipoVentaGuardar = 7 ' BU - BONIFICACION DE USADO
ElseIf ListaRemisionesNC.Any(Function(RNC) (RNC.Num1 = 1)) Then
CveTipoVentaGuardar = 9 ' CU - CANCELACION DE USADO
End If
End If
End If
End If
End If
'GA - GARANTIAS Y AJUSTES
If factura.TipoDocto = "Egs" AndAlso factura.EsGarantia Then CveTipoVentaGuardar = 11
'DM - DEVOLUCION DE MERCANCIA
If factura.TipoDocto = "Dev" Then CveTipoVentaGuardar = 10
'SI TIENE TIPO VENTA LA AUTORIZACION TOMAR DE AHI
If factura.TipoDocto = "Egs" AndAlso Me.CveAutorizacion > 0 Then
If ObjVentas.GetAutorizacion(Me.CveAutorizacion, UsuarioActual.CveEmpresa) Then
If ObjVentas.DtResultados.FiltroPrimeroValor("CveTipoVenta").ToEntero() > 0 Then CveTipoVentaGuardar = ObjVentas.DtResultados.FiltroPrimeroValor("CveTipoVenta").ToEntero()
End If
End If
End If
If Not ObjVentas.AddVenta(factura.TipoDocto, factura.Folio, factura.CveCliente, factura.CveClienteSucursal, factura.SubTotalTC, factura.DescuentoTC,
factura.AmortizacionTC, factura.IVATC, factura.RetIVATC, factura.RetISRTC,
factura.TotalTC, factura.CveMoneda, factura.TipoCambio, factura.CveMetodoPago, factura.CondicionesPago, 0, factura.FechaPago, factura.Fecha, factura.MotivoDescuento,
@@ -31844,6 +31878,18 @@ Partial Class Ventas
BtnEmitirImprimir.Visible = True
End If
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Me.CveAutorizacion > 0 Then
Using ObjVentas As New ClsVentas
If ObjVentas.GetAutorizacion(CveAutorizacion, UsuarioActual.CveEmpresa) Then
If Not String.IsNullOrEmpty(ObjVentas.DtResultados.FiltroPrimeroValor("TipoVenta")) Then
TrTipoVentaEgs.Visible = True
TxtObsFact.Text = $"{ObjVentas.DtResultados.FiltroPrimeroValor("TipoVenta")}"
UPObservaciones.Update()
End If
End If
End Using
End If
Catch ex As Exception
OnError("Ocurrió un error al aplicar NC", ex)
End Try
@@ -36380,10 +36426,19 @@ Partial Class Ventas
Select Case RblRNCTipo.SelectedValue
Case "1" 'CARGOS
NCConcepto = ArrayNC(3).ToEntero()
If DivTipoVentaAsingado.Visible Then
LblTipoVentaAsignado.Text = "CU - CANCELACION DE USADO "
End If
Case "2" 'BONIFICACIONES
NCConcepto = ArrayNC(4).ToEntero()
If DivTipoVentaAsingado.Visible Then
LblTipoVentaAsignado.Text = "BU - BONIFICACION DE USADO"
End If
Case "3" 'AJUSTE/GARANTIAS
NCConcepto = ArrayNC(1).ToEntero()
If DivTipoVentaAsingado.Visible Then
LblTipoVentaAsignado.Text = "GA - GARANTIAS Y AJUSTES"
End If
End Select
'CARGOS/AJUSTES POR GARANTIA POR PRODUCTO
@@ -36455,6 +36510,7 @@ Partial Class Ventas
Exit For
End If
Next
'CARGOS/AJUSTES POR GARANTIA POR TOTAL
ElseIf RblRNCTipo.SelectedValue.Contiene("1", "3") AndAlso Not ChkMostarProductosRNC.Checked Then
@@ -36574,6 +36630,7 @@ Partial Class Ventas
Exit For
End If
Next
'BONIFICACIONES POR TOTAL
ElseIf RblRNCTipo.SelectedValue.Contiene("2") AndAlso Not ChkMostarProductosRNCBon.Checked Then
For Each GvRow As GridViewRow In GvRemisionesNCBon.Rows
@@ -38385,6 +38442,7 @@ Partial Class Ventas
End If
TxtImporteSolicitud.Text = ""
DdlSolCreditoTipoDocto_SelectedIndexChanged(Nothing, EventArgs.Empty)
RegistraScript("$('#DivModalSolicitarCredito').modal('show')")
UpModalSolicitud.Update()
End Sub
@@ -38427,9 +38485,18 @@ Partial Class Ventas
End If
Dim Motivo As String = TxtMotivoAutorizacion.Text
Dim CveTipoVenta As Integer = -1
If DdlTipoVentaSolCredito.SelectedValue.ToEntero() > 0 Then
CveTipoVenta = DdlTipoVentaSolCredito.SelectedValue.ToEntero()
End If
If CveTipoVenta <= 0 AndAlso TipoDocto = "Egs" Then
Alert("Debe seleccionar un tipo de venta", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim ObjPS As New ClsVentas
If ObjPS.AddAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero(), TxtImporteSolicitud.Text.ToDecimal(), CveEstatus, UsuarioActual.CveUsuario, CveTipoAutorizacion, TipoDocumento:=DdlSolCreditoTipoDocto.SelectedValue, DiasVencidos:=DiasVencidos, Motivo:=Motivo) Then
If ObjPS.AddAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, DdlVendedor.SelectedValue.ToEntero(), TxtImporteSolicitud.Text.ToDecimal(), CveEstatus, UsuarioActual.CveUsuario, CveTipoAutorizacion, TipoDocumento:=DdlSolCreditoTipoDocto.SelectedValue, DiasVencidos:=DiasVencidos, Motivo:=Motivo, CveTipoVenta:=CveTipoVenta) Then
RegistraScript("$('#DivModalSolicitarCredito').modal('hide')")
Alert("La autorización se agregó correctamente.", TipoMensaje.MsgInformacion)
'signal
@@ -38460,10 +38527,16 @@ Partial Class Ventas
DdlTipoAutorizacion.Items.Insert(0, New ListItem("Vencimiento", "2"))
DivMotivoAutorizacion.Visible = True
End If
DivTipoVentaSol.Visible = False
Case "Egs"
'QUITAR LA DE VENCIMIENTO
DdlTipoAutorizacion.Items.Remove(DdlTipoAutorizacion.Items.FindByValue("2"))
DivMotivoAutorizacion.Visible = True
DivTipoVentaSol.Visible = True
DdlTipoVentaSolCredito.DataSource = GlobalDTTipoVenta(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' AND TipoDocto = 'Egs' AND CveTipoVenta NOT IN (7,9,10,11) ")
DdlTipoVentaSolCredito.DataBind()
DdlTipoVentaSolCredito.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Select
UpModalSolicitud.Update()
End Sub
@@ -40482,7 +40555,7 @@ Partial Class Ventas
Protected Sub LBNotaCredito_Click(sender As Object, e As EventArgs)
CargaDdlNCPS()
DivTipoVentaAsingado.Visible = False
If CveVenta <= 0 Then 'cuando es nueva la factura
DivGvCxC.Visible = True
CargaCxC()
@@ -40490,6 +40563,24 @@ Partial Class Ventas
UpAplicarNC.Update()
'CARGAR RNC
RblRNCTipo_SelectedIndexChanged(RblRNCTipo, EventArgs.Empty)
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
VerificaAutorizacionEgs(VerificarImportes:=True)
If Me.CveAutorizacion <= 0 Then
Exit Sub
Else
Using ObjVentas As New ClsVentas
If ObjVentas.GetAutorizacion(Me.CveAutorizacion, UsuarioActual.CveEmpresa) Then
If ObjVentas.DtResultados.FiltroPrimeroValor("CveTipoVenta").ToEntero() > 0 Then
DivTipoVentaAsingado.Visible = True
LblTipoVentaAsignado.Text = ObjVentas.DtResultados.FiltroPrimeroValor("TipoVenta")
DdlNCPS.Enabled = True
End If
End If
End Using
End If
End If
RegistraScript("$('#ModalAplicarNC').modal('show');", "ModalNC")
End Sub