-- prespuestos resumen

This commit is contained in:
2024-05-20 19:39:17 -07:00
parent 4d6d7b3e0c
commit 55d070df28
2 changed files with 14 additions and 28 deletions

View File

@@ -3201,7 +3201,7 @@ Public Class ClsContratos
End Function 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 Dim Retorno As Boolean = False
DataAdapter("PA_Con_PresupuestosResumenGet") DataAdapter("PA_Con_PresupuestosResumenGet")
@@ -3209,6 +3209,8 @@ Public Class ClsContratos
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto
.Add("@Opcion", SqlDbType.Int).Value = Opcion .Add("@Opcion", SqlDbType.Int).Value = Opcion
.Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio
.Add("@FechaFin", SqlDbType.Date).Value = FechaFin
End With End With
Try Try

View File

@@ -9056,54 +9056,46 @@ Partial Class OC_OC
Dim ObjCon As New ClsContratos Dim ObjCon As New ClsContratos
Dim CvePresupuesto As Integer = 0 Dim CvePresupuesto As Integer = 0
Dim Autorizado As Double = 0 Dim Autorizado As Decimal = 0
Dim Ejercido As Double = 0 Dim Ejercido As Decimal = 0
Dim FechaCompra As Date = TxtFecha.Text.ToDate
If ObjCon.GetPresupuestosResumen(UsuarioActual.CveEmpresa, -1, 2) Then
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() Dim resultadosFiltrados = From row In ObjCon.DtResultados.AsEnumerable()
Where FechaCompra >= row.Field(Of Date)("FechaInicio") AndAlso
FechaCompra <= row.Field(Of Date)("FechaFin")
Select row Select row
If ObjCon.DtResultados.Rows.Count > 0 Then
If resultadosFiltrados.Count > 0 Then
If Opcion = 1 Then If Opcion = 1 Then
Dim tieneRegistrosConCveSubProyecto As Boolean = resultadosFiltrados.Any(Function(row) CType(row("CveSubProyecto"), Integer) = ValCveSubProyecto) Dim tieneRegistrosConCveSubProyecto As Boolean = resultadosFiltrados.Any(Function(row) CType(row("CveSubProyecto"), Integer) = ValCveSubProyecto)
If tieneRegistrosConCveSubProyecto Then If tieneRegistrosConCveSubProyecto Then
Dim saldoTotal As Decimal = (From row In resultadosFiltrados Dim saldoTotal As Decimal = (From row In resultadosFiltrados
Where row.Field(Of Integer)("CveSubProyecto") = ValCveSubProyecto AndAlso Where row.Field(Of Integer)("CveSubProyecto") = ValCveSubProyecto AndAlso
row.Field(Of Integer)("CveClasificacion") = ValCveClasificacion row.Field(Of Integer)("CveClasificacion") = ValCveClasificacion
Select row.Field(Of Decimal)("Saldo")).Sum() Select row.Field(Of Decimal)(ColumnaSaldo)).Sum()
If saldoTotal > 0 Then If saldoTotal > 0 Then
Dim TotalAcumuladoTabla As Decimal = (DtDetalle.SUM("Total", $" CveSubProyecto = {ValCveSubProyecto} AND CveClasificacion = {ValCveClasificacion} ")) Dim TotalAcumuladoTabla As Decimal = (DtDetalle.SUM("Total", $" CveSubProyecto = {ValCveSubProyecto} AND CveClasificacion = {ValCveClasificacion} "))
Dim Diferencia As Decimal = saldoTotal - TotalAcumuladoTabla - ValImporte Dim Diferencia As Decimal = saldoTotal - TotalAcumuladoTabla - ValImporte
If (Diferencia) < 0 Then If (Diferencia) < 0 Then
Alert($"No hay presupuesto disponible en el subproyecto <b>{ValSubProyecto}</b> con la clasificación <b>{ValClasificacion}</b>. Se excede por <b>{ Math.Abs(Diferencia).FormatoNumero}</b>", TipoMensaje.MsgAdvertencia) Alert($"No hay presupuesto disponible en: <br/> Subproyecto:<b> {ValSubProyecto}</b> Clasificación:<b> {ValClasificacion}</b>. Se excede por <b>{ Math.Abs(Diferencia).FormatoNumero}</b>", TipoMensaje.MsgAdvertencia)
respuesta = False respuesta = False
Else Else
respuesta = True respuesta = True
End If End If
Else Else
Alert($"No hay presupuesto disponible en el subproyecto <b>{ValSubProyecto}</b> con la clasificación <b>{ValClasificacion}</b>.", TipoMensaje.MsgAdvertencia) Alert($"No hay presupuesto disponible en: <br/> Subproyecto:<b> {ValSubProyecto}</b> Clasificación:<b> {ValClasificacion}</b>.", TipoMensaje.MsgAdvertencia)
respuesta = False respuesta = False
End If End If
Else Else
respuesta = True respuesta = True
End If End If
Else Else
Dim EnumAgrupado = (From row In DtDetalle.AsEnumerable() Dim EnumAgrupado = (From row In DtDetalle.AsEnumerable()
Group row By Group row By
SubProyecto = row.Field(Of String)("SubProyecto"), SubProyecto = row.Field(Of String)("SubProyecto"),
@@ -9127,7 +9119,7 @@ Partial Class OC_OC
Dim saldoTotal As Decimal = (From row In resultadosFiltrados Dim saldoTotal As Decimal = (From row In resultadosFiltrados
Where row.Field(Of Integer)("CveSubProyecto") = item.CveSubProyecto AndAlso Where row.Field(Of Integer)("CveSubProyecto") = item.CveSubProyecto AndAlso
row.Field(Of Integer)("CveClasificacion") = item.CveClasificacion 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 If saldoTotal > 0 Then
Dim Diferencia As Decimal = saldoTotal - item.TotalSum Dim Diferencia As Decimal = saldoTotal - item.TotalSum
@@ -9139,7 +9131,6 @@ Partial Class OC_OC
Else Else
respuesta = True respuesta = True
End If End If
Else Else
Alert($"No hay presupuesto disponible en el subproyecto <b>{item.SubProyecto}</b> con la clasificación <b>{item.Clasificacion}</b>.", TipoMensaje.MsgAdvertencia) Alert($"No hay presupuesto disponible en el subproyecto <b>{item.SubProyecto}</b> con la clasificación <b>{item.Clasificacion}</b>.", TipoMensaje.MsgAdvertencia)
respuesta = False respuesta = False
@@ -9149,7 +9140,6 @@ Partial Class OC_OC
respuesta = True respuesta = True
End If End If
Next Next
End If End If
Else Else
@@ -9160,16 +9150,10 @@ Partial Class OC_OC
'Alert("No hay presupuestos.", TipoMensaje.MsgAdvertencia) 'Alert("No hay presupuestos.", TipoMensaje.MsgAdvertencia)
respuesta = False respuesta = False
End If End If
ObjCon.Dispose() ObjCon.Dispose()
Else Else
respuesta = True respuesta = True
End If End If
Return respuesta Return respuesta
End Function End Function