This commit is contained in:
2024-07-20 07:24:26 -07:00
20 changed files with 663 additions and 173 deletions

View File

@@ -5284,6 +5284,8 @@ Partial Class Ventas
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"))
HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta"))
TrMotivoDev.Visible = True
lblMotivoDev.Text = DbRowVenta("MotivoDevolucion").ToString()
Case "Ped"
DdlTipoComprobante.Items.Insert(0, New ListItem("Pedido", "Ped"))
CvePedido = CveVenta
@@ -5527,6 +5529,7 @@ Partial Class Ventas
TxtObsFact.Text = DbRowVenta("Observaciones").ToString()
LblUsuario.Text = DbRowVenta("Nombre").ToString().SubStringADS(30)
LblFechaRegistro.Text = DbRowVenta("FechaIng").ToString().ToDate.ToShortDateString
LblSeTimbro.Text = DbRowVenta("SeTimbro").ToString()
LblMail.Text = DbRowVenta("EnvioMail").ToString()
TxtFechaPago.Text = DbRowVenta("FechaVencimiento").ToString()
@@ -8881,11 +8884,20 @@ Partial Class Ventas
Dim DatarowPS As DataRow = Nothing
DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("") ' Estado = -1
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
If DdlTipoComprobante.SelectedValue = "Cot" Then
If PU < DatarowPS("PrecioMinimo").ToString().ToDecimal() Then
Alert($"El precio no puede ser menor al precio mínimo. Precio Mínimo: {DatarowPS("PrecioMinimo"):N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then
If PU < DatarowPS("PrecioMinimo").ToString().ToDecimal() Then
Alert($"El precio no puede ser menor al precio mínimo. Precio Mínimo: {DatarowPS("PrecioMinimo"):N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
If DdlTipoComprobante.SelectedValue = "Ant" Then
Dim PSCodigoSAT As String = DatarowPS("SATClavePS").ToString
If PSCodigoSAT <> "84111506" Then
Alert($"El producto y/o servicio no es valido para generar anticipos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
@@ -8957,7 +8969,7 @@ Partial Class Ventas
If ValidaExistencia AndAlso DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False AndAlso Not RegistroxOC Then
'VALIDA EXISTENCIA
If UsuarioActual.CveEmpresa.Contiene({72, 80, 119, 140, 153}) Then
If UsuarioActual.CveEmpresa.Contiene({72, 80, 119, 140, 153, 190, 192, 197}) Then
'SI ES VENTA NUEVA TOMA EN CUENTA LO DEL TMPDT
If CveVenta <= 0 Then
If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then
@@ -9752,13 +9764,13 @@ Partial Class Ventas
Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero()
Dim ObjVentas As New ClsVentas
If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, If(DdlTipoComprobante.SelectedValue = "Egs", "Egs", "Ing"), CveEstatus:=1) Then
If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, "Ing", CveEstatus:=1) Then
Dim RowAutorizacion As DataRow = Nothing
'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
If TieneDiasVencidos Then
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='{If(DdlTipoComprobante.SelectedValue = "Egs", "Egs", "Ing")}'", Orderby:="Importe DESC")
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='{"Ing"}'", Orderby:="Importe DESC")
Else
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='{If(DdlTipoComprobante.SelectedValue = "Egs", "Egs", "Ing")}'", Orderby:="Importe DESC")
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='{"Ing"}'", Orderby:="Importe DESC")
End If
If RowAutorizacion IsNot Nothing Then
@@ -9806,14 +9818,6 @@ Partial Class Ventas
End If
'If TipoAutorizacion = 2 Then
' If DiasVencidosCliente > DiasVencidosAutorizacion Then
' CveAutorizacion = -1
' Alert($"El crédito no esta autorizado. Los días vencidos del cliente son mayores a lo autorizado", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
'End If
'SI NO SE ENCONTRO NINGUA AUTORIZACION
If TipoAutorizacion = 0 Then
If TieneDiasVencidos Then
@@ -9824,21 +9828,57 @@ Partial Class Ventas
End If
End If
'If TieneDiasVencidos AndAlso DdlTipoComprobante.SelectedValue = "Egs" AndAlso CveAutorizacion <= 0 Then
' CveAutorizacion = -1
' Alert($"El crédito no esta autorizado. No tiene autorización para generar notas de crédito. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
' Exit Sub
'End If
End If
'If TipoDocumentoAutorizacion = "Egs" Then
' If TipoAutorizacion = 1 Then
' If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
' CveAutorizacion = -1
' Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
' End If
'End If
'VALIDACION DE AUTORIZACION PARA NC, POR AHORA SOLO BDH
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Egs") Then
PermiteAutorizacion = False
'SI NO ES GENERADA CON REMISIONES DE NC, UTILIZAR LA AUTORIZACION
If (ListaRemisionesNC Is Nothing OrElse ListaRemisionesNC.Count = 0) Then
PermiteAutorizacion = True
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)
Exit Sub
End If
End If
End If
'VALIDAR LINEAS ADICIONALES
@@ -14008,6 +14048,11 @@ Partial Class Ventas
'CveAlmacenTraspasoDestino
End If
Dim CveMotivoDevolucion As Integer = -1
If DdlMotivoDevolucion.SelectedValue.ToEntero() > 0 Then
CveMotivoDevolucion = DdlMotivoDevolucion.SelectedValue.ToEntero()
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,
@@ -14027,7 +14072,7 @@ Partial Class Ventas
FormaPaqueteria:=RblPaqueteria.SelectedValue.ToEntero, FacturarSucursal:=factura.FacturarSucursal, VentaDesglosaIEPS:=factura.VentaDesglosaIEPS, RFCReceptor:=RFCReceptor, Adjunto:=Adjunto, DevolucionImportePagado:=factura.DevolucionImportePagado, EsGarantia:=factura.EsGarantia, ServicioDomicilio:=TrServicioDomicilio.Visible,
CveLineaAdicional:=DdlLineaAdicional.SelectedValue.ToEntero(), DescripcionVenta:=DescripcionVenta,
CveMedico:=CveMedico, CveProcedimiento:=CveProcedimiento, CveTipoVenta:=CveTipoVentaGuardar, RequiereOS:=ChkRequiereTecnico.Checked, FechaParaSurtir:=factura.FechaParaSurtir,
Paciente:=TxtPaciente.Text, Episodio:=TxtEpisodio.Text) Then
Paciente:=TxtPaciente.Text, Episodio:=TxtEpisodio.Text, CveMotivoDevolucion:=CveMotivoDevolucion) 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 OrElse CveAnticipoPadre > 0 Then
@@ -16702,6 +16747,13 @@ Partial Class Ventas
HdnTieneAnticipos.Value = "0"
If CveCliente > 0 Then
'QUE NO SE PUEDA REALIZAR AMORTIZACIÓN DE ANTICIPO POR DESCUENTO
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
If DdlTipoAmortizacionAnticipo.Items.FindByValue("1") IsNot Nothing Then
DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("1"))
End If
End If
HdnIVACalculado.Value = "0"
'SI ES REFACTURACION NO LIMPIAR EL FOLIO FISCAL
If NuevaFactura <> 1 Then
@@ -18108,7 +18160,7 @@ Partial Class Ventas
End Sub
Protected Sub DdlNCFactura_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlNCFactura.SelectedIndexChanged
Dim objcompras As New ClsCompras
If objcompras.GetCompraDetallealmacen(0, DdlNCFactura.SelectedValue.ToEntero()) Then
If objcompras.GetCompraDetalleAlmacen(0, DdlNCFactura.SelectedValue.ToEntero()) Then
GvInvNC.DataSource = objcompras.DtResultados
If objcompras.DtResultados.Rows.Count > 0 Then
Tab.ActiveTabIndex = 1
@@ -18802,13 +18854,24 @@ Partial Class Ventas
Return False
End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
Dim DatarowPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
If DatarowPS IsNot Nothing Then
If PU < DatarowPS("PrecioMinimo").ToString().ToDecimal() Then
Alert($"El precio no puede ser menor al precio mínimo. Precio Mínimo: {DatarowPS("PrecioMinimo"):N2}", TipoMensaje.MsgAdvertencia)
Return False
If DdlTipoComprobante.SelectedValue = "Cot" Then
If PU < DatarowPS("PrecioMinimo").ToString().ToDecimal() Then
Alert($"El precio no puede ser menor al precio mínimo. Precio Mínimo: {DatarowPS("PrecioMinimo"):N2}", TipoMensaje.MsgAdvertencia)
Return False
End If
End If
If DdlTipoComprobante.SelectedValue = "Ant" Then
Dim PSCodigoSAT As String = DatarowPS("SATClavePS").ToString
If PSCodigoSAT <> "84111506" Then
Alert($"El producto y/o servicio '{DatarowPS("CodigoPS").ToString}' no es valido para generar anticipos", TipoMensaje.MsgAdvertencia)
Return False
End If
End If
End If
End If
@@ -18887,7 +18950,7 @@ Partial Class Ventas
If ValidaExistencia Then
'VALIDA EXISTENCIA
If UsuarioActual.CveEmpresa.Contiene({72, 80, 119, 153, 140, 186, 190}) Then
If UsuarioActual.CveEmpresa.Contiene({72, 80, 119, 153, 140, 186, 190, 192, 197}) Then
Dim BuscarEnTabla As Boolean = If(UsuarioActual.Empresa.Funcionalidad(715) = "1", True, False)
@@ -18899,7 +18962,14 @@ Partial Class Ventas
CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=0, PendientePorSurtir:=1,
RestringirAlmacenes:=1, ExcluyeApartados:=-1, BuscarEnTabla:=BuscarEnTabla)
Else
Existencia = ObjInv2.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(),
Dim CveAlmacenConsulta As Integer = -1
If UsuarioActual.Empresa.Funcionalidad(567) = "1" AndAlso DivAlmacen.Visible Then
CveAlmacenConsulta = ddlAlmacen.SelectedValue.ToEntero()
End If
Existencia = ObjInv2.GetExistenciasPS(CvePS, CveUM, UsuarioActual.CveEmpresa, CveAlmacenConsulta, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(),
CveVendedor:=DdlVendedor.SelectedValue.ToEntero(), CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, PendientePorSurtir:=1,
RestringirAlmacenes:=1, ExcluyeApartados:=-1, BuscarEnTabla:=BuscarEnTabla)
End If
@@ -18907,7 +18977,19 @@ Partial Class Ventas
If CveVenta <= 0 OrElse Me.EsCreaApartirDe Then
If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < (If(CantidadModal > 0, CantidadModal, TxtCantidad.Text.ToDouble)) Then
Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia)
Dim CveAlmacenConsulta As Integer = -1
Dim StrAlmacen As New StringBuilder
If UsuarioActual.Empresa.Funcionalidad(567) = "1" AndAlso DivAlmacen.Visible Then
CveAlmacenConsulta = ddlAlmacen.SelectedValue.ToEntero()
If CveAlmacenConsulta > 0 Then
Dim Almacen As String = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=CveAlmacenConsulta).FiltroPrimeroValor("Almacen")
StrAlmacen.AppendFormat("<br/>Almacén: {0}", Almacen)
End If
End If
Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + "." + StrAlmacen.ToString(), TipoMensaje.MsgAdvertencia)
Return False
End If
Else
@@ -24047,9 +24129,9 @@ Partial Class Ventas
Dim AmortizacionNC As Decimal = 0
'SI ES AMORTIZACION POR NOTA DE CREDITO DEBE SUMAR LA TOTALIDAD PARA COMPARAR EL PAGO
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") AndAlso DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("2", "4") Then
For Each gvr As GridViewRow In GVAnticipos.Rows
If gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked AndAlso gvr.DataKey("CveConceptoContable").ToEntero().Contiene(3) Then
If gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked AndAlso gvr.DataKey("CveConceptoContable").ToEntero().Contiene(3, 12) Then
AmortizacionNC += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal
End If
Next
@@ -37389,6 +37471,22 @@ Partial Class Ventas
End If
If PuedeAplicarDevolucion Then
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
DivMotivoDevolucion.Visible = True
Using ObjVenta As New ClsVentas
If ObjVenta.GetMotivoDevolucion(-1, 1, UsuarioActual.CveEmpresa) Then
DdlMotivoDevolucion.DataSource = ObjVenta.DtResultados.Copy()
End If
DdlMotivoDevolucion.DataBind()
DdlMotivoDevolucion.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Using
UpDevolucion.Update()
End If
RegistraScript("$('#DivAplicaDevolucion').modal('show');")
End If
@@ -38405,9 +38503,12 @@ Partial Class Ventas
DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("2"))
End If
Else
If DdlTipoAmortizacionAnticipo.Items.FindByValue("1") Is Nothing Then
DdlTipoAmortizacionAnticipo.Items.Add(New ListItem("Amortización anticipo en descuento", "1"))
If Not (UsuarioActual.Empresa.Funcionalidad(382) = "1") Then
If DdlTipoAmortizacionAnticipo.Items.FindByValue("1") Is Nothing Then
DdlTipoAmortizacionAnticipo.Items.Add(New ListItem("Amortización anticipo en descuento", "1"))
End If
End If
If DdlTipoAmortizacionAnticipo.Items.FindByValue("2") Is Nothing Then
DdlTipoAmortizacionAnticipo.Items.Add(New ListItem("Amortización anticipo con nota de crédito", "2"))
End If