This commit is contained in:
Hector Javier Rodriguez Flores
2021-09-26 20:44:36 -07:00
24 changed files with 512 additions and 229 deletions

View File

@@ -6216,7 +6216,7 @@ Partial Class Ventas
Dim ValorAutorizacion As String = UsuarioActual.Empresa.Funcionalidad(595)
'OBLIGAR PAGO DE CONTADO SI EL CLIENTE NO PERMITE CREDITO
If UsuarioActual.Empresa.Funcionalidad(570) = "1" AndAlso Me.PermiteCredito = False AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta <= 0 Then
If UsuarioActual.Empresa.Funcionalidad(570) = "1" AndAlso Me.PermiteCredito = False AndAlso ((DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") AndAlso CveVenta < 1) OrElse (DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") AndAlso EsCreaApartirDe)) Then
RBLPago.SelectedValue = "2"
RBLPago.Items(0).Enabled = False
RBLPago_SelectedIndexChanged(Nothing, Nothing)
@@ -6234,12 +6234,14 @@ Partial Class Ventas
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem"))
LnkPedido2SinFacturar.Visible = False
LnkCotizaciones.Visible = False
BtnsFacturar.Visible = False
End If
UPCondicionesPago.Update()
'CARGAR CREDITO DISPONIBLE AL GENERAR UNA FACTURA
End If
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot", "PA") 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
RBLPago.SelectedValue = "1"
RBLPago_SelectedIndexChanged(Nothing, Nothing)
@@ -6252,7 +6254,7 @@ Partial Class Ventas
LblCreditoDisponible.Text = CreditoDispo.FormatoNumero
If PorcentajeCredito > 80 Then TrPorcentajeCredito.Visible = True : LblPorcentajeCredito.Text = $"{PorcentajeCredito.FormatoNumero}%"
If Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "PA") Then
If Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "PA") AndAlso (Not UsuarioActual.Empresa.Funcionalidad(702).Contiene("2")) 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: <br> <br> {0}", Vta.SerieVenta)
@@ -6288,8 +6290,9 @@ Partial Class Ventas
' 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
If UsuarioActual.TienePermisoProceso(60) Then DdlTipoComprobante.SelectedValueExistInsert("Ing", "Ingresos") 'puede facturar
DdlTipoComprobante.SelectedValueExist(UsuarioActual.CveTipoDocumento)
TxtFechaPago.Text = If(DdlTipoComprobante.SelectedValue = "Rem", Now.AddDays(PlazoCobranzaRemision), Now.AddDays(PlazoCobranza)).ToShortDateString
@@ -6301,7 +6304,7 @@ Partial Class Ventas
'GENERAR AUTORIZACION SI TIENE EXCEDIO EL LIMITE DE CREDITO
Select Case ValorAutorizacion
Case "1" 'CREAR DOCUMENTO DE AUTORIZACION PA
If Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "Ant", "PA") Then
If Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "Ant", "PA") AndAlso Not (UsuarioActual.Empresa.Funcionalidad(702).Contiene("2")) Then
'VERIFICAR CANDADOS DE VENTA, REMISIONES SIN FACTURAR, FACTURAS QUE NO TENGAN VENCIDAS
Dim Vta As New ClsVentas
@@ -6311,6 +6314,7 @@ Partial Class Ventas
If Opcion > 0 Then
If Opcion = 1 Then
BtnEmitirImprimir.Visible = False
BtnsFacturar.Visible = False
End If
If Alertas Then Alert(OpcionMsg, TipoMensaje.MsgAdvertencia)
Else
@@ -6387,7 +6391,7 @@ Partial Class Ventas
End If
'Puede hacer pedido
If Me.CveVenta <= 0 Then
If CveVenta <= 0 Then
If Not UsuarioActual.TienePermisoProceso(177) Then
If DdlTipoComprobante.Items.FindByValue("Pd2") IsNot Nothing Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Pd2"))
@@ -7645,36 +7649,40 @@ Partial Class Ventas
'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 (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
Dim ObjVentas As New ClsVentas
If ObjVentas.ObtenerCreditoRestante(CveCliente, DdlSucursalCliente.SelectedValue.ToEntero()) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
If Not UsuarioActual.Empresa.Funcionalidad(702) = "1" Then
Dim ObjVentas As New ClsVentas
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
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
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
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
Else
ObjVentas.Dispose()
Alert("Ocurrio un error al obtener el limite de credito del cliente", TipoMensaje.MsgError)
Exit Sub
End If
ObjVentas.Dispose()
'End If
End If
@@ -8196,7 +8204,7 @@ Partial Class Ventas
Dim CveVentaAnterior As Integer = Me.CveVenta
GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjFactura, TmpDT, ObjFactura.CveNCaVincular, ObjContPaq, ObjBancos, ObjOS,
ObjEventos, ObjCGame, ObjClientes, EsNCAmortizacion:=EsNCAmortizacion)
ObjEventos, ObjCGame, ObjClientes, EsNCAmortizacion:=EsNCAmortizacion, CveAnticipoPadre:=CveAnticipoPadre)
'Agregamos las OCs a la tabla
If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso DTOrdenesCompraPS IsNot Nothing AndAlso DTOrdenesCompraPS.Rows.Count > 0 AndAlso ErrorList.Count = 0 Then
@@ -11176,7 +11184,7 @@ Partial Class Ventas
#Region " GUARDAR - VENTA, PREPOLIZAS, INV, ESTIMACIONES, AC, NOTA DE CRÉDITO "
Private Sub GuardarVenta(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, factura As Modelos.Factura, ByRef TmpDTDetalle As DataTable, CveNCaVincular As Integer,
ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing,
ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False, Optional ListaNCDescuento As List(Of Modelos.Factura) = Nothing)
ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False, Optional ListaNCDescuento As List(Of Modelos.Factura) = Nothing, Optional CveAnticipoPadre As Integer = -1)
Dim Msgok As New StringBuilder
Dim CveAlmacenTraspasoOrigen As Integer = -1
@@ -11282,7 +11290,7 @@ Partial Class Ventas
FormaPaqueteria:=RblPaqueteria.SelectedValue.ToEntero, FacturarSucursal:=factura.FacturarSucursal, VentaDesglosaIEPS:=factura.VentaDesglosaIEPS, RFCReceptor:=RFCReceptor, Adjunto:=Adjunto, DevolucionImportePagado:=factura.DevolucionImportePagado) Then
ErrorList.Add("Ocurrió un error al Generar la Venta.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
Else
If factura.TipoDocto.Contiene("Dev", "Egs") OrElse DtVentasNC IsNot Nothing OrElse CveEstatusRefacturacion > 0 Then
If factura.TipoDocto.Contiene("Dev", "Egs") OrElse DtVentasNC IsNot Nothing OrElse CveEstatusRefacturacion > 0 OrElse CveAnticipoPadre > 0 Then
If DtVentasNC IsNot Nothing Then
For Each row As DataRow In DtVentasNC.Rows
If Not row("CveVenta").ToString().ToEntero() = -1 Then
@@ -11292,6 +11300,7 @@ Partial Class Ventas
End If
Next
Else
'SI ES REFACTURACION DEBE AGREGAR LA VENTA ANTERIOR COMO RELACIONADA TAMBIEN
If Not CveVenta = -1 Then
If Not ObjVentas.AddVentasRelacionadas(ObjVentas.CveVenta, CveVenta) Then
ErrorList.Add("Ocurrió un error al relacionar las ventas entre si comuníquese a Soporte Técnico")
@@ -11303,6 +11312,14 @@ Partial Class Ventas
End If
End If
End If
'SI TIENE UN ANTICIPO TAMBIEN DEBE RELACIONARLO
If CveAnticipoPadre > 0 Then
If Not ObjVentas.AddVentasRelacionadas(ObjVentas.CveVenta, CveAnticipoPadre) Then
ErrorList.Add("Ocurrió un error al relacionar las ventas entre si comuníquese a Soporte Técnico")
End If
End If
End If
End If
@@ -18147,7 +18164,7 @@ Partial Class Ventas
End Sub
Private Sub SetPermisos()
If CveVenta < 1 Then
If CveVenta < 1 OrElse EsCreaApartirDe Then
'Puede cotizar
If Not UsuarioActual.TienePermisoProceso(59) Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Cot"))
@@ -18938,13 +18955,6 @@ Partial Class Ventas
End If
End If
If Not OcurrioError AndAlso ConSalida Then
'Esquema viejo, evitamos que aparezca por surtir
If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then
OcurrioError = True
End If
End If
End If
End If
@@ -19113,6 +19123,23 @@ Partial Class Ventas
'COMIENZA: VENTADETALLE
'CUANDO SEA SALIDA VA POR LA VENTA DETALLE DE LA FACTURA DE LA REMISION - OJO!! SOLO FUNCIONA HASTA ORITA QUE SE HACE SALIDA SOLO CUANDO SE FACTURA LA REMISION
Dim CveVentaDetalle = If(ConceptoEntrada.Contiene(3, 40), TmpDT.FiltroPrimeroValor("CveVentaDetalle", $"Consec={Consec}").ToEntero(), MovDet("CveVentaDetalle").ToString().ToEntero())
Dim CveVentaDetallePadre As Integer = -1
'If ConceptoEntrada = 3 Then
' CveVentaDetalle = TmpDT.FiltroPrimeroValor("CveVentaDetalle", $"Consec={Consec}").ToEntero()
'ElseIf ConceptoEntrada = 40 Then
' CveVentaDetalle = MovDet("CveVentaDetalle").ToString().ToEntero()
' CveVentaDetallePadre = TmpDT.FiltroPrimeroValor("CveVentaDetalle", $"Consec={Consec}").ToEntero()
' 'CUANDO LA VENTADETALLE NO TENGA VALOR DEBE MARCAR ERROR, NUEVA RESTRICCION DE ALMACEN
' If CveVentaDetallePadre < 0 Then
' Alert("no se encontro la venta detalle nueva. Por favor comuniquese con atención SIG.", TipoMensaje.ToastError)
' OcurrioError = True
' Exit For
' End If
'Else
' CveVentaDetalle = MovDet("CveVentaDetalle").ToString().ToEntero()
'End If
'CUANDO LA VENTADETALLE NO TENGA VALOR DEBE MARCAR ERROR, NUEVA RESTRICCION DE ALMACEN
If CveVentaDetalle < 0 Then
Alert("no se encontro la venta detalle. Por favor comuniquese con atención SIG.", TipoMensaje.ToastError)
@@ -19133,7 +19160,7 @@ Partial Class Ventas
CveMovimientoDetalleEntrada = MovDet("CveMovimientoDetalle").ToString().ToEntero()
End If
If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada) Then
If ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, PU, -1, CveSeccionAlmacen:=CveSeccionAlmacen, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalleEntrada, CveVentaDetallePadre:=CveVentaDetallePadre) Then
ContadorMovtosDetalles += 1
Else
OcurrioError = True
@@ -23106,7 +23133,7 @@ Partial Class Ventas
RequiereAlmacenDestino = True
DdlAlmacenAsignado.Items.Clear()
DdlAlmacenAsignado.Items.Insert(0, New ListItem(" Seleccione ", "-1"))
DdlAlmacenAsignado.SelectedValue = "-1"
DdlAlmacenAsignado.SelectedValueExist("-1")
DdlAlmacenAsignado.DataBind()
DdlAlmacenAsignado.Items.Insert(0, New ListItem("Almacen", DbRowVenta("CveAlmacenTraspasoOrigen").ToString()))
DdlAlmacenAsignado.SelectedValueExist(DbRowVenta("CveAlmacenTraspasoOrigen").ToString())
@@ -29836,6 +29863,8 @@ Partial Class Ventas
GvPS.Columns(17).Visible = True
GvPS.Columns(18).Visible = True
SetPermisos()
CambiaTipoDocto()
CambiaSucursalGeneral(RecargarPartidas:=False)
CargaAnticipos(CveCliente)