--- parametro de cveempresa, en updatePS

This commit is contained in:
2023-10-19 13:25:18 -07:00
parent cb231a4578
commit 34c0529694

View File

@@ -2,6 +2,7 @@
Option Explicit On
Imports System.Data
Imports System.Math
Imports ClosedXML.Excel
Imports Extensiones
Imports GemBox.Spreadsheet
Imports log4net.Filter
@@ -30,8 +31,8 @@ Partial Class General_SaldosIniciales
Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
Dim dt As New DataTable
Dim ErrorArchivo = False
Dim ErrorExcel = False
Dim ErrorArchivo As Boolean = False
Dim ErrorExcel As Boolean = False
dt = ReadExcelFile(Ruta + FileName, True)
@@ -358,15 +359,15 @@ Partial Class General_SaldosIniciales
Exit Sub
End If
If Not dt.Columns(10).ColumnName = "Tamaño" Then
Alert("El nombre de la onceava columna debe ser 'Tamaño'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
'If Not dt.Columns(10).ColumnName = "Tamaño" Then
' Alert("El nombre de la onceava columna debe ser 'Tamaño'. Favor de corregirlo", TipoMensaje.MsgError)
' Exit Sub
'End If
If Not dt.Columns(11).ColumnName = "Código SAT" Then
Alert("El nombre de la doceava columna debe ser 'Código SAT'. Favor de corregirlo", TipoMensaje.MsgError)
Exit Sub
End If
'If Not dt.Columns(11).ColumnName = "Código SAT" Then
' Alert("El nombre de la doceava columna debe ser 'Código SAT'. Favor de corregirlo", TipoMensaje.MsgError)
' Exit Sub
'End If
'If Not dt.Columns(12).ColumnName = "Servicio" Then
' Alert("El nombre de la treceava columna debe ser 'Servicio'. Favor de corregirlo", TipoMensaje.MsgError)
@@ -641,7 +642,6 @@ Partial Class General_SaldosIniciales
dt.TableName = "Datos"
Dim NumRows As Integer = dt.Rows.Count
@@ -712,7 +712,7 @@ Partial Class General_SaldosIniciales
Dim AplicaSerie As Boolean = If(Row("AplicaSerie").ToString().Trim.ToUpper.Contiene("1", "SI"), True, False)
Dim Precio As Double = Row("Precio").ToString().ToDouble
Dim IEPS As Decimal = Row("IEPS").ToString().ToDecimal
Dim Tamaño As String = Row("Tamaño").ToString().Trim
Dim Tamaño As String = If(Row.Table.Columns.Contains("Tamaño"), Row("Tamaño").ToString().Trim, "")
Dim SATClavePS As String = Row("Código SAT").ToString().Trim
Dim Clasificacion2 As String = If(dt.Columns.Contains("Servicio"), Row("Servicio").ToString().Trim, "")
@@ -843,7 +843,7 @@ Partial Class General_SaldosIniciales
'If Not CveClasificacion2 > 0 AndAlso Clasificacion2 <> "" Then Alert("No se encontró la Serie: " + Clasificacion2, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
If CvePS > 0 Then
If Not ObjPS.UpdatePS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, -1, RetIVA, False, -1, True, True, True, UsuarioActual.CveUsuario, CvePS, -1, -1, CveSATPS,
If Not ObjPS.UpdatePS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio, -1, RetIVA, False, -1, True, True, True, UsuarioActual.CveUsuario, CvePS, -1, -1, CveSATPS, UsuarioActual.CveEmpresa,
CveTipoPS:=CveTipoPS, CveMarca:=CveMarca, CveMedida:=CveMedida, CveRinTamaño:=CveRinTamaño,
CveModelo:=CveModelo, Litraje:=Litraje, IEPSPorcentaje:=IEPS, CveClasificacion2:=CveClasificacion2, CveTamaño:=CveTamaño, AplicaSerie:=AplicaSerie, CveObjetoImpuesto:=2) Then
'If Not ObjPS.UpdatePS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, 0, 1, 1, False, 0, True, True, True, UsuarioActual.CveUsuario, CvePS, -1, -1, CveSATPS,
@@ -1209,25 +1209,26 @@ Partial Class General_SaldosIniciales
Dim sbErrores As New StringBuilder
Dim CveCuentaContable As Integer
If dt.Columns.Contains("CuentaContable") Then
For Each Row As DataRow In dt.Rows
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(" ", "")
Dim RazonSocial As String = Row("RazonSocial").ToString()
Dim CuentaContable As String = Row("CuentaContable").ToString().Trim.Replace("-", "").Replace(" ", "")
If CuentaContable.Length > 0 Then
CveCuentaContable = DTCuentasContables.FiltroPrimeroValor("CveCuenta", $"Codigo ='{CuentaContable}'").ToEntero()
If CuentaContable.Length > 0 Then
Dim CveCuentaContable As Integer = DTCuentasContables.FiltroPrimeroValor("CveCuenta", $"Codigo ='{CuentaContable}'").ToEntero()
If CveCuentaContable > 0 Then
Row("CveCuentaContable") = CveCuentaContable
Else
sbErrores.AppendLine($"Cliente {RazonSocial} cuenta {CuentaContable} no encontrada.<br>")
ErrorClientes = True
If CveCuentaContable > 0 Then
Row("CveCuentaContable") = CveCuentaContable
Else
sbErrores.AppendLine($"Cliente {RazonSocial} cuenta {CuentaContable} no encontrada.<br>")
ErrorClientes = True
End If
End If
End If
Next
Next
End If
If Not ErrorClientes Then
dt.AcceptChanges()
@@ -1249,7 +1250,8 @@ Partial Class General_SaldosIniciales
Dim RazonSocial As String = Row("RazonSocial").ToString()
Dim RFC As String = Row("RFC").ToString().Trim
Dim Calle As String = Row("Calle").ToString()
Dim NumExt As Decimal = Row("Número exterior").ToString().ToDecimal
Dim NumExt As String = Row("Número exterior").ToString()
Dim NumInt As String = If(dt.Columns.Contains("Número interior"), Row("Número interior").ToString(), "")
Dim Colonia As String = Row("Colonia").ToString()
Dim CodigoPostal As String = Row("Código Postal").ToString()
Dim Poblacion As String = Row("Población").ToString()
@@ -1278,8 +1280,17 @@ Partial Class General_SaldosIniciales
Dim CobranzaContacto As String = If(dt.Columns.Contains("Encargado Pagoa"), Row("Encargado Pago").ToString(), "")
Dim CobranzaTelefono As String = Row("Celular Contacto").ToString().Replace("-", "").Replace(" ", "").Replace("(", "").Replace(")", "")
Dim CveUsoCFDI As Integer = If(Row("UsoCFDI").ToString() = "", -1, GlobalDTSATUsosCFDI().FiltroPrimeroValor("CveUsoCFDI", String.Format("UsoCFDI = '{0}'", Row("UsoCFDI").ToString())).ToEntero())
Dim CveCuentaContable As Integer = Row("CveCuentaContable").ToString().ToEntero()
' CobranzaContacto = Regex.Replace(CobranzaContacto, "[^0-9]", "")
Dim CuentaContable As String = If(dt.Columns.Contains("CuentaContable"), Row("CuentaContable").ToString(), "")
CuentaContable = CuentaContable.Trim.Replace("-", "").Replace(" ", "")
If CuentaContable.Length > 0 Then
CveCuentaContable = DTCuentasContables.FiltroPrimeroValor("CveCuenta", $"Codigo ='{CuentaContable}'").ToEntero()
If CveCuentaContable <= 0 Then
sbErrores.AppendLine($"Cliente {RazonSocial} cuenta {CuentaContable} no encontrada.<br>")
ErrorClientes = True
End If
End If
'Telefono
@@ -1380,7 +1391,7 @@ Partial Class General_SaldosIniciales
Else
Dim CveSATEstado As Integer = GlobalDTGralEstados("MEX").FiltroPrimeroValor("CveSATEstado", String.Format(" NombreEstado ='{0}'", Estado.ToUpper)).ToEntero()
If Not ObjClientes.AddCliente(RazonSocial, RazonSocial, Calle, NumExt.ToString(), "", Colonia, Poblacion, Poblacion, Estado, Pais, RFC, CodigoPostal, Telefono, Contacto, "", "", "", "", "", -1, False, 0, 0, False, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "", CveVendedor, PlazoCobranza, -1,
If Not ObjClientes.AddCliente(RazonSocial, RazonSocial, Calle, NumExt.ToString(), NumInt, Colonia, Poblacion, Poblacion, Estado, Pais, RFC, CodigoPostal, Telefono, Contacto, "", "", "", "", "", -1, False, 0, 0, False, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, "", CveVendedor, PlazoCobranza, -1,
"-1", "-1", "-1", Codigo, LimiteCredito, False, "", "", "", False, "", "", "", "", "", False, "", "", "", False, 0, -1, EsDistribuidor:=EsDistribuidor, CveClienteClasificacion:=CveClasificación, CargoUsado:=CargoUsado,
BonificacionUsado:=BonificacionUsado, CobranzaContacto:=CobranzaContacto, CobranzaCorreo:=CobranzaCorreo, DiasEspecifico:=DiasPagoEspecifico, DiasRevision:=DìaVisita, CobranzaTelefono:=CobranzaTelefono, CveFormaPago:=CveFormaPago33, CveUsoCFDI:=CveUsoCFDI, CveSATEstado:=CveSATEstado, CveAdminTrayecto:=0) Then
@@ -1440,8 +1451,8 @@ Partial Class General_SaldosIniciales
Dim CveCompra As Integer
Dim Contador As Integer = 0
Dim ExisteCompra As Boolean = False
Dim DtProveedores = New DataTable
Dim NoEncontrados = 0
Dim DtProveedores As New DataTable
Dim NoEncontrados As Integer = 0
Dim Encontrados As Integer = 0
DtProveedores = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
Dim RFC As String = ""
@@ -1593,7 +1604,7 @@ Partial Class General_SaldosIniciales
Dim ObjIE As New ClsBancos(ObjVentas.IniciaTransacSQL())
Dim ErrorVentas As Boolean = False
Dim CveVenta As Integer
Dim DtClientes = New DataTable
Dim DtClientes As New DataTable
'Dim ExisteVenta As Boolean = False
'Dim Contador As Integer = 0
DtClientes = GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1)
@@ -1644,6 +1655,18 @@ Partial Class General_SaldosIniciales
Dim Folio2 As String = "" ' Row("Folio2").ToString()
Dim CodCliente As String = "" 'Row("CodCliente2").ToString()
If dt.Columns.Contains("ClienteSucursal") AndAlso Row("ClienteSucursal").ToString() <> "" Then
Dim ObjCliente As New ClsClientes
If ObjCliente.GetSucursales(CveCliente) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
CveClienteSucursal = ObjCliente.DtResultados.FiltroPrimeroValor("CveSucursalCliente", "SucursalCliente = '" & Row("ClienteSucursal").ToString().Trim & "'").ToEntero
End If
End If
ObjCliente.Dispose()
End If
'If Not CveCliente > 0 Then Alert(String.Format("No se encontró el cliente con el RFC: {0}", {RFC}), TipoMensaje.MsgError) : ErrorVentas = True : RFC.GuardaLog : Exit For
TipoDocto = IIf(TipoDocto.ToUpper.Contiene("INGRESO", "INGRESOS", "ING"), "Ing", IIf(TipoDocto.ToUpper.Contiene("EGRESO", "EGRESOS", "EGS"), "Egs", "Rem")).ToString()
@@ -1986,7 +2009,7 @@ Partial Class General_SaldosIniciales
Exit For
End If
Dim IdNew = ObjConta.AddCuenta(Cuenta.Replace("-", ""), NombreCuenta, TipoCuenta, 1, 0, 1, 0, "", 0, CveCuentaPadre, AgrupadorSAT.ToEntero())
Dim IdNew As Integer = ObjConta.AddCuenta(Cuenta.Replace("-", ""), NombreCuenta, TipoCuenta, 1, 0, 1, 0, "", 0, CveCuentaPadre, AgrupadorSAT.ToEntero())
If IdNew > 0 Then
ContadorUpdate = ContadorUpdate + 1
Else
@@ -2059,7 +2082,7 @@ Partial Class General_SaldosIniciales
CveCuentaPadre = -2
End If
Dim IdNew = ObjConta.AddCuenta(CveCuentaPadre, Cuenta.Replace("-", ""), NombreCuenta, TipoCuenta, 1, 1, CveEmpresaParam:=UsuarioActual.CveEmpresa, CveAgrupadorSAT:=CveAgrupadorSAT)
Dim IdNew As Integer = ObjConta.AddCuenta(CveCuentaPadre, Cuenta.Replace("-", ""), NombreCuenta, TipoCuenta, 1, 1, CveEmpresaParam:=UsuarioActual.CveEmpresa, CveAgrupadorSAT:=CveAgrupadorSAT)
If IdNew > 0 Then
ContadorUpdate = ContadorUpdate + 1
Else
@@ -2471,7 +2494,7 @@ Partial Class General_SaldosIniciales
'End If
Dim CveClasificaionTemp = DTClasificaiones.FiltroPrimeroValor("CveClasificacion", $"Clasificacion='{Clasificacion}'").ToEntero()
Dim CveClasificaionTemp As Integer = DTClasificaiones.FiltroPrimeroValor("CveClasificacion", $"Clasificacion='{Clasificacion}'").ToEntero()
If CveClasificaionTemp > 0 Then
CveClasificacion = CveClasificaionTemp
@@ -3279,7 +3302,7 @@ Partial Class General_SaldosIniciales
If (ObjRH.TiposTrabajadorGet(-1, UsuarioActual.CveEmpresa)) Then
dtTipoTrabajador = ObjRH.DtResultados
End If
Dim dtpuestos = GlobalDTRHPuestos(UsuarioActual.CveEmpresa)
Dim dtpuestos As DataTable = GlobalDTRHPuestos(UsuarioActual.CveEmpresa)
dtpuestos.CaseSensitive = False
If ObjRH.GetRegistrosPatronales(-1, UsuarioActual.CveEmpresa, -1) Then
dtregistrospatronales = ObjRH.DtResultados
@@ -3690,7 +3713,7 @@ Partial Class General_SaldosIniciales
End Sub
Protected Sub LnkCargaMasiva_Click(sender As Object, e As EventArgs)
Dim wb As ClosedXML.Excel.XLWorkbook = New ClosedXML.Excel.XLWorkbook()
Dim libro = wb.AddWorksheet("Personal")
Dim libro As IXLWorksheet = wb.AddWorksheet("Personal")
Dim crow As Integer = 1
Dim ccol As Integer = 1
@@ -3698,7 +3721,7 @@ Partial Class General_SaldosIniciales
Dim rowLugarNacimiento As Integer = 1
#Region "Regimen de contratación"
Dim Catalogos = wb.AddWorksheet("Catalogos")
Dim Catalogos As IXLWorksheet = wb.AddWorksheet("Catalogos")
crow = 1
ccol = 1
Dim colRegimenContratacion As Integer = 1
@@ -3899,8 +3922,8 @@ Partial Class General_SaldosIniciales
#End Region
#Region "Metodo pago"
Dim colmetodopago = 0
Dim rowmetodopago = 0
Dim colmetodopago As Integer = 0
Dim rowmetodopago As Integer = 0
crow = 1
ccol = ccol + 1
Catalogos.Cell(crow, ccol).Value = "Metodo pago"
@@ -3914,12 +3937,12 @@ Partial Class General_SaldosIniciales
#End Region
#Region "subproyecto"
Dim colsubproyecto = 0
Dim rowsubproyecto = 0
Dim colsubproyecto As Integer = 0
Dim rowsubproyecto As Integer = 0
crow = 1
ccol = ccol + 1
Catalogos.Cell(crow, ccol).Value = "subproyecto"
Dim dtsubproyecto = If(Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1))
Dim dtsubproyecto As DataTable = If(Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1))
For Each row As DataRow In dtsubproyecto.Rows
crow = crow + 1
Catalogos.Cell(crow, ccol).Value = String.Format("{0}: {1}", row("CveSubProyecto"), row("SubProyecto"))