diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index 3fe1cc915..1b696dca2 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -856,16 +856,16 @@ Partial Class General_SaldosIniciales If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, -1, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1, CveTipoPS:=CveTipoPS, CveSATPS:=CveSATPS, CveMarca:=CveMarca, CveTamaño:=CveTamaño, CveMedida:=CveMedida, CveRinTamaño:=CveRinTamaño, CveModelo:=CveModelo, Litraje:=Litraje, IEPSPorcentaje:=IEPS, CveClasificacion2:=CveClasificacion2, CveClasificacionDetalle:=CveClasificacionDetalle) <= 0 Then - 'If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", "", Descripcion, 0, 0, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1, - ' CveTipoPS:=CveTipoPS, CveSATPS:=CveSATPS, CveMarca:=CveMarca, CveTamaño:=CveTamaño, CveMedida:=CveMedida) <= 0 Then - ErrorPS = True - Codigo.GuardaLog - Exit For - 'Else - ' If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa) Then - ' DTPS = ObjPS.DtResultados - ' End If - End If + 'If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", "", Descripcion, 0, 0, 0, False, 0, False, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1, + ' CveTipoPS:=CveTipoPS, CveSATPS:=CveSATPS, CveMarca:=CveMarca, CveTamaño:=CveTamaño, CveMedida:=CveMedida) <= 0 Then + ErrorPS = True + Codigo.GuardaLog + Exit For + 'Else + ' If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa) Then + ' DTPS = ObjPS.DtResultados + ' End If + End If 'End If End If @@ -1468,12 +1468,14 @@ Partial Class General_SaldosIniciales 'PrePólizaDetalle If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SubTotal, Folio.ToString, 4, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, ImporteMX:=SubTotal, CveSubProyecto:=Sucursal.ToEntero) Then ErrorVentas = True : Exit For If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Folio.ToString, ConceptoContable, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Total) Then ErrorVentas = True : Exit For - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, Folio.ToString, 13, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=IVA, PorcentajeImpuesto:=PorcentajeIVA) Then ErrorVentas = True : Exit For + + If IVA > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, Folio.ToString, 13, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=IVA, PorcentajeImpuesto:=PorcentajeIVA) Then ErrorVentas = True : Exit For + End If 'If IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IEPS, Folio.ToString, 38, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=IEPS) Then ErrorVentas = True : Exit For If UsaComplementaria Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total, Folio.ToString, 203, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteME:=Total, ImporteMX:=Total * TipoCambio.ToDecimal, TipoCambio:=TipoCambio.ToDecimal) Then ErrorVentas = True : Exit For - + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total * TipoCambio.ToDecimal - Total, Folio.ToString, 203, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteME:=Total, ImporteMX:=Total * TipoCambio.ToDecimal - Total, TipoCambio:=TipoCambio.ToDecimal) Then ErrorVentas = True : Exit For End If 'Saldo @@ -1961,6 +1963,86 @@ Partial Class General_SaldosIniciales End If + Catch ex As Exception + ObjConta.RollBack() + End Try + + ObjConta.Dispose() + + ElseIf RblFormato.SelectedValue = "11" Then + + Dim ObjConta As New ClsContabilidad() + ObjConta.IniciaTransacSQL() + Try + Dim TieneError As Boolean = False + Dim ContadorUpdate As Integer = 0 + Dim ContadorError As Integer = 0 + Dim NombreCuenta As String = "" + Dim CvePrePoliza As Integer = 0 + Dim Cuenta As String = "" + Dim Reporte As New StringBuilder + + CvePrePoliza = ObjConta.AddPrePolizas("SI", 1, 0, 0, 1, Now.ToDate, "Saldos Iniciales", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + For Each Row As DataRow In dt.Rows + NombreCuenta = Row("NombreCuenta").ToString + Cuenta = Row("Cuenta").ToString + + Dim Importe As Decimal = If(Row("Cargo").ToString.ToDecimal <> 0, Row("Cargo").ToString.ToDecimal, Row("Abono").ToString.ToDecimal) + Dim Concepto As String = Row("Concepto").ToString + Dim IdCuenta As Integer = -1 + Dim CveSubProyecto As Integer = -1 + Dim TipoMovto As Boolean = If(Row("Cargo").ToString.ToDecimal <> 0, False, True) + Dim YaExiste As Boolean = False + + Dim SubP As String = Row("SubProyecto").ToString + If SubP <> "" Then + CveSubProyecto = GlobalDTSubProyectos(-1, -1, CveEmpresa:=UsuarioActual.CveEmpresa, Estatus:=-1).FiltroPrimeroValor("CveSubProyecto", "").ToEntero + End If + + If ObjConta.GetCuentas(-1, Cuenta.Replace("-", ""), 1, UsuarioActual.CveEmpresa) Then + If ObjConta.DtResultados.Rows.Count > 0 Then + IdCuenta = ObjConta.DtResultados().FiltroPrimeroValor("CveCuenta").ToEntero + 'TipoCuenta = ObjConta.DtResultados().FiltroPrimeroValor("Tipo") + Else + Reporte.AppendLine($"{Cuenta} - {NombreCuenta} - {Importe}
") + TieneError = True + YaExiste = True + End If + Else + TieneError = True + Exit For + End If + + + 'If TipoCuenta.Contiene("A", "C", "E") Then + ' CargoAbono = False + 'End If + + If YaExiste = False Then + If IdCuenta > 0 Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, "", 95, Concepto, Now.toDate, -1, -1, CveSubProyecto:=CveSubProyecto) Then + TieneError = True + Exit For + End If + Else + IdCuenta = -2 + End If + End If + + + Next + + If Not TieneError Then + ObjConta.Commit() + Alert($"Se agregó la póliza {CvePrePoliza}") + + Else + Alert($"No encontraron las siguientes cuentas: {Reporte.ToString} ", TipoMensaje.MsgError) + ObjConta.RollBack() + End If + + Catch ex As Exception ObjConta.RollBack() End Try @@ -2059,6 +2141,8 @@ Partial Class General_SaldosIniciales Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoContabilidad.xlsx" ElseIf RblFormato.SelectedValue = "9" Then Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoContabilidad.xlsx" + ElseIf RblFormato.SelectedValue = "11" Then + Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoPrePoliza.xlsx" ElseIf RblFormato.SelectedValue = "12" Then Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoAlmacen.xlsx" End If