diff --git a/.gitignore b/.gitignore index b28695a3b..fc8032bc3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,270 +1,269 @@ -## 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.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc -/SIGGIT.sln +## 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 + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc +/Utilerias diff --git a/App_Code/ClsCompras.vb b/App_Code/ClsCompras.vb index 4ac7964f3..d51086b15 100644 --- a/App_Code/ClsCompras.vb +++ b/App_Code/ClsCompras.vb @@ -1618,7 +1618,7 @@ Public Class ClsCompras #Region "F A C T U R A S " - Public Function GetFacturas(CveFactura As Integer, Folio As String, FechaFacturaI As Date, FechaFacturaF As Date, RFC As String, Proveedor As String, FueValidado As Integer, CveResponsable As Integer, CveProveedorClasificacion As Integer, CveTipoProveedor As Integer, CveEmpresa As Integer) As Boolean + Public Function GetFacturas(CveFactura As Integer, Folio As String, FechaFacturaI As Date, FechaFacturaF As Date, RFC As String, Proveedor As String, FueValidado As Integer, CveResponsable As Integer, CveProveedorClasificacion As Integer, CveTipoProveedor As Integer, TipoComprobante As String, CveEmpresa As Integer) As Boolean Dim OnError As Boolean = False 'StrSQL.Clear() @@ -1653,6 +1653,7 @@ Public Class ClsCompras .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveProveedorClasificacion", SqlDbType.Int).Value = CveProveedorClasificacion .Add("@CveTipoProveedor", SqlDbType.Int).Value = CveTipoProveedor + .Add("@TipoComprobante", SqlDbType.VarChar).Value = TipoComprobante End With Try diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 0b2f51307..04ad93303 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -389,7 +389,17 @@ Public Class ClsPaginas Property GlobalDTPSATUM() As DataTable Get - GlobalDTPSATUM = DirectCast(Application("GlobalDTPSATUM"), DataTable) + + 'System.Data.EnumerableRowCollection + If Not IsNothing(Application("GlobalDTPSATUM")) Then + If Application("GlobalDTPSATUM").GetType().IsSubclassOf(GetType(EnumerableRowCollection)) Then + Return DirectCast(Application("GlobalDTPSATUM"), EnumerableRowCollection(Of DataRow)).CopyToDataTable() + Else + Return DirectCast(Application("GlobalDTPSATUM"), DataTable) + End If + Else + Return Nothing + End If End Get Set(value As DataTable) Application("GlobalDTPSATUM") = value @@ -3308,9 +3318,6 @@ Public Class ClsPaginas - 'Protected Overridable Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender - - 'End Sub Private Function Obt_ClavePagina(Pagina As String) As Integer Dim Retorno As Integer @@ -3320,7 +3327,7 @@ Public Class ClsPaginas PaginaDict = New System.Collections.Hashtable PaginaDict.Add("/Inicio.aspx".ToUpper(), -1) - + PaginaDict.Add("/Ventas/RepConciliacionEmitidosSat.aspx".ToUpper(), -1) PaginaDict.Add("/Nomina/CatConceptos2.aspx".ToUpper(), -1) PaginaDict.Add("/Nomina/Aguinaldo.aspx".ToUpper(), -1) @@ -4661,11 +4668,14 @@ Public Class ClsPaginas Mensaje.Alert(Mensaje, pOpcion, JSBtnAceptar, TimeoutToast:=timeout) End If End Sub - Protected Overrides Sub SavePageStateToPersistenceMedium(pviewState As Object) + Protected Overridable Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender If Not IsNothing(ViewState("strToastMsglargonoreplace")) AndAlso ViewState("strToastMsglargonoreplace").ToString.Length > 0 Then RegistraScript(ViewState("strToastMsglargonoreplace").ToString(), "esteseraunticklargoparaquenosesobrescribaconotro") ViewState("strToastMsglargonoreplace") = Nothing End If + + End Sub + Protected Overrides Sub SavePageStateToPersistenceMedium(pviewState As Object) 'If Request.Form("__VIEWSTATE_KEY") IsNot Nothing Then Cache.Remove(Request.Form("__VIEWSTATE_KEY")) 'elimino la cachado anteriormente Dim VSKey As String = String.Format("VIEWSTATE_{0}_{1}_{2}", Session.SessionID, Request.Path, Date.Now.Ticks) 'Cache.Add(VSKey, pviewState, Nothing, Date.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.Default, Nothing) 'Store the ViewState on Cache diff --git a/Ashx/SIGGPS.ashx b/Ashx/SIGGPS.ashx index 93b689f28..f9736c0e1 100644 --- a/Ashx/SIGGPS.ashx +++ b/Ashx/SIGGPS.ashx @@ -1,4 +1,4 @@ -<%@ WebHandler Language="VB" Class="SIGGPS" %> +<%@ WebHandler Language="VB" Class="SIGGPS" %> Option Explicit On Option Strict On @@ -16,7 +16,9 @@ Public Class SIGGPS : Implements IHttpHandler, IRequiresSessionState If context.Request("metodo") IsNot Nothing Then Select Case context.Request("metodo") Case "getimginstalacion" - GetImgInstalacion(context) + GetImgInstalacion(context) + Case "EjecutarNotificaciones" + EjecutarNotificaciones(context) End Select ElseIf context.Request.InputStream IsNot Nothing Then Using reader As New StreamReader(context.Request.InputStream) @@ -64,6 +66,14 @@ Public Class SIGGPS : Implements IHttpHandler, IRequiresSessionState Return URLParametros End Function + Private Sub EjecutarNotificaciones(ByVal context As HttpContext) + Dim Retorno As String = "[]" + Using ObjGPS As New ClsSisNotificaciones + ObjGPS.ObtenerNotificaciones() + End Using + context.Response.Write(Retorno) + End Sub + Private Sub GetImgInstalacion(ByVal context As HttpContext) Dim params As String = Decripta(context.Request("r").ToString) Dim Parametros = Me.Parametros(params) diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index 38a671b26..37a12c668 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -310,9 +310,9 @@ Partial Class Bancos_ProveedoresAbonar ViewState("CveCuentaRetISR") = 0 End If - If UsuarioActual.CveEmpresa.Contiene(1, 4, 5, 7, 11, 12, 72, 80, 126, 119, 122) Then - rowComisiones.Visible = True - End If + 'If UsuarioActual.CveEmpresa.Contiene(1, 4, 5, 7, 11, 12, 72, 80, 126, 119, 122,145) Then + ' rowComisiones.Visible = True + 'End If IdCuenta = 0 CveCuentaB = 0 @@ -1506,16 +1506,16 @@ Partial Class Bancos_ProveedoresAbonar 'funcionalidad que toma el 100% del pago para acreditamiento de iva If TotalImporte = gvr.DataKey("Saldo").ToDecimal Then If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal + ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal - importeMX = gvr.DataKey("IVADeducible").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) + ImporteMovimiento = gvr.DataKey("IVA").ToDecimal + importeMX = gvr.DataKey("IVA").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal + ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal + ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) @@ -1528,79 +1528,16 @@ Partial Class Bancos_ProveedoresAbonar End If Else If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarDeducible").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarDeducible").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) - importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) - End If - ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) - importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) - - If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" - End If - TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) - - PorcentajeImpuesto = gvr.DataKey("PorcentajeIVA").ToDecimal - Dim IdCtaIVAXAcreditar As Integer = 0 - Dim IdCtaIVAAcreditable As Integer = 0 - - If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows.Count > 0 Then - IdCtaIVAXAcreditar = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAXAcreditar").ToString.ToEntero - IdCtaIVAAcreditable = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=PorcentajeImpuesto).Rows(0)("IdCtaIVAAcreditable").ToString.ToEntero - End If - IdCtaContable = If(IdCtaIVAAcreditable > 0, IdCtaIVAAcreditable, 0) - - If ImporteMovimiento <> 0 AndAlso ObjMov.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then - If ObjMov.DtResultados.Rows.Count > 0 Then - IdCtaContable = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditable").ToString.ToEntero - CveCuenta = ObjMov.DtResultados.Rows(0)("IdCuentaIVAAcreditableSIG").ToString.ToEntero - End If - End If - Case 280 'Iva Acreditado No Deducible - Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - If UsuarioActual.Empresa.Funcionalidad(521) = "1" Then - 'funcionalidad que toma el 100% del pago para acreditamiento de iva - If TotalImporte = gvr.DataKey("Saldo").ToDecimal Then - If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal - importeMX = ImporteMovimiento - ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal - importeMX = gvr.DataKey("IVANoDeducible").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) - ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal - importeMX = ImporteMovimiento * tipoCambioCompra - ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = gvr.DataKey("IVANoDeducible").ToDecimal - importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) - End If - ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) - importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) - - If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" - Else - ImporteMovimiento = 0 - importeMX = 0 - End If - Else - If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) - importeMX = ImporteMovimiento - ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) - importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) - ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) - importeMX = ImporteMovimiento * tipoCambioCompra - ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal - (gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagarNoDeducible").ToDecimal, gvr.DataKey("IVANoDeducible").ToDecimal * PorcentajePago) + ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) diff --git a/Compras/Compras.aspx.cs b/Compras/Compras.aspx.cs deleted file mode 100644 index 3d3c4cf25..000000000 --- a/Compras/Compras.aspx.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; - -public partial class Compras_Default : ClsPaginas -{ - protected void Page_Load(object sender, EventArgs e) - { - Alert(UsuarioActual.Nombre); - } -} \ No newline at end of file diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index aaf9f4043..6a563aae9 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -1618,7 +1618,7 @@ Partial Class Compras_Compras Private Function CargaFactura(CveFactura As Integer) As String Dim ObjeFacturas As New ClsCompras Dim RFC As String = "" - If ObjeFacturas.GetFacturas(CveFactura, "-1", Now.AddYears(-3), Now, "-1", "-1", -1, -1, -1, -1, UsuarioActual.CveEmpresa) AndAlso ObjeFacturas.DtResultados.Rows.Count > 0 Then + If ObjeFacturas.GetFacturas(CveFactura, "-1", Now.AddYears(-3), Now, "-1", "-1", -1, -1, -1, -1, "-1", UsuarioActual.CveEmpresa) AndAlso ObjeFacturas.DtResultados.Rows.Count > 0 Then Dim dr As DataRow = ObjeFacturas.DtResultados.Rows(0) ' no toma la cero, porque es el totalizador Dim XMLDoc As New XmlDocument diff --git a/Compras/Compras.rar b/Compras/Compras.rar deleted file mode 100644 index 4725afffd..000000000 Binary files a/Compras/Compras.rar and /dev/null differ diff --git a/Compras/Proveedores.aspx.vb b/Compras/Proveedores.aspx.vb index 01d316185..06cf44aa7 100644 --- a/Compras/Proveedores.aspx.vb +++ b/Compras/Proveedores.aspx.vb @@ -484,7 +484,7 @@ Partial Class Compras_Proveedores Private Function CargadeFactura(CveFactura As Integer) As Integer Dim ObjeFacturas As New ClsCompras - If ObjeFacturas.GetFacturas(CveFactura, "-1", Now.AddYears(-2), Now, "-1", "-1", -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then + If ObjeFacturas.GetFacturas(CveFactura, "-1", Now.AddYears(-2), Now, "-1", "-1", -1, -1, -1, -1, "-1", UsuarioActual.CveEmpresa) Then Dim XMLDoc As New XmlDocument Try diff --git a/Compras/eFacturas.aspx b/Compras/eFacturas.aspx index 5e3123081..a3b6472f7 100644 --- a/Compras/eFacturas.aspx +++ b/Compras/eFacturas.aspx @@ -154,6 +154,13 @@ +
  • Tipo Comprobante + + + + + +
  • diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb index 9ded18cff..683c2a728 100644 --- a/Compras/eFacturas.aspx.vb +++ b/Compras/eFacturas.aspx.vb @@ -673,7 +673,7 @@ Partial Class Compras_eFacturas End If Dim DtPagos As DataTable = Nothing Dim ObjDatos As New ClsCompras - If ObjDatos.GetFacturas(-1, Folio, FechaI, FechaF, RFC, Proveedor, DdlValidado.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, DdlClasificacionProv.SelectedValue.ToEntero, DdlCveTipoProveedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + If ObjDatos.GetFacturas(-1, Folio, FechaI, FechaF, RFC, Proveedor, DdlValidado.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, DdlClasificacionProv.SelectedValue.ToEntero, DdlCveTipoProveedor.SelectedValue.ToEntero, DdlTipoComprobante.SelectedValue.ToString, UsuarioActual.CveEmpresa) Then If ObjDatos.DtResultados.Rows.Count > 0 Then GvD.DataSource = ObjDatos.DtResultados.FiltraParametros("TipoComprobante <> 'P'") '.AsEnumerable().Take(100).CopyToDataTable() DtPagos = ObjDatos.DtResultados.FiltraParametros("TipoComprobante = 'P'") @@ -1246,7 +1246,7 @@ Partial Class Compras_eFacturas Dim Folio = If(TxtFolio.Text.Trim.Length > 0, String.Format("%{0}%", TxtFolio.Text.Trim.ToUpper), "-1") Dim Proveedor = If(TxtProveedor.Text.Trim.Length > 0, String.Format("%{0}%", TxtProveedor.Text.Trim.ToUpper.Replace(" ", "%")), "-1") - If ObjDatos.GetFacturas(-1, Folio, txtFechaI.Text.Trim.ToDate, txtFechaF.Text.Trim.ToDate, "-1", Proveedor, DdlValidado.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, DdlClasificacionProv.SelectedValue.ToEntero, DdlCveTipoProveedor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + If ObjDatos.GetFacturas(-1, Folio, txtFechaI.Text.Trim.ToDate, txtFechaF.Text.Trim.ToDate, "-1", Proveedor, DdlValidado.SelectedValue.ToEntero, DdlResponsable.SelectedValue.ToEntero, DdlClasificacionProv.SelectedValue.ToEntero, DdlCveTipoProveedor.SelectedValue.ToEntero, DdlTipoComprobante.SelectedValue.ToString, UsuarioActual.CveEmpresa) Then Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) diff --git a/Contabilidad/RepIVA.aspx b/Contabilidad/RepIVA.aspx index 86d3b36c2..cd25184a0 100644 --- a/Contabilidad/RepIVA.aspx +++ b/Contabilidad/RepIVA.aspx @@ -117,6 +117,7 @@ + diff --git a/Sistemas/SessionesActivas.aspx.vb b/Sistemas/SessionesActivas.aspx.vb index 169069e5d..d75f57267 100644 --- a/Sistemas/SessionesActivas.aspx.vb +++ b/Sistemas/SessionesActivas.aspx.vb @@ -16,13 +16,13 @@ Partial Class SessionesActivas End Property Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then - - Dim listacve As New List(Of String) - listacve.Add("1815") - Notificaciones.AlertaVentana("notificacion", listacve, timeoutseconds:=0) - - RCveUsuario = "0" - ClsSisNotificaciones.SendNotificacionERP(100, "Titulo", "Hola Mundo", 1) + + ' Dim listacve As New List(Of String) + ' listacve.Add("1815") + ' Notificaciones.AlertaVentana("notificacion", listacve, timeoutseconds:=0) + + ' RCveUsuario = "0" + 'ClsSisNotificaciones.SendNotificacionERP(100, "Titulo", "Hola Mundo", 1) CargaDatos("") End If End Sub diff --git a/Ventas/RepConciliacionEmitidosSat.aspx b/Ventas/RepConciliacionEmitidosSat.aspx index 2e7772fdc..9be90a3db 100644 --- a/Ventas/RepConciliacionEmitidosSat.aspx +++ b/Ventas/RepConciliacionEmitidosSat.aspx @@ -98,10 +98,11 @@ <%-- --%> - + - + r + diff --git a/Ventas/RepConciliacionEmitidosSat.aspx.cs b/Ventas/RepConciliacionEmitidosSat.aspx.cs index 94dc209c0..649c309c0 100644 --- a/Ventas/RepConciliacionEmitidosSat.aspx.cs +++ b/Ventas/RepConciliacionEmitidosSat.aspx.cs @@ -24,6 +24,7 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas DdlSubProyectoDatos.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True "); DdlSubProyectoDatos.DataBind(); DdlClasificacion.DataSource = get_GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion: 1).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby: "Clasificacion"); + DdlClasificacion.DataBind(); @@ -43,98 +44,184 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas DdlPS.setEsWebService(false); DdlPS.ddl.DataSource = get_GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion: CveClasificacion, Estatus: 1, AplicaParaVenta: 1); DdlPS.ddl.DataBind(); - } + } } } protected void CargaConciliacionemitidasSATGet() { ClsVentas ObjV = new ClsVentas(); ObjV.ConciliacionemitidasSATGet(UsuarioActual.CveEmpresa); - GVConciliacionemitidasSAT.DataSource = ObjV.DtResultados; + GVConciliacionemitidasSAT.DataSource = ObjV.DtResultados.FiltraParametros("", "CveVenta"); ObjV.Dispose(); GVConciliacionemitidasSAT.DataBind(); UpDatosReporte.Update(); + + } + private void registrarventa(GridViewRow gvrow) + { + + { + + string ruta = gvrow.DataKey("RutaXml"); + strErrores = new StringBuilder(); + XmlSatCFDI objxml = null; + Modelos.Factura objfact = null; + bool continuar = true; + objxml = XmlSatCFDI.readXML(ruta); + continuar = continuar && (objxml != null); + if (continuar) + { + + objfact = GetFacturaFromXML(objxml); + } + continuar = continuar && (objfact != null); + if (continuar) + { + + // Dim As New (ObjVentas.IniciaTransacSQL()) + // Dim As = Nothing + // Dim MensajeAlert = New StringBuilder + ClsVentas ObjVentas = new ClsVentas(); + ClsInventarios ObjInventario = new ClsInventarios(ObjVentas.IniciaTransacSQL()); + ClsContabilidad ObjConta = new ClsContabilidad(ObjVentas.IniciaTransacSQL()); + ClsContratos ObjContr = new ClsContratos(ObjVentas.IniciaTransacSQL()); + ClsOS ObjOS = new ClsOS(ObjVentas.IniciaTransacSQL()); + ClsBancos ObjBancos = new ClsBancos(ObjVentas.IniciaTransacSQL()); + ClsClientes ObjClientes = new ClsClientes(ObjVentas.IniciaTransacSQL()); + ClsOIEventos ObjEventos = new ClsOIEventos(ObjVentas.IniciaTransacSQL()); + ClsCGame ObjCGame = new ClsCGame(ObjVentas.IniciaTransacSQL()); + ClsEdocumentacion ObjDocCliente = new ClsEdocumentacion(ObjVentas.IniciaTransacSQL()); + ClsAcumuladores ObjAcum = new ClsAcumuladores(ObjVentas.IniciaTransacSQL()); + ClsContPAQi ObjContPaq = null; + //StringBuilder MensajeAlert = new StringBuilder() ; + try + { + objfact.GuardarVenta(ref objfact, ref ObjVentas, ref ObjConta, ref ObjInventario, ref ObjContr, ref objfact.DtDetalle, objfact.CveNCaVincular, ref ObjContPaq, ref ObjBancos, ref ObjOS, ref ObjEventos, ref ObjCGame, ref ObjClientes, ObjAcum: ObjAcum); + + } + catch (Exception) + { + objfact.CveVenta = -1; + } + if (ObjVentas.UpdateEstatusFactura(3, objxml.complemento.UUID, "", DateTime.ParseExact(objxml.comprobante.Fecha.Replace("T", " "), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture), ObjVentas.CveVenta, CvePAC: 4)) + if (objfact.CveVenta > 0 && objfact.ErrorList.Count == 0) + { + ObjVentas.Commit(); + } + else + { + foreach (string item in objfact.ErrorList) + { + strErrores.AppendLine("
    "); + strErrores.AppendLine(item); + } + objfact.CveVenta = -1; + ObjVentas.RollBack(); + } + ObjVentas.Dispose(); + ObjConta.Dispose(); + ObjInventario.Dispose(); + ObjCGame.Dispose(); + ObjContr.Dispose(); + ObjDocCliente.Dispose(); + ObjClientes.Dispose(); + ObjAcum.Dispose(); + + } + if (objfact != null && objfact.CveVenta > 0) + { + CargaConciliacionemitidasSATGet(); + Alert($"se ha agregado la factura correctamente.
    Ver Factura ", ModExtensiones.TipoMensaje.ToastInformacion, timeout: 25); + } + else { continuar = false; } + if (!continuar) + { + Alert($"no se pudo agregar la factura {strErrores.ToString()}", ModExtensiones.TipoMensaje.MsgAdvertencia); + } + } + } protected void LnkRegistrar_Click(object sender, EventArgs e) { GridViewRow gvrow = (GridViewRow)(((LinkButton)sender).NamingContainer); - string ruta = gvrow.DataKey("RutaXml"); - strErrores = new StringBuilder(); - XmlSatCFDI objxml = null; - Modelos.Factura objfact = null; - bool continuar = true; - objxml = XmlSatCFDI.readXML(ruta); - continuar = continuar && (objxml != null); - if (continuar) - { + registrarventa(gvrow); + //string ruta = gvrow.DataKey("RutaXml"); + //strErrores = new StringBuilder(); + //XmlSatCFDI objxml = null; + //Modelos.Factura objfact = null; + //bool continuar = true; + //objxml = XmlSatCFDI.readXML(ruta); + //continuar = continuar && (objxml != null); + //if (continuar) + //{ - objfact = GetFacturaFromXML(objxml); - } - continuar = continuar && (objfact != null); - if (continuar) - { + // objfact = GetFacturaFromXML(objxml); + //} + //continuar = continuar && (objfact != null); + //if (continuar) + //{ - // Dim As New (ObjVentas.IniciaTransacSQL()) - // Dim As = Nothing - // Dim MensajeAlert = New StringBuilder - ClsVentas ObjVentas = new ClsVentas(); - ClsInventarios ObjInventario = new ClsInventarios(ObjVentas.IniciaTransacSQL()); - ClsContabilidad ObjConta = new ClsContabilidad(ObjVentas.IniciaTransacSQL()); - ClsContratos ObjContr = new ClsContratos(ObjVentas.IniciaTransacSQL()); - ClsOS ObjOS = new ClsOS(ObjVentas.IniciaTransacSQL()); - ClsBancos ObjBancos = new ClsBancos(ObjVentas.IniciaTransacSQL()); - ClsClientes ObjClientes = new ClsClientes(ObjVentas.IniciaTransacSQL()); - ClsOIEventos ObjEventos = new ClsOIEventos(ObjVentas.IniciaTransacSQL()); - ClsCGame ObjCGame = new ClsCGame(ObjVentas.IniciaTransacSQL()); - ClsEdocumentacion ObjDocCliente = new ClsEdocumentacion(ObjVentas.IniciaTransacSQL()); - ClsAcumuladores ObjAcum = new ClsAcumuladores(ObjVentas.IniciaTransacSQL()); - ClsContPAQi ObjContPaq = null; - //StringBuilder MensajeAlert = new StringBuilder() ; - try - { - objfact.GuardarVenta(ref objfact, ref ObjVentas, ref ObjConta, ref ObjInventario, ref ObjContr, ref objfact.DtDetalle, objfact.CveNCaVincular, ref ObjContPaq, ref ObjBancos, ref ObjOS, ref ObjEventos, ref ObjCGame, ref ObjClientes, ObjAcum: ObjAcum); + // // Dim As New (ObjVentas.IniciaTransacSQL()) + // // Dim As = Nothing + // // Dim MensajeAlert = New StringBuilder + // ClsVentas ObjVentas = new ClsVentas(); + // ClsInventarios ObjInventario = new ClsInventarios(ObjVentas.IniciaTransacSQL()); + // ClsContabilidad ObjConta = new ClsContabilidad(ObjVentas.IniciaTransacSQL()); + // ClsContratos ObjContr = new ClsContratos(ObjVentas.IniciaTransacSQL()); + // ClsOS ObjOS = new ClsOS(ObjVentas.IniciaTransacSQL()); + // ClsBancos ObjBancos = new ClsBancos(ObjVentas.IniciaTransacSQL()); + // ClsClientes ObjClientes = new ClsClientes(ObjVentas.IniciaTransacSQL()); + // ClsOIEventos ObjEventos = new ClsOIEventos(ObjVentas.IniciaTransacSQL()); + // ClsCGame ObjCGame = new ClsCGame(ObjVentas.IniciaTransacSQL()); + // ClsEdocumentacion ObjDocCliente = new ClsEdocumentacion(ObjVentas.IniciaTransacSQL()); + // ClsAcumuladores ObjAcum = new ClsAcumuladores(ObjVentas.IniciaTransacSQL()); + // ClsContPAQi ObjContPaq = null; + // //StringBuilder MensajeAlert = new StringBuilder() ; + // try + // { + // objfact.GuardarVenta(ref objfact, ref ObjVentas, ref ObjConta, ref ObjInventario, ref ObjContr, ref objfact.DtDetalle, objfact.CveNCaVincular, ref ObjContPaq, ref ObjBancos, ref ObjOS, ref ObjEventos, ref ObjCGame, ref ObjClientes, ObjAcum: ObjAcum); - } - catch (Exception ) - { - objfact.CveVenta = -1; - } - if (ObjVentas.UpdateEstatusFactura(3, objxml.complemento.UUID, "", DateTime.ParseExact(objxml.comprobante.Fecha.Replace("T", " "), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture), ObjVentas.CveVenta, CvePAC: 4)) - if (objfact.CveVenta > 0 && objfact.ErrorList.Count == 0) - { - ObjVentas.Commit(); - } - else - { - foreach (string item in objfact.ErrorList) - { - strErrores.AppendLine("
    "); - strErrores.AppendLine(item); - } - objfact.CveVenta = -1; - ObjVentas.RollBack(); - } - ObjVentas.Dispose(); - ObjConta.Dispose(); - ObjInventario.Dispose(); - ObjCGame.Dispose(); - ObjContr.Dispose(); - ObjDocCliente.Dispose(); - ObjClientes.Dispose(); - ObjAcum.Dispose(); + // } + // catch (Exception ) + // { + // objfact.CveVenta = -1; + // } + // if (ObjVentas.UpdateEstatusFactura(3, objxml.complemento.UUID, "", DateTime.ParseExact(objxml.comprobante.Fecha.Replace("T", " "), "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture), ObjVentas.CveVenta, CvePAC: 4)) + // if (objfact.CveVenta > 0 && objfact.ErrorList.Count == 0) + // { + // ObjVentas.Commit(); + // } + // else + // { + // foreach (string item in objfact.ErrorList) + // { + // strErrores.AppendLine("
    "); + // strErrores.AppendLine(item); + // } + // objfact.CveVenta = -1; + // ObjVentas.RollBack(); + // } + // ObjVentas.Dispose(); + // ObjConta.Dispose(); + // ObjInventario.Dispose(); + // ObjCGame.Dispose(); + // ObjContr.Dispose(); + // ObjDocCliente.Dispose(); + // ObjClientes.Dispose(); + // ObjAcum.Dispose(); - } - if (objfact != null && objfact.CveVenta > 0) - { - CargaConciliacionemitidasSATGet(); - Alert($"se ha agregado la factura correctamente.
    Ver Factura ", ModExtensiones.TipoMensaje.MsgInformacion); - } - else { continuar = false; } - if (!continuar) - { - Alert($"no se pudo agregar la factura {strErrores.ToString()}", ModExtensiones.TipoMensaje.MsgAdvertencia); - } + //} + //if (objfact != null && objfact.CveVenta > 0) + //{ + // CargaConciliacionemitidasSATGet(); + // Alert($"se ha agregado la factura correctamente.
    Ver Factura ", ModExtensiones.TipoMensaje.ToastInformacion,timeout:25); + //} + //else { continuar = false; } + //if (!continuar) + //{ + // Alert($"no se pudo agregar la factura {strErrores.ToString()}", ModExtensiones.TipoMensaje.MsgAdvertencia); + //} } protected Modelos.Factura GetFacturaFromXML(XmlSatCFDI objxml) @@ -388,11 +475,17 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas Row["CveTipoPS"] = DrPS["CveTipoPS"]; Row["CveTipoInvPS"] = DrPS["Inv_CveMetodoInventario"]; Row["CveTamaño"] = DrPS["CveTamaño"]; - ADSistemaLibrary.SatXml.CFDIConceptoImpuesto impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "002" && x.Impuesto == "Traslado"); + ADSistemaLibrary.SatXml.CFDIConceptoImpuesto impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "002" && x.Tipo == "Traslado"); + decimal sumaimpuesto=0; + decimal PorcentajeIVA = 0; if (impuesto != null) { - Row["PorcentajeIVA"] = impuesto.TasaOCuota; - Row["ImporteIVA"] = impuesto.Importe; + decimal decimpuesto = 0; + decimal.TryParse(impuesto.TasaOCuota, out decimpuesto); + PorcentajeIVA = decimpuesto/100; + Row["PorcentajeIVA"] = decimpuesto / 100; + Row["ImporteIVA"] = decimpuesto / 100;// impuesto.Importe;//Math.Round(item.Importe * (decimpuesto/100), 2); + sumaimpuesto += impuesto.Importe; } else { @@ -400,12 +493,15 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas Row["ImporteIVA"] = 0; } Row["IVA"] = Row["PorcentajeIVA"]; - impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "003" && x.Impuesto == "Traslado"); + impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "003" && x.Tipo == "Traslado"); if (impuesto != null) { - Row["PorcentajeIEPS"] = impuesto.TasaOCuota; + decimal decimpuesto = 0; + decimal.TryParse(impuesto.TasaOCuota, out decimpuesto); + Row["PorcentajeIEPS"] = decimpuesto / 100; Row["ImporteIEPS"] = impuesto.Importe; Row["IEPS"] = impuesto.Importe; + sumaimpuesto += impuesto.Importe; } else { @@ -413,22 +509,28 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas Row["ImporteIEPS"] = 0; Row["IEPS"] = 0; } - impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "001" && x.Impuesto == "Retencion"); + impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "001" && x.Tipo == "Retencion"); if (impuesto != null) { + decimal decimpuesto = 0; + decimal.TryParse(impuesto.TasaOCuota, out decimpuesto); + Row["PorcentajeRetISR"] = decimpuesto / 100; Row["ImporteRetISR"] = impuesto.Importe; - Row["PorcentajeRetISR"] = impuesto.TasaOCuota; + sumaimpuesto -= impuesto.Importe; } else { Row["ImporteRetISR"] = 0; Row["PorcentajeRetISR"] = 0; } - impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "002" && x.Impuesto == "Retencion"); + impuesto = item.Impuestos.FirstOrDefault(x => x.Impuesto == "002" && x.Tipo == "Retencion"); if (impuesto != null) { + decimal decimpuesto = 0; + decimal.TryParse(impuesto.TasaOCuota, out decimpuesto); + Row["PorcentajeRetIVA"] = decimpuesto / 100; Row["ImporteRetIVA"] = impuesto.Importe; - Row["PorcentajeRetIVA"] = impuesto.TasaOCuota; + sumaimpuesto -= impuesto.Importe; } else { @@ -438,7 +540,8 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas Row["Descuento"] = item.Descuento; Row["TipoDescuento"] = "2"; - Row["Total"] = item.Importe; + //Row["Total"] = item.Importe - sumaimpuesto; + Row["Total"] = item.Importe /(1+ PorcentajeIVA); Row["TotalImporte"] = item.Importe; Row["SATClaveProdServ"] = item.ClaveProdServ; @@ -468,6 +571,11 @@ public partial class Ventas_RepConciliacionEmitidosSat : ClsPaginas protected void LnkAceptarDefault_Click(object sender, EventArgs e) { RegistraScript("$('#DModalDefaults').modal('hide');"); + //foreach (GridViewRow gvrow in GVConciliacionemitidasSAT.Rows) + //{ + + // registrarventa(gvrow); + //} } } /* diff --git a/Ventas/RepVentasUtilidad.aspx.vb b/Ventas/RepVentasUtilidad.aspx.vb index 9b9a2dabf..6be403b27 100644 --- a/Ventas/RepVentasUtilidad.aspx.vb +++ b/Ventas/RepVentasUtilidad.aspx.vb @@ -41,6 +41,8 @@ Partial Class Ventas_RepVentasUtilidad Dim EsWS = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False) If EsWS Then DdlClientes.setEsWebService(True) + DdlClientes.SelectedValue = "-1" + DdlClientes.SelectedText = "Todos" Else DdlClientes.setEsWebService(False) DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) diff --git a/Ventas/RepVentasUtilidadDetalle.aspx b/Ventas/RepVentasUtilidadDetalle.aspx index a799a547c..359d5a7be 100644 --- a/Ventas/RepVentasUtilidadDetalle.aspx +++ b/Ventas/RepVentasUtilidadDetalle.aspx @@ -260,6 +260,16 @@ + + Dias Emision:  + + + + Dias Vencimiento:  + + + + diff --git a/Ventas/RepVentasUtilidadDetalle.aspx.vb b/Ventas/RepVentasUtilidadDetalle.aspx.vb index 2542a39d8..d16c9c28b 100644 --- a/Ventas/RepVentasUtilidadDetalle.aspx.vb +++ b/Ventas/RepVentasUtilidadDetalle.aspx.vb @@ -181,6 +181,8 @@ Partial Class Ventas_RepVentasUtilidadDetalle If ObjVentas.DtResultados.Rows.Count > 0 Then CveMovimiento = ObjVentas.DtResultados.Rows(1)("CveMovimiento").ToString.ToEntero + LblDiasVencimiento.Text = ObjVentas.DtResultados.Rows(1)("DiasVencimiento").ToString + LblDiasEmision.Text = ObjVentas.DtResultados.Rows(1)("DiasEmision").ToString LblCostoFecha.Text = "$" + ObjVentas.Costo.ToString("N2") HLCostoFolio.Text = ObjVentas.FolioCosto LblFechaSalid.Text = ObjVentas.FechaSalidaCosto.ToDate.ToShortDateString diff --git a/Ventas/RepVentasUtilidadPadre.aspx.vb b/Ventas/RepVentasUtilidadPadre.aspx.vb index 83458643a..8719b0036 100644 --- a/Ventas/RepVentasUtilidadPadre.aspx.vb +++ b/Ventas/RepVentasUtilidadPadre.aspx.vb @@ -44,8 +44,10 @@ Partial Class Ventas_RepVentasUtilidadPadre txtFechaF.Text = Now.LastDayOfMonth.ToShortDateString 'Carga Clientes - If UsuarioActual.CveEmpresa = 119 Then + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1" Then DdlClientesWS.setEsWebService(True) + DdlClientesWS.SelectedValue = "-1" + DdlClientesWS.SelectedText = "Todos" Else DdlClientesWS.setEsWebService(False) DdlClientesWS.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 1aa78c8f2..8f60dce37 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -10,8 +10,8 @@ Imports System.Security.Cryptography.X509Certificates Imports System.Globalization Partial Class Ventas - Inherits ClsPaginas - + Inherits ClsPaginas + #Region "Propiedades" Private Const NumeroDecimales As Integer = 2 @@ -1132,12 +1132,12 @@ Partial Class Ventas Set(value As Integer) ViewState("CveEstatusRefacturacion") = value End Set - End Property - + End Property + #End Region - + #Region "Propiedades PuntoVenta" - + Private Property CveCorte As Integer Get Return ViewState("CveCorte").ToString.ToEntero @@ -1178,10 +1178,10 @@ Partial Class Ventas Get Return ViewState("CveCicloComercial").ToString.ToEntero End Get - End Property - + End Property + #End Region - + #Region "Propiedades Contratos" Private Property DtContratos As DataTable Get @@ -1270,10 +1270,10 @@ Partial Class Ventas Set(value As Integer) ViewState("LimitaCantidadSerieLote") = value End Set - End Property - + End Property + #End Region - + #Region " PROPIEDADES NUEVAS | GUARDAR - IMPRESION " Private Property ErrorList As List(Of String) Get @@ -1306,9 +1306,9 @@ Partial Class Ventas Set(value As Modelos.Factura) ViewState("ObjFacturaDevolucion") = value End Set - End Property + End Property #End Region - + #Region " PROPIEDADES NUEVAS " Private Property CveOC As Integer Get @@ -1588,13 +1588,13 @@ Partial Class Ventas Set(value As Boolean) ViewState("SeCancelaRemisionProceso") = value End Set - End Property - - + End Property + + #End Region - + #Region " A C U M U L A D O R E S" - + Private Property ClienteEsDistribuidor As Boolean Get If ViewState("ClienteEsDistribuidor") Is Nothing Then @@ -1606,11 +1606,11 @@ Partial Class Ventas Set(value As Boolean) ViewState("ClienteEsDistribuidor") = value End Set - End Property - - + End Property + + #End Region - + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then Modalidad = "" @@ -2453,8 +2453,8 @@ Partial Class Ventas Case 119 TxtObsPS.Attributes.Add("onkeypress", "setFocus(event,'TxtPrecio');") End Select - End Sub - + End Sub + #Region "Punto Venta" Private Sub CargaCorteCaja() 'Checar si hay un Turno Abierto @@ -2640,9 +2640,9 @@ Partial Class Ventas End Sub Protected Sub LkbRetiro_Click(sender As Object, e As EventArgs) CargaIngresoEgreso(0) - End Sub + End Sub #End Region - + #Region "Contratos" Private Sub PresionarBotonModal(Boton As String) Try @@ -3211,9 +3211,9 @@ Partial Class Ventas DdlContratosOC.SelectedValue = DdlContratosModal.SelectedValue UPOCFactura.Update() - End Sub + End Sub #End Region - + #Region "C A R G A S" Private Sub ClasificacionModal() DdlClasificacionModal.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") @@ -5103,10 +5103,12 @@ Partial Class Ventas End If If CveVenta <= 0 Then - CveMetodoPagoCliente = ObjCliente.DtResultados.Rows(0)("CveMetodoPago").ToString.ToEntero + CveMetodoPagoCliente = ObjCliente.DtResultados.Rows(0)("CveMetodoPago").ToString.ToEntero + + DdlMetodoPago33.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveMetodoPago33").ToString) + DdlMetodoPago33_SelectedIndexChanged(DdlMetodoPago33, EventArgs.Empty) DdlFormaPago33.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveFormaPago33").ToString) - DdlMetodoPago33.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveMetodoPago33").ToString) DdlUsoCFDI.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveUsoCFDI").ToString) End If @@ -5131,10 +5133,12 @@ Partial Class Ventas PlazoCobranza = ObjCliente.PlazoCobranza If CveVenta <= 0 Then - CveMetodoPagoCliente = ObjCliente.CveMetodoPago + CveMetodoPagoCliente = ObjCliente.CveMetodoPago + + DdlMetodoPago33.SelectedValueExist(ObjCliente.CveMetodoPago33) + DdlMetodoPago33_SelectedIndexChanged(DdlMetodoPago33, EventArgs.Empty) DdlFormaPago33.SelectedValueExist(ObjCliente.CveFormaPago33) - DdlMetodoPago33.SelectedValueExist(ObjCliente.CveMetodoPago33) DdlUsoCFDI.SelectedValueExist(ObjCliente.CveUsoCFDI) End If @@ -5287,11 +5291,11 @@ Partial Class Ventas DdlNCPSAnt.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC DdlNCPSAnt.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlNCPSAnt.DataBind() - End Sub + End Sub #End Region - + #Region "G R I D V I E W S" - + #Region "GvPS" Protected Sub GvPS_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvPS.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -5659,11 +5663,11 @@ Partial Class Ventas CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") UpContado.Update() - End Sub + End Sub #End Region - + #Region "GvINV" - + Private Sub GvInv_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvInv.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -5736,45 +5740,45 @@ Partial Class Ventas Dim Cantidad As Double = DirectCast(GvInv.Rows(e.RowIndex).FindControl("txtECantidad"), TextBox).Text.ToDouble DtInv.Rows.Item(e.RowIndex)("Cantidad") = Cantidad GvInv.DataSource = DtInv.FiltraParametros("CveTipoPS=2") - End Sub - - + End Sub + + #End Region - + #Region "GvInvNC" Protected Sub GvInvNCCheckClick(sender As Object, e As EventArgs) Dim chk As CheckBox = DirectCast(sender, CheckBox) Dim gvr As GridViewRow = DirectCast(chk.NamingContainer, GridViewRow) gvr.FCTextBox("Txtcantidad").Visible = chk.Checked UpINVNC.Update() - End Sub - - 'Private Function SubTotalFacturaVinNC() As Decimal *** ESTABA TRONANDO EN COMPU 11/01/17 *** - ' Dim retorno As Decimal = 0 - ' If GvInvNC.Rows.Count = 0 Then - ' Try - ' If Not IsNothing(DTFacNC) AndAlso DTFacNC.FiltraParametros(String.Format("CveVenta={0}", DdlNCFactura.SelectedValue)).Rows.Count > 0 Then - ' retorno = DTFacNC.FiltroPrimero(String.Format("CveVenta={0}", DdlNCFactura.SelectedValue))("SubTotal").ToString.ToDecimal - ' End If - ' Catch ex As Exception - - ' End Try - ' Else - ' For Each gvrow As GridViewRow In GvInvNC.Rows - ' Dim txt As TextBox = gvrow.FCTextBox("Txtcantidad") - ' If txt.Visible Then - ' retorno += txt.Text.ToDecimal * gvrow.DataKey("PU").ToString.ToDecimal - ' End If - ' Next - ' End If - - ' Return retorno - 'End Function - + End Sub + + 'Private Function SubTotalFacturaVinNC() As Decimal *** ESTABA TRONANDO EN COMPU 11/01/17 *** + ' Dim retorno As Decimal = 0 + ' If GvInvNC.Rows.Count = 0 Then + ' Try + ' If Not IsNothing(DTFacNC) AndAlso DTFacNC.FiltraParametros(String.Format("CveVenta={0}", DdlNCFactura.SelectedValue)).Rows.Count > 0 Then + ' retorno = DTFacNC.FiltroPrimero(String.Format("CveVenta={0}", DdlNCFactura.SelectedValue))("SubTotal").ToString.ToDecimal + ' End If + ' Catch ex As Exception + + ' End Try + ' Else + ' For Each gvrow As GridViewRow In GvInvNC.Rows + ' Dim txt As TextBox = gvrow.FCTextBox("Txtcantidad") + ' If txt.Visible Then + ' retorno += txt.Text.ToDecimal * gvrow.DataKey("PU").ToString.ToDecimal + ' End If + ' Next + ' End If + + ' Return retorno + 'End Function + #End Region - - - + + + #Region "GvConceptos" Protected Sub GvConceptos_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvConceptos.RowDeleting DTmpC.Rows.RemoveAt(e.RowIndex) @@ -5804,9 +5808,9 @@ Partial Class Ventas GvConceptos.DataSource = DTmpC GvConceptos.DataBind() - End Sub + End Sub #End Region - + #Region "GvFirma" Protected Sub GvFirmas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvFirmas.RowDataBound If e.Row.RowType = DataControlRowType.DataRow And Not e.Row.RowState = DataControlRowState.Edit Then @@ -5849,21 +5853,21 @@ Partial Class Ventas GvFirmas.DataSource = DTmpF GvFirmas.DataBind() - End Sub + End Sub #End Region - + #Region "GvIEPS" - 'Protected Sub GvIEPS_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvIEPS.RowDataBound - ' If e.Row.RowType = DataControlRowType.DataRow Then - ' e.Row.FCLiteral("LtlIEPS").Text = String.Format("IEPS ({0}):", If(e.Row.DBCampo("PorcentajeIEPS").ToDecimal = 0.03, "3%", If(e.Row.DBCampo("PorcentajeIEPS").ToDecimal = 0.06, "6%", If(e.Row.DBCampo("PorcentajeIEPS").ToDecimal = 0.07, "7%", "9%")))) - ' End If - 'End Sub + 'Protected Sub GvIEPS_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvIEPS.RowDataBound + ' If e.Row.RowType = DataControlRowType.DataRow Then + ' e.Row.FCLiteral("LtlIEPS").Text = String.Format("IEPS ({0}):", If(e.Row.DBCampo("PorcentajeIEPS").ToDecimal = 0.03, "3%", If(e.Row.DBCampo("PorcentajeIEPS").ToDecimal = 0.06, "6%", If(e.Row.DBCampo("PorcentajeIEPS").ToDecimal = 0.07, "7%", "9%")))) + ' End If + 'End Sub #End Region - + #End Region - + #Region " EMITIR IMPRIMIR - GUARDAR " - + Protected Sub BtnEmitirImprimir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnEmitirImprimir.Click EmitirImprimir() End Sub @@ -6150,11 +6154,15 @@ Partial Class Ventas End If End If + If GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) > 0 AndAlso ddlAlmacen.SelectedValue.ToEntero() <= 0 Then + Alert("Tiene que seleccionar un almacen", TipoMensaje.MsgAdvertencia) + Exit Sub + End If EmitirImprimirNew() - End Sub + End Sub #End Region - + #Region " NNNNEEEEEEEWWWWWW " Private Sub InicializaImprimirNew() Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/Factura.rdlc", UsuarioActual.Empresa.Ruta)) @@ -6661,7 +6669,7 @@ Partial Class Ventas If RefacturacionGeneroNC Then If Not IsNothing(ObjNC) AndAlso ObjNC.Count > 0 Then Dim ofa As Modelos.Factura = CType(ObjNC(0), Modelos.Factura) - SeTimbroNC = ObjTimbrado.TimbrarFactura(UsuarioActual, ofa) + SeTimbroNC = ObjTimbrado.TimbrarFactura(UsuarioActual, ofa) End If End If @@ -8461,9 +8469,9 @@ Partial Class Ventas TmpDTComplementosTimbrado.Rows.Add(Row2) - End Sub + End Sub #End Region - + #Region "Ordenes de Compra Sin Facurar" Private Sub CargaOCs() Dim ObjVentas As New ClsVentas @@ -8692,13 +8700,13 @@ Partial Class Ventas End Sub Private Sub BtnConsultarOC_Click(sender As Object, e As EventArgs) Handles BtnConsultarOC.Click CargaOCSinFacturar() - End Sub + End Sub #End Region - - - - - + + + + + #Region " GUARDAR - VENTA, PREPOLIZAS, INV, ESTIMACIONES, AC, NOTA DE CRÉDITO " Private Sub GuardarVenta(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, factura As Modelos.Factura, TmpDTDetalle As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing, ByRef Optional ObjCliente As ClsClientes = Nothing) @@ -8981,25 +8989,6 @@ Partial Class Ventas End If Next End If - - ElseIf AplicarVentaFacturada Then - '25/11/2017 SE VA A ELIMINAR, DIJO EL IPP - - 'If Not ObjVentas.UpdateVentaRemision(CveVenta, ObjFactura.CveVenta) Then - ' ErrorList.Add("Ocurrió un error al actualizar la remisión") - 'End If - - 'If Not ObjConta.TraspasarSaldosPrePolizas(CveVenta, ObjFactura.CveVenta, -1, ObjFactura.CvePrePoliza, 2) Then - ' ErrorList.Add("Ocurrió un error al traspasar los saldos de la remisión") - 'End If - - ''If Not ObjConta.CancelarPrePolizas(-1, CveVenta) Then - '' ErrorList.Add("Ocurrió un error al cancelar los saldos de la remisión") - ''End If - - 'If Not TraspasoAlmacen(ObjInventario, CveVenta, ObjConta, True, 9) Then - ' ErrorList.Add("Ocurrió un error al traspasar el almacen") - 'End If End If End If @@ -10251,147 +10240,152 @@ Partial Class Ventas End Function Private Function GuardarVentaInventarios(ObjInventario As ClsInventarios, ObjConta As ClsContabilidad, factura As Modelos.Factura) As Boolean Dim OcurrioError As Boolean = False - - If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") Then - - If GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) > 0 Then - - Dim CveAlmacen = ddlAlmacen.SelectedValue.ToEntero - Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, 3, factura.CveMoneda, factura.Fecha, -1, factura.CveUsuario, factura.CveEmpresa, -1, factura.CveVenta, -1, -1) - - If CveMovimientoInventario <= 0 Then - OcurrioError = True - ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
    Revise su factura y cualquier detalle comuníquese a Soporte Técnico") - Else - Dim Mensaje As String = "" - Dim i As Integer = 0 - Dim Cantidad As Double - Dim CveUnidad As Integer - Dim CveProducto As Integer - Dim Existencia As Double - 'Dim Pu As Double - 'DtInv.Clone() - - Dim DtEquivalencias As DataTable - - For Each Dr As DataRow In DtInv.Rows - If GvInv.Rows(i).FCCheckBox("cbInv").Checked Then - - CveProducto = Dr("CvePS").ToString.ToEntero - CveUnidad = Dr("CveUM").ToString.ToEntero - Cantidad = Dr("Cantidad").ToString.ToDouble - - If Dr("CveTipoInvPS").ToString.ToEntero = 5 And Dr("SerieLote").ToString = "" Then - OcurrioError = True - ErrorList.Add("Se deben especificar las Series de los productos de almacén") - Exit For - End If - - If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing") Then - Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, UsuarioActual.CveEmpresa, CveAlmacen, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) - If Existencia < Cantidad Then - OcurrioError = True - ErrorList.Add($"No cuenta con la cantidad suficiente en inventario del producto {Dr("CodigoPS")} .Cuenta con {Existencia.FormatoNumero(2)}.") - Exit For - End If - End If - - If UsuarioActual.CveEmpresa = 1 Then - DtEquivalencias = New DataTable - DtEquivalencias = GlobalDTProductosServiciosEquivalencias(CveProducto, -1) - Dim CveUnidadBase As Integer = DtEquivalencias.FiltroPrimeroValor("CveUM", "UnidadBase = 'True'").ToEntero - Dim drUMBase As DataRow = DtEquivalencias.FiltroPrimero("UnidadBase = 'True'") - - 'SI LA UNIDAD ACTUAL NO ES LA BASE SACA PROPORCION (EQUIVALENTE) - If CveUnidadBase <> CveUnidad Then - ' LO QUE PUSE LO QUE VALE UNIDAD BASE LO QUE VALE UNIDAD SELECCIONADA - Cantidad = Dr("Cantidad").ToString.ToDouble * drUMBase("Cantidad").ToString.ToDouble / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDouble - CveUnidad = CveUnidadBase - End If - End If - - If CveProducto > 0 Then - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, 0, -1, SerieLote:=Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then - OcurrioError = True - ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
    ") - Exit For - End If - Else - OcurrioError = True - ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
    ") - Exit For - End If - - End If - i = i + 1 - Next - - 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN - If Not OcurrioError Then - Dim DtCostos As DataTable = Nothing - Dim ValorInventario As Decimal = 0 - Dim TotalCosto As Decimal = 0 - If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) Then - DtCostos = ObjInventario.DtResultados - TotalCosto = DtCostos.SUMD("Total").RoundSQL - Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) - Dim IdCtaContable As Integer = 0 - Dim CveCuenta As Integer = 0 - If tmpCostos.Rows.Count > 0 Then - Dim TotalCostoAcumulado As Decimal = 0 - Dim cont As Integer = 1 - '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 = tmpCostos.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then - ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) - End If - - 'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString) - IdCtaContable = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - CveCuenta = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - If ValorInventario <> 0 Then - - If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, ValorInventario, factura.SerieFolio, 69, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveSubProyecto:=factura.CveSubProyecto, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta) Then - OcurrioError = True - End If - End If - cont += 1 - Next - End If - IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacen)).ToEntero - - If TotalCosto <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, True, TotalCosto, factura.SerieFolio, 68, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=factura.CveSubProyecto) Then - OcurrioError = True - End If - End If - - factura.Inv_CveMovimiento = CveMovimientoInventario - factura.Inv_ValorInventario = ValorInventario - - End If - End If - - - End If - - End If - - If RemisionesLista.Count > 0 Then - For Each CveRemision As Integer In RemisionesLista - 'El almacen general es el Primer Almacen de Material en la Sucursal - If Not TraspasoAlmacen(ObjInventario, CveRemision, ObjConta, True, 9) Then - OcurrioError = True - Exit For - End If - Next - End If - - End If + Try + + If UsuarioActual.Empresa.UsaInventarios AndAlso factura.TipoDocto.Contiene("Ing", "Egs", "Rem") Then + + If RemisionesLista.Count > 0 Then + For Each CveRemision As Integer In RemisionesLista + 'El almacen general es el Primer Almacen de Material en la Sucursal + If Not TraspasoAlmacen(ObjInventario, CveRemision, ObjConta, True, 9) Then + OcurrioError = True + Exit For + End If + Next + End If + + If GvInv.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("cbInv").Checked) > 0 Then + + Dim CveAlmacen = ddlAlmacen.SelectedValue.ToEntero + Dim CveMovimientoInventario As Integer = ObjInventario.AddMovimiento(CveAlmacen, 3, factura.CveMoneda, factura.Fecha, -1, factura.CveUsuario, factura.CveEmpresa, -1, factura.CveVenta, -1, -1) + + If CveMovimientoInventario <= 0 Then + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
    Revise su factura y cualquier detalle comuníquese a Soporte Técnico") + Else + Dim Mensaje As String = "" + Dim i As Integer = 0 + Dim Cantidad As Double + Dim CveUnidad As Integer + Dim CveProducto As Integer + Dim Existencia As Double + 'Dim Pu As Double + 'DtInv.Clone() + + Dim DtEquivalencias As DataTable + + For Each Dr As DataRow In DtInv.Rows + If GvInv.Rows(i).FCCheckBox("cbInv").Checked Then + + CveProducto = Dr("CvePS").ToString.ToEntero + CveUnidad = Dr("CveUM").ToString.ToEntero + Cantidad = Dr("Cantidad").ToString.ToDouble + + If Dr("CveTipoInvPS").ToString.ToEntero = 5 And Dr("SerieLote").ToString = "" Then + OcurrioError = True + ErrorList.Add("Se deben especificar las Series de los productos de almacén") + Exit For + End If + + If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing") Then + Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, UsuarioActual.CveEmpresa, CveAlmacen, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1) + If Existencia < Cantidad Then + OcurrioError = True + ErrorList.Add($"No cuenta con la cantidad suficiente en inventario del producto {Dr("CodigoPS")} .Cuenta con {Existencia.FormatoNumero(2)}.") + Exit For + End If + End If + + If UsuarioActual.CveEmpresa = 1 Then + DtEquivalencias = New DataTable + DtEquivalencias = GlobalDTProductosServiciosEquivalencias(CveProducto, -1) + Dim CveUnidadBase As Integer = DtEquivalencias.FiltroPrimeroValor("CveUM", "UnidadBase = 'True'").ToEntero + Dim drUMBase As DataRow = DtEquivalencias.FiltroPrimero("UnidadBase = 'True'") + + 'SI LA UNIDAD ACTUAL NO ES LA BASE SACA PROPORCION (EQUIVALENTE) + If CveUnidadBase <> CveUnidad Then + ' LO QUE PUSE LO QUE VALE UNIDAD BASE LO QUE VALE UNIDAD SELECCIONADA + Cantidad = Dr("Cantidad").ToString.ToDouble * drUMBase("Cantidad").ToString.ToDouble / DtEquivalencias.FiltraParametros(String.Format("CveUM = {0}", CveUnidad)).Rows(0)("Cantidad").ToString.ToDouble + CveUnidad = CveUnidadBase + End If + End If + + If CveProducto > 0 Then + If Not ObjInventario.AddMovimientoDetalle(CveMovimientoInventario, Cantidad, CveUnidad, CveProducto, 0, -1, SerieLote:=Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
    ") + Exit For + End If + Else + OcurrioError = True + ErrorList.Add("Ocurrió un error al agregar los Movimientos de salida al Inventario.
    ") + Exit For + End If + + End If + i = i + 1 + Next + + 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN + If Not OcurrioError Then + Dim DtCostos As DataTable = Nothing + Dim ValorInventario As Decimal = 0 + Dim TotalCosto As Decimal = 0 + If ObjInventario.GetMovimientosDetalle(CveMovimientoInventario, UsuarioActual.CveEmpresa) Then + DtCostos = ObjInventario.DtResultados + TotalCosto = DtCostos.SUMD("Total").RoundSQL + Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) + Dim IdCtaContable As Integer = 0 + Dim CveCuenta As Integer = 0 + If tmpCostos.Rows.Count > 0 Then + Dim TotalCostoAcumulado As Decimal = 0 + Dim cont As Integer = 1 + '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 = tmpCostos.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then + ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) + End If + + 'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString) + IdCtaContable = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + CveCuenta = GlobalDTClasificaciones(factura.CveEmpresa).FiltroPrimeroValor("IdCuentaGastoSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero + If ValorInventario <> 0 Then + + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, False, ValorInventario, factura.SerieFolio, 69, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveSubProyecto:=factura.CveSubProyecto, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=ValorInventario, CveCuenta:=CveCuenta) Then + OcurrioError = True + End If + End If + cont += 1 + Next + End If + IdCtaContable = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", String.Format("CveAlmacen = {0}", CveAlmacen)).ToEntero + + If TotalCosto <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(factura.CvePrePoliza, True, TotalCosto, factura.SerieFolio, 68, factura.SerieFolio, factura.Fecha, IdCtaContable, -1, CveVenta:=factura.CveVenta, CveCliente:=factura.CveCliente, CveMovimientoAlmacen:=CveMovimientoInventario, ImporteMX:=TotalCosto, CveCuenta:=CveCuenta, CveSubProyecto:=factura.CveSubProyecto) Then + OcurrioError = True + End If + End If + + factura.Inv_CveMovimiento = CveMovimientoInventario + factura.Inv_ValorInventario = ValorInventario + + End If + End If + + End If + + End If + + End If + + Catch ex As Exception + OcurrioError = True + OnError("Ocurrió un error al guardar el inventario", ex) + End Try Return OcurrioError End Function @@ -10675,9 +10669,9 @@ Partial Class Ventas End If Return ProcesoCorrecto - End Function + End Function #End Region - + #Region " VISTA PREVIA NEW " Private Sub VistaPreviaNew() @@ -10787,10 +10781,10 @@ Partial Class Ventas 'PdfFacturaPyME(ObjFactura, TmpDT) End If - End Sub - + End Sub + #End Region - + #Region "¡ P D F R E P O R T V I E W E R !" Private Sub GeneraPDFFactura(EnviaCorreo As Boolean) @@ -10937,10 +10931,10 @@ Partial Class Ventas ObjVentas.Dispose() End Try End If - End Sub - + End Sub + #End Region - + #Region " ANTICIPOS " Private Sub CargaAnticipos(CveCliente As Integer) @@ -11933,9 +11927,9 @@ Partial Class Ventas Return PrePolizaCorrecta - End Function + End Function #End Region - + #Region " BTN ELIMINAR " Protected Sub BtnEmitir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnEmitir.Click @@ -12051,9 +12045,9 @@ Partial Class Ventas ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" Then End If - End Sub + End Sub #End Region - + #Region " DESCUENTOS " Protected Sub BtnAplicarDescG_Click(sender As Object, e As System.EventArgs) Handles BtnAplicarDescG.Click If HdnTipoDescuento.Value = "2" Then @@ -12165,18 +12159,18 @@ Partial Class Ventas ObjBanco.Dispose() - End Sub + End Sub #End Region - - - + + + #Region " VISTA PREVIA " Protected Sub BtnVistaPrevia_Click(sender As Object, e As System.EventArgs) Handles BtnVistaPrevia.Click VistaPreviaNew() - End Sub - + End Sub + #End Region - + #Region "I M A G E - B U T T O N S" Protected Function CancelarMovimientoInventario(ByRef ObjInventario As ClsInventarios, ByRef ObjConta As ClsContabilidad, CveVentaNueva As Integer, CveVentaVieja As Integer) As Boolean @@ -12498,221 +12492,7 @@ Partial Class Ventas Return Not ErrorCancelar End Function - 'Protected Sub ImgGuardaEstatus_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImgGuardaEstatus.Click - ' '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 DdlTipoComprobante.SelectedValue = "Ant" AndAlso (HdnPagado.Value.ToDecimal > 0 Or GvAntNC.Rows.Count > 0) Then - ' Alert("La factura no se puede cancelar debido a que tiene pagos vinculados.", TipoMensaje.MsgAdvertencia) - ' Exit Sub - ' End If - - ' 'La validacion de saldos cuando es refacturacion se hace antes asi que si es refacturacion ignoramos esta condicion - ' If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem") AndAlso HdnPagado.Value.ToDecimal > 0 Then - ' Alert("La factura no se puede cancelar debido a que tiene pagos vinculados.", TipoMensaje.MsgAdvertencia) - ' Exit Sub - ' End If - - ' ' si tiene movimientos en almacen, y sigue sin ser marcado como devuelto - ' If (GvInv.Rows.Count > 0 AndAlso DevolucionAlmacen.Contiene(0, 1)) AndAlso DdlTipoComprobante.SelectedValue <> "Rem" Then - ' Alert("La factura no se puede cancelar debido a que tiene movimientos de inventario.", TipoMensaje.MsgAdvertencia) - ' Exit Sub - ' End If - - ' 'Si la remision esta facturada no se puede cancelar - ' If DdlTipoComprobante.SelectedValue = "Rem" Then - ' Dim ObjV As New ClsVentas - ' If ObjV.VerificarRemisionFacturada(CveVenta) Then - ' If ObjV.DtResultados.Rows.Count > 0 Then - ' Alert("La remisión no se puede cancelar debido a que ya esta vinculada a una factura.", TipoMensaje.MsgAdvertencia) - ' Exit Sub - ' End If - ' End If - ' ObjV.Dispose() - ' End If - - - ' Dim ObjVentas As New ClsVentas() : ObjVentas.IniciaTransacSQL() - ' Dim ObjAC As ClsContPAQi = Nothing - ' Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL()) - ' Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL()) - ' Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL()) - ' Dim ObjContratos As New ClsContratos(ObjVentas.IniciaTransacSQL()) - - ' Dim IDPoliza As Integer = -1 - ' Dim CvePrePoliza As Integer - ' Dim CvePlantillaPoliza As Integer - - ' Dim ErrorCancelar As Boolean = False - ' Dim Mensaje As String = "" - - ' CreaObjetosVenta() - ' If UsuarioActual.Empresa.UsaAC Then - ' ObjAC = New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL() - ' End If - - ' If GvInv.Rows.Count > 0 AndAlso DdlTipoComprobante.SelectedValue = "Rem" Then - ' If CveAlmacenTransitorio > 0 Then - ' ErrorCancelar = Not TraspasoAlmacen(ObjInventario, CveVenta, ObjConta, False, 9) - ' Else - ' ErrorCancelar = Not SalidaEntradaAlmacen(ObjInventario, CveVenta, ObjConta) - ' End If - ' End If - - ' If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then - ' CvePlantillaPoliza = 7 - ' ElseIf ObjFactura.TipoDocto.Contiene("Ing", "Rem", "Ant") Then - ' CvePlantillaPoliza = 4 - ' Else - ' CvePlantillaPoliza = 4 - ' End If - - ' ObjFactura.CveVenta = CveVenta - - ' If HplSaldoAuxiliar.Text.ToDecimal > 0 Then - ' CvePrePoliza = ObjConta.AddPrePolizas("Ventas/GuardaEstatus", CvePlantillaPoliza, TxtTotal.Text.ToDouble, TxtTotal.Text.Replace(",", "").ToDouble, DdlMoneda.SelectedValue.ToEntero, Now, NombreCliente, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - ' ObjFactura.CvePrePoliza = CvePrePoliza - - ' If Not ErrorCancelar Then - ' ErrorCancelar = ProcesoPrepolizas(ObjConta, ObjFactura, -1, TmpDT, ObjAC, -1, ObjBancos, ObjVentas) - ' End If - - ' If Not ErrorCancelar Then - ' ErrorCancelar = GuardarVentaImpuestosLocales(ObjVentas, ObjConta, ObjFactura, -1) - ' Else - ' Exit Sub - ' End If - ' End If - - ' 'Desvincular Remisiones - ' '[IPP] COMENTADO PORQUE UNA REMISION USADA SE QUEMA - DETALLES CON INV - 30/ENERO/2018 - ' 'If DdlTipoComprobante.SelectedValue = "Ing" Then - ' ' If Not ObjVentas.LiberarRemisionesFacturadas(CveVenta) Then - ' ' ErrorCancelar = True - ' ' Mensaje = "Ocurrió un error al desvincular las remisiones" - ' ' End If - ' 'End If - - ' 'Contratos - ' ErrorList = New List(Of String) - ' If ObjFactura.CveContrato > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") Then - ' GuardarContratoAvanceEstimaciones(ObjContratos, ObjFactura, ErrorList, -1, True) - ' If ErrorList.Count > 0 Then : ErrorCancelar = True : End If - ' ElseIf ObjFactura.CveContrato > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev") Then - ' GuardarContratoAvanceEstimaciones(ObjContratos, ObjFactura, ErrorList, 1, True) - ' If ErrorList.Count > 0 Then : ErrorCancelar = True : End If - ' End If - - ' If DdlEstatus.SelectedValue = "4" Then - - ' If ObjVentas.UpdateEstatusFactura(DdlEstatus.SelectedValue.ToEntero, FolioFiscal, "", Now, CveVenta, IDPoliza) Then - ' Mensaje = "El nuevo estatus se guardó correctamente" - ' Else - ' ErrorCancelar = True - ' End If - - ' 'Si se está mandando a Cancelada SAT - ' ElseIf DdlEstatus.SelectedValue = "5" Then - ' Try - ' Dim DT As DataTable = Nothing - - ' If FolioFiscal = "" Then - ' Dim XmlDoc As New XmlDocument - ' XmlDoc.Load(Ruta & "XML\" & DdlTipoComprobante.SelectedValue & "\" & VentaFolio & ".xml") - ' ViewState("FolioFiscal") = XmlDoc.DocumentElement("cfdi:Complemento").FirstChild.Attributes("UUID").InnerText - ' End If - - ' 'Si es cancelar en el SAT: - - ' 'Dim xmlDoc As New System.Xml.XmlDocument() - ' 'xmlDoc.LoadXml(Encoding.UTF8.GetString(Convert.FromBase64String("PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pgo8QWN1c2UgRmVjaGE9IjIwMTYtMTItMzBUMTg6Mjk6MjAuNTExOTg1NSIgUmZjRW1pc29yPSJNT1FKODUxMjE0SEs0IiB4bWxuczpuczI9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyMiIHhtbG5zOm5zMz0iaHR0cDovL2NhbmNlbGFjZmQuc2F0LmdvYi5teCI+CiAgICA8bnMzOkZvbGlvcz4KICAgICAgICA8bnMzOlVVSUQ+NjNBOEQxN0UtRDMxQi00QjVFLTkzMEEtMzdDNDJDRTFBM0M4PC9uczM6VVVJRD4KICAgICAgICA8bnMzOkVzdGF0dXNVVUlEPjIwMTwvbnMzOkVzdGF0dXNVVUlEPgogICAgPC9uczM6Rm9saW9zPgogICAgPG5zMjpTaWduYXR1cmUgSWQ9IlNlbGxvU0FUIj4KICAgICAgICA8bnMyOlNpZ25lZEluZm8+CiAgICAgICAgICAgIDxuczI6Q2Fub25pY2FsaXphdGlvbk1ldGhvZCBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnL1RSLzIwMDEvUkVDLXhtbC1jMTRuLTIwMDEwMzE1Ii8+CiAgICAgICAgICAgIDxuczI6U2lnbmF0dXJlTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8wNC94bWxkc2lnLW1vcmUjaG1hYy1zaGE1MTIiLz4KICAgICAgICAgICAgPG5zMjpSZWZlcmVuY2UgVVJJPSIiPgogICAgICAgICAgICAgICAgPG5zMjpUcmFuc2Zvcm1zPgogICAgICAgICAgICAgICAgICAgIDxuczI6VHJhbnNmb3JtIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvVFIvMTk5OS9SRUMteHBhdGgtMTk5OTExMTYiPgogICAgICAgICAgICAgICAgICAgICAgICA8bnMyOlhQYXRoPm5vdChhbmNlc3Rvci1vci1zZWxmOjoqW2xvY2FsLW5hbWUoKT0nU2lnbmF0dXJlJ10pPC9uczI6WFBhdGg+CiAgICAgICAgICAgICAgICAgICAgPC9uczI6VHJhbnNmb3JtPgogICAgICAgICAgICAgICAgPC9uczI6VHJhbnNmb3Jtcz4KICAgICAgICAgICAgICAgIDxuczI6RGlnZXN0TWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8wNC94bWxlbmMjc2hhNTEyIi8+CiAgICAgICAgICAgICAgICA8bnMyOkRpZ2VzdFZhbHVlPk8zNzJtbWlEMFZWWUdkcGE4WjJ5K3VPQXVVcTdZb3JURldicER3K2xnVG9CUng3c2RrREtlNDZKRjRaM01hZHZ2djh6bG9vZTYwRGtZUGZyRGNZMUZ3PT08L25zMjpEaWdlc3RWYWx1ZT4KICAgICAgICAgICAgPC9uczI6UmVmZXJlbmNlPgogICAgICAgIDwvbnMyOlNpZ25lZEluZm8+CiAgICAgICAgPG5zMjpTaWduYXR1cmVWYWx1ZT5IbEJVbHplZlZFKzFXNS9QKzRuVk9YbEFuOVZLQUladm0vK2tuSldSb2plTVI4Ung5bHBpTUdIOXBVZG5iVWtObTloOTZQSXQ4QzBFd0Z2UVptRjlCZz09PC9uczI6U2lnbmF0dXJlVmFsdWU+CiAgICAgICAgPG5zMjpLZXlJbmZvPgogICAgICAgICAgICA8bnMyOktleU5hbWU+MDAwMDEwODg4ODg4MDAwMDAwMTY8L25zMjpLZXlOYW1lPgogICAgICAgICAgICA8bnMyOktleVZhbHVlPgogICAgICAgICAgICAgICAgPG5zMjpSU0FLZXlWYWx1ZT4KICAgICAgICAgICAgICAgICAgICA8bnMyOk1vZHVsdXM+eG5MMnpEUHRINWpEc0FaRFRJZk1xYktHcnZlK0F0OEt5eDJFWnZiZlhicEs5dVZFeFdTODc0b01lbEZ6TnE2OS9ZcVNSZVQzSTdJOHdyK2pveTVPN291WkgrNEtXZElHcDRTaTZsSGUwa250eHpObXV1S3lPUGtKOXRNY250bkZtUTRiZnhGeGxnL1VkMmhDdHVveTNqMnhZa0lYdTVPNHBHTTk4Tno4cEFNPTwvbnMyOk1vZHVsdXM+CiAgICAgICAgICAgICAgICAgICAgPG5zMjpFeHBvbmVudD5BUUFCPC9uczI6RXhwb25lbnQ+CiAgICAgICAgICAgICAgICA8L25zMjpSU0FLZXlWYWx1ZT4KICAgICAgICAgICAgPC9uczI6S2V5VmFsdWU+CiAgICAgICAgPC9uczI6S2V5SW5mbz4KICAgIDwvbnMyOlNpZ25hdHVyZT4KPC9BY3VzZT4K"))) - - ' Dim ObjCancelacion As New Timbrado - ' Dim TotalT As Decimal = TxtTotal.Text.ToDecimal - ' Dim RFCReceptor As String = LblRFC.Text.Trim - ' Dim CvePACCancelacion As Integer = UsuarioActual.Empresa.CvePAC - ' ImprimeCancelacion(CveVenta) - - ' 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 - ' ' ImprimeCancelacion(CveVenta) - - ' If UsuarioActual.Empresa.UsaAC Then - ' IDPoliza = GenerarPolizaAC(ObjAC, True) - ' If IDPoliza <= 0 Then - ' Mensaje = "No se pudo generar la poliza" - ' ErrorCancelar = True - ' End If - ' End If - - ' If Not ErrorCancelar Then - ' If ObjVentas.UpdateEstatusFactura(DdlEstatus.SelectedValue.ToEntero, FolioFiscal, ObjCancelacion.CancelacionAcuse, ObjCancelacion.CancelacionFecha, CveVenta, IDPoliza, CvePAC:=CvePACCancelacion) Then - ' Mensaje = "El nuevo estatus se guardó correctamente" - - ' Else - ' ErrorCancelar = True - ' End If - ' End If - ' End If - - ' Catch ex As Exception - ' Mensaje = "Ocurrio un error al Cancelar la factura" - ' GuardaLog($"{ex.Message}") - ' End Try - - ' ElseIf DdlEstatus.SelectedValue = "9" Then - - ' If UsuarioActual.Empresa.UsaAC Then - ' IDPoliza = GenerarPolizaAC(ObjAC, True) - - ' If IDPoliza > 0 Then - ' Mensaje = "Se canceló exitosamente el compromiso." - ' Else - ' Mensaje = "No se pudo generar la poliza de cancelación" - ' ErrorCancelar = True - ' End If - - ' End If - - ' If Not ErrorCancelar Then - ' If Not ObjVentas.UpdateEstatusFactura(DdlEstatus.SelectedValue.ToEntero, "", "", TxtFecha.Text.ToDate, CveVenta, IDPoliza) Then - ' ErrorCancelar = True - ' End If - ' End If - - ' ElseIf DdlEstatus.SelectedValue = "12" Then - ' If ObjVentas.UpdateEstatusFactura(DdlEstatus.SelectedValue.ToEntero, FolioFiscal, "", Now, CveVenta, IDPoliza) Then - ' Mensaje = "Se canceló exitosamente la Remisión" - ' Else - ' ErrorCancelar = True - ' End If - ' Else - ' If ObjVentas.UpdateEstatusFactura(DdlEstatus.SelectedValue.ToEntero, FolioFiscal, "", Now, CveVenta, IDPoliza) Then - ' 'Alert("El nuevo estatus se guardó correctamente", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=" & CveVenta & """;") - ' Mensaje = "El nuevo estatus se guardó correctamente" - ' Else - ' ErrorCancelar = True - ' End If - ' End If - - - ' If Not ErrorCancelar Then - ' Alert(Mensaje, TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=" & CveVenta & """;") - ' ObjVentas.Commit() - ' If ObjAC IsNot Nothing Then ObjAC.Commit() - ' Else - ' Alert(Mensaje, TipoMensaje.MsgError) - ' ObjVentas.RollBack() - ' If ObjAC IsNot Nothing Then ObjAC.RollBack() - ' End If - - ' ObjVentas.Dispose() - ' ObjContratos.Dispose() - ' ObjConta.Dispose() - ' ObjBancos.Dispose() - ' ObjInventario.Dispose() - ' If ObjAC IsNot Nothing Then ObjAC.Dispose() - - 'End Sub Protected Sub ImgBtnAddC_Click(sender As Object, e As ImageClickEventArgs) Handles ImgBtnAddC.Click Dim Row As DataRow = Nothing Row = DTmpC.NewRow @@ -12745,9 +12525,9 @@ Partial Class Ventas GvFirmas.DataBind() UPFirmas.Update() tbTituloF.Focus() - End Sub + End Sub #End Region - + #Region "D R O P - D O W N - L I S T" Private Sub DdlPSIndexChange(CvePSParametro As Integer, Ddl As ADServerControl.Dropdownlost) @@ -13146,9 +12926,9 @@ Partial Class Ventas End Sub Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged CargaSubProyecto() - End Sub + End Sub #End Region - + #Region " SUCURSAL FACTURACION " Private Sub DdlSubProyectoDatos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSubProyectoDatos.SelectedIndexChanged CambiaSucursalGeneral() @@ -13315,9 +13095,9 @@ Partial Class Ventas If Not DdlVendedor.SelectedValue.ToEntero > 0 Then DdlVendedor.SelectedValueExist(UsuarioActual.CveVendedor.ToString) End If - End Sub + End Sub #End Region - + #Region " AGREGAR PS " Protected Sub LbAgregar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LbAgregar.Click AgregarPS() @@ -13901,10 +13681,10 @@ Partial Class Ventas Retorno = True Return Retorno - End Function - + End Function + #End Region - + #Region "D A T A - T A B L E S" Private Sub CreaDTVentas() TmpDT = New DataTable @@ -14030,44 +13810,44 @@ Partial Class Ventas TmpDTDocumentosRelacionados.Columns.Add("Fecha", GetType(String)) TmpDTDocumentosRelacionados.Columns.Add("Importe", GetType(Decimal)) TmpDTDocumentosRelacionados.Columns.Add("FolioFiscal", GetType(Integer)) - End Sub + End Sub #End Region - + #Region "P D F" - - + + #End Region - + #Region "A C T U A L I Z A " - + #Region "New" - 'Private Function ActualizaTimbrado(Timbro As Boolean, CveVenta As Integer) As Boolean - ' Dim Retorno = False - ' Dim ObjVentas As New ClsVentas() - - ' Retorno = ObjVentas.UpdateVentaTimbre(CBool(Timbro), CveVenta) - ' ObjVentas.Dispose() - - ' Return Retorno - 'End Function - 'Private Sub ActualizaCadenaOriginal(CadenaOriginal As String, CveVenta As Integer) - ' Dim ObjVentas As New ClsVentas() - ' ObjVentas.UpdateVentaCadenaOriginal(CadenaOriginal.ToString, CveVenta) - ' ObjVentas.Dispose() - 'End Sub - 'Private Sub ActualizaEstatus(CveEstatus As Integer, FolioFiscal As String, CveVenta As Integer) - ' Dim ObjVentas As New ClsVentas() - ' ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, "", Now, CveVenta) - ' ObjVentas.Dispose() - 'End Sub - 'Private Sub ActualizaCliente(NumCtaPago As String, MetodoDePago As Integer, CveCliente As Integer) - ' Dim ObjCliente As New ClsClientes - ' ObjCliente.UpdateClienteFactura(NumCtaPago, MetodoDePago, CveCliente, UsuarioActual.CveUsuario) - ' ObjCliente.Dispose() - 'End Sub + 'Private Function ActualizaTimbrado(Timbro As Boolean, CveVenta As Integer) As Boolean + ' Dim Retorno = False + ' Dim ObjVentas As New ClsVentas() + + ' Retorno = ObjVentas.UpdateVentaTimbre(CBool(Timbro), CveVenta) + ' ObjVentas.Dispose() + + ' Return Retorno + 'End Function + 'Private Sub ActualizaCadenaOriginal(CadenaOriginal As String, CveVenta As Integer) + ' Dim ObjVentas As New ClsVentas() + ' ObjVentas.UpdateVentaCadenaOriginal(CadenaOriginal.ToString, CveVenta) + ' ObjVentas.Dispose() + 'End Sub + 'Private Sub ActualizaEstatus(CveEstatus As Integer, FolioFiscal As String, CveVenta As Integer) + ' Dim ObjVentas As New ClsVentas() + ' ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, "", Now, CveVenta) + ' ObjVentas.Dispose() + 'End Sub + 'Private Sub ActualizaCliente(NumCtaPago As String, MetodoDePago As Integer, CveCliente As Integer) + ' Dim ObjCliente As New ClsClientes + ' ObjCliente.UpdateClienteFactura(NumCtaPago, MetodoDePago, CveCliente, UsuarioActual.CveUsuario) + ' ObjCliente.Dispose() + 'End Sub #End Region #End Region - + #Region "M E T O D O S" Private Sub CargaOtrosConceptos() Dim ObjVentas As New ClsVentas @@ -14840,107 +14620,121 @@ Partial Class Ventas End Sub Private Function TraspasoAlmacen(ByRef ObjInventario As ClsInventarios, CveRemision As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean - Dim OcurrioError As Boolean = False - Dim DtMovimientos As DataTable - Dim DtMovimientosDetalles As DataTable - DtRemConceptosSurtidos = Nothing - - 'Obtenemos los movimientos detalle - If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then - - If ObjInventario.DtResultados.Rows.Count > 0 Then - - DtMovimientos = ObjInventario.DtResultados.FiltraParametros("", DistinctColumns:={"CveMovimiento"}) - - 'Si estamos facturando remisiones ajustamos por ventadetalle - If RemisionesLista.Count > 0 Then - Dim resultados = From DtRemisiones In DtRemisionesTmpDT - Join DtMovDet In ObjInventario.DtResultados.FiltraParametros("CvePS > 0") On DtRemisiones("CveVentaDetalleRemision").ToString.ToEntero Equals DtMovDet("CveVentaDetalle").ToString.ToEntero - Select DtMovDet - Try - DtMovimientosDetalles = resultados.CopyToDataTable - Catch ex As Exception - GuardaLog($"LOG IPP: Ventas LN: 10033. - DtRemisionesTmpDT.Rows.Count: {DtRemisionesTmpDT.Rows.Count} - ObjInventario.DtResultados.FiltraParametros('CvePS > 0').Rows.Count: {ObjInventario.DtResultados.FiltraParametros("CvePS > 0").Rows.Count}") - DtMovimientosDetalles = New DataTable - End Try - Else - DtMovimientosDetalles = ObjInventario.DtResultados.FiltraParametros("CvePS > 0") - End If - - For Each dr As DataRow In DtMovimientos.Rows - - 'Obtenemos los Movimientos de salida - If ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, ConceptoMovimiento, -1, UsuarioActual.CveEmpresa) Then - - If ObjInventario.DtResultados.Rows.Count > 0 AndAlso DtMovimientosDetalles.Rows.Count > 0 Then - - Dim CveAlmacenSalida As Integer = ObjInventario.DtResultados(0)("CveAlmacen").ToString.ToEntero - Dim CveAlmacenEntrada As Integer = ObjInventario.DtResultados(0)("CveAlmacenRelacionado").ToString.ToEntero - Dim CveMoneda As Integer = ObjInventario.DtResultados(0)("CveMoneda").ToString.ToEntero - Dim CveTipoAlmacen As Integer = ObjInventario.DtResultados(0)("CveTipoAlmacen").ToString.ToEntero - - If (CveAlmacenEntrada > 0 AndAlso CveTipoAlmacen <> 1) Or RemisionesLista.Count = 0 Then 'Con remisiones parciales ignoramos las surtidas ya realizadas - - Dim MovDetalle As New DataTable - If RemisionesLista.Count > 0 Then - MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND TieneSalidaxFactura IS NULL")) - Else - MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}") - End If - - If ErrorList.Count = 0 Then - If MovDetalle.Rows.Count > 0 Then - Dim CveMovimientoSalidaPorTraspaso = -1 - - 'Le damos salida de apartado por traspaso - CveMovimientoSalidaPorTraspaso = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 8, CveMoneda, CveRemision) - If Not CveMovimientoSalidaPorTraspaso > 0 Then - OcurrioError = True - Exit For - End If - - 'Le damos entrada al general por traspaso - If Not OcurrioError Then - If Not GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 9, CveMoneda, CveRemision, CveMovimientoRelacionado:=CveMovimientoSalidaPorTraspaso) > 0 Then - OcurrioError = True - Exit For - End If - End If - - If Not OcurrioError Then - If ConSalida Then - 'Le damos salida normal - If Not GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 3, CveMoneda, ObjFactura.CveVenta, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0 Then - OcurrioError = True - Exit For - End If - End If - End If - End If - Else - OcurrioError = True - End If - - MovDetalle.Dispose() - End If - - End If - - ElseIf ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, 3, -1, UsuarioActual.CveEmpresa) Then - - 'Esquema viejo, evitamos que aparezca por surtir - If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then - OcurrioError = True - Exit For - End If - - End If - Next - - End If - - End If - + Dim OcurrioError As Boolean = False + Try + Dim DtMovimientos As DataTable + Dim DtMovimientosDetalles As DataTable + DtRemConceptosSurtidos = Nothing + + 'Obtenemos los movimientos detalle + If ObjInventario.GetInv_Mov(CveRemision, UsuarioActual.CveEmpresa) Then + + If ObjInventario.DtResultados.Rows.Count > 0 Then + + DtMovimientos = ObjInventario.DtResultados.FiltraParametros("", DistinctColumns:={"CveMovimiento"}) + + 'Si estamos facturando remisiones ajustamos por ventadetalle + If RemisionesLista.Count > 0 Then + Dim resultados = From DtRemisiones In DtRemisionesTmpDT + Join DtMovDet In ObjInventario.DtResultados.FiltraParametros("CvePS > 0") On DtRemisiones("CveVentaDetalleRemision").ToString.ToEntero Equals DtMovDet("CveVentaDetalle").ToString.ToEntero + Select DtMovDet + Try + DtMovimientosDetalles = resultados.CopyToDataTable + Catch ex As Exception + GuardaLog($"LOG IPP: Ventas LN: 10033. - DtRemisionesTmpDT.Rows.Count: {DtRemisionesTmpDT.Rows.Count} - ObjInventario.DtResultados.FiltraParametros('CvePS > 0').Rows.Count: {ObjInventario.DtResultados.FiltraParametros("CvePS > 0").Rows.Count}") + DtMovimientosDetalles = New DataTable + End Try + Else + DtMovimientosDetalles = ObjInventario.DtResultados.FiltraParametros("CvePS > 0") + End If + + If DtMovimientos.Rows.Count > 0 Then + Dim GeneroMovimientoAlmacen As Boolean = False + + For Each dr As DataRow In DtMovimientos.Rows + + 'Obtenemos los Movimientos de salida + If ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, ConceptoMovimiento, -1, UsuarioActual.CveEmpresa) Then + + If ObjInventario.DtResultados.Rows.Count > 0 AndAlso DtMovimientosDetalles.Rows.Count > 0 Then + Dim RowMovimiento As DataRow = ObjInventario.DtResultados(0) + + Dim CveAlmacenSalida As Integer = RowMovimiento("CveAlmacen").ToString.ToEntero() + Dim CveAlmacenEntrada As Integer = RowMovimiento("CveAlmacenRelacionado").ToString.ToEntero() + Dim CveMoneda As Integer = RowMovimiento("CveMoneda").ToString.ToEntero() + Dim CveTipoAlmacen As Integer = RowMovimiento("CveTipoAlmacen").ToString.ToEntero() + + If (CveAlmacenEntrada > 0 AndAlso CveTipoAlmacen <> 1) Or RemisionesLista.Count = 0 Then 'Con remisiones parciales ignoramos las surtidas ya realizadas + + Dim MovDetalle As New DataTable + + If RemisionesLista.Count > 0 Then + MovDetalle = CuadrarFacturaMovimientos(DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")} AND TieneSalidaxFactura IS NULL")) + Else + MovDetalle = DtMovimientosDetalles.FiltraParametros($"CveMovimiento = {dr("CveMovimiento")}") + End If + + If ErrorList.Count = 0 AndAlso MovDetalle.Rows.Count > 0 Then + Dim CveMovimientoSalidaPorTraspaso As Integer = -1 + + 'Le damos salida de apartado por traspaso + CveMovimientoSalidaPorTraspaso = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenSalida, 8, CveMoneda, CveRemision) + + If Not CveMovimientoSalidaPorTraspaso > 0 Then + OcurrioError = True + Exit For + End If + + 'Le damos entrada al general por traspaso + If Not OcurrioError Then + GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 9, CveMoneda, CveRemision, CveMovimientoRelacionado:=CveMovimientoSalidaPorTraspaso) > 0 + + If Not GeneroMovimientoAlmacen Then + OcurrioError = True + Exit For + End If + End If + + 'Le damos salida normal + If ConSalida AndAlso Not OcurrioError Then + GeneroMovimientoAlmacen = GenerarMovimientoAlmacen(ObjInventario, MovDetalle, CveAlmacenEntrada, 3, CveMoneda, ObjFactura.CveVenta, MovimientoPrePoliza:=True, ObjConta:=ObjConta) > 0 + + If Not GeneroMovimientoAlmacen Then + OcurrioError = True + Exit For + End If + End If + + Else + OcurrioError = True + End If + + MovDetalle.Dispose() + End If + + End If + + ElseIf ObjInventario.GetMovimientos(dr("CveMovimiento").ToString.ToEntero, 3, -1, UsuarioActual.CveEmpresa) Then + 'Esquema viejo, evitamos que aparezca por surtir + If Not ObjInventario.ActualizarEsDevolucionVenta(ObjFactura.CveVenta, 2) Then + OcurrioError = True + Exit For + End If + End If + Next + + OcurrioError = Not GeneroMovimientoAlmacen + End If + + End If + Else + OcurrioError = True + End If + + Catch ex As Exception + OcurrioError = True + OnError("Ocurrió un error al realizar el traspaso", ex) + End Try Return Not OcurrioError End Function Private Function CuadrarFacturaMovimientos(MovDetalle As DataTable) As DataTable @@ -15254,12 +15048,12 @@ Partial Class Ventas End If Return TieneError - End Function - 'Protected Sub LbVerInventario_Click(sender As Object, e As EventArgs) Handles LbVerInventario.Click - ' RegistraScript(String.Format("AbrirVentana('/Inventarios/PopUpExistenciasAlmacen.aspx?CvePS={0}',800,547,'N');", DdlPS.SelectedValue)) - 'End Sub + End Function + 'Protected Sub LbVerInventario_Click(sender As Object, e As EventArgs) Handles LbVerInventario.Click + ' RegistraScript(String.Format("AbrirVentana('/Inventarios/PopUpExistenciasAlmacen.aspx?CvePS={0}',800,547,'N');", DdlPS.SelectedValue)) + 'End Sub #End Region - + #Region " MANDA CORREO " Private Sub MandaMails(CveVenta As Integer, EnviarFactura As Boolean, XML As String, PDF As String) @@ -15339,11 +15133,11 @@ Partial Class Ventas ObjVentas.Dispose() End Try - End Sub + End Sub #End Region - + #Region " ESTIMACIONES " - + Protected Sub DdlContrato_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlContrato.SelectedIndexChanged Dim valueselect = DdlContrato.SelectedValue CargaDatosEstimaciones(CveCliente) @@ -15427,9 +15221,9 @@ Partial Class Ventas Catch ex As Exception Alert("No se pudo verificar la fecha del certificado", TipoMensaje.MsgError) End Try - End Sub + End Sub #End Region - + #Region "E V E N T O - B I T A C O R A" Protected Sub GvEB_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -15499,10 +15293,10 @@ Partial Class Ventas HttpContext.Current.Response.End() Archivo = Nothing - End Sub - + End Sub + #End Region - + #Region "BTN 'S" Protected Sub LnkActualizarOrdenProduccion_Click(sender As Object, e As EventArgs) If DdlOrdenProduccion.SelectedValue.ToEntero > 0 Then @@ -15737,7 +15531,6 @@ Partial Class Ventas Row("Descuento") = Math.Round(Row("Descuento").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales) Row("ImporteIEPS") = Math.Round(Row("ImporteIEPS").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales) Row("ImporteIVA") = Math.Round(Row("ImporteIVA").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales) - Row("ImporteIEPS") = Math.Round(Row("ImporteIEPS").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales) Row("ImporteRetIVA") = Math.Round(Row("ImporteRetIVA").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales) Row("ImporteRetISR") = Math.Round(Row("ImporteRetISR").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales) Next @@ -15912,9 +15705,9 @@ Partial Class Ventas Alert("Se asignó correctamente la cuenta terminal", JSBtnAceptar:="BtnRefrescarPagina();") End If ObjVentas.Dispose() - End Sub + End Sub #End Region - + #Region "CODIGO DE BARRAS" Protected Sub ChkClasificacion_CheckedChanged(sender As Object, e As EventArgs) If ChkClasificacion.Checked Then @@ -16126,10 +15919,10 @@ Partial Class Ventas GVBuscarPrecio.DataBind() UpBuscarPrecio.Update() - End Sub - + End Sub + #End Region - + #Region " CONDICIONES DE PAGO " Private Sub InicializaCondicionesPago() DtPagos = New DataTable @@ -16365,11 +16158,11 @@ Partial Class Ventas End If Return Retorno - End Function + End Function #End Region - + #Region " SERIE ALMACEN " - + Protected Sub BtnSerie_Click(sender As Object, e As EventArgs) Dim Row = CType(CType(sender, Button).NamingContainer, GridViewRow) @@ -16430,11 +16223,11 @@ Partial Class Ventas Next Return Retorno - End Function - - + End Function + + #End Region - + #Region " BUSCAR CLIENTE " Protected Sub BtnBuscarCliente_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnBuscarCliente.Click ViewState("CveCliente") = HdnCveCliente.Value.ToEntero @@ -16451,11 +16244,11 @@ Partial Class Ventas 'CARGA CONTRATOS VerificarContrato() - End Sub - - + End Sub + + #End Region - + #Region " INVENTARIO POR ENTREGA" Private Sub InventarioMov(Optional CveVentaPadre As Integer = -1) If CveVentaPadre > 0 Then @@ -16503,9 +16296,9 @@ Partial Class Ventas GvInv.DataSource = DtTemporal GvInv.DataBind() UpINV.Update() - End Sub + End Sub #End Region - + #Region "IMPUESTOS LOCALES" Private Sub GvImpuestosLocales2_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvImpuestosLocales2.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then @@ -16547,10 +16340,10 @@ Partial Class Ventas If Not ErrorCancelar Then ErrorCancelar = GuardarVentaImpuestosLocales(ObjVentas, ObjConta, ObjFactura, 1) Return ErrorCancelar - End Function - + End Function + #End Region - + #Region " DEVOLUCION ALMACEN " Private Sub InicializaDevolucionAlmacen() If Not GvInv.Rows.Count > 0 Then @@ -16594,10 +16387,10 @@ Partial Class Ventas UpnTools.Update() ObjVentas.Dispose() - End Sub - + End Sub + #End Region - + #Region "D I R E C C I O N E N V I O" Private Sub CargaDireccionesEnvio() Dim ObjClientes As New ClsClientes @@ -16668,9 +16461,9 @@ Partial Class Ventas TxtCP.Text = LblCP.Text.Trim UpBodyDireccion.Update() RegistraScript("$('#divAddDireccionEnvio').modal();") - End Sub + End Sub #End Region - + #Region " CARGA FACTURA OC " Private Sub CargaFacturaOC() @@ -16740,10 +16533,10 @@ Partial Class Ventas End If - End Sub - + End Sub + #End Region - + #Region "CargaFactura" Private Function CargaFactura(CveFactura As Integer) As String Dim RFC As String = "" @@ -17166,9 +16959,9 @@ Partial Class Ventas Else Return o.Value End If - End Function + End Function #End Region - + #Region "Metodos Viejos" Private Sub GeneraPDF(FechaFactura As DateTime, FolioFiscal As String, NoSerieCertificado As String, FechaCertificacion As DateTime, NoSerieCertificadoContribuyente As String, DTConceptos As DataTable, SelloCFDi As String, SelloSAT As String, CBB As String, Folio As String, RutaXML As String, EsVistaPrevia As Boolean, MuestraAlert As Boolean, Optional MR As ReportViewer = Nothing) @@ -17261,9 +17054,9 @@ Partial Class Ventas EsSupervisor = True GeneraPDFCotizacion(True) Alert("La cotización ha sido enviada al correo de nuestro cliente:" & Mail) - End Sub + End Sub #End Region - + #Region "Cancelar, Generar y mandar por correo el acuse de cancelación." Private Sub BtnEnviarMailCancelacion_Click(sender As Object, e As EventArgs) Handles BtnEnviarMailCancelacion.Click ImprimeCancelacion(CveVenta) @@ -18395,11 +18188,11 @@ Partial Class Ventas UpEstatus.Update() - End Sub - - + End Sub + + #End Region - + #Region "CiclosComerciales" Private Sub CargaCicloComercialURL() Dim ObjContratos As New ClsContratos @@ -18472,9 +18265,9 @@ Partial Class Ventas huboerror = True End If ObjContratos.Dispose() - End Sub + End Sub #End Region - + #Region "DESCARGAR E IMPRIMIR LISTADO" Public Sub DescargarFormato() Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\Formatos\FormatoVentas.xlsx" @@ -18691,9 +18484,9 @@ Partial Class Ventas StrReturn = "False|    - No se encontró " & Valor & " en la fila " & NumRow & ", columna " & Opt End If Return StrReturn - End Function + End Function #End Region - + #Region "P E D I D O S" Private Sub CargaNotificacionContrato() Dim ObjContratos As New ClsContratos @@ -18812,9 +18605,9 @@ Partial Class Ventas Return strBody.ToString - End Function + End Function #End Region - + #Region " CANCELAR PEDIDO " Protected Sub LBCancelarPedido_Click(sender As Object, e As EventArgs) Dim ObjVentas As New ClsVentas @@ -18832,12 +18625,10 @@ Partial Class Ventas End If ObjVentas.Dispose() - End Sub - + End Sub + #End Region - - - + #Region "D E V O L U C I O N D E P E D I D O " Private Sub CargaFacturaDevolucionPedido() Dim CveVenta As Integer = Me.CveVenta @@ -18974,11 +18765,11 @@ Partial Class Ventas UpPS.Update() UpCliente.Update() UpEstatus.Update() - End Sub + End Sub #End Region - + #Region " FLETES " - + Private Sub CargaFletes() If UsuarioActual.CveEmpresa <> 125 Or CveVenta > 0 Then @@ -18997,12 +18788,12 @@ Partial Class Ventas UpFletes.Update() ObjVentas.Dispose() - End Sub - - - + End Sub + + + #End Region - + #Region "A G R E G A R P S M O D A L" Private Sub CargaMetodosPSModal() CargaTipoProductos() @@ -19175,9 +18966,9 @@ Partial Class Ventas End If ObjPS.Dispose() - End Sub + End Sub #End Region - + #Region "P Y M E" Private Sub LnkAddVenta_Click(sender As Object, e As EventArgs) Handles LnkAddVenta.Click Modalidad = "A" @@ -19361,12 +19152,12 @@ Partial Class Ventas Private Sub DdlClasificacionPyME_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClasificacionPyME.SelectedIndexChanged CargaPSPyME(DdlClasificacionPyME.SelectedValue.ToEntero, DdlPSPyME) UpClasificacionPyME.Update() - End Sub - - - + End Sub + + + #End Region - + #Region "REORDENAR" Protected Sub BtnReordenar_Click(sender As Object, e As EventArgs) Handles BtnReordenar.Click Dim sArray As String() @@ -19389,10 +19180,10 @@ Partial Class Ventas GvPS.DataBind() CalculaTotalesVenta() DTClon.Dispose() - End Sub - + End Sub + #End Region - + #Region " CONTRATO DE CONSIGNACION DE VENTA - SURTIDO DE ALMACÉN " Function RegistraAlmacenConsignacionVenta(ByRef ObjInventario As ClsInventarios, factura As Modelos.Factura) As Boolean If Not (UsuarioActual.Empresa.UsaInventarios AndAlso CveAlmacenExistenciasContrato > 0) Then @@ -19477,8 +19268,8 @@ Partial Class Ventas Return True - End Function - + End Function + #Region " AGREGA POR SERIE/LOTE " Private Sub CreaConsignacionSerieDetalle() If DtContratosSerieDetalle Is Nothing Then @@ -19656,12 +19447,12 @@ Partial Class Ventas Exit For End If Next - End Sub - + End Sub + #End Region - + #End Region - + #Region " ENVIAR SMS - CONFIRMACION DE TIMBRADO " Private Function EnviarSMSTimbrado(ByRef ObjEventos As ClsOIEventos) As Integer 'NOTA: @@ -19693,9 +19484,9 @@ Partial Class Ventas Else Return 2 End If - End Function + End Function #End Region - + #Region " COMPLEMENTOS PAGO " Private Sub CargaComplementosPago() @@ -19800,30 +19591,30 @@ Partial Class Ventas OnError("Ocurrió error al mandar MAIL", ex) End Try - End Sub + End Sub #End Region - + #Region "RELACIONAR FACTURAS A NC " - 'Private Sub CargaFacturasRelacionar() - - ' Dim ObjVentas As New ClsVentas - ' Dim dtt As DataTable = Nothing - ' If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", CveCliente, -1, 3, -1, - ' Now.AddYears(-1).ToShortDateString, Now.ToShortDateString, "-1", -1, -1, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then - ' If ObjVentas.DtResultados.Rows.Count > 0 Then - ' dtt = ObjVentas.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Ant')") - ' End If - ' End If - ' ObjVentas.Dispose() - ' Alert(dtt.Rows.Count.ToString) - - ' GvRelacionarNC.DataSource = dtt - ' GvRelacionarNC.DataBind() - ' If dtt IsNot Nothing Then dtt.Dispose() - ' UPRelacionarNC.Update() - 'End Sub + 'Private Sub CargaFacturasRelacionar() + + ' Dim ObjVentas As New ClsVentas + ' Dim dtt As DataTable = Nothing + ' If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", CveCliente, -1, 3, -1, + ' Now.AddYears(-1).ToShortDateString, Now.ToShortDateString, "-1", -1, -1, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then + ' If ObjVentas.DtResultados.Rows.Count > 0 Then + ' dtt = ObjVentas.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Ant')") + ' End If + ' End If + ' ObjVentas.Dispose() + ' Alert(dtt.Rows.Count.ToString) + + ' GvRelacionarNC.DataSource = dtt + ' GvRelacionarNC.DataBind() + ' If dtt IsNot Nothing Then dtt.Dispose() + ' UPRelacionarNC.Update() + 'End Sub #End Region - + #Region " DOCUMENTACION VENTAS" Property DtDocumentacionCliente As DataTable Get @@ -20096,9 +19887,9 @@ Partial Class Ventas UpModalTitleUploadDocumentoCliente.Update() UpModalButtonUploadDocumentoCliente.Update() RegistraScript("$('#DivDocsClienteUpload').modal({ backdrop: 'static', keyboard: false});", "modalOC") - End Sub + End Sub #End Region - + #Region " SALDAR VENTA " Protected Sub BtnSaldarVenta_Click(sender As Object, e As EventArgs) SaldarVenta() @@ -20290,11 +20081,11 @@ Partial Class Ventas ObjConta.Dispose() - End Sub + End Sub #End Region - + #Region "PAQUETERIA GUIAS" - + Protected Sub LnkAgregarGuia_Click(sender As Object, e As EventArgs) ''DivModalGuias 'DdlPaqueteria.Items.Clear() @@ -20726,9 +20517,9 @@ Partial Class Ventas End Try ObjEventos.Dispose() - End Sub + End Sub #End Region - + #Region " APLICAR NOTA DE CREDITO " Private Sub InicializaAplicarNC() 'If Not UsuarioActual.CveUsuario = 100 Then @@ -21209,10 +21000,10 @@ Partial Class Ventas DtVentasNC.Rows.Add(Dr) End If - End Sub - + End Sub + #End Region - + #Region " APLICA DEVOLUCION " Private Sub InicializaAplicaDevolucion() If Not UsuarioActual.CveUsuario = 100 Then @@ -21430,17 +21221,17 @@ Partial Class Ventas UpnTools.Update() UPObservaciones.Update() UpAntNC.Update() - End Sub + End Sub #End Region - + #Region "COMERCIO EXTERIOR" - - 'Public Sub InicializaComercioExterior() - ' 'CargoComercioExterior = True - ' 'CargaCombos() - ' CargaGvComercioExterior() - 'End Sub - + + 'Public Sub InicializaComercioExterior() + ' 'CargoComercioExterior = True + ' 'CargaCombos() + ' CargaGvComercioExterior() + 'End Sub + Public Sub CargaGvComercioExterior() GvComercioExterior.DataSource = TmpDT GvComercioExterior.DataBind() @@ -21520,10 +21311,10 @@ Partial Class Ventas Next Return True - End Function - + End Function + #End Region - + #Region "NOTIFICACIONES AVACE" Private Sub EnviarNotificacionAvance(NumeroContrato As String, DescripcionContrato As String, ContratoTipo As String, Cliente As String, CorreoVendedor As String, Optional MontoMaximo As Double = 0) @@ -21543,9 +21334,9 @@ Partial Class Ventas ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Cuerpo) - End Sub + End Sub #End Region - + #Region "Comercio Exterior" Private Sub CargaPais() DdlComExtPais.Items.Clear() @@ -21632,9 +21423,9 @@ Partial Class Ventas gvr.FCTextBox("TxtCantidad").Text = (gvr.FCTextBox("TxtCantidad").Text.ToDecimal * TxtComExtConvertir.Text.ToDecimal).ToString gvr.FCTextBox("TxtValorUnitario").Text = (gvr.FCTextBox("TxtValorUnitario").Text.ToDecimal / TxtComExtConvertir.Text.ToDecimal).ToString Next - End Sub + End Sub #End Region - + Private Sub BtnFolioFiscalAsignar_Click(sender As Object, e As EventArgs) Handles BtnFolioFiscalAsignar.Click Dim ObjVentas As New ClsVentas() If ObjVentas.UpdateVentaFolioFiscal(TxtModalFolioFiscal.Text.Trim, CveVenta, UsuarioActual.CveEmpresa) Then @@ -21642,8 +21433,8 @@ Partial Class Ventas RegistraScript("$('#ModalFolioFiscal').modal('hide')") End If ObjVentas.Dispose() - End Sub - + End Sub + #Region "FORMATO CICOVISA" Protected Sub LnkImprimirFormatoCicovisa_Click(sender As Object, e As EventArgs) Dim ObjVentas As New ClsVentas @@ -21684,9 +21475,9 @@ Partial Class Ventas params.Add(New ReportParameter("Guia", Guia)) ImprimirPDF("Empresas/Grales/Formatos/Cicovisa.rdlc", Dt, params, String.Format("Formato Cicovisa -{0}", Now.ToDateTime.ToShortDateString)) End If - End Sub + End Sub #End Region - + #Region "REQUIERE OC" Protected Sub btnBuscarOCRegistrada_Click(sender As Object, e As EventArgs) Dim ObjVentas As New ClsVentas @@ -21699,9 +21490,9 @@ Partial Class Ventas End If End If ObjVentas.Dispose() - End Sub + End Sub #End Region - + #Region "CLASIFICACIONES DETALLES" Protected Sub DdlClasificacionPS_SelectedIndexChanged(sender As Object, e As EventArgs) CargaClasificacionesDetalles() @@ -21754,13 +21545,13 @@ Partial Class Ventas Private Sub CambiaMetodoPago33() CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero) - End Sub - + End Sub + #End Region - - - - + + + + #Region " COTIZACIONES - EDITAR " Private Sub BtnPermisoEditarCotizacion_Click(sender As Object, e As EventArgs) Handles BtnPermisoEditarCotizacion.Click ModalidadEdicion = True @@ -21929,10 +21720,10 @@ Partial Class Ventas End If ObjVentas.Dispose() - End Sub - + End Sub + #End Region - + #Region " COTIZACIONES - SIN FACTURAR " Private Sub LnkCotizaciones_Click(sender As Object, e As EventArgs) Handles LnkCotizaciones.Click If ChkCotProductos.Checked Then @@ -22149,10 +21940,10 @@ Partial Class Ventas Else Return False End If - End Function - + End Function + #End Region - + #Region " COTIZACIONES - FACTURAR " Private Function PreparaFacturarCotizacion() As Boolean 'LIMPIAMOS @@ -22190,10 +21981,10 @@ Partial Class Ventas End If Return True - End Function + End Function #End Region - - + + #Region " REMISIONES - SIN FACTURAR " Protected Sub ChkCanRem_CheckedChanged(sender As Object, e As EventArgs) If ChkCanRem.Checked Then @@ -22537,10 +22328,10 @@ Partial Class Ventas End If Next Return Nothing - End Function - + End Function + #End Region - + #Region " REMISIONES - FACTURAR " Private Sub ActivaFacturarRemision() 'If UsuarioActual.CveUsuario <> 100 Then @@ -22635,10 +22426,10 @@ Partial Class Ventas End If Return True - End Function + End Function #End Region - - + + #Region " PEDIDOS2 - SIN FACTURAR " Protected Sub LnkPedido2SinFacturar_Click(sender As Object, e As EventArgs) @@ -22857,10 +22648,10 @@ Partial Class Ventas Else Return False End If - End Function - + End Function + #End Region - + #Region " PEDIDOS2 - FACTURAR " Private Function PreparaFacturarPedido() As Boolean 'LIMPIAMOS @@ -22894,12 +22685,12 @@ Partial Class Ventas TxtObsFact.Text = String.Format("Pedido: {0}-{1} {2}", LblSerie.Text, TxtFolio.Text, If(TxtObsFact.Text.Length > 0, $"({TxtObsFact.Text})", "")) Return True - End Function + End Function #End Region - - + + #Region " BOTONERA - ACCIONES DE ABAJO " - + #Region " CREAR APARTIR DE " Protected Sub BtnCrearApartirDe_Click(sender As Object, e As System.EventArgs) Handles BtnCrearApartirDe.Click ''[IPP-2Novimebre2018] COMENTADO POR SER UNA FUNCIONALIDAD SUPER RARA! LA REEMPLAZA EL EDITAR COTIZACION @@ -23126,9 +22917,9 @@ Partial Class Ventas CargaRestriccionesCreditoCliente() UpParametros.Update() - End Sub + End Sub #End Region - + #Region " GENERAR FACTURA " Protected Sub LBFacturarIngreso_Click(sender As Object, e As EventArgs) EraCotizacion = If(DdlTipoComprobante.SelectedValue = "Cot", 1, 0) @@ -23139,9 +22930,9 @@ Partial Class Ventas EraCotizacion = If(DdlTipoComprobante.SelectedValue = "Cot", 1, 0) 'DdlTipoComprobante.SelectedValue = "Ant" EmitirDocumentoNuevo("Ant") - End Sub + End Sub #End Region - + #Region " GENERAR REMISION " Private Sub BtnGenerarRemision_Click(sender As Object, e As EventArgs) Handles BtnGenerarRemision.Click If DdlTipoComprobante.SelectedValue.Contiene("Cot", "PA", "Pd2") Then 'CUANDO ES COTIZACION O PEDIDOA O PEDIDO2 SE HARA REMISION @@ -23149,20 +22940,20 @@ Partial Class Ventas 'DdlTipoComprobante.SelectedValue = "Rem" EmitirDocumentoNuevo("Rem") End If - End Sub + End Sub #End Region - + #Region "GENERAR AUTORIZACIÓN" - + Protected Sub BtnGeneraAutorizacion_Click(sender As Object, e As EventArgs) If DdlTipoComprobante.SelectedValue.Contiene("Pd2") Then EmitirDocumentoNuevo("PA") End If - End Sub - + End Sub + #End Region - + #Region " EMITIR DOCUMENTO NUEVO " Private Sub EmitirDocumentoNuevo(TipoDoctoNuevo As String) Dim FolioFijo As Integer = 0 @@ -23209,13 +23000,13 @@ Partial Class Ventas If FolioFijo = 0 Then CargaFolios() 'RECARGA FOLIOS CON EL NUEVO TIPO DOCTO EmitirImprimir() 'MANDA A EMITIR - PROCESO VIEJO - End Sub + End Sub #End Region - + #End Region - + #Region "ACTUALIZAR FECHA DE VENCIMIENTO" - + Protected Sub LnkUpdateFechaVencimiento_Click(sender As Object, e As EventArgs) Dim ObjVentas As New ClsVentas Dim ObjEventos As New ClsOIEventos(ObjVentas.IniciaTransacSQL()) @@ -23257,14 +23048,14 @@ Partial Class Ventas End Sub Private Sub BtnRefrescarPagina_Click(sender As Object, e As EventArgs) Handles BtnRefrescarPagina.Click Response.Redirect($"~/Ventas/Ventas.aspx?CveVenta={Me.CveVenta}") - End Sub - + End Sub + #End Region - - + + #Region "U S A D O S" - - + + Private Sub CalculaUsados() @@ -23444,11 +23235,11 @@ Partial Class Ventas Return Resultado - End Function - - + End Function + + #End Region - + #Region "PORCENTAJE IVA" Protected Sub DdlIVA_SelectedIndexChanged(sender As Object, e As EventArgs) If Not CveVenta > 0 Or EsCreaApartirDe Or CveDevolucion > 0 Then RecalculaIVA() @@ -23476,13 +23267,8 @@ Partial Class Ventas End If Next CalculaTotalesVenta() - End Sub - + End Sub + #End Region - - - - - - + End Class \ No newline at end of file