Compras, SaldosIniciales

This commit is contained in:
Oscar Irigoyen
2022-10-10 19:08:20 -07:00
parent 6c5d7af1b2
commit 272eea922a
67 changed files with 14552 additions and 20242 deletions

View File

@@ -122,13 +122,32 @@ Partial Class General_SaldosIniciales
Exit Sub
End If
If Not dt.Columns(19).ColumnName.ToUpper = "MONEDA PREFERENTE" Then
Alert("El nombre de la columna 20 debe ser 'Moneda Preferente'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
If Not dt.Columns(20).ColumnName.ToUpper = "CLASIFICACIÓN PROVEEDOR" Then
Alert("El nombre de la columna 21 debe ser 'Clasificación Proveedor'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
If Not dt.Columns(21).ColumnName.ToUpper = "REGIMEN FISCAL" Then
Alert("El nombre de la columna 22 debe ser 'CuentaContable'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
If Not dt.Columns(22).ColumnName.ToUpper = "TIPO TERCERO" Then
Alert("El nombre de la columna 23 debe ser 'Tipo Tercero'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
If Not dt.Columns(23).ColumnName.ToUpper = "TIPO OPERACIÓN" Then
Alert("El nombre de la columna 24 debe ser 'Tipo Operación'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
ElseIf RblFormato.SelectedValue = "2" Then
@@ -898,11 +917,6 @@ Partial Class General_SaldosIniciales
Dim Contador As Integer = 0
Dim ExisteProveedor As Boolean = False
If Not dt.Columns.Contains("CveCuentaContable") Then
dt.Columns.Add("CveCuentaContable", GetType(Integer))
End If
@@ -913,6 +927,9 @@ Partial Class General_SaldosIniciales
For Each Row As DataRow In dt.Rows
Dim RazonSocial As String = Row("RazonSocial").ToString
Dim CuentaContable As String = Row("CuentaContable").ToString.Trim.Replace("-", "").Replace(" ", "")
If CuentaContable.Length > 0 Then
@@ -943,16 +960,24 @@ Partial Class General_SaldosIniciales
Exit Sub
End If
Dim DTClasificaciones As New DataTable
Using ObjClasificaciones As New ClsClasificaciones
If ObjClasificaciones.GetClasificaciones(UsuarioActual.CveEmpresa) Then
DTClasificaciones = ObjClasificaciones.DtResultados
End If
End Using
ObjProv.IniciaTransacSQL()
For Each Row As DataRow In dt.Rows
Dim Codigo As String = Row("Codigo").ToString
Dim RazonSocial As String = Row("RazonSocial").ToString
If RazonSocial.Trim.Length = 0 Then
Continue For
End If
Dim RFC As String = Row("RFC").ToString.Trim
Dim Dirrecion As String = $"{ Row("Población").ToString}, { Row("Estado").ToString} , Colonia { Row("Colonia").ToString}, {Row("Calle").ToString} #{Row("Número exterior").ToString}"
@@ -979,25 +1004,127 @@ Partial Class General_SaldosIniciales
Dim CveProveedor As Integer = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveProveedor", $"RFC = '{RFC}'").ToString.ToEntero
Dim CveProveedor2 As Integer = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveProveedor", $"RazonSocial = '{RazonSocial}'").ToString.ToEntero
Dim CveProveedor3 As Integer = 0
Dim CveCuentaContable As Integer = Row("CveCuentaContable").ToString.ToEntero
Dim TipoProveedor As Integer = If(Row("TipoProveedor").ToString.ToUpper = "PROVEEDOR", 1, 2)
Dim CveConceptoCuentaAsiganaciones As Integer = If(TipoProveedor = 1, 5, 305)
If Codigo.Trim.Length > 0 Then
CveProveedor3 = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveProveedor", $"Codigo = '{Codigo}'").ToString.ToEntero
End If
' If CveProveedor > 0 Or CveProveedor2 > 0 Or CveProveedor3 > 0 Then
Dim CodigoRegimenFiscal As String = Row("Regimen Fiscal").ToString
Dim Clasificacion As String = Row("Clasificación Proveedor").ToString
Dim Moneda As String = Row("Moneda Preferente").ToString
Dim DIOTTipoTercero As String = Row("Tipo Tercero").ToString.Trim.ToUpper
Dim DIOTipoOperacion As String = Row("Tipo Operación").ToString
Dim CveMoneda As Integer = -1
Dim CveProveedorClasificacion As Integer = -1
Dim CveRegimenFiscal As Integer = 0
Dim DIOTCveTipoTercero As Integer = 0
Dim DIOTCveTipoOperacion As Integer = 0
If DIOTTipoTercero.Length > 0 Then
Select Case DIOTTipoTercero
Case "PROVEEDOR NACIONAL"
DIOTCveTipoTercero = 1
Exit Select
Case "PROVEEDOR EXTRANJERO"
DIOTCveTipoTercero = 2
Exit Select
Case "ACCIONISTAS, SOCIOS O INTEGRANTES"
DIOTCveTipoTercero = 3
Exit Select
Case "RETENCIONES (EXCEPTO PROVEEDORES)"
DIOTCveTipoTercero = 4
Exit Select
Case "PROVEEDOR NACIONAL GLOBAL"
DIOTCveTipoTercero = 5
Exit Select
Case "PROVEEDOR EXTRANJERO GLOBAL"
DIOTCveTipoTercero = 6
Exit Select
Case "EGRESOS VARIOS"
DIOTCveTipoTercero = 7
Case Else
DIOTCveTipoTercero = 0
Exit Select
End Select
If Not DIOTCveTipoTercero > 0 Then
sbErrores.AppendLine($"Proveedor {RazonSocial} Tipo Tercero {DIOTTipoTercero} invalida.<br>")
ErrorProv = True
End If
End If
If DIOTipoOperacion.Length > 0 Then
Select Case DIOTipoOperacion
Case "03", "3"
DIOTCveTipoOperacion = 1
Exit Select
Case "06", "6"
DIOTCveTipoOperacion = 2
Exit Select
Case "85"
DIOTCveTipoOperacion = 3
Exit Select
Case Else
DIOTCveTipoOperacion = 0
Exit Select
End Select
If Not DIOTCveTipoOperacion > 0 Then
sbErrores.AppendLine($"Proveedor {RazonSocial} Tipo Operación {DIOTipoOperacion} invalida.<br>")
ErrorProv = True
End If
End If
If Moneda.ToUpper.Contiene("PESOS", "PESO", "MXN", "MONEDA NACIONAL") Then
CveMoneda = 1
ElseIf Moneda.ToUpper.Contiene("DOLARES", "DOLAR", "USD", "DÓLARES") Then
CveMoneda = 2
Else
sbErrores.AppendLine($"Proveedor {RazonSocial} Moneda {Moneda} invalida.<br>")
ErrorProv = True
End If
If Clasificacion.Trim.Length > 0 Then
CveProveedorClasificacion = DTClasificaciones.FiltroPrimeroValor("CveClasificacion", $"Clasificacion = '{Clasificacion}'").ToString.ToEntero
If Not CveProveedorClasificacion > 0 Then
sbErrores.AppendLine($"Proveedor {RazonSocial} Clasificación {Clasificacion} invalida.<br>")
ErrorProv = True
End If
End If
If CodigoRegimenFiscal.Trim.Length > 0 Then
CveRegimenFiscal = GlobalDTRegimenesFiscales.FiltroPrimeroValor("CveRegimenFiscal", $"CodigoRegimenFiscal= '{CodigoRegimenFiscal}' ").ToEntero
If Not CveRegimenFiscal > 0 Then
sbErrores.AppendLine($"Proveedor {RazonSocial} Codigo RegimenFiscal {CodigoRegimenFiscal} invalido.<br>")
ErrorProv = True
End If
End If
If ErrorProv Then
Alert($"Errores detectados <br>{sbErrores.ToString()}", TipoMensaje.MsgAdvertencia)
Exit For
End If
If CveProveedor > 0 Or CveProveedor2 > 0 Or CveProveedor3 > 0 Then
Contador = Contador + 1
'If Not ObjProv.UpdateProveedor(Codigo, RazonSocial, RazonSocial, RazonSocial, RFC, Calle, Telefono,
' Contacto, "", Telefono, LimiteCredito, PlazoCobranza, "", 0, 0, 0, -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "",
' -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, -1, True, "", "", False, CveProveedor) Then
@@ -1013,15 +1140,19 @@ Partial Class General_SaldosIniciales
Telefono = If(Telefono.Length > 10, "", Telefono)
CelularContacto = If(CelularContacto.Length > 10, "", Telefono)
If Not ObjProv.AddProveedor(Codigo, RazonSocial, RazonSocial, RazonSocial, RFC, Dirrecion, Telefono,
"", ContactoMail, CelularContacto, LimiteCredito, PlazoCobranza, "", 0, 0, 0, -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "",
-1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, -1, "", "", False, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CP:=CodigoPostal, CveRegimenFiscal:=0, CveTipoProveedor:=TipoProveedor) Then
If Not ObjProv.AddProveedor(Codigo, RazonSocial, RazonSocial, RazonSocial, RFC, Dirrecion, Telefono, "", ContactoMail, CelularContacto, LimiteCredito, PlazoCobranza, "",
0, 0, 0, -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "",
-1, "", -1, "", -1, "", CveProveedorClasificacion, -1, "", "", False, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CP:=CodigoPostal, CveRegimenFiscal:=CveRegimenFiscal,
CveTipoProveedor:=TipoProveedor, CveMonedaPreferente:=CveMoneda, DIOTCveTipoTercero:=DIOTCveTipoTercero, DIOTCveTipoOperacion:=DIOTCveTipoOperacion) Then
ErrorProv = True
Exit For
Else
Dim ErrorCuentaDeposito As Boolean = False
'RESTRICCIONES GENERALES
'QUE TENGA ALGUN DATO DE TIPO DE CUENTA