- mejora en validación de presupuesto
This commit is contained in:
171
OC/OC.aspx.vb
171
OC/OC.aspx.vb
@@ -644,8 +644,8 @@ Partial Class OC_OC
|
||||
GlobalDTCultivosCuadro(UsuarioActual.CveEmpresa) = Nothing
|
||||
CargaDatosAgregarPS()
|
||||
CveProveedorOriginal = -1
|
||||
EnviarNotificacionWhatsApp("526621430964", "hola34 https:/sig.adssistemas.mx/ventas/ventas.aspx")
|
||||
EnviarNotificacionWhatsApp("526621430964", "", "hello_world")
|
||||
'EnviarNotificacionWhatsApp("526621430964", "hola34 https:/sig.adssistemas.mx/ventas/ventas.aspx")
|
||||
'EnviarNotificacionWhatsApp("526621430964", "", "hello_world")
|
||||
'MODALIDAD MULTIEMPRESA
|
||||
CveEmpresaActual = UsuarioActual.CveEmpresa
|
||||
If CveEmpresaActual > 0 Then
|
||||
@@ -1647,7 +1647,7 @@ Partial Class OC_OC
|
||||
DdlProveedores.SelectedValue = objOC.CveProveedor.ToString
|
||||
If DdlProveedores.SelectedValue.ToEntero > 0 Then
|
||||
CveProveedorOriginal = objOC.CveProveedor
|
||||
DdlProveedores.SelectedText = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltraParametros($"CveProveedor = {objOC.CveProveedor}").Rows(0)("RazonSocial").ToString
|
||||
DdlProveedores.SelectedText = GlobalDTCompProveedores(UsuarioActual.CveEmpresa, CveProveedor:=objOC.CveProveedor).FiltroPrimeroValor("RazonSocial")
|
||||
Else
|
||||
DdlProveedores.SelectedText = "-"
|
||||
End If
|
||||
@@ -1697,7 +1697,7 @@ Partial Class OC_OC
|
||||
ChkCotizacion.Visible = True
|
||||
DdlProveedores.SelectedValue = objOC.CveProveedor.ToString
|
||||
If DdlProveedores.SelectedValue.ToEntero > 0 Then
|
||||
DdlProveedores.SelectedText = GlobalDTCompProveedores(CveEmpresaActual).FiltraParametros($"CveProveedor = {objOC.CveProveedor}").Rows(0)("RazonSocial").ToString
|
||||
DdlProveedores.SelectedText = GlobalDTCompProveedores(UsuarioActual.CveEmpresa, CveProveedor:=objOC.CveProveedor).FiltroPrimeroValor("RazonSocial")
|
||||
Else
|
||||
DdlProveedores.SelectedText = "-"
|
||||
End If
|
||||
@@ -2756,8 +2756,6 @@ Partial Class OC_OC
|
||||
End Function
|
||||
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
||||
|
||||
|
||||
|
||||
'VALIDACIONES PARA GUARDAR
|
||||
If ValidaGuardar() Then Exit Sub
|
||||
|
||||
@@ -2765,8 +2763,6 @@ Partial Class OC_OC
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Dim MsgError As String = "Hubo un error al registrar"
|
||||
'VARIABLES
|
||||
Dim CveProveedorSucursal As Integer = -1
|
||||
@@ -3740,7 +3736,7 @@ Partial Class OC_OC
|
||||
If CveProveedor > 0 Then
|
||||
'CUANDO VIENE DE COTIZACION
|
||||
tTotalIVA = (DtDetalle.SUM("Total", String.Format("CveProveedor = {0}", CveProveedor)) * tPorIVA).ToString.ToDecimal
|
||||
tPorIVA = GlobalDTCompProveedores(CveEmpresaActual).FiltraParametros(String.Format("CveProveedor = {0}", CveProveedor)).Rows(0)("IVA").ToString.ToDecimal
|
||||
tPorIVA = GlobalDTCompProveedores(CveEmpresaActual, CveProveedor:=CveProveedor).FiltroPrimeroValor("IVA").ToDecimal
|
||||
tTotalGral = DtDetalle.SUM("Total", String.Format("CveProveedor = {0}", CveProveedor)).ToString.ToDecimal
|
||||
Else
|
||||
'CUANDO NO VIENE DE COTIZACION
|
||||
@@ -4260,7 +4256,6 @@ Partial Class OC_OC
|
||||
End If
|
||||
|
||||
|
||||
|
||||
'SE TOMAN VALORES EN CASO DE QUE LA CvePS SEA DIFERENTE DE LA ANTERIOR
|
||||
Dim CvePSAnterior As Integer = gvr.DataKey("CvePS").ToEntero
|
||||
PS = gvr.DataKey("PS").ToString
|
||||
@@ -4306,7 +4301,6 @@ Partial Class OC_OC
|
||||
|
||||
CveSubProyecto = gvr.FCDropDownList("DdlSubProyectoEdit").SelectedValue.ToEntero
|
||||
SubProyecto = gvr.FCDropDownList("DdlSubProyectoEdit").SelectedItem.Text
|
||||
|
||||
CveCultivoCuadroDetalle = gvr.FCDropDownList("DdlCultivosCuadroEdit").SelectedValue.ToEntero
|
||||
Cuadro = ""
|
||||
If CveCultivoCuadroDetalle > 0 Then
|
||||
@@ -4322,93 +4316,65 @@ Partial Class OC_OC
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(532).Contiene("1", "2") Then
|
||||
Dim ObjCon As New ClsContratos
|
||||
Dim CvePresupuesto As Integer = 0
|
||||
Dim Autorizado As Decimal = 0
|
||||
Dim Ejercido As Decimal = 0
|
||||
If ObjCon.GetPresupuestos(-1, "-1", CveSubProyecto, 2, -1, UsuarioActual.CveEmpresa) Then
|
||||
If ObjCon.DtResultados.Rows.Count > 0 Then
|
||||
CvePresupuesto = ObjCon.DtResultados.Rows(0)("CvePresupuesto").ToString.ToEntero
|
||||
If CvePresupuesto > 0 Then
|
||||
If ObjCon.GetPresupuestosDetalle(CvePresupuesto, -1, UsuarioActual.CveEmpresa) Then
|
||||
If ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {CveClasificacion} And Importe > 0").Rows.Count > 0 Then
|
||||
Autorizado = ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {CveClasificacion} And Importe > 0").Rows(0)("Importe").ToString.ToDecimal
|
||||
End If
|
||||
End If
|
||||
If ObjCon.GetPresupuestosRep(CvePresupuesto, -1, 1, $"01/09/{NowADS().Year - 1}".ToDate, NowADS(), UsuarioActual.CveEmpresa, CveProyecto,
|
||||
CveSubProyecto, UsuarioActual.CveUsuario, CveClasificacion) Then
|
||||
If ObjCon.DtResultados.Rows.Count > 0 Then
|
||||
Ejercido = ObjCon.DtResultados.Rows(0)("Ejercido").ToString.ToDecimal
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
'se envía el dato anterior, para restarlo y agregar el nuevo importe
|
||||
If Not ValidaPresupuesto(1, CveSubProyecto, SubProyecto, CveClasificacion, Clasificacion, (Importe * Cantidad).RoundSQL, DdlMoneda.SelectedValue.ToEntero, (gvr.DataKey("Importe").ToDecimal * gvr.DataKey("Cantidad").ToDecimal).RoundSQL) Then
|
||||
Exit Sub
|
||||
End If
|
||||
ObjCon.Dispose()
|
||||
|
||||
'If CvePresupuesto > 0 And Autorizado > 0 Then
|
||||
' Dim Diferencia As Decimal = (Ejercido + Total) - Autorizado
|
||||
' If Diferencia > 0 Then
|
||||
' Alert($"No hay presupuesto disponible en el subproyecto <b>{SubProyecto}</b> y la clasificación <b>{Clasificacion}</b> se excede por <b>{Diferencia.FormatoNumero}</b>", TipoMensaje.MsgAdvertencia)
|
||||
' Exit Sub
|
||||
' End If
|
||||
'End If
|
||||
End If
|
||||
|
||||
'Agarra el nuevo AF si se modifico o deja el pasado
|
||||
CveActivoFijo = If(gvr.FCHiddenField("HdnCveActivoFijo").Value.ToEntero > 0, gvr.FCHiddenField("HdnCveActivoFijo").Value.ToEntero, HdnEditCveActivoFijo.Value.ToEntero)
|
||||
Codigo = If(gvr.FCHiddenField("HdnCodigoAF").Value <> "-1", gvr.FCHiddenField("HdnCodigoAF").Value, HdnEditCodigo.Value)
|
||||
|
||||
HdnEditCveActivoFijo.Value = ""
|
||||
HdnEditCodigo.Value = ""
|
||||
|
||||
Dim dr As DataRow() = DtDetalle.Select("CveOrdenCompraDetalle = " & gvr.DataKey("CveOrdenCompraDetalle").ToString.ToEntero)
|
||||
If dr.Count > 0 Then
|
||||
dr(0)("Cantidad") = Cantidad
|
||||
dr(0)("CveUnidadMedida") = CveUnidad
|
||||
dr(0)("UM") = UM
|
||||
dr(0)("CveClasificacion") = CveClasificacion
|
||||
dr(0)("Clasificacion") = Clasificacion
|
||||
|
||||
dr(0)("Cantidad") = Cantidad
|
||||
dr(0)("CveUnidadMedida") = CveUnidad
|
||||
dr(0)("UM") = UM
|
||||
dr(0)("CveClasificacion") = CveClasificacion
|
||||
dr(0)("Clasificacion") = Clasificacion
|
||||
If isWithFamily() Then
|
||||
dr(0)("CveSubFamilia") = CveClasificacion
|
||||
dr(0)("SubFamilia") = Clasificacion
|
||||
End If
|
||||
|
||||
If isWithFamily() Then
|
||||
dr(0)("CveSubFamilia") = CveClasificacion
|
||||
dr(0)("SubFamilia") = Clasificacion
|
||||
dr(0)("CvePS") = CvePS
|
||||
dr(0)("PS") = PS
|
||||
dr(0)("Observacion") = Obs
|
||||
|
||||
dr(0)("CveSubProyecto") = CveSubProyecto
|
||||
dr(0)("SubProyecto") = SubProyecto
|
||||
dr(0)("CveProyecto") = CveProyecto
|
||||
dr(0)("Proyecto") = Proyecto
|
||||
dr(0)("Importe") = Importe
|
||||
dr(0)("Descuento") = Descuento
|
||||
dr(0)("Total") = Total
|
||||
dr(0)("IEPSPS") = IEPSPS * Total
|
||||
dr(0)("IEPSPSPorcentaje") = IEPSPS
|
||||
dr(0)("IEPSPSIVA") = IEPSPSIVA * Total
|
||||
dr(0)("IEPSPSIVAPorcentaje") = IEPSPSIVA
|
||||
|
||||
'If DdlIVA.SelectedValue.ToDecimal = 1 Then dr(0)("IVA") = 0 Else dr(0)("IVA") = IvaPS * Total
|
||||
dr(0)("IVAPorcentaje") = If(IvaPS = -1, Math.Round(DdlIVA.SelectedValue.ToDecimal - 1, 2), 0)
|
||||
Dim TotalGravado As Decimal = Total
|
||||
If IEPSPSIVA > 0 Then TotalGravado = Total * (1 + IEPSPSIVA) 'grava para iva, el importe del IEPS
|
||||
dr(0)("IVA") = Math.Round(dr(0)("IVAPorcentaje").ToString.ToDecimal * TotalGravado, 2)
|
||||
|
||||
dr(0)("RetIVA") = (RetIVA * Total).RoundSQL(6)
|
||||
dr(0)("RetIVAPorcentaje") = RetIVA
|
||||
dr(0)("RetISR") = (RetISR * Total).RoundSQL(6)
|
||||
dr(0)("RetISRPorcentaje") = RetISR
|
||||
|
||||
dr(0)("CveActivoFijo") = CveActivoFijo
|
||||
dr(0)("CodigoAF") = Codigo
|
||||
|
||||
dr(0)("CveCultivoCuadroDetalle") = CveCultivoCuadroDetalle
|
||||
dr(0)("Cuadro") = Cuadro
|
||||
End If
|
||||
|
||||
dr(0)("CvePS") = CvePS
|
||||
dr(0)("PS") = PS
|
||||
dr(0)("Observacion") = Obs
|
||||
|
||||
dr(0)("CveSubProyecto") = CveSubProyecto
|
||||
dr(0)("SubProyecto") = SubProyecto
|
||||
dr(0)("CveProyecto") = CveProyecto
|
||||
dr(0)("Proyecto") = Proyecto
|
||||
dr(0)("Importe") = Importe
|
||||
dr(0)("Descuento") = Descuento
|
||||
dr(0)("Total") = Total
|
||||
dr(0)("IEPSPS") = IEPSPS * Total
|
||||
dr(0)("IEPSPSPorcentaje") = IEPSPS
|
||||
dr(0)("IEPSPSIVA") = IEPSPSIVA * Total
|
||||
dr(0)("IEPSPSIVAPorcentaje") = IEPSPSIVA
|
||||
|
||||
'If DdlIVA.SelectedValue.ToDecimal = 1 Then dr(0)("IVA") = 0 Else dr(0)("IVA") = IvaPS * Total
|
||||
dr(0)("IVAPorcentaje") = If(IvaPS = -1, Math.Round(DdlIVA.SelectedValue.ToDecimal - 1, 2), 0)
|
||||
Dim TotalGravado As Decimal = Total
|
||||
If IEPSPSIVA > 0 Then TotalGravado = Total * (1 + IEPSPSIVA) 'grava para iva, el importe del IEPS
|
||||
dr(0)("IVA") = Math.Round(dr(0)("IVAPorcentaje").ToString.ToDecimal * TotalGravado, 2)
|
||||
|
||||
dr(0)("RetIVA") = (RetIVA * Total).RoundSQL(6)
|
||||
dr(0)("RetIVAPorcentaje") = RetIVA
|
||||
dr(0)("RetISR") = (RetISR * Total).RoundSQL(6)
|
||||
dr(0)("RetISRPorcentaje") = RetISR
|
||||
|
||||
|
||||
dr(0)("CveActivoFijo") = CveActivoFijo
|
||||
dr(0)("CodigoAF") = Codigo
|
||||
|
||||
dr(0)("CveCultivoCuadroDetalle") = CveCultivoCuadroDetalle
|
||||
dr(0)("Cuadro") = Cuadro
|
||||
|
||||
'si el tipodato viene de la BD, entonces sufrió una actualización
|
||||
If dr(0)("TipoDato").ToString.ToEntero = 2 Then dr(0)("TipoDato") = 1
|
||||
DtDetalle.AcceptChanges()
|
||||
@@ -9213,7 +9179,7 @@ Partial Class OC_OC
|
||||
''' <param name="ValImporte">Usado al validar Presupuesto cuando se agrega un producto o servicio </param>
|
||||
''' <returns>Verdadero si hay presupuesto, Falso si no hay presupuesto.</returns>
|
||||
Public Function ValidaPresupuesto(Opcion As Integer, Optional ValCveSubProyecto As Integer = -1, Optional ValSubProyecto As String = "", Optional ValCveClasificacion As Integer = -1, Optional ValClasificacion As String = "",
|
||||
Optional ValImporte As Decimal = 0, Optional CveMoneda As Integer = 1) As Boolean
|
||||
Optional ValImporte As Decimal = 0, Optional CveMoneda As Integer = 1, Optional ImportePrevioGuardado As Decimal = 0) As Boolean
|
||||
|
||||
Dim respuesta As Boolean = False
|
||||
|
||||
@@ -9224,6 +9190,7 @@ Partial Class OC_OC
|
||||
Dim Autorizado As Decimal = 0
|
||||
Dim Ejercido As Decimal = 0
|
||||
Dim FechaCompra As Date = TxtFecha.Text.ToDate
|
||||
ValImporte = (ValImporte - ImportePrevioGuardado)
|
||||
|
||||
If CveMoneda > 1 Then ValImporte = ValImporte * GlobalTipoCambio(FechaCompra).ToDecimal
|
||||
|
||||
@@ -9289,19 +9256,17 @@ Partial Class OC_OC
|
||||
row.Field(Of Integer)("CveClasificacion") = item.CveClasificacion
|
||||
Select row.Field(Of Decimal)(ColumnaSaldo)).Sum()
|
||||
If saldoTotal > 0 Then
|
||||
|
||||
Dim Diferencia As Decimal = saldoTotal - item.TotalSum
|
||||
|
||||
If (Diferencia) < 0 Then
|
||||
Alert($"No hay presupuesto disponible en: <br/> Subproyecto: <b>{item.SubProyecto}</b><br/> Clasificación <b>{item.Clasificacion}</b>. Se excede por <b>{Math.Abs(Diferencia).FormatoNumero}</b>", TipoMensaje.MsgAdvertencia)
|
||||
respuesta = True
|
||||
respuesta = False
|
||||
Exit For
|
||||
Else
|
||||
respuesta = True
|
||||
End If
|
||||
Else
|
||||
Alert($"No hay presupuesto disponible en: <br/> Subproyecto: <b>{item.SubProyecto}</b><br/> Clasificación <b>{item.Clasificacion}</b>.", TipoMensaje.MsgAdvertencia)
|
||||
respuesta = True
|
||||
respuesta = False
|
||||
Exit For
|
||||
End If
|
||||
Else
|
||||
@@ -9309,7 +9274,6 @@ Partial Class OC_OC
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
Else
|
||||
' Alert("No hay presupuestos.", TipoMensaje.MsgAdvertencia)
|
||||
respuesta = True
|
||||
@@ -9406,7 +9370,6 @@ Partial Class OC_OC
|
||||
|
||||
Dim descuentoParts As String() = TxtDescuentoEscalonado.Text.Split("+"c)
|
||||
|
||||
|
||||
For Each dRow As DataRow In DtDetalle.Rows
|
||||
|
||||
Dim PU As Decimal = dRow("Importe").ToString.ToDecimal
|
||||
@@ -9452,12 +9415,6 @@ Partial Class OC_OC
|
||||
dRow("TipoDato") = 1
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Next
|
||||
|
||||
DtDetalle.AcceptChanges()
|
||||
@@ -9470,7 +9427,6 @@ Partial Class OC_OC
|
||||
UpIvas.Update()
|
||||
UPPDetalle.Update()
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnEdicionMasiva_Click(sender As Object, e As EventArgs)
|
||||
@@ -9484,17 +9440,13 @@ Partial Class OC_OC
|
||||
|
||||
End If
|
||||
ModoEdicionMasiva()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub ModoEdicionMasiva()
|
||||
|
||||
If EstaEnmodiEdicionMasiva Then
|
||||
BtnEdicionMasiva.Text = "Aplicar Edición Masiva"
|
||||
|
||||
For Each GvRow As GridViewRow In GvD.Rows
|
||||
|
||||
GvRow.FCTextBox("TxtEMObsPS").Visible = True
|
||||
GvRow.FCTextBox("TxtEMCantEdit").Visible = True
|
||||
GvRow.FCTextBox("TxtEMDescuentoEdit").Visible = True
|
||||
@@ -9505,15 +9457,11 @@ Partial Class OC_OC
|
||||
GvRow.FCLiteral("LtlDescuento").Visible = False
|
||||
GvRow.FCLabel("LtlImporte").Visible = False
|
||||
GvRow.FCLinkButton("imgE").Visible = False
|
||||
|
||||
|
||||
'observación, PU, descuento, cantidad
|
||||
Next
|
||||
|
||||
Else
|
||||
|
||||
'GvD_RecalculaEdicionMasiva()
|
||||
|
||||
BtnEdicionMasiva.Text = "Edición Masiva"
|
||||
For Each GvRow As GridViewRow In GvD.Rows
|
||||
GvRow.FCTextBox("TxtEMObsPS").Visible = False
|
||||
@@ -9526,39 +9474,28 @@ Partial Class OC_OC
|
||||
GvRow.FCLiteral("LtlDescuento").Visible = True
|
||||
GvRow.FCLabel("LtlImporte").Visible = True
|
||||
GvRow.FCLinkButton("imgE").Visible = True
|
||||
|
||||
Next
|
||||
|
||||
|
||||
|
||||
End If
|
||||
RegistraScript("$(document).ready(function() {setTimeout(function() {document.getElementById('DVSeccionGVD').scrollIntoView({ behavior: 'smooth' }); }, 250);});", "100")
|
||||
|
||||
|
||||
UPPDetalle.Update()
|
||||
uppOpciones.Update()
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function GvD_RecalculaEdicionMasiva() As Boolean
|
||||
|
||||
For Each gvr As GridViewRow In GvD.Rows
|
||||
|
||||
Dim Cantidad, Importe, Descuento As Decimal
|
||||
Cantidad = gvr.FCTextBox("TxtEMCantEdit").Text.Trim.ToDecimal
|
||||
Importe = gvr.FCTextBox("TxtEMImporteEdit").Text.Trim.ToDecimal
|
||||
Descuento = gvr.FCTextBox("TxtEMDescuentoEdit").Text.Trim.ToDecimal
|
||||
Dim PS As String = gvr.DataKey("PS").ToString
|
||||
Dim Total As Decimal = Importe * Cantidad - Descuento
|
||||
|
||||
'VALIDA
|
||||
If Descuento > 0 AndAlso ((Cantidad * Importe) <= Descuento) Then
|
||||
Alert($"El producto {PS}, cantidad {Cantidad}, el campo <b>'Descuento'</b> no debe ser mayor o igual al total({(Cantidad * Importe).ToString("###,###,###.00")}).", TipoMensaje.MsgAdvertencia)
|
||||
Return False
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
|
||||
For Each gvr As GridViewRow In GvD.Rows
|
||||
|
||||
Reference in New Issue
Block a user