From 78b36e410da92f2f35e451d7f80cd96a8f04cb27 Mon Sep 17 00:00:00 2001 From: rrene Date: Mon, 14 Feb 2022 08:34:38 -0700 Subject: [PATCH 1/5] =?UTF-8?q?--=20mejoras=20en=20fluctuaciones=20--=20ca?= =?UTF-8?q?ndado=20de=20no=20eliminar=20en=20regprepolizas,=20si=20tiene?= =?UTF-8?q?=20fluctuaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/ClsContabilidad.vb | 20 -------- Bancos/FluctuacionCambiaria.aspx | 77 ++++++++++++----------------- Bancos/FluctuacionCambiaria.aspx.vb | 68 ++++++++++++++++++------- Contabilidad/RegPrePoliza.aspx.vb | 8 ++- Contabilidad/RegPrePolizaS.aspx | 9 ++-- Contabilidad/RegPrePolizaS.aspx.vb | 6 +++ 6 files changed, 98 insertions(+), 90 deletions(-) diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb index 9f4d8f0e8..d6693040d 100644 --- a/App_Code/ClsContabilidad.vb +++ b/App_Code/ClsContabilidad.vb @@ -6599,26 +6599,6 @@ Public Class ClsContabilidad Return Retorno End Function - Public Function UpdateCompraTCValuacion(CveCompra As Integer, TCValuacion As Decimal) As Boolean - Dim Retorno = False - - DataAdapter("PA_Conta_ComprasTCValuacionUpdate") - - With SqlAdapter.SelectCommand.Parameters - .Add("@CveCompra", SqlDbType.Int).Value = CveCompra - .Add("@TCValuacion", SqlDbType.Decimal).Value = TCValuacion - End With - - Try - SqlAdapter.Fill(Data) - Retorno = True - Catch ex As Exception - Me.OnError("Ocurrió un error al actualizar el tipo de cambio", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) - End Try - - Return Retorno - End Function - #End Region #Region "IDisposable Support" diff --git a/Bancos/FluctuacionCambiaria.aspx b/Bancos/FluctuacionCambiaria.aspx index cb222b49c..42753215c 100644 --- a/Bancos/FluctuacionCambiaria.aspx +++ b/Bancos/FluctuacionCambiaria.aspx @@ -242,9 +242,9 @@
- + -
+ @@ -256,7 +256,7 @@ - + @@ -335,7 +335,7 @@ - + @@ -347,22 +347,19 @@ - - - +
- + + +
+ - - - -
- - + +
@@ -380,11 +377,9 @@ - - +
-
- +
@@ -402,17 +397,12 @@ -
- - - +
-
- - +
- - - - - -
+
@@ -462,8 +447,7 @@ -
- +
@@ -514,20 +498,23 @@
-
- +
+ + +
-
-
+ + +
- + @@ -535,6 +522,7 @@ +
@@ -559,20 +547,17 @@ - - +
-
- +
-
- + 0") - Dim Final As Double = GanaciaAux - PerdidaAux + Dim Final As Double = GanaciaAux - PerdidaAux + HdnClienteCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString + HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString + BtnClientesRemove.Visible = HdnClienteCvePrePoliza.Value.ToEntero > 0 + BtnGeneraVentas.Visible = Not HdnClienteCvePrePoliza.Value.ToEntero > 0 IImagenFinalVentas.Attributes("class") = If(Final > 0, "widget-thumb-icon bg-green-jungle fa fa-usd", "widget-thumb-icon bg-red fa fa-usd") @@ -255,6 +259,11 @@ Partial Class Bancos_FluctuacionCambiaria If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 6, UsuarioActual.CveEmpresa) Then GvAcreedores.DataSource = ObjBancos.DtResultados LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + HdnAcreedorCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString + HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString + BtnAcreedoresRemove.Visible = HdnAcreedorCvePrePoliza.Value.ToEntero > 0 + BtnGeneraAcreedores.Visible = Not HdnAcreedorCvePrePoliza.Value.ToEntero > 0 + Else GvAcreedores.DataSource = Nothing Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia) @@ -344,7 +353,6 @@ Partial Class Bancos_FluctuacionCambiaria ErrorRegistrar = True Exit For End If - Next Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 1, CveBitacora, UsuarioActual.CveEmpresa) @@ -353,9 +361,11 @@ Partial Class Bancos_FluctuacionCambiaria If Not ErrorRegistrar Then Conta.Commit() + BtnGeneraCompras.Visible = False Alert(String.Format("La Fluctuación se ha generado
Ver PrePóliza", CvePrePoliza), TipoMensaje.MsgInformacion) Else - Conta.RollBack() + Conta.RollBack() + Alert("Error al generar la fluctuación", TipoMensaje.MsgError) End If Conta.Dispose() End Sub @@ -448,13 +458,14 @@ Partial Class Bancos_FluctuacionCambiaria ErrorRegistrar = True End If - If Not ErrorRegistrar Then Conta.Commit() + BtnGeneraVentas.Visible = False Alert(String.Format("La Fluctuación se ha generado
Ver PrePóliza", CvePrePoliza), TipoMensaje.MsgInformacion) Else Conta.RollBack() + Alert("Error al generar la fluctuación", TipoMensaje.MsgError) End If Conta.Dispose() End Sub @@ -731,7 +742,6 @@ Partial Class Bancos_FluctuacionCambiaria Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 - Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer Dim idCtaPerdida, IdCtaGanancia As Integer Dim TipoMovto As Boolean = False @@ -750,23 +760,21 @@ Partial Class Bancos_FluctuacionCambiaria Total = LblTotalAcreedores.Text.ToDecimal If Total > 0 Then CveConceptoContable = 64 - CveCuenta = CveCuentaGanancia idCta = IdCtaGanancia TipoMovto = True Else CveConceptoContable = 65 - CveCuenta = CveCuentaPerdida idCta = idCtaPerdida TipoMovto = False End If Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Acreedores", CveConceptoContable, "Fluctuación Acreedores", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoAcreedores.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Acreedores", CveConceptoContable, "Fluctuación Acreedores", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoAcreedores.SelectedValue.ToEntero) Then ErrorRegistrar = True End If - Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 6, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If CveBitacora <= 0 Then ErrorRegistrar = True End If @@ -778,26 +786,26 @@ Partial Class Bancos_FluctuacionCambiaria IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() 'movimiento de complementaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), 202, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, ImporteMX:=Total, ImporteME:=Total, CveCuenta:=CveCuentaComplementaria) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), 202, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then ErrorRegistrar = True Exit For End If - 'If Not Conta.UpdateCompraTCValuacion(gvr.DataKey("CveCompra").ToEntero, TCValuacion:=TCUltimaFluctuacion) Then - ' ErrorRegistrar = True - ' Exit For - 'End If - + If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then + ErrorRegistrar = True + Exit For + End If Next - Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 5, CveBitacora, UsuarioActual.CveEmpresa) - + Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 6, CveBitacora, UsuarioActual.CveEmpresa) If Not ErrorRegistrar Then Conta.Commit() + BtnGeneraAcreedores.Visible = False Alert(String.Format("La Fluctuación se ha generado
Ver Póliza", CvePrePoliza), TipoMensaje.MsgInformacion) Else Conta.RollBack() + Alert("Error al generar la fluctuación", TipoMensaje.MsgError) End If Conta.Dispose() Banco.Dispose() @@ -884,4 +892,30 @@ Partial Class Bancos_FluctuacionCambiaria Banco.Dispose() End Sub + + Protected Sub BtnClientesRemove_Click(sender As Object, e As EventArgs) + Dim Banco As New ClsBancos + Banco.IniciaTransacSQL() + + If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnClienteCvePrePoliza.Value.ToEntero, 2, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then + Banco.Commit() + Alert("Flucturación eliminada.") + Else + Banco.RollBack() + End If + Banco.Dispose() + End Sub + + Protected Sub BtnAcreedoresRemove_Click(sender As Object, e As EventArgs) + Dim Banco As New ClsBancos + Banco.IniciaTransacSQL() + + If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnAcreedorCvePrePoliza.Value.ToEntero, 6, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then + Banco.Commit() + Alert("Flucturación eliminada.") + Else + Banco.RollBack() + End If + Banco.Dispose() + End Sub End Class diff --git a/Contabilidad/RegPrePoliza.aspx.vb b/Contabilidad/RegPrePoliza.aspx.vb index 342ec85f1..6e3813cef 100644 --- a/Contabilidad/RegPrePoliza.aspx.vb +++ b/Contabilidad/RegPrePoliza.aspx.vb @@ -474,6 +474,12 @@ Partial Class ContabilidadC_RegPrePoliza CargaCuentasContables() End If + If dr("Modulo").ToString.Contiene("Banc/FluctuaA", "Banc/FluctuaC", "Banc/FluctuaV", "Banc/FluctuaFilial") Then + + BtnEliminar.Enabled = False + BtnEliminar.ToolTip = "No se puede eliminar al prepóliza, eliminarlos desde el módulo" + End If + ObjContabilidad.GetContabilizacionDiarioDetalle(CvePrePoliza) DtMovimientos = ObjContabilidad.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}") @@ -2114,7 +2120,7 @@ Partial Class ContabilidadC_RegPrePoliza Dim NombreArchivo As String SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet) Dim workbook As New ExcelFile() - Dim worksheet = workbook.Worksheets.Add(DdlPlantilla2.SelectedItem.Text.ToString()) + Dim worksheet = workbook.Worksheets.Add(DdlPlantilla2.SelectedItem.Text.Substring(1, 30)) Dim CvePlantilla As Integer = DdlPlantilla2.SelectedValue.ToEntero() Dim Dt As DataTable = GlobalDTContaPlantillasPolizasDetalle(CvePlantilla).FiltraParametros(String.Format("CveEmpresa={0}", UsuarioActual.CveEmpresa), "Orden") diff --git a/Contabilidad/RegPrePolizaS.aspx b/Contabilidad/RegPrePolizaS.aspx index ccd045873..15117ab36 100644 --- a/Contabilidad/RegPrePolizaS.aspx +++ b/Contabilidad/RegPrePolizaS.aspx @@ -594,7 +594,6 @@
- @@ -602,7 +601,6 @@
-
@@ -635,9 +633,8 @@ TC -
+
-
Cargo @@ -666,14 +663,14 @@ - + - +
diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb index e70ff49f9..6fd890e1f 100644 --- a/Contabilidad/RegPrePolizaS.aspx.vb +++ b/Contabilidad/RegPrePolizaS.aspx.vb @@ -495,6 +495,12 @@ Partial Class ContabilidadC_RegPrePolizaS ObjContabilidad.GetContabilizacionDiarioDetalle(CvePrePoliza) DtMovimientos = ObjContabilidad.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}") + If dr("Modulo").ToString.Contiene("Banc/FluctuaA", "Banc/FluctuaC", "Banc/FluctuaV", "Banc/FluctuaFilial") Then + + BtnEliminar.Enabled = False + BtnEliminar.ToolTip = "No se puede eliminar al prepóliza, eliminarlos desde el módulo" + End If + 'DtMovimientos.DefaultView.Sort = "OrdenPP" 'DtMovimientos = DtMovimientos.DefaultView.ToTable From 6ef6a0cd01d4582863b7127dc1e197416ab617b2 Mon Sep 17 00:00:00 2001 From: rrene Date: Mon, 14 Feb 2022 08:35:13 -0700 Subject: [PATCH 2/5] - mejora --- Inventarios/TraspasoAlmacen.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Inventarios/TraspasoAlmacen.aspx.vb b/Inventarios/TraspasoAlmacen.aspx.vb index db965ef7c..91b4b928a 100644 --- a/Inventarios/TraspasoAlmacen.aspx.vb +++ b/Inventarios/TraspasoAlmacen.aspx.vb @@ -3343,7 +3343,7 @@ Partial Class Inventarios_TraspasoAlmacen Dim PesoKg As Decimal = DrPS("PesoKg").ToString.ToDecimal Dim SATClaveUnidadMedida As String = DrPS("SATClaveUnidadMedida").ToString.Trim - If CveSATPS > 0 And PesoKg > 0 And SATClaveUnidadMedida.Length > 0 Then + If CveSATPS > 0 AndAlso PesoKg > 0 AndAlso SATClaveUnidadMedida.Length > 0 Then Respuesta = True Else Respuesta = False From 2070a41f2b802690c3a26ff32a3e13af0cc3dbf2 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Mon, 14 Feb 2022 09:37:09 -0700 Subject: [PATCH 3/5] Redireccion a cliente al eliminar venta --- Ventas/Ventas.aspx.vb | 488 +++++++++++++++++++++--------------------- 1 file changed, 244 insertions(+), 244 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index fb940169b..a1bba138d 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -8998,286 +8998,286 @@ Partial Class Ventas Try - Dim DirectoriArchivoXML As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto) ' System.IO.Path.Combine() - If Not Directory.Exists(DirectoriArchivoXML) Then - Directory.CreateDirectory(DirectoriArchivoXML) - End If - Catch ex As Exception + Dim DirectoriArchivoXML As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto) ' System.IO.Path.Combine() + If Not Directory.Exists(DirectoriArchivoXML) Then + Directory.CreateDirectory(DirectoriArchivoXML) + End If + Catch ex As Exception - End Try + End Try - Dim SeTimbro As Boolean = False - Dim SeTimbroNC As Boolean = False - Dim EstatusSMS = 0 + Dim SeTimbro As Boolean = False + Dim SeTimbroNC As Boolean = False + Dim EstatusSMS = 0 - Dim MsgCancelacionRefacturacion As Modelos.Factura.MCancelacionVentaMensaje = Nothing + Dim MsgCancelacionRefacturacion As Modelos.Factura.MCancelacionVentaMensaje = Nothing - 'TIMBRADO Y CASO ESPECIAL NOTA DE CREDITO - If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "RNC", "Cot", "Ped", "DPe", "PA", "Pd2")) Then + 'TIMBRADO Y CASO ESPECIAL NOTA DE CREDITO + If (TipoDoctoDevolucion = "" OrElse Not TipoDoctoDevolucion.Contiene("Rem", "RNC", "Cot", "Ped", "DPe", "PA", "Pd2")) Then - Dim DebeTimbrar As Boolean = True - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then - 'si tiene anticipos seleccionados y el total es cero, que no se timbre(previo empresa72) - If LblAmortizacion.Text.ToDouble > 0 And TxtTotal.Text.ToDouble <= 0 Then - DebeTimbrar = False - End If - End If + Dim DebeTimbrar As Boolean = True + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then + 'si tiene anticipos seleccionados y el total es cero, que no se timbre(previo empresa72) + If LblAmortizacion.Text.ToDouble > 0 And TxtTotal.Text.ToDouble <= 0 Then + DebeTimbrar = False + End If + End If - 'Si es AMORTIZACIÓN ANTICIPO SOBRE FACTURA EN CERO no debe timbrar - If DdlTipoAmortizacionAnticipo.SelectedValue = "3" Then - DebeTimbrar = False - End If + 'Si es AMORTIZACIÓN ANTICIPO SOBRE FACTURA EN CERO no debe timbrar + If DdlTipoAmortizacionAnticipo.SelectedValue = "3" Then + DebeTimbrar = False + End If - If UsuarioActual.TienePermisoProceso(335) Then - DebeTimbrar = False - End If + If UsuarioActual.TienePermisoProceso(335) Then + DebeTimbrar = False + End If - If DebeTimbrar AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then - If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso (UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1) Then + If DebeTimbrar AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Egs", "Ant", "Dev") Then + If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso (UsuarioActual.Empresa.FacturaProduccion OrElse UsuarioActual.CveEmpresa = 1) Then - 'FACTURA INGRESO/EGRESO - Dim FM As New Modelos.FemsaFactura - Dim TmpDT7Eleven As New DataTable - Dim TmpDTComplementosTimbrado As New DataTable + 'FACTURA INGRESO/EGRESO + Dim FM As New Modelos.FemsaFactura + Dim TmpDT7Eleven As New DataTable + Dim TmpDTComplementosTimbrado As New DataTable - If AplicaFEMSA Then - PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado) - End If + If AplicaFEMSA Then + PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado) + End If - Dim ObjTimbrado As New Timbrado - SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) - Dim FolioFiscalFactura As String = ObjTimbrado.UUID - Dim MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI - ObjTimbrado = Nothing + Dim ObjTimbrado As New Timbrado + SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura) + Dim FolioFiscalFactura As String = ObjTimbrado.UUID + Dim MsgErrorTimbrado = ObjTimbrado.MensajeErrorCFDI + ObjTimbrado = Nothing - 'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION - If DebeTimbrar AndAlso ListaNotasCreditoGeneradas.Count > 0 Then - Try - For Each NCGenerada In ListaNotasCreditoGeneradas - If NCGenerada.Timbre IsNot Nothing Then - NCGenerada.Timbre.CFDIRelacionados.UUID.Clear() - NCGenerada.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura) + 'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION + If DebeTimbrar AndAlso ListaNotasCreditoGeneradas.Count > 0 Then + Try + For Each NCGenerada In ListaNotasCreditoGeneradas + If NCGenerada.Timbre IsNot Nothing Then + NCGenerada.Timbre.CFDIRelacionados.UUID.Clear() + NCGenerada.Timbre.CFDIRelacionados.UUID.Add(FolioFiscalFactura) - Dim ObjTimbradoNC As New Timbrado - Dim TimbroNC = ObjTimbradoNC.TimbrarFactura(UsuarioActual, NCGenerada) + Dim ObjTimbradoNC As New Timbrado + Dim TimbroNC = ObjTimbradoNC.TimbrarFactura(UsuarioActual, NCGenerada) - If Not TimbroNC Then - Alert(ObjTimbradoNC.MensajeErrorCFDI, TipoMensaje.MsgError) - End If - ObjTimbradoNC = Nothing - End If - Next - Catch ex As Exception - OnError("Ocurrió un error al timbrar la NC.", ex) - End Try - - End If - - If SeTimbro AndAlso ObjFactura.TipoDocto.Contiene("Ing") Then - EstatusSMS = EnviarSMSTimbrado(ObjEventos) - End If - - If Not SeTimbro Then - Alert(MsgErrorTimbrado, TipoMensaje.MsgError) - End If - - 'CANCELAR FACTURA ANTERIOR - If SeTimbro AndAlso (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then - If Me.ObjFacturaNC IsNot Nothing Then - Me.ObjFacturaNC.CveEstatusRefacturacion = 2 'MARCAR COMO REFACTURADA - MsgCancelacionRefacturacion = Me.ObjFacturaNC.CancelarPorRefacturacion(Me.ObjFacturaNC.CveMotivoCancelacion, Me.ObjFacturaNC.MotivoCancelacion, FolioFiscalFactura) + If Not TimbroNC Then + Alert(ObjTimbradoNC.MensajeErrorCFDI, TipoMensaje.MsgError) End If + ObjTimbradoNC = Nothing End If - End If - End If + Next + Catch ex As Exception + OnError("Ocurrió un error al timbrar la NC.", ex) + End Try End If - 'VERIFICAR 100% AVANCE A IMPORTE Y CANTIDAD - If ObjFactura.TipoDocto.Contiene("Ing", "Ant") AndAlso CveContrato > 0 Then - If ObjContr.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then + If SeTimbro AndAlso ObjFactura.TipoDocto.Contiene("Ing") Then + EstatusSMS = EnviarSMSTimbrado(ObjEventos) + End If - If ObjContr.DtResultados.Rows.Count > 0 Then + If Not SeTimbro Then + Alert(MsgErrorTimbrado, TipoMensaje.MsgError) + End If - - 'SI ES FLEXIBLE QUE NOTIFIQUE EL MONTO MAXIMO, SI NO LO ES QUE NOTIFIQUE EL PORCENTAJE ALCANZADO... FLEXIBLE = 2, NO FLEXIBLE = 1 - If ObjContr.DtResultados.Rows(0)("ModalidadDetalle").ToString() = "1" Then - Dim PorcentajeAvance As Double = ObjContr.DtResultados.Rows(0)("ContratoAvance").ToString().ToDouble - - If PorcentajeAvance >= 100 Then - EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString()) - End If - Else - Dim MontoMaximo As Double = ObjContr.DtResultados.Rows(0)("ImporteMax").ToString().ToDouble - Dim Avance As Double = ObjContr.DtResultados.Rows(0)("Avance").ToString().ToDouble - - Dim PorcentajeAvance As Double = (Avance / MontoMaximo) * 100 - - If PorcentajeAvance >= 100 And MontoMaximo > 0 Then - EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString(), MontoMaximo) - End If - End If - - End If + 'CANCELAR FACTURA ANTERIOR + If SeTimbro AndAlso (Me.CveDevolucion > 0 AndAlso Me.NuevaFactura = 1) Then + If Me.ObjFacturaNC IsNot Nothing Then + Me.ObjFacturaNC.CveEstatusRefacturacion = 2 'MARCAR COMO REFACTURADA + MsgCancelacionRefacturacion = Me.ObjFacturaNC.CancelarPorRefacturacion(Me.ObjFacturaNC.CveMotivoCancelacion, Me.ObjFacturaNC.MotivoCancelacion, FolioFiscalFactura) End If End If + End If + End If - 'MENSAJE PRINCIPAL - MensajeAlert.AppendFormat(String.Format("
La {0}: {1} se generó correctamente.

", ObjFactura.TipoDocumento, ObjFactura.SerieFolio)) + End If + + 'VERIFICAR 100% AVANCE A IMPORTE Y CANTIDAD + If ObjFactura.TipoDocto.Contiene("Ing", "Ant") AndAlso CveContrato > 0 Then + If ObjContr.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then + + If ObjContr.DtResultados.Rows.Count > 0 Then - ' DESCARGA XML - SI SE TIMBRA MANDA CORREO CON FACTURA - If SeTimbro Then - Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) - If File.Exists(ArchivoXML) Then - MensajeAlert.AppendFormat("", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", ObjFactura.SerieFolio, ObjFactura.TipoDocto))) + 'SI ES FLEXIBLE QUE NOTIFIQUE EL MONTO MAXIMO, SI NO LO ES QUE NOTIFIQUE EL PORCENTAJE ALCANZADO... FLEXIBLE = 2, NO FLEXIBLE = 1 + If ObjContr.DtResultados.Rows(0)("ModalidadDetalle").ToString() = "1" Then + Dim PorcentajeAvance As Double = ObjContr.DtResultados.Rows(0)("ContratoAvance").ToString().ToDouble + + If PorcentajeAvance >= 100 Then + EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString()) End If - GeneraPDFFactura(ChkEnviarFactura.Checked) 'MANDA CORREO - - End If - - 'DESCARGA PDF - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant", "Egs", "Dev", "Pd2") Then - 'If Not ImprimeAlert Then - - Dim ArchivoIngPyMe As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.mrt", UsuarioActual.Empresa.Ruta)) - Dim ArchivoIng As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.rdlc", UsuarioActual.Empresa.Ruta)) - Dim ArchivoRem As New System.IO.FileInfo(String.Format("{0}Formatos/Remision.rdlc", UsuarioActual.Empresa.Ruta)) - Dim ArchivoEgs As New System.IO.FileInfo(String.Format("{0}Formatos/NotaCredito.rdlc", UsuarioActual.Empresa.Ruta)) - - If ArchivoIng.Exists Or ArchivoRem.Exists Or ArchivoIngPyMe.Exists Or ArchivoEgs.Exists Then - MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))) - Else - MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ") - End If - End If - - 'ERROR DE NO TIMBRADO - If Not SeTimbro And (DdlTipoComprobante.SelectedValue = "Ing" Or DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev") Or DdlTipoComprobante.SelectedValue = "Ant") Then - MensajeAlert.AppendFormat("La factura no se pudo timbrar. Por favor intentelo de nuevo a traves del boton Emitir.") - End If - - 'ERROR DE NO TIMBRADO NC - If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 AndAlso Not SeTimbroNC Then - MensajeAlert.AppendFormat("
La NC #{0} no se pudo timbrar. Por favor intentelo de nuevo a traves del boton Emitir.", CType(ObjNC(0), Modelos.Factura).SerieFolio) - End If - - 'NOTIFICACION DE SMS - Select Case EstatusSMS - Case 1 - MensajeAlert.AppendFormat("
Notificación SMS: enviado con éxito al cliente al celular: {0}", ObjFactura.Cliente.CobranzaTelefono) - Case 2 - MensajeAlert.AppendFormat("
Notificación SMS: sin enviar. Ocurrió un error en el envío, por favor verifique la información del cliente.") - Case 3 - MensajeAlert.AppendFormat("
Notificación SMS: sin enviar. No se pudo cargar el celular del cliente, por favor verifique la información del cliente.") - End Select - - - 'AUTO DESCARGAR PDF - If UsuarioActual.CveEmpresa.Contiene(72, 1) Then - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then - RegistraScript($"window.location.href = '/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))}'", "Imprimir") - End If - End If - - 'DESCARGAR PDF DE CICOVISA - 'If UsuarioActual.CveEmpresa = 72 And CveCliente = 70381 Then - ' If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") Then - ' MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=CIC&CVEVENTA={0}", CveVenta))) - ' End If - 'End If - - If DdlTipoComprobante.SelectedValue = "Cot" Then - If Not CveEmpresaCRM > 0 Then - If CveVenta > 0 Then MensajeAlert = New StringBuilder - Dim ArchivoCotizacion As New System.IO.FileInfo(String.Format("{0}Formatos/Cotizacion.rdlc", UsuarioActual.Empresa.Ruta)) - - If Opcion = "Cot" And UsuarioActual.Empresa.Funcionalidad(558) = "1" Then - MensajeAlert.AppendFormat("Facturar

", CveVenta) - End If - - If ArchivoCotizacion.Exists Then - MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=0", CveVenta))) - Else - MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ") - End If - - GeneraPDFCotizacion(ChkEnviarFactura.Checked) ' MANDA CORREO - End If - ElseIf DdlTipoComprobante.SelectedValue = "Rem" Then - If UsuarioActual.CveEmpresa.Contiene(81, 109) Then - EnviaPDFRemision(ChkEnviarFactura.Checked) - End If - End If - - 'ENVIA CORREO CON DETALLE DEL CONTRATO - If DdlTipoComprobante.SelectedValue.Contiene("DPe", "Ped") Then - If Not String.IsNullOrEmpty(CorreoNotificacionPedDev) Then - EnviarCorreoDevPed() - End If - End If - - 'MOVIMIENTO DE ALMACEN - If ObjFactura.Inv_CveMovimiento > 0 Then - MensajeAlert.AppendFormat("

Movimiento de Almacén
", ObjFactura.Inv_CveMovimiento) - End If - - If TieneAnticipo AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then - MensajeAlert.AppendFormat("

Se generó una Nota de crédito Folio: {0} amortizando el anticipo
", ObjFacturaDevolucion.Folio) - End If - - If RBLPago.SelectedValue.ToEntero() = 2 And TxtCambio.Text.ToDecimal > 0 Then - MensajeAlert.AppendFormat("

Su cambio es de ${0}
", TxtCambio.Text.ToDecimal.FormatoNumero(2)) - End If - - If CveVentaNCProntoPago > 0 Then - MensajeAlert.AppendFormat(String.Format("
La nota de crédito {0} por descuento pronto pago se generó correctamente.

", SerieFolioNCProntoPago)) - End If - - If MsgCancelacionRefacturacion IsNot Nothing Then - If Not MsgCancelacionRefacturacion.HuboError Then - If MsgCancelacionRefacturacion.CveEstatus = 5 Then - MensajeAlert.AppendFormat("
El folio {0} fue cancelado. Descargar Acuse", Me.ObjFacturaNC.SerieFolio, Encripta(String.Format("OP=CAN&CVEVTA={0}", Me.ObjFacturaNC.CveVenta))) - ElseIf MsgCancelacionRefacturacion.CveEstatus = 20 Then - MensajeAlert.AppendFormat("
El folio {0} esta en proceso de cancelación. Descargar Acuse", Me.ObjFacturaNC.SerieFolio, Encripta(String.Format("OP=CAN&CVEVTA={0}", Me.ObjFacturaNC.CveVenta))) - End If - MensajeAlert.AppendFormat(" Enviar Acuse.

", Me.ObjFacturaNC.CveVenta) - End If - End If - - 'MUESTA ALERT OK - ' si es elrol 1165-Ventas,EMp:80, o la empresa 119, recarga ventas, para seguir registrando-. - 'Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";")) - 'Alert(MensajeAlert.ToString(), TipoMensaje.MsgInformacion, Liga) - - Dim Liga As String = "" - Dim Liga2 As String = "" - - If Request("CveCliente") IsNot Nothing AndAlso Request("CveCliente").ToEntero > 0 Then - Liga = $"document.location.href=""/Ventas/Ventas.aspx?CveCliente={Request("CveCliente")}"";" Else - Liga = "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";" + Dim MontoMaximo As Double = ObjContr.DtResultados.Rows(0)("ImporteMax").ToString().ToDouble + Dim Avance As Double = ObjContr.DtResultados.Rows(0)("Avance").ToString().ToDouble + + Dim PorcentajeAvance As Double = (Avance / MontoMaximo) * 100 + + If PorcentajeAvance >= 100 And MontoMaximo > 0 Then + EnviarNotificacionAvance(ObjContr.DtResultados.Rows(0)("NumeroContrato").ToString(), ObjContr.DtResultados.Rows(0)("DescripcionContrato").ToString(), ObjContr.DtResultados.Rows(0)("ContratoTipo").ToString(), ObjContr.DtResultados.Rows(0)("NombreComercial").ToString(), ObjContr.DtResultados.Rows(0)("CorreoVendedor").ToString(), MontoMaximo) + End If End If - If CveEmpresaCRM > 0 Then - Liga2 = $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";" - Else - Liga2 = $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}"";" - End If + End If + End If + End If - Alert(MensajeAlert.ToString(), TipoMensaje.MsgDosBotones, Liga, TextoConfirmacion:="Seguir Registrando", TextoSegundoBoton:="Ir al Cliente", JSBtn2:=Liga2, ShowCloseButton:=False) + 'MENSAJE PRINCIPAL + MensajeAlert.AppendFormat(String.Format("
La {0}: {1} se generó correctamente.

", ObjFactura.TipoDocumento, ObjFactura.SerieFolio)) - MensajeAlert.Clear() - 'LIMPIA CONDICIONES DE PAGO - CONTADO - RBLPago.SelectedValue = "1" - LimpiaEscondeContado() - BtnEmitirImprimir.Visible = False - ObjFactura = Nothing + ' DESCARGA XML - SI SE TIMBRA MANDA CORREO CON FACTURA + If SeTimbro Then + Dim ArchivoXML = String.Format("{0}/XML/{1}/{2}.xml", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + If File.Exists(ArchivoXML) Then + MensajeAlert.AppendFormat("", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", ObjFactura.SerieFolio, ObjFactura.TipoDocto))) + End If + GeneraPDFFactura(ChkEnviarFactura.Checked) 'MANDA CORREO + End If + + 'DESCARGA PDF + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant", "Egs", "Dev", "Pd2") Then + 'If Not ImprimeAlert Then + + Dim ArchivoIngPyMe As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.mrt", UsuarioActual.Empresa.Ruta)) + Dim ArchivoIng As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.rdlc", UsuarioActual.Empresa.Ruta)) + Dim ArchivoRem As New System.IO.FileInfo(String.Format("{0}Formatos/Remision.rdlc", UsuarioActual.Empresa.Ruta)) + Dim ArchivoEgs As New System.IO.FileInfo(String.Format("{0}Formatos/NotaCredito.rdlc", UsuarioActual.Empresa.Ruta)) + + If ArchivoIng.Exists Or ArchivoRem.Exists Or ArchivoIngPyMe.Exists Or ArchivoEgs.Exists Then + MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))) + Else + MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ") + End If + End If + + 'ERROR DE NO TIMBRADO + If Not SeTimbro And (DdlTipoComprobante.SelectedValue = "Ing" Or DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev") Or DdlTipoComprobante.SelectedValue = "Ant") Then + MensajeAlert.AppendFormat("La factura no se pudo timbrar. Por favor intentelo de nuevo a traves del boton Emitir.") + End If + + 'ERROR DE NO TIMBRADO NC + If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 AndAlso Not SeTimbroNC Then + MensajeAlert.AppendFormat("
La NC #{0} no se pudo timbrar. Por favor intentelo de nuevo a traves del boton Emitir.", CType(ObjNC(0), Modelos.Factura).SerieFolio) + End If + + 'NOTIFICACION DE SMS + Select Case EstatusSMS + Case 1 + MensajeAlert.AppendFormat("
Notificación SMS: enviado con éxito al cliente al celular: {0}", ObjFactura.Cliente.CobranzaTelefono) + Case 2 + MensajeAlert.AppendFormat("
Notificación SMS: sin enviar. Ocurrió un error en el envío, por favor verifique la información del cliente.") + Case 3 + MensajeAlert.AppendFormat("
Notificación SMS: sin enviar. No se pudo cargar el celular del cliente, por favor verifique la información del cliente.") + End Select + + + 'AUTO DESCARGAR PDF + If UsuarioActual.CveEmpresa.Contiene(72, 1) Then + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") Then + RegistraScript($"window.location.href = '/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1", CveVenta))}'", "Imprimir") + End If + End If + + 'DESCARGAR PDF DE CICOVISA + 'If UsuarioActual.CveEmpresa = 72 And CveCliente = 70381 Then + ' If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") Then + ' MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=CIC&CVEVENTA={0}", CveVenta))) + ' End If + 'End If + + If DdlTipoComprobante.SelectedValue = "Cot" Then + If Not CveEmpresaCRM > 0 Then + If CveVenta > 0 Then MensajeAlert = New StringBuilder + Dim ArchivoCotizacion As New System.IO.FileInfo(String.Format("{0}Formatos/Cotizacion.rdlc", UsuarioActual.Empresa.Ruta)) + + If Opcion = "Cot" And UsuarioActual.Empresa.Funcionalidad(558) = "1" Then + MensajeAlert.AppendFormat("Facturar

", CveVenta) + End If + + If ArchivoCotizacion.Exists Then + MensajeAlert.AppendFormat("
", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=0", CveVenta))) Else - ObjVentas.RollBack() + MensajeAlert.Append("Ocurrió un error al generar el PDF. Por favor vuelva a entrar a la factura para imprimir el PDF. ") + End If + + GeneraPDFCotizacion(ChkEnviarFactura.Checked) ' MANDA CORREO + End If + ElseIf DdlTipoComprobante.SelectedValue = "Rem" Then + If UsuarioActual.CveEmpresa.Contiene(81, 109) Then + EnviaPDFRemision(ChkEnviarFactura.Checked) + End If + End If + + 'ENVIA CORREO CON DETALLE DEL CONTRATO + If DdlTipoComprobante.SelectedValue.Contiene("DPe", "Ped") Then + If Not String.IsNullOrEmpty(CorreoNotificacionPedDev) Then + EnviarCorreoDevPed() + End If + End If + + 'MOVIMIENTO DE ALMACEN + If ObjFactura.Inv_CveMovimiento > 0 Then + MensajeAlert.AppendFormat("

Movimiento de Almacén
", ObjFactura.Inv_CveMovimiento) + End If + + If TieneAnticipo AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then + MensajeAlert.AppendFormat("

Se generó una Nota de crédito Folio: {0} amortizando el anticipo
", ObjFacturaDevolucion.Folio) + End If + + If RBLPago.SelectedValue.ToEntero() = 2 And TxtCambio.Text.ToDecimal > 0 Then + MensajeAlert.AppendFormat("

Su cambio es de ${0}
", TxtCambio.Text.ToDecimal.FormatoNumero(2)) + End If + + If CveVentaNCProntoPago > 0 Then + MensajeAlert.AppendFormat(String.Format("
La nota de crédito {0} por descuento pronto pago se generó correctamente.

", SerieFolioNCProntoPago)) + End If + + If MsgCancelacionRefacturacion IsNot Nothing Then + If Not MsgCancelacionRefacturacion.HuboError Then + If MsgCancelacionRefacturacion.CveEstatus = 5 Then + MensajeAlert.AppendFormat("
El folio {0} fue cancelado. Descargar Acuse", Me.ObjFacturaNC.SerieFolio, Encripta(String.Format("OP=CAN&CVEVTA={0}", Me.ObjFacturaNC.CveVenta))) + ElseIf MsgCancelacionRefacturacion.CveEstatus = 20 Then + MensajeAlert.AppendFormat("
El folio {0} esta en proceso de cancelación. Descargar Acuse", Me.ObjFacturaNC.SerieFolio, Encripta(String.Format("OP=CAN&CVEVTA={0}", Me.ObjFacturaNC.CveVenta))) + End If + MensajeAlert.AppendFormat(" Enviar Acuse.

", Me.ObjFacturaNC.CveVenta) + End If + End If + + 'MUESTA ALERT OK + ' si es elrol 1165-Ventas,EMp:80, o la empresa 119, recarga ventas, para seguir registrando-. + 'Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";")) + 'Alert(MensajeAlert.ToString(), TipoMensaje.MsgInformacion, Liga) + + Dim Liga As String = "" + Dim Liga2 As String = "" + + If Request("CveCliente") IsNot Nothing AndAlso Request("CveCliente").ToEntero > 0 Then + Liga = $"document.location.href=""/Ventas/Ventas.aspx?CveCliente={Request("CveCliente")}"";" + Else + Liga = "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";" + End If + + If CveEmpresaCRM > 0 Then + Liga2 = $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";" + Else + Liga2 = $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}"";" + End If + + Alert(MensajeAlert.ToString(), TipoMensaje.MsgDosBotones, Liga, TextoConfirmacion:="Seguir Registrando", TextoSegundoBoton:="Ir al Cliente", JSBtn2:=Liga2, ShowCloseButton:=False) + + MensajeAlert.Clear() + + 'LIMPIA CONDICIONES DE PAGO - CONTADO + RBLPago.SelectedValue = "1" + LimpiaEscondeContado() + BtnEmitirImprimir.Visible = False + ObjFactura = Nothing + + Else + ObjVentas.RollBack() If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack() For Each ErrorItem In ErrorList From 0683951c4ab6cff3d8cc0b2b3f949be4bf735651 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 15 Feb 2022 11:36:58 -0700 Subject: [PATCH 4/5] mejoras en fluctuaciones --- Bancos/FluctuacionCambiaria.aspx | 481 +++++++++++++----- Bancos/FluctuacionCambiaria.aspx.vb | 726 +++++++++++++++++++++------- 2 files changed, 911 insertions(+), 296 deletions(-) diff --git a/Bancos/FluctuacionCambiaria.aspx b/Bancos/FluctuacionCambiaria.aspx index 42753215c..0c8743599 100644 --- a/Bancos/FluctuacionCambiaria.aspx +++ b/Bancos/FluctuacionCambiaria.aspx @@ -155,8 +155,7 @@ -
-
+ @@ -219,11 +218,8 @@ -
- - -
- +
+
- -
- +

- @@ -266,6 +260,108 @@ <%----%> + + + + +
+
+
+

PÉRDIDA

+
+ +
+ MXN + + + +
+
+
+
+
+
+

GANANCIA

+
+ +
+
+
+ MXN + + + +
+
+
+
+
+
+
+
+

+

+
+ +
+
+
+ MXN + + + +
+
+
+
+
+
+
+
+
+
+
+
+ + + + +
+ +
+ + + + + +
+ +
+ + +
+
+
+ + + + + + + + + + + + <%----%> +
+
+ @@ -349,7 +445,7 @@ -
+
@@ -376,7 +472,218 @@ - + + + + +
+
+
+

PÉRDIDA

+
+ +
+ MXN + + + +
+
+
+
+
+
+

GANANCIA

+
+ +
+
+
+ MXN + + + +
+
+
+
+
+
+
+
+

+

+ +
+ +
+
+
+ MXN + + + +
+
+
+
+
+
+
+
+
+ + +
+
+ +
+ + + + +
+ +
+ + + + + +
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + +
+
+ + + + + + +
+ +
+ + + + +
+ +
+ + + + + +
+
+ + + +
+ +
+ +
+ + + + + + + + + + + + + +
+
+ + + +
+ +
+ + + + +
+ +
+ + + + + +
+
+ + + +
+ +
+ +
+ + + + + + + + + + + + +
+
+ +
@@ -426,105 +733,7 @@ - - - -
- -
- - - - -
- -
- - - - - -
- -
- -
-
- -
- - - - - - - - - - - - - - -
-
- - - - -
-
- -
- - - - -
- -
- - - - - -
-
- - - -
- -
- -
- - - - - - - - - - - - - -
-
+ @@ -575,6 +784,54 @@ + + + + +
+ +
+ + + + +
+ +
+ + + + + +
+ +
+ +
+
+ +
+ + + + + + + + + + + + +
+
+ diff --git a/Bancos/FluctuacionCambiaria.aspx.vb b/Bancos/FluctuacionCambiaria.aspx.vb index 56cfe835c..5e6d50ed6 100644 --- a/Bancos/FluctuacionCambiaria.aspx.vb +++ b/Bancos/FluctuacionCambiaria.aspx.vb @@ -28,11 +28,14 @@ Partial Class Bancos_FluctuacionCambiaria Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargaFechas() + CargarCentrosDeCosto(Nothing, DdlSubProyectoCompras, Nothing, LblSubProyectoCompras, "") + CargarCentrosDeCosto(Nothing, DdlSubProyectoComprasAnt, Nothing, LblSubProyectoComprasAnt, "") + CargarCentrosDeCosto(Nothing, DdlsubProyectoVentas, Nothing, LblSubProyectoVentas, "") + CargarCentrosDeCosto(Nothing, DdlsubProyectoVentasAnt, Nothing, LblSubProyectoVentasAnt, "") + CargarCentrosDeCosto(Nothing, DdlSubProyectoAcreedores, Nothing, LblSubProyectoAcreedores, "") + CargarCentrosDeCosto(Nothing, DdlSubProyectoAcreeedoresAnt, Nothing, LblSubProyectoAcreedoresAnt, "") CargarCentrosDeCosto(Nothing, DdlSubproyectoBancos, Nothing, LblSubProyectoBancos, "") - CargarCentrosDeCosto(Nothing, DdlsubProyectoVentas, Nothing, LblSubProyectoVentas, "") - CargarCentrosDeCosto(Nothing, DdlSubProyectoCompras, Nothing, LblSubProyectoCompras, "") - CargarCentrosDeCosto(Nothing, DdlSubProyectoFiliales, Nothing, LblSubProyectoFiliales, "") - CargarCentrosDeCosto(Nothing, DdlSubProyectoAcreedores, Nothing, LblSubProyectoAcreedores, "") + CargarCentrosDeCosto(Nothing, DdlSubProyectoFiliales, Nothing, LblSubProyectoFiliales, "") CargarCentrosDeCosto(Nothing, DdlSubProyectoDeudores, Nothing, LblSubProyectoDeudores, "") CargaUltimaFluctuacion() @@ -62,14 +65,18 @@ Partial Class Bancos_FluctuacionCambiaria End Sub - Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) CargaTipoCambio() - If T.ActiveTabIndex = 0 Then CargaDatosCompra() - If T.ActiveTabIndex = 1 Then CargaDatosVentas() - If T.ActiveTabIndex = 2 Then CargaDatosCuentas() - If T.ActiveTabIndex = 3 Then CargaDatosDeudores() - If T.ActiveTabIndex = 4 Then CargaDatosAcreedores() - If T.ActiveTabIndex = 5 Then CargaDatosFiliales() + If T.ActiveTabIndex = 0 Then CargaDatosProveedores() + If T.ActiveTabIndex = 1 Then CargaDatosProveedoresAnticipos() + If T.ActiveTabIndex = 2 Then CargaDatosClientes() + If T.ActiveTabIndex = 3 Then CargaDatosClientesAnticipos() + If T.ActiveTabIndex = 4 Then CargaDatosAcreedores() + If T.ActiveTabIndex = 5 Then CargaDatosAcreedoresAnticipos() + If T.ActiveTabIndex = 6 Then CargaDatosCuentas() + + If T.ActiveTabIndex = 7 Then CargaDatosFiliales() + If T.ActiveTabIndex = 8 Then CargaDatosDeudores() UpTabs.Update() End Sub @@ -84,21 +91,8 @@ Partial Class Bancos_FluctuacionCambiaria ObjGenerales.Dispose() End Sub - Private Sub CargaUltimaFluctuacion() - 'Dim Obj As New ClsBancos - 'If Obj.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then - ' Dim dt As DataTable = Obj.DtResultados.FiltraParametros("TipoFluctuacion = 1", "Fecha DESC") - ' If dt.Rows.Count > 0 Then - ' LtlUltimaFluctuacion.Text = String.Format("Ultima Fluctuación : {0}", dt.Rows(0)("Fecha").ToString.ToDate.ToShortDateString) - ' 'si la ultima fluctuacion es mayor o igual al fin de mes anterior, entonces pon la fecha actual - ' If dt.Rows(0)("Fecha").ToString.ToDate >= Now.AddMonths(-1).LastDayOfMonth Then - ' TxtFecha.Text = Now.ToShortDateString - ' Else - ' TxtFecha.Text = Now.AddMonths(-1).LastDayOfMonth.ToShortDateString() - ' End If - ' End If - 'End If - 'Obj.Dispose() + Private Sub CargaUltimaFluctuacion() + Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(Now) @@ -111,24 +105,23 @@ Partial Class Bancos_FluctuacionCambiaria Else DdlMes.SelectedValueExist(Now.AddMonths(-1).Month) DdlAnio.SelectedValueExist(Now.AddMonths(-1).Year) - 'TxtFecha.Text = Now.AddMonths(-1).LastDayOfMonth.ToShortDateString() End If End If CargaTipoCambio() End Sub - Private Sub CargaDatosCompra() - Dim ObjBancos As New ClsBancos - 'LblTotalCompras.Text = "0.00" + Private Sub CargaDatosProveedores() + Dim ObjBancos As New ClsBancos + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 1, UsuarioActual.CveEmpresa) Then - GvCompras.DataSource = ObjBancos.DtResultados + GvProveedores.DataSource = ObjBancos.DtResultados 'LblTotalCompras.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero - Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0 ") - Dim Ganancias As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion > 0 ") + Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion > 0 ") + Dim Ganancias As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0 ") Dim PerdidaAux As Double = Perdida.SUM("Fluctuacion").Abs - Dim GanaciaAux As Double = Ganancias.SUM("Fluctuacion") + Dim GanaciaAux As Double = Ganancias.SUM("Fluctuacion").Abs Dim Final As Double = GanaciaAux - PerdidaAux HdnProveedorCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString @@ -138,6 +131,44 @@ Partial Class Bancos_FluctuacionCambiaria IImagenResultado.Attributes("class") = If(Final > 0, "widget-thumb-icon bg-green-jungle fa fa-usd", "widget-thumb-icon bg-red fa fa-usd") + LtIndicador_ExistenciaPerdida.Text = PerdidaAux.ToString.FormatoNumero + LtIndicador_ValorPesosGanancia.Text = GanaciaAux.ToString.FormatoNumero + LtIndicador_CPPesosFinal.Text = Final.Abs.ToString.FormatoNumero + LblComprasPerdidaGanancia.Text = If(Final < 0, "Ganancia", "Pérdida") + + LblTotal = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + Else + GvProveedores.DataSource = Nothing + Alert("Ocurrio un error al cargar las compras", TipoMensaje.MsgAdvertencia) + End If + ObjBancos.Dispose() + GvProveedores.DataBind() + UpIndicadores.Visible = True + If GvProveedores.Rows.Count > 0 Then + GvProveedores.Rows(GvProveedores.Rows.Count - 1).CssClass = "SubTotales2" + End If + End Sub + + Private Sub CargaDatosProveedoresAnticipos() + Dim ObjBancos As New ClsBancos + + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 2, UsuarioActual.CveEmpresa) Then + GvProveedoresAnt.DataSource = ObjBancos.DtResultados + 'LblTotalCompras.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0 ") + Dim Ganancias As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion > 0 ") + + Dim PerdidaAux As Double = Perdida.SUM("Fluctuacion").Abs + Dim GanaciaAux As Double = Ganancias.SUM("Fluctuacion") + + Dim Final As Double = GanaciaAux - PerdidaAux + HdnProveedorAntCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString + HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString + BtnProveedoresAntRemove.Visible = HdnProveedorAntCvePrePoliza.Value.ToEntero > 0 + BtnGeneraComprasAnt.Visible = Not HdnProveedorAntCvePrePoliza.Value.ToEntero > 0 + + IImagenResultado.Attributes("class") = If(Final > 0, "widget-thumb-icon bg-green-jungle fa fa-usd", "widget-thumb-icon bg-red fa fa-usd") + LtIndicador_ExistenciaPerdida.Text = PerdidaAux.ToString.FormatoNumero LtIndicador_ValorPesosGanancia.Text = GanaciaAux.ToString.FormatoNumero LtIndicador_CPPesosFinal.Text = Final.Abs.ToString.FormatoNumero @@ -145,28 +176,26 @@ Partial Class Bancos_FluctuacionCambiaria LblTotal = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero Else - GvCompras.DataSource = Nothing + GvProveedoresAnt.DataSource = Nothing Alert("Ocurrio un error al cargar las compras", TipoMensaje.MsgAdvertencia) End If ObjBancos.Dispose() - GvCompras.DataBind() - UpIndicadores.Visible = True - If GvCompras.Rows.Count > 0 Then - GvCompras.Rows(GvCompras.Rows.Count - 1).CssClass = "SubTotales2" - End If + GvProveedoresAnt.DataBind() + UpIndicadores.Visible = True + End Sub - Private Sub CargaDatosVentas() + Private Sub CargaDatosClientes() Dim ObjBancos As New ClsBancos LblTotalVentas.Text = "0.00" - If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 2, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 3, UsuarioActual.CveEmpresa) Then GvVentas.DataSource = ObjBancos.DtResultados - Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0") - Dim Ganancias As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion > 0") + Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion > 0") + Dim Ganancias As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0") - Dim PerdidaAux As Double = Perdida.SUM("Fluctuacion", "Fluctuacion < 0").Abs - Dim GanaciaAux As Double = Ganancias.SUM("Fluctuacion", "Fluctuacion > 0") + Dim PerdidaAux As Double = Perdida.SUM("Fluctuacion", "Fluctuacion > 0").Abs + Dim GanaciaAux As Double = Ganancias.SUM("Fluctuacion", "Fluctuacion < 0").Abs Dim Final As Double = GanaciaAux - PerdidaAux HdnClienteCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString @@ -190,12 +219,84 @@ Partial Class Bancos_FluctuacionCambiaria End If ObjBancos.Dispose() GvVentas.DataBind() + End Sub + + Private Sub CargaDatosClientesAnticipos() + Dim ObjBancos As New ClsBancos + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 4, UsuarioActual.CveEmpresa) Then + GvClientesAnt.DataSource = ObjBancos.DtResultados + + Dim Perdida As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion < 0") + Dim Ganancias As DataTable = ObjBancos.DtResultados.FiltraParametros("Fluctuacion > 0") + + Dim PerdidaAux As Double = Perdida.SUM("Fluctuacion", "Fluctuacion < 0").Abs + Dim GanaciaAux As Double = Ganancias.SUM("Fluctuacion", "Fluctuacion > 0") + + Dim Final As Double = GanaciaAux - PerdidaAux + HdnClienteAntCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString + HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString + BtnClientesAntRemove.Visible = HdnClienteAntCvePrePoliza.Value.ToEntero > 0 + BtnClientesAnticipos.Visible = Not HdnClienteAntCvePrePoliza.Value.ToEntero > 0 + + 'IImagenFinalVentas.Attributes("class") = If(Final > 0, "widget-thumb-icon bg-green-jungle fa fa-usd", "widget-thumb-icon bg-red fa fa-usd") + + 'LtIndicador_PerdidasVentas.Text = PerdidaAux.ToString.FormatoNumero + 'LtIndicador_GanaciaVentas.Text = GanaciaAux.ToString.FormatoNumero + 'LtIndicador_FinalVentas.Text = Final.ToString.FormatoNumero + 'LblVentasPerdidaGanancia.Text = If(Final < 0, "Pérdida", "Ganancia") + + LblTotalVentasAnt.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + + UpIndicadoresVentas.Visible = True + Else + GvClientesAnt.DataSource = Nothing + Alert("Ocurrio un error al cargar las compras", TipoMensaje.MsgAdvertencia) + End If + ObjBancos.Dispose() + GvClientesAnt.DataBind() + End Sub + + + Private Sub CargaDatosAcreedores() + Dim ObjBancos As New ClsBancos + + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 5, UsuarioActual.CveEmpresa) Then + + HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString + HdnAcreedorCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString + BtnAcreedoresRemove.Visible = HdnAcreedorCvePrePoliza.Value.ToEntero > 0 + BtnGeneraAcreedores.Visible = Not HdnAcreedorCvePrePoliza.Value.ToEntero > 0 + GvAcreedores.DataSource = ObjBancos.DtResultados + LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + Else + GvAcreedoresAnt.DataSource = Nothing + Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia) + End If + ObjBancos.Dispose() + GvAcreedores.DataBind() End Sub + Private Sub CargaDatosAcreedoresAnticipos() + Dim ObjBancos As New ClsBancos + + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 6, UsuarioActual.CveEmpresa) Then + HdnAcreedorAntCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString + BtnAcreedoresAntRemove.Visible = HdnAcreedorAntCvePrePoliza.Value.ToEntero > 0 + BtnGeneraAcreedoresAnt.Visible = Not HdnAcreedorAntCvePrePoliza.Value.ToEntero > 0 + GvAcreedoresAnt.DataSource = ObjBancos.DtResultados + LblTotalAcreedoresAnt.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero + Else + GvAcreedoresAnt.DataSource = Nothing + Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia) + End If + ObjBancos.Dispose() + GvAcreedoresAnt.DataBind() + End Sub + Private Sub CargaDatosCuentas() Dim ObjBancos As New ClsBancos LblTotalBancos.Text = "0.00" - If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 4, UsuarioActual.CveEmpresa) Then + If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 7, UsuarioActual.CveEmpresa) Then Dim DtTemp As DataTable = ObjBancos.DtResultados.Copy Dim TCCierreFluctuacion As Decimal = LtTipoCambioActual.Text.ToDecimal Dim TotAcumulado As Decimal = 0 @@ -237,7 +338,7 @@ Partial Class Bancos_FluctuacionCambiaria End If ObjBancos.Dispose() GvCuentas.DataBind() - End Sub + End Sub Private Sub CargaDatosDeudores() Dim ObjBancos As New ClsBancos @@ -253,24 +354,6 @@ Partial Class Bancos_FluctuacionCambiaria GvDeudores.DataBind() End Sub - Private Sub CargaDatosAcreedores() - Dim ObjBancos As New ClsBancos - LblTotalAcreedores.Text = "0.00" - If ObjBancos.GetFluctuaciones(FechaUltimoDiaMes, 6, UsuarioActual.CveEmpresa) Then - GvAcreedores.DataSource = ObjBancos.DtResultados - LblTotalAcreedores.Text = ObjBancos.DtResultados.SUM("Fluctuacion").FormatoNumero - HdnAcreedorCvePrePoliza.Value = ObjBancos.DtResultados.MAX("CvePrePoliza").ToString - HdnCveFluctuacionBitacora.Value = ObjBancos.DtResultados.MAX("CveFluctuacionBitacora").ToString - BtnAcreedoresRemove.Visible = HdnAcreedorCvePrePoliza.Value.ToEntero > 0 - BtnGeneraAcreedores.Visible = Not HdnAcreedorCvePrePoliza.Value.ToEntero > 0 - - Else - GvAcreedores.DataSource = Nothing - Alert("Ocurrio un error al cargar los acreedores", TipoMensaje.MsgAdvertencia) - End If - ObjBancos.Dispose() - GvAcreedores.DataBind() - End Sub Private Sub CargaDatosFiliales() Dim ObjBancos As New ClsBancos @@ -315,7 +398,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias Total = LblTotal.ToDecimal - If Total > 0 Then + If Total < 0 Then CveConceptoContable = 64 idCta = IdCtaGanancia TipoMovto = True @@ -327,7 +410,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Compras", CveConceptoContable, "Fluctuación Compras", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoCompras.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Proveedores Anticipos", CveConceptoContable, "Fluctuación Proveedores Anticipos", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoCompras.SelectedValue.ToEntero) Then ErrorRegistrar = True End If @@ -338,13 +421,13 @@ Partial Class Bancos_FluctuacionCambiaria If Not ErrorRegistrar Then 'saco las cuentas de pérdida y ganancia - For Each gvr As GridViewRow In GvCompras.Rows + For Each gvr As GridViewRow In GvProveedores.Rows Total = gvr.DataKey("Fluctuacion").ToDecimal 'si es pérdida o ganancia IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString.ToEntero() 'movimiento de complementaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), gvr.DataKey("CveConceptoContable").ToEntero, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), gvr.DataKey("CveConceptoContable").ToEntero, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then ErrorRegistrar = True Exit For End If @@ -370,6 +453,86 @@ Partial Class Bancos_FluctuacionCambiaria Conta.Dispose() End Sub + + Protected Sub BtnGeneraComprasAnt_Click(sender As Object, e As EventArgs) + Dim Total As Decimal = 0 + Dim Conta As New ClsContabilidad + Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaC", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoComprasAnt.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + Dim idCta As Integer = 0 + + Dim CveCuentaPerdida, CveCuentaGanancia As Integer + Dim idCtaPerdida, IdCtaGanancia As Integer + + Dim TipoMovto As Boolean = False + Dim CveConceptoContable As Integer = 0 + Dim IdCtaComplementaria As Integer = 0 + + Dim ErrorRegistrar As Boolean = False + + CveCuentaPerdida = 0 '55379 + CveCuentaGanancia = 0 ' 55382 + idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227 + IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230 + Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias + + Total = LblTotal.ToDecimal + If Total > 0 Then + CveConceptoContable = 64 + idCta = IdCtaGanancia + TipoMovto = True + Else + CveConceptoContable = 65 + idCta = idCtaPerdida + TipoMovto = False + End If + + Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() + + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Compras Anticipos", CveConceptoContable, "Fluctuación Proveedores Anticipos", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoComprasAnt.SelectedValue.ToEntero) Then + ErrorRegistrar = True + End If + + Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 2, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CveBitacora <= 0 Then + ErrorRegistrar = True + End If + + If Not ErrorRegistrar Then + 'saco las cuentas de pérdida y ganancia + For Each gvr As GridViewRow In GvProveedoresAnt.Rows + Total = gvr.DataKey("Fluctuacion").ToDecimal + 'si es pérdida o ganancia + IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString.ToEntero() + + 'movimiento de complementaria + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), gvr.DataKey("CveConceptoContable").ToEntero, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then + ErrorRegistrar = True + Exit For + End If + + If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then + ErrorRegistrar = True + Exit For + End If + Next + + Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 2, CveBitacora, UsuarioActual.CveEmpresa) + + End If + + If Not ErrorRegistrar Then + Conta.Commit() + BtnGeneraComprasAnt.Visible = False + Alert(String.Format("La Fluctuación se ha generado
Ver PrePóliza", CvePrePoliza), TipoMensaje.MsgInformacion) + Else + Conta.RollBack() + Alert("Error al generar la fluctuación", TipoMensaje.MsgError) + End If + Conta.Dispose() + End Sub + #End Region #Region "FLUCTUACION VENTAS" @@ -397,7 +560,7 @@ Partial Class Bancos_FluctuacionCambiaria '' Total = LblTotalVentas.Text.ToDecimal - If Total > 0 Then + If Total < 0 Then CveConceptoContable = 64 CveCuenta = CveCuentaGanancia TipoMovto = True @@ -442,7 +605,7 @@ Partial Class Bancos_FluctuacionCambiaria End If 'movimiento de complementaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then ErrorRegistrar = True Exit For End If @@ -454,7 +617,7 @@ Partial Class Bancos_FluctuacionCambiaria Next - If Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 2, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then + If Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 3, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then ErrorRegistrar = True End If @@ -470,6 +633,261 @@ Partial Class Bancos_FluctuacionCambiaria Conta.Dispose() End Sub + + + Protected Sub BtnClientesAnticipos_Click(sender As Object, e As EventArgs) + Dim Total As Decimal = 0 + + Dim idCta As Integer = 0 + Dim CveCuenta As Integer = 0 + Dim CveCuentaPerdida, CveCuentaGanancia As Integer + Dim idCtaPerdida, IdCtaGanancia As Integer + Dim TipoMovto As Boolean = False + Dim CveConceptoContable As Integer = 0 + Dim IdCtaComplementaria As Integer = 0 + Dim ErrorRegistrar As Boolean = False + + CveCuentaPerdida = 0 '55379 + CveCuentaGanancia = 0 ' 55382 + idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227 + IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230 + Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias + + Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() + '' + + Total = LblTotalVentasAnt.Text.ToDecimal + If Total < 0 Then + CveConceptoContable = 64 + CveCuenta = CveCuentaGanancia + TipoMovto = True + idCta = IdCtaGanancia + Else + CveConceptoContable = 65 + CveCuenta = CveCuentaPerdida + idCta = idCtaPerdida + TipoMovto = False + End If + + If Total = 0 Then + Alert("El Importe tiene que ser diferente a cero", TipoMensaje.MsgError) + Exit Sub + End If + + Dim Conta As New ClsContabilidad + Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaV", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoVentasAnt.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Ventas", CveConceptoContable, "Fluctuación Ventas", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlsubProyectoVentasAnt.SelectedValue.ToEntero) Then + ErrorRegistrar = True + End If + + Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 4, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CveBitacora <= 0 Then + ErrorRegistrar = True + End If + + Dim CveConconceptoCliente As Integer = 203 + + 'saco las cuentas de pérdida y ganancia + For Each gvr As GridViewRow In GvClientesAnt.Rows + Total = gvr.DataKey("Fluctuacion").ToDecimal + + IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() + + If (gvr.DataKey("CveIE").ToEntero > 0 AndAlso gvr.DataKey("CveVenta").ToEntero < 0) OrElse (gvr.DataKey("CveVenta").ToEntero > 0 AndAlso gvr.DataKey("TipoDocto") = "Ant") Then + CveConconceptoCliente = 226 + Else + CveConconceptoCliente = 203 + End If + + 'movimiento de complementaria + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), CveConconceptoCliente, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveVenta:=gvr.DataKey("CveVenta").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then + ErrorRegistrar = True + Exit For + End If + + If Not Conta.UpdateTCValuacion(gvr.DataKey("CveVenta").ToEntero, -1, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then + ErrorRegistrar = True + Exit For + End If + + Next + + If Not Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 4, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then + ErrorRegistrar = True + End If + + If Not ErrorRegistrar Then + Conta.Commit() + BtnClientesAnticipos.Visible = False + Alert(String.Format("La Fluctuación se ha generado
Ver PrePóliza", CvePrePoliza), TipoMensaje.MsgInformacion) + + Else + Conta.RollBack() + Alert("Error al generar la fluctuación", TipoMensaje.MsgError) + End If + Conta.Dispose() + End Sub + +#End Region + + +#Region "FLUCTUACION ACREEDORES" + + Protected Sub BtnGeneraAcreedores_Click(sender As Object, e As EventArgs) + RegistraFluctuacionAcreedores() + End Sub + + Private Sub RegistraFluctuacionAcreedores(Optional Anticipos As Boolean = False) + Dim Total As Decimal = 0 + Dim Conta As New ClsContabilidad + Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim idCta As Integer = 0 + Dim CveCuentaPerdida, CveCuentaGanancia As Integer + Dim idCtaPerdida, IdCtaGanancia As Integer + Dim TipoMovto As Boolean = False + Dim CveConceptoContable As Integer = 0 + Dim CveCuentaComplementaria As Integer = 55206 + Dim IdCtaComplementaria As Integer = 1081 + Dim ErrorRegistrar As Boolean = False + + CveCuentaPerdida = 0 '55379 + CveCuentaGanancia = 0 ' 55382 + idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227 + IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230 + Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias + + Total = LblTotalAcreedores.Text.ToDecimal + If Total < 0 Then + CveConceptoContable = 64 + idCta = IdCtaGanancia + TipoMovto = True + Else + CveConceptoContable = 65 + idCta = idCtaPerdida + TipoMovto = False + End If + + Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() + + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Acreedores", CveConceptoContable, "Fluctuación Acreedores", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoAcreedores.SelectedValue.ToEntero) Then + ErrorRegistrar = True + End If + + Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 5, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CveBitacora <= 0 Then + ErrorRegistrar = True + End If + + 'saco las cuentas de pérdida y ganancia + For Each gvr As GridViewRow In GvAcreedores.Rows + Total = gvr.DataKey("Fluctuacion").ToDecimal + 'si es pérdida o ganancia + IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() + + 'movimiento de complementaria + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, True, Total, gvr.DataKey("SerieFolio"), 202, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then + ErrorRegistrar = True + Exit For + End If + + If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then + ErrorRegistrar = True + Exit For + End If + Next + + Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 5, CveBitacora, UsuarioActual.CveEmpresa) + + If Not ErrorRegistrar Then + Conta.Commit() + BtnGeneraAcreedores.Visible = False + Alert(String.Format("La Fluctuación se ha generado
Ver Póliza", CvePrePoliza), TipoMensaje.MsgInformacion) + Else + Conta.RollBack() + Alert("Error al generar la fluctuación", TipoMensaje.MsgError) + End If + Conta.Dispose() + Banco.Dispose() + End Sub + + + Protected Sub BtnGeneraAcreedoresAnt_Click(sender As Object, e As EventArgs) + Dim Total As Decimal = 0 + Dim Conta As New ClsContabilidad + Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedoresAnt.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim idCta As Integer = 0 + Dim CveCuentaPerdida, CveCuentaGanancia As Integer + Dim idCtaPerdida, IdCtaGanancia As Integer + Dim TipoMovto As Boolean = False + Dim CveConceptoContable As Integer = 0 + Dim CveCuentaComplementaria As Integer = 55206 + Dim IdCtaComplementaria As Integer = 1081 + Dim ErrorRegistrar As Boolean = False + + CveCuentaPerdida = 0 '55379 + CveCuentaGanancia = 0 ' 55382 + idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227 + IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230 + Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias + + Total = LblTotalAcreedoresAnt.Text.ToDecimal + If Total > 0 Then + CveConceptoContable = 64 + idCta = IdCtaGanancia + TipoMovto = True + Else + CveConceptoContable = 65 + idCta = idCtaPerdida + TipoMovto = False + End If + + Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() + + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Acreedores", CveConceptoContable, "Fluctuación Acreedores Anticipos ", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoAcreeedoresAnt.SelectedValue.ToEntero) Then + ErrorRegistrar = True + End If + + Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 6, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CveBitacora <= 0 Then + ErrorRegistrar = True + End If + + 'saco las cuentas de pérdida y ganancia + For Each gvr As GridViewRow In GvAcreedoresAnt.Rows + Total = gvr.DataKey("Fluctuacion").ToDecimal + 'si es pérdida o ganancia + IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() + + 'movimiento de complementaria + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), 202, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then + ErrorRegistrar = True + Exit For + End If + + If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then + ErrorRegistrar = True + Exit For + End If + Next + + Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 6, CveBitacora, UsuarioActual.CveEmpresa) + + If Not ErrorRegistrar Then + Conta.Commit() + BtnGeneraAcreedoresAnt.Visible = False + Alert(String.Format("La Fluctuación se ha generado
Ver Póliza", CvePrePoliza), TipoMensaje.MsgInformacion) + Else + Conta.RollBack() + Alert("Error al generar la fluctuación", TipoMensaje.MsgError) + End If + Conta.Dispose() + Banco.Dispose() + End Sub + #End Region #Region "FLUCTUACION BANCOS" @@ -493,7 +911,6 @@ Partial Class Bancos_FluctuacionCambiaria Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaB", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoBancos.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - CveCuentaPerdida = 0 ' 55379 CveCuentaGanancia = 0 ' 55382 idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227 @@ -733,116 +1150,9 @@ Partial Class Bancos_FluctuacionCambiaria #End Region -#Region "FLUCTUACION ACREEDORES" - - Protected Sub BtnGeneraAcreedores_Click(sender As Object, e As EventArgs) - - Dim Total As Decimal = 0 - Dim Conta As New ClsContabilidad - Dim Banco As New ClsBancos(Conta.IniciaTransacSQL()) - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, FechaUltimoDiaMes, TxtConceptoAcreedores.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - Dim idCta As Integer = 0 - Dim CveCuentaPerdida, CveCuentaGanancia As Integer - Dim idCtaPerdida, IdCtaGanancia As Integer - Dim TipoMovto As Boolean = False - Dim CveConceptoContable As Integer = 0 - Dim CveCuentaComplementaria As Integer = 55206 - Dim IdCtaComplementaria As Integer = 1081 - Dim ErrorRegistrar As Boolean = False - - CveCuentaPerdida = 0 '55379 - CveCuentaGanancia = 0 ' 55382 - idCtaPerdida = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria '1227 - IdCtaGanancia = UsuarioActual.Empresa.IdCuentaGananciaCambiaria '1230 - Dim TC As Decimal = 2 ' se pone 2, para que cumpla con el check constrains de complementarias - - - Total = LblTotalAcreedores.Text.ToDecimal - If Total > 0 Then - CveConceptoContable = 64 - idCta = IdCtaGanancia - TipoMovto = True - Else - CveConceptoContable = 65 - idCta = idCtaPerdida - TipoMovto = False - End If - - Dim TCUltimaFluctuacion As Decimal = GlobalTipoCambio(FechaUltimoDiaMes).ToDecimal() - - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Acreedores", CveConceptoContable, "Fluctuación Acreedores", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveSubProyecto:=DdlSubProyectoAcreedores.SelectedValue.ToEntero) Then - ErrorRegistrar = True - End If - - Dim CveBitacora As Integer = Banco.AddFluctuacionesBitacora(-1, FechaUltimoDiaMes, 6, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CveBitacora <= 0 Then - ErrorRegistrar = True - End If - - 'saco las cuentas de pérdida y ganancia - For Each gvr As GridViewRow In GvAcreedores.Rows - Total = gvr.DataKey("Fluctuacion").ToDecimal - 'si es pérdida o ganancia - IdCtaComplementaria = gvr.DataKey("IdCtaContComplementaria").ToString().ToEntero() - - 'movimiento de complementaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, False, Total, gvr.DataKey("SerieFolio"), 202, gvr.DataKey("SerieFolio"), Now, IdCtaComplementaria, 0, CveCompra:=gvr.DataKey("CveCompra").ToEntero, TipoCambio:=TC, TipoCambioPago:=gvr.DataKey("TipoCambio").ToDecimal, ImporteMX:=Total, ImporteME:=Total, CveIE:=gvr.DataKey("CveIE").ToEntero) Then - ErrorRegistrar = True - Exit For - End If - - If Not Conta.UpdateTCValuacion(-1, gvr.DataKey("CveCompra").ToEntero, gvr.DataKey("CveIE").ToEntero, TCUltimaFluctuacion, UsuarioActual.CveEmpresa) Then - ErrorRegistrar = True - Exit For - End If - Next - - Banco.UpdateFluctuacionesBitacoraPrePoliza(CvePrePoliza, 6, CveBitacora, UsuarioActual.CveEmpresa) - - If Not ErrorRegistrar Then - Conta.Commit() - BtnGeneraAcreedores.Visible = False - Alert(String.Format("La Fluctuación se ha generado
Ver Póliza", CvePrePoliza), TipoMensaje.MsgInformacion) - Else - Conta.RollBack() - Alert("Error al generar la fluctuación", TipoMensaje.MsgError) - End If - Conta.Dispose() - Banco.Dispose() - End Sub - -#End Region - #Region "GRIDVIEWS" - Protected Sub GvCompras_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCompras.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - 'TipoCambio = e.Row.DBCampo("TipoCambio").ToString.ToDouble - 'e.Row.FCLabel("LbTipoCambioActual").Text = TipoCambioActual.ToString - 'e.Row.FCLabel("LbTipoCambio").Text = If(TipoCambio > 0, TipoCambio.ToString, "No hay TipoCambio") - 'e.Row.FCLabel("LbFluctuacion").Text = If(TipoCambio > 0, ((TipoCambio - TipoCambioActual) * e.Row.DBCampo("Saldo").ToString.ToDouble).ToString.FormatoNumero, "No aplica") - 'If e.Row.FCLabel("LbFluctuacion").Text = "No aplica" Then - ' e.Row.BackColor = Drawing.Color.LightSalmon - 'ElseIf e.Row.FCLabel("LbFluctuacion").Text.ToDouble < 0 Then - ' e.Row.BackColor = Drawing.Color.LightGoldenrodYellow - 'End If - - 'e.Row.FCHyperLink("HLProveedor").NavigateUrl = String.Format("/Compras/Proveedores.aspx?CveProveedor={0}", e.Row.DBCampo("CveProveedor").ToString.ToEntero) - - 'If Not e.Row.DBCampo("IdCtaContProveedores").ToString.ToEntero > 0 Then - ' e.Row.FCHyperLink("HLProveedor").ForeColor = Drawing.Color.Red - 'End If - - - 'If e.Row.DBCampo("Fluctuacion").ToString.ToDouble < 0 Then - ' e.Row.BackColor = Drawing.Color.LightGoldenrodYellow - 'End If - 'If e.Row.DBCampo("SinTipoCambio").ToString.ToEntero > 0 Then - ' e.Row.BackColor = Drawing.Color.LightSalmon - 'End If - End If - End Sub - + Protected Sub GvCuentas_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCuentas.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'TipoCambio = e.Row.DBCampo("TipoCambio").ToString.ToDouble @@ -885,6 +1195,7 @@ Partial Class Bancos_FluctuacionCambiaria If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnProveedorCvePrePoliza.Value.ToEntero, 1, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then Banco.Commit() + BtnProveedoresRemove.visible = False Alert("Flucturación eliminada.") Else Banco.RollBack() @@ -893,12 +1204,41 @@ Partial Class Bancos_FluctuacionCambiaria End Sub + Protected Sub BtnProveedoresAntRemove_Click(sender As Object, e As EventArgs) + Dim Banco As New ClsBancos + Banco.IniciaTransacSQL() + + If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnProveedorAntCvePrePoliza.Value.ToEntero, 2, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then + Banco.Commit() + BtnProveedoresAntRemove.Visible = False + Alert("Flucturación eliminada.") + Else + Banco.RollBack() + End If + Banco.Dispose() + End Sub + Protected Sub BtnClientesRemove_Click(sender As Object, e As EventArgs) Dim Banco As New ClsBancos Banco.IniciaTransacSQL() - If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnClienteCvePrePoliza.Value.ToEntero, 2, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then + If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnClienteCvePrePoliza.Value.ToEntero, 3, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then Banco.Commit() + BtnClientesRemove.Visible = False + Alert("Flucturación eliminada.") + Else + Banco.RollBack() + End If + Banco.Dispose() + End Sub + + Protected Sub BtnClientesAntRemove_Click(sender As Object, e As EventArgs) + Dim Banco As New ClsBancos + Banco.IniciaTransacSQL() + + If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnClienteAntCvePrePoliza.Value.ToEntero, 4, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then + Banco.Commit() + BtnClientesAntRemove.Visible = False Alert("Flucturación eliminada.") Else Banco.RollBack() @@ -910,12 +1250,30 @@ Partial Class Bancos_FluctuacionCambiaria Dim Banco As New ClsBancos Banco.IniciaTransacSQL() - If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnAcreedorCvePrePoliza.Value.ToEntero, 6, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then + If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnAcreedorCvePrePoliza.Value.ToEntero, 5, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then Banco.Commit() + BtnAcreedoresRemove.Visible = False Alert("Flucturación eliminada.") Else Banco.RollBack() End If Banco.Dispose() End Sub + + + Protected Sub BtnAcreedoresAntRemove_Click(sender As Object, e As EventArgs) + Dim Banco As New ClsBancos + Banco.IniciaTransacSQL() + + If Banco.FluctuacionesBitacoraPrePolizaRemove(HdnAcreedorAntCvePrePoliza.Value.ToEntero, 6, HdnCveFluctuacionBitacora.Value.ToEntero, UsuarioActual.CveEmpresa) Then + Banco.Commit() + BtnAcreedoresAntRemove.Visible = False + Alert("Flucturación eliminada.") + Else + Banco.RollBack() + End If + Banco.Dispose() + End Sub + + End Class From 0683b3e7eb050fe55ba0e410b3f1cffef5d94803 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 15 Feb 2022 12:25:51 -0700 Subject: [PATCH 5/5] =?UTF-8?q?--=20correci=C3=B3n=20de=20importe=20real?= =?UTF-8?q?=20de=20devoluci=C3=B3n=20--=20activar=20resico=20para=20vsh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Compras/Compras.aspx.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 85dfd42e1..82c2469c5 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -2194,7 +2194,7 @@ Partial Class Compras_Compras DdlRetISRConcepto.Items.Clear() DdlRetISRConcepto.Items.Insert(0, New ListItem("Honorarios", "1")) DdlRetISRConcepto.Items.Insert(1, New ListItem("Arrendamiento", "2")) - If UsuarioActual.CveEmpresa = 119 Then + If UsuarioActual.CveEmpresa.Contiene(119, 7, 11, 12, 122, 145) Then DdlRetISRConcepto.Items.Insert(1, New ListItem("Resico", "3")) End If End If @@ -6917,7 +6917,7 @@ Partial Class Compras_Compras End If - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, TotalRealDevolucion, Referencia, ConceptoContabilizacionNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, CveMovimientoAlmacen:=CveMovimientoDevolucion, Contabilizable:=SeContabiliza) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, TotalRealDevolucion, Referencia, ConceptoContabilizacionNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, ImporteMX:=TotalRealDevolucion * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, TotalRealDevolucion), TipoCambio:=tipoCambioActual, CveMovimientoAlmacen:=CveMovimientoDevolucion, Contabilizable:=SeContabiliza) Then ErrorPrepoliza = True End If Else