diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index 2c3d36add..652cdc548 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -576,33 +576,36 @@ Partial Class General_SaldosIniciales Alert("El nombre de la primera columna debe ser 'CuentaBancaria'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - - If Not dt.Columns(1).ColumnName = "Importe" Then + If Not dt.Columns(1).ColumnName = "Banco" Then + Alert("El nombre de la primera columna debe ser 'Banco'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(2).ColumnName = "Importe" Then Alert("El nombre de la segunda columna debe ser 'Importe'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not dt.Columns(2).ColumnName = "Moneda" Then + If Not dt.Columns(3).ColumnName = "Moneda" Then Alert("El nombre de la segunda columna debe ser 'Moneda'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not dt.Columns(3).ColumnName = "TipoCambio" Then + If Not dt.Columns(4).ColumnName = "TipoCambio" Then Alert("El nombre de la segunda columna debe ser 'TipoCambio'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not dt.Columns(4).ColumnName = "Fecha" Then + If Not dt.Columns(5).ColumnName = "Fecha" Then Alert("El nombre de la cuarta columna debe ser 'Fecha'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not dt.Columns(5).ColumnName = "Descripcion" Then + If Not dt.Columns(6).ColumnName = "Descripcion" Then Alert("El nombre de la cuarta columna debe ser 'Descripcion'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not dt.Columns(6).ColumnName = "CuentaContable" Then + If Not dt.Columns(7).ColumnName = "CuentaContable" Then Alert("El nombre de la tercera columna debe ser 'CuentaContable'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If @@ -2494,11 +2497,11 @@ Partial Class General_SaldosIniciales Dim Contador As Integer = 0 For Each dRow As DataRow In DTBancos.Rows - Dim Fecha As Date = dRow("Fecha").ToString.ToDate Dim Importe As Decimal = dRow("Importe").ToString.ToDecimal Dim Descripcion As String = dRow("Descripcion").ToString - Dim NumCuenta As String = dRow("CuentaBancaria").ToString + Dim Banco As String = dRow("Banco").ToString + Dim NumCuenta As String = dRow("CuentaBancaria").ToString.Trim Dim ImporteMX As Decimal = 0 Dim ImporteME As Decimal = 0 @@ -2506,8 +2509,6 @@ Partial Class General_SaldosIniciales Dim CveMoneda As Integer Dim TipoCambio As Decimal = dRow("TipoCambio").ToString.ToDecimal - - If Moneda.ToUpper.Contiene("PESOS", "PESO", "MXN") Then CveMoneda = 1 TipoCambio = 1 @@ -2536,16 +2537,32 @@ Partial Class General_SaldosIniciales End If - - Dim CveCuentaBancaria As Integer = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa, Estatus:=1).FiltroPrimeroValor("CveCuenta", $" NumCuenta = '{NumCuenta}'").ToEntero + Dim CveTipoTransaccion As Integer = 3 ' tipo transaccion, cheque recibido + Dim CveCuentaBancaria As Integer = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa, Estatus:=-1).FiltroPrimeroValor("CveCuenta", $" NumCuenta = '{NumCuenta}'").ToEntero If Not CveCuentaBancaria > 0 Then - Alert($"No se detecto cuenta Bancaria {NumCuenta}", TipoMensaje.MsgAdvertencia) - ErrorProceso = True - Exit For + + ' se registrará primero + Dim CveBanco As Integer = GlobalDTBancos().FiltroPrimeroValor("CveBanco", String.Format("CveEmpresa = {0} AND Banco = '{1}'", UsuarioActual.CveEmpresa, Banco)).ToEntero + + If CveBanco > 0 Then + Dim CveTipoCuenta As Integer = 2 'tipo de cheques + If NumCuenta.ToLower.Contains("caja chica") Then CveTipoCuenta = 1 ' cuando es caja chica + If ObjBancos.AddBancosCuentas(CveBanco, 2, NumCuenta, "", CveMoneda, 1, 1, 1, 9999999, 0, 0, 0, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "", False, False) Then + CveCuentaBancaria = ObjBancos.TCveCuenta + Else + Alert($"No se detecto cuenta Bancaria {NumCuenta}", TipoMensaje.MsgAdvertencia) + ErrorProceso = True : Exit For + End If + Else + Alert($"No se detecto cuenta Bancaria {NumCuenta}", TipoMensaje.MsgAdvertencia) + ErrorProceso = True : Exit For + End If End If + If ImporteMX < 0 Then CveTipoTransaccion = 2 'salida de dinero, concepto de transferencia realizada + Dim FolioStr As String = "" - FolioStr = CStr(ObjBancos.GetNextFolio(CveCuentaBancaria, 3) + Contador) + FolioStr = CStr(ObjBancos.GetNextFolio(CveCuentaBancaria, CveTipoTransaccion)) Dim CveCuentaContable As Integer = 0 Dim CuentaContable As String = dRow("CuentaContable").ToString.Trim.Replace("-", "").Replace(" ", "") @@ -2568,32 +2585,30 @@ Partial Class General_SaldosIniciales End If - - If Not AsignacionCuenta(ObjConta, 30, CveCuentaContable, CveCuentaBancaria, -1, -1, -1, UsuarioActual.CveEmpresa, -1) Then + If CveCuentaContable > 0 AndAlso Not AsignacionCuenta(ObjConta, 30, CveCuentaContable, CveCuentaBancaria, -1, -1, -1, UsuarioActual.CveEmpresa, -1) Then ErrorProceso = True Alert("Se presento un error al guardar en asignaciones", TipoMensaje.MsgAdvertencia) Exit For End If - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Bancos/SaldoInicial", 66, Importe, Importe, CveMoneda, Fecha, FolioStr, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If Importe <> 0 Then + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Bancos/SaldoInicial", 66, Importe, Importe, CveMoneda, Fecha, FolioStr, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + If Not CvePrePoliza > 0 Then + ErrorProceso = True : Exit For + End If + + Dim CveIE As Integer = ObjBancos.AddBancos_IE(CveCuentaBancaria, CveTipoTransaccion, Fecha, FolioStr.ToString, "", Importe, CveMoneda, + TipoCambio, Descripcion, "", False, False, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Importe, FolioStr.ToString, 30, FolioStr, Fecha, -1, -1, CveIE:=CveIE, Contabilizable:=False, ImporteMX:=ImporteMX, ImporteME:=ImporteME, TipoCambio:=TipoCambio) Then ErrorProceso = True : Exit For + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Importe, FolioStr.ToString, 95, FolioStr, Fecha, -1, -1, CveIE:=CveIE, Contabilizable:=False, ImporteMX:=ImporteMX, ImporteME:=ImporteME, TipoCambio:=TipoCambio) Then ErrorProceso = True : Exit For - If Not CvePrePoliza > 0 Then - ErrorProceso = True - Exit For End If - - Dim CveIE As Integer = ObjBancos.AddBancos_IE(CveCuentaBancaria, 3, Fecha, FolioStr.ToString, "", Importe, CveMoneda, - TipoCambio, Descripcion, "", False, False, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Importe, FolioStr.ToString, 30, FolioStr, Fecha, -1, -1, CveIE:=CveIE, Contabilizable:=False, ImporteMX:=ImporteMX, ImporteME:=ImporteME, TipoCambio:=TipoCambio) Then ErrorProceso = True : Exit For - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Importe, FolioStr.ToString, 95, FolioStr, Fecha, -1, -1, CveIE:=CveIE, Contabilizable:=False, ImporteMX:=ImporteMX, ImporteME:=ImporteME, TipoCambio:=TipoCambio) Then ErrorProceso = True : Exit For - Contador = Contador + 1 Next - - If Not ErrorProceso Then Alert($"Se agregaron {Contador} Movimientos.") ObjBancos.Commit()