This commit is contained in:
2025-06-11 17:38:28 -07:00
13 changed files with 3286 additions and 1291 deletions

View File

@@ -500,82 +500,99 @@ Partial Class Ventas_PVCobranza
Dim GvRow As GridViewRow = DirectCast(ImgBtn.BindingContainer, GridViewRow)
Dim TieneError As Boolean = False
Dim CveVenta As Integer = e.CommandArgument.ToString.ToEntero
Dim CondicionesPagoContado As Boolean = GvRow.DataKey("CondicionesPago") = "0"
Dim ObjVentas As New ClsVentas
ObjVentas.IniciaTransacSQL()
Try
If Not ObjVentas.UpdateAsignaVentaCobranza(CveVenta, 1, UsuarioActual.CveUsuario, -1, "", Now) Then
Dim CveVenta As Integer = e.CommandArgument.ToString.ToEntero
Dim RowVenta As DataRow = Nothing
Using ObjVta As New ClsVentas
If ObjVta.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
RowVenta = ObjVta.DtResultados.Copy().Rows(0)
End If
End Using
If RowVenta IsNot Nothing Then
Dim ObjVentas As New ClsVentas
ObjVentas.IniciaTransacSQL()
Try
If Not ObjVentas.UpdateAsignaVentaCobranza(CveVenta, 1, UsuarioActual.CveUsuario, -1, "", Now) Then
TieneError = True
End If
HdnCveVenta.Value = CveVenta.ToString
Dim Saldo As Decimal = RowVenta("Saldo").ToString().ToDecimal()
Dim CveFormaPago33 As String = RowVenta("CveFormaPago33").ToString()
HdnCveCliente.Value = RowVenta("CveCliente").ToString()
TxtImporteContado.Text = Saldo.FormatoNumero
HdnTotal.Value = Saldo.ToString()
TxtImporteEfectivo.Focus()
LtlNombre.Text = RowVenta("AtencionA").ToString()
LtlFolio.Text = RowVenta("SerieFolio").ToString()
LtlSaldo.Text = Saldo.FormatoNumero
LtlMoneda.Text = RowVenta("Moneda").ToString()
Dim CondicionesPagoContado As Boolean = RowVenta("CondicionesPago").ToString() = "0"
Dim CveMoneda As Integer = RowVenta("CveMoneda").ToString().ToEntero()
HdnMoneda.Value = CveMoneda.ToString()
If CveMoneda = 2 Then
DivUSD.Visible = True
TxtTC.Text = GlobalTipoCambio(Now).ToString()
TxtTotalMXN.Text = (TxtImporteContado.Text.ToDecimal() * TxtTC.Text.ToDecimal()).FormatoNumero()
End If
HdnVentaCondicionesPago.Value = RowVenta("CondicionesPago").ToString()
HdnPlazoCobranza.Value = GvRow.DataKey("PlazoCobranza")
If UsuarioActual.CveEmpresa.Contiene(189, 193, 195, 196, 197) AndAlso RowVenta("TipoDocto").ToString().Contiene("Rem", "Ant") Then
DivAnticipo.Visible = True
ImgAntiPend.Visible = True
End If
If CondicionesPagoContado Then
'según la forma de pago va a establecer el valor para pago.
Select Case CveFormaPago33
Case "1"
TxtImporteEfectivo.Text = Saldo.FormatoNumero
Case "2"
TxtImporteCheque.Text = Saldo.FormatoNumero
Case "3"
TxtImporteTransferencia.Text = Saldo.FormatoNumero
Case "4"
TxtImporteCredito.Text = Saldo.FormatoNumero
Case "18"
TxtImporteDebito.Text = Saldo.FormatoNumero
Case Else
TxtImporteEfectivo.Text = Saldo.FormatoNumero
End Select
DivContadoBancos.Visible = True
BtnPagar.Text = "Pagar"
Else
DivContadoBancos.Visible = False
BtnPagar.Text = "Emitir a crédito"
End If
Catch ex As Exception
TieneError = True
End If
HdnCveVenta.Value = CveVenta.ToString
HdnCveCliente.Value = GvRow.DataKey("CveCliente")
TxtImporteContado.Text = GvRow.DataKey("Saldo").FormatoNumero
HdnTotal.Value = GvRow.DataKey("Saldo")
TxtImporteEfectivo.Focus()
LtlNombre.Text = GvRow.DataKey("AtencionA")
LtlFolio.Text = GvRow.DataKey("SerieFolio")
LtlSaldo.Text = GvRow.DataKey("Saldo").ToDecimal.FormatoNumero
LtlMoneda.Text = GvRow.DataKey("Moneda")
End Try
Dim CveMoneda As Integer = GvRow.DataKey("CveMoneda").ToEntero()
'carga información para cobranza
HdnMoneda.Value = CveMoneda.ToString()
If CveMoneda = 2 Then
DivUSD.Visible = True
TxtTC.Text = GlobalTipoCambio(Now).ToString()
TxtTotalMXN.Text = (TxtImporteContado.Text.ToDecimal() * TxtTC.Text.ToDecimal()).FormatoNumero()
End If
HdnVentaCondicionesPago.Value = GvRow.DataKey("CondicionesPago")
HdnPlazoCobranza.Value = GvRow.DataKey("PlazoCobranza")
If UsuarioActual.CveEmpresa.Contiene(189, 193, 195, 196, 197) AndAlso GvRow.DataKey("TipoDocto").Contiene("Rem", "Ant") Then
DivAnticipo.Visible = True
ImgAntiPend.Visible = True
End If
If CondicionesPagoContado Then
'según la forma de pago va a establecer el valor para pago.
Select Case GvRow.DataKey("CveFormaPago33")
Case "1"
TxtImporteEfectivo.Text = GvRow.DataKey("Saldo").FormatoNumero
Case "2"
TxtImporteCheque.Text = GvRow.DataKey("Saldo").FormatoNumero
Case "3"
TxtImporteTransferencia.Text = GvRow.DataKey("Saldo").FormatoNumero
Case "4"
TxtImporteCredito.Text = GvRow.DataKey("Saldo").FormatoNumero
Case "18"
TxtImporteDebito.Text = GvRow.DataKey("Saldo").FormatoNumero
Case Else
TxtImporteEfectivo.Text = GvRow.DataKey("Saldo").FormatoNumero
End Select
DivContadoBancos.Visible = True
BtnPagar.Text = "Pagar"
If Not TieneError Then
ObjVentas.Commit()
PnlContado.Visible = True
Else
DivContadoBancos.Visible = False
BtnPagar.Text = "Emitir a crédito"
ObjVentas.RollBack()
PnlContado.Visible = False
Alert("Hubo un error al asignar datos de cobranza", TipoMensaje.MsgInformacion)
End If
Catch ex As Exception
TieneError = True
End Try
'carga información para cobranza
If Not TieneError Then
ObjVentas.Commit()
PnlContado.Visible = True
Else
ObjVentas.RollBack()
PnlContado.Visible = False
Alert("Hubo un error al asignar datos de cobranza", TipoMensaje.MsgInformacion)
End If
ObjVentas.Dispose()
'CargaDatos()
ObjVentas.Dispose()
End If
'CargaDatos()
End If
End Sub
@@ -906,6 +923,23 @@ Partial Class Ventas_PVCobranza
SaldoPendientePagos -= PagoEfectivo
End If
If SobranteFaltante <> 0 Then
Dim Pago As New VentaPago
Pago.ImportePagoVenta = Math.Abs(SobranteFaltante)
Pago.ImportePago = Math.Abs(SobranteFaltante)
Pago.CveIE = -1
Pago.CveMonedaPago = VentaActual.CveMoneda
Pago.Fecha = NowADS()
Pago.Referencia = VentaActual.SerieFolio
Pago.TipoPago = "XXX"
Pago.OtroGastoIngreso = SobranteFaltante
Dim ErrorConta As Boolean = AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjConta)
If ErrorConta Then
MsgError = "Error en aplicación de sobrante/faltante"
End If
End If
If SaldoPendienteVenta > 0 AndAlso Not ChkSobFaltante.Checked Then
MsgError = "Tiene saldo pendiente por aplicar"
End If

View File

@@ -7699,7 +7699,7 @@
<div class="row" id="DivRNCCargosDetalle" runat="server" visible="false">
<div class="col-md-12" style="max-height: 440px; overflow: auto">
<asp:GridView ID="GvRemisionesNCDetalle" runat="server" AutoGenerateColumns="False"
DataKeyNames="CveVenta,CveVentaDetalleRNC,CvePS,PU,PorcentajeIVA" CssClass="table table-striped table-advance table-hover Widthall mysmallbtn" GridLines="None">
DataKeyNames="CveVenta,CveVentaDetalleRNC,CvePS,PU,PorcentajeIVA,Saldo" CssClass="table table-striped table-advance table-hover Widthall mysmallbtn" GridLines="None">
<Columns>
<asp:TemplateField>
<ItemTemplate>

View File

@@ -2866,6 +2866,8 @@ Partial Class Ventas
TmpDT.Columns.Add("PSAlterno", GetType(String))
TmpDT.Columns.Add("Costo", GetType(Decimal))
TmpDT.Columns("Costo").DefaultValue = 0D
TmpDT.Columns.Add("UltimoCosto", GetType(Decimal))
TmpDT.Columns("UltimoCosto").DefaultValue = 0D
GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind()
@@ -2887,6 +2889,8 @@ Partial Class Ventas
TmpDT = ObjCGame.DtResultados
TmpDT.Columns.Add("Costo", GetType(Decimal))
TmpDT.Columns("Costo").DefaultValue = 0D
TmpDT.Columns.Add("UltimoCosto", GetType(Decimal))
TmpDT.Columns("UltimoCosto").DefaultValue = 0D
If Not TmpDT.Columns.Contains("NumeroParte") Then TmpDT.Columns.Add("NumeroParte", GetType(String))
GvPS.DataBind()
@@ -2935,6 +2939,9 @@ Partial Class Ventas
TmpDT.Columns.Add("NumeroParte", GetType(String))
TmpDT.Columns.Add("Costo", GetType(Decimal))
TmpDT.Columns("Costo").DefaultValue = 0D
TmpDT.Columns.Add("UltimoCosto", GetType(Decimal))
TmpDT.Columns("UltimoCosto").DefaultValue = 0D
GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind()
@@ -8112,6 +8119,8 @@ Partial Class Ventas
If CreditoDispo < 0 Then
BtnsFacturar.Visible = False
BtnGenerarRemision.Visible = False
TieneBloqueoPorCreditoVencimiento = 1
Alert("El límite de crédito se ha excedido", TipoMensaje.MsgAdvertencia)
End If
End If
@@ -8126,9 +8135,7 @@ Partial Class Ventas
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
TieneBloqueoPorCreditoVencimiento = 1
End If
End If
End If
@@ -8432,6 +8439,12 @@ Partial Class Ventas
End If
'SI ES COTIZACION, PERMITIR CREAR UN DOCUMENTO NUEVO TIPO "PA"
If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(595) = "1" AndAlso TieneBloqueoPorCreditoVencimiento = 1 Then
BtnGeneraAutorizacion.Visible = True
UpFacturar.Update()
End If
End Sub
@@ -9283,6 +9296,9 @@ Partial Class Ventas
If DrPS IsNot Nothing Then
gvr.FCTextBox("TxtPrecio").Enabled = CBool(DrPS("PrecioLibre"))
End If
'PONER LA CLASIFICACION EN TODAS, PARA NO FILTRAR POR CLASIFICACION
gvr.FCDropDownList("DdlClasificacion").SelectedValueExist("-1")
End If
If UsuarioActual.TienePermisoProceso(253) Then gvr.FCTextBox("TxtPrecio").Enabled = True
@@ -10381,7 +10397,6 @@ Partial Class Ventas
PU = dr("PU").ToString().ToDecimal * If(DdlMoneda.SelectedValue.ToEntero() = 1, 1, TxtTipoCambio.Text.ToDecimal)
If UsuarioActual.Empresa.Funcionalidad(602) = "UC" Then 'validación sobre el último costo
If ObjInventarios.GetUltimoCosto(UsuarioActual.CveEmpresa, dr("CvePS").ToString().ToEntero()) Then
Dim drps As DataRow = ObjInventarios.DtResultados.FiltroPrimero("")
If drps IsNot Nothing Then
@@ -10391,6 +10406,7 @@ Partial Class Ventas
Else
Costo = ObjInventarios.GetCostoPS(dr("CvePS").ToString().ToEntero(), dr("Cantidad").ToString().ToDecimal, -1, "-1", TxtFecha.Text.ToDate, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveTipoAlmacen:=1)
End If
Dim PrecioMinimo As Decimal = 0
'RMF. condicion temporal, para reubicación, precio mínimo
If UsuarioActual.CveEmpresa = 119 Then
@@ -13781,13 +13797,7 @@ Partial Class Ventas
Timbre.Comprobante.TipoComprobante = If(Obj.TipoDocto.Contiene("Ing", "Ant"), "I", If(Obj.TipoDocto.Contiene("Egs", "Dev"), "E", ""))
Timbre.Comprobante.Folio = Obj.Folio.ToString()
Timbre.Comprobante.Serie = Obj.Serie
If Me.CveVenta = 4381091 Then
Timbre.Comprobante.Fecha = Obj.Fecha
Else
Timbre.Comprobante.Fecha = Obj.FechaCP
End If
Timbre.Comprobante.Fecha = Obj.FechaCP
Timbre.Comprobante.CondicionesdePago = If(UsuarioActual.CveEmpresa.Contiene(15, 76, 198), "No Aplica", Obj.FormaPago)
Timbre.Comprobante.MetodoPago = GlobalDTVtaMetodoPago.FiltroPrimeroValor("ClaveMetodoPagoSAT", $"CveMetodoPago = {Obj.CveMetodoPago}") ' Obj.ClaveMetodoPagoSAT
@@ -13890,7 +13900,8 @@ Partial Class Ventas
If Obj.TipoDocto.Contiene("Egs", "Dev") OrElse (NuevaFactura = 1) Then
If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then
Timbre.CFDIRelacionados.UUID.Clear()
For Each Dr As DataRow In DtVentasNC.Rows
'QUITAR LAS QUE ESTEN CANCELADAS
For Each Dr As DataRow In DtVentasNC.FiltraParametros("CveEstatusFactura <> 5").Rows
Timbre.CFDIRelacionados.UUID.Add(Dr("FolioFiscal").ToString())
Next
Else
@@ -21690,6 +21701,9 @@ Partial Class Ventas
TmpDT.Columns.Add("Costo", GetType(Decimal))
TmpDT.Columns("Costo").DefaultValue = 0D
TmpDT.Columns.Add("UltimoCosto", GetType(Decimal))
TmpDT.Columns("UltimoCosto").DefaultValue = 0D
End Sub
Private Sub CreaDTmpC()
DTmpC = New DataTable
@@ -22094,6 +22108,20 @@ Partial Class Ventas
End If
End If
'SI ES FACTURACION DE COTIZACION Y REQUIERE AUTORIZACION, SOLO DEBE PERMITIR ESTA
If UsuarioActual.Empresa.Funcionalidad(595) = "1" AndAlso Request("CveCotizacion") IsNot Nothing AndAlso Request("CveCotizacion").ToString().ToEntero() > 0 AndAlso TieneBloqueoPorAutorizacion = 1 Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing"))
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Egs"))
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Cot"))
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Dev"))
DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización")
DdlTipoComprobante.SelectedValue = "PA"
BtnCrearApartirDe.Visible = False
UpFacturar.Update()
End If
'[IPP]: FALTA CONFIGURAR Y DAR PERMISO A TODOS LOS QUE TENGAN ACCESO A VENTAS
''Puede remisionar
@@ -24729,6 +24757,19 @@ Partial Class Ventas
Exit Sub
End If
'si es de FNC contado. bloquear edición si está pagada o en proceso de cobro
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
Using ObjVta As New ClsVentas
If ObjVta.GetVenta(Me.CveVenta, UsuarioActual.CveEmpresa) Then
Dim DbRowVenta As DataRow = ObjVta.DtResultados.FiltroPrimero("")
If DbRowVenta IsNot Nothing AndAlso (DbRowVenta("CveCobranzaEstatus").ToString = "1" OrElse DbRowVenta("Saldo").ToString.ToDecimal = 0) Then
Alert("No se puede actualizar la información de la remisión porque esta en proceso de cobro. Para aplicar cambios se debera de liberar desde el módulo de 'cobro por caja'.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End Using
End If
Dim OcurrioError As Boolean = False
Dim ObjVentas As New ClsVentas
ObjVentas.IniciaTransacSQL()
@@ -30703,7 +30744,7 @@ Partial Class Ventas
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1) Then
DtNC = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'RNC' AND CveVenta > 0 and Saldo > 0", "Moneda,Fecha,Folio")
DtNC = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'RNC' AND CveVenta > 0 and Saldo > 1", "Moneda,Fecha,Folio")
End If
ObjMovtos.Dispose()
@@ -30807,7 +30848,7 @@ Partial Class Ventas
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1) Then
DtNC = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'RNC' AND CveVenta > 0 and Saldo > 0", "Moneda,Fecha,Folio")
DtNC = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'RNC' AND CveVenta > 0 and Saldo > 1", "Moneda,Fecha,Folio")
End If
ObjMovtos.Dispose()
@@ -33135,7 +33176,7 @@ Partial Class Ventas
Next
If Not Selecciono Then
Alert("Tiene que seleccionar al menos un concepto y este dege tener una cantidad mayor a 0. Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
Alert("Tiene que seleccionar al menos un concepto y este debe tener una cantidad mayor a 0. Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
@@ -35976,7 +36017,7 @@ Partial Class Ventas
#Region "GENERAR AUTORIZACIÓN"
Protected Sub BtnGeneraAutorizacion_Click(sender As Object, e As EventArgs)
If DdlTipoComprobante.SelectedValue.Contiene("Ped") Then
If DdlTipoComprobante.SelectedValue.Contiene("Ped", "Cot") Then
EmitirDocumentoNuevo("PA")
End If
End Sub
@@ -36670,10 +36711,15 @@ Partial Class Ventas
Dim ImporteIVA As Decimal = (TotalCalculableImpuestos * PorcentajeIVA).RoundSQL(2)
Dim TotalRNCDetalle As Decimal = (TotalCalculableImpuestos + ImporteIVA)
Dim Saldo As Decimal = GvRow.DataKey("Saldo").ToDecimal()
'AJUSTAR SALDO SI EL TOTAL ES MAYOR
If TotalRNCDetalle > Saldo Then
TotalRNCDetalle = Saldo
End If
TotalRNC += TotalRNCDetalle
End If
End If