diff --git a/App_Code/ClsContabilidad.vb b/App_Code/ClsContabilidad.vb
index 024b4fe5f..50892c8ff 100644
--- a/App_Code/ClsContabilidad.vb
+++ b/App_Code/ClsContabilidad.vb
@@ -1089,6 +1089,27 @@ Public Class ClsContabilidad
End Function
+ Public Function ContabilizaDesContabilizaPrePoliza(CvePrePoliza As Integer, Contabilizar As Boolean, CveEmpresa As Integer) As Boolean
+ Dim Retorno As Boolean = False
+ DataAdapter("PA_Conta_PrePolizasContabilizarDescontabilizar")
+ With SqlAdapter.SelectCommand.Parameters
+ .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza
+ .Add("@Contabilizar", SqlDbType.Bit).Value = Contabilizar
+ .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
+ End With
+ Try
+ SqlAdapter.Fill(Data)
+ Retorno = True
+ Catch ex As Exception
+ If ex.Message.Contains("50015;") Then
+ OnError("No se puede actualizar una póliza en un ejercicio Cerrado", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
+ Else
+ OnError("Ocurrió un error al bloquear o desbloquear las prepolizas detalle.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ End If
+ End Try
+ Return Retorno
+ End Function
+
Public Function ContabilizarPrePoliza(CvePrePoliza As Integer, CveUsuario As Integer, Empresa As Empresa, Optional Fecha As Date = MinFecha, Optional Concepto As String = "",
Optional ObjConta As ClsContPAQi = Nothing, Optional pIDPoliza As Integer = -1) As Boolean
@@ -1096,36 +1117,30 @@ Public Class ClsContabilidad
Dim Retorno As Boolean = False
- 'No modificar esta seccion bajo ninguna circunstancia -- Empresa.CvePlataforma = 3 Or
- '*****************************************************
- If (CveUsuario.Contiene(100, 1425) And Empresa.CveEmpresa = 1) Then
- Retorno = ContabilizarPrePolizaSIG(CvePrePoliza, CveUsuario, Empresa, Fecha, Concepto)
- Return Retorno
- End If
- '*****************************************************
+ If Empresa.TipoContabilizacion = 1 Then
- If Empresa.UsaArmonizacion Then
- DataAdapter("PA_Conta_ContabilizaPrepoliza")
- With SqlAdapter.SelectCommand.Parameters
- .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza
- .Add("@CvePoliza", SqlDbType.Int).Direction = ParameterDirection.Output
- End With
+ ContabilizaDesContabilizaPrePoliza(CvePrePoliza, True, Empresa.CveEmpresa)
- Try
- SqlAdapter.Fill(Data)
- ContaIdPoliza = SqlAdapter.SelectCommand.Parameters("@CvePoliza").Value.ToString.ToEntero
- If ContaIdPoliza <> 0 Then
- Retorno = True
- End If
- Catch ex As Exception
- OnError("Ocurrió un error al obtener Movimientos Prepolizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
- End Try
+ 'DataAdapter("PA_Conta_ContabilizaPrepoliza")
+ 'With SqlAdapter.SelectCommand.Parameters
+ ' .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza
+ ' .Add("@CvePoliza", SqlDbType.Int).Direction = ParameterDirection.Output
+ 'End With
+
+ 'Try
+ ' SqlAdapter.Fill(Data)
+ ' ContaIdPoliza = SqlAdapter.SelectCommand.Parameters("@CvePoliza").Value.ToString.ToEntero
+ ' If ContaIdPoliza <> 0 Then
+ ' Retorno = True
+ ' End If
+ 'Catch ex As Exception
+ ' OnError("Ocurrió un error al obtener Movimientos Prepolizas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ 'End Try
Else
If CvePrePoliza <= 0 Then Return False
Dim OcurrioError As Boolean = False
-
Dim ContaCompartida As Boolean = False
If ObjConta Is Nothing Then
@@ -1135,9 +1150,6 @@ Public Class ClsContabilidad
ContaCompartida = True
End If
-
-
-
Dim tIdPoliza As Integer
Dim CveTipoPoliza, FolioFijo, CvePlantillaPoliza As Integer
Dim Cargos As Decimal
@@ -1152,23 +1164,8 @@ Public Class ClsContabilidad
Dim ContabilizarCausacion As Boolean
Dim ContabilizarDIOT As Boolean
- 'Dim Periodo As Integer = -1
- 'Dim Ejercicio As Integer = -1
- 'Dim GuidPoliza As String = "-1"
-
- ' Dim FolioFiscal As String = ""
- ' Dim DatosCuentas As New DataTable
- ' Dim CveMoneda As Integer = 0
- ' Dim Total As Decimal = 0
-
-
-
Try
- 'If Empresa.Funcionalidad(522).ToString = "1" AndAlso ObjConta.GetCuentas(-1, "-1", -1) Then
- ' DatosCuentas = ObjConta.DtResultados
- 'End If
-
If GetEncabezadoPrePoliza(CvePrePoliza, Empresa.CveEmpresa) Then
CveTipoPoliza = Data.Rows(0)("CveTipoPoliza").ToString.ToEntero
Cargos = Data.Rows(0)("Cargos").ToString.ToDecimal
@@ -1255,30 +1252,6 @@ Public Class ClsContabilidad
Exit For
End If
- 'If Empresa.Funcionalidad(522).ToString = "1" Then
- ' GuidPoliza = ObjConta.DtResultados.Rows(0)("Guid").ToString
- ' Periodo = Data.Rows(0)("Fecha").ToString.ToDate.Month
- ' Ejercicio = Data.Rows(0)("Fecha").ToString.ToDate.Year
-
- ' Dim CodigoCuenta As String = ""
-
- ' If DatosCuentas.Rows.Count > 0 Then
- ' If DatosCuentas.FiltraParametros($"Id = {dr("IdCtaContable").ToString}").Rows.Count > 0 Then 'Filtra primero valorCambiar
- ' CodigoCuenta = DatosCuentas.FiltraParametros($"Id = {dr("IdCtaContable").ToString}").Rows(0)("Codigo").ToString
- ' If Not ObjConta.AddASocCFDIs(False, TipoPol, GuidPoliza, FolioFiscal, 0, CodigoCuenta, Empresa.BDContPAQi, -1, -1, ContaFolio) Then
- ' OcurrioError = True
- ' Exit For
- ' End If
- ' Else
- ' OcurrioError = True
- ' Exit For
- ' End If
- ' Else
- ' OcurrioError = True
- ' Exit For
- ' End If
- 'End If
-
Else
If Not ObjConta.AddMovimiento(tIdPoliza, dr("IdCtaContable").ToString.ToEntero, tipoMovimiento,
@@ -1288,29 +1261,6 @@ Public Class ClsContabilidad
End If
- 'If Empresa.Funcionalidad(522).ToString = "1" Then
- ' GuidPoliza = ObjConta.DtResultados.Rows(0)("Guid").ToString
- ' Periodo = Data.Rows(0)("Fecha").ToString.ToDate.Month
- ' Ejercicio = Data.Rows(0)("Fecha").ToString.ToDate.Year
-
- ' Dim CodigoCuenta As String = ""
-
- ' If DatosCuentas.Rows.Count > 0 Then
- ' If DatosCuentas.FiltraParametros($"Codigo = {dr("IdCtaContable").ToString}").Rows.Count > 0 Then
- ' CodigoCuenta = DatosCuentas.FiltraParametros($"Codigo = {dr("IdCtaContable").ToString}").Rows(0)("Codigo").ToString
- ' If Not ObjConta.AddASocCFDIs(False, TipoPol, GuidPoliza, FolioFiscal, 0, CodigoCuenta, Empresa.BDContPAQi, -1, -1, ContaFolio) Then
- ' OcurrioError = True
- ' Exit For
- ' End If
- ' Else
- ' OcurrioError = True
- ' Exit For
- ' End If
- ' Else
- ' OcurrioError = True
- ' Exit For
- ' End If
- 'End If
End If
Else
@@ -1425,89 +1375,6 @@ Public Class ClsContabilidad
- 'If Empresa.Funcionalidad(522).ToString = "1" And Empresa.UsaContabilidad Then
-
- ' Dim CodigoPersona As String = ""
- ' Dim Bnefciciario As String = ""
-
- ' If ObjConta.GetPersona(RFC) Then
- ' CodigoPersona = ObjConta.DtResultados.FiltroPrimeroValor("CodigoPersona")
- ' Bnefciciario = ObjConta.DtResultados.FiltroPrimeroValor("Nombre")
- ' Else
-
- ' OcurrioError = True
- ' Mensaje.Append("Se presento un error al obtener los datos de la persona. ")
-
- ' End If
-
-
-
-
- ' If TipoPol = 1 Then 'Ingreso
- ' Dim IdDocumento As Integer = 0
- ' ' Dim UsuarioSistema As String = ""
- ' Dim IdCuentaCheques As Integer = 1
- ' Dim NatBancaria As Integer = 2
- ' Dim Naturaleza As Integer = 1
- ' Dim IdIngreso As Integer
-
- ' If ObjConta.AddIngreso(1, 34, 42, Ejercicio, Periodo, Fecha, Ejercicio, Periodo, CodigoPersona, Bnefciciario, IdCuentaCheques, NatBancaria, Naturaleza, CveMoneda, 2, 1, Total, "", 0, 0, "", 0,
- ' 0, Ejercicio, Periodo, TipoPol, ContaFolio.ToEntero, 0, 0, tIdPoliza, 11, 0, 0, 0, 0, UsuarioSistema, UsuarioSistema, 0, System.Guid.NewGuid().ToString().ToUpper, "", 0, MetodoPagoSAT) Then 'Actualizar Documento IdDocumento despues de Insertarlo
-
- ' If ObjConta.DtResultados.Rows.Count > 0 Then
- ' IdIngreso = ObjConta.DtResultados.Rows(0)("IdIngreso").ToString.ToEntero
-
- ' If Not ObjConta.AddDocumentoBancario(1, 0, 0, IdIngreso, 0, 0, Fecha, Fecha, 0, 0, IdCuentaCheques) Then
- ' OcurrioError = True
- ' Mensaje.Append("Se presento un error al guardar el el documento. ")
- ' End If
-
- ' Else
- ' OcurrioError = True
- ' Mensaje.Append("Se presento un error al guardar el Ingreso. ")
- ' End If
- ' Else
- ' OcurrioError = True
- ' Mensaje.Append("Se presento un error al guardar el Ingreso. ")
- ' End If
-
- ' ElseIf TipoPol = 2 Then 'Egreso
-
- ' Dim IdDocumento As Integer = 0
- ' ' Dim UsuarioSistema As String = ""
- ' Dim BancoDestino As String = ""
- ' Dim CuentaDestino As String = ""
- ' Dim IdCuentaCheques As Integer = 1
- ' Dim NatBancaria As Integer = 0
- ' Dim Naturaleza As Integer = 2
- ' Dim IdEgreso As Integer
-
- ' If ObjConta.AddEgreso(1, 36, 45, Ejercicio, Periodo, Fecha, Ejercicio, Periodo, CodigoPersona, Bnefciciario, IdCuentaCheques, NatBancaria, Naturaleza, CveMoneda, 2, 1, Total, "", 0, "", 0, 0, Ejercicio,
- ' Periodo, TipoPol, NumPoliza, 0, 0, ContaIdPoliza, tIdPoliza, IdDocumento, Ejercicio, Periodo, 0, 0, 0, 0, 0, 0, UsuarioSistema, UsuarioSistema, 0, System.Guid.NewGuid().ToString().ToUpper,
- ' CuentaDestino, BancoDestino, MetodoPagoSAT) Then
-
- ' If ObjConta.DtResultados.Rows.Count > 0 Then
- ' IdEgreso = ObjConta.DtResultados.Rows(0)("IdEgreso").ToString.ToEntero
-
- ' If Not ObjConta.AddDocumentoBancario(1, 0, IdEgreso, 0, 0, 0, Fecha, Fecha, 0, 0, IdCuentaCheques) Then
- ' OcurrioError = True
- ' Mensaje.Append("Se presento un error al guardar el el documento. ")
- ' End If
-
- ' Else
- ' OcurrioError = True
- ' Mensaje.Append("Se presento un error al guardar el Egreso. ")
- ' End If
- ' Else
- ' OcurrioError = True
- ' Mensaje.Append("Se presento un error al guardar el Egreso")
-
- ' End If 'Actualizar Documento IdDocumento despues de Insertarlo
-
- ' End If
-
- 'End If
-
If OcurrioError Then
If Not ContaCompartida Then ObjConta.RollBack()
Else
@@ -1539,215 +1406,6 @@ Public Class ClsContabilidad
Return Retorno
End Function
- 'No modificar este metodo bajo ninguna circunstancia
- Public Function ContabilizarPrePolizaSIG(CvePrePoliza As Integer, CveUsuario As Integer, Empresa As Empresa, Optional Fecha As Date = MinFecha, Optional Concepto As String = "") As Boolean
-
- If CvePrePoliza <= 0 Then Return False
-
- Dim Retorno As Boolean = False
- Dim OcurrioError As Boolean = False
- Dim tCvePoliza As Integer
- Dim CveTipoPoliza, FolioFijo As Integer
- Dim Cargos As Decimal
- Dim Abonos As Decimal
- Dim NumPoliza As String = ""
- Dim CodigoNumeroPoliza As String = ""
- Dim TipoPoliza As String
-
- Dim ContaFolio As String = ""
- Dim ContabilizarCausacion As Boolean
- Dim ContabilizarDIOT As Boolean
-
- Dim ObjConta As New ClsContabilidad
- ObjConta.IniciaTransacSQL()
-
- Try
-
- If GetEncabezadoPrePoliza(CvePrePoliza, Empresa.CveEmpresa) Then
- CveTipoPoliza = Data.Rows(0)("CveTipoPoliza").ToString.ToEntero
- Cargos = Data.Rows(0)("Cargos").ToString.ToDecimal
- Abonos = Data.Rows(0)("Abonos").ToString.ToDecimal
- FolioFijo = Data.Rows(0)("FolioFijo").ToString.ToEntero
- TipoPoliza = Data.Rows(0)("TipoPoliza").ToString
- CodigoNumeroPoliza = Data.Rows(0)("CodigoNumeroPoliza").ToString
-
- 'tiene prioridad el concepto en parametro
- If Concepto = "" Then Concepto = Data.Rows(0)("Concepto").ToString
- If Fecha = MinFecha Then Fecha = Data.Rows(0)("Fecha").ToString.ToDate
-
- If FolioFijo > 0 Then
- CodigoNumeroPoliza = "CHQ"
- Else
- GetNumeroPoliza(CveTipoPoliza, TipoPoliza, Fecha, Empresa.CveEmpresa)
- FolioFijo = Data.Rows(0)("NumPoliza").ToString.ToEntero
- End If
-
- tCvePoliza = ObjConta.AddPoliza(CveTipoPoliza, FolioFijo, Fecha, Concepto, CveUsuario, Empresa.CveEmpresa, CvePrePoliza)
-
- If tCvePoliza > 0 AndAlso GetContabilizacionDiarioDetalle(CvePrePoliza) Then
- Dim tipoMovimiento As Boolean = False
- Dim CveConceptoContable As Integer
- Dim SigReferencia As String = ""
-
- For Each dr As DataRow In Data.Rows
-
- CveConceptoContable = dr("CveConceptoContable").ToString().ToEntero
-
- Select Case CveConceptoContable
- Case 6, 5, 17, 14, 19, 15, 16
- SigReferencia = dr("CveCompra").ToString.ContaReferencia(TipoContaReferencia.Compra)
- Case 2, 4, 1, 13, 61, 62, 63, 8, 9
- SigReferencia = dr("CveVenta").ToString.ContaReferencia(TipoContaReferencia.Venta)
- Case 30
- SigReferencia = dr("CveIE").ToString.ContaReferencia(TipoContaReferencia.Banco)
-
- End Select
-
- Select Case CveConceptoContable
- Case 19 ' IVA Acreditable
- ContabilizarDIOT = True
- Case 61 ' IVA Trasladado
- ContabilizarCausacion = True
- Case 30 ' Bancos
- If dr("Abono").ToString.ToDecimal > 0 Then ContabilizarDIOT = True
- If dr("Cargo").ToString.ToDecimal > 0 Then ContabilizarCausacion = True
- End Select
-
- tipoMovimiento = (dr("TipoMovto").ToString = "True")
-
- 'Si las cuentas contables estan en 0 no se debe contabilizar
- If dr("CveCuenta").ToString.ToEntero > 0 Then
-
- 'Si ImporteMN es mayor que 0 entonces la compra es en dolares y debemos ingresar la cantidad en pesos
- If dr("ImporteMN").ToString.ToDecimal <> 0 Then
- If Not ObjConta.AddPolizaDetalle(tCvePoliza, dr("CveCuenta").ToString.ToEntero, "", dr("CveSubProyecto").ToString.ToEntero, tipoMovimiento,
- dr("ImporteMN").ToString.ToDecimal, dr("Referencia").ToString, dr("Concepto").ToString, Fecha, ImporteMonedaExtranjera:=dr("ImporteME").ToString.ToDecimal, CvePrePolizaDetalle:=dr("CvePrePolizaDetalle").ToString.ToEntero) Then
- OcurrioError = True
- Exit For
- End If
- Else
- If Not ObjConta.AddPolizaDetalle(tCvePoliza, dr("CveCuenta").ToString.ToEntero, "", dr("CveSubProyecto").ToString.ToEntero, tipoMovimiento,
- dr("Importe").ToString.ToDecimal, dr("Referencia").ToString, dr("Concepto").ToString, Fecha, ImporteMonedaExtranjera:=dr("ImporteME").ToString.ToDecimal, CvePrePolizaDetalle:=dr("CvePrePolizaDetalle").ToString.ToEntero) Then
- OcurrioError = True
- Exit For
- End If
- End If
-
- Else
- OcurrioError = True
- Mensaje.Append(String.Format("
La cuenta contable {0} es invalida", dr("ConceptoContable")))
- Exit For
- End If
-
- Next
-
- 'Obtenemos los valores de la causacion y los agregamos
- 'If Not OcurrioError AndAlso ContabilizarCausacion Then
- ' If GetCausacionesValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then
- ' Dim dr As DataRow = Data(0)
- ' If Not ObjConta.AddCausacionesIVA(tIdPoliza,
- ' dr("TotalTasa16").ToString.ToDecimal,
- ' dr("BaseTasa16").ToString.ToDecimal,
- ' dr("IvaTasa16").ToString.ToDecimal,
- ' 0,
- ' dr("ISRRetenido").ToString.ToDecimal,
- ' dr("IVARetenido").ToString.ToDecimal, False) Then
- ' OcurrioError = True
-
- ' End If
- ' End If
- 'End If
-
- 'Obtenemos los valores del DIOT y los agregamos
- 'If Not OcurrioError AndAlso ContabilizarDIOT Then
- ' If GetDIOTValores(CvePrePoliza) AndAlso Data.Rows.Count > 0 Then
- ' Dim IdProveedor As Integer
- ' Dim RFC, RazonSocial As String
-
- ' RFC = Data(0)("RFC").ToString
- ' RazonSocial = Data(0)("RazonSocial").ToString
- ' IdCtaContProveedores = Data(0)("IdCtaContProveedores").ToString.ToEntero
-
- ' If IdCtaContProveedores > 0 Then
-
- ' 'busco la clave del proveedor en la contabilidad por su cuenta contable
- ' If ObjConta.GetProveedores(IdCuentaContable:=IdCtaContProveedores) Then
- ' If ObjConta.DtResultados.Rows.Count > 0 Then
- ' Dim dr As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = dr("Id").ToString.ToEntero
- ' End If
- ' End If
- ' Else
- ' 'busco la clave del proveedor en la contabilidad por su cuenta contable
- ' If ObjConta.GetProveedores(RFC:=RFC) Then
- ' If ObjConta.DtResultados.Rows.Count > 0 Then
- ' Dim dr As DataRow = ObjConta.DtResultados.Rows(0) : IdProveedor = dr("Id").ToString.ToEntero
- ' End If
- ' Else
- ' 'registro el proveedor generico
- ' Select Case Empresa.CveEmpresa
- ' Case 66 : IdProveedor = 12726
- ' Case Else : IdProveedor = 1
- ' End Select
- ' End If
-
- ' End If
-
-
- ' If IdProveedor <= 0 Then
- ' IdProveedor = ObjConta.AddProveedor(IdCtaContProveedores, RFC, RazonSocial, "")
- ' If IdProveedor <= 0 Then
- ' OcurrioError = True
- ' End If
- ' End If
-
- ' For Each dr As DataRow In Data.Rows
- ' If dr("Total").ToString.ToDecimal <> 0.00 Then
- ' If Not ObjConta.AddDevolucionesIVA(tIdPoliza, dr("CuentaBancos").ToString.ToEntero,
- ' IdProveedor,
- ' 16,
- ' dr("SubTotal").ToString.ToDecimal,
- ' dr("IvaAcreditable").ToString.ToDecimal,
- ' dr("IVARetenido").ToString.ToDecimal,
- ' dr("ISRRetenido").ToString.ToDecimal,
- ' Fecha,
- ' ContaFolio,
- ' dr("Serie").ToString.ToString,
- ' dr("Folio").ToString.StrToNum, "") Then
- ' OcurrioError = True
- ' Mensaje.Append("La Poliza o la Cuenta no son válidas")
- ' End If
-
-
- ' End If
-
- ' Next
-
- ' End If
- 'End If
-
- If Not OcurrioError Then
- Mensaje.Append(String.Format("{1}
", tCvePoliza, FolioFijo))
- ObjConta.Commit()
- Retorno = True
- _ContaIdPoliza = tCvePoliza
- End If
- End If
-
- Else
- OcurrioError = True
- End If
-
-
-
- Catch ex As Exception
- ObjConta.RollBack()
- OnError("Ocurrió un error al intentar contabilizar la PrePoliza", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
- Retorno = False
- End Try
-
- ObjConta.Dispose()
- Return Retorno
- End Function
Public Function GetCuentaDobleConta(IdCtaContable As Integer, CveEmpresa As Integer) As Boolean