diff --git a/App_Code/ClsContratos.vb b/App_Code/ClsContratos.vb
index 3c0f7b656..52d3826f9 100644
--- a/App_Code/ClsContratos.vb
+++ b/App_Code/ClsContratos.vb
@@ -3201,7 +3201,7 @@ Public Class ClsContratos
End Function
- Public Function GetPresupuestosResumen(CveEmpresa As Integer, CveSubProyecto As Integer, Opcion As Integer) As Boolean
+ Public Function GetPresupuestosResumen(CveEmpresa As Integer, CveSubProyecto As Integer, FechaInicio As Date, FechaFin As Date, Opcion As Integer) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Con_PresupuestosResumenGet")
@@ -3209,6 +3209,8 @@ Public Class ClsContratos
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto
.Add("@Opcion", SqlDbType.Int).Value = Opcion
+ .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio
+ .Add("@FechaFin", SqlDbType.Date).Value = FechaFin
End With
Try
diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb
index 9793c9c20..620f20dba 100644
--- a/OC/OC.aspx.vb
+++ b/OC/OC.aspx.vb
@@ -9056,54 +9056,46 @@ Partial Class OC_OC
Dim ObjCon As New ClsContratos
Dim CvePresupuesto As Integer = 0
- Dim Autorizado As Double = 0
- Dim Ejercido As Double = 0
-
- If ObjCon.GetPresupuestosResumen(UsuarioActual.CveEmpresa, -1, 2) Then
-
- Dim FechaCompra As Date = TxtFecha.Text.ToDate
+ Dim Autorizado As Decimal = 0
+ Dim Ejercido As Decimal = 0
+ Dim FechaCompra As Date = TxtFecha.Text.ToDate
+ If ObjCon.GetPresupuestosResumen(UsuarioActual.CveEmpresa, -1, FechaCompra.FirstDayOfMonth, FechaCompra.LastDayOfMonth, 2) Then
+ Dim ColumnaSaldo As String = "Saldo"
+ If UsuarioActual.CveEmpresa.Contiene(13, 83) Then ColumnaSaldo = "SalodComprometido"
Dim resultadosFiltrados = From row In ObjCon.DtResultados.AsEnumerable()
- Where FechaCompra >= row.Field(Of Date)("FechaInicio") AndAlso
- FechaCompra <= row.Field(Of Date)("FechaFin")
Select row
-
- If resultadosFiltrados.Count > 0 Then
+ If ObjCon.DtResultados.Rows.Count > 0 Then
If Opcion = 1 Then
-
Dim tieneRegistrosConCveSubProyecto As Boolean = resultadosFiltrados.Any(Function(row) CType(row("CveSubProyecto"), Integer) = ValCveSubProyecto)
If tieneRegistrosConCveSubProyecto Then
Dim saldoTotal As Decimal = (From row In resultadosFiltrados
Where row.Field(Of Integer)("CveSubProyecto") = ValCveSubProyecto AndAlso
row.Field(Of Integer)("CveClasificacion") = ValCveClasificacion
- Select row.Field(Of Decimal)("Saldo")).Sum()
+ Select row.Field(Of Decimal)(ColumnaSaldo)).Sum()
If saldoTotal > 0 Then
Dim TotalAcumuladoTabla As Decimal = (DtDetalle.SUM("Total", $" CveSubProyecto = {ValCveSubProyecto} AND CveClasificacion = {ValCveClasificacion} "))
Dim Diferencia As Decimal = saldoTotal - TotalAcumuladoTabla - ValImporte
If (Diferencia) < 0 Then
- Alert($"No hay presupuesto disponible en el subproyecto {ValSubProyecto} con la clasificación {ValClasificacion}. Se excede por { Math.Abs(Diferencia).FormatoNumero}", TipoMensaje.MsgAdvertencia)
+ Alert($"No hay presupuesto disponible en:
Subproyecto: {ValSubProyecto} Clasificación: {ValClasificacion}. Se excede por { Math.Abs(Diferencia).FormatoNumero}", TipoMensaje.MsgAdvertencia)
respuesta = False
-
Else
respuesta = True
End If
-
Else
- Alert($"No hay presupuesto disponible en el subproyecto {ValSubProyecto} con la clasificación {ValClasificacion}.", TipoMensaje.MsgAdvertencia)
+ Alert($"No hay presupuesto disponible en:
Subproyecto: {ValSubProyecto} Clasificación: {ValClasificacion}.", TipoMensaje.MsgAdvertencia)
respuesta = False
End If
Else
respuesta = True
End If
-
Else
-
Dim EnumAgrupado = (From row In DtDetalle.AsEnumerable()
Group row By
SubProyecto = row.Field(Of String)("SubProyecto"),
@@ -9127,7 +9119,7 @@ Partial Class OC_OC
Dim saldoTotal As Decimal = (From row In resultadosFiltrados
Where row.Field(Of Integer)("CveSubProyecto") = item.CveSubProyecto AndAlso
row.Field(Of Integer)("CveClasificacion") = item.CveClasificacion
- Select row.Field(Of Decimal)("Saldo")).Sum()
+ Select row.Field(Of Decimal)(ColumnaSaldo)).Sum()
If saldoTotal > 0 Then
Dim Diferencia As Decimal = saldoTotal - item.TotalSum
@@ -9139,7 +9131,6 @@ Partial Class OC_OC
Else
respuesta = True
End If
-
Else
Alert($"No hay presupuesto disponible en el subproyecto {item.SubProyecto} con la clasificación {item.Clasificacion}.", TipoMensaje.MsgAdvertencia)
respuesta = False
@@ -9149,7 +9140,6 @@ Partial Class OC_OC
respuesta = True
End If
Next
-
End If
Else
@@ -9160,16 +9150,10 @@ Partial Class OC_OC
'Alert("No hay presupuestos.", TipoMensaje.MsgAdvertencia)
respuesta = False
End If
-
ObjCon.Dispose()
-
-
-
Else
respuesta = True
End If
-
-
Return respuesta
End Function