diff --git a/.gitignore b/.gitignore
index a3e8e0702..b14cc0feb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,270 +1,12 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-web.config
-Log.txt
-LogMail.txt
-LogPenske.txt
-LogTimbrado.txt
-[Mm]enu/
-[Tt]emp/
-[Ee]mpresas/
-# User-specific files
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-bld/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-
-# Visual Studio 2015 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# DNX
-project.lock.json
-project.fragment.lock.json
-artifacts/
-
-*_i.c
-*_p.c
-*_i.h
-*.ilk
-*.meta
-*.obj
-*.pch
-*.pdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# TODO: Comment the next line if you want to checkin your web deploy settings
-# but database connection strings (with potential passwords) will be unencrypted
-#*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/packages/*
-# except build/, which is used as an MSBuild target.
-!**/packages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/packages/repositories.config
-# NuGet v3's project.json files produces more ignoreable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.jfm
-*.pfx
-*.publishsettings
-node_modules/
-orleans.codegen.cs
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-
-# SQL Server files
-*.mdf
-*.ldf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# JetBrains Rider
-.idea/
-*.sln.iml
-*.sln
-
-# CodeRush
-.cr/
-
-# Python Tools for Visual Studio (PTVS)
-__pycache__/
-*.pyc
-/Utilerias
+################################################################################
+# Este archivo .gitignore ha sido creado automáticamente por Microsoft(R) Visual Studio.
+################################################################################
+
+/Empresas
+/Menu
+/Web.config
+/Log.txt
+/.vs/localhost/v14/.suo
+/LogMail.txt
+/.vs
+/packages
diff --git a/.vs/SIGGIT/v14/.suo b/.vs/SIGGIT/v14/.suo
new file mode 100644
index 000000000..fea5bbe7e
Binary files /dev/null and b/.vs/SIGGIT/v14/.suo differ
diff --git a/App_Code/ClsCompras.vb b/App_Code/ClsCompras.vb
index 1da48e7a6..a7f69b063 100644
--- a/App_Code/ClsCompras.vb
+++ b/App_Code/ClsCompras.vb
@@ -2921,6 +2921,23 @@ Public Class ClsCompras
Return Retorno
End Function
+ Public Function UpdateFechaVencimientoCompra(CveCompra As Integer, FechaVencimiento As Date, CveEmpresa As Integer) As Boolean
+ Dim Retorno As Boolean = False
+ DataAdapter("PA_Comp_ComprasFechaVencimientoUpdate")
+ With SqlAdapter.SelectCommand.Parameters
+ .Add("@CveCompra", SqlDbType.Int).Value = CveCompra
+ .Add("@FechaVencimiento", SqlDbType.Date).Value = FechaVencimiento
+ .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
+ End With
+ Try
+ SqlAdapter.Fill(Data)
+ Retorno = True
+ Catch ex As Exception
+ OnError("Ocurrió un error al actualizar la fecha de vencimiento de la compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
+ End Try
+ Return Retorno
+ End Function
+
#Region "REPORTE PUE SIN PAGO"
Public Function GetPUESinPago(FI As DateTime, FF As DateTime, CveProveedor As Integer, CveSubProyecto As Integer, CveEmpresa As Integer, Optional CveUsuario As Integer = -1) As Boolean
diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb
index a643b79af..653c048d5 100644
--- a/App_Code/ClsPaginas.vb
+++ b/App_Code/ClsPaginas.vb
@@ -4351,6 +4351,7 @@ Public Class ClsPaginas
PaginaDict.Add("/Sistemas/PermisosPorUsuario.aspx".ToUpper(), 700)
PaginaDict.Add("/Sistemas/Cierre.aspx".ToUpper(), 713)
PaginaDict.Add("/Sistemas/CatTareasProgramadas.aspx".ToUpper(), -1)
+ PaginaDict.Add("/Sistemas/ConfiguracionEmpresa.aspx".ToUpper(), 683)
#End Region
#Region "Ventas"
'VENTAS
diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb
index c7465b9e7..c94f491b2 100644
--- a/App_Code/ClsProductosServicios.vb
+++ b/App_Code/ClsProductosServicios.vb
@@ -1796,6 +1796,87 @@ Public Class ClsProductosServicios
End Function
#End Region
+#Region "Porcentaje Marcas de Productos"
+ Public Function GetPorcentajeMarcas(CveCliente As Integer) As Boolean
+ Dim Retorno As Boolean = False
+ DataAdapter("PA_Vta_PorcentajeMarcasGet")
+
+ With SqlAdapter.SelectCommand.Parameters
+
+ .Add("@CveCliente", SqlDbType.Int).Value = CveCliente
+
+ End With
+ Try
+ SqlAdapter.Fill(Data)
+ Retorno = True
+ Catch ex As Exception
+ OnError("Ocurrió un error al obtener los porcentajes de las Marcas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ End Try
+
+ Return Retorno
+ End Function
+
+ Public Function AddPorcentajeMarcas(CveCliente As Integer, CveMarca As Integer, PorcentajeProducto As Decimal, CveUsuario As Integer) As Boolean
+ Dim Retorno As Boolean = False
+ DataAdapter("PA_Vta_PorcentajeMarcasAdd")
+
+ With SqlAdapter.SelectCommand.Parameters
+
+ .Add("@CveCliente", SqlDbType.Int).Value = CveCliente
+ .Add("@CveMarca", SqlDbType.Int).Value = CveMarca
+ .Add("@PorcentajeProducto", SqlDbType.SmallMoney).Value = PorcentajeProducto
+ .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario
+
+ End With
+ Try
+ SqlAdapter.Fill(Data)
+ Retorno = True
+ Catch ex As Exception
+ OnError("Ocurrió un error al agregar el porcentaje de la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ End Try
+
+ Return Retorno
+ End Function
+ Public Function UpdatePorcentajeMarcas(CveCliente As Integer, CveMarca As Integer, PorcentajeProducto As Decimal) As Boolean
+ Dim Retorno As Boolean = False
+ DataAdapter("PA_Vta_PorcentajeMarcasUpdate")
+
+ With SqlAdapter.SelectCommand.Parameters
+
+ .Add("@CveCliente", SqlDbType.Int).Value = CveCliente
+ .Add("@CveMarca", SqlDbType.Int).Value = CveMarca
+ .Add("@PorcentajeProducto", SqlDbType.SmallMoney).Value = PorcentajeProducto
+
+ End With
+ Try
+ SqlAdapter.Fill(Data)
+ Retorno = True
+ Catch ex As Exception
+ OnError("Ocurrió un error al actualizar el porcentaje de la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ End Try
+
+ Return Retorno
+ End Function
+ Public Function RemovePorcentajeMarcas(CveCliente As Integer, CveMarca As Integer) As Boolean
+ Dim Retorno As Boolean = False
+ DataAdapter("PA_Vta_PorcentajeMarcasRemove")
+
+ With SqlAdapter.SelectCommand.Parameters
+
+ .Add("@CveCliente", SqlDbType.Int).Value = CveCliente
+ .Add("@CveMarca", SqlDbType.Int).Value = CveMarca
+
+ End With
+ Try
+ SqlAdapter.Fill(Data)
+ Retorno = True
+ Catch ex As Exception
+ OnError("Ocurrió un error al eliminar el porcentaje de la Marca.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ End Try
+
+ Return Retorno
+ End Function
+#End Region
#Region "IDisposable Support"
diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb
index 448b3e53a..9f55d50e7 100644
--- a/App_Code/ClsVentas.vb
+++ b/App_Code/ClsVentas.vb
@@ -568,6 +568,26 @@ Public Class ClsVentas
Return Retorno
End Function
+ Public Function UpdateVentaRealizarDevolucion(CveVenta As Integer, RealizarDevolucion As Boolean, CveAlmacenDevolucion As Integer) As Boolean
+ Dim Retorno As Boolean = False
+
+ DataAdapter("PA_VentasRealizarDevolucionUpdate")
+
+ With SqlAdapter.SelectCommand.Parameters
+ .Add("@CveVenta", SqlDbType.Int).Value = CveVenta
+ .Add("@RealizarDevolucion", SqlDbType.Bit).Value = RealizarDevolucion
+ .Add("@CveAlmacenDevolucion", SqlDbType.Int).Value = CveAlmacenDevolucion
+ End With
+
+ Try
+ SqlAdapter.Fill(Data)
+ Retorno = True
+ Catch ex As Exception
+ OnError("Ocurrió un error al actualizar el estatus de devolución.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
+ End Try
+
+ Return Retorno
+ End Function
Public Function UpdateEstatusRefacturacion(CveVenta As Integer, CveEstatusRefacturacion As Integer) As Boolean
Dim Retorno As Boolean = False
@@ -835,6 +855,20 @@ Public Class ClsVentas
Return Retorno
End Function
+ Public Function GetRemisionesXCancelar(CveVenta As Integer) As Boolean
+ Dim Retorno As Boolean = False
+ DataAdapter("PA_Vta_RemisionesXCancelarGet")
+ With SqlAdapter.SelectCommand.Parameters
+ .Add("@CveVenta", SqlDbType.Int).Value = CveVenta
+ End With
+ Try
+ SqlAdapter.Fill(Data)
+ Retorno = True
+ Catch ex As Exception
+ OnError("Ocurrió un error al agregar las remisiones x cancelar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
+ End Try
+ Return Retorno
+ End Function
Public Function AddRemisionesXCancelar(CveVenta As Integer, CveVentaRemision As Integer) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Vta_RemisionesXCancelarAdd")
@@ -3596,6 +3630,23 @@ Public Class ClsVentas
Return retorno
End Function
+ Public Function TraspasaVentasAplicadasAnt(CveVentaNueva As Integer, CveVentaAnterior As Integer, CveEmpresa As Integer) As Boolean
+ Dim retorno As Boolean = False
+ DataAdapter("PA_Vta_TraspasaVentasAplicadasAnt", CommandType.StoredProcedure)
+ With SqlAdapter.SelectCommand.Parameters
+ .Add("@CveVentaNueva", SqlDbType.Int).Value = CveVentaNueva
+ .Add("@CveVentaAnterior", SqlDbType.Int).Value = CveVentaAnterior
+ .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
+ End With
+ Try
+ SqlAdapter.Fill(Data)
+ retorno = True
+ Catch ex As Exception
+ OnError("Ocurrió un error al traspasar las ventas aplicadas al nuevo anticipo.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
+ End Try
+ Return retorno
+ End Function
+
#Region " AUTORIZACION DESCUENTOS "
Public Function AutorizacionDescuentosGet(CveAutorizacionDescuento As Integer, CveEmpresa As Integer) As Boolean
diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb
index 2f8659c84..954c278f3 100644
--- a/App_Code/Modelos.vb
+++ b/App_Code/Modelos.vb
@@ -285,9 +285,9 @@ Namespace Modelos
Public Property CveProveedor As Integer
Public Property CveMoneda As Integer
- End Class
-
-
+ End Class
+
+
#Region " OBJETOS Ventas"
Public Enum TipoMensajeRespuesta
TextoLimpio = 0
@@ -316,7 +316,7 @@ Namespace Modelos
Public Sub New(ObjsClsPaginas As ClsPaginas, Optional Row As Data.DataRow = Nothing)
If Row IsNot Nothing Then
- SetValues(Row)
+ setValues(Row)
Else
IniciaValores()
End If
@@ -330,7 +330,7 @@ Namespace Modelos
Dim ObjVentas As New ClsVentas()
If ObjVentas.GetVenta(CveVenta, CveEmpresa) Then
If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
- SetValues(ObjVentas.DtResultados.Rows(0))
+ setValues(ObjVentas.DtResultados.Rows(0))
SetMetodoPago(ObjsClsPaginas)
SetMoneda(ObjsClsPaginas)
End If
@@ -344,7 +344,7 @@ Namespace Modelos
Me.RemisionesLista = New List(Of Integer)
Me.ListaMensajes = New List(Of String)
If Row IsNot Nothing Then
- SetValues(Row)
+ setValues(Row)
Else
IniciaValores()
End If
@@ -361,13 +361,13 @@ Namespace Modelos
Me.RemisionesLista = New List(Of Integer)
Me.ListaMensajes = New List(Of String)
If Row IsNot Nothing Then
- SetValues(Row)
+ setValues(Row)
Else
IniciaValores()
End If
Timbre = New CFDITimbre
End Sub
- Public Sub New(UsuarioActual As Usuario, CveVenta As Integer, CveEmpresa As Integer, DirectorioServidor As String)
+ Public Sub New(UsuarioActual As Usuario, CveVenta As Integer, CveEmpresa As Integer, Optional DirectorioServidor As String = "")
Me.UsuarioActual = UsuarioActual
Me.CveVenta = CveVenta
Me.CveEmpresa = CveEmpresa
@@ -375,10 +375,11 @@ Namespace Modelos
Me.RemisionesLista = New List(Of Integer)
Me.ListaMensajes = New List(Of String)
Me.FolioFiscal = ""
+ IniciaValores()
Dim ObjVentas As New ClsVentas()
If ObjVentas.GetVenta(CveVenta, CveEmpresa) Then
If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
- SetValues(ObjVentas.DtResultados.Rows(0))
+ setValues(ObjVentas.DtResultados.Rows(0))
SetMetodoPago()
SetMoneda()
SetSubProyecto()
@@ -389,7 +390,11 @@ Namespace Modelos
If ObjVentas.GetVentaDetalle(CveVenta) Then
Me.DtDetalle = ObjVentas.DtResultados.Copy()
End If
- ObjVentas.Dispose()
+ ObjVentas.Dispose()
+ IniciaValoresVentas()
+ If String.IsNullOrEmpty(DirectorioServidor) Then
+ DirectorioServidor = HttpContext.Current.Server.MapPath("/")
+ End If
Me.DirectorioServidor = DirectorioServidor
Timbre = New CFDITimbre
End Sub
@@ -439,6 +444,43 @@ Namespace Modelos
Me.IEPS = 0
Me.CveAlmacenTraspasoOrigen = 0
End Sub
+ Private Sub IniciaValoresVentas()
+ If CveVenta > 0 AndAlso CveEmpresa > 0 Then
+ Me.DtAnticipos = New DataTable()
+ Dim ObjVentas As New ClsVentas
+ 'CARGA PROMOCIONES
+ If ObjVentas.GetPromocionesPS(-1, Me.Fecha, Me.CveSubProyecto, CveCliente, Me.CveVendedor, Me.CveEmpresa) Then
+ Me.DtPromociones = ObjVentas.DtResultados.Copy()
+ End If
+ 'CARGA FIRMAS
+ If ObjVentas.GetVentasFirmas(CveVenta) Then
+ If ObjVentas.DtResultados.Rows.Count > 0 Then
+ DtFirmas = ObjVentas.DtResultados.Copy()
+ End If
+ End If
+ ObjVentas.Dispose()
+ Me.DtPagos = New DataTable()
+ Me.DtRemisiones = New DataTable()
+ Me.DtInventario = New DataTable()
+ Me.DtRemisionesPS = New DataTable()
+ Me.DtPedidos2 = New DataTable()
+ Me.DtPedidos2PS = New DataTable()
+ Me.DTOrdenesCompraPS = New DataTable()
+ Me.DtCotizacionesPS = New DataTable()
+ Me.DtDocumentacionCliente = New DataTable()
+ Me.DtContratosSerieDetalle = New DataTable()
+ Me.DtRemConceptosSurtidos = New DataTable()
+ Me.DtImpuestosLocales = New DataTable()
+ Me.DtOtrosConceptos = New DataTable()
+ Me.CveContratoSecciones = ""
+ 'Me.DtInventario = DtDetalle.FiltraParametros("CveTipoPS = 2")
+
+ If Me.RealizarDevolucionAlmacen Then
+ Me.CveAlmacenDevolucion = Me.CveAlmacenDevolucionVenta
+ End If
+
+ End If
+ End Sub
Public Class MMensajeFactura
Sub New()
CveVenta = -1
@@ -942,8 +984,8 @@ Namespace Modelos
Return Retorno
- End Function
-
+ End Function
+
#Region " GUARDAR - VENTA, PREPOLIZAS, INV, NC , ESTIMACIONES, AC, NOTA DE CRÉDITO "
Private Function RegistrarNCAmortizacion(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean
Dim ProcesoCorrecto As Boolean = True
@@ -1742,7 +1784,9 @@ Namespace Modelos
End If
End If
End Sub
- Private Function ProcesoPrepolizas(ObjFactura As Factura, ByRef ObjConta As ClsContabilidad, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi, Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing) As Boolean
+ Private Function ProcesoPrepolizas(ObjFactura As Factura, ByRef ObjConta As ClsContabilidad, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi,
+ Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing,
+ Optional ByRef DtRemisionesRelacionadas As DataTable = Nothing, Optional SeCancelaRemisionProceso As Boolean = False, Optional CancelarRemisiones As Boolean = False, Optional ListaRemisionesCancelar As List(Of Integer) = Nothing) As Boolean
Dim ErrorPrepoliza As Boolean = False
Try
@@ -1761,7 +1805,7 @@ Namespace Modelos
CvePlantilaPoliza = 4
ElseIf ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
CvePlantilaPoliza = 7
- ElseIf ObjFactura.TipoDocto = "Rem" Then
+ ElseIf ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then
CvePlantilaPoliza = 4
End If
@@ -1793,12 +1837,22 @@ Namespace Modelos
Dim CveSubProyectoVenta = ObjFactura.CveSubProyecto
Dim CveSubProyectoContabilizar As Integer
Dim IdCtaIVAXTrasladar As Integer = 0
- Dim IdCtaIVATrasladado As Integer = 0
-
- If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=ObjFactura.DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows.Count > 0 Then
- IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=ObjFactura.DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero
- IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=ObjFactura.DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero
+ Dim IdCtaIVATrasladado As Integer = 0
+ Dim CveCuentaIVAxTrasladar As Integer = 0
+ Dim CveCuentaIVATrasladado As Integer = 0
+ Dim SeContabiliza As Boolean = True
+
+ If (UsuarioActual.Empresa.Funcionalidad(343) = "1" AndAlso ObjFactura.TipoDocto = "Ant") Then
+ SeContabiliza = False
End If
+
+ If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=ObjFactura.DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows.Count > 0 Then
+ IdCtaIVAXTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("IdCtaIVAXTrasladar").ToString.ToEntero
+ CveCuentaIVAxTrasladar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("CveCuentaIVAXTrasladar").ToString.ToEntero
+ IdCtaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("IdCtaIVATrasladado").ToString.ToEntero
+ CveCuentaIVATrasladado = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=DtDetalle.MAX("PorcentajeIVA").ToDouble).Rows(0)("CveCuentaIVATrasladado").ToString.ToEntero
+ End If
+
Dim UsaComplementariaClientes As Boolean = False
If UsuarioActual.CveEmpresa.Contiene(1, 119) Then UsaComplementariaClientes = True
@@ -1818,7 +1872,7 @@ Namespace Modelos
Select Case ConceptoContable
Case 1 'Cliente
- If Not ObjFactura.TipoDocto.Contiene("Egs", "Rem") Then
+ If Not ObjFactura.TipoDocto.Contiene("Egs", "Rem", "RNC") Then
importeMovimiento = ((ObjFactura.Total - ObjFactura.TotalOtrosConceptos) * ValorMultiplicador)
importeMX = (importeMovimiento * tipoCambio * Multiplicador)
FechaMovimiento = ObjFactura.FechaPago
@@ -1847,20 +1901,52 @@ Namespace Modelos
CveCuentaCliente = CveCuenta
End If
- Case 3 'Cliente
-
- If ObjFactura.TipoDocto = "Ant" Then
- importeMovimiento = (ObjFactura.SubTotal * ValorMultiplicador)
- importeMX = importeMovimiento * tipoCambio * Multiplicador
- FechaMovimiento = ObjFactura.FechaPago
- IdCtaContable = ObjFactura.Cliente.IdCtaContAnticipos
- CveCuenta = ObjFactura.Cliente.CveCuentaAnticipos
- CveSubProyectoContabilizar = CveSubProyectoVenta
- If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
+ Case 3 'Cliente
+
+ If ObjFactura.TipoDocto = "Ant" Then
+ ConceptoContable = If(UsuarioActual.CveEmpresa.Contiene(1, 119), 95, ConceptoContable)
+ importeMovimiento = ObjFactura.SubTotal * ValorMultiplicador
+ importeMX = importeMovimiento * tipoCambio * Multiplicador
+ FechaMovimiento = ObjFactura.FechaPago
+ IdCtaContable = ObjFactura.Cliente.IdCtaContAnticipos
+ CveCuenta = ObjFactura.Cliente.CveCuentaAnticipos
+ CveSubProyectoContabilizar = CveSubProyectoVenta
+ If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
End If
+
Case 190 'Remisión del cliente
- If ObjFactura.TipoDocto = "Rem" Then
+ If ObjFactura.TipoDocto = "Rem" Then
+ importeMovimiento = (ObjFactura.Total - TotalOtrosConceptos) * ValorMultiplicador
+ importeMX = importeMovimiento * tipoCambio * Multiplicador
+ FechaMovimiento = ObjFactura.FechaPago
+ CveSubProyectoContabilizar = CveSubProyectoVenta
+ If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
+
+ If tipoCambio = 1 Then
+ IdCtaContable = ObjFactura.Cliente.IdCtaContClientes
+ CveCuenta = ObjFactura.Cliente.CveCuentaClientes
+ Else
+ IdCtaContable = ObjFactura.Cliente.IdCtaContMonedaExtranjera
+ CveCuenta = ObjFactura.Cliente.CveCuentaMonedaExtranjera
+ End If
+ IdCtaContableCliente = IdCtaContable
+ CveCuentaCliente = CveCuenta
+
+ If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 190, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
+ If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 193, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
+ ErrorPrepoliza = True
+ End If
+ Else
+ ErrorPrepoliza = True
+ End If
+
+ importeMovimiento = 0
+ ObjFactura.SeGuardoPrePoliza = True
+ End If
+ Case 277 'Remisión del cliente
+
+ If ObjFactura.TipoDocto = "RNC" Then
importeMovimiento = ((ObjFactura.Total - TotalOtrosConceptos) * ValorMultiplicador)
importeMX = importeMovimiento * tipoCambio * Multiplicador
FechaMovimiento = ObjFactura.FechaPago
@@ -1877,8 +1963,8 @@ Namespace Modelos
IdCtaContableCliente = IdCtaContable
CveCuentaCliente = CveCuenta
- If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 190, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
- If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 193, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
+ If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 277, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
+ If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 278, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True
End If
Else
@@ -1889,6 +1975,7 @@ Namespace Modelos
ObjFactura.SeGuardoPrePoliza = True
End If
+
Case 12 'Nota de Credito
If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
importeMovimiento = (ObjFactura.Total * ValorMultiplicador)
@@ -2287,7 +2374,7 @@ Namespace Modelos
importeMovimiento = 0
Case 4 'Venta Clasificacion
- If Not ObjFactura.TipoDocto.Contiene("Rem", "Ant", "Egs", "Dev") Then
+ If Not ObjFactura.TipoDocto.Contiene("Rem", "Ant", "Egs", "Dev", "RNC") Then
Dim ConceptoContableAplicar = 4
Dim CveVentaAplicar = ObjFactura.CveVenta
@@ -2442,7 +2529,7 @@ Namespace Modelos
importeMovimiento = 0
Case 103 'Descuento
- If Not ObjFactura.TipoDocto.Contiene("Rem") AndAlso ObjFactura.CveTipoAmortizacionAnticipo = -1 Then
+ If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso ObjFactura.CveTipoAmortizacionAnticipo = -1 Then
importeMovimiento = (ObjFactura.Descuento * ValorMultiplicador)
importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador
@@ -2480,7 +2567,7 @@ Namespace Modelos
End If
Case 8 'Ret IVA por Trasladar
- If Not ObjFactura.TipoDocto.Contiene("Rem") Then
+ If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then
importeMovimiento = (ObjFactura.RetIVA * ValorMultiplicador)
importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador
FechaMovimiento = ObjFactura.FechaPago
@@ -2511,7 +2598,7 @@ Namespace Modelos
End If
Case 9 'Ret ISR por Trasladar
- If Not ObjFactura.TipoDocto.Contiene("Rem") Then
+ If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then
importeMovimiento = (ObjFactura.RetISR * ValorMultiplicador)
importeMX = importeMovimiento * tipoCambio * Multiplicador
FechaMovimiento = ObjFactura.FechaPago
@@ -2541,7 +2628,7 @@ Namespace Modelos
End If
End If
Case 13 'Iva por Trasladar
- If Not ObjFactura.TipoDocto.Contiene("Rem") Then
+ If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then
importeMovimiento = (ObjFactura.IVA * ValorMultiplicador)
importeMX = Math.Round(importeMovimiento * tipoCambio * Multiplicador, 2)
FechaMovimiento = ObjFactura.FechaPago
@@ -2554,7 +2641,7 @@ Namespace Modelos
Case 38 'IEPS por Trasladar
- If Not ObjFactura.TipoDocto.Contiene("Rem") Then
+ If Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") Then
importeMovimiento = (ObjFactura.IEPS * ValorMultiplicador)
importeMX = Math.Round(importeMovimiento * tipoCambio * Multiplicador, 2)
FechaMovimiento = ObjFactura.Fecha
@@ -2569,104 +2656,102 @@ Namespace Modelos
End If
- Case 30 'PAGO - BANCOS
- If DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then
-
- For Each DrPago As DataRow In DtPagos.Rows
- CveIEPago = -1
-
- FolioIE = -1
- FolioIE = ObjBancos.GetNextFolio(DrPago("CveCuenta").ToString.ToEntero, DrPago("CveTipoMovimiento").ToString.ToEntero)
- If Not FolioIE > 0 Then
- ErrorPrepoliza = True
- Exit For
- End If
-
- CveIEPago = ObjBancos.AddBancos_IE(DrPago("CveCuenta").ToString.ToEntero, DrPago("CveTipoMovimiento").ToString.ToEntero, Fecha, FolioIE.ToString, String.Format("PAGO: {0}", ObjFactura.Folio), DrPago("Importe").ToString.ToDouble, ObjFactura.CveMoneda, tipoCambio, DrPago("Observaciones").ToString, "", False, False, -1, ObjFactura.CvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCorte:=CveCorte)
-
- If CveIEPago > 0 Then
-
- importeMovimiento = (DrPago("Importe").ToString.ToDecimal * ValorMultiplicador)
- importeMX = importeMovimiento * tipoCambio * Multiplicador
- IdCtaContable = 0
- CveCuenta = 0
- CveSubProyectoContabilizar = CveSubProyectoVenta
- Dim PorcentajeImpuestoPago As Decimal = TmpDTDetalle.MAX("PorcentajeIVA").ToDecimal
-
-
- If GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString.ToEntero).Rows.Count = 1 Then
- IdCtaContable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString.ToEntero).Rows(0)("IdCtaContable").ToString.ToEntero
- CveCuenta = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString.ToEntero).Rows(0)("IdCtaContableSIG").ToString.ToEntero
- End If
-
- If IdCtaContable <= 0 Then
- CuentasContablesInvalidas.AppendFormat(" {0}", GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString.ToEntero).Rows(0)("NumCuentaMoneda").ToString.ToEntero)
- idCuentaContabilizacion = 0
- End If
-
- If CveCuenta <= 0 Then
- CuentasContablesInvalidasSIG.AppendFormat(" {0}", GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString.ToEntero).Rows(0)("NumCuentaMoneda").ToString.ToEntero)
- CveCuentaContabilizacion = 0
- End If
-
- 'BANCOS
- Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 30, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
- If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then
- ErrorPrepoliza = True
- Exit For
- End If
-
- 'CLIENTES
- Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 2, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
- If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 2, Concepto, Fecha, IdCtaContableCliente, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuentaCliente, CveSubProyecto:=CveSubProyectoContabilizar) Then
- ErrorPrepoliza = True
- Exit For
- End If
-
- 'IVA X TRASLADAR
- Dim IdCtaContableIVAXTrasladar As Integer = 0
- IdCtaContableIVAXTrasladar = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar)
- Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 13, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
- If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, (importeMovimiento * ObjFactura.IVA) / ObjFactura.Total, Referencia, 13, Concepto, Fecha, IdCtaContableIVAXTrasladar, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=((importeMovimiento * ObjFactura.IVA) / ObjFactura.Total) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=UsuarioActual.Empresa.CveCuentaIVAxTrasladar, CveSubProyecto:=CveSubProyectoContabilizar, PorcentajeImpuesto:=PorcentajeImpuestoPago) Then
- ErrorPrepoliza = True
- Exit For
- End If
-
- 'IVA PAGADO
- Dim IdCtaContableIVATrasladado As Integer = 0
- IdCtaContableIVATrasladado = If(IdCtaIVATrasladado > 0, IdCtaIVATrasladado, UsuarioActual.Empresa.IdCuentaIVATrasladado)
- Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 61, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
- If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, (importeMovimiento * ObjFactura.IVA) / ObjFactura.Total, Referencia, 61, Concepto, Fecha, IdCtaContableIVATrasladado, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=((importeMovimiento * ObjFactura.IVA) / ObjFactura.Total) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=UsuarioActual.Empresa.CveCuentaIVATrasladado, CveSubProyecto:=CveSubProyectoContabilizar, PorcentajeImpuesto:=PorcentajeImpuestoPago) Then
- ErrorPrepoliza = True
- Exit For
- End If
-
- 'IEPS X TRASLADAR
- Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 38, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
- If ObjFactura.IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, (importeMovimiento * ObjFactura.IEPS) / ObjFactura.Total, Referencia, 38, Concepto, Fecha, UsuarioActual.Empresa.IdCuentaIEPSxTrasladar, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=((importeMovimiento * ObjFactura.IEPS) / ObjFactura.Total) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=UsuarioActual.Empresa.CveCuentaIEPSxTrasladar, CveSubProyecto:=CveSubProyectoContabilizar) Then
- ErrorPrepoliza = True
- Exit For
- End If
-
- 'IEPS PAGADO
- Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 39, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
- If ObjFactura.IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, (importeMovimiento * ObjFactura.IEPS) / ObjFactura.Total, Referencia, 39, Concepto, Fecha, UsuarioActual.Empresa.IdCuentaIEPSTrasladado, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=((importeMovimiento * ObjFactura.IEPS) / ObjFactura.Total) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=UsuarioActual.Empresa.CveCuentaIEPSTrasladado, CveSubProyecto:=CveSubProyectoContabilizar) Then
- ErrorPrepoliza = True
- Exit For
- End If
-
-
- Else
- ErrorPrepoliza = True
- Exit For
- End If
-
- Next
-
- importeMovimiento = 0
+ Case 30 'PAGO - BANCOS
+ If DtPagos IsNot Nothing AndAlso DtPagos.Rows.Count > 0 Then
+
+ For Each DrPago As DataRow In DtPagos.Rows
+ CveIEPago = -1
+
+ FolioIE = -1
+ FolioIE = ObjBancos.GetNextFolio(DrPago("CveCuenta").ToString.ToEntero, DrPago("CveTipoMovimiento").ToString.ToEntero)
+ If Not FolioIE > 0 Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ CveIEPago = ObjBancos.AddBancos_IE(DrPago("CveCuenta").ToString.ToEntero, DrPago("CveTipoMovimiento").ToString.ToEntero, Fecha, FolioIE.ToString, String.Format("PAGO: {0}", ObjFactura.Folio), DrPago("Importe").ToString.ToDouble, ObjFactura.CveMoneda, tipoCambio, DrPago("Observaciones").ToString, "", False, False, -1, ObjFactura.CvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCorte:=CveCorte)
+
+ If CveIEPago > 0 Then
+
+ importeMovimiento = DrPago("Importe").ToString.ToDecimal * ValorMultiplicador
+ importeMX = importeMovimiento * tipoCambio * Multiplicador
+ IdCtaContable = 0
+ CveCuenta = 0
+ CveSubProyectoContabilizar = CveSubProyectoVenta
+ Dim PorcentajeImpuestoPago As Decimal = TmpDTDetalle.MAX("PorcentajeIVA").ToDecimal
+
+
+ If GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString.ToEntero).Rows.Count = 1 Then
+ IdCtaContable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString.ToEntero).Rows(0)("IdCtaContable").ToString.ToEntero
+ CveCuenta = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString.ToEntero).Rows(0)("IdCtaContableSIG").ToString.ToEntero
+ End If
+
+ If IdCtaContable <= 0 Then
+ CuentasContablesInvalidas.AppendFormat(" {0}", GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString.ToEntero).Rows(0)("NumCuentaMoneda").ToString.ToEntero)
+ idCuentaContabilizacion = 0
+ End If
+
+ If CveCuenta <= 0 Then
+ CuentasContablesInvalidasSIG.AppendFormat(" {0}", GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString.ToEntero).Rows(0)("NumCuentaMoneda").ToString.ToEntero)
+ CveCuentaContabilizacion = 0
+ End If
+
+ 'BANCOS
+ Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 30, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
+ If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ 'CLIENTES
+ Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 2, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
+ If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 2, Concepto, Fecha, IdCtaContableCliente, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuentaCliente, CveSubProyecto:=CveSubProyectoContabilizar) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ 'IVA X TRASLADAR
+ IdCtaIVAXTrasladar = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar)
+ CveCuentaIVAxTrasladar = If(CveCuentaIVAxTrasladar > 0, CveCuentaIVAxTrasladar, UsuarioActual.Empresa.CveCuentaIVAxTrasladar)
+ Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 13, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
+ If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, (importeMovimiento * ObjFactura.IVA) / ObjFactura.Total, Referencia, 13, Concepto, Fecha, IdCtaIVAXTrasladar, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=((importeMovimiento * ObjFactura.IVA) / ObjFactura.Total) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuentaIVAxTrasladar, CveSubProyecto:=CveSubProyectoContabilizar, PorcentajeImpuesto:=PorcentajeImpuestoPago) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ 'IVA PAGADO
+ IdCtaIVATrasladado = If(IdCtaIVATrasladado > 0, IdCtaIVATrasladado, UsuarioActual.Empresa.IdCuentaIVATrasladado)
+ CveCuentaIVATrasladado = If(CveCuentaIVATrasladado > 0, CveCuentaIVATrasladado, UsuarioActual.Empresa.CveCuentaIVATrasladado)
+ Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 61, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
+ If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, (importeMovimiento * ObjFactura.IVA) / ObjFactura.Total, Referencia, 61, Concepto, Fecha, IdCtaIVATrasladado, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=((importeMovimiento * ObjFactura.IVA) / ObjFactura.Total) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuentaIVATrasladado, CveSubProyecto:=CveSubProyectoContabilizar, PorcentajeImpuesto:=PorcentajeImpuestoPago) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ 'IEPS X TRASLADAR
+ Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 38, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
+ If ObjFactura.IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, (importeMovimiento * ObjFactura.IEPS) / ObjFactura.Total, Referencia, 38, Concepto, Fecha, UsuarioActual.Empresa.IdCuentaIEPSxTrasladar, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=((importeMovimiento * ObjFactura.IEPS) / ObjFactura.Total) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=UsuarioActual.Empresa.CveCuentaIEPSxTrasladar, CveSubProyecto:=CveSubProyectoContabilizar) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ 'IEPS PAGADO
+ Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 39, ObjFactura.Cliente.Nombre, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString)
+ If ObjFactura.IEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, (importeMovimiento * ObjFactura.IEPS) / ObjFactura.Total, Referencia, 39, Concepto, Fecha, UsuarioActual.Empresa.IdCuentaIEPSTrasladado, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=((importeMovimiento * ObjFactura.IEPS) / ObjFactura.Total) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=UsuarioActual.Empresa.CveCuentaIEPSTrasladado, CveSubProyecto:=CveSubProyectoContabilizar) Then
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ Else
+ ErrorPrepoliza = True
+ Exit For
+ End If
+
+ Next
+
+ importeMovimiento = 0
End If
-
End Select
If importeMovimiento <> 0 And Not ErrorPrepoliza Then
@@ -2697,44 +2782,60 @@ Namespace Modelos
End If
- 'Si es Facturacion de una remision cancelamos, traspasamos saldos y agregamos evento a la bitacora
- If RemisionesLista.Count > 0 Then
- For Each CveRemision As Integer In RemisionesLista
- If Not ObjConta.TraspasarSaldosRemision(CveRemision, ObjFactura.CvePrePoliza, ObjFactura.CveVenta) Then
- ErrorPrepoliza = True
- End If
-
- 'Factura
- If Not ObjEventos.AddEventoBitacora($"Sustituye a: Folio Factura", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=ObjFactura.CveVenta) Then
- ErrorPrepoliza = True
- End If
-
- 'Remision
- If Not ObjEventos.AddEventoBitacora($"Refacturacion en: {ObjFactura.Folio}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveRemision) Then
- ErrorPrepoliza = True
- End If
-
- If ErrorPrepoliza Then
- Exit For
- End If
- Next
+ If DtRemisionesRelacionadas Is Nothing Then
+ If ObjVentas.GetRemisionesRelacionadas(ObjFactura.CveVenta, ObjFactura.TipoDocto) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
+ DtRemisionesRelacionadas = ObjVentas.DtResultados.Copy()
+ End If
End If
- 'REGRESA SALDO A LAS REMISIONES QUE SE FACTURARON EN EL INGRESO QUE SE ESTA CANCELANDO
- If ObjFactura.TipoDocto = "Ing" And ValorMultiplicador = -1 AndAlso NuevaFactura <> 1 Then ' se debe de excluir cuando es refacturación
- If ObjVentas.GetRemisionesRelacionadas(ObjFactura.CveVenta, ObjFactura.TipoDocto) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
- For Each Dr As DataRow In ObjVentas.DtResultados.Rows
- If Not ObjConta.TraspasarSaldosRemision(Dr("CveVenta").ToString.ToEntero, ObjFactura.CvePrePoliza, ObjFactura.CveVenta, 1) Then
- ErrorPrepoliza = True
- End If
-
- 'Remision
- If Not ObjEventos.AddEventoBitacora($"Facturación cancelada en: {ObjFactura.Folio}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=Dr("CveVenta").ToString.ToEntero) Then
- ErrorPrepoliza = True
- End If
-
- Next
+ 'Si es Facturacion de una remision cancelamos, traspasamos saldos y agregamos evento a la bitacora
+ If (DtRemisionesRelacionadas IsNot Nothing AndAlso DtRemisionesRelacionadas.Rows.Count > 0) OrElse ObjFactura.RemisionesLista.Count > 0 Then
+
+ If ObjFactura.RemisionesLista.Count = 0 AndAlso (DtRemisionesRelacionadas IsNot Nothing AndAlso DtRemisionesRelacionadas.Rows.Count > 0) Then
+ For Each Row As DataRow In DtRemisionesRelacionadas.Rows
+ ObjFactura.RemisionesLista.Add(Row("CveVenta").ToString().ToEntero())
+ Next
+ End If
+
+ If ObjFactura.RemisionesLista.Count > 0 Then
+ For Each CveRemision As Integer In RemisionesLista
+ If Not ObjConta.TraspasarSaldosRemision(CveRemision, ObjFactura.CvePrePoliza, ObjFactura.CveVenta) Then
+ ErrorPrepoliza = True
+ End If
+
+ 'Factura
+ If Not ObjEventos.AddEventoBitacora($"Sustituye a: Folio Factura", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=ObjFactura.CveVenta) Then
+ ErrorPrepoliza = True
+ End If
+
+ 'Remision
+ If Not ObjEventos.AddEventoBitacora($"Refacturacion en: {ObjFactura.Folio}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveRemision) Then
+ ErrorPrepoliza = True
+ End If
+
+ If ErrorPrepoliza Then
+ Exit For
+ End If
+ Next
+ End If
+
+ 'REGRESA SALDO A LAS REMISIONES QUE SE FACTURARON EN EL INGRESO QUE SE ESTA CANCELANDO
+ If ObjFactura.TipoDocto = "Ing" And ValorMultiplicador = -1 AndAlso NuevaFactura <> 1 AndAlso Not SeCancelaRemisionProceso Then ' se debe de excluir cuando es refacturación
+ For Each Dr As DataRow In DtRemisionesRelacionadas.Rows
+
+ Dim DebeCancelar As Boolean = CancelarRemisiones AndAlso ListaRemisionesCancelar.Any(Function(CveRemision) CveRemision = Dr("CveVenta").ToString.ToEntero())
+
+ If Not DebeCancelar Then
+ If Not ObjConta.TraspasarSaldosRemision(Dr("CveVenta").ToString.ToEntero, ObjFactura.CvePrePoliza, ObjFactura.CveVenta, 1) Then
+ ErrorPrepoliza = True
+ End If
+ If Not ObjEventos.AddEventoBitacora($"Facturación cancelada en: {ObjFactura.Folio}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=Dr("CveVenta").ToString.ToEntero) Then
+ ErrorPrepoliza = True
+ End If
+ End If
+ Next
End If
+
End If
@@ -3231,7 +3332,7 @@ Namespace Modelos
If factura.TipoDocto.Contiene("Ing", "Egs", "OP", "Com") Then
'Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL()
- Dim IDPoliza As Integer = -1 ' GenerarPolizaAC(ObjAC, Me)
+ Dim IDPoliza As Integer = GenerarPolizaAC(factura, ObjAC)
If IDPoliza > 0 Then
@@ -3253,7 +3354,7 @@ Namespace Modelos
Private Function GuardarVentaImpuestosLocales(factura As Modelos.Factura, ObjVentas As ClsVentas, ObjConta As ClsContabilidad, Optional ValorMultiplicador As Integer = 1) As Boolean
Dim ErrorPrepoliza As Boolean = False
- If DtImpuestosLocales IsNot Nothing AndAlso factura.CvePrePoliza > 0 AndAlso Not factura.TipoDocto.Contiene("Cot", "Rem") Then
+ If factura.DtImpuestosLocales IsNot Nothing AndAlso factura.CvePrePoliza > 0 AndAlso Not factura.TipoDocto.Contiene("Cot", "Rem") Then
Dim Importe As Decimal
Dim IdCtaContable, CveCuenta As Integer
@@ -3261,7 +3362,7 @@ Namespace Modelos
Dim tipoCambio As Decimal
Dim CveSubProyectoContabilizar As Integer = factura.CveSubProyecto
- For Each RowIL As DataRow In DtImpuestosLocales.Rows
+ For Each RowIL As DataRow In factura.DtImpuestosLocales.Rows
If RowIL("TipoImpuesto").ToString.ToEntero > 0 Then
Importe = RowIL("Importe").ToString.ToDecimal * ValorMultiplicador
@@ -3417,321 +3518,977 @@ Namespace Modelos
End If
End Function
- Private Function DecodeBase64(ByVal strXMLCodificado As String) As String
+ Private Shared Function DecodeBase64(ByVal strXMLCodificado As String) As String
Try
Dim decbuff As Byte() = Convert.FromBase64String(strXMLCodificado)
Return System.Text.Encoding.UTF8.GetString(decbuff)
Catch
Return ""
End Try
- End Function
- Public Function CancelarDocumento() As MMensajeFactura
- Dim Retorno As New MMensajeFactura()
- Retorno.CveVenta = CveVenta
- Retorno.CveEstatus = Me.CveEstatus
- Retorno.TieneError = False
-
-
- If CveVenta <= 0 Then
- Retorno.Mensajes.Add("Se debe asingar una CveVenta")
- Retorno.TieneError = True
- Return Retorno
- End If
-
- 'CARGA REMISIONES DE LA VENTA DEVUELTA
- Dim DtDevRem As New DataTable
- Dim ObjInventarioTemporal As New ClsInventarios()
- If ObjInventarioTemporal.GetDevolucionRemisionesCanceladas(CveVenta) Then
- DtDevRem = ObjInventarioTemporal.DtResultados.FiltraParametros("CantidadSurtida > 0")
- Else
- Retorno.Mensajes.Add("Ocurrió un error al verificar los movimientos de almacén relacionados al documento.")
- ObjInventarioTemporal.Dispose()
- Retorno.TieneError = True
- Return Retorno
- End If
- ObjInventarioTemporal.Dispose()
-
- If (DtInventario IsNot Nothing AndAlso DtInventario.Rows.Count > 0 AndAlso EsDevolucionVenta.Contiene(0, 1)) Then ' [COMENTADO IPP 3 Agosto 2017] | AndAlso Not (DdlTipoComprobante.SelectedValue.Contiene("Rem", "DPe")) | REMISION YA SE DEBE HACER POR EL PROCESO DE DEVOLUCION DE ALMACEN
- Retorno.Mensajes.Add("La factura no se puede cancelar debido a que tiene movimientos de inventario.")
- Retorno.TieneError = True
- Return Retorno
- End If
-
- Dim CancelacionFecha As Date
- Dim CancelacionAcuse As String = ""
- Dim MensajeError As String = ""
- Dim ObjCancelacion As New Timbrado
- Dim TotalT As Decimal = Total
- Dim RFCReceptor As String = Me.Cliente.RFC
- Dim CvePACCancelacion As Integer = Me.UsuarioActual.Empresa.CvePAC
- Dim CveEstatus As Integer = 4
- Dim IDPoliza As Integer = -1
- Dim CvePrePoliza As Integer
- Dim CvePlantillaPoliza As Integer
- Dim ErrorCancelar As Boolean = False
-
- Dim Continuar As Boolean = False
- Dim ContinuarCancelacion As Boolean = False
- Dim ObtenerAcuse As Boolean = False
- Dim RequiereAceptacion As Boolean = False
- Try
- If FolioFiscal <> "" Then
- If Me.TipoDocto.Contiene("Ing", "Ant", "Dev", "Egs") Then
-
- Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), UsuarioActual.Empresa.FacturaProduccion)
- If Vigencia IsNot Nothing Then
- If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then
- Retorno.Mensajes.Add("Esta factura no es cancelable.")
- Retorno.TieneError = True
- Return Retorno
- End If
- If Vigencia.Estado.ToUpper().Contains("CANCELADO") Then
- ContinuarCancelacion = False
- ObtenerAcuse = True
- Dim solicitud = New WSGF.Service1SoapClient()
- Dim acuse = solicitud.GetAcuse(UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx", "rene2018", FolioFiscal)
-
- If acuse.Estado = 0 Then
- Dim xmlAcuse = New System.Xml.XmlDocument()
- xmlAcuse.LoadXml(DecodeBase64(acuse.CfdiB64))
- CancelacionAcuse = xmlAcuse.GetElementsByTagName("SignatureValue")(0).InnerText
- CancelacionFecha = xmlAcuse.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate()
- CveEstatus = 5
- Else
- CancelacionFecha = Now.Date
- CancelacionAcuse = ""
- CveEstatus = 4
- End If
- ElseIf Vigencia.Estado.ToUpper().Contains("VIGENTE") Then
-
- If Vigencia.EstatusCancelacion.ToUpper() = "EN PROCESO" Then
- CveEstatus = 20
- ContinuarCancelacion = False
- ElseIf Vigencia.EsCancelable.ToUpper() = "CANCELABLE CON ACEPTACIÓN" Then
- CveEstatus = 20
- ContinuarCancelacion = True
- RequiereAceptacion = True
- ElseIf Vigencia.EsCancelable.ToUpper() = "CANCELABLE SIN ACEPTACIÓN" Then
- ContinuarCancelacion = True
- End If
-
- Else
- If Vigencia.EsCancelable.ToUpper() = "CANCELABLE SIN ACEPTACIÓN" Then
- ContinuarCancelacion = True
- Else
- Retorno.Mensajes.Add("La factura no se puede cancelar debido a que no se encontro su estatus en el SAT.")
- Retorno.TieneError = True
- Return Retorno
- End If
- End If
- Else
- Alert("No se pudo comprobar la vigencia de la factura.", TipoMensaje.MsgAdvertencia)
- End If
-
- If Not ObtenerAcuse Then
- If ContinuarCancelacion Then
- If ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscal, TotalT, RFCReceptor, UsuarioActual.Empresa.RFC, CvePACCancelacion) Then
- 'Generamos el acuse y mandamos mail de con el acuse de cancelación - DF 13/01/2017
- If RequiereAceptacion Then
- CancelacionFecha = Now.Date
- CancelacionAcuse = ""
- CveEstatus = 20
- Else
- CancelacionFecha = ObjCancelacion.CancelacionFecha
- CancelacionAcuse = ObjCancelacion.CancelacionAcuse
- CveEstatus = 5
- End If
- Else
- Retorno.Mensajes.Add("La factura no se pudo cancelar ante el SAT")
- Retorno.TieneError = True
- Return Retorno
- End If
- Else
- CancelacionFecha = Now.Date
- CancelacionAcuse = ""
- End If
- End If
- Else
- CancelacionFecha = Now.Date
- CancelacionAcuse = ""
- End If
- Else
- CancelacionFecha = Now.Date
- CancelacionAcuse = ""
- End If
- Catch ex As Exception
- MensajeError = "Ocurrió un Error al Cancelar la factura con los servicios del SAT."
- GuardaLog($"{MensajeError} - Error:{ex.Message}")
- Alert(MensajeError, TipoMensaje.MsgError)
- Retorno.TieneError = True
- End Try
-
- Dim ObjVentas As New ClsVentas() : ObjVentas.IniciaTransacSQL()
- Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
- Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL())
- Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL())
- Dim ObjContrato As New ClsContratos(ObjVentas.IniciaTransacSQL())
- Dim ObjEventos As New ClsOIEventos(ObjVentas.IniciaTransacSQL())
- Dim ObjAC As ClsContPAQi = Nothing
-
- If UsuarioActual.Empresa.UsaAC Then
- ObjAC = New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL()
- End If
-
- Try
- If Me.TipoDocto.Contiene("Egs", "Dev") Then
- CvePlantillaPoliza = 7
- ElseIf Me.TipoDocto.Contiene("Ing", "Rem", "Ant") Then
- CvePlantillaPoliza = 4
- Else
- CvePlantillaPoliza = 4
- End If
-
- If (Me.Saldo > 0 AndAlso CveEstatus.Contiene(4, 5)) OrElse CvePlantillaPoliza = 7 Then
- 'RMF. 2018.08.08 cuando se cancela, la póliza debe de ser de diario
- CvePrePoliza = ObjConta.AddPrePolizas("Ventas/CancelarDocumento", CvePlantillaPoliza, Me.Total, Me.Total, Me.CveMoneda, Now, Me.Cliente.Nombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
- Me.CvePrePoliza = CvePrePoliza
-
- 'CANCELAR PAGOS
- If Me.TipoDocto.Contiene("Egs", "Dev") Then
- If Not ErrorCancelar Then
- If Not ObjConta.PrePolizasCancelarPagos(CveDevolucion, CvePrePoliza) Then
- ErrorCancelar = True
- MensajeError = "Ocurrió un error al generar la prepoliza de cancelación de pago."
- End If
- End If
- End If
-
- 'CANCELA PREPOLIZA
- If Not ErrorCancelar Then
- ErrorCancelar = ProcesoPrepolizas(Me, ObjConta, -1, DtDetalle, ObjAC, -1, ObjBancos, ObjVentas, ObjEventos)
- MensajeError = "Ocurrió un error al generar la prepoliza de cancelación."
- End If
-
- 'CANCELA IMPUESTOS LOCALES
- If Not ErrorCancelar Then
- ErrorCancelar = GuardarVentaImpuestosLocales(Me, ObjVentas, ObjConta, -1)
- MensajeError = "Ocurrió un error al cancelar los impuestos locales."
- End If
- End If
-
- 'CANCELA CONTRATOS
- If Not ErrorCancelar Then
- ErrorList = New List(Of String)
- If Me.CveContrato > 0 AndAlso Me.TipoDocto.Contiene("Ing", "Ant") Then
- GuardarContratoAvanceEstimaciones(ObjContrato, ErrorList, -1, True)
- ErrorCancelar = ErrorList.Count > 0
- MensajeError = "Ocurrió un error al cancelar las estimaciones del contrato."
- ElseIf Me.CveContrato > 0 AndAlso Me.TipoDocto.Contiene("Egs", "Dev") Then
- GuardarContratoAvanceEstimaciones(ObjContrato, ErrorList, 1, True)
- ErrorCancelar = ErrorList.Count > 0
- MensajeError = "Ocurrió un error al cancelar los avances del contrato."
- End If
- End If
-
-
- 'DESVINCULA REMISIONES PREDECESORAS
- If Not ErrorCancelar Then
- If Me.TipoDocto.Contiene("Ing", "Ant") Then
- If Not ObjVentas.LiberarRemisionesFacturadas(CveVenta) Then
- ErrorCancelar = True
- MensajeError = "Ocurrió un error al desvincular las remisiones."
- End If
- End If
- End If
-
- 'DESVINCULA COTIZACIONES PREDECESORAS
- If Not ErrorCancelar Then
- If Me.TipoDocto.Contiene("Ing", "Ant", "Rem") Then
- If Not ObjVentas.LiberarCotizacionesFacturadas(CveVenta) Then
- ErrorCancelar = True
- MensajeError = "Ocurrió un error al desvincular las cotizaciones."
- End If
- End If
- End If
-
- 'DESVINCULA PEDIDOS2 PREDECESORES
- If Not ErrorCancelar Then
- If Me.TipoDocto.Contiene("Ing", "Ant", "Rem") Then
- If Not ObjVentas.LiberarPedidos2Facturados(CveVenta) Then
- ErrorCancelar = True
- MensajeError = "Ocurrió un error al desvincular los pedidos."
- End If
- End If
- End If
-
- 'DESVINCULA OCs PREDECESORAS
- If Not ErrorCancelar Then
- If Me.TipoDocto = "Ing" Then
- If Not ObjVentas.LiberarOCFacturadas(CveVenta) Then
- ErrorCancelar = True
- MensajeError = "Ocurrió un error al desvincular las Ordenes de Compra."
- End If
- End If
- End If
-
- 'ELIMINA LAS VENTAS DETALLE DE LA DEVOLUCION
- If Not ErrorCancelar Then
- If Me.TipoDocto = "Dev" Then
- If Not ObjVentas.RemoveVentaDetalleDevolucion(CveVenta) Then
- ErrorCancelar = True
- MensajeError = "Ocurrió un error al eliminar las ventas detalle devolución."
- End If
- End If
- End If
-
- 'POLIZA DE CANCELACION
- If Not ErrorCancelar Then
- 'If UsuarioActual.Empresa.UsaAC Then
- ' IDPoliza = GenerarPolizaAC(ObjAC, True)
- ' If IDPoliza <= 0 Then
- ' ErrorCancelar = True
- ' MensajeError = "Ocurrió un error al generar la poliza de cancelación."
- ' End If
- 'End If
- End If
-
- 'ACTUALIZA ESTATUS
- If Not ErrorCancelar Then
- Select Case Me.TipoDocto
- Case "Rem"
- CveEstatus = 12
- Case "Com"
- CveEstatus = 9
- End Select
-
- If Not ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, CancelacionAcuse, CancelacionFecha, CveVenta, IDPoliza, CvePAC:=CvePACCancelacion) Then
- ErrorCancelar = True
- MensajeError = "Ocurrió un error al guardar el estatus de cancelación."
- End If
- End If
-
- If Not ErrorCancelar Then
- ObjVentas.Commit()
- If ObjAC IsNot Nothing Then ObjAC.Commit()
- Me.CveEstatus = CveEstatus
- Retorno.CveEstatus = CveEstatus
- Retorno.Mensajes.Add("La factura se cancelo correctamente")
- Else
- Retorno.Mensajes.Add(MensajeError)
- ObjVentas.RollBack()
- If ObjAC IsNot Nothing Then ObjAC.RollBack()
- End If
- Catch ex As Exception
- GuardaLog(ex.ToString())
- ObjVentas.RollBack()
- If ObjAC IsNot Nothing Then ObjAC.RollBack()
- Finally
-
- ObjVentas.Dispose()
- ObjBancos.Dispose()
- ObjInventario.Dispose()
- ObjContrato.Dispose()
- ObjConta.Dispose()
- If ObjAC IsNot Nothing Then ObjAC.Dispose()
- Retorno.TieneError = ErrorCancelar
- End Try
- Return Retorno
+ End Function
+ Public Class MCancelacionVentaMensaje
+ Public Property HuboError As Boolean = False
+ Public Property TipoMensaje As TipoMensaje
+ Public Property Mensaje As String
+ Public Property CveEstatus As Integer
+ End Class
+ '''
+ ''' Ejecuta los procesos pendientes para concluir la cancelacion de la factura
+ '''
+ '''
+ '''
+ '''
+ '''
+ Public Function EjecutarCancelacionPendiente(CveEstatus As Integer, FechaCancelacion As DateTime, AcuseCancelacion As String) As MCancelacionVentaMensaje
+ Dim ListaRemisionesCancelar As New List(Of Integer)
+ Dim ObjVentas As New ClsVentas()
+ If ObjVentas.GetRemisionesXCancelar(Me.CveVenta) Then
+ For Each Row As DataRow In ObjVentas.DtResultados.Rows
+ ListaRemisionesCancelar.Add(Row("CveVentaRemision").ToString().ToEntero())
+ Next
+ End If
+ ObjVentas.Dispose()
+
+
+ Return CancelarVenta(Me, Me.UsuarioActual, RealizarDevolucionAlmacen:=Me.RealizarDevolucionAlmacen, ListaRemisionesCancelar:=ListaRemisionesCancelar, CveEstatusFacturaAsignado:=CveEstatus, FechaCancelacion:=FechaCancelacion.ToString("dd/MM/yyyy hh:mm:ss"), AcuseCancelacion:=AcuseCancelacion)
+ End Function
+ '''
+ ''' Cancela la factura para poder realizar la refacturacion
+ '''
+ '''
+ Public Function CancelarPorRefacturacion() As MCancelacionVentaMensaje
+ Return CancelarVenta(Me, Me.UsuarioActual, EsRefacturacion:=True)
+ End Function
+ '''
+ ''' Cancela la factura y realiza las operaciones correspondientes
+ '''
+ '''
+ '''
+ '''
+ Public Function CancelarFactura(RealizarDevolucionAlmacen As Boolean, Optional ListaRemisionesCancelar As List(Of Integer) = Nothing) As MCancelacionVentaMensaje
+ Return CancelarVenta(Me, Me.UsuarioActual, RealizarDevolucionAlmacen:=RealizarDevolucionAlmacen, ListaRemisionesCancelar:=ListaRemisionesCancelar)
+ End Function
+
+ Private Function CancelarVenta(ObjFactura As Modelos.Factura, UsuarioActual As Usuario, Optional EsRefacturacion As Boolean = False, Optional RealizarDevolucionAlmacen As Boolean = False,
+ Optional ListaRemisionesCancelar As List(Of Integer) = Nothing, Optional CveEstatusFacturaAsignado As Integer = -1,
+ Optional FechaCancelacion As String = "-1", Optional AcuseCancelacion As String = "") As MCancelacionVentaMensaje
+ Dim Retorno As New MCancelacionVentaMensaje()
+ Dim ErrorList As New List(Of String)
+
+ Dim CveVenta As Integer = ObjFactura.CveVenta
+
+ Dim EsRemisionFacturada As Boolean = False
+ Dim TieneRemisionesRelacionadas As Boolean = False
+ Dim CancelarRemisiones As Boolean = ListaRemisionesCancelar IsNot Nothing AndAlso ListaRemisionesCancelar.Count > 0
+
+ Dim TieneAlmacen As Boolean = False
+
+ 'VALIDA QUE LA FACTURA NO TENGA PAGOS
+ If ObjFactura.TipoDocto.Contiene("Ing", "Rem") AndAlso ObjFactura.Pagado > 0 Then
+ Retorno.Mensaje = "La factura no se puede cancelar debido a que tiene pagos vinculados."
+ Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia
+
+ Return Retorno
+ End If
+
+ Dim ObjInv As New ClsInventarios
+ If ObjInv.GetInv_Mov(CveVenta, UsuarioActual.CveEmpresa) Then
+ TieneAlmacen = ObjInv.DtResultados.Rows.Count > 0
+ End If
+ ObjInv.Dispose()
+
+ 'CARGA AS NOTAS DE CREDITO VINCULADAS
+ Dim DTDocumentosRelacionados As New DataTable
+ If ObjFactura.TipoDocto.Contiene("Ing", "Ant", "Rem") Then
+ Dim ObjVentasAntNC As New ClsVentas
+ If ObjVentasAntNC.GetVentasAntNC(ObjFactura.CveVenta, -1) Then
+ DTDocumentosRelacionados = ObjVentasAntNC.DtResultados.Copy()
+ End If
+ ObjVentasAntNC.Dispose()
+ End If
+
+ 'LA VALIDACION DE SALDOS CUANDO ES REFACTURACION SE HACE ANTES ASI QUE SI ES REFACTURACION IGNORAMOS ESTA CONDICION, SI ES ANTICIPO VERIFICA QUE NO ESTÉ APLICADO
+ If ObjFactura.TipoDocto = "Ant" AndAlso ObjFactura.Pagado > 0 AndAlso DTDocumentosRelacionados.Rows.Count > 0 Then
+ Retorno.Mensaje = "La factura no se puede cancelar debido a que tiene pagos vinculados."
+ Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia
+
+ Return Retorno
+ End If
+
+ 'SI LA REMISION ESTA FACTURADA NO SE PUEDE CANCELAR
+ If ObjFactura.TipoDocto = "Rem" Then
+ Dim ObjV As New ClsVentas
+ If ObjV.VerificarRemisionFacturada(ObjFactura.CveVenta) Then
+ EsRemisionFacturada = ObjV.DtResultados.Rows.Count > 0
+ End If
+ ObjV.Dispose()
+
+ If EsRemisionFacturada Then
+ Retorno.Mensaje = "La factura no se puede cancelar debido a que tiene pagos vinculados."
+ Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia
+
+ Return Retorno
+ End If
+
+ End If
+
+ 'CARGA REMISIONES DE LA VENTA DEVUELTA
+ Dim DtDevRem As New DataTable
+ If Not EsRefacturacion Then
+ Dim ObjInventarioTemporal As New ClsInventarios()
+ If ObjInventarioTemporal.GetDevolucionRemisionesCanceladas(ObjFactura.CveVenta) Then
+ DtDevRem = ObjInventarioTemporal.DtResultados
+ Else
+ ObjInventarioTemporal.Dispose()
+
+ Retorno.Mensaje = "Ocurrió un error al verificar los movimientos de almacén relacionados al documento."
+ Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia
+
+ Return Retorno
+ End If
+ ObjInventarioTemporal.Dispose()
+ End If
+
+ 'CARGA REMISIONES
+ Dim DtRemisionesRelacionadas As New DataTable()
+ Dim ObjVentasRem As New ClsVentas
+ If ObjVentasRem.GetRemisionesRelacionadas(ObjFactura.CveVenta, ObjFactura.TipoDocto) Then
+ DtRemisionesRelacionadas = ObjVentasRem.DtResultados.Copy()
+ TieneRemisionesRelacionadas = DtRemisionesRelacionadas.Rows.Count > 0
+ End If
+ ObjVentasRem.Dispose()
+
+ 'SI ES REMISION PARA CANCELARLA NO DEBE TENER NINGUNA FACTURADA RELACIONADA
+ If ObjFactura.TipoDocto.Contiene("Rem") And DtRemisionesRelacionadas.Rows.Count > 0 Then
+ Retorno.Mensaje = "La remision no debe tener ninguna factura relacionada para poder cancelarla."
+ Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia
+
+ Return Retorno
+ End If
+
+ 'CUANDO SE CANCELA, Y TIENE RELACIONADA UNA REMISIÓN, Y ESTA NO SE CANCELARÁ. DEBE DE HACER EN AUTOMÁTICO LOS MOVIMIENTOS AL ALMACEN DE ENTREGA POR ADELANTADO
+ Dim RevivirRemisiones = Not EsRefacturacion AndAlso ((TieneRemisionesRelacionadas AndAlso ListaRemisionesCancelar Is Nothing) OrElse (DtRemisionesRelacionadas.Rows.Count > ListaRemisionesCancelar.Count))
+
+ 'REMISION YA SE DEBE HACER POR EL PROCESO DE DEVOLUCION DE ALMACEN
+ If Not EsRefacturacion AndAlso (ObjFactura.SaldoAlmacen > 0 AndAlso ObjFactura.EsDevolucionVenta.Contiene(0, 1)) AndAlso Not RealizarDevolucionAlmacen And RevivirRemisiones = False Then
+
+ Retorno.Mensaje = "La factura no se puede cancelar debido a que tiene movimientos de inventario."
+ Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia
+
+ Return Retorno
+ End If
+
+
+ Dim CancelacionFecha As Date
+ Dim FolioFiscal As String = ObjFactura.FolioFiscal
+ Dim CancelacionAcuse As String = ""
+ Dim MensajeError As String = ""
+ Dim ObjCancelacion As New Timbrado
+ Dim TotalT As Decimal = ObjFactura.Total
+ Dim RFCReceptor As String = ObjFactura.Cliente.RFC
+ Dim CvePACCancelacion As Integer = ObjFactura.CvePAC
+ Dim CveEstatus As Integer = 4
+ Dim IDPoliza As Integer = -1
+ Dim CvePrePoliza As Integer
+ Dim CvePlantillaPoliza As Integer
+ Dim ErrorCancelar As Boolean = False
+
+ Dim Continuar As Boolean = False
+ Dim ContinuarCancelacion As Boolean = False
+ Dim ObtenerAcuse As Boolean = False
+ Dim RequiereAceptacion As Boolean = False
+ Dim Mensaje As String = ""
+
+ If CveEstatusFacturaAsignado <= 0 Then
+ Try
+ If ObjFactura.FolioFiscal <> "" Then
+ If ObjFactura.TipoDocto.Contiene("Ing", "Ant", "Dev", "Egs") Then
+
+ Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), UsuarioActual.Empresa.FacturaProduccion)
+
+ If Vigencia IsNot Nothing Then
+ If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then
+ Retorno.Mensaje = "Esta factura no es cancelable."
+ Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia
+
+ Return Retorno
+ End If
+ If Vigencia.Estado.ToUpper().Contains("CANCELADO") Then
+ ContinuarCancelacion = False
+ ObtenerAcuse = True
+ Dim solicitud = New WSGF.Service1SoapClient()
+ Dim acuse = solicitud.GetAcuse(UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx", "rene2018", FolioFiscal)
+
+ If acuse.Estado = 0 Then
+ Dim xmlAcuse = New System.Xml.XmlDocument()
+ xmlAcuse.LoadXml(DecodeBase64(acuse.CfdiB64))
+ CancelacionAcuse = xmlAcuse.GetElementsByTagName("SignatureValue")(0).InnerText
+ CancelacionFecha = xmlAcuse.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate()
+ CveEstatus = 5
+ Else
+ CancelacionFecha = Now.Date
+ CancelacionAcuse = ""
+ CveEstatus = 5
+ End If
+
+ ElseIf Vigencia.Estado.ToUpper().Contains("VIGENTE") Then
+
+ If Vigencia.EstatusCancelacion.ToUpper() = "EN PROCESO" Then
+ CveEstatus = 20
+ ContinuarCancelacion = False
+ ElseIf Vigencia.EsCancelable.ToUpper() = "CANCELABLE CON ACEPTACIÓN" Then
+ CveEstatus = 20
+ ContinuarCancelacion = True
+ RequiereAceptacion = True
+ ElseIf Vigencia.EsCancelable.ToUpper() = "CANCELABLE SIN ACEPTACIÓN" Then
+ ContinuarCancelacion = True
+ CveEstatus = 5
+ End If
+
+ Else
+ If Vigencia.EsCancelable.ToUpper() = "CANCELABLE SIN ACEPTACIÓN" Then
+ ContinuarCancelacion = True
+ CveEstatus = 5
+ Else
+ CveEstatus = 20
+ ContinuarCancelacion = False
+ CancelacionFecha = Now.Date
+ CancelacionAcuse = ""
+ End If
+ End If
+ Else
+ Retorno.Mensaje = "No se pudo comprobar la vigencia de la factura."
+ Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia
+
+ Return Retorno
+ End If
+
+ If Not ObtenerAcuse Then
+ If ContinuarCancelacion Then
+ If ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscal, TotalT, RFCReceptor, UsuarioActual.Empresa.RFC, CvePACCancelacion) Then
+ 'GENERAMOS EL ACUSE Y MANDAMOS MAIL DE CON EL ACUSE DE CANCELACIÓN
+ If RequiereAceptacion Then
+ CancelacionFecha = Now.Date
+ CancelacionAcuse = ""
+ CveEstatus = 20
+
+ Else
+ CancelacionFecha = ObjCancelacion.CancelacionFecha
+ CancelacionAcuse = ObjCancelacion.CancelacionAcuse
+ CveEstatus = 5
+ End If
+ Else
+ Retorno.Mensaje = "La factura no se pudo cancelar ante el SAT."
+ Retorno.TipoMensaje = TipoMensaje.MsgError
+
+ Return Retorno
+ End If
+ Else
+ CancelacionFecha = Now.Date
+ CancelacionAcuse = ""
+ End If
+ End If
+ Else
+ CancelacionFecha = Now.Date
+ CancelacionAcuse = ""
+ End If
+ Else
+ CancelacionFecha = Now.Date
+ CancelacionAcuse = ""
+ End If
+ Catch ex As Exception
+ MensajeError = "Ocurrió un Error al Cancelar la factura con los servicios del SAT."
+ ModExtensiones.GuardaLog($"{MensajeError} - Error:{ex.Message}")
+
+ Retorno.Mensaje = MensajeError
+ Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia
+ Retorno.HuboError = True
+
+ Return Retorno
+ End Try
+ Else
+ CveEstatus = CveEstatusFacturaAsignado
+ CancelacionFecha = FechaCancelacion.ToDateTime()
+ CancelacionAcuse = AcuseCancelacion
+ End If
+
+ 'SI ES CANCELACION EN PROCESO CANCELA EL PROCESO DE LAS REMISIONES
+ Dim SeCancelaRemisionProceso = (CveEstatus = 20 AndAlso TieneRemisionesRelacionadas AndAlso CancelarRemisiones)
+
+ Retorno.CveEstatus = CveEstatus
+
+ Dim ObjVentas As New ClsVentas() : ObjVentas.IniciaTransacSQL()
+ Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
+ Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL())
+ Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL())
+ Dim ObjContrato As New ClsContratos(ObjVentas.IniciaTransacSQL())
+ Dim ObjEventos As New ClsOIEventos(ObjVentas.IniciaTransacSQL())
+ Dim ObjAC As ClsContPAQi = Nothing
+ If UsuarioActual.Empresa.UsaAC Then
+ ObjAC = New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL()
+ End If
+
+
+ Try
+ If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
+ CvePlantillaPoliza = 7
+ ElseIf ObjFactura.TipoDocto.Contiene("Ing", "Rem", "Ant") Then
+ CvePlantillaPoliza = 4
+ Else
+ CvePlantillaPoliza = 4
+ End If
+
+ 'CUANDO LA CANCELACION ESTA EN PROCESO NO DEBE REALIZAR NADA DE ESTE PROCESO
+ If (((ObjFactura.Saldo > 0 AndAlso (CveEstatus > 0 AndAlso CveEstatus <> 20)) OrElse (ObjFactura.Total = 0 AndAlso UsuarioActual.CveEmpresa.Contiene(72) AndAlso ObjFactura.TipoDocto.Contiene("Ing"))) AndAlso CveEstatus.Contiene(4, 5)) OrElse CvePlantillaPoliza = 7 Then
+
+ 'CUANDO SE CANCELA, LA PÓLIZA DEBE DE SER DE DIARIO
+ CvePrePoliza = ObjConta.AddPrePolizas("Modelos/CancelarDocumento", CvePlantillaPoliza, ObjFactura.Total, ObjFactura.Total, ObjFactura.CveMoneda, Now, ObjFactura.Cliente.Nombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
+ ObjFactura.CvePrePoliza = CvePrePoliza
+
+ 'CANCELAR PAGOS
+ If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
+ If Not ErrorCancelar Then
+ If Not ObjConta.PrePolizasCancelarPagos(ObjFactura.CveDevolucion, CvePrePoliza) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al generar la prepoliza de cancelación de pago."
+ End If
+ End If
+ End If
+
+ 'CANCELA PREPOLIZA
+ If Not ErrorCancelar Then
+ ErrorCancelar = ProcesoPrepolizas(ObjFactura, ObjConta, -1, ObjFactura.DtDetalle, ObjAC, -1, ObjBancos, ObjVentas, ObjEventos, DtRemisionesRelacionadas:=DtRemisionesRelacionadas,
+ SeCancelaRemisionProceso:=SeCancelaRemisionProceso, CancelarRemisiones:=CancelarRemisiones, ListaRemisionesCancelar:=ListaRemisionesCancelar)
+ MensajeError = "Ocurrió un error al generar la prepoliza de cancelación."
+ End If
+
+ 'CANCELA IMPUESTOS LOCALES
+ If Not ErrorCancelar Then
+ ErrorCancelar = GuardarVentaImpuestosLocales(ObjFactura, ObjVentas, ObjConta, -1)
+ MensajeError = "Ocurrió un error al cancelar los impuestos locales."
+ End If
+
+ End If
+
+ 'CUANDO LA CANCELACION ESTA EN PROCESO NO DEBE REALIZAR NADA DE ESTE PROCESO
+ If Not EsRefacturacion AndAlso (CveEstatus > 0 AndAlso CveEstatus <> 20) Then
+
+ 'DEVOLUCION DE ALMACEN
+ If Not ErrorCancelar AndAlso TieneAlmacen Then
+ Dim TieneSalida As Boolean = False
+ Dim DtDatos As New DataTable
+ Dim DtExistencias As New DataTable
+
+ 'CUANDO SE VAYA A REALIZAR LA DEVOLUCION AQUI DEBE MARCALA PARA NO SOLICITARLA DE NUEVO, SI NO LA SOLICITARA
+ If ObjFactura.EsDevolucionVenta = 0 Then
+ Dim EstatusDevolucion = 1
+ If Not ObjVentas.UpdateVentasDevolucionAlmacen(EstatusDevolucion, CveVenta) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al solicitar la devolucion de almacen."
+ End If
+ End If
+
+ If Not ErrorCancelar AndAlso ObjInventario.EntregaAlmacenGet(CveVenta) Then
+ If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
+ DtDatos = ObjInventario.DtResultados
+ DtDatos.Columns.Add("Consec", GetType(Integer))
+ DtDatos.Columns.Add("CantidadGV", GetType(Double))
+ DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
+ Dim Index = 1
+ For Each Dr As DataRow In DtDatos.Rows
+ Dr("Consec") = Index
+ Dr("CantidadGV") = Dr("CantidadF")
+ Index += 1
+ Next
+
+ If DtDatos IsNot Nothing AndAlso DtDatos.Rows.Count > 0 AndAlso ObjInventario.DtResultados.Rows(0)("CveVentaPadre").ToString.ToEntero > 0 Then
+ Dim Filtro As String
+ Select Case ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString
+ Case "Ing", "Ped"
+ Filtro = "CveConcepto = 3"
+ Case "Dev"
+ Filtro = "CveConcepto = 3"
+ Case Else
+ Filtro = "CveConcepto = 9"
+ End Select
+
+ If ObjInventario.GetInv_Mov(ObjInventario.DtResultados.Rows(0)("CveVentaPadre").ToString.ToEntero, UsuarioActual.CveEmpresa) Then
+ DtExistencias = ObjInventario.DtResultados.FiltraParametros($"CvePS Is Not NULL AND {Filtro}")
+
+ If DtExistencias.Rows.Count > 0 Then
+ TieneSalida = True
+ End If
+
+ Else
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar."
+ End If
+ End If
+
+ End If
+ End If
+
+ If Not ErrorCancelar AndAlso TieneSalida Then
+
+
+ Dim DtTraspasos As New DataTable
+ DtTraspasos.Columns.Add("CveAlmacen", GetType(Integer))
+ DtTraspasos.Columns.Add("Almacen", GetType(String))
+ DtTraspasos.Columns.Add("CveMovimientoSalida", GetType(Integer))
+ DtTraspasos.Columns.Add("FolioSalida", GetType(Integer))
+ DtTraspasos.Columns.Add("CveMovimientoEntrada", GetType(Integer))
+ DtTraspasos.Columns.Add("FolioEntrada", GetType(Integer))
+
+ Dim ConceptoMovimiento = 18 'DEVOLUCION DEL CLIENTE
+ Dim CveMovimiento As Integer = 0
+ Dim Folio As Integer = 0
+ Dim CantidadPendiente As Decimal = 0
+
+ If Not ErrorCancelar AndAlso RealizarDevolucionAlmacen Then
+ Dim CveAlmacenDevolucion = ObjFactura.CveAlmacenDevolucion
+
+ CveMovimiento = ObjInventario.AddMovimiento(CveAlmacenDevolucion, ConceptoMovimiento, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveAlmacenDestino:=-1)
+ Folio = ObjInventario.Folio
+
+ 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN)
+ If CveMovimiento > 0 Then
+
+ 'ES EL MOVIMIENTO PRINCIPAL
+ CantidadPendiente = 0
+ For Each Dr As DataRow In DtDatos.Rows
+ CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal
+ If CantidadPendiente > 0 Then
+ Dim PU As Decimal = 0
+
+ If DtExistencias IsNot Nothing Then
+ PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal
+ End If
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar."
+ Exit For
+ End If
+
+ End If
+ Next
+ Else
+ MensajeError = "Ocurrió un error al agregar el movimiento"
+ ErrorCancelar = True
+ End If
+
+ 'GENERA PREPOLIZA DEL MOVIMIENTO DE DEVOLUCION
+ If Not ErrorCancelar Then
+ Dim DtCostos As DataTable = Nothing
+ Dim ValorInventario As Decimal = 0
+ If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
+ DtCostos = ObjInventario.DtResultados
+
+ Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
+ Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {CveAlmacenDevolucion}").ToEntero
+ Dim CveCuentaAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {CveAlmacenDevolucion}").ToEntero
+ Dim IdCtaContable As Integer = 0
+ Dim CveCuenta As Integer = 0
+ If tmpCostos.Rows.Count > 0 Then
+
+ If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
+ Dim Fecha As Date = Now
+ Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero
+ Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString
+ Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString
+ Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL()
+ Dim TotalCostoAcumulado As Decimal = 0
+ Dim cont As Integer = 1
+
+ Dim CvePrePolizaDev As Integer = ObjConta.AddPrePolizas("Inventario/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
+ 'SE AGREGA MOVIMIENTO SEPARADO POR LA CUENTA DE VENTAS (ER)
+ For Each RowInv As DataRow In tmpCostos.Rows
+ ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL()
+ TotalCostoAcumulado += ValorInventario
+
+ 'CUANDO ES EL ÚLTIMO MOVIMIENTO Y HAY DIFERENCIAS EN LOS IMPORTES
+ If cont = DtCostos.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then
+ ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado)
+ End If
+
+ IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
+ CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
+
+ If Not ErrorCancelar Then
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, False, -1 * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=ObjFactura.CveSubProyecto, ImporteMX:=-1 * ValorInventario, CveCuenta:=CveCuenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then
+ ErrorCancelar = True
+ End If
+ End If
+
+ cont += 1
+ Next
+
+ If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, True, -1 * TotalCosto, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=ObjFactura.CveSubProyecto, ImporteMX:=-1 * TotalCosto, CveCuenta:=CveCuentaAlmacen) Then
+ ErrorCancelar = True
+ End If
+
+ 'AUTOCONTA - EL MOVIMIENTO 1 ES EL DE VENTA
+
+ Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
+
+ If UsuarioActual.CveEmpresa = 119 AndAlso ObjFactura.TipoDocto = "Ant" Then
+ AutoConta = False
+ End If
+
+ If AutoConta And Not ErrorCancelar Then
+ Dim ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa)
+
+ If IdCtaContable > 0 Then
+ If Not ObjConta.ContabilizarPrePoliza(CvePrePolizaDev, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al contabilizar la prepoliza."
+ End If
+ Else
+ Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia)
+ End If
+
+ ObjContPaq.Dispose()
+ End If
+
+ Else
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un Error al ingresar las prepolizas"
+ End If
+
+ End If
+ End If
+ End If
+
+ 'If Not ErrorCancelar AndAlso RevivirRemisiones Then
+ ' If Not GeneraMovimientosApartados(ObjInventario, DtTraspasos) Then
+ ' ErrorCancelar = True
+ ' MensajeError = "Ocurrió un error al guardar los movimientos de control de apartados"
+ ' End If
+ 'End If
+
+ 'DEVOLUCION REMISION - REGRESA LAS EXISTENCIAS A ENTREGA POR ADELANTADO SI LA FACTURA VIENE DE REMISION
+ If Not ErrorCancelar AndAlso RevivirRemisiones Then
+ If Not GeneraMovimientosEntregaPorAdelantadoRemision(CveMovimiento, ObjVentas, ObjInventario, DtDevRem, ListaRemisionesCancelar) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al generar los movimientos de devolución a remisión"
+ End If
+ End If
+
+ If Not ErrorCancelar Then
+ 'QUEMA DEVOLUCION | QUEMA = LA QUITA DE PENDIENTE POR RECIBIR (DEVOLVER)
+ If CveMovimiento > 0 AndAlso RealizarDevolucionAlmacen Then
+ If Not ErrorCancelar Then
+ If Not ObjVentas.UpdateVentasDevolucionAlmacen(2, CveVenta) Then
+ MensajeError = "Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar."
+ ErrorCancelar = True
+ End If
+ End If
+
+ 'AGREGA BITACORA A VENTA
+ If Not ErrorCancelar Then
+ Dim MensajeBitacora = "Devuelta"
+ If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimiento, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then
+ ErrorCancelar = True
+ End If
+ End If
+ End If
+ End If
+
+ End If
+ End If
+ End If
+
+ 'CANCELA CONTRATOS
+ If Not ErrorCancelar Then
+ If ObjFactura.CveContrato > 0 AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Ant") Then
+ ObjFactura.GuardarContratoAvanceEstimaciones(ObjContrato, ErrorList, -1, True)
+ ErrorCancelar = ErrorList.Count > 0
+ MensajeError = "Ocurrió un error al cancelar las estimaciones del contrato."
+ ElseIf ObjFactura.CveContrato > 0 AndAlso ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
+ ObjFactura.GuardarContratoAvanceEstimaciones(ObjContrato, ErrorList, 1, True)
+ ErrorCancelar = ErrorList.Count > 0
+ MensajeError = "Ocurrió un error al cancelar los avances del contrato."
+ End If
+ End If
+
+ 'DESVINCULA COTIZACIONES FACTURADAS
+ If Not ErrorCancelar Then
+ If ObjFactura.TipoDocto.Contiene("Ing", "Ant", "Rem") Then
+ If Not ObjVentas.LiberarCotizacionesFacturadas(CveVenta) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al desvincular las cotizaciones."
+ End If
+ End If
+ End If
+
+ 'DESVINCULA PEDIDOS2 PREDECESORES
+ If Not ErrorCancelar Then
+ If ObjFactura.TipoDocto.Contiene("Ing", "Ant", "Rem") Then
+ If Not ObjVentas.LiberarPedidos2Facturados(CveVenta) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al desvincular los pedidos."
+ End If
+ End If
+ End If
+
+ 'DESVINCULA OCs PREDECESORAS
+ If Not ErrorCancelar Then
+ If ObjFactura.TipoDocto = "Ing" Then
+ If Not ObjVentas.LiberarOCFacturadas(CveVenta) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al desvincular las Ordenes de Compra."
+ End If
+ End If
+ End If
+
+ 'ELIMINA LAS VENTAS DETALLE DE LA DEVOLUCION
+ If Not ErrorCancelar Then
+ If ObjFactura.TipoDocto = "Dev" Then
+ If Not ObjVentas.RemoveVentaDetalleDevolucion(CveVenta) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al eliminar las ventas detalle devolución."
+ End If
+ End If
+ End If
+
+ 'POLIZA DE CANCELACION
+ If Not ErrorCancelar Then
+ If UsuarioActual.Empresa.UsaAC Then
+ IDPoliza = GenerarPolizaAC(ObjFactura, ObjAC, True)
+ If IDPoliza <= 0 Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al generar la poliza de cancelación."
+ End If
+ End If
+ End If
+
+ 'DESVINCULA REMISIONES PREDECESORAS
+ If Not ErrorCancelar Then
+ If ObjFactura.TipoDocto.Contiene("Ing", "Ant") AndAlso RevivirRemisiones Then
+ For Each Row As DataRow In DtRemisionesRelacionadas.Rows
+ Dim PuedeLiberar As Boolean = (ListaRemisionesCancelar Is Nothing) OrElse (Not ListaRemisionesCancelar.Any(Function(CveRemisionCancelar) CveRemisionCancelar = Row("CveVenta").ToString().ToEntero()))
+ If PuedeLiberar Then
+ If Not ObjVentas.LiberarRemisionesFacturadas(CveVenta, Row("CveVenta").ToString().ToEntero()) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al desvincular las remisiones."
+ End If
+ End If
+ Next
+ End If
+ End If
+
+ Else
+ 'MARCA LA VENTA PARA REALIZAR LA DEVOLUCION POSTERIORMENTE
+ If Not ErrorCancelar Then
+ If RealizarDevolucionAlmacen AndAlso CveAlmacenDevolucion > 0 Then
+ If Not ObjVentas.UpdateVentaRealizarDevolucion(CveVenta, RealizarDevolucionAlmacen, CveAlmacenDevolucion) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al marcar la venta para devolución"
+ End If
+ End If
+ End If
+
+ End If
+
+ Dim CveEstatusRefacturacion As Integer = 0
+ 'ACTUALIZA ESTATUS
+ If Not ErrorCancelar Then
+ Select Case ObjFactura.TipoDocto
+ Case "Rem"
+ CveEstatus = 12
+ Case "Com"
+ CveEstatus = 9
+ End Select
+ '0 Sin Refacturacion, 1 Refacturacion en Proceso, 3. Refacturación en proceso sin aceptación
+ If EsRefacturacion Then
+ If CveEstatus = 5 Then
+ CveEstatusRefacturacion = 3 ' refacturación en proceso sin autorización de cancelación
+ Else
+ CveEstatusRefacturacion = 1 ' refacturación en proceso con autorización de cancelación
+ End If
+ End If
+
+
+ If Not ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, CancelacionAcuse, CancelacionFecha, CveVenta, IDPoliza, CvePAC:=CvePACCancelacion, CveEstatusRefacturacion:=CveEstatusRefacturacion,
+ CveUsuarioCambiaEstatus:=UsuarioActual.CveUsuario, FechaCambioEstatus:=Now.ToString("yyyy-MM-dd hh:mm:ss.mmm")) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al guardar el estatus de cancelación."
+ End If
+
+ If CancelarRemisiones Then
+ If SeCancelaRemisionProceso Then
+ For Each CveRemisionCancelar In ListaRemisionesCancelar
+ If Not ObjVentas.AddRemisionesXCancelar(CveVenta, CveRemisionCancelar) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al guardar la remisión x cancelar."
+ End If
+ Next
+
+ If Not ObjVentas.UpdateCancelaRemision(CveVenta, SeCancelaRemisionProceso) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al actualizar que la remision sea cancelable."
+ End If
+
+ Else
+
+ For Each CveRemisionCancelar In ListaRemisionesCancelar
+ If Not ObjVentas.UpdateEstatusFactura(12, "", "", CancelacionFecha, CveRemisionCancelar) Then
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al guardar el estatus de cancelación de la remisión."
+ End If
+ Next
+
+ End If
+ End If
+
+ End If
+
+ Catch ex As Exception
+ ErrorCancelar = True
+ MensajeError = "Ocurrió un error al cancelar el documento"
+ OnError("Ocurrió un error al cancelar el documento", ex)
+ Finally
+ If Not ErrorCancelar Then
+ ObjVentas.Commit()
+ If ObjAC IsNot Nothing Then ObjAC.Commit()
+
+ If CveEstatus = 5 Then
+ Dim MensajeAlert As New StringBuilder
+ MensajeAlert.Append("El Documento se canceló correctamente.")
+ MensajeAlert.Append($" Imprimir Acuse")
+ MensajeAlert.Append(" ¿Desea enviar el Acuse de Cancelación al Cliente?")
+
+ Retorno.Mensaje = MensajeAlert.ToString
+ Retorno.HuboError = False
+ Retorno.TipoMensaje = TipoMensaje.MsgConfirmacion
+
+ Else
+ If Not EsRefacturacion Then
+ Retorno.Mensaje = "El documento se canceló exitosamente"
+ Retorno.HuboError = False
+ Retorno.TipoMensaje = TipoMensaje.MsgInformacion
+ End If
+ End If
+
+ Me.CveEstatus = CveEstatus
+ Else
+ ObjVentas.RollBack()
+ If ObjAC IsNot Nothing Then ObjAC.RollBack()
+
+ Retorno.Mensaje = MensajeError
+ Retorno.HuboError = True
+ Retorno.TipoMensaje = TipoMensaje.MsgError
+
+ End If
+
+ Retorno.CveEstatus = CveEstatus
+
+ ObjVentas.Dispose()
+ ObjBancos.Dispose()
+ ObjInventario.Dispose()
+ ObjContrato.Dispose()
+ ObjConta.Dispose()
+ If ObjAC IsNot Nothing Then ObjAC.Dispose()
+ End Try
+
+ Return Retorno
+ End Function
+ Private Function GeneraMovimientosEntregaPorAdelantadoRemision(CveMovimiento As Integer, ByRef ObjVentas As ClsVentas, ByRef ObjInventario As ClsInventarios, ByRef DtDevRem As DataTable, ByRef ListaRemisionesCancelar As List(Of Integer)) As Boolean
+ Dim ErrorCancelar As Boolean = False
+
+ Dim DtMovtosDev As New DataTable
+ Dim CveAlmacenTraspasoDestinoDevRem = -1
+
+ Dim CveVentaDetalleRem = -1
+ Dim CantidadDevolver As Decimal = 0
+ Dim CantidadRem As Decimal = 0
+ Dim CveMovimientoSalidaDevRem As Integer = 0
+ Dim FolioMovimientoSalidaDevRem As Integer = 0
+ Dim CveMovimientoEntradaDevRem As Integer = 0
+ Dim FolioMovimientoEntradaDevRem As Integer = 0
+
+ 'CARGA REMISIONES DE LA VENTA DEVUELTA
+ If ObjInventario.GetDevolucionRemisionesFacturadas(CveVenta) Then
+ DtDevRem = ObjInventario.DtResultados.FiltraParametros("CantidadAlmacen > 0")
+ Else
+ ErrorCancelar = True
+ End If
+
+ 'CARGA CONCEPTOS DEVUELTOS EN LA VENTA
+ If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
+ DtMovtosDev = ObjInventario.DtResultados
+ Else
+ ErrorCancelar = True
+ End If
+
+ If Not ErrorCancelar Then
+ If DtDevRem.Rows.Count > 0 And DtMovtosDev.Rows.Count > 0 Then
+
+ For Each DrMovtos As DataRow In DtDevRem.FiltraParametros("", "CveRem", {"CveRem", "CveAlmacenTraspasoDestino"}).Rows
+
+ 'CHECO SI NO SE VA A CANCELAR
+ Dim SeCancela As Boolean = (ListaRemisionesCancelar IsNot Nothing) AndAlso (ListaRemisionesCancelar.Any(Function(CveRemisionCancelar) CveRemisionCancelar = DrMovtos("CveRem").ToString.ToEntero()))
+
+ If Not SeCancela Then
+
+ CveAlmacenTraspasoDestinoDevRem = DrMovtos("CveAlmacenTraspasoDestino").ToString.ToEntero
+
+ If Not CveAlmacenTraspasoDestinoDevRem > 0 Then
+ ErrorCancelar = True
+ Exit For
+ End If
+
+ 'SALIDA GENERAL
+ CveMovimientoSalidaDevRem = ObjInventario.AddMovimiento(CveAlmacenDevolucion, 8, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, DrMovtos("CveRem").ToString.ToEntero, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=CveAlmacenTraspasoDestinoDevRem)
+ FolioMovimientoSalidaDevRem = ObjInventario.Folio
+
+ 'ENTRADA ADELANTADO
+ CveMovimientoEntradaDevRem = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestinoDevRem, 9, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, DrMovtos("CveRem").ToString.ToEntero, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimientoSalidaDevRem, CveAlmacenDestino:=CveAlmacenDevolucion)
+ FolioMovimientoEntradaDevRem = ObjInventario.Folio
+
+ If Not (CveMovimientoSalidaDevRem > 0 And CveMovimientoEntradaDevRem > 0) Then
+ ErrorCancelar = True
+ Exit For
+ End If
+
+ 'SALIDA POR TRAPASO DE GENERAL
+ For Each DrRem As DataRow In DtDevRem.FiltraParametros($"CveRem = {DrMovtos("CveRem")}").Rows
+ CveVentaDetalleRem = DrRem("CveVentaDetalleRem").ToString.ToEntero
+ CantidadRem = DrRem("CantidadFacturada").ToString.ToDecimal
+
+ If Not CveVentaDetalleRem > 0 Then
+ ErrorCancelar = True
+ Exit For
+ End If
+
+ For Each Dr As DataRow In DtMovtosDev.FiltraParametros($"CveVentaDetalle = {DrRem("CveVentaDetalle").ToString.ToEntero}").Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaDevRem, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=CveVentaDetalleRem, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then
+ ErrorCancelar = True
+ Exit For
+ End If
+ Next
+
+ If ErrorCancelar Then
+ Exit For
+ End If
+ Next
+
+ If ErrorCancelar Then
+ Exit For
+ End If
+
+ 'ENTRADA POR TRAPASO A ENTREGA POR ADELANTADO
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaDevRem, UsuarioActual.CveEmpresa) Then
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaDevRem, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then
+ ErrorCancelar = True
+ Exit For
+ End If
+ Next
+
+ If ErrorCancelar Then
+ Exit For
+ End If
+
+ Else
+ ErrorCancelar = True
+ Exit For
+ End If
+
+
+ If Not ObjVentas.UpdateVentasDevolucionAlmacen(0, DrMovtos("CveRem").ToString.ToEntero) Then
+ ErrorCancelar = True
+ Exit For
+ End If
+
+ End If
+
+ Next
+ End If
+ End If
+
+ Return Not ErrorCancelar
+ End Function
+
+ Private Function GeneraMovimientosApartados(ByRef ObjInventario As ClsInventarios, ByRef DtTraspasos As DataTable) As Boolean
+ Dim ErrorCancelar As Boolean = False
+ If Not ErrorCancelar Then
+ If ObjInventario.VentasAlmacenApartadosGet(CveVenta) Then
+
+ Dim DtTempApartados = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 9", "CveAlmacen")
+ Dim CveMovimientoSalidaApartado = -1
+ Dim CveAlmacenApartado = -1
+ Dim CveAlmacenOrigen = CveAlmacenDevolucion
+ Dim FolioSalida As Integer = 0, FolioEntrada = 0, CveMovimientoSalida = 0, CveMovimientoEntradaApartado = 0
+
+ For Each Dr As DataRow In DtTempApartados.Rows
+
+ If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString.ToEntero Then
+ CveMovimientoSalidaApartado = ObjInventario.AddMovimiento(CveAlmacenOrigen, 8, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveVendedor:=1, CveCliente:=CveCliente, CveAlmacenDestino:=Dr("CveAlmacen").ToString.ToEntero)
+ FolioSalida = ObjInventario.Folio
+ CveAlmacenApartado = Dr("CveAlmacen").ToString.ToEntero
+
+ Dim DrMovto = DtTraspasos.NewRow
+ DrMovto("Almacen") = Dr("Almacen").ToString.ToEntero
+ DrMovto("CveAlmacen") = Dr("CveAlmacen").ToString.ToEntero
+ DrMovto("CveMovimientoSalida") = CveMovimientoSalidaApartado
+ DrMovto("FolioSalida") = FolioSalida
+ DtTraspasos.Rows.Add(DrMovto)
+ End If
+
+ If Not CveMovimientoSalidaApartado > 0 Then
+ ErrorCancelar = True
+ Exit For
+ End If
+
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then
+ ErrorCancelar = True
+ Exit For
+ End If
+ Next
+
+ If Not ErrorCancelar Then
+ For Each Dr1 As DataRow In DtTraspasos.Rows
+ CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero
+
+ CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 9, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", CveAlmacenDestino:=CveAlmacenDevolucion, CveMovimientoRelacionado:=CveMovimientoSalida, Guia:="", CveContrato:=CveContrato, CveVendedor:=-1, CveCliente:=CveCliente)
+ FolioEntrada = ObjInventario.Folio
+
+ If Not CveMovimientoEntradaApartado > 0 Then
+ ErrorCancelar = True
+ Exit For
+ End If
+
+ Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado
+ Dr1("FolioEntrada") = FolioEntrada
+
+ If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
+ For Each Dr As DataRow In ObjInventario.DtResultados.Rows
+ If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then
+ ErrorCancelar = True
+ Exit For
+ End If
+ Next
+ End If
+
+ If ErrorCancelar Then Exit For
+ Next
+ End If
+ Else
+ ErrorCancelar = True
+ End If
+ End If
+
+ Return Not ErrorCancelar
+ End Function
+
+
+ Public Function CancelarDocumento() As MMensajeFactura
+ Dim Retorno As New MMensajeFactura()
+
+ CancelarVenta(Me, UsuarioActual)
+
+ Return Retorno
End Function
Protected Function CancelarFactura(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjAC As ClsContPAQi, ByRef ObjBancos As ClsBancos) As Boolean
@@ -3800,11 +4557,11 @@ Namespace Modelos
If ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscal, Total, RFCReceptor, UsuarioActual.Empresa.RFC) Then
'falta verificar traer el acuse y reenviarlo
If UsuarioActual.Empresa.UsaAC Then
- 'IDPoliza = GenerarPolizaAC(ObjAC, True)
- 'If IDPoliza <= 0 Then
- ' Mensaje = "No se pudo generar la poliza"
- ' ErrorCancelar = True
- 'End If
+ IDPoliza = GenerarPolizaAC(Me, ObjAC, True)
+ If IDPoliza <= 0 Then
+ Mensaje = "No se pudo generar la poliza"
+ ErrorCancelar = True
+ End If
End If
If Not ErrorCancelar Then
@@ -3835,168 +4592,117 @@ Namespace Modelos
End If
Return ProcesoCorrecto
- End Function
-
+ End Function
+ Private Function GenerarPolizaAC(ObjFactura As Modelos.Factura, ObjAC As ClsContPAQi, Optional CancelacionIngreso As Boolean = False) As Integer
+ Dim Retorno As Integer = 0
+ Dim IDPoliza As Integer = 0
+
+ Dim ErrorAC As Boolean = False
+ 'Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL()
+ Dim Fecha As Date = ObjFactura.Fecha
+ Dim Concepto As String = String.Format("GD {0}", ObjFactura.Cliente.Nombre)
+ Dim Paridad As Integer = 1
+ Dim TipoMovto As Boolean = False
+
+ If CancelacionIngreso Then
+ Concepto = String.Format("Cancelación GD {0}", ObjFactura.Cliente.Nombre)
+ Paridad = -1
+ TipoMovto = True
+ End If
+
+ Dim TipoPoliza = If(ObjFactura.TipoDocto = "OP" Or ObjFactura.TipoDocto = "Com", 3, 1)
+
+ IDPoliza = ObjAC.AddPoliza(TipoPoliza, Concepto, ObjFactura.Total * 2, ObjFactura.Total * 2, UsuarioActual.CveUsuario, Fecha)
+ Dim dr As DataRow
+
+ Dim CtaCliente As Integer = ObjFactura.Cliente.IdCtaContClientes
+ Dim CtaISSSTESON As Integer = 643
+ Dim CtaISPT As Integer = 1745
+
+
+ If IDPoliza > 0 Then
+
+ 'Orden de PAGO
+ If ObjFactura.TipoDocto = "OP" Then
+ 'ORDEN DE PAGO
+ If ObjFactura.Num3 = 1 Then
+ 'ISSSTESON
+
+ If ObjAC.AddMovimiento(IDPoliza, CtaCliente, False, Paridad * ObjFactura.Total, "", Concepto, 0, Fecha, "") Then
+ If Not ObjAC.AddMovimiento(IDPoliza, CtaISSSTESON, True, Paridad * ObjFactura.Total, "", Concepto, 0, Fecha, "") Then
+ ErrorAC = True
+ End If
+ Else
+ ErrorAC = True
+ End If
+
+ Else
+ 'ISPT
+
+ If ObjAC.AddMovimiento(IDPoliza, CtaCliente, False, Paridad * ObjFactura.Total, "", Concepto, 0, Fecha, "") Then
+ If Not ObjAC.AddMovimiento(IDPoliza, CtaISPT, True, Paridad * ObjFactura.Total, "", Concepto, 0, Fecha, "") Then
+ ErrorAC = True
+ End If
+ Else
+ ErrorAC = True
+ End If
+ End If
+
+ ' NORMAL
+ Else
+ Dim DTPresupuestoIngresos As New DataTable
+ Dim AC As New ClsAC
+ If AC.GetPresupuestoIngresos(-1, Now.Year, True, UsuarioActual.CveEmpresa) Then
+ DTPresupuestoIngresos = AC.DtResultados.Copy()
+ End If
+ AC.Dispose()
+
+ For Each grp As DataRow In DtDetalleAC.Rows
+ dr = DTPresupuestoIngresos.FiltroPrimero(String.Format("CvePresupuestoIngreso = {0}", grp("CvePresupuestoIngreso")))
+ Concepto = String.Format("{0} - {1}: {2}", ObjFactura.Cliente.Nombre, ObjFactura.TipoDocumento, ObjFactura.Folio)
+
+ If ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaPorEjecutar").ToString.ToEntero, False, Paridad * grp("TotalImporte").ToString().ToDouble(), "", Concepto, 0, Fecha, "") Then
+ If ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, Paridad * grp("TotalImporte").ToString().ToDouble(), "", Concepto, 0, Fecha, "") Then
+ 'CARGO la deuda del cliente
+ If ObjAC.AddMovimiento(IDPoliza, CtaCliente, TipoMovto, grp("TotalImporte").ToString().ToDouble(), "", Concepto, 0, Fecha, "") Then
+ 'abono,
+ If Not ObjAC.AddMovimiento(IDPoliza, dr("IdCuentaMatriz").ToString.ToEntero, Not TipoMovto, grp("TotalImporte").ToString().ToDouble(), "", Concepto, 0, Fecha, "") Then
+ ErrorAC = True
+ End If
+ Else
+ ErrorAC = True
+ End If
+ Else
+ ErrorAC = True
+ End If
+ Else
+ ErrorAC = True
+ End If
+ Next
+ End If
+
+ Else
+ ErrorAC = True
+ End If
+
+ If Not ErrorAC Then
+ ObjAC.AjustaPoliza(IDPoliza)
+
+ Retorno = IDPoliza
+ Else
+ Retorno = -1
+ 'Alert("Error al Agregar la Póliza de AC.", TipoMensaje.MsgError)
+ End If
+
+ Return Retorno
+
+ End Function
+
#End Region
-
-
-#Region "Claves"
-
- Public Property CveVenta As Integer
- Public Property CveEmpresa As Integer
- Public Property CveSucursal As Integer 'sucursal de la empresa que factura
- Public Property CveSubProyecto As Integer
- Public Property CveAlmacenRecepcionUsados As Integer = -1
- Public Property CveDireccionEnvio As Integer
- Public Property RefacturacionGeneroNC As Boolean = False
- 'Public Property Sucursal As SucursalModel
- Public Property SubProyecto As Modelos.SubProyectoModel
-
- Public DtDetalle As Data.DataTable
- Public DtAjustes As Data.DataTable
- Public DtRecepcionUsados As Data.DataTable
- Public DtVentasNC As Data.DataTable
- Public DtDeduccion As Data.DataTable
- Public DtFirmas As Data.DataTable
- Public DtDesgloseImpuestos As Data.DataTable
- Public DtDocumentosRelacionados As Data.DataTable
- Public DtNCVinculadas As Data.DataTable
-
- Public DtAnticipos As Data.DataTable
- Public DtPromociones As Data.DataTable
- Public DtImpuestosLocales As Data.DataTable
- Public DtPagos As Data.DataTable
- Public DtRemisionesPS As Data.DataTable
- Public DtRemisiones As Data.DataTable
- Public DtPedidos2 As Data.DataTable
- Public DtPedidos2PS As Data.DataTable
- Public DTOrdenesCompraPS As Data.DataTable
- Public DtCotizacionesPS As Data.DataTable
- Public DtDocumentacionCliente As Data.DataTable
- Public DtContratosSerieDetalle As Data.DataTable
- Public DtOtrosConceptos As Data.DataTable
- Public DtInventario As Data.DataTable
- Public DtRemConceptosSurtidos As Data.DataTable
- Public Property UsadosBonificacion As List(Of Integer)
- Public Property TipoBonificacion As Integer = 0
- Public Property Timbre As CFDITimbre
- Public Property CveCliente As Integer
- Public Property Cliente As Modelos.ClienteModel
- Public Property SubProyectoMatriz As Modelos.SubProyectoModel
-
- Public Sub SetSubProyecto()
- If CveSubProyecto > 0 Then
- SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}"))
- End If
- End Sub
- Public Sub SetSubProyectoMatriz()
- Dim Row As Data.DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1")
- If Not IsNothing(Row) Then
- SubProyectoMatriz = New Modelos.SubProyectoModel(Row)
- End If
- End Sub
- Public Sub SetCliente()
- If CveCliente > 0 Then
- Cliente = New Modelos.ClienteModel(CveCliente, CveEmpresa)
- End If
- End Sub
- Public Sub SetMoneda()
- If CveMoneda > 0 Then
- Dim dr As DataRow = GlobalDTMonedas.FiltroPrimero(String.Format("CveMoneda ={0}", CveMoneda))
- If Not IsNothing(dr) Then
- Moneda = dr("Moneda").ToString()
- MonedaSAT = dr("AbreviaturaSAT").ToString()
- MonedaAbreviatura = dr("Abreviatura").ToString()
- End If
- End If
- End Sub
- Public Sub SetMetodoPago()
- If CveMetodoPago > 0 AndAlso Not IsNothing(GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))) Then
- MetodoPago = GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("MetodoPago").ToString()
- ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("ClaveSAT").ToString()
- End If
- End Sub
- Public Sub SetMoneda(ObjClsPaginas As ClsPaginas)
- If Not IsNothing(ObjClsPaginas) Then
- Dim dr As DataRow = ObjClsPaginas.GlobalDTMonedas.FiltroPrimero(String.Format("CveMoneda ={0}", CveMoneda))
- If Not IsNothing(dr) Then
- Moneda = dr("Moneda").ToString()
- MonedaSAT = dr("AbreviaturaSAT").ToString()
- MonedaAbreviatura = dr("Abreviatura").ToString()
- End If
- End If
- End Sub
- Public Sub SetMetodoPago(ObjClsPaginas As ClsPaginas)
- If Not IsNothing(ObjClsPaginas) Then
- If Not IsNothing(ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))) Then
- MetodoPago = ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("MetodoPago").ToString()
- ClaveMetodoPagoSAT = ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("ClaveSAT").ToString()
- End If
- End If
- End Sub
- Public Sub SetSubProyecto(obj As ClsPaginas)
- If CveSubProyecto > 0 AndAlso Not IsNothing(obj) Then
- SubProyecto = New Modelos.SubProyectoModel(obj.GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}"))
- End If
- End Sub
- Public Sub SetSubProyectoMatriz(obj As ClsPaginas)
- If Not IsNothing(obj) Then
- Dim Row As Data.DataRow = obj.GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=obj.UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1")
- If Not IsNothing(Row) Then
- SubProyectoMatriz = New Modelos.SubProyectoModel(Row)
- End If
- End If
- End Sub
-
- Public Property CveClienteSucursal As Integer
- Public Property ClienteSucursal As Modelos.SucursalModel
- Public Property EnviarA As Modelos.EnviarAModel
- Public Property NumeroContrato As String
- Public Property PedidoContrato As String
- Public Property OrdenCompra As String = "-1"
- Public Property CveMetodoPago As Integer
- Public Property MetodoPago As String
- Public Property ClaveMetodoPagoSAT As String
- Public Property CveMetodoPago33 As Integer
- Public Property MetodoPago33 As String
- Public Property CveFormaPago33 As Integer
- Public Property MetodoPagoSAT33 As String
- Public Property FormaPago33 As String
- Public Property FormaPagoSAT33 As String
- Public Property UsoCFDI As String = ""
- Public Property CveUsoCFDI As Integer
- Public Property ClaveUsoCFDI As String = ""
- Public Property CveTipoRelacion As Integer = -1
- Public Property CveEstatusFactura As Integer
- Public Property CveVendedor As Integer
- Public Property VendedorCodigo As String
- Public Property CveSucursalEjecucion As Integer
- Public Property FechaEjecucion As Date
- Public Property CveSucursalCobranza As Integer
-
- Public Property CveSubProyectoCobranza As Integer
- Public Property CveSubProyectoEjecucion As Integer
- Public Property CveOS As Integer
- Public Property CveContrato As Integer
- Public Property CveVentaPadre As Integer
- Public Property CvePrePoliza As Integer
- Public Property Entrega As String
- Public Property TiempoEntrega As String
- Public Property Vigencia As Date
- Public Property TipoEstatus As Integer
- Public Property CveCondicionEntrega As Integer
- Public Property CondicionEntrega As String
-
- Public Property TipoRelacion As String
- Public Property UUIDRelacionados As List(Of String)
-
-
- Public Property CveVentaRelacion As Integer = -1
- Public Property ImporteRelacion As Decimal
-
-
-#End Region
- 'Ventas
+
+
+#Region "P R O P I E D A D E S"
+
Public Property NuevaFactura As Integer
Public Property EnviarCorreo As Boolean = False
Public Property ErrorList As List(Of String)
@@ -4041,10 +4747,55 @@ Namespace Modelos
Public Property CvePSAmortizacion As Integer
Public Property SaldoVentaDevolucion As Decimal
Public Property Saldo As Decimal
+ Public Property SaldoAlmacen As Decimal
+ Public Property CvePAC As Integer
Public Property CveAnticipo As Integer
Public Property RemisionesLista As List(Of Integer)
Public Property CveAlmacen As Integer
+ Public Property CveAlmacenDevolucion As Integer
+ Public Property CveVenta As Integer
+ Public Property CveEmpresa As Integer
+ Public Property CveSucursal As Integer 'sucursal de la empresa que factura
+ Public Property CveSubProyecto As Integer
+ Public Property CveAlmacenRecepcionUsados As Integer = -1
+ Public Property CveDireccionEnvio As Integer
+ Public Property RefacturacionGeneroNC As Boolean = False
+ Public Property Pagado As Decimal
+ 'Public Property Sucursal As SucursalModel
+ Public Property SubProyecto As Modelos.SubProyectoModel
+ Public DtDetalle As Data.DataTable
+ Public DtDetalleAC As Data.DataTable
+ Public DtAjustes As Data.DataTable
+ Public DtRecepcionUsados As Data.DataTable
+ Public DtVentasNC As Data.DataTable
+ Public DtDeduccion As Data.DataTable
+ Public DtFirmas As Data.DataTable
+ Public DtDesgloseImpuestos As Data.DataTable
+ Public DtDocumentosRelacionados As Data.DataTable
+ Public DtNCVinculadas As Data.DataTable
+
+ Public DtAnticipos As Data.DataTable
+ Public DtPromociones As Data.DataTable
+ Public DtImpuestosLocales As Data.DataTable
+ Public DtPagos As Data.DataTable
+ Public DtRemisionesPS As Data.DataTable
+ Public DtRemisiones As Data.DataTable
+ Public DtPedidos2 As Data.DataTable
+ Public DtPedidos2PS As Data.DataTable
+ Public DTOrdenesCompraPS As Data.DataTable
+ Public DtCotizacionesPS As Data.DataTable
+ Public DtDocumentacionCliente As Data.DataTable
+ Public DtContratosSerieDetalle As Data.DataTable
+ Public DtOtrosConceptos As Data.DataTable
+ Public DtInventario As Data.DataTable
+ Public DtRemConceptosSurtidos As Data.DataTable
+ Public Property UsadosBonificacion As List(Of Integer)
+ Public Property TipoBonificacion As Integer = 0
+ Public Property Timbre As CFDITimbre
+ Public Property CveCliente As Integer
+ Public Property Cliente As Modelos.ClienteModel
+ Public Property SubProyectoMatriz As Modelos.SubProyectoModel
'CFDi
Public Property Version As String
@@ -4071,7 +4822,8 @@ Namespace Modelos
Public Property SeTimbro As String
Public Property TipoDocto As String
Public Property RefDocto As String
-
+ Public Property RealizarDevolucionAlmacen As Boolean
+ Public Property CveAlmacenDevolucionVenta As Integer
Public Property TipoDocumento As String
@@ -4205,9 +4957,9 @@ Namespace Modelos
End Get
End Property
- Public Property MotivoDescuento As String
-
-
+ Public Property MotivoDescuento As String
+
+
#Region "Totales"
Public Property SubTotal As Decimal
Public Property Descuento As Decimal
@@ -4220,10 +4972,10 @@ Namespace Modelos
Public Property IEPS As Decimal
Public Property Total As Decimal
- Public Property Otros As Decimal
-
+ Public Property Otros As Decimal
+
#Region "Totales por Tipo de cambio"
-
+
Public ReadOnly Property SubTotalTC As Decimal
Get
If ConvertirPesos Then
@@ -4305,7 +5057,7 @@ Namespace Modelos
Return Otros
End If
End Get
- End Property
+ End Property
#End Region
#End Region
Public Property AtencionA As String
@@ -4354,10 +5106,124 @@ Namespace Modelos
Public Property ComplementoINE As Modelos.ComplementoINE
Public Property FordGSDB As String = ""
Public Property FordASN As String = ""
- Public Property FemsaFactura As Modelos.FemsaFactura
+ Public Property FemsaFactura As Modelos.FemsaFactura
+
+ Public Sub SetSubProyecto()
+ If CveSubProyecto > 0 Then
+ SubProyecto = New Modelos.SubProyectoModel(GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}"))
+ End If
+ End Sub
+ Public Sub SetSubProyectoMatriz()
+ Dim Row As Data.DataRow = GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1")
+ If Not IsNothing(Row) Then
+ SubProyectoMatriz = New Modelos.SubProyectoModel(Row)
+ End If
+ End Sub
+ Public Sub SetCliente()
+ If CveCliente > 0 Then
+ Cliente = New Modelos.ClienteModel(CveCliente, CveEmpresa)
+ End If
+ End Sub
+ Public Sub SetMoneda()
+ If CveMoneda > 0 Then
+ Dim dr As DataRow = GlobalDTMonedas.FiltroPrimero(String.Format("CveMoneda ={0}", CveMoneda))
+ If Not IsNothing(dr) Then
+ Moneda = dr("Moneda").ToString()
+ MonedaSAT = dr("AbreviaturaSAT").ToString()
+ MonedaAbreviatura = dr("Abreviatura").ToString()
+ End If
+ End If
+ End Sub
+ Public Sub SetMetodoPago()
+ If CveMetodoPago > 0 AndAlso Not IsNothing(GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))) Then
+ MetodoPago = GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("MetodoPago").ToString()
+ ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("ClaveSAT").ToString()
+ End If
+ End Sub
+ Public Sub SetMoneda(ObjClsPaginas As ClsPaginas)
+ If Not IsNothing(ObjClsPaginas) Then
+ Dim dr As DataRow = ObjClsPaginas.GlobalDTMonedas.FiltroPrimero(String.Format("CveMoneda ={0}", CveMoneda))
+ If Not IsNothing(dr) Then
+ Moneda = dr("Moneda").ToString()
+ MonedaSAT = dr("AbreviaturaSAT").ToString()
+ MonedaAbreviatura = dr("Abreviatura").ToString()
+ End If
+ End If
+ End Sub
+ Public Sub SetMetodoPago(ObjClsPaginas As ClsPaginas)
+ If Not IsNothing(ObjClsPaginas) Then
+ If Not IsNothing(ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))) Then
+ MetodoPago = ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("MetodoPago").ToString()
+ ClaveMetodoPagoSAT = ObjClsPaginas.GlobalDTMetodosPago.FiltroPrimero(String.Format(" CveMetodoPago ={0}", CveMetodoPago))("ClaveSAT").ToString()
+ End If
+ End If
+ End Sub
+ Public Sub SetSubProyecto(obj As ClsPaginas)
+ If CveSubProyecto > 0 AndAlso Not IsNothing(obj) Then
+ SubProyecto = New Modelos.SubProyectoModel(obj.GlobalDTSubProyectos(-1).FiltroPrimero($"CveSubProyecto = {CveSubProyecto}"))
+ End If
+ End Sub
+ Public Sub SetSubProyectoMatriz(obj As ClsPaginas)
+ If Not IsNothing(obj) Then
+ Dim Row As Data.DataRow = obj.GlobalDTSubProyectos(-1, CveSubProyecto:=-1, CveEmpresa:=obj.UsuarioActual.CveEmpresa).FiltroPrimero("TipoSucursal=1")
+ If Not IsNothing(Row) Then
+ SubProyectoMatriz = New Modelos.SubProyectoModel(Row)
+ End If
+ End If
+ End Sub
+ Public Property CveClienteSucursal As Integer
+ Public Property ClienteSucursal As Modelos.SucursalModel
+ Public Property EnviarA As Modelos.EnviarAModel
+ Public Property NumeroContrato As String
+ Public Property PedidoContrato As String
+ Public Property OrdenCompra As String = "-1"
+ Public Property CveMetodoPago As Integer
+ Public Property MetodoPago As String
+ Public Property ClaveMetodoPagoSAT As String
+ Public Property CveMetodoPago33 As Integer
+ Public Property MetodoPago33 As String
+ Public Property CveFormaPago33 As Integer
+ Public Property MetodoPagoSAT33 As String
+ Public Property FormaPago33 As String
+ Public Property FormaPagoSAT33 As String
+ Public Property UsoCFDI As String = ""
+ Public Property CveUsoCFDI As Integer
+ Public Property ClaveUsoCFDI As String = ""
+ Public Property CveTipoRelacion As Integer = -1
+ Public Property CveEstatusFactura As Integer
+ Public Property CveVendedor As Integer
+ Public Property VendedorCodigo As String
+ Public Property CveSucursalEjecucion As Integer
+ Public Property FechaEjecucion As Date
+ Public Property CveSucursalCobranza As Integer
+
+ Public Property CveSubProyectoCobranza As Integer
+ Public Property CveSubProyectoEjecucion As Integer
+ Public Property CveOS As Integer
+ Public Property CveContrato As Integer
+ Public Property CveVentaPadre As Integer
+ Public Property CvePrePoliza As Integer
+ Public Property Entrega As String
+ Public Property TiempoEntrega As String
+ Public Property Vigencia As Date
+ Public Property TipoEstatus As Integer
+ Public Property CveCondicionEntrega As Integer
+ Public Property CondicionEntrega As String
+
+ Public Property TipoRelacion As String
+ Public Property UUIDRelacionados As List(Of String)
+
+
+ Public Property CveVentaRelacion As Integer = -1
+ Public Property ImporteRelacion As Decimal
+
+
+#End Region
+
+
#Region "IDisposable Support"
- 'Atributos de la clase
+ 'Atributos de la clase
Private disposedValue As Boolean = False
' IDisposable
@@ -4398,9 +5264,9 @@ Namespace Modelos
' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
- End Sub
+ End Sub
#End Region
-
+
#Region "G L O B A L - D T"
Public Property GlobalTipoCambio(Optional Fecha As Date = MinFecha) As Double
Get
@@ -4585,10 +5451,10 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTPSATPS") = value
End Set
- End Property
-
+ End Property
+
#Region "GLOBALES DE SAT COMERCIO EXTERIOR"
-
+
Property GlobalDTClavePedimento() As DataTable
Get
GlobalDTClavePedimento = DirectCast(HttpContext.Current.Application("GlobalDTClavePedimento"), DataTable)
@@ -4698,10 +5564,10 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTColonia") = value
End Set
- End Property
-
+ End Property
+
#End Region
-
+
Property GlobalDTPSATUM() As DataTable
Get
GlobalDTPSATUM = DirectCast(HttpContext.Current.Application("GlobalDTPSATUM"), DataTable)
@@ -5886,9 +6752,9 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTVtaCobranzaEstatus") = value
End Set
- End Property
-
-
+ End Property
+
+
#Region "***********************************************************************DT EVENTOS****************************************************************************************"
Property GlobalDTTiposEventos() As DataTable
Get
@@ -5924,9 +6790,9 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTOIEstatusEventos") = value
End Set
- End Property
+ End Property
#End Region
-
+
#Region " **********************************************************************DT PROSPECTOS*************************************************************************************"
Property GlobalDTProspectosCaracteristicasClasificaciones() As DataTable
Get
@@ -5967,9 +6833,9 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTProspectosCaracteristicasOpciones") = value
End Set
- End Property
+ End Property
#End Region
-
+
#Region "***********************************************************************DT ACTIVOS FIJOS**********************************************************************************"
Property GlobalDTActivoFijos(CveEmpresa As Integer, Optional CveSubTipoActivoFijo As Integer = -1, Optional CveActivoFijo As Integer = -1) As DataTable
Get
@@ -6062,10 +6928,10 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTTipoActivoFijo") = value
End Set
- End Property
-
+ End Property
+
#End Region
-
+
#Region "***********************************************************************DT GENERALES**************************************************************************************"
Property GlobalDTGralPaises() As DataTable
Get
@@ -6153,10 +7019,10 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTGralColectivas") = value
End Set
- End Property
-
+ End Property
+
#End Region
-
+
#Region "***********************************************************************DT PROSPECTOS*************************************************************************************"
Property GlobalDTProspectosSupervisores(CveEmpresa As Integer) As DataTable
Get
@@ -6365,8 +7231,8 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTProspectosTipos") = value
End Set
- End Property
-
+ End Property
+
#Region " DT PROSPECTOS SOLICITUDES"
Property GlobalDTProspectosSolicitudes(CveEmpresa As Integer) As DataTable
Get
@@ -6433,15 +7299,15 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTProspectosSolicitudesApoyos") = value
End Set
- End Property
-
+ End Property
+
#End Region
#End Region
-
+
#Region "**********************************************DT AMORTIZACIÓN CONTABLE PLAN DE DESARROLLO********************************************************************************"
-
+
#Region "***********************************************************************DT AMORTIZACIÓN CONTABLE*********************************************************************************************"
-
+
Property GlobalDTAC_RubrosIngreso() As DataTable
Get
GlobalDTAC_RubrosIngreso = DirectCast(HttpContext.Current.Application("GlobalDTAC_RubrosIngreso"), DataTable)
@@ -6697,11 +7563,11 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTAC_MatrizEgresos") = value
End Set
- End Property
-
-
+ End Property
+
+
#End Region
-
+
Property GlobalDTAC_PD_EjeRector(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
@@ -6780,9 +7646,9 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTAC_PD_Metas") = value
End Set
- End Property
+ End Property
#End Region
-
+
#Region "***********************************************************************GLOBAL DT ORDENES DE COMPRA***********************************************************************"
Property GlobalDTOCEstatus(CveEmpresa As Integer) As DataTable
Get
@@ -6819,11 +7685,11 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTOCEstatusUsuarios") = value
End Set
- End Property
-
-
+ End Property
+
+
#End Region
-
+
#Region "F I N A N Z A S "
Property GlobalDTFinan_RazonesFinancieras() As DataTable
Get
@@ -6832,10 +7698,10 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTFinan_RazonesFinancieras") = value
End Set
- End Property
+ End Property
#End Region
-
-
+
+
#Region "***********************************************************************GLOBAL DT CONTABILIDAD****************************************************************************"
Property GlobalDTContaPlantillasPolizas(CveEmpresa As Integer, Optional TipoPlantilla As Integer = -1) As DataTable
Get
@@ -6889,9 +7755,9 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTContaConceptosContables") = value
End Set
- End Property
+ End Property
#End Region
-
+
#Region "**********************************************************************GLOBAL DT RH (RECURSOS HUMANOS)********************************************************************"
Property GlobalDTAsistenciaDetalle() As DataTable
Get
@@ -7043,13 +7909,13 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTTipoBuzon") = value
End Set
- End Property
+ End Property
#End Region
-
+
#Region "*********** D T - C O M B U S T I B L E S ***********"
-
-
-
+
+
+
Property GlobalDTCombustibles(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
@@ -7088,11 +7954,11 @@ Namespace Modelos
Set(ByVal value As DataTable)
HttpContext.Current.Application("GlobalDTCombustiblesTipos") = value
End Set
- End Property
+ End Property
#End Region
-
+
#Region "*********** D T - M A N T E N I M I E N T O S ***********"
-
+
Property GlobalDTMantenimientosTipos() As DataTable
Get
GlobalDTMantenimientosTipos = DirectCast(HttpContext.Current.Application("GlobalDTMantenimientosTipos"), DataTable)
@@ -7131,13 +7997,13 @@ Namespace Modelos
HttpContext.Current.Application("GlobalDTMantenimientosTipos") = value
End Set
- End Property
-
+ End Property
+
#End Region
-
-
+
+
#Region "*********** D T - T A L L E R E S ***********"
-
+
Property GlobalDTTalleresTipos() As DataTable
Get
GlobalDTTalleresTipos = DirectCast(HttpContext.Current.Application("GlobalDTTalleresTipos"), DataTable)
@@ -7154,12 +8020,12 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTTalleres") = value
End Set
- End Property
-
+ End Property
+
#End Region
-
+
#Region "*********** D T - D I S T R I B U I D O R E S ***********"
-
+
Property GlobalDTDistribuidoresTipos() As DataTable
Get
GlobalDTDistribuidoresTipos = DirectCast(HttpContext.Current.Application("GlobalDTDistribuidoresTipos"), DataTable)
@@ -7176,11 +8042,11 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTDistribuidores") = value
End Set
- End Property
-
+ End Property
+
#End Region
-
-
+
+
Property GlobalDTOIRevision(CveEmpresa As Integer) As DataTable
Get
If CveEmpresa <> -1 Then
@@ -7242,27 +8108,27 @@ Namespace Modelos
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTPaqueteriaGuiaTipos") = value
End Set
- End Property
+ End Property
Property GlobalDTClasificacionPorcentaje(CveEmpresa As Integer, Optional CveClasicacionPorcentaje As Integer = -1, Optional CveClasicacion As Integer = -1,
- Optional PorcentajeIVA As Double = -1) As DataTable
-
- Get
- Dim Str As StringBuilder = New StringBuilder()
- If CveEmpresa <> -1 Or CveClasicacionPorcentaje <> -1 Or CveClasicacion <> -1 Or PorcentajeIVA <> -1 Then
- If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa)
- If CveClasicacionPorcentaje <> -1 Then Str.AppendFormat(" {0} CveClasicacionPorcentaje = {1}", If(Str.Length > 0, "AND", ""), CveClasicacionPorcentaje)
- If CveClasicacion <> -1 Then Str.AppendFormat(" {0} CveClasicacion = {1}", If(Str.Length > 0, "AND", ""), CveClasicacion)
- If PorcentajeIVA <> -1 Then Str.AppendFormat(" {0} PorcentajeIVA = {1}", If(Str.Length > 0, "AND", ""), PorcentajeIVA)
- Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificacionPorcentaje"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows)
- GlobalDTClasificacionPorcentaje = Dv.ToTable
- Dv.Dispose()
- Else
- GlobalDTClasificacionPorcentaje = DirectCast(HttpContext.Current.Application("GlobalDTClasificacionPorcentaje"), DataTable)
- End If
- End Get
- Set(value As DataTable)
- HttpContext.Current.Application("GlobalDTClasificacionPorcentaje") = value
- End Set
+ Optional PorcentajeIVA As Double = -1) As DataTable
+
+ Get
+ Dim Str As StringBuilder = New StringBuilder()
+ If CveEmpresa <> -1 Or CveClasicacionPorcentaje <> -1 Or CveClasicacion <> -1 Or PorcentajeIVA <> -1 Then
+ If CveEmpresa <> -1 Then Str.AppendFormat("CveEmpresa = {0}", CveEmpresa)
+ If CveClasicacionPorcentaje <> -1 Then Str.AppendFormat(" {0} CveClasicacionPorcentaje = {1}", If(Str.Length > 0, "AND", ""), CveClasicacionPorcentaje)
+ If CveClasicacion <> -1 Then Str.AppendFormat(" {0} CveClasicacion = {1}", If(Str.Length > 0, "AND", ""), CveClasicacion)
+ If PorcentajeIVA <> -1 Then Str.AppendFormat(" {0} PorcentajeIVA = {1}", If(Str.Length > 0, "AND", ""), PorcentajeIVA)
+ Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTClasificacionPorcentaje"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows)
+ GlobalDTClasificacionPorcentaje = Dv.ToTable
+ Dv.Dispose()
+ Else
+ GlobalDTClasificacionPorcentaje = DirectCast(HttpContext.Current.Application("GlobalDTClasificacionPorcentaje"), DataTable)
+ End If
+ End Get
+ Set(value As DataTable)
+ HttpContext.Current.Application("GlobalDTClasificacionPorcentaje") = value
+ End Set
End Property
Property GlobalDTPaqueterias() As DataTable
Get
@@ -7274,9 +8140,9 @@ Namespace Modelos
End Property
Public Property CveContratoSecciones As String
- Public Property CveEstatus As Integer
+ Public Property CveEstatus As Integer
#End Region
-
+
End Class
@@ -7294,7 +8160,7 @@ Namespace Modelos
MyBase.New()
End Sub
Public Sub New(Row As System.Data.DataRow)
- SetValues(Row)
+ setValues(Row)
End Sub
Public Property AplicaFEMSA As Boolean = False 'AplicaFEMSA
@@ -7341,7 +8207,7 @@ Namespace Modelos
End Sub
Public Sub New(Row As System.Data.DataRow)
SetDefaultValues()
- SetValues(Row)
+ setValues(Row)
End Sub
Public ReadOnly Property LugarExp As String
@@ -7468,13 +8334,13 @@ Namespace Modelos
End Sub
Public Sub New(Row As Data.DataRow)
SetDefaultValues()
- SetValues(Row)
+ setValues(Row)
End Sub
Public Sub New(CveCliente As Integer, CveEmpresa As Integer)
SetDefaultValues()
Dim ObjCliente As New ClsClientes()
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa, -1, TipoCliente:=-1) AndAlso ObjCliente.DtResultados.Rows.Count > 0 Then
- SetValues(ObjCliente.DtResultados.Rows(0))
+ setValues(ObjCliente.DtResultados.Rows(0))
End If
ObjCliente.Dispose()
End Sub
@@ -7581,7 +8447,7 @@ Namespace Modelos
End Sub
Public Sub New(Row As System.Data.DataRow)
SetDefaultValues()
- SetValues(Row)
+ setValues(Row)
End Sub
Public ReadOnly Property LugarExp As String
@@ -7602,12 +8468,12 @@ Namespace Modelos
Public Property EnvioPedidoContrato As String
Public Property EnvioCP As String
Public Property EnvioTel As String
- End Class
-
+ End Class
+
#End Region
-
+
#Region "Personal"
-
+
Public Class RH_PersonalRequerido
Public Sub New()
CveRequerimiento = -1
@@ -7631,11 +8497,11 @@ Namespace Modelos
Public Property Usuario As String
Public Property CveEmpresa As Integer
- End Class
+ End Class
#End Region
-
+
#Region "E FACTURAS"
- Public Class eFactura
+ Public Class eFactura
#Region "Propiedades"
Public Property CveEmpresa() As Integer
Get
@@ -7911,326 +8777,326 @@ Namespace Modelos
m_DirectorioTemporal = Value
End Set
End Property
- Private m_DirectorioTemporal As String
+ Private m_DirectorioTemporal As String
#End Region
- End Class
-
-
- ' Public Class ClsValidaCFDi
- ' Implements IDisposable
-
- '#Region "Campos"
- ' 'Campos
- ' Private LFolioFiscal As String
- ' Private LRFCEmisor As String
- ' Private LRFCReceptor As String
- ' ' Para detectar llamadas redundantes
- ' Private disposedValue As Boolean = False
- '#End Region
-
- '#Region "Propiedades"
- ' 'Propiedades
- ' Public Property EsValida() As Integer
- ' Get
- ' Return m_EsValida
- ' End Get
- ' Set
- ' m_EsValida = Value
- ' End Set
- ' End Property
- ' Private m_EsValida As Integer
- ' Public Property Efecto() As String
- ' Get
- ' Return m_Efecto
- ' End Get
- ' Set
- ' m_Efecto = Value
- ' End Set
- ' End Property
- ' Private m_Efecto As String
- ' Public Property FechaEmision() As String
- ' Get
- ' Return m_FechaEmision
- ' End Get
- ' Set
- ' m_FechaEmision = Value
- ' End Set
- ' End Property
- ' Private m_FechaEmision As String
- ' Public Property FolioFiscal() As String
- ' Get
- ' Return m_FolioFiscal
- ' End Get
- ' Set
- ' m_FolioFiscal = Value
- ' End Set
- ' End Property
- ' Private m_FolioFiscal As String
- ' Public Property Estado() As String
- ' Get
- ' Return m_Estado
- ' End Get
- ' Set
- ' m_Estado = Value
- ' End Set
- ' End Property
- ' Private m_Estado As String
- ' Public Property RFCEmisor() As String
- ' Get
- ' Return m_RFCEmisor
- ' End Get
- ' Set
- ' m_RFCEmisor = Value
- ' End Set
- ' End Property
- ' Private m_RFCEmisor As String
- ' Public Property Emisor() As String
- ' Get
- ' Return m_Emisor
- ' End Get
- ' Set
- ' m_Emisor = Value
- ' End Set
- ' End Property
- ' Private m_Emisor As String
- ' Public Property RFCReceptor() As String
- ' Get
- ' Return m_RFCReceptor
- ' End Get
- ' Set
- ' m_RFCReceptor = Value
- ' End Set
- ' End Property
- ' Private m_RFCReceptor As String
- ' Public Property Receptor() As String
- ' Get
- ' Return m_Receptor
- ' End Get
- ' Set
- ' m_Receptor = Value
- ' End Set
- ' End Property
- ' Private m_Receptor As String
- ' Public Property RFCPAC() As String
- ' Get
- ' Return m_RFCPAC
- ' End Get
- ' Set
- ' m_RFCPAC = Value
- ' End Set
- ' End Property
- ' Private m_RFCPAC As String
- ' Public Property FechaCertificacion() As String
- ' Get
- ' Return m_FechaCertificacion
- ' End Get
- ' Set
- ' m_FechaCertificacion = Value
- ' End Set
- ' End Property
- ' Private m_FechaCertificacion As String
- ' Public Property Monto() As Double
- ' Get
- ' Return m_Monto
- ' End Get
- ' Set
- ' m_Monto = Value
- ' End Set
- ' End Property
- ' Private m_Monto As Double
- ' Public Property FechaCancelacion() As String
- ' Get
- ' Return m_FechaCancelacion
- ' End Get
- ' Set
- ' m_FechaCancelacion = Value
- ' End Set
- ' End Property
- ' Private m_FechaCancelacion As String
- ' Public Property ResponseHTML() As String
- ' Get
- ' Return m_ResponseHTML
- ' End Get
- ' Set
- ' m_ResponseHTML = Value
- ' End Set
- ' End Property
- ' Private m_ResponseHTML As String
- '#End Region
-
-
- ' 'Public Sub New()
- ' 'End Sub
-
- ' 'Public Sub New(FolioFiscal As String, RFCEmisor As String, RFCReceptor As String, MontoTotal As Double, Fecha As String)
- ' ' Me.LFolioFiscal = FolioFiscal
- ' ' Me.LRFCEmisor = RFCEmisor
- ' ' Me.LRFCReceptor = RFCReceptor
- ' ' Verificar()
- ' ' ' valida que este vigente y que el total coincida entre el xml y la pagina
- ' ' If EsValida = 1 AndAlso Math.Abs(Me.Monto - MontoTotal) <0.01 AndAlso Me.FechaEmision= Fecha Then
- ' ' EsValida = 1
- ' ' End If
- ' 'End Sub
-
- ' 'Public Function Verificar(FolioFiscal As String, RFCEmisor As String, RFCReceptor As String, MontoTotal As Double, Fecha As System.DateTime) As Integer
- ' ' Me.LFolioFiscal = FolioFiscal
- ' ' Me.LRFCEmisor = RFCEmisor
- ' ' Me.LRFCReceptor = RFCReceptor
- ' ' Verificar()
- ' ' ' valida que este vigente y que el total coincida entre el xml y la pagina
- ' ' If EsValida = 1 AndAlso Math.Abs(Me.Monto - MontoTotal) < 0.01 AndAlso Me.FechaEmision.ToDate() = Fecha Then
- ' ' EsValida = 1
- ' ' End If
- ' ' Return Me.EsValida
- ' 'End Function
-
- ' 'Private Sub Verificar()
-
- ' ' Try
- ' ' Dim URL As String = "https://verificacfdi.facturaelectronica.sat.gob.mx/"
- ' ' Dim Captcha As String = "86347"
- ' ' Dim PostData As String = String.Format("ctl00%24ScriptManager1=ctl00%24MainContent%24UpnlBusqueda%7Cctl00%24MainContent%24BtnBusqueda&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=4XIkDFIZJUcFomimZq9eTLrdtnhIAGlsq6y0rtQuJT37JwifEc%2FW5maVQfV4be%2B4NQhS%2F%2FyWBSZzL5CyT1G1n7QcKgYNWEBpVwB63yZO4GEPtkhlMnxHIX%2BVxggo%2Fer8r5tKDnW%2FvXWy0%2BZTkT0xTcXs7bDk%2F9J3p8kUPusbOcuaNmov7RxCXqW5%2F2DKoYrkc0Jn4A6N0ndsdtjVuD3fH8wGQ5kaKpMxmr6Nyr4mO98kc%2Bbd8AkKR458juZEzpgmmifqg61Ho7LLzuq02TCN3jDbPH4MQ79m8mh%2BYDxeZi%2BVG%2FbOjGECspr6aKxLT0zuzlQX5ZWVKenYv1Ei0YQkfhrmsNWqUwBWUAFeZwziDX2d0HNp&__VIEWSTATEGENERATOR=CA0B0334&__VIEWSTATEENCRYPTED=&ctl00%24MainContent%24TxtUUID={0}&ctl00%24MainContent%24TxtRfcEmisor={1}&ctl00%24MainContent%24TxtRfcReceptor={2}&ctl00%24MainContent%24TxTCaptchaNumbers={3}&__ASYNCPOST=true&ctl00%24MainContent%24BtnBusqueda=Verificar%20CFDI", LFolioFiscal, LRFCEmisor, LRFCReceptor, Captcha)
- ' ' Dim Encoding As Encoding = Encoding.UTF8
- ' ' Dim Data As Byte() = Encoding.GetBytes(PostData)
- ' ' Dim Request As HttpWebRequest = Nothing
-
- ' ' Request = DirectCast(WebRequest.Create(URL), HttpWebRequest)
- ' ' Request.Method = "POST"
- ' ' Request.Accept = "*/*"
- ' ' Request.Headers.Add("X-Requested-With", "XMLHttpRequest")
- ' ' Request.Headers.Add("X-MicrosoftAjax", "Delta=true")
- ' ' Request.ContentType = "application/x-www-form-urlencoded; charset=utf-8"
- ' ' Request.Referer = "https://verificacfdi.facturaelectronica.sat.gob.mx/"
- ' ' Request.Headers.Add("Accept-Language", "es-mx")
- ' ' Request.Headers.Add("Accept-Encoding", "gzip, deflate")
- ' ' Request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; WOW64; Trident/5.0)"
- ' ' Request.Host = "verificacfdi.facturaelectronica.sat.gob.mx"
- ' ' Request.Headers.Add("Pragma", "no-cache")
- ' ' Request.ServicePoint.Expect100Continue = False
- ' ' Request.KeepAlive = True
- ' ' Request.ContentLength = Data.Length
-
- ' ' Dim OutStream As Stream = Request.GetRequestStream()
- ' ' OutStream.Write(Data, 0, Data.Length)
- ' ' OutStream.Close()
- ' ' Dim Response = DirectCast(Request.GetResponse(), HttpWebResponse)
-
- ' ' Dim InStream As Stream = Nothing
- ' ' Select Case Response.ContentEncoding.ToUpperInvariant()
- ' ' Case "GZIP"
- ' ' InStream = New GZipStream(Response.GetResponseStream(), CompressionMode.Decompress)
- ' ' Exit Select
- ' ' Case "DEFLATE"
- ' ' InStream = New DeflateStream(Response.GetResponseStream(), CompressionMode.Decompress)
- ' ' Exit Select
- ' ' Case Else
- ' ' InStream = Response.GetResponseStream()
- ' ' Exit Select
- ' ' End Select
-
- ' ' Dim SR As New StreamReader(InStream, Encoding)
- ' ' Dim DataBack As String = SR.ReadToEnd()
-
- ' ' ProcesarDatos(DataBack)
- ' ' Catch ex As Exception
- ' ' ModExtensiones.GuardaLog("'ERROR : No se pudo Validar la factura:" + ex.Message)
- ' ' End Try
- ' 'End Sub
-
- ' 'Private Sub ProcesarDatos(HTML As String)
- ' ' Dim tValida As Integer = -1
- ' ' EsValida = 0
- ' ' ' No tiene Error
- ' ' If (HTML.Contains("El Comprobante NO se encuentra registrado")) Then
- ' ' HTML = "No se encontró el CFDi"
- ' ' 'Se validó
- ' ' tValida = 0
- ' ' Else
- ' ' Dim i As Integer = HTML.IndexOf("
")
-
- ' ' If i >= 0 Then
- ' ' HTML = HTML.Substring(i)
- ' ' HTML = HTML.Substring(0, HTML.IndexOf("
"))
- ' ' HTML = HTML.Replace(" ", " ")
- ' ' tValida = 1
- ' ' Me.ResponseHTML = HTML
-
- ' ' End If
- ' ' End If
-
- ' ' 'Cargo estructura de la clase
- ' ' If tValida = 1 Then
- ' ' Me.Efecto = ExtraeDatos(HTML, "ctl00_MainContent_LblEfectoComprobante"">", 10)
- ' ' Me.FechaEmision = ExtraeDatos(HTML, "ctl00_MainContent_LblFechaEmision"">", 19)
- ' ' Me.FolioFiscal = ExtraeDatos(HTML, "ctl00_MainContent_LblUuid"">", 40)
- ' ' Me.Estado = ExtraeDatos(HTML, "ctl00_MainContent_LblEstado"">", 15)
- ' ' Me.RFCEmisor = ExtraeDatos(HTML, "ctl00_MainContent_LblRfcEmisor"">", 13)
- ' ' Me.Emisor = ExtraeDatos(HTML, "ctl00_MainContent_LblNombreEmisor"">", 200)
- ' ' Me.RFCReceptor = ExtraeDatos(HTML, "ctl00_MainContent_LblRfcReceptor"">", 13)
- ' ' Me.Receptor = ExtraeDatos(HTML, "ctl00_MainContent_LblNombreReceptor"">", 200)
- ' ' Me.RFCPAC = ExtraeDatos(HTML, "ctl00_MainContent_LblRfcPac"">", 13)
- ' ' Me.FechaCertificacion = ExtraeDatos(HTML, "ctl00_MainContent_LblFechaCertificacion"">", 19)
- ' ' Me.Monto = ExtraeDatos(HTML, "ctl00_MainContent_LblMonto"">", 15).ToDouble()
- ' ' Me.FechaCancelacion = ExtraeDatos(HTML, "ctl00_MainContent_LblFechaCancelacion"">", 19)
- ' ' If Estado.ToLower() = "vigente" Then
- ' ' EsValida = 1
- ' ' End If
-
- ' ' If Estado.ToLower() = "cancelado" Then
- ' ' EsValida = 2
- ' ' End If
- ' ' End If
- ' 'End Sub
-
- ' 'Private Function ExtraeDatos(HTML As String, Container As String, MaxLength As Integer) As String
- ' ' Dim DataBack As String = String.Empty
- ' ' 'Código HTML: $ = '$', : = ':'
- ' ' For i As Integer = 0 To HTML.IndexOf(Container) + MaxLength
- ' ' If HTML.Substring(HTML.IndexOf(Container) + Container.Length - 1, i).Trim().EndsWith("") Then
- ' ' DataBack = HTML.Substring(HTML.IndexOf(Container) + Container.Length, i - 1).Replace("", "").Trim().Replace("$", "").Replace(":", ":").Replace("/", "/")
- ' ' ' TODO: might not be correct. Was : Exit For
- ' ' Exit For
- ' ' Else
- ' ' i = i + 1
- ' ' End If
- ' ' Next
-
- ' ' Return DataBack.Trim()
- ' 'End Function
-
- '#Region " IDisposable Support "
- ' ' IDisposable
- ' Protected Overridable Sub Dispose(disposing As Boolean)
- ' If Not disposedValue Then
- ' ' TODO: Liberar otro estado (objetos administrados).
- ' If disposing Then
-
- ' ' TODO: Liberar su propio estado (objetos no administrados).
- ' ' TODO: Establecer campos grandes como Null.
- ' End If
- ' End If
- ' disposedValue = True
- ' End Sub
-
- ' ' Visual Basic agregó este código para implementar correctamente el modelo descartable.
- ' Public Sub Dispose()
- ' ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean).
- ' Dispose(True)
- ' GC.SuppressFinalize(Me)
- ' End Sub
-
- ' Private Sub IDisposable_Dispose() Implements IDisposable.Dispose
- ' Throw New NotImplementedException()
- ' End Sub
- '#End Region
-
- ' End Class
-
+ End Class
+
+
+ ' Public Class ClsValidaCFDi
+ ' Implements IDisposable
+
+ '#Region "Campos"
+ ' 'Campos
+ ' Private LFolioFiscal As String
+ ' Private LRFCEmisor As String
+ ' Private LRFCReceptor As String
+ ' ' Para detectar llamadas redundantes
+ ' Private disposedValue As Boolean = False
+ '#End Region
+
+ '#Region "Propiedades"
+ ' 'Propiedades
+ ' Public Property EsValida() As Integer
+ ' Get
+ ' Return m_EsValida
+ ' End Get
+ ' Set
+ ' m_EsValida = Value
+ ' End Set
+ ' End Property
+ ' Private m_EsValida As Integer
+ ' Public Property Efecto() As String
+ ' Get
+ ' Return m_Efecto
+ ' End Get
+ ' Set
+ ' m_Efecto = Value
+ ' End Set
+ ' End Property
+ ' Private m_Efecto As String
+ ' Public Property FechaEmision() As String
+ ' Get
+ ' Return m_FechaEmision
+ ' End Get
+ ' Set
+ ' m_FechaEmision = Value
+ ' End Set
+ ' End Property
+ ' Private m_FechaEmision As String
+ ' Public Property FolioFiscal() As String
+ ' Get
+ ' Return m_FolioFiscal
+ ' End Get
+ ' Set
+ ' m_FolioFiscal = Value
+ ' End Set
+ ' End Property
+ ' Private m_FolioFiscal As String
+ ' Public Property Estado() As String
+ ' Get
+ ' Return m_Estado
+ ' End Get
+ ' Set
+ ' m_Estado = Value
+ ' End Set
+ ' End Property
+ ' Private m_Estado As String
+ ' Public Property RFCEmisor() As String
+ ' Get
+ ' Return m_RFCEmisor
+ ' End Get
+ ' Set
+ ' m_RFCEmisor = Value
+ ' End Set
+ ' End Property
+ ' Private m_RFCEmisor As String
+ ' Public Property Emisor() As String
+ ' Get
+ ' Return m_Emisor
+ ' End Get
+ ' Set
+ ' m_Emisor = Value
+ ' End Set
+ ' End Property
+ ' Private m_Emisor As String
+ ' Public Property RFCReceptor() As String
+ ' Get
+ ' Return m_RFCReceptor
+ ' End Get
+ ' Set
+ ' m_RFCReceptor = Value
+ ' End Set
+ ' End Property
+ ' Private m_RFCReceptor As String
+ ' Public Property Receptor() As String
+ ' Get
+ ' Return m_Receptor
+ ' End Get
+ ' Set
+ ' m_Receptor = Value
+ ' End Set
+ ' End Property
+ ' Private m_Receptor As String
+ ' Public Property RFCPAC() As String
+ ' Get
+ ' Return m_RFCPAC
+ ' End Get
+ ' Set
+ ' m_RFCPAC = Value
+ ' End Set
+ ' End Property
+ ' Private m_RFCPAC As String
+ ' Public Property FechaCertificacion() As String
+ ' Get
+ ' Return m_FechaCertificacion
+ ' End Get
+ ' Set
+ ' m_FechaCertificacion = Value
+ ' End Set
+ ' End Property
+ ' Private m_FechaCertificacion As String
+ ' Public Property Monto() As Double
+ ' Get
+ ' Return m_Monto
+ ' End Get
+ ' Set
+ ' m_Monto = Value
+ ' End Set
+ ' End Property
+ ' Private m_Monto As Double
+ ' Public Property FechaCancelacion() As String
+ ' Get
+ ' Return m_FechaCancelacion
+ ' End Get
+ ' Set
+ ' m_FechaCancelacion = Value
+ ' End Set
+ ' End Property
+ ' Private m_FechaCancelacion As String
+ ' Public Property ResponseHTML() As String
+ ' Get
+ ' Return m_ResponseHTML
+ ' End Get
+ ' Set
+ ' m_ResponseHTML = Value
+ ' End Set
+ ' End Property
+ ' Private m_ResponseHTML As String
+ '#End Region
+
+
+ ' 'Public Sub New()
+ ' 'End Sub
+
+ ' 'Public Sub New(FolioFiscal As String, RFCEmisor As String, RFCReceptor As String, MontoTotal As Double, Fecha As String)
+ ' ' Me.LFolioFiscal = FolioFiscal
+ ' ' Me.LRFCEmisor = RFCEmisor
+ ' ' Me.LRFCReceptor = RFCReceptor
+ ' ' Verificar()
+ ' ' ' valida que este vigente y que el total coincida entre el xml y la pagina
+ ' ' If EsValida = 1 AndAlso Math.Abs(Me.Monto - MontoTotal) <0.01 AndAlso Me.FechaEmision= Fecha Then
+ ' ' EsValida = 1
+ ' ' End If
+ ' 'End Sub
+
+ ' 'Public Function Verificar(FolioFiscal As String, RFCEmisor As String, RFCReceptor As String, MontoTotal As Double, Fecha As System.DateTime) As Integer
+ ' ' Me.LFolioFiscal = FolioFiscal
+ ' ' Me.LRFCEmisor = RFCEmisor
+ ' ' Me.LRFCReceptor = RFCReceptor
+ ' ' Verificar()
+ ' ' ' valida que este vigente y que el total coincida entre el xml y la pagina
+ ' ' If EsValida = 1 AndAlso Math.Abs(Me.Monto - MontoTotal) < 0.01 AndAlso Me.FechaEmision.ToDate() = Fecha Then
+ ' ' EsValida = 1
+ ' ' End If
+ ' ' Return Me.EsValida
+ ' 'End Function
+
+ ' 'Private Sub Verificar()
+
+ ' ' Try
+ ' ' Dim URL As String = "https://verificacfdi.facturaelectronica.sat.gob.mx/"
+ ' ' Dim Captcha As String = "86347"
+ ' ' Dim PostData As String = String.Format("ctl00%24ScriptManager1=ctl00%24MainContent%24UpnlBusqueda%7Cctl00%24MainContent%24BtnBusqueda&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=4XIkDFIZJUcFomimZq9eTLrdtnhIAGlsq6y0rtQuJT37JwifEc%2FW5maVQfV4be%2B4NQhS%2F%2FyWBSZzL5CyT1G1n7QcKgYNWEBpVwB63yZO4GEPtkhlMnxHIX%2BVxggo%2Fer8r5tKDnW%2FvXWy0%2BZTkT0xTcXs7bDk%2F9J3p8kUPusbOcuaNmov7RxCXqW5%2F2DKoYrkc0Jn4A6N0ndsdtjVuD3fH8wGQ5kaKpMxmr6Nyr4mO98kc%2Bbd8AkKR458juZEzpgmmifqg61Ho7LLzuq02TCN3jDbPH4MQ79m8mh%2BYDxeZi%2BVG%2FbOjGECspr6aKxLT0zuzlQX5ZWVKenYv1Ei0YQkfhrmsNWqUwBWUAFeZwziDX2d0HNp&__VIEWSTATEGENERATOR=CA0B0334&__VIEWSTATEENCRYPTED=&ctl00%24MainContent%24TxtUUID={0}&ctl00%24MainContent%24TxtRfcEmisor={1}&ctl00%24MainContent%24TxtRfcReceptor={2}&ctl00%24MainContent%24TxTCaptchaNumbers={3}&__ASYNCPOST=true&ctl00%24MainContent%24BtnBusqueda=Verificar%20CFDI", LFolioFiscal, LRFCEmisor, LRFCReceptor, Captcha)
+ ' ' Dim Encoding As Encoding = Encoding.UTF8
+ ' ' Dim Data As Byte() = Encoding.GetBytes(PostData)
+ ' ' Dim Request As HttpWebRequest = Nothing
+
+ ' ' Request = DirectCast(WebRequest.Create(URL), HttpWebRequest)
+ ' ' Request.Method = "POST"
+ ' ' Request.Accept = "*/*"
+ ' ' Request.Headers.Add("X-Requested-With", "XMLHttpRequest")
+ ' ' Request.Headers.Add("X-MicrosoftAjax", "Delta=true")
+ ' ' Request.ContentType = "application/x-www-form-urlencoded; charset=utf-8"
+ ' ' Request.Referer = "https://verificacfdi.facturaelectronica.sat.gob.mx/"
+ ' ' Request.Headers.Add("Accept-Language", "es-mx")
+ ' ' Request.Headers.Add("Accept-Encoding", "gzip, deflate")
+ ' ' Request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; WOW64; Trident/5.0)"
+ ' ' Request.Host = "verificacfdi.facturaelectronica.sat.gob.mx"
+ ' ' Request.Headers.Add("Pragma", "no-cache")
+ ' ' Request.ServicePoint.Expect100Continue = False
+ ' ' Request.KeepAlive = True
+ ' ' Request.ContentLength = Data.Length
+
+ ' ' Dim OutStream As Stream = Request.GetRequestStream()
+ ' ' OutStream.Write(Data, 0, Data.Length)
+ ' ' OutStream.Close()
+ ' ' Dim Response = DirectCast(Request.GetResponse(), HttpWebResponse)
+
+ ' ' Dim InStream As Stream = Nothing
+ ' ' Select Case Response.ContentEncoding.ToUpperInvariant()
+ ' ' Case "GZIP"
+ ' ' InStream = New GZipStream(Response.GetResponseStream(), CompressionMode.Decompress)
+ ' ' Exit Select
+ ' ' Case "DEFLATE"
+ ' ' InStream = New DeflateStream(Response.GetResponseStream(), CompressionMode.Decompress)
+ ' ' Exit Select
+ ' ' Case Else
+ ' ' InStream = Response.GetResponseStream()
+ ' ' Exit Select
+ ' ' End Select
+
+ ' ' Dim SR As New StreamReader(InStream, Encoding)
+ ' ' Dim DataBack As String = SR.ReadToEnd()
+
+ ' ' ProcesarDatos(DataBack)
+ ' ' Catch ex As Exception
+ ' ' ModExtensiones.GuardaLog("'ERROR : No se pudo Validar la factura:" + ex.Message)
+ ' ' End Try
+ ' 'End Sub
+
+ ' 'Private Sub ProcesarDatos(HTML As String)
+ ' ' Dim tValida As Integer = -1
+ ' ' EsValida = 0
+ ' ' ' No tiene Error
+ ' ' If (HTML.Contains("El Comprobante NO se encuentra registrado")) Then
+ ' ' HTML = "No se encontró el CFDi"
+ ' ' 'Se validó
+ ' ' tValida = 0
+ ' ' Else
+ ' ' Dim i As Integer = HTML.IndexOf("
")
+
+ ' ' If i >= 0 Then
+ ' ' HTML = HTML.Substring(i)
+ ' ' HTML = HTML.Substring(0, HTML.IndexOf("
"))
+ ' ' HTML = HTML.Replace(" ", " ")
+ ' ' tValida = 1
+ ' ' Me.ResponseHTML = HTML
+
+ ' ' End If
+ ' ' End If
+
+ ' ' 'Cargo estructura de la clase
+ ' ' If tValida = 1 Then
+ ' ' Me.Efecto = ExtraeDatos(HTML, "ctl00_MainContent_LblEfectoComprobante"">", 10)
+ ' ' Me.FechaEmision = ExtraeDatos(HTML, "ctl00_MainContent_LblFechaEmision"">", 19)
+ ' ' Me.FolioFiscal = ExtraeDatos(HTML, "ctl00_MainContent_LblUuid"">", 40)
+ ' ' Me.Estado = ExtraeDatos(HTML, "ctl00_MainContent_LblEstado"">", 15)
+ ' ' Me.RFCEmisor = ExtraeDatos(HTML, "ctl00_MainContent_LblRfcEmisor"">", 13)
+ ' ' Me.Emisor = ExtraeDatos(HTML, "ctl00_MainContent_LblNombreEmisor"">", 200)
+ ' ' Me.RFCReceptor = ExtraeDatos(HTML, "ctl00_MainContent_LblRfcReceptor"">", 13)
+ ' ' Me.Receptor = ExtraeDatos(HTML, "ctl00_MainContent_LblNombreReceptor"">", 200)
+ ' ' Me.RFCPAC = ExtraeDatos(HTML, "ctl00_MainContent_LblRfcPac"">", 13)
+ ' ' Me.FechaCertificacion = ExtraeDatos(HTML, "ctl00_MainContent_LblFechaCertificacion"">", 19)
+ ' ' Me.Monto = ExtraeDatos(HTML, "ctl00_MainContent_LblMonto"">", 15).ToDouble()
+ ' ' Me.FechaCancelacion = ExtraeDatos(HTML, "ctl00_MainContent_LblFechaCancelacion"">", 19)
+ ' ' If Estado.ToLower() = "vigente" Then
+ ' ' EsValida = 1
+ ' ' End If
+
+ ' ' If Estado.ToLower() = "cancelado" Then
+ ' ' EsValida = 2
+ ' ' End If
+ ' ' End If
+ ' 'End Sub
+
+ ' 'Private Function ExtraeDatos(HTML As String, Container As String, MaxLength As Integer) As String
+ ' ' Dim DataBack As String = String.Empty
+ ' ' 'Código HTML: $ = '$', : = ':'
+ ' ' For i As Integer = 0 To HTML.IndexOf(Container) + MaxLength
+ ' ' If HTML.Substring(HTML.IndexOf(Container) + Container.Length - 1, i).Trim().EndsWith("") Then
+ ' ' DataBack = HTML.Substring(HTML.IndexOf(Container) + Container.Length, i - 1).Replace("", "").Trim().Replace("$", "").Replace(":", ":").Replace("/", "/")
+ ' ' ' TODO: might not be correct. Was : Exit For
+ ' ' Exit For
+ ' ' Else
+ ' ' i = i + 1
+ ' ' End If
+ ' ' Next
+
+ ' ' Return DataBack.Trim()
+ ' 'End Function
+
+ '#Region " IDisposable Support "
+ ' ' IDisposable
+ ' Protected Overridable Sub Dispose(disposing As Boolean)
+ ' If Not disposedValue Then
+ ' ' TODO: Liberar otro estado (objetos administrados).
+ ' If disposing Then
+
+ ' ' TODO: Liberar su propio estado (objetos no administrados).
+ ' ' TODO: Establecer campos grandes como Null.
+ ' End If
+ ' End If
+ ' disposedValue = True
+ ' End Sub
+
+ ' ' Visual Basic agregó este código para implementar correctamente el modelo descartable.
+ ' Public Sub Dispose()
+ ' ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean).
+ ' Dispose(True)
+ ' GC.SuppressFinalize(Me)
+ ' End Sub
+
+ ' Private Sub IDisposable_Dispose() Implements IDisposable.Dispose
+ ' Throw New NotImplementedException()
+ ' End Sub
+ '#End Region
+
+ ' End Class
+
#End Region
-
+
#Region "A P L I C A C I O N E S"
-
+
Public Class MCliente
Public Property CveCliente As Integer
Public Property Nombre As String
@@ -8534,7 +9400,7 @@ Namespace Modelos
Public Property RequiereAFInsumo As Boolean
Public Property RequierePersonal As Boolean
Public Property EsAcumulador As Boolean
- End Class
-
+ End Class
+
#End Region
End Namespace
\ No newline at end of file
diff --git a/Bancos/CuentasBancariasDetalle.aspx.vb b/Bancos/CuentasBancariasDetalle.aspx.vb
index beab9c9ec..aa6c11579 100644
--- a/Bancos/CuentasBancariasDetalle.aspx.vb
+++ b/Bancos/CuentasBancariasDetalle.aspx.vb
@@ -36,8 +36,6 @@ Partial Class Bancos_CuentasBancariasDetalle
DdlUsuarios.DataSource = GlobalDTUsuarios(CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "Nombre")
DdlUsuarios.DataBind()
-
-
If Request("CveCuenta") IsNot Nothing AndAlso IsNumeric(Request("CveCuenta")) AndAlso Request("CveCuenta").ToEntero > 0 Then
ViewState("CveCuenta") = Request("CveCuenta")
diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb
index 873ea911d..57d76e13f 100644
--- a/Bancos/IE.aspx.vb
+++ b/Bancos/IE.aspx.vb
@@ -656,23 +656,7 @@ Partial Class Bancos_IE
RBL.Items.Add(New ListItem("Acreedores Diversos", "AC"))
End If
- '08/05/2018 - Se deshabilita opcion Eliminar IE si tiene un complemento de pago relacionado
- If CveIE = -1 Or (CveIE > 0 AndAlso VerificaComplementos(False)) Then
- LnkEliminar.Visible = False
- If CveIE > 0 Then
- LnkCancelar.Visible = False
- If UsuarioActual.TienePermisoProceso(85) Then
- LnkCancelarComplemento.Visible = True
- LnkCancelarComplementoImporte.Visible = True
- End If
- 'LnkEliminarComplemento.NavigateUrl = String.Format("/Ventas/ClientesAbonar.aspx?CveIESustitucion={0}&CveCliente={1}", CveIE, CveCliente)
- End If
- Else
- LnkEliminar.Visible = True
- LnkCancelarComplemento.Visible = False
- LnkCancelarComplementoImporte.Visible = False
- End If
If TabCancelacion.Visible Then
LnkCancelar.Visible = False
@@ -1101,33 +1085,52 @@ Partial Class Bancos_IE
BtnGuardar.Enabled = False
End If
+ '2019-08-28 unificados vista de controles complemento (Cancelado, conciliciado, Con complemento vigente, sin complemento vigente)
+ Dim ExistenComplementosVigentes As Boolean = VerificaComplementos(True)
+ Dim ExistenComplementos As Boolean = VerificaComplementos(False)
- If Not ChkConciliado.Checked Then
+ If Not ChkConciliado.Checked And ObjIE.CveEstatusIE <> 2 Then
- If (Not VerificaComplementos(True)) And UsuarioActual.TienePermisoProceso(99) And ObjIE.CveEstatusIE <> 2 Then
+ If (Not ExistenComplementosVigentes) Then
+
+ If UsuarioActual.TienePermisoProceso(99) Then ' Proceso 99 Editar IE
+ BtnEditar.Visible = True
+ PermisoComplementoVigente = True
+ End If
+ DVGenerarComplementoModal.Visible = True
BtnEditar.Visible = True
- PermisoComplementoVigente = True
Else
- BtnEditar.Visible = True
+
+ If UsuarioActual.TienePermisoProceso(99) Then
+ BtnEditar.Visible = True
+ PermisoComplementoVigente = True
+ Else
+ BtnEditar.Visible = False
+ End If
+
+ LnkEliminar.Visible = False
+ LnkCancelar.Visible = False
+
+ LnkCancelarComplemento.Visible = True
+ LnkCancelarComplementoImporte.Visible = True
+
End If
- UpGuardar.Update()
+ Else
+ BtnEditar.Visible = False
+ LnkEliminar.Visible = False
+ LnkCancelarComplemento.Visible = False
+ LnkCancelarComplementoImporte.Visible = False
+ DVGenerarComplementoModal.Visible = False
End If
+ UpGuardar.Update()
+
+ End If
+
- End If
-
- 'If CveIE > 0 Then
- ' DdlProveedores.Visible = False
- ' LblBeneficiario.Visible = True
- ' LblBeneficiario.Text = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltraParametros($"CveProveedor = {CveProveedor}")(0)("RazonSocial").ToString
- 'End If
-
-
-
-
RecargaGlobalCuentasBancarias()
ObjIE.Dispose()
ObjIE2.Dispose()
@@ -1207,10 +1210,10 @@ Partial Class Bancos_IE
If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
- If IDCtaBeneficiario = 0 And UsuarioActual.Empresa.UsaContabilidad Then
+ If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
BtnGuardar.Enabled = False
- ElseIf CveCuentaBeneficiario = 0 And UsuarioActual.Empresa.UsaContabilidadSIG Then
+ ElseIf CveCuentaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then
Alert("El Beneficiario no tiene cuenta contable vinculada en SIG. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
BtnGuardar.Enabled = False
Else
@@ -1260,7 +1263,7 @@ Partial Class Bancos_IE
End If
If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
- If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then
+ If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
BtnGuardar.Enabled = False
ElseIf CveCuentaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then
@@ -1320,7 +1323,7 @@ Partial Class Bancos_IE
CveCuentaBeneficiario = ObjPersonal.CveCuentaPersonal
If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
- If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then
+ If IDCtaBeneficiario = 0 AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
BtnGuardar.Enabled = False
ElseIf CveCuentaBeneficiario = 0 AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then
@@ -1419,7 +1422,7 @@ Partial Class Bancos_IE
DivTarjeta.Visible = False
End If
- If Not IDCtaContable > 0 AndAlso UsuarioActual.Empresa.UsaContabilidad Then
+ If Not IDCtaContable > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
Alert("La Cuenta Bancaria no tiene asignada una cuenta contable", TipoMensaje.MsgAdvertencia)
End If
@@ -3768,10 +3771,10 @@ Partial Class Bancos_IE
End If
Dim Banc As New ClsBancos
- Banc.IniciaTransacSQL()
+ Dim ObjConta As New ClsContabilidad(Banc.IniciaTransacSQL())
Dim ObjAC As ClsContPAQi = Nothing
- If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then
+ If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
ObjAC = New ClsContPAQi(UsuarioActual.Empresa)
ObjAC.IniciaTransacSQL()
End If
@@ -3782,7 +3785,7 @@ Partial Class Bancos_IE
Dim IdPolizaNueva = -1
Dim FolioPolizaNueva = -1
- If (IDPoliza > 0 AndAlso (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad)) Then
+ If (IDPoliza > 0 AndAlso (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1")) Then
If ObjAC Is Nothing Then
ErrorCancelar = True
@@ -3831,20 +3834,38 @@ Partial Class Bancos_IE
Else
- 'LIMPIA POLIZA PONIENDO IMPORTE EN CEROS
- For Each dr As DataRow In dt.Rows
- If Not ObjAC.UpdateMovimiento(dr("Id").ToString.ToEntero, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "1", 0, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegNeg").ToString.ToEntero, dr("Fecha").ToString.ToDate) Then
- ErrorCancelar = True
- MensajeError = "Error al actualizar Movimientos con importe 0"
- Exit For
- End If
- Next
+ 'SE COMENTO PARA PODER DESBLOQUEAR LA PREPOLIZA Y CREAR UNA NUEVA POLIZA
+ ''LIMPIA POLIZA PONIENDO IMPORTE EN CEROS
+ 'For Each dr As DataRow In dt.Rows
+ ' If Not ObjAC.UpdateMovimiento(dr("Id").ToString.ToEntero, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "1", 0, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegNeg").ToString.ToEntero, dr("Fecha").ToString.ToDate) Then
+ ' ErrorCancelar = True
+ ' MensajeError = "Error al actualizar Movimientos con importe 0"
+ ' Exit For
+ ' End If
+ 'Next
- 'AJUSTA POLIZA
- If Not ErrorCancelar Then
- If Not ObjAC.AjustaPoliza(IDPoliza) Then
+ ''AJUSTA POLIZA
+ 'If Not ErrorCancelar Then
+ ' If Not ObjAC.AjustaPoliza(IDPoliza) Then
+ ' ErrorCancelar = True
+ ' MensajeError = "Error al ajustar poliza negativa"
+ ' End If
+ 'End If
+
+ If ObjAC.RemovePoliza(IDPoliza) Then
+ If Not ObjConta.DesvincularPrePolizaContabilizada(IDPoliza, UsuarioActual.CveEmpresa) Then
ErrorCancelar = True
- MensajeError = "Error al ajustar poliza negativa"
+ MensajeError = "Error al desvincular poliza."
+ End If
+ Else
+ ErrorCancelar = True
+ MensajeError = "Error al eliminar poliza."
+ End If
+
+ If Not ErrorCancelar Then
+ If Not ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
+ ErrorCancelar = True
+ MensajeError = "Error al desbloquear prepoliza."
End If
End If
@@ -3856,6 +3877,11 @@ Partial Class Bancos_IE
End If
End If
+ If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
+ ErrorCancelar = True
+ MensajeError = "Error al contabilizar poliza"
+ End If
+
End If
End If
@@ -3955,6 +3981,7 @@ Partial Class Bancos_IE
If ObjAC IsNot Nothing Then ObjAC.Dispose()
Banc.Dispose()
+ ObjConta.Dispose()
End Sub
Protected Sub BtnDevueltoIE_Click(sender As Object, e As EventArgs)
@@ -3981,7 +4008,7 @@ Partial Class Bancos_IE
Dim ObjConta As New ClsContabilidad(Banc.IniciaTransacSQL)
Dim ObjAC As ClsContPAQi = Nothing
- If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then
+ If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1" Then
ObjAC = New ClsContPAQi(UsuarioActual.Empresa)
ObjAC.IniciaTransacSQL()
End If
@@ -3991,7 +4018,7 @@ Partial Class Bancos_IE
Dim IdPolizaNueva = -1
Dim FolioPolizaNueva = -1
- If (IDPoliza > 0 AndAlso (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad)) Then
+ If (IDPoliza > 0 AndAlso (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1")) Then
If ObjAC Is Nothing Then
ErrorCancelar = True
@@ -4311,7 +4338,7 @@ Partial Class Bancos_IE
Dim ErrorCompra = False
'Elimina la poliza
- If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IDPoliza > 0 Then
+ If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") AndAlso IDPoliza > 0 Then
If Not ObjAC.RemovePoliza(IDPoliza) Then
ErrorCompra = True
End If
@@ -4674,6 +4701,9 @@ Partial Class Bancos_IE
End Sub
Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles BtnRemove.Click
+
+
+
If Not TxtDescripcion.Text = "" Then
If ChkConciliado.Checked Then
Alert("El documento seleccionado no se puede eliminar porque se encuentra conciliado.", TipoMensaje.MsgError)
@@ -4698,7 +4728,7 @@ Partial Class Bancos_IE
End If
End If
- If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IDPoliza > 0 Then
+ If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200).ToString = "1") AndAlso IDPoliza > 0 Then
ObjAC = New ClsContPAQi(UsuarioActual.Empresa)
ObjAC.IniciaTransacSQL()
If Not ObjAC.RemovePoliza(IDPoliza) Then
@@ -5624,15 +5654,24 @@ Partial Class Bancos_IE
Private Sub ControlesEdicion()
+ Dim ExistenComplementosVigentes As Boolean = VerificaComplementos(True)
If PermisoComplementoVigente Then
- DdlTipoTransaccion.Enabled = True
- LblCuenta.Visible = False
- DdlCuenta.Enabled = True
- DdlCuenta.Visible = True
- TxtFolio.Enabled = True
- TxtObservaciones.Enabled = True
+ If ExistenComplementosVigentes Then
+ TxtFolio.Enabled = True
+ TxtObservaciones.Enabled = True
+ Else
+
+ DdlTipoTransaccion.Enabled = True
+ LblCuenta.Visible = False
+ DdlCuenta.Enabled = True
+ DdlCuenta.Visible = True
+ TxtFolio.Enabled = True
+ TxtObservaciones.Enabled = True
+
+ End If
+
UpDatos.Update()
CargaCuentasDepositoClientes()
diff --git a/Bancos/ProveedoresAbonar.aspx b/Bancos/ProveedoresAbonar.aspx
index dec829379..29c9eeb36 100644
--- a/Bancos/ProveedoresAbonar.aspx
+++ b/Bancos/ProveedoresAbonar.aspx
@@ -199,7 +199,7 @@
diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb
index f9d14b40f..02bb186f9 100644
--- a/Compras/Compras.aspx.vb
+++ b/Compras/Compras.aspx.vb
@@ -2634,6 +2634,7 @@ Partial Class Compras_Compras
DdlPS.Enabled = True
TxtObsPS.Enabled = True
LbAgregar.Enabled = True
+ LnkUpdateFechaPago.Visible = True
End If
BtnGuardar.Visible = False
@@ -9947,18 +9948,18 @@ Partial Class Compras_Compras
If Not (e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5) Then
If e.Row.RowIndex = 0 Then
- e.Row.Cells(0).Width = Unit.Pixel(15)
- e.Row.Cells(1).Width = Unit.Pixel(45)
- e.Row.Cells(2).Width = Unit.Pixel(70)
- e.Row.Cells(3).Width = Unit.Pixel(230)
- e.Row.Cells(4).Width = Unit.Pixel(202)
- e.Row.Cells(5).Width = Unit.Pixel(155)
- e.Row.Cells(6).Width = Unit.Pixel(155)
- e.Row.Cells(7).Width = Unit.Pixel(50)
- e.Row.Cells(8).Width = Unit.Pixel(80)
- e.Row.Cells(9).Width = Unit.Pixel(80)
- e.Row.Cells(10).Width = Unit.Pixel(43)
- e.Row.Cells(11).Width = Unit.Pixel(43)
+ 'e.Row.Cells(0).Width = Unit.Pixel(15)
+ 'e.Row.Cells(1).Width = Unit.Pixel(45)
+ 'e.Row.Cells(2).Width = Unit.Pixel(70)
+ 'e.Row.Cells(3).Width = Unit.Pixel(230)
+ 'e.Row.Cells(4).Width = Unit.Pixel(202)
+ 'e.Row.Cells(5).Width = Unit.Pixel(155)
+ 'e.Row.Cells(6).Width = Unit.Pixel(155)
+ 'e.Row.Cells(7).Width = Unit.Pixel(50)
+ 'e.Row.Cells(8).Width = Unit.Pixel(80)
+ 'e.Row.Cells(9).Width = Unit.Pixel(80)
+ 'e.Row.Cells(10).Width = Unit.Pixel(43)
+ 'e.Row.Cells(11).Width = Unit.Pixel(43)
If UsuarioActual.Empresa.UsaAC Then 'AndAlso (CveFactura > 0 Or CveCompra > 0)
e.Row.Cells(12).Width = Unit.Pixel(150)
@@ -14521,7 +14522,7 @@ Partial Class Compras_Compras
End If
End If
- If (HdnIEPSModificadoOC.Value.ToDecimal <> LbIEPSOC2.Text.ToDecimal) Then
+ If Math.Abs(HdnIEPSModificadoOC.Value.ToDecimal - LbIEPSOC2.Text.ToDecimal) > 0.05 Then
Alert($"Hay una diferencia de IEPS entre la factura y la OC. Dif: {HdnIEPSModificadoOC.Value.ToDecimal - LbIEPSOC2.Text.ToDecimal}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
@@ -18816,4 +18817,26 @@ Partial Class Compras_Compras
AddPS2(EsNoDeducible:=EsNoDeducible)
End Sub
+ Protected Sub LnkUpdateFechaPago_Click(sender As Object, e As EventArgs)
+ Dim ObjComp As New ClsCompras
+ Dim FechaPagoAnterior As String = ""
+
+ If ObjComp.GetCompras(CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then
+ If ObjComp.DtResultados.Rows.Count > 0 Then
+ FechaPagoAnterior = ObjComp.DtResultados.Rows(0)("FechaVencimiento").ToString.ToDate.ToShortDateString
+ End If
+ End If
+
+ If FechaPagoAnterior = TxtFechaPago.Text Then
+ Alert("La fecha de pago seleccionada es igual que la anterior.", TipoMensaje.MsgAdvertencia)
+ ObjComp.Dispose()
+ Exit Sub
+ End If
+
+ If ObjComp.UpdateFechaVencimientoCompra(CveCompra, TxtFechaPago.Text.ToDate, UsuarioActual.CveEmpresa) Then
+ Alert("Fecha de pago actualizada correctamente.")
+ End If
+
+ ObjComp.Dispose()
+ End Sub
End Class
\ No newline at end of file
diff --git a/Empresas/119/Formatos/RepClientesCxC.rpt b/Empresas/119/Formatos/RepClientesCxC.rpt
index 246d65950..f8e06f121 100644
Binary files a/Empresas/119/Formatos/RepClientesCxC.rpt and b/Empresas/119/Formatos/RepClientesCxC.rpt differ
diff --git a/Empresas/137/Formatos/RepClientesCxC.rpt b/Empresas/137/Formatos/RepClientesCxC.rpt
index 132388990..e73183a2d 100644
Binary files a/Empresas/137/Formatos/RepClientesCxC.rpt and b/Empresas/137/Formatos/RepClientesCxC.rpt differ
diff --git a/Empresas/72/Formatos/RepClientesCxC.rpt b/Empresas/72/Formatos/RepClientesCxC.rpt
index 3328a6999..7138b6374 100644
Binary files a/Empresas/72/Formatos/RepClientesCxC.rpt and b/Empresas/72/Formatos/RepClientesCxC.rpt differ
diff --git a/Empresas/80/Formatos/RepClientesCxC.rpt b/Empresas/80/Formatos/RepClientesCxC.rpt
index dd01f9438..627ab3e5c 100644
Binary files a/Empresas/80/Formatos/RepClientesCxC.rpt and b/Empresas/80/Formatos/RepClientesCxC.rpt differ
diff --git a/Empresas/Grales/Formatos/RepClientesCxC.rpt b/Empresas/Grales/Formatos/RepClientesCxC.rpt
index f7308a548..85aa597c6 100644
Binary files a/Empresas/Grales/Formatos/RepClientesCxC.rpt and b/Empresas/Grales/Formatos/RepClientesCxC.rpt differ
diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb
index 7ffc1911c..be0979ef5 100644
--- a/General/SaldosIniciales.aspx.vb
+++ b/General/SaldosIniciales.aspx.vb
@@ -1561,6 +1561,7 @@ Partial Class General_SaldosIniciales
End If
Else
mensajeError = $"No se encontró el producto o servicio con código ""{nuevaEntrada("CodigoPS")}"""
+ Throw New Exception()
End If
Next
Else
diff --git a/Global.asax b/Global.asax
index f69cea9f7..dcb70128c 100644
--- a/Global.asax
+++ b/Global.asax
@@ -183,7 +183,7 @@
'If ObjBancos.GetBancosCuentasUsuarios(-1) Then Application("GlobalDTBancosCuentas") = ObjBancos.DtResultados Else Application("GlobalDTBancosCuentas") = Nothing
If ObjBancos.GetBancosCuentasUsuarios(-1) Then Application("GlobalDTBancosCuentas") = ObjBancos.DtResultados Else Application("GlobalDTBancosCuentas") = Nothing
If ObjBancos.GetBancos_TiposTransaccion(-1) Then Application("GlobalDTTipoTransacciones") = ObjBancos.DtResultados Else Application("GlobalDTTipoTransacciones") = Nothing
- If ObjBancos.GetBancos_EstatusIE() Then Application("GlobalDTEstatusIE") = ObjBancos.DtResultados Else Application("GlobalDTEstatusIE") = Nothing
+ If ObjBancos.GetBancos_EstatusIE() Then Application("GlobalDTBancosEstatusIE") = ObjBancos.DtResultados Else Application("GlobalDTBancosEstatusIE") = Nothing
If ObjBancos.GetBancos() Then Application("GlobalDTBancos") = ObjBancos.DtResultados Else Application("GlobalDTBancos") = Nothing
If ObjBancos.GetBancos_TiposCuenta() Then Application("GlobalDTTipoCuenta") = ObjBancos.DtResultados Else Application("GlobalDTTipoCuenta") = Nothing
ObjBancos.Dispose()
diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb
index be7cc478a..130eb6006 100644
--- a/Inventarios/EntradasSalidas.aspx.vb
+++ b/Inventarios/EntradasSalidas.aspx.vb
@@ -1058,7 +1058,7 @@ Partial Class Inventarios_EntradasSalidas
ObjConta.IniciaTransacSQL()
End If
- If ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, TxtDescripcion.Text, "Inventarios", TxtFolio.Text + " / " + DdlConcepto.SelectedItem.Text) Then
+ If Not ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, TxtDescripcion.Text, "Inventarios", TxtFolio.Text + " / " + DdlConcepto.SelectedItem.Text) Then
TieneError = True
End If
diff --git a/Inventarios/KardexAlmacenHorizontal.aspx.vb b/Inventarios/KardexAlmacenHorizontal.aspx.vb
index 829a76939..289615efa 100644
--- a/Inventarios/KardexAlmacenHorizontal.aspx.vb
+++ b/Inventarios/KardexAlmacenHorizontal.aspx.vb
@@ -152,10 +152,14 @@ Partial Class Inventarios_KardexAlmacen
dt = Nothing
Return dt
Exit Function
- End If
- End If
-
- ObjMovimientos.Dispose()
+ End If
+ Else
+ ObjMovimientos.Dispose()
+ Alert("Ocurrió un error al consultar el Kardex.", TipoMensaje.MsgError)
+ Exit Function
+ End If
+
+
GvDatos.DataBind()
For index = 3 To GvDatos.Rows(0).Cells.Count - 1
diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb
index 82bc8cde7..ed0f11905 100644
--- a/Inventarios/RecepcionAlmacen.aspx.vb
+++ b/Inventarios/RecepcionAlmacen.aspx.vb
@@ -2346,16 +2346,18 @@ Partial Class Inventarios_RecepcionAlmacen
End If
'CONTABILIZAR - UNIFICAR Y SIMPLIFICAR CON PP DE LA COMPRA
- If Not ErrorMovInv And CvePrePolizaCompra > 0 Then
+ If Not ErrorMovInv Then
- If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then
- If Not ObjConta.PrePolizaUnificacion(CvePrePolizaCompra, CvePrePoliza) Then
- ErrorMovInv = True
- MensajeError = "Error al unificar los conceptos contables"
+ If CvePrePolizaCompra > 0 Then
+ If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then
+ If Not ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaCompra) Then
+ ErrorMovInv = True
+ MensajeError = "Error al unificar los conceptos contables"
+ End If
End If
End If
- If UsuarioActual.Empresa.Funcionalidad(220) <> "" Or UsuarioActual.CveEmpresa = 119 Then
+ If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then
ErrorMovInv = True
MensajeError = "Error al simplificar los conceptos contables"
@@ -2458,17 +2460,20 @@ Partial Class Inventarios_RecepcionAlmacen
End If
'CONTABILIZAR - UNIFICAR Y SIMPLIFICAR CON PP DE LA COMPRA
- If Not ErrorMovInv And CvePrePolizaCompra > 0 Then
+ If Not ErrorMovInv Then
- If UsuarioActual.Empresa.Funcionalidad(219) = "1" Or UsuarioActual.CveEmpresa = 119 Then
- If Not ObjConta.PrePolizaUnificacion(CvePrePolizaCompra, CvePrePoliza) Then
- ErrorMovInv = True
- MensajeError = "Error al unificar los conceptos contables"
+ If CvePrePolizaCompra > 0 Then
+ If UsuarioActual.Empresa.Funcionalidad(219) = "1" Then
+ If Not ObjConta.PrePolizaUnificacion(CvePrePoliza, CvePrePolizaCompra) Then
+ ErrorMovInv = True
+ MensajeError = "Error al unificar los conceptos contables"
+ End If
End If
End If
- If UsuarioActual.Empresa.Funcionalidad(220) <> "" Or UsuarioActual.CveEmpresa = 119 Then
- If Not ObjConta.PrePolizaSimplificacion(CvePrePolizaCompra, UsuarioActual.CveEmpresa) Then
+
+ If UsuarioActual.Empresa.Funcionalidad(220) <> "" Then
+ If Not ObjConta.PrePolizaSimplificacion(CvePrePoliza, UsuarioActual.CveEmpresa) Then
ErrorMovInv = True
MensajeError = "Error al simplificar los conceptos contables"
End If
@@ -2743,6 +2748,17 @@ Partial Class Inventarios_RecepcionAlmacen
End If
End If
+ If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
+ ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
+ ObjContaAC.IniciaTransacSQL()
+ If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContaAC) Then
+ MensajeError = $" Movimiento contabilizado en el folio: {ObjConta.ContaFolio} "
+ Else
+ ErrorMovInv = True
+ MensajeError = "Error al contabilizar los conceptos contables"
+ End If
+ End If
+
'FINAL
If Not ErrorMovInv Then
diff --git a/LogMail.txt b/LogMail.txt
new file mode 100644
index 000000000..def4d02c0
--- /dev/null
+++ b/LogMail.txt
@@ -0,0 +1 @@
+
28/08/2019:04:44 p. m. No se especifico a remitente - SIG - Se Genero una Recepción de Usados con el folio: 79
28/08/2019:05:48 p. m. No se especifico a remitente - SIG - Se Genero una Recepción de Usados con el folio: 80
\ No newline at end of file
diff --git a/Sistemas/ConfiguracionEmpresa.aspx b/Sistemas/ConfiguracionEmpresa.aspx
new file mode 100644
index 000000000..ca36a2e4c
--- /dev/null
+++ b/Sistemas/ConfiguracionEmpresa.aspx
@@ -0,0 +1,121 @@
+<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="ConfiguracionEmpresa.aspx.vb" Inherits="Sistemas_ConfiguracionEmpresa" %>
+
+<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cuenta
+
+
+
+
+
+
+
+
+
+
+
+
+
Clientes:
+
+
+
+
+
+
+
+
+
Clave de Empresa:
+
+
+
+
+
+
+
+
Razón Social:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sistemas/ConfiguracionEmpresa.aspx.vb b/Sistemas/ConfiguracionEmpresa.aspx.vb
new file mode 100644
index 000000000..2089a9192
--- /dev/null
+++ b/Sistemas/ConfiguracionEmpresa.aspx.vb
@@ -0,0 +1,23 @@
+Option Explicit On
+Option Strict On
+
+Imports System.Data
+Imports Extensiones
+Imports System.Runtime.InteropServices
+Imports System.IO
+
+Partial Class Sistemas_ConfiguracionEmpresa
+ Inherits ClsPaginas
+
+#Region " PROPIEDADES "
+
+#End Region
+
+
+ Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
+ If Not IsPostBack Then
+
+
+ End If
+ End Sub
+End Class
diff --git a/Sistemas/PopUpAddUsuario.aspx b/Sistemas/PopUpAddUsuario.aspx
index 7dd9651a7..9d685feb4 100644
--- a/Sistemas/PopUpAddUsuario.aspx
+++ b/Sistemas/PopUpAddUsuario.aspx
@@ -69,7 +69,6 @@
-
diff --git a/Sistemas/PopUpAddUsuario.aspx.vb b/Sistemas/PopUpAddUsuario.aspx.vb
index 110869def..c99a8cbf3 100644
--- a/Sistemas/PopUpAddUsuario.aspx.vb
+++ b/Sistemas/PopUpAddUsuario.aspx.vb
@@ -716,6 +716,7 @@ Partial Class Sistemas_PopUpAddUsuario
GvModulosPermiso.DataSource = ObjProcesos.DtResultados.FiltraParametros($"CvePlataforma = 6")
ElseIf UsuarioActual.Empresa.CvePlataforma = 1 And CveProveedor > 0 Then
GvModulosPermiso.DataSource = ObjProcesos.DtResultados.FiltraParametros($"CvePlataforma = 7")
+ BtnDefaultPWD.Visible = True
ElseIf UsuarioActual.Empresa.CvePlataforma = 3 Then
GvModulosPermiso.DataSource = ObjProcesos.DtResultados.FiltraParametros("CveModulo = 433")
End If
@@ -855,4 +856,5 @@ Partial Class Sistemas_PopUpAddUsuario
CargaComandos()
UpDatos.Update()
End Sub
+
End Class
diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx
index 40f948510..371c4b76a 100644
--- a/Ventas/Clientes.aspx
+++ b/Ventas/Clientes.aspx
@@ -255,10 +255,18 @@
+
+
+
- <%-- FIN MODAL IMPORTAR SALDOS --%>
+ <%-- FIN MODAL MODIFICAR PRECIOS PS --%>
+
diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb
index 34f83d72e..81f813eae 100644
--- a/Ventas/Clientes.aspx.vb
+++ b/Ventas/Clientes.aspx.vb
@@ -1253,7 +1253,8 @@ Partial Class Clientes
'CargaFormaPago33()
'CargaComboCFDI()
- 'LnkPorcentajePrecios.Visible = True
+ LnkPorcentajeMarcas.Visible = True
+ LnkPorcentajePrecios.Visible = True
If UsuarioActual.TienePermisoProceso(261) Then LnkVerGrafica.Visible = True
@@ -3643,14 +3644,14 @@ Partial Class Clientes
Dim FechaVencimientoF As String = If(TxtFechaVFCxP.Text = "", "-1", TxtFechaVFCxP.Text).ToString
Dim ObjMovtos As New ClsMovimientos()
- If ObjMovtos.GetCxCDetalle(FI, FF, CveCliente, -1, -1, -1, -1, -1, "-1", "-1", DdlSucursalCliente.SelectedValue.ToEntero(), "S", -1, "-1", 1, UsuarioActual.CveEmpresa, -1, 1, TipoDocto:=TipoDocto, FechaCorte:=FechaCorte, FechaVI:=FechaVencimientoI, FechaVF:=FechaVencimientoF, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
- DtCxCFact = ObjMovtos.DtResultados '.FiltraParametros("Tipo = 'Act'").Copy ' If(DdlTipoCuentasCxC.SelectedValue = "-1", ObjMovtos.DtResultados.FiltraParametros("CveVentaAmortizacion IS NULL", "TipoDocto").Copy, ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act' AND CveVentaAmortizacion IS NULL", "TipoDocto"))
+ If ObjMovtos.GetCxCClienteDetalle(CveCliente, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, DdlSucursalCliente.SelectedValue.ToEntero) Then
+ DtCxCFact = If(DdlTipoCuentasCxC.SelectedValue = "-1", ObjMovtos.DtResultados.FiltraParametros("", "TipoDocto").Copy, ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'", "TipoDocto"))
'cargo los anticipos NC
DtCxCFact.Columns.Add("SaldoAnticipo", GetType(Decimal))
Dim dtt As DataTable = Nothing
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, -1, -1) Then
- dtt = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0 AND SaldoVentaAnticipo = 0 AND ((Tipo = 'IxC' AND CveIE > 0) OR (Tipo = 'Ant' AND CveVenta > 0) )") ' que tenga saldo de anticipo y no de cliente
+ dtt = If(DdlTipoCuentasCxC.SelectedValue = "-1", ObjMovtos.DtResultados.FiltraParametros("SaldoVentaAnticipo = 0 AND ((Tipo = 'IxC' AND CveIE > 0) OR (Tipo = 'Ant' AND CveVenta > 0) OR (Tipo = 'NC' AND CveVenta > 0) OR (Tipo = 'Egs' AND CveVenta > 0) )"), ObjMovtos.DtResultados.FiltraParametros("Saldo > 0 AND SaldoVentaAnticipo = 0 AND ((Tipo = 'IxC' AND CveIE > 0) OR (Tipo = 'Ant' AND CveVenta > 0) OR (Tipo = 'NC' AND CveVenta > 0) OR (Tipo = 'Egs' AND CveVenta > 0) )")) ' que tenga saldo de anticipo y no de cliente
If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then
For Each drt As DataRow In dtt.Rows
Dim drr As DataRow = DtCxCFact.NewRow
@@ -3685,7 +3686,7 @@ Partial Class Clientes
SaldoIngDolaresPesos = SaldoIngDolaresPesos + (Row("Saldo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble)
End If
- ElseIf (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble = 0) Or Row("TipoDocto").ToString = "IxC" Or Row("TipoDocto").ToString = "Egs" Or Row("TipoDocto").ToString = "Dev" Then 'Anticipos, NC, IxC
+ ElseIf (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble = 0) Or Row("TipoDocto").ToString = "IxC" Or Row("TipoDocto").ToString = "NC" Or Row("TipoDocto").ToString = "Dev" Then 'Anticipos, NC, IxC
ContaAnt = ContaAnt + 1
If Row("CveMoneda").ToString.ToEntero = 1 Then
If Row("TipoDocto").ToString = "Dev" Then
@@ -8132,14 +8133,13 @@ Partial Class Clientes
End Sub
#End Region
-#Region "PORCENTAJE PRECIO DE PRODUCTOS"
- Private Sub LnkPorcentajePrecios_Click(sender As Object, e As EventArgs) Handles LnkPorcentajePrecios.Click
- RegistraScript(String.Format("$('#{0}').modal();", "DivPorcentajePrecios"))
+#Region "PORCENTAJE PRECIO DE MARCAS"
+ Private Sub LnkPorcentajeMarcas_Click(sender As Object, e As EventArgs) Handles LnkPorcentajeMarcas.Click
+ RegistraScript(String.Format("$('#{0}').modal();", "DivPorcentajeMarcas"))
CreaDT()
- txtPorcentaje.Attributes.Add("onchange", String.Format("FnCambiaPorcentaje({0});", "5"))
- CargaPorcentajesProductos()
+ CargaMarcas()
LimpiaModalPorcentaje()
End Sub
Private Sub CreaDT()
@@ -8154,66 +8154,28 @@ Partial Class Clientes
End With
DTPorcentajeTemp.Columns.Add(column)
- DTPorcentajeTemp.Columns.Add("CvePS", GetType(Integer))
- DTPorcentajeTemp.Columns.Add("Producto", GetType(String))
- DTPorcentajeTemp.Columns.Add("PrecioG", GetType(Decimal))
+ DTPorcentajeTemp.Columns.Add("CveMarca", GetType(Integer))
+ DTPorcentajeTemp.Columns.Add("Marca", GetType(String))
DTPorcentajeTemp.Columns.Add("PorcentajeProducto", GetType(Decimal))
- DTPorcentajeTemp.Columns.Add("PrecioA", GetType(Decimal))
DTPorcentajeTemp.Columns.Add("Estatus", GetType(String))
DTPorcentajePrecios = DTPorcentajeTemp.Clone
End Sub
- Private Sub CargaPorcentajesProductos()
- 'Llenar el dropdownlist de Secciones
- If UsuarioActual.CveEmpresa = 66 Then
- DdlClasificacion2.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion")
- Else
- Dim ObjClasificaciones As New ClsClasificaciones
- If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then
- DdlClasificacion2.DataSource = ObjClasificaciones.DtResultados
- End If
- ObjClasificaciones.Dispose()
- End If
- DdlClasificacion2.DataBind()
+ Private Sub CargaMarcas()
+ Dim ObjMarcas As New ClsProductosServicios
+ ObjMarcas.GetMarcas(UsuarioActual.CveEmpresa)
+ DdlMarcaPS.DataSource = ObjMarcas.DtResultados
+ ObjMarcas.Dispose()
+ DdlMarcaPS.DataBind()
+ DdlMarcaPS.Items.Insert(0, New ListItem("Seleccione", "-1"))
- CargaPS()
CargaGridPorcentajes()
-
UpPorcentaje.Update()
End Sub
- Private Sub CargaPS()
- DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
-
- If UsuarioActual.CveEmpresa = 66 Then
- DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios")
- End If
-
- If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then
- DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2")
-
- DdlProducto2.DataBind()
-
- DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
- End If
-
- End Sub
-
- Protected Sub DdlProducto2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlProducto2.selectedindexchange
- DdlProducto2IndexChange(DdlProducto2.SelectedValue.ToEntero, DdlProducto2)
- End Sub
- Private Sub DdlProducto2IndexChange(CvePSParametro As Integer, Ddl As ADServerControl.Dropdownlost)
- Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSParametro).FiltroPrimero("")
-
- If drPS IsNot Nothing Then
- Dim Precio = drPS("Precio").ToString.ToDouble
- LbPrecioG.Text = Precio.FormatoNumero()
- LbPrecioA.Text = ((Precio * txtPorcentaje.Text.ToDecimal) / 100).FormatoNumero
- End If
- End Sub
Private Sub CargaGridPorcentajes()
Dim ObjPS As New ClsProductosServicios
- If ObjPS.GetPorcentajeProductos(CveCliente) Then
+ If ObjPS.GetPorcentajeMarcas(CveCliente) Then
DTPorcentajePrecios = ObjPS.DtResultados
GvM.DataSource = DTPorcentajePrecios
End If
@@ -8232,37 +8194,29 @@ Partial Class Clientes
Private Sub LimpiaModalPorcentaje()
txtPorcentaje.Text = ""
- DdlClasificacion2.SelectedValue = "-1"
- DdlProducto2.SelectedText = ""
+ DdlMarcaPS.SelectedValue = "-1"
End Sub
- Protected Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
+ Protected Sub LbAgregarMarca_Click(sender As Object, e As EventArgs) Handles LbAgregarMarca.Click
+ If txtPorcentaje.Text.ToDecimal >= 0 And txtPorcentaje.Text.ToDecimal <= 100 Then
- If DdlProducto2.SelectedText <> "" Then
- If txtPorcentaje.Text.ToDecimal >= 0 And txtPorcentaje.Text.ToDecimal <= 100 Then
+ Dim registro As DataRow = DTPorcentajePrecios.NewRow
- Dim registro As DataRow = DTPorcentajePrecios.NewRow
-
- registro.Item("No") = DTPorcentajePrecios.Rows.Count + 1
- registro.Item("CvePS") = DdlProducto2.SelectedValue.ToEntero
- registro.Item("Producto") = DdlProducto2.SelectedText
- registro.Item("PrecioG") = 0
- registro.Item("PrecioA") = 0 * txtPorcentaje.Text.ToDecimal / 100
- registro.Item("PorcentajeProducto") = txtPorcentaje.Text.ToDecimal
- registro.Item("Estatus") = "I"
- DTPorcentajePrecios.Rows.Add(registro)
- CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
- Else
- Alert("El Porcentaje debe estar en un rango entre 0 y 100", TipoMensaje.MsgAdvertencia)
- End If
+ registro.Item("No") = DTPorcentajePrecios.Rows.Count + 1
+ registro.Item("CveMarca") = DdlMarcaPS.SelectedValue.ToEntero
+ registro.Item("Marca") = DdlMarcaPS.SelectedItem.Text
+ registro.Item("PorcentajeProducto") = txtPorcentaje.Text.ToDecimal
+ registro.Item("Estatus") = "I"
+ DTPorcentajePrecios.Rows.Add(registro)
+ CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
Else
- Alert("El campo ''Producto'' es necesario, por favor ingréselo.", TipoMensaje.MsgAdvertencia)
+ Alert("El Porcentaje debe estar en un rango entre 0 y 100", TipoMensaje.MsgAdvertencia)
End If
LimpiaModalPorcentaje()
End Sub
- Protected Sub DeleteRow(sender As Object, e As EventArgs)
+ Protected Sub DeleteRowMarca(sender As Object, e As EventArgs)
Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
@@ -8272,7 +8226,7 @@ Partial Class Clientes
i = lnkRemove.CommandArgument.ToString.ToEntero
Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", i))
If Drs.Count > 0 Then
- If CveCliente > 0 AndAlso Drs(0)("CvePS").ToString.ToEntero > 0 Then
+ If CveCliente > 0 AndAlso Drs(0)("CveMarca").ToString.ToEntero > 0 Then
Drs(0)("Estatus") = "D"
Else
Drs(0).Delete()
@@ -8309,7 +8263,6 @@ Partial Class Clientes
If Drs.Count > 0 Then
Drs(0)("PorcentajeProducto") = PorcentajeProducto
- Drs(0)("PrecioA") = Drs(0)("PrecioG").ToString.ToDouble * PorcentajeProducto / 100
Drs(0)("Estatus") = "U"
End If
@@ -8323,6 +8276,238 @@ Partial Class Clientes
End Sub
+ Protected Sub BtnGuardarPorcentajesMarca_Click(sender As Object, e As EventArgs) Handles BtnGuardarPorcentajesMarca.Click
+
+ Dim TieneError As Boolean = False
+
+ Dim ObjPS As New ClsProductosServicios
+ ObjPS.IniciaTransacSQL()
+
+ For Each Dr As DataRow In DTPorcentajePrecios.Rows
+
+ If Dr("Estatus").ToString <> "" Then
+
+ If Dr("Estatus").ToString = "I" Then
+ If Not ObjPS.AddPorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal, UsuarioActual.CveUsuario) Then
+ TieneError = True
+ End If
+ ElseIf Dr("Estatus").ToString = "U" Then
+ If Not ObjPS.UpdatePorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal) Then
+ TieneError = True
+ End If
+ ElseIf Dr("Estatus").ToString = "D" Then
+ If Not ObjPS.RemovePorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero) Then
+ TieneError = True
+ End If
+ End If
+
+ End If
+ Next
+
+ If TieneError Then
+ ObjPS.RollBack()
+ Else
+ ObjPS.Commit()
+ Alert("Los Porcentajes se guardaron correctamente.", TipoMensaje.MsgInformacion)
+ RegistraScript("$('#DivPorcentajeMarcas').modal('hide')", "hidemodal")
+ End If
+
+ ObjPS.Dispose()
+
+ End Sub
+#End Region
+
+#Region "PORCENTAJE PRECIO DE PRODUCTOS"
+ Private Sub LnkPorcentajePrecios_Click(sender As Object, e As EventArgs) Handles LnkPorcentajePrecios.Click
+ RegistraScript(String.Format("$('#{0}').modal();", "DivPorcentajePrecios"))
+
+ CreaDT2()
+
+ TxtPorcentajePS.Attributes.Add("onchange", String.Format("FnCambiaPorcentaje({0});", "5"))
+ CargaPorcentajesProductos()
+ LimpiaModalPorcentaje2()
+ End Sub
+ Private Sub CreaDT2()
+ Dim DTPorcentajeTemp As New DataTable
+
+ Dim column As DataColumn = New DataColumn("No")
+ column.DataType = Type.GetType("System.Int32")
+ With column
+ .AutoIncrement = True
+ .AutoIncrementSeed = 1
+ .AutoIncrementStep = 1
+ End With
+
+ DTPorcentajeTemp.Columns.Add(column)
+ DTPorcentajeTemp.Columns.Add("CvePS", GetType(Integer))
+ DTPorcentajeTemp.Columns.Add("Producto", GetType(String))
+ DTPorcentajeTemp.Columns.Add("PrecioG", GetType(Decimal))
+ DTPorcentajeTemp.Columns.Add("PorcentajeProducto", GetType(Decimal))
+ DTPorcentajeTemp.Columns.Add("PrecioA", GetType(Decimal))
+ DTPorcentajeTemp.Columns.Add("Estatus", GetType(String))
+ DTPorcentajePrecios = DTPorcentajeTemp.Clone
+ End Sub
+ Private Sub CargaPorcentajesProductos()
+ 'Llenar el dropdownlist de Secciones
+ If UsuarioActual.CveEmpresa = 66 Then
+ DdlClasificacion2.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion")
+ Else
+ Dim ObjClasificaciones As New ClsClasificaciones
+ If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then
+ DdlClasificacion2.DataSource = ObjClasificaciones.DtResultados
+ End If
+ ObjClasificaciones.Dispose()
+ End If
+ DdlClasificacion2.DataBind()
+
+ CargaPS()
+ CargaGridPorcentajes2()
+
+ UpPorcentajeP.Update()
+ End Sub
+ Private Sub CargaPS()
+ DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
+
+ If UsuarioActual.CveEmpresa = 66 Then
+ DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios")
+ End If
+
+ If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then
+ DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2")
+
+ DdlProducto2.DataBind()
+
+ DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
+ End If
+
+ End Sub
+
+ Protected Sub DdlProducto2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlProducto2.selectedindexchange
+ DdlProducto2IndexChange(DdlProducto2.SelectedValue.ToEntero, DdlProducto2)
+ End Sub
+ Private Sub DdlProducto2IndexChange(CvePSParametro As Integer, Ddl As ADServerControl.Dropdownlost)
+ Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSParametro).FiltroPrimero("")
+
+ If drPS IsNot Nothing Then
+ Dim Precio = drPS("Precio").ToString.ToDouble
+ LbPrecioG.Text = Precio.FormatoNumero()
+ LbPrecioA.Text = ((Precio * TxtPorcentajePS.Text.ToDecimal) / 100).FormatoNumero
+ End If
+ End Sub
+
+ Private Sub CargaGridPorcentajes2()
+ Dim ObjPS As New ClsProductosServicios
+
+ If ObjPS.GetPorcentajeProductos(CveCliente) Then
+ DTPorcentajePrecios = ObjPS.DtResultados
+ GvP.DataSource = DTPorcentajePrecios
+ End If
+ ObjPS.Dispose()
+
+ GvP.DataBind()
+ UpPorcentajePS.Update()
+
+ End Sub
+ Private Sub CargaDTPorcentajePrecios2(DtTemp As DataTable)
+ GvP.DataSource = DtTemp
+ GvP.DataBind()
+
+ UpPorcentajePS.Update()
+ End Sub
+
+ Private Sub LimpiaModalPorcentaje2()
+ TxtPorcentajePS.Text = ""
+ DdlClasificacion2.SelectedValue = "-1"
+ DdlProducto2.SelectedText = ""
+ End Sub
+
+ Protected Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
+
+ If DdlProducto2.SelectedText <> "" Then
+ If TxtPorcentajePS.Text.ToDecimal >= 0 And TxtPorcentajePS.Text.ToDecimal <= 100 Then
+
+ Dim registro As DataRow = DTPorcentajePrecios.NewRow
+
+ registro.Item("No") = DTPorcentajePrecios.Rows.Count + 1
+ registro.Item("CvePS") = DdlProducto2.SelectedValue.ToEntero
+ registro.Item("Producto") = DdlProducto2.SelectedText
+ registro.Item("PrecioG") = LbPrecioG.Text.ToDecimal
+ registro.Item("PrecioA") = LbPrecioG.Text.ToDecimal * TxtPorcentajePS.Text.ToDecimal / 100
+ registro.Item("PorcentajeProducto") = TxtPorcentajePS.Text.ToDecimal
+ registro.Item("Estatus") = "I"
+ DTPorcentajePrecios.Rows.Add(registro)
+ CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
+ Else
+ Alert("El Porcentaje debe estar en un rango entre 0 y 100", TipoMensaje.MsgAdvertencia)
+ End If
+ Else
+ Alert("El campo ''Producto'' es necesario, por favor ingréselo.", TipoMensaje.MsgAdvertencia)
+ End If
+
+ LimpiaModalPorcentaje()
+ End Sub
+
+ Protected Sub DeleteRow(sender As Object, e As EventArgs)
+
+ Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
+
+
+ If DTPorcentajePrecios.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then
+ Dim i As Integer
+ i = lnkRemove.CommandArgument.ToString.ToEntero
+ Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", i))
+ If Drs.Count > 0 Then
+ If CveCliente > 0 AndAlso Drs(0)("CvePS").ToString.ToEntero > 0 Then
+ Drs(0)("Estatus") = "D"
+ Else
+ Drs(0).Delete()
+ End If
+
+ End If
+ DTPorcentajePrecios.AcceptChanges()
+ End If
+
+ GvP.EditIndex = -1
+
+ CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
+
+ End Sub
+
+ Protected Sub GvP_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvP.RowEditing
+ GvP.EditIndex = e.NewEditIndex
+
+ CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
+ End Sub
+ Protected Sub GvP_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvP.RowCancelingEdit
+ GvP.EditIndex = -1
+
+ CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
+ End Sub
+ Protected Sub GvP_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvP.RowUpdating
+
+ Dim PorcentajeProducto As Double = GvP.Rows(e.RowIndex).FCTextBox("TxtPorcentajeP").Text.ToDouble
+
+ If PorcentajeProducto >= 0 And PorcentajeProducto <= 100 Then
+ Dim No As Integer = GvP.Rows(e.RowIndex).DataKey("No").ToEntero
+
+ Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", No))
+
+ If Drs.Count > 0 Then
+ Drs(0)("PorcentajeProducto") = PorcentajeProducto
+ Drs(0)("PrecioA") = Drs(0)("PrecioG").ToString.ToDouble * PorcentajeProducto / 100
+ Drs(0)("Estatus") = "U"
+ End If
+
+ DTPorcentajePrecios.AcceptChanges()
+ GvP.EditIndex = -1
+
+ CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
+ Else
+ Alert("El Porcentaje debe estar en un rango entre 0 y 100", TipoMensaje.MsgAdvertencia)
+ End If
+
+ End Sub
+
Protected Sub BtnGuardarPorcentajes_Click(sender As Object, e As EventArgs) Handles BtnGuardarPorcentajes.Click
Dim TieneError As Boolean = False
@@ -8473,7 +8658,7 @@ Partial Class Clientes
End Sub
- Function FolioNotaCredito() As Boolean
+ Function FolioNotaCredito(Tipo As Integer) As Boolean
FolioNotaAcumulador = 0
SerieNotaAcumulador = ""
@@ -8485,7 +8670,7 @@ Partial Class Clientes
If DTSucursales.Rows.Count > 0 Then
- If ObjFolios.GetFolios("Egs", UsuarioActual.CveEmpresa) Then
+ If ObjFolios.GetFolios(If(Tipo = 1, "RNC", "Egs"), UsuarioActual.CveEmpresa) Then
Dim DT As DataTable
If UsuarioActual.CveSubProyecto > 0 Then
@@ -8862,7 +9047,7 @@ Partial Class Clientes
Dim Folio As Integer = 0
Dim Serie As String = ""
- If FolioNotaCredito() Then
+ If FolioNotaCredito(Tipo) Then
Folio = FolioNotaAcumulador
Serie = SerieNotaAcumulador
End If
@@ -8879,7 +9064,7 @@ Partial Class Clientes
ObjFactura.CveMoneda = 1
ObjFactura.Moneda = "Pesos"
ObjFactura.MonedaSAT = "MXN"
- ObjFactura.TipoDocto = "Egs"
+ ObjFactura.TipoDocto = If(Tipo = 1, "RNC", "Egs")
ObjFactura.Folio = Folio
@@ -9013,7 +9198,7 @@ Partial Class Clientes
End If
- If ObjFactura.TipoDocto = "Egs" Then
+ If ObjFactura.TipoDocto.Contiene("Egs", "RNC") Then
ObjFactura.CveTipoRelacion = -1
End If
diff --git a/Ventas/ProductosServicios.aspx b/Ventas/ProductosServicios.aspx
index c8c23ac17..29c2aca5d 100644
--- a/Ventas/ProductosServicios.aspx
+++ b/Ventas/ProductosServicios.aspx
@@ -130,7 +130,7 @@
-
+
diff --git a/Ventas/ProductosServicios.aspx.vb b/Ventas/ProductosServicios.aspx.vb
index efd4939a0..31ec53798 100644
--- a/Ventas/ProductosServicios.aspx.vb
+++ b/Ventas/ProductosServicios.aspx.vb
@@ -212,6 +212,14 @@ Partial Class ProductosyServicios
InicializaEcommerce()
+ If UsuarioActual.CveEmpresa.Contiene(141) Then
+ 'DivDatos.Attributes("class") = "col-md-12"
+
+ DivDdlTipo.Visible = True
+ DdlTipoPSDes.Attributes.Add("onChange", "CreaDescripcionPS();")
+
+ End If
+
If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) And CvePS = -1 Then
'DivDatos.Attributes("class") = "col-md-12"
TxtPS.Enabled = False
diff --git a/Ventas/RepCancelacionesPorRespuesta.aspx.cs b/Ventas/RepCancelacionesPorRespuesta.aspx.cs
index cd394656f..3dbbbcf11 100644
--- a/Ventas/RepCancelacionesPorRespuesta.aspx.cs
+++ b/Ventas/RepCancelacionesPorRespuesta.aspx.cs
@@ -89,7 +89,8 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
{
var resp = Timbrado.VerificarVigenciaSAT(uuid, UsuarioActual.Empresa.RFC, receptor, total, UsuarioActual.Empresa.FacturaProduccion);
if (resp != null)
- {
+ {
+
if (resp.Estado == null)
{
sb.Append("No se pudo comprobar el estado de la factura. El servicio del sat no esta disponible");
@@ -100,7 +101,15 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
sb.AppendFormat("Codigo Estado: {0} ", resp.CodigoEstatus);
sb.AppendFormat("Estado: {0} ", resp.Estado);
sb.AppendFormat("Es Cancelable: {0} ", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EsCancelable);
- sb.AppendFormat("Estatus de Cancelación: {0}