From fb43822e4835d8bb4014c236293a74143dc33eea Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 29 May 2024 05:23:13 -0700 Subject: [PATCH] =?UTF-8?q?--=20prep=C3=B3liza=20de=20cancelaci=C3=B3n=20d?= =?UTF-8?q?e=20presupuesto.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OC/OC.aspx.vb | 108 ++++++++++++-------------------------------------- 1 file changed, 26 insertions(+), 82 deletions(-) diff --git a/OC/OC.aspx.vb b/OC/OC.aspx.vb index c0c487db9..1c4726a8d 100644 --- a/OC/OC.aspx.vb +++ b/OC/OC.aspx.vb @@ -6,7 +6,6 @@ Imports System.Data.SqlClient Imports System.IO Imports Extensiones Imports GemBox.Spreadsheet -Imports Microsoft.Owin.Security.Provider Imports Newtonsoft.Json Partial Class OC_OC @@ -926,13 +925,13 @@ Partial Class OC_OC ChkEntregaDirecta.Checked = False End If - If UsuarioActual.CveEmpresa.Contiene(13, 73) AndAlso CveOrdenCompra > 0 AndAlso Request("Conta") IsNot Nothing AndAlso Request("Conta").ToEntero = 1 Then - If GeneraPrePolizaPresupuesto(CveOrdenCompra, Nothing) Then - Alert("PrePoliza de Presupuesto Generada Correctamente") - Else - Alert("No Se Genero la PrePoliza de Presupuesto Generada Correctamente", TipoMensaje.MsgAdvertencia) - End If - End If + 'If UsuarioActual.CveEmpresa.Contiene(13, 73) AndAlso CveOrdenCompra > 0 AndAlso Request("Conta") IsNot Nothing AndAlso Request("Conta").ToEntero = 1 Then + ' If GeneraPrePolizaPresupuesto(CveOrdenCompra, Nothing) Then + ' Alert("PrePoliza de Presupuesto Generada Correctamente") + ' Else + ' Alert("No Se Genero la PrePoliza de Presupuesto Generada Correctamente", TipoMensaje.MsgAdvertencia) + ' End If + 'End If End If @@ -2218,51 +2217,11 @@ Partial Class OC_OC Exit Sub End If - - Dim ValImporte As Decimal = (TxtCant.Text.ToDecimal * txtPrecioUnitario.Text.ToDecimal).RoundSQL(2) If Not ValidaPresupuesto(1, DdlSubProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text, ValImporte) Then Exit Sub End If - 'If UsuarioActual.Empresa.Funcionalidad(532) = "1" 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", DdlSubProyecto.SelectedValue.ToEntero, 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 = {DdlClasificacion.SelectedValue.ToEntero} AND Importe > 0").Rows.Count > 0 Then - ' Autorizado = ObjCon.DtResultados.FiltraParametros($"CveClasificacion = {DdlClasificacion.SelectedValue.ToEntero} 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, DdlProyecto.SelectedValue.ToEntero, - ' DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveUsuario, DdlClasificacion.SelectedValue.ToEntero) Then - ' If ObjCon.DtResultados.Rows.Count > 0 Then - ' Ejercido = ObjCon.DtResultados.Rows(0)("Ejercido").ToString.ToDecimal - ' End If - ' End If - ' End If - ' End If - 'End If - 'ObjCon.Dispose() - - 'If CvePresupuesto > 0 And Autorizado > 0 Then - ' Dim Diferencia As Decimal = (Ejercido + If(txtPrecioUnitario.Text.ToDecimal > 0, (txtPrecioUnitario.Text.ToDecimal * TxtCant.Text.ToDecimal) - TxtDescuentoAdd.Text.ToDecimal, 0)) - Autorizado - ' If Diferencia > 0 Then - ' Alert($"No hay presupuesto disponible en el subproyecto {DdlSubProyecto.SelectedItem.Text} y la clasificación {DdlClasificacion.SelectedItem.Text} se excede por {Diferencia.FormatoNumero}", TipoMensaje.MsgAdvertencia) - ' Exit Sub - ' End If - 'End If - 'End If - - - - Dim RetISR As Decimal = DrPS("RetISR").ToString.ToDecimal Dim RetIVA As Decimal = DrPS("RetIVA").ToString.ToDecimal Dim IvaPS As Decimal = DrPS("IVA").ToString.ToDecimal @@ -3551,8 +3510,7 @@ Partial Class OC_OC End If - - If UsuarioActual.CveEmpresa.Contiene(13, 73) Then + If UsuarioActual.Empresa.Funcionalidad(532) = "1" Then If Not GeneraPrePolizaPresupuesto(objOrdenCompra.CveOrdenCompra, objOrdenCompra.IniciaTransacSQL) Then HuboError = True @@ -3560,7 +3518,6 @@ Partial Class OC_OC End If - Catch ex As Exception HuboError = True End Try @@ -3717,6 +3674,10 @@ Partial Class OC_OC TieneError = True End If + If (UsuarioActual.Empresa.Funcionalidad(532) = "1") Then + GeneraPrePolizaPresupuesto(CveOrdenCompra, objOrdenCompra.IniciaTransacSQL, True) + End If + If IDPolizaPresupuestal > 0 AndAlso UsuarioActual.Empresa.UsaAC Then PolizaCancelacion = CancelarAC(ObjAC) @@ -9187,32 +9148,24 @@ Partial Class OC_OC End Function - - Private Function GeneraPrePolizaPresupuesto(CveOrdenCompraPresupuesto As Integer, Optional ByRef transaccion As SqlTransaction = Nothing) As Boolean + Private Function GeneraPrePolizaPresupuesto(CveOrdenCompraPresupuesto As Integer, Optional ByRef transaccion As SqlTransaction = Nothing, Optional EsCancelacion As Boolean = False) As Boolean Dim Respuesta As Boolean = True - If UsuarioActual.CveEmpresa.Contiene(13, 73) Then + If UsuarioActual.Empresa.Funcionalidad(532) = "1" Then Dim CveMonedaPresupuesto As Integer = DdlMoneda.SelectedValue.ToEntero Dim TC As Decimal = If(CveMonedaPresupuesto = 1, 1, GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal) If CveMonedaPresupuesto > 1 AndAlso TC = 0 Then - Alert($"No se genero la prepoliza de presupuesto, no se pudo obtener el Tipo de Cambio de la fecha {TxtFecha.Text}", TipoMensaje.MsgAdvertencia) + Alert($"No se genero la póliza de presupuesto, no se pudo obtener el Tipo de Cambio de la fecha {TxtFecha.Text}", TipoMensaje.MsgAdvertencia) Return False End If - Dim ObjConta As New ClsContabilidad() + Dim ObjConta As New ClsContabilidad(transaccion) + Dim CvePrePolizaPresupuesto = ObjConta.AddPrePolizas("OC/OC-(Presupuesto)", 53, LblTotal.Text.ToDecimal, LblTotal.Text.ToDecimal, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, DdlProveedores.SelectedText, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If transaccion Is Nothing Then - ObjConta = New ClsContabilidad() - Else - ObjConta = New ClsContabilidad(transaccion) - End If - - Dim CvePrePolizaPreSuPuesto = ObjConta.AddPrePolizas("OC/OC-(Presupuesto)", 53, LblTotal.Text.ToDecimal, LblTotal.Text.ToDecimal, DdlMoneda.SelectedValue.ToEntero, TxtFecha.Text.ToDate, DdlProveedores.SelectedText, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - If CvePrePolizaPreSuPuesto > 0 Then + If CvePrePolizaPresupuesto > 0 Then Dim EnumAgrupado = (From row In DtDetalle.AsEnumerable() Group row By @@ -9232,37 +9185,28 @@ Partial Class OC_OC For Each item In EnumAgrupado Dim SerieFolio = $"OC: {Folio}, Clasificación: {item.Clasificacion}" + Dim Multiplicador As Decimal = If(EsCancelacion, -1, 1) - Dim Importe As Decimal = item.TotalSum - Dim ImporteME As Decimal = If(CveMonedaPresupuesto = 1, 0, item.TotalSum) - Dim ImporteMN As Decimal = If(CveMonedaPresupuesto = 1, item.TotalSum, item.TotalSum * TC) + Dim Importe As Decimal = Multiplicador * item.TotalSum + Dim ImporteME As Decimal = Multiplicador * If(CveMonedaPresupuesto = 1, 0, item.TotalSum) + Dim ImporteMN As Decimal = Multiplicador * If(CveMonedaPresupuesto = 1, item.TotalSum, item.TotalSum * TC) - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaPreSuPuesto, False, Importe, ImporteMN, 154, SerieFolio, SerieFolio, ImporteME:=ImporteME, TipoCambio:=TC, CveProveedor:=DdlProveedores.SelectedValue.ToEntero, CveOC:=CveOrdenCompraPresupuesto, CveClasificacion:=item.CveClasificacion, CveSubProyecto:=item.CveSubProyecto, Contabilizable:=True) Then - Respuesta = False - Exit For + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaPresupuesto, False, Importe, ImporteMN, 154, SerieFolio, SerieFolio, ImporteME:=ImporteME, TipoCambio:=TC, CveProveedor:=DdlProveedores.SelectedValue.ToEntero, CveOC:=CveOrdenCompraPresupuesto, CveClasificacion:=item.CveClasificacion, CveSubProyecto:=item.CveSubProyecto, Contabilizable:=True) Then + Respuesta = False : Exit For End If - - If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaPreSuPuesto, True, Importe, ImporteMN, 152, SerieFolio, SerieFolio, ImporteME:=ImporteME, TipoCambio:=TC, CveProveedor:=DdlProveedores.SelectedValue.ToEntero, CveOC:=CveOrdenCompraPresupuesto, CveClasificacion:=item.CveClasificacion, CveSubProyecto:=item.CveSubProyecto, Contabilizable:=True) Then - Respuesta = False - Exit For + If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaPresupuesto, True, Importe, ImporteMN, 152, SerieFolio, SerieFolio, ImporteME:=ImporteME, TipoCambio:=TC, CveProveedor:=DdlProveedores.SelectedValue.ToEntero, CveOC:=CveOrdenCompraPresupuesto, CveClasificacion:=item.CveClasificacion, CveSubProyecto:=item.CveSubProyecto, Contabilizable:=True) Then + Respuesta = False : Exit For End If - Next Else Respuesta = False End If - - - End If - Return Respuesta End Function - - #End Region