Merge branch 'master' of http://rpimienta@192.168.10.111:8383/SIG.git
This commit is contained in:
276
.gitignore
vendored
276
.gitignore
vendored
@@ -1,270 +1,8 @@
|
|||||||
## Ignore Visual Studio temporary files, build results, and
|
################################################################################
|
||||||
## files generated by popular Visual Studio add-ons.
|
# Este archivo .gitignore ha sido creado automáticamente por Microsoft(R) Visual Studio.
|
||||||
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)
|
/Empresas
|
||||||
*.userprefs
|
/Menu
|
||||||
|
/Web.config
|
||||||
# Build results
|
/Log.txt
|
||||||
[Dd]ebug/
|
|
||||||
[Dd]ebugPublic/
|
|
||||||
[Rr]elease/
|
|
||||||
[Rr]eleases/
|
|
||||||
x64/
|
|
||||||
x86/
|
|
||||||
bld/
|
|
||||||
[Bb]in/
|
|
||||||
[Oo]bj/
|
|
||||||
[Ll]og/
|
|
||||||
|
|
||||||
# Visual Studio 2015 cache/options directory
|
|
||||||
.vs/
|
|
||||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
|
||||||
#wwwroot/
|
|
||||||
|
|
||||||
# MSTest test Results
|
|
||||||
[Tt]est[Rr]esult*/
|
|
||||||
[Bb]uild[Ll]og.*
|
|
||||||
|
|
||||||
# NUNIT
|
|
||||||
*.VisualState.xml
|
|
||||||
TestResult.xml
|
|
||||||
|
|
||||||
# Build Results of an ATL Project
|
|
||||||
[Dd]ebugPS/
|
|
||||||
[Rr]eleasePS/
|
|
||||||
dlldata.c
|
|
||||||
|
|
||||||
# DNX
|
|
||||||
project.lock.json
|
|
||||||
project.fragment.lock.json
|
|
||||||
artifacts/
|
|
||||||
|
|
||||||
*_i.c
|
|
||||||
*_p.c
|
|
||||||
*_i.h
|
|
||||||
*.ilk
|
|
||||||
*.meta
|
|
||||||
*.obj
|
|
||||||
*.pch
|
|
||||||
*.pdb
|
|
||||||
*.pgc
|
|
||||||
*.pgd
|
|
||||||
*.rsp
|
|
||||||
*.sbr
|
|
||||||
*.tlb
|
|
||||||
*.tli
|
|
||||||
*.tlh
|
|
||||||
*.tmp
|
|
||||||
*.tmp_proj
|
|
||||||
*.log
|
|
||||||
*.vspscc
|
|
||||||
*.vssscc
|
|
||||||
.builds
|
|
||||||
*.pidb
|
|
||||||
*.svclog
|
|
||||||
*.scc
|
|
||||||
|
|
||||||
# Chutzpah Test files
|
|
||||||
_Chutzpah*
|
|
||||||
|
|
||||||
# Visual C++ cache files
|
|
||||||
ipch/
|
|
||||||
*.aps
|
|
||||||
*.ncb
|
|
||||||
*.opendb
|
|
||||||
*.opensdf
|
|
||||||
*.sdf
|
|
||||||
*.cachefile
|
|
||||||
*.VC.db
|
|
||||||
*.VC.VC.opendb
|
|
||||||
|
|
||||||
# Visual Studio profiler
|
|
||||||
*.psess
|
|
||||||
*.vsp
|
|
||||||
*.vspx
|
|
||||||
*.sap
|
|
||||||
|
|
||||||
# TFS 2012 Local Workspace
|
|
||||||
$tf/
|
|
||||||
|
|
||||||
# Guidance Automation Toolkit
|
|
||||||
*.gpState
|
|
||||||
|
|
||||||
# ReSharper is a .NET coding add-in
|
|
||||||
_ReSharper*/
|
|
||||||
*.[Rr]e[Ss]harper
|
|
||||||
*.DotSettings.user
|
|
||||||
|
|
||||||
# JustCode is a .NET coding add-in
|
|
||||||
.JustCode
|
|
||||||
|
|
||||||
# TeamCity is a build add-in
|
|
||||||
_TeamCity*
|
|
||||||
|
|
||||||
# DotCover is a Code Coverage Tool
|
|
||||||
*.dotCover
|
|
||||||
|
|
||||||
# NCrunch
|
|
||||||
_NCrunch_*
|
|
||||||
.*crunch*.local.xml
|
|
||||||
nCrunchTemp_*
|
|
||||||
|
|
||||||
# MightyMoose
|
|
||||||
*.mm.*
|
|
||||||
AutoTest.Net/
|
|
||||||
|
|
||||||
# Web workbench (sass)
|
|
||||||
.sass-cache/
|
|
||||||
|
|
||||||
# Installshield output folder
|
|
||||||
[Ee]xpress/
|
|
||||||
|
|
||||||
# DocProject is a documentation generator add-in
|
|
||||||
DocProject/buildhelp/
|
|
||||||
DocProject/Help/*.HxT
|
|
||||||
DocProject/Help/*.HxC
|
|
||||||
DocProject/Help/*.hhc
|
|
||||||
DocProject/Help/*.hhk
|
|
||||||
DocProject/Help/*.hhp
|
|
||||||
DocProject/Help/Html2
|
|
||||||
DocProject/Help/html
|
|
||||||
|
|
||||||
# Click-Once directory
|
|
||||||
publish/
|
|
||||||
|
|
||||||
# Publish Web Output
|
|
||||||
*.[Pp]ublish.xml
|
|
||||||
*.azurePubxml
|
|
||||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
|
||||||
# but database connection strings (with potential passwords) will be unencrypted
|
|
||||||
#*.pubxml
|
|
||||||
*.publishproj
|
|
||||||
|
|
||||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
|
||||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
|
||||||
# in these scripts will be unencrypted
|
|
||||||
PublishScripts/
|
|
||||||
|
|
||||||
# NuGet Packages
|
|
||||||
*.nupkg
|
|
||||||
# The packages folder can be ignored because of Package Restore
|
|
||||||
**/packages/*
|
|
||||||
# except build/, which is used as an MSBuild target.
|
|
||||||
!**/packages/build/
|
|
||||||
# Uncomment if necessary however generally it will be regenerated when needed
|
|
||||||
#!**/packages/repositories.config
|
|
||||||
# NuGet v3's project.json files produces more ignoreable files
|
|
||||||
*.nuget.props
|
|
||||||
*.nuget.targets
|
|
||||||
|
|
||||||
# Microsoft Azure Build Output
|
|
||||||
csx/
|
|
||||||
*.build.csdef
|
|
||||||
|
|
||||||
# Microsoft Azure Emulator
|
|
||||||
ecf/
|
|
||||||
rcf/
|
|
||||||
|
|
||||||
# Windows Store app package directories and files
|
|
||||||
AppPackages/
|
|
||||||
BundleArtifacts/
|
|
||||||
Package.StoreAssociation.xml
|
|
||||||
_pkginfo.txt
|
|
||||||
|
|
||||||
# Visual Studio cache files
|
|
||||||
# files ending in .cache can be ignored
|
|
||||||
*.[Cc]ache
|
|
||||||
# but keep track of directories ending in .cache
|
|
||||||
!*.[Cc]ache/
|
|
||||||
|
|
||||||
# Others
|
|
||||||
ClientBin/
|
|
||||||
~$*
|
|
||||||
*~
|
|
||||||
*.dbmdl
|
|
||||||
*.dbproj.schemaview
|
|
||||||
*.jfm
|
|
||||||
*.pfx
|
|
||||||
*.publishsettings
|
|
||||||
node_modules/
|
|
||||||
orleans.codegen.cs
|
|
||||||
|
|
||||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
|
||||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
|
||||||
#bower_components/
|
|
||||||
|
|
||||||
# RIA/Silverlight projects
|
|
||||||
Generated_Code/
|
|
||||||
|
|
||||||
# Backup & report files from converting an old project file
|
|
||||||
# to a newer Visual Studio version. Backup files are not needed,
|
|
||||||
# because we have git ;-)
|
|
||||||
_UpgradeReport_Files/
|
|
||||||
Backup*/
|
|
||||||
UpgradeLog*.XML
|
|
||||||
UpgradeLog*.htm
|
|
||||||
|
|
||||||
# SQL Server files
|
|
||||||
*.mdf
|
|
||||||
*.ldf
|
|
||||||
|
|
||||||
# Business Intelligence projects
|
|
||||||
*.rdl.data
|
|
||||||
*.bim.layout
|
|
||||||
*.bim_*.settings
|
|
||||||
|
|
||||||
# Microsoft Fakes
|
|
||||||
FakesAssemblies/
|
|
||||||
|
|
||||||
# GhostDoc plugin setting file
|
|
||||||
*.GhostDoc.xml
|
|
||||||
|
|
||||||
# Node.js Tools for Visual Studio
|
|
||||||
.ntvs_analysis.dat
|
|
||||||
|
|
||||||
# Visual Studio 6 build log
|
|
||||||
*.plg
|
|
||||||
|
|
||||||
# Visual Studio 6 workspace options file
|
|
||||||
*.opt
|
|
||||||
|
|
||||||
# Visual Studio LightSwitch build output
|
|
||||||
**/*.HTMLClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/ModelManifest.xml
|
|
||||||
**/*.Server/GeneratedArtifacts
|
|
||||||
**/*.Server/ModelManifest.xml
|
|
||||||
_Pvt_Extensions
|
|
||||||
|
|
||||||
# Paket dependency manager
|
|
||||||
.paket/paket.exe
|
|
||||||
paket-files/
|
|
||||||
|
|
||||||
# FAKE - F# Make
|
|
||||||
.fake/
|
|
||||||
|
|
||||||
# JetBrains Rider
|
|
||||||
.idea/
|
|
||||||
*.sln.iml
|
|
||||||
*.sln
|
|
||||||
|
|
||||||
# CodeRush
|
|
||||||
.cr/
|
|
||||||
|
|
||||||
# Python Tools for Visual Studio (PTVS)
|
|
||||||
__pycache__/
|
|
||||||
*.pyc
|
|
||||||
/Utilerias
|
|
||||||
|
|||||||
@@ -568,6 +568,26 @@ Public Class ClsVentas
|
|||||||
|
|
||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
|
Public Function UpdateVentaRealizarDevolucion(CveVenta As Integer, RealizarDevolucion As Boolean, CveAlmacenDevolucion As Integer) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
|
||||||
|
DataAdapter("PA_VentasRealizarDevolucionUpdate")
|
||||||
|
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta
|
||||||
|
.Add("@RealizarDevolucion", SqlDbType.Bit).Value = RealizarDevolucion
|
||||||
|
.Add("@CveAlmacenDevolucion", SqlDbType.Int).Value = CveAlmacenDevolucion
|
||||||
|
End With
|
||||||
|
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
Retorno = True
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al actualizar el estatus de devolución.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return Retorno
|
||||||
|
End Function
|
||||||
Public Function UpdateEstatusRefacturacion(CveVenta As Integer, CveEstatusRefacturacion As Integer) As Boolean
|
Public Function UpdateEstatusRefacturacion(CveVenta As Integer, CveEstatusRefacturacion As Integer) As Boolean
|
||||||
Dim Retorno As Boolean = False
|
Dim Retorno As Boolean = False
|
||||||
|
|
||||||
@@ -835,6 +855,20 @@ Public Class ClsVentas
|
|||||||
|
|
||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
|
Public Function GetRemisionesXCancelar(CveVenta As Integer) As Boolean
|
||||||
|
Dim Retorno As Boolean = False
|
||||||
|
DataAdapter("PA_Vta_RemisionesXCancelarGet")
|
||||||
|
With SqlAdapter.SelectCommand.Parameters
|
||||||
|
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta
|
||||||
|
End With
|
||||||
|
Try
|
||||||
|
SqlAdapter.Fill(Data)
|
||||||
|
Retorno = True
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al agregar las remisiones x cancelar.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||||
|
End Try
|
||||||
|
Return Retorno
|
||||||
|
End Function
|
||||||
Public Function AddRemisionesXCancelar(CveVenta As Integer, CveVentaRemision As Integer) As Boolean
|
Public Function AddRemisionesXCancelar(CveVenta As Integer, CveVentaRemision As Integer) As Boolean
|
||||||
Dim Retorno As Boolean = False
|
Dim Retorno As Boolean = False
|
||||||
DataAdapter("PA_Vta_RemisionesXCancelarAdd")
|
DataAdapter("PA_Vta_RemisionesXCancelarAdd")
|
||||||
|
|||||||
1627
App_Code/Modelos.vb
1627
App_Code/Modelos.vb
File diff suppressed because it is too large
Load Diff
@@ -90,6 +90,7 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
|
|||||||
var resp = Timbrado.VerificarVigenciaSAT(uuid, UsuarioActual.Empresa.RFC, receptor, total, UsuarioActual.Empresa.FacturaProduccion);
|
var resp = Timbrado.VerificarVigenciaSAT(uuid, UsuarioActual.Empresa.RFC, receptor, total, UsuarioActual.Empresa.FacturaProduccion);
|
||||||
if (resp != null)
|
if (resp != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (resp.Estado == null)
|
if (resp.Estado == null)
|
||||||
{
|
{
|
||||||
sb.Append("No se pudo comprobar el estado de la factura. El servicio del sat no esta disponible");
|
sb.Append("No se pudo comprobar el estado de la factura. El servicio del sat no esta disponible");
|
||||||
@@ -102,6 +103,14 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
|
|||||||
sb.AppendFormat("Es Cancelable: {0} <br/>", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EsCancelable);
|
sb.AppendFormat("Es Cancelable: {0} <br/>", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EsCancelable);
|
||||||
sb.AppendFormat("Estatus de Cancelación: {0} <br/><br/>", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EstatusCancelacion);
|
sb.AppendFormat("Estatus de Cancelación: {0} <br/><br/>", string.IsNullOrEmpty(resp.EsCancelable) ? "Desconocido" : resp.EstatusCancelacion);
|
||||||
|
|
||||||
|
//var FueCancelado = CancelarDocumento(CveVenta, CveEstatus, CveCliente, Folio, uuid, CancelacionAcuse, CancelacionFecha, TipoDocto, total.ToDouble(), UsuarioActual.Empresa.CvePAC).Mensaje;
|
||||||
|
|
||||||
|
//sb.AppendFormat("{0} <br/>", FueCancelado);
|
||||||
|
//if (CveEstatus.Contiene(4, 5) && EsRefacturacion)
|
||||||
|
//{
|
||||||
|
// Response.Redirect(string.Format("Ventas.aspx?CveDevolucion={0}&NuevaFactura=1", CveVenta));
|
||||||
|
//}
|
||||||
|
|
||||||
if ((resp.EsCancelable.ToUpper() == "NO CANCELABLE"))
|
if ((resp.EsCancelable.ToUpper() == "NO CANCELABLE"))
|
||||||
{
|
{
|
||||||
sb.Append("Esta factura no es cancelable.");
|
sb.Append("Esta factura no es cancelable.");
|
||||||
@@ -123,7 +132,8 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
|
|||||||
CancelacionFecha = xmlAcuse.SelectSingleNode("Acuse").Attributes["Fecha"].Value.ToDate();
|
CancelacionFecha = xmlAcuse.SelectSingleNode("Acuse").Attributes["Fecha"].Value.ToDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
var FueCancelado = CancelarDocumento(CveVenta, CveEstatus, CveCliente, Folio, uuid, CancelacionAcuse, CancelacionFecha, TipoDocto, total.ToDouble(), UsuarioActual.Empresa.CvePAC);
|
var FueCancelado = CancelarDocumento(CveVenta, CveEstatus, CveCliente, Folio, uuid, CancelacionAcuse, CancelacionFecha, TipoDocto, total.ToDouble(), UsuarioActual.Empresa.CvePAC).Mensaje;
|
||||||
|
|
||||||
sb.AppendFormat("{0} <br/>", FueCancelado);
|
sb.AppendFormat("{0} <br/>", FueCancelado);
|
||||||
if (CveEstatus.Contiene(4, 5) && EsRefacturacion)
|
if (CveEstatus.Contiene(4, 5) && EsRefacturacion)
|
||||||
{
|
{
|
||||||
@@ -160,137 +170,11 @@ public partial class Ventas_RepCancelacionesPorRespuesta : ClsPaginas
|
|||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
private string CancelarDocumento(int CveVenta, int CveEstatus, int CveCliente, string Folio, string FolioFiscal, string CancelacionAcuse, DateTime CancelacionFecha, string TipoComprobante, double Total, int CvePACCancelacion)
|
private Modelos.Factura.MCancelacionVentaMensaje CancelarDocumento(int CveVenta, int CveEstatus, int CveCliente, string Folio, string FolioFiscal, string CancelacionAcuse, DateTime CancelacionFecha, string TipoComprobante, double Total, int CvePACCancelacion)
|
||||||
{
|
{
|
||||||
string Mensaje = "";
|
var factura = new Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa);
|
||||||
ClsVentas ObjVentas = new ClsVentas();
|
var retorno = factura.EjecutarCancelacionPendiente(CveEstatus, CancelacionFecha, CancelacionAcuse);
|
||||||
ClsOIEventos ObjEventos = new ClsOIEventos(ObjVentas.IniciaTransacSQL());
|
return retorno;
|
||||||
ClsContabilidad ObjConta = new ClsContabilidad(ObjVentas.IniciaTransacSQL());
|
|
||||||
ClsContPAQi ObjContPaq = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (UsuarioActual.Empresa.UsaAC || UsuarioActual.Empresa.Funcionalidad(200) == "1")
|
|
||||||
{
|
|
||||||
ObjContPaq = new ClsContPAQi(UsuarioActual.Empresa);
|
|
||||||
ObjContPaq.IniciaTransacSQL();
|
|
||||||
}
|
|
||||||
bool ErrorCancelar = false;
|
|
||||||
var ErrorList = new List<string>();
|
|
||||||
|
|
||||||
int IDPoliza = -1;
|
|
||||||
int CvePrePolizaCancelacion = -1;
|
|
||||||
|
|
||||||
// CANCELA PREPOLIZA
|
|
||||||
ErrorCancelar = !ObjVentas.ProcesoPrepolizasCancelacion(CveVenta, UsuarioActual.CveUsuario);
|
|
||||||
|
|
||||||
if (ErrorCancelar)
|
|
||||||
{
|
|
||||||
Mensaje = "Ocurrió un error al generar la prepoliza de cancelación.";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ObjVentas.DtResultados.Rows.Count > 0)
|
|
||||||
{
|
|
||||||
CvePrePolizaCancelacion = ObjVentas.DtResultados.FiltroPrimeroValor("CvePrepolizaCancelacion").ToEntero();
|
|
||||||
if (CvePrePolizaCancelacion <= 0)
|
|
||||||
{
|
|
||||||
ErrorCancelar = true;
|
|
||||||
Mensaje = "Ocurrió un error al generar la prepoliza de cancelación.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ErrorCancelar = true;
|
|
||||||
Mensaje = "Ocurrió un error al generar la prepoliza de cancelación.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// POLIZA DE CANCELACION
|
|
||||||
if (!ErrorCancelar)
|
|
||||||
{
|
|
||||||
if (UsuarioActual.Empresa.UsaAC)
|
|
||||||
{
|
|
||||||
IDPoliza = GenerarPolizaAC(ObjContPaq, CveVenta, Folio, CveCliente, TipoComprobante, DateTime.Now, true);
|
|
||||||
if ((IDPoliza <= 0))
|
|
||||||
{
|
|
||||||
ErrorCancelar = true;
|
|
||||||
Mensaje = "Ocurrió un error al generar la poliza de cancelación.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//AUTO CONTABILIDAD
|
|
||||||
if (!ErrorCancelar)
|
|
||||||
{
|
|
||||||
if (UsuarioActual.Empresa.Funcionalidad(200) == "1" & !ErrorCancelar && CvePrePolizaCancelacion > 0)
|
|
||||||
{
|
|
||||||
if (!ObjConta.ContabilizarPrePoliza(CvePrePolizaCancelacion, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta: ObjContPaq))
|
|
||||||
{
|
|
||||||
ErrorCancelar = true;
|
|
||||||
Mensaje = "Ocurrió un error al contabilizar. Favor de ponerse en contacto con Soporte Técnico";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ACTUALIZA ESTATUS
|
|
||||||
if (!ErrorCancelar)
|
|
||||||
{
|
|
||||||
switch (TipoComprobante)
|
|
||||||
{
|
|
||||||
case "Rem":
|
|
||||||
CveEstatus = 12;
|
|
||||||
break;
|
|
||||||
case "Com":
|
|
||||||
CveEstatus = 9;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!ObjVentas.UpdateCancelaVenta(CveVenta, CancelacionFecha, CancelacionAcuse, UsuarioActual.CveEmpresa, CvePACCancelacion))
|
|
||||||
{
|
|
||||||
ErrorCancelar = true;
|
|
||||||
Mensaje = "Ocurrió un error al guardar el estatus de cancelación.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ErrorCancelar)
|
|
||||||
{
|
|
||||||
if (ObjContPaq != null)
|
|
||||||
{
|
|
||||||
ObjContPaq.Commit();
|
|
||||||
}
|
|
||||||
ObjVentas.Commit();
|
|
||||||
Mensaje = "El Documento se canceló correctamente";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ObjContPaq != null)
|
|
||||||
{
|
|
||||||
ObjContPaq.RollBack();
|
|
||||||
}
|
|
||||||
ObjVentas.RollBack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ObjVentas.RollBack();
|
|
||||||
if (ObjContPaq != null)
|
|
||||||
{
|
|
||||||
ObjContPaq.RollBack();
|
|
||||||
}
|
|
||||||
Mensaje = "Ocurrió un error al cancelar la factura";
|
|
||||||
this.OnError(Mensaje, ex);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
ObjVentas.Dispose();
|
|
||||||
ObjEventos.Dispose();
|
|
||||||
ObjConta.Dispose();
|
|
||||||
if (ObjContPaq != null)
|
|
||||||
{
|
|
||||||
ObjContPaq.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Mensaje;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GenerarPolizaAC(ClsContPAQi ObjAC, int CveVenta, string Folio, int CveCliente, string TipoComprobante, DateTime Fecha, bool CancelacionIngreso = false)
|
private int GenerarPolizaAC(ClsContPAQi ObjAC, int CveVenta, string Folio, int CveCliente, string TipoComprobante, DateTime Fecha, bool CancelacionIngreso = false)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ Imports Microsoft.Reporting.WebForms
|
|||||||
Imports System.IO
|
Imports System.IO
|
||||||
Imports System.IO.Compression
|
Imports System.IO.Compression
|
||||||
Imports System.Net
|
Imports System.Net
|
||||||
|
Imports System.Net.Http
|
||||||
|
|
||||||
Partial Class RepVentaDetalle
|
Partial Class RepVentaDetalle
|
||||||
Inherits ClsPaginas
|
Inherits ClsPaginas
|
||||||
@@ -873,6 +874,27 @@ Partial Class RepVentaDetalle
|
|||||||
Response.ContentType = "application/zip"
|
Response.ContentType = "application/zip"
|
||||||
Response.End()
|
Response.End()
|
||||||
End Sub
|
End Sub
|
||||||
|
Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer) As Byte()
|
||||||
|
Dim Url = New Uri(String.Format("{0}Compras/PopUpVerFactura.aspx?P={1}", ClsPaginas.UrlSitio, Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta))))
|
||||||
|
Dim File As Byte() = Nothing
|
||||||
|
Try
|
||||||
|
Using httpClient = New HttpClient()
|
||||||
|
httpClient.Timeout = New TimeSpan(0, 15, 0)
|
||||||
|
Using request = New HttpRequestMessage(HttpMethod.Get, Url)
|
||||||
|
request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}", CveEmpresa, DateTime.UtcNow.Ticks)))
|
||||||
|
Dim response = httpClient.SendAsync(request).Result
|
||||||
|
If response.StatusCode = Net.HttpStatusCode.OK Then
|
||||||
|
File = response.Content.ReadAsByteArrayAsync().Result
|
||||||
|
End If
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
Catch ex As Exception
|
||||||
|
File = Nothing
|
||||||
|
OnError("Ocurrió un error al descargar la factura", ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return File
|
||||||
|
End Function
|
||||||
|
|
||||||
Private Sub BtnDescargarXML_Click(sender As Object, e As EventArgs) Handles BtnDescargarXML.Click
|
Private Sub BtnDescargarXML_Click(sender As Object, e As EventArgs) Handles BtnDescargarXML.Click
|
||||||
Dim pathXML As String
|
Dim pathXML As String
|
||||||
@@ -973,124 +995,126 @@ Partial Class RepVentaDetalle
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub GenerarFacturaVentaDEV(CveVenta As Integer)
|
Private Sub GenerarFacturaVentaDEV(CveVenta As Integer)
|
||||||
Dim ObjVentas As New ClsVentas
|
|
||||||
Dim Vta As Modelos.Factura = Nothing
|
|
||||||
|
|
||||||
Dim TmpDTImpuestos = New DataTable
|
DescargarFactura(CveVenta, UsuarioActual.CveEmpresa)
|
||||||
TmpDTImpuestos.Columns.Add("ImpuestoLocal", GetType(String))
|
'Dim ObjVentas As New ClsVentas
|
||||||
TmpDTImpuestos.Columns.Add("Importe", GetType(Double))
|
'Dim Vta As Modelos.Factura = Nothing
|
||||||
TmpDTImpuestos.Columns.Add("Orden", GetType(Integer))
|
|
||||||
|
|
||||||
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
|
'Dim TmpDTImpuestos = New DataTable
|
||||||
Dim dtVentas As DataTable = ObjVentas.DtResultados
|
'TmpDTImpuestos.Columns.Add("ImpuestoLocal", GetType(String))
|
||||||
|
'TmpDTImpuestos.Columns.Add("Importe", GetType(Double))
|
||||||
|
'TmpDTImpuestos.Columns.Add("Orden", GetType(Integer))
|
||||||
|
|
||||||
' se rellenan los campos de la factura
|
'If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
|
||||||
Vta = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.Factura)
|
' Dim dtVentas As DataTable = ObjVentas.DtResultados
|
||||||
|
|
||||||
Vta.MonedaAbreviatura = dtVentas(0)("Abreviatura").ToString
|
' ' se rellenan los campos de la factura
|
||||||
'se rellena la sucursal
|
' Vta = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa, Server.MapPath("/"))
|
||||||
Vta.Cliente.Sucursal = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SucursalModel).ToString
|
|
||||||
Vta.Cliente = New Modelos.ClienteModel
|
' Vta.MonedaAbreviatura = dtVentas(0)("Abreviatura").ToString
|
||||||
Vta.Cliente.Nombre = dtVentas(0)("ClienteNombre").ToString
|
' 'se rellena la sucursal
|
||||||
Vta.Cliente.Telefono = dtVentas(0)("Telefono").ToString
|
' Vta.Cliente.Sucursal = New Modelos.ClienteModel(dtVentas(0)("CveCliente").ToString.ToEntero, UsuarioActual.CveEmpresa)
|
||||||
Vta.Cliente.Direccion = dtVentas(0)("ClienteDireccion").ToString
|
' Vta.Cliente = New Modelos.ClienteModel
|
||||||
Vta.Cliente.CP = dtVentas(0)("CPCliente").ToString
|
' Vta.Cliente.Nombre = dtVentas(0)("ClienteNombre").ToString
|
||||||
Vta.Cliente.Ciudad = dtVentas(0)("ClienteCiudad").ToString
|
' Vta.Cliente.Telefono = dtVentas(0)("Telefono").ToString
|
||||||
Vta.Cliente.Localidad = dtVentas(0)("ClienteLocalidad").ToString
|
' Vta.Cliente.Direccion = dtVentas(0)("ClienteDireccion").ToString
|
||||||
Vta.Cliente.Estado = dtVentas(0)("ClienteEstado").ToString
|
' Vta.Cliente.CP = dtVentas(0)("CPCliente").ToString
|
||||||
Vta.Cliente.Pais = dtVentas(0)("ClientePais").ToString
|
' Vta.Cliente.Ciudad = dtVentas(0)("ClienteCiudad").ToString
|
||||||
Vta.Cliente.RFC = dtVentas(0)("ClienteRFC").ToString
|
' Vta.Cliente.Localidad = dtVentas(0)("ClienteLocalidad").ToString
|
||||||
Vta.Cliente.Colonia = dtVentas(0)("ColoniaCliente").ToString
|
' Vta.Cliente.Estado = dtVentas(0)("ClienteEstado").ToString
|
||||||
Vta.AtencionA = dtVentas(0)("AtencionA").ToString
|
' Vta.Cliente.Pais = dtVentas(0)("ClientePais").ToString
|
||||||
Vta.Cliente.NoExt = dtVentas(0)("ClienteNoExt").ToString
|
' Vta.Cliente.RFC = dtVentas(0)("ClienteRFC").ToString
|
||||||
Vta.Cliente.NoInt = dtVentas(0)("ClienteNoInt").ToString
|
' Vta.Cliente.Colonia = dtVentas(0)("ColoniaCliente").ToString
|
||||||
Vta.Cliente.Codigo = dtVentas(0)("ClienteCodigo").ToString
|
' Vta.AtencionA = dtVentas(0)("AtencionA").ToString
|
||||||
Vta.Cliente.Mail = dtVentas(0)("Mail").ToString
|
' Vta.Cliente.NoExt = dtVentas(0)("ClienteNoExt").ToString
|
||||||
Vta.RefDocto = dtVentas(0)("Ref").ToString
|
' Vta.Cliente.NoInt = dtVentas(0)("ClienteNoInt").ToString
|
||||||
Vta.CveVenta = dtVentas(0)("CveVenta").ToString.ToEntero
|
' Vta.Cliente.Codigo = dtVentas(0)("ClienteCodigo").ToString
|
||||||
|
' Vta.Cliente.Mail = dtVentas(0)("Mail").ToString
|
||||||
|
' Vta.RefDocto = dtVentas(0)("Ref").ToString
|
||||||
|
' Vta.CveVenta = dtVentas(0)("CveVenta").ToString.ToEntero
|
||||||
|
|
||||||
|
|
||||||
Vta.ClienteSucursal = New Modelos.SucursalModel
|
' Vta.ClienteSucursal = New Modelos.SucursalModel
|
||||||
Vta.ClienteSucursal.Direccion = dtVentas(0)("SucClienteDireccion").ToString
|
' Vta.ClienteSucursal.Direccion = dtVentas(0)("SucClienteDireccion").ToString
|
||||||
Vta.ClienteSucursal.NoExt = dtVentas(0)("SucClienteNoExt").ToString
|
' Vta.ClienteSucursal.NoExt = dtVentas(0)("SucClienteNoExt").ToString
|
||||||
Vta.ClienteSucursal.NoInt = dtVentas(0)("SucClienteNoInt").ToString
|
' Vta.ClienteSucursal.NoInt = dtVentas(0)("SucClienteNoInt").ToString
|
||||||
Vta.ClienteSucursal.Colonia = dtVentas(0)("SucClienteColonia").ToString
|
' Vta.ClienteSucursal.Colonia = dtVentas(0)("SucClienteColonia").ToString
|
||||||
Vta.ClienteSucursal.CP = dtVentas(0)("SucClienteCP").ToString
|
' Vta.ClienteSucursal.CP = dtVentas(0)("SucClienteCP").ToString
|
||||||
Vta.ClienteSucursal.Municipio = dtVentas(0)("SucClienteCiudad").ToString
|
' Vta.ClienteSucursal.Municipio = dtVentas(0)("SucClienteCiudad").ToString
|
||||||
Vta.ClienteSucursal.Estado = dtVentas(0)("SucClienteEstado").ToString
|
' Vta.ClienteSucursal.Estado = dtVentas(0)("SucClienteEstado").ToString
|
||||||
Vta.ClienteSucursal.Pais = dtVentas(0)("SucClientePais").ToString
|
' Vta.ClienteSucursal.Pais = dtVentas(0)("SucClientePais").ToString
|
||||||
Vta.ClienteSucursal.Localidad = dtVentas(0)("SucClienteLocalidad").ToString
|
' Vta.ClienteSucursal.Localidad = dtVentas(0)("SucClienteLocalidad").ToString
|
||||||
Vta.ClienteSucursal.CorreoSucursal = dtVentas(0)("SucClienteCorreo").ToString
|
' Vta.ClienteSucursal.CorreoSucursal = dtVentas(0)("SucClienteCorreo").ToString
|
||||||
Vta.ClienteSucursal.TelefonoSucursal = dtVentas(0)("SucClienteTelefono").ToString
|
' Vta.ClienteSucursal.TelefonoSucursal = dtVentas(0)("SucClienteTelefono").ToString
|
||||||
Vta.ClienteSucursal.Sucursal = dtVentas(0)("SucursalCliente").ToString
|
' Vta.ClienteSucursal.Sucursal = dtVentas(0)("SucursalCliente").ToString
|
||||||
|
|
||||||
Vta.EnviarA = New Modelos.EnviarAModel
|
' Vta.EnviarA = New Modelos.EnviarAModel
|
||||||
Vta.EnviarA.CveDireccionEnvio = dtVentas(0)("CveDireccionEnvio").ToString.ToEntero
|
' Vta.EnviarA.CveDireccionEnvio = dtVentas(0)("CveDireccionEnvio").ToString.ToEntero
|
||||||
Vta.EnviarA.EnvioDireccion = dtVentas(0)("EnvioDireccion").ToString
|
' Vta.EnviarA.EnvioDireccion = dtVentas(0)("EnvioDireccion").ToString
|
||||||
Vta.EnviarA.EnvioColonia = dtVentas(0)("EnvioColonia").ToString
|
' Vta.EnviarA.EnvioColonia = dtVentas(0)("EnvioColonia").ToString
|
||||||
Vta.EnviarA.EnvioCiudad = dtVentas(0)("EnvioCiudad").ToString
|
' Vta.EnviarA.EnvioCiudad = dtVentas(0)("EnvioCiudad").ToString
|
||||||
Vta.EnviarA.EnvioEstado = dtVentas(0)("EnvioEstado").ToString
|
' Vta.EnviarA.EnvioEstado = dtVentas(0)("EnvioEstado").ToString
|
||||||
Vta.EnviarA.EnvioCP = dtVentas(0)("EnvioCP").ToString
|
' Vta.EnviarA.EnvioCP = dtVentas(0)("EnvioCP").ToString
|
||||||
|
|
||||||
Dim DR As DataRow = TmpDTImpuestos.NewRow()
|
' Dim DR As DataRow = TmpDTImpuestos.NewRow()
|
||||||
If UsuarioActual.CveEmpresa.Contiene(1, 5, 15, 17, 72, 66, 79, 81, 109, 110, 111, 76) Then
|
' If UsuarioActual.CveEmpresa.Contiene(1, 5, 15, 17, 72, 66, 79, 81, 109, 110, 111, 76) Then
|
||||||
If dtVentas(0)("SubTotal").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Subtotal" : DR("Importe") = dtVentas(0)("SubTotal").ToString.ToDouble : DR("Orden") = 10 : TmpDTImpuestos.Rows.Add(DR)
|
' If dtVentas(0)("SubTotal").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Subtotal" : DR("Importe") = dtVentas(0)("SubTotal").ToString.ToDouble : DR("Orden") = 10 : TmpDTImpuestos.Rows.Add(DR)
|
||||||
DR = TmpDTImpuestos.NewRow()
|
' DR = TmpDTImpuestos.NewRow()
|
||||||
If dtVentas(0)("Descuento").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Descuentos" : DR("Importe") = dtVentas(0)("Descuento").ToString.ToDouble : DR("Orden") = 20 : TmpDTImpuestos.Rows.Add(DR)
|
' If dtVentas(0)("Descuento").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Descuentos" : DR("Importe") = dtVentas(0)("Descuento").ToString.ToDouble : DR("Orden") = 20 : TmpDTImpuestos.Rows.Add(DR)
|
||||||
DR = TmpDTImpuestos.NewRow()
|
' DR = TmpDTImpuestos.NewRow()
|
||||||
If dtVentas(0)("Amortizacion").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Amort.Ant" : DR("Importe") = dtVentas(0)("Amortizacion").ToString.ToDouble : DR("Orden") = 30 : TmpDTImpuestos.Rows.Add(DR)
|
' If dtVentas(0)("Amortizacion").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Amort.Ant" : DR("Importe") = dtVentas(0)("Amortizacion").ToString.ToDouble : DR("Orden") = 30 : TmpDTImpuestos.Rows.Add(DR)
|
||||||
DR = TmpDTImpuestos.NewRow()
|
' DR = TmpDTImpuestos.NewRow()
|
||||||
If dtVentas(0)("SubTotal").ToString.ToDouble <> (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) Then DR("ImpuestoLocal") = "SubTotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) : DR("Orden") = 40 : TmpDTImpuestos.Rows.Add(DR)
|
' If dtVentas(0)("SubTotal").ToString.ToDouble <> (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) Then DR("ImpuestoLocal") = "SubTotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) : DR("Orden") = 40 : TmpDTImpuestos.Rows.Add(DR)
|
||||||
DR = TmpDTImpuestos.NewRow()
|
' DR = TmpDTImpuestos.NewRow()
|
||||||
If dtVentas(0)("IVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "IVA" : DR("Importe") = dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 50 : TmpDTImpuestos.Rows.Add(DR)
|
' If dtVentas(0)("IVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "IVA" : DR("Importe") = dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 50 : TmpDTImpuestos.Rows.Add(DR)
|
||||||
|
|
||||||
'solo para eclipse, que muesre un subtotal debajo de IVA
|
' 'solo para eclipse, que muesre un subtotal debajo de IVA
|
||||||
If UsuarioActual.CveEmpresa = 15 Then DR = TmpDTImpuestos.NewRow() : DR("ImpuestoLocal") = "Subtotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) + dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 51 : TmpDTImpuestos.Rows.Add(DR)
|
' If UsuarioActual.CveEmpresa = 15 Then DR = TmpDTImpuestos.NewRow() : DR("ImpuestoLocal") = "Subtotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) + dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 51 : TmpDTImpuestos.Rows.Add(DR)
|
||||||
DR = TmpDTImpuestos.NewRow()
|
' DR = TmpDTImpuestos.NewRow()
|
||||||
If dtVentas(0)("RetIVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.IVA" : DR("Importe") = dtVentas(0)("RetIVA").ToString.ToDouble : DR("Orden") = 60 : TmpDTImpuestos.Rows.Add(DR)
|
' If dtVentas(0)("RetIVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.IVA" : DR("Importe") = dtVentas(0)("RetIVA").ToString.ToDouble : DR("Orden") = 60 : TmpDTImpuestos.Rows.Add(DR)
|
||||||
DR = TmpDTImpuestos.NewRow()
|
' DR = TmpDTImpuestos.NewRow()
|
||||||
If dtVentas(0)("RetISR").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.ISR" : DR("Importe") = dtVentas(0)("RetISR").ToString.ToDouble : DR("Orden") = 70 : TmpDTImpuestos.Rows.Add(DR)
|
' If dtVentas(0)("RetISR").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.ISR" : DR("Importe") = dtVentas(0)("RetISR").ToString.ToDouble : DR("Orden") = 70 : TmpDTImpuestos.Rows.Add(DR)
|
||||||
DR = TmpDTImpuestos.NewRow()
|
' DR = TmpDTImpuestos.NewRow()
|
||||||
If dtVentas(0)("Total").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = dtVentas(0)("Total").ToString.ToDouble : DR("Orden") = 1000 : TmpDTImpuestos.Rows.Add(DR)
|
' If dtVentas(0)("Total").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = dtVentas(0)("Total").ToString.ToDouble : DR("Orden") = 1000 : TmpDTImpuestos.Rows.Add(DR)
|
||||||
DR = TmpDTImpuestos.NewRow()
|
' DR = TmpDTImpuestos.NewRow()
|
||||||
End If
|
' End If
|
||||||
|
|
||||||
If ObjVentas.GetVentaDetalle(CveVenta) Then 'Obtenemos el Detalle de la Oorden de Compra
|
' If ObjVentas.GetVentaDetalle(CveVenta) Then 'Obtenemos el Detalle de la Oorden de Compra
|
||||||
Vta.DtDetalle = ObjVentas.DtResultados
|
' Vta.DtDetalle = ObjVentas.DtResultados
|
||||||
End If
|
' End If
|
||||||
|
|
||||||
If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then
|
' If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then
|
||||||
If UsuarioActual.CveEmpresa.Contiene(1, 5, 15, 17, 72, 66, 79, 81, 109, 110, 111, 76) Then
|
' If UsuarioActual.CveEmpresa.Contiene(1, 5, 15, 17, 72, 66, 79, 81, 109, 110, 111, 76) Then
|
||||||
Dim dtImpuesto As DataTable = ObjVentas.DtResultados
|
' Dim dtImpuesto As DataTable = ObjVentas.DtResultados
|
||||||
If dtImpuesto.Rows.Count > 0 Then
|
' If dtImpuesto.Rows.Count > 0 Then
|
||||||
For Each Row As DataRow In dtImpuesto.Rows
|
' For Each Row As DataRow In dtImpuesto.Rows
|
||||||
Dim Orden = 80
|
' Dim Orden = 80
|
||||||
If Row("Importe").ToString.ToDouble <> 0 Then
|
' If Row("Importe").ToString.ToDouble <> 0 Then
|
||||||
DR("ImpuestoLocal") = Row("ImpuestoLocal").ToString
|
' DR("ImpuestoLocal") = Row("ImpuestoLocal").ToString
|
||||||
DR("Importe") = Row("Importe").ToString.ToDouble
|
' DR("Importe") = Row("Importe").ToString.ToDouble
|
||||||
DR("Orden") = Orden
|
' DR("Orden") = Orden
|
||||||
TmpDTImpuestos.Rows.Add(DR)
|
' TmpDTImpuestos.Rows.Add(DR)
|
||||||
DR = TmpDTImpuestos.NewRow()
|
' DR = TmpDTImpuestos.NewRow()
|
||||||
Orden = Orden + 1
|
' Orden = Orden + 1
|
||||||
End If
|
' End If
|
||||||
Next
|
' Next
|
||||||
End If
|
' End If
|
||||||
Vta.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC")
|
' Vta.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC")
|
||||||
Else
|
' Else
|
||||||
Vta.DtDeduccion = ObjVentas.DtResultados
|
' Vta.DtDeduccion = ObjVentas.DtResultados
|
||||||
End If
|
' End If
|
||||||
End If
|
' End If
|
||||||
|
|
||||||
If ObjVentas.GetVentasFirmas(CveVenta) Then
|
' If ObjVentas.GetVentasFirmas(CveVenta) Then
|
||||||
Vta.DtFirmas = ObjVentas.DtResultados
|
' Vta.DtFirmas = ObjVentas.DtResultados
|
||||||
End If
|
' End If
|
||||||
End If
|
'End If
|
||||||
ObjVentas.Dispose()
|
'ObjVentas.Dispose()
|
||||||
|
|
||||||
If Not IsNothing(Vta) Then
|
'If Not IsNothing(Vta) Then
|
||||||
PdfFactura(Vta)
|
' PdfFactura(Vta)
|
||||||
Vta = Nothing
|
' Vta = Nothing
|
||||||
End If
|
'End If
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
@@ -7266,7 +7266,13 @@ Partial Class Ventas
|
|||||||
|
|
||||||
|
|
||||||
Private Sub CreaObjetosVenta(Optional VistaPrevia As Boolean = False)
|
Private Sub CreaObjetosVenta(Optional VistaPrevia As Boolean = False)
|
||||||
ObjFactura = New Modelos.Factura
|
|
||||||
|
If Me.CveVenta > 0 Then
|
||||||
|
ObjFactura = New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa)
|
||||||
|
Else
|
||||||
|
ObjFactura = New Modelos.Factura
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
ObjFactura.Version = "3.3"
|
ObjFactura.Version = "3.3"
|
||||||
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
ObjFactura.CveUsuario = UsuarioActual.CveUsuario
|
||||||
@@ -17127,6 +17133,8 @@ Partial Class Ventas
|
|||||||
TxtPrecio.Text = GvRow.FCLiteral("LtlPU").Text
|
TxtPrecio.Text = GvRow.FCLiteral("LtlPU").Text
|
||||||
RegistraScript("Recalcula();")
|
RegistraScript("Recalcula();")
|
||||||
LbAgregar_Click(Nothing, Nothing)
|
LbAgregar_Click(Nothing, Nothing)
|
||||||
|
Else
|
||||||
|
DdlPS_SelectedIndexChanged(Nothing, Nothing)
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
Protected Sub OrdenarGvPS(ByVal sender As Object, ByVal e As EventArgs)
|
Protected Sub OrdenarGvPS(ByVal sender As Object, ByVal e As EventArgs)
|
||||||
@@ -17413,874 +17421,40 @@ Partial Class Ventas
|
|||||||
CancelarRefacturada()
|
CancelarRefacturada()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'La validacion de saldos cuando es refacturacion se hace antes asi que si es refacturacion ignoramos esta condicion, si es Anticipo verifica que no esté aplicado
|
|
||||||
If 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 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
|
|
||||||
|
|
||||||
'CARGA REMISIONES DE LA VENTA DEVUELTA
|
|
||||||
Dim DtDevRem As New DataTable
|
|
||||||
If Not EsRefacturacion Then
|
|
||||||
Dim ObjInventarioTemporal As New ClsInventarios()
|
|
||||||
If ObjInventarioTemporal.GetDevolucionRemisionesCanceladas(CveVenta) Then
|
|
||||||
DtDevRem = ObjInventarioTemporal.DtResultados
|
|
||||||
Else
|
|
||||||
Alert("Ocurrió un error al verificar los movimientos de almacén relacionados al documento.", TipoMensaje.MsgError)
|
|
||||||
ObjInventarioTemporal.Dispose()
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
ObjInventarioTemporal.Dispose()
|
|
||||||
End If
|
|
||||||
|
|
||||||
'[IPP] FALTA TERMINAR 27/Noviembre/2018
|
|
||||||
'' si tiene movimientos en almacen que se hallan surtido en el documento actual, y sigue sin ser marcado como devuelto
|
|
||||||
'If (GvInv.Rows.Count > 0 AndAlso DevolucionAlmacen.Contiene(0, 1)) And DtDevRem.COUNT("CantidadSurtida", "ISNULL(CveRem,0) = 0") > 0 Then ' [COMENTADO IPP 3 Agosto 2017] | AndAlso Not (DdlTipoComprobante.SelectedValue.Contiene("Rem", "DPe")) | REMISION YA SE DEBE HACER POR EL PROCESO DE DEVOLUCION DE ALMACEN
|
|
||||||
' Alert("La factura no se puede cancelar debido a que tiene movimientos de inventario.", TipoMensaje.MsgAdvertencia)
|
|
||||||
' Exit Sub
|
|
||||||
'End If
|
|
||||||
|
|
||||||
Dim ReviveRemision As Boolean = False
|
|
||||||
'RMF. ANOTACION. cuando se cancela, y tiene relacionada una remisión, y esta no se cancelará. debe de hacer en automático los movimientos al almacen de entrega por adelantado
|
|
||||||
If Not EsRefacturacion AndAlso ChkCanRem.Visible AndAlso ChkCanRem.Checked = False Then
|
|
||||||
ReviveRemision = True
|
|
||||||
End If
|
|
||||||
If Not EsRefacturacion AndAlso (VentaSaldoAlmacen > 0 AndAlso DevolucionAlmacen.Contiene(0, 1)) AndAlso Not ChkDevAlm.Checked And ReviveRemision = False Then ' [COMENTADO IPP 3 Agosto 2017] | AndAlso Not (DdlTipoComprobante.SelectedValue.Contiene("Rem", "DPe")) | REMISION YA SE DEBE HACER POR EL PROCESO DE DEVOLUCION DE ALMACEN
|
|
||||||
Alert("La factura no se puede cancelar debido a que tiene movimientos de inventario.", TipoMensaje.MsgAdvertencia)
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
|
|
||||||
Dim CancelacionFecha As Date
|
|
||||||
Dim CancelacionAcuse As String = ""
|
|
||||||
Dim MensajeError As String = ""
|
|
||||||
Dim ObjCancelacion As New Timbrado
|
|
||||||
Dim TotalT As Decimal = TxtTotal.Text.ToDecimal
|
|
||||||
Dim RFCReceptor As String = LblRFC.Text.Trim
|
|
||||||
Dim CvePACCancelacion As Integer = CvePAC
|
|
||||||
Dim CveEstatus As Integer = 4
|
|
||||||
Dim IDPoliza As Integer = -1
|
|
||||||
Dim CvePrePoliza As Integer
|
|
||||||
Dim CvePlantillaPoliza As Integer
|
|
||||||
Dim ErrorCancelar As Boolean = False
|
|
||||||
|
|
||||||
Dim Continuar As Boolean = False
|
|
||||||
Dim ContinuarCancelacion As Boolean = False
|
|
||||||
Dim ObtenerAcuse As Boolean = False
|
|
||||||
Dim RequiereAceptacion As Boolean = False
|
|
||||||
Dim Mensaje As String = ""
|
|
||||||
Try
|
|
||||||
If FolioFiscal <> "" Then
|
|
||||||
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Dev", "Egs") Then
|
|
||||||
|
|
||||||
Dim Vigencia = Timbrado.VerificarVigenciaSAT(FolioFiscal, UsuarioActual.Empresa.RFC, RFCReceptor, TotalT.ToString(), UsuarioActual.Empresa.FacturaProduccion)
|
|
||||||
If Vigencia IsNot Nothing Then
|
|
||||||
If Vigencia.EsCancelable.ToUpper() = "NO CANCELABLE" Then
|
|
||||||
Alert("Esta factura no es cancelable.", TipoMensaje.MsgAdvertencia)
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
If Vigencia.Estado.ToUpper().Contains("CANCELADO") Then
|
|
||||||
ContinuarCancelacion = False
|
|
||||||
ObtenerAcuse = True
|
|
||||||
Dim solicitud = New WSGF.Service1SoapClient()
|
|
||||||
Dim acuse = solicitud.GetAcuse(UsuarioActual.Empresa.RFC, "rene.molina@adsistemas.mx", "rene2018", FolioFiscal)
|
|
||||||
|
|
||||||
If acuse.Estado = 0 Then
|
|
||||||
Dim xmlAcuse = New System.Xml.XmlDocument()
|
|
||||||
xmlAcuse.LoadXml(DecodeBase64(acuse.CfdiB64))
|
|
||||||
CancelacionAcuse = xmlAcuse.GetElementsByTagName("SignatureValue")(0).InnerText
|
|
||||||
CancelacionFecha = xmlAcuse.SelectSingleNode("Acuse").Attributes("Fecha").Value.ToDate()
|
|
||||||
CveEstatus = 5
|
|
||||||
Else
|
|
||||||
CancelacionFecha = Now.Date
|
|
||||||
CancelacionAcuse = ""
|
|
||||||
CveEstatus = 5
|
|
||||||
End If
|
|
||||||
|
|
||||||
ElseIf Vigencia.Estado.ToUpper().Contains("VIGENTE") Then
|
|
||||||
|
|
||||||
If Vigencia.EstatusCancelacion.ToUpper() = "EN PROCESO" Then
|
|
||||||
CveEstatus = 20
|
|
||||||
ContinuarCancelacion = False
|
|
||||||
If ChkCanRem.Checked Then SeCancelaRemisionProceso = True
|
|
||||||
ElseIf Vigencia.EsCancelable.ToUpper() = "CANCELABLE CON ACEPTACIÓN" Then
|
|
||||||
CveEstatus = 20
|
|
||||||
ContinuarCancelacion = True
|
|
||||||
RequiereAceptacion = True
|
|
||||||
If ChkCanRem.Checked Then SeCancelaRemisionProceso = True
|
|
||||||
ElseIf Vigencia.EsCancelable.ToUpper() = "CANCELABLE SIN ACEPTACIÓN" Then
|
|
||||||
ContinuarCancelacion = True
|
|
||||||
CveEstatus = 5
|
|
||||||
End If
|
|
||||||
|
|
||||||
Else
|
|
||||||
If Vigencia.EsCancelable.ToUpper() = "CANCELABLE SIN ACEPTACIÓN" Then
|
|
||||||
ContinuarCancelacion = True
|
|
||||||
CveEstatus = 5
|
|
||||||
Else
|
|
||||||
'Alert("La factura no se puede cancelar debido a que no se encontro su estatus en el SAT.", TipoMensaje.MsgAdvertencia)
|
|
||||||
'Exit Sub
|
|
||||||
CveEstatus = 20
|
|
||||||
ContinuarCancelacion = False
|
|
||||||
CancelacionFecha = Now.Date
|
|
||||||
CancelacionAcuse = ""
|
|
||||||
If ChkCanRem.Checked Then SeCancelaRemisionProceso = True
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
Alert("No se pudo comprobar la vigencia de la factura.", TipoMensaje.MsgAdvertencia)
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ObtenerAcuse Then
|
|
||||||
If ContinuarCancelacion Then
|
|
||||||
If ObjCancelacion.CFDICancelar(UsuarioActual.Empresa, FolioFiscal, TotalT, RFCReceptor, UsuarioActual.Empresa.RFC, CvePACCancelacion) Then
|
|
||||||
'Generamos el acuse y mandamos mail de con el acuse de cancelación - DF 13/01/2017
|
|
||||||
If RequiereAceptacion Then
|
|
||||||
CancelacionFecha = Now.Date
|
|
||||||
CancelacionAcuse = ""
|
|
||||||
CveEstatus = 20
|
|
||||||
If ChkCanRem.Checked Then SeCancelaRemisionProceso = True
|
|
||||||
Else
|
|
||||||
CancelacionFecha = ObjCancelacion.CancelacionFecha
|
|
||||||
CancelacionAcuse = ObjCancelacion.CancelacionAcuse
|
|
||||||
CveEstatus = 5
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
Alert("La factura no se pudo cancelar ante el SAT", TipoMensaje.MsgError)
|
|
||||||
Exit Sub
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
CancelacionFecha = Now.Date
|
|
||||||
CancelacionAcuse = ""
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
CancelacionFecha = Now.Date
|
|
||||||
CancelacionAcuse = ""
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
CancelacionFecha = Now.Date
|
|
||||||
CancelacionAcuse = ""
|
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
|
||||||
MensajeError = "Ocurrió un Error al Cancelar la factura con los servicios del SAT."
|
|
||||||
GuardaLog($"{MensajeError} - Error:{ex.Message}")
|
|
||||||
Alert(MensajeError, TipoMensaje.MsgError)
|
|
||||||
Exit Sub
|
|
||||||
End Try
|
|
||||||
|
|
||||||
Dim ObjVentas As New ClsVentas() : ObjVentas.IniciaTransacSQL()
|
|
||||||
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
|
||||||
Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL())
|
|
||||||
Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL())
|
|
||||||
Dim ObjContrato As New ClsContratos(ObjVentas.IniciaTransacSQL())
|
|
||||||
Dim ObjEventos As New ClsOIEventos(ObjVentas.IniciaTransacSQL())
|
|
||||||
Dim ObjAC As ClsContPAQi = Nothing
|
|
||||||
If UsuarioActual.Empresa.UsaAC Then
|
|
||||||
ObjAC = New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL()
|
|
||||||
End If
|
|
||||||
CreaObjetosVenta()
|
CreaObjetosVenta()
|
||||||
|
Dim resp As Modelos.Factura.MCancelacionVentaMensaje = Nothing
|
||||||
|
|
||||||
ObjFactura.CveVenta = CveVenta
|
If ObjFactura IsNot Nothing AndAlso ObjFactura.CveVenta > 0 Then
|
||||||
If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
|
|
||||||
CvePlantillaPoliza = 7
|
|
||||||
ElseIf ObjFactura.TipoDocto.Contiene("Ing", "Rem", "Ant") Then
|
|
||||||
CvePlantillaPoliza = 4
|
|
||||||
Else
|
|
||||||
CvePlantillaPoliza = 4
|
|
||||||
End If
|
|
||||||
|
|
||||||
If ((HplSaldoAuxiliar.Text.ToDecimal > 0 OrElse (TxtTotal.Text.ToDecimal = 0 AndAlso UsuarioActual.CveEmpresa.Contiene(72) AndAlso ObjFactura.TipoDocto.Contiene("Ing"))) AndAlso CveEstatus.Contiene(4, 5)) OrElse CvePlantillaPoliza = 7 Then
|
|
||||||
'RMF. 2018.08.08 cuando se cancela, la póliza debe de ser de diario
|
|
||||||
CvePrePoliza = ObjConta.AddPrePolizas("Ventas/CancelarDocumento", CvePlantillaPoliza, TxtTotal.Text.ToDouble, TxtTotal.Text.ToDouble, DdlMoneda.SelectedValue.ToEntero, Now, NombreCliente, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
|
|
||||||
ObjFactura.CvePrePoliza = CvePrePoliza
|
|
||||||
|
|
||||||
'CANCELAR PAGOS
|
|
||||||
If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If Not ObjConta.PrePolizasCancelarPagos(CveDevolucion, CvePrePoliza) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al generar la prepoliza de cancelación de pago."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'CANCELA PREPOLIZA
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
ErrorCancelar = ProcesoPrepolizas(ObjConta, ObjFactura, -1, TmpDT, ObjAC, -1, ObjBancos, ObjVentas, ObjEventos)
|
|
||||||
MensajeError = "Ocurrió un error al generar la prepoliza de cancelación."
|
|
||||||
End If
|
|
||||||
|
|
||||||
'CANCELA IMPUESTOS LOCALES
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
ErrorCancelar = GuardarVentaImpuestosLocales(ObjVentas, ObjConta, ObjFactura, -1)
|
|
||||||
MensajeError = "Ocurrió un error al cancelar los impuestos locales."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'CANCELA CONTRATOS
|
|
||||||
If Not EsRefacturacion Then
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
ErrorList = New List(Of String)
|
|
||||||
If ObjFactura.CveContrato > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") Then
|
|
||||||
GuardarContratoAvanceEstimaciones(ObjContrato, ObjFactura, ErrorList, -1, True)
|
|
||||||
ErrorCancelar = ErrorList.Count > 0
|
|
||||||
MensajeError = "Ocurrió un error al cancelar las estimaciones del contrato."
|
|
||||||
ElseIf ObjFactura.CveContrato > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Egs", "Dev") Then
|
|
||||||
GuardarContratoAvanceEstimaciones(ObjContrato, ObjFactura, ErrorList, 1, True)
|
|
||||||
ErrorCancelar = ErrorList.Count > 0
|
|
||||||
MensajeError = "Ocurrió un error al cancelar los avances del contrato."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
'DESVINCULA COTIZACIONES PREDECESORAS
|
|
||||||
If Not EsRefacturacion Then
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") Then
|
|
||||||
If Not ObjVentas.LiberarCotizacionesFacturadas(CveVenta) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al desvincular las cotizaciones."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'DESVINCULA PEDIDOS2 PREDECESORES
|
|
||||||
If Not EsRefacturacion Then
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem") Then
|
|
||||||
If Not ObjVentas.LiberarPedidos2Facturados(CveVenta) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al desvincular los pedidos."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
'DESVINCULA OCs PREDECESORAS
|
|
||||||
If Not EsRefacturacion Then
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If DdlTipoComprobante.SelectedValue = "Ing" Then
|
|
||||||
If Not ObjVentas.LiberarOCFacturadas(CveVenta) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al desvincular las Ordenes de Compra."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'ELIMINA LAS VENTAS DETALLE DE LA DEVOLUCION
|
|
||||||
If Not EsRefacturacion Then
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If DdlTipoComprobante.SelectedValue = "Dev" Then
|
|
||||||
If Not ObjVentas.RemoveVentaDetalleDevolucion(CveVenta) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al eliminar las ventas detalle devolución."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
'POLIZA DE CANCELACION
|
|
||||||
If Not EsRefacturacion Then
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If UsuarioActual.Empresa.UsaAC Then
|
|
||||||
IDPoliza = GenerarPolizaAC(ObjAC, True)
|
|
||||||
If IDPoliza <= 0 Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al generar la poliza de cancelación."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'DEVOLUCION DE ALMACEN
|
|
||||||
If ChkDevAlm.Checked Or ReviveRemision Then
|
|
||||||
Dim TieneSalida As Boolean = False
|
|
||||||
Dim DtDatos As New DataTable
|
|
||||||
Dim DtExistencias As New DataTable
|
|
||||||
|
|
||||||
If DevolucionAlmacen = 0 Then
|
|
||||||
Dim EstatusDevolucion = 1
|
|
||||||
If Not ObjVentas.UpdateVentasDevolucionAlmacen(EstatusDevolucion, CveVenta) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al solicitar la devolucion de almacen."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ErrorCancelar AndAlso ObjInventario.EntregaAlmacenGet(CveVenta) Then
|
|
||||||
If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then
|
|
||||||
DtDatos = ObjInventario.DtResultados
|
|
||||||
DtDatos.Columns.Add("Consec", GetType(Integer))
|
|
||||||
DtDatos.Columns.Add("CantidadGV", GetType(Double))
|
|
||||||
DtDatos.Columns.Add("CantidadTraspaso", GetType(Double))
|
|
||||||
Dim Index = 1
|
|
||||||
For Each Dr As DataRow In DtDatos.Rows
|
|
||||||
Dr("Consec") = Index
|
|
||||||
Dr("CantidadGV") = Dr("CantidadF")
|
|
||||||
Index += 1
|
|
||||||
Next
|
|
||||||
|
|
||||||
If DtDatos IsNot Nothing AndAlso DtDatos.Rows.Count > 0 AndAlso ObjInventario.DtResultados.Rows(0)("CveVentaPadre").ToString.ToEntero > 0 Then
|
|
||||||
Dim Filtro As String '= If(ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString.Contiene({"Ing", "Dev", "Ped"}), "CveConcepto = 3", "CveConcepto = 9")
|
|
||||||
Select Case ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString
|
|
||||||
Case "Ing", "Ped"
|
|
||||||
Filtro = "CveConcepto = 3"
|
|
||||||
Case "Dev"
|
|
||||||
Filtro = "CveConcepto = 3"
|
|
||||||
Case Else
|
|
||||||
Filtro = "CveConcepto = 9"
|
|
||||||
End Select
|
|
||||||
If ObjInventario.GetInv_Mov(ObjInventario.DtResultados.Rows(0)("CveVentaPadre").ToString.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
||||||
DtExistencias = ObjInventario.DtResultados.FiltraParametros($"CvePS Is Not NULL AND {Filtro}")
|
|
||||||
|
|
||||||
If DtExistencias.Rows.Count > 0 Then
|
|
||||||
TieneSalida = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
Else
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ErrorCancelar AndAlso TieneSalida Then
|
|
||||||
Dim DtDatosDetalle As New DataTable
|
|
||||||
DtDatosDetalle.Columns.Add("CveVentaDetalle", GetType(Integer))
|
|
||||||
DtDatosDetalle.Columns.Add("Consec", GetType(Integer))
|
|
||||||
DtDatosDetalle.Columns.Add("ConsecId", GetType(Integer))
|
|
||||||
DtDatosDetalle.Columns.Add("CvePS", GetType(Integer))
|
|
||||||
DtDatosDetalle.Columns.Add("PS", GetType(String))
|
|
||||||
DtDatosDetalle.Columns.Add("CveUM", GetType(Integer))
|
|
||||||
DtDatosDetalle.Columns.Add("SerieLote", GetType(String))
|
|
||||||
DtDatosDetalle.Columns.Add("FechaCaducidad", GetType(String))
|
|
||||||
DtDatosDetalle.Columns.Add("FueTraspaso", GetType(Integer))
|
|
||||||
|
|
||||||
Dim DtDatosDetalleLote As New DataTable
|
|
||||||
DtDatosDetalleLote.Columns.Add("CveVentaDetalle", GetType(Integer))
|
|
||||||
DtDatosDetalleLote.Columns.Add("Consec", GetType(Integer))
|
|
||||||
DtDatosDetalleLote.Columns.Add("ConsecId", GetType(Integer))
|
|
||||||
DtDatosDetalleLote.Columns.Add("Cantidad", GetType(Double))
|
|
||||||
DtDatosDetalleLote.Columns.Add("CvePS", GetType(Integer))
|
|
||||||
DtDatosDetalleLote.Columns.Add("PS", GetType(String))
|
|
||||||
DtDatosDetalleLote.Columns.Add("CveUM", GetType(Integer))
|
|
||||||
DtDatosDetalleLote.Columns.Add("Lote", GetType(String))
|
|
||||||
DtDatosDetalleLote.Columns.Add("Batch", GetType(String))
|
|
||||||
DtDatosDetalleLote.Columns.Add("FechaCaducidad", GetType(String))
|
|
||||||
DtDatosDetalleLote.Columns.Add("FueTraspaso", GetType(Integer))
|
|
||||||
|
|
||||||
Dim DtTraspasos As New DataTable
|
|
||||||
DtTraspasos.Columns.Add("CveAlmacen", GetType(Integer))
|
|
||||||
DtTraspasos.Columns.Add("Almacen", GetType(String))
|
|
||||||
DtTraspasos.Columns.Add("CveMovimientoSalida", GetType(Integer))
|
|
||||||
DtTraspasos.Columns.Add("FolioSalida", GetType(Integer))
|
|
||||||
DtTraspasos.Columns.Add("CveMovimientoEntrada", GetType(Integer))
|
|
||||||
DtTraspasos.Columns.Add("FolioEntrada", GetType(Integer))
|
|
||||||
|
|
||||||
Dim ConceptoMovimiento = 18
|
|
||||||
Dim CveMovimiento As Integer = 0
|
|
||||||
Dim Folio As Integer = 0
|
|
||||||
Dim CantidadPendiente As Decimal = 0
|
|
||||||
Dim DtDetalle As New DataTable
|
|
||||||
Dim DtDetalleLote As New DataTable
|
|
||||||
|
|
||||||
CveMovimiento = ObjInventario.AddMovimiento(CveAlmacenDevolucion, ConceptoMovimiento, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveAlmacenDestino:=-1)
|
|
||||||
Folio = ObjInventario.Folio
|
|
||||||
|
|
||||||
'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN)
|
|
||||||
'If Not (CveContrato > 0 And CveAlmacenTraspasoDestino > 0) Then
|
|
||||||
If CveMovimiento > 0 Then
|
|
||||||
|
|
||||||
'ES EL MOVIMIENTO PRINCIPAL
|
|
||||||
CantidadPendiente = 0
|
|
||||||
For Each Dr As DataRow In DtDatos.Rows
|
|
||||||
CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal
|
|
||||||
If CantidadPendiente > 0 Then
|
|
||||||
Dim PU As Decimal = 0
|
|
||||||
|
|
||||||
'SI FUE POR SERIELOTE
|
|
||||||
DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
|
|
||||||
DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec")))
|
|
||||||
If DtDetalle.Rows.Count > 0 Then
|
|
||||||
For Each Dr1 As DataRow In DtDetalle.Rows
|
|
||||||
If DtExistencias IsNot Nothing Then
|
|
||||||
PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar."
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
ElseIf DtDetalleLote.Rows.Count > 0 Then
|
|
||||||
For Each Dr1 As DataRow In DtDetalleLote.Rows
|
|
||||||
If DtExistencias IsNot Nothing Then
|
|
||||||
PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar."
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
Else
|
|
||||||
If DtExistencias IsNot Nothing Then
|
|
||||||
PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar."
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
Else
|
|
||||||
ErrorCancelar = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
Dim DtCostos As DataTable = Nothing
|
|
||||||
Dim ValorInventario As Decimal = 0
|
|
||||||
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
||||||
DtCostos = ObjInventario.DtResultados
|
|
||||||
|
|
||||||
Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"})
|
|
||||||
Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {CveAlmacenDevolucion}").ToEntero
|
|
||||||
Dim CveCuentaAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {CveAlmacenDevolucion}").ToEntero
|
|
||||||
Dim IdCtaContable As Integer = 0
|
|
||||||
Dim CveCuenta As Integer = 0
|
|
||||||
If tmpCostos.Rows.Count > 0 Then
|
|
||||||
|
|
||||||
|
|
||||||
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
|
|
||||||
Dim Fecha As Date = Now
|
|
||||||
Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero
|
|
||||||
Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString
|
|
||||||
Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString
|
|
||||||
Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL()
|
|
||||||
Dim TotalCostoAcumulado As Decimal = 0
|
|
||||||
Dim cont As Integer = 1
|
|
||||||
|
|
||||||
Dim CvePrePolizaDev As Integer = ObjConta.AddPrePolizas("Inventario/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
||||||
'Se agrega movimiento separado por la cuenta de ventas (ER)
|
|
||||||
For Each RowInv As DataRow In tmpCostos.Rows
|
|
||||||
ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL()
|
|
||||||
TotalCostoAcumulado += ValorInventario
|
|
||||||
|
|
||||||
'cuando es el último movimiento y hay diferencias en los importes
|
|
||||||
If cont = DtCostos.Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then
|
|
||||||
ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado)
|
|
||||||
End If
|
|
||||||
|
|
||||||
'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString)
|
|
||||||
IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
|
|
||||||
CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero
|
|
||||||
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, False, -1 * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero, ImporteMX:=-1 * ValorInventario, CveCuenta:=CveCuenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
cont += 1
|
|
||||||
Next
|
|
||||||
|
|
||||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePolizaDev, True, -1 * TotalCosto, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero, ImporteMX:=-1 * TotalCosto, CveCuenta:=CveCuentaAlmacen) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
'AutoConta - El movimiento 1 es el de Venta
|
|
||||||
|
|
||||||
Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
|
|
||||||
|
|
||||||
If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue = "Ant" Then
|
|
||||||
AutoConta = False
|
|
||||||
End If
|
|
||||||
|
|
||||||
If AutoConta And Not ErrorCancelar Then
|
|
||||||
Dim ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa)
|
|
||||||
|
|
||||||
If IdCtaContable > 0 Then
|
|
||||||
If Not ObjConta.ContabilizarPrePoliza(CvePrePolizaDev, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
|
|
||||||
Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico")
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia)
|
|
||||||
End If
|
|
||||||
|
|
||||||
ObjContPaq.Dispose()
|
|
||||||
End If
|
|
||||||
|
|
||||||
Else
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un Error al ingresar las prepolizas"
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If ObjInventario.VentasAlmacenApartadosGet(CveVenta) Then
|
|
||||||
|
|
||||||
Dim DtTempApartados = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 9", "CveAlmacen")
|
|
||||||
Dim CveMovimientoSalidaApartado = -1
|
|
||||||
Dim CveAlmacenApartado = -1
|
|
||||||
Dim CveAlmacenOrigen = CveAlmacenDevolucion
|
|
||||||
Dim FolioSalida As Integer = 0, FolioEntrada = 0, CveMovimientoSalida = 0, CveMovimientoEntradaApartado = 0
|
|
||||||
|
|
||||||
For Each Dr As DataRow In DtTempApartados.Rows
|
|
||||||
|
|
||||||
If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString.ToEntero Then
|
|
||||||
CveMovimientoSalidaApartado = ObjInventario.AddMovimiento(CveAlmacenOrigen, 8, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveVendedor:=1, CveCliente:=CveCliente, CveAlmacenDestino:=Dr("CveAlmacen").ToString.ToEntero)
|
|
||||||
FolioSalida = ObjInventario.Folio
|
|
||||||
CveAlmacenApartado = Dr("CveAlmacen").ToString.ToEntero
|
|
||||||
|
|
||||||
Dim DrMovto = DtTraspasos.NewRow
|
|
||||||
DrMovto("Almacen") = Dr("Almacen").ToString.ToEntero
|
|
||||||
DrMovto("CveAlmacen") = Dr("CveAlmacen").ToString.ToEntero
|
|
||||||
DrMovto("CveMovimientoSalida") = CveMovimientoSalidaApartado
|
|
||||||
DrMovto("FolioSalida") = FolioSalida
|
|
||||||
DtTraspasos.Rows.Add(DrMovto)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not CveMovimientoSalidaApartado > 0 Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al guardar los movimientos de control de apartados"
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al guardar los movimientos de control de apartados"
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
For Each Dr1 As DataRow In DtTraspasos.Rows
|
|
||||||
CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero
|
|
||||||
|
|
||||||
CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 9, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, Observaciones:="", CveAlmacenDestino:=CveAlmacenDevolucion, CveMovimientoRelacionado:=CveMovimientoSalida, Guia:="", CveContrato:=CveContrato, CveVendedor:=-1, CveCliente:=CveCliente)
|
|
||||||
FolioEntrada = ObjInventario.Folio
|
|
||||||
|
|
||||||
If Not CveMovimientoEntradaApartado > 0 Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar."
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
|
|
||||||
Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado
|
|
||||||
Dr1("FolioEntrada") = FolioEntrada
|
|
||||||
|
|
||||||
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then
|
|
||||||
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar."
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
End If
|
|
||||||
|
|
||||||
If ErrorCancelar Then Exit For
|
|
||||||
Next
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'DEVOLUCION REMISION - REGRESA LAS EXISTENCIAS A ENTREGA POR ADELANTADO SI LA FACTURA VIENE DE REMISION
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
Dim DtMovtosDev As New DataTable
|
|
||||||
Dim CveAlmacenTraspasoDestinoDevRem = -1
|
|
||||||
|
|
||||||
Dim CveVentaDetalleRem = -1
|
|
||||||
Dim CantidadDevolver As Decimal = 0
|
|
||||||
Dim CantidadRem As Decimal = 0
|
|
||||||
Dim CveMovimientoSalidaDevRem As Integer = 0
|
|
||||||
Dim FolioMovimientoSalidaDevRem As Integer = 0
|
|
||||||
Dim CveMovimientoEntradaDevRem As Integer = 0
|
|
||||||
Dim FolioMovimientoEntradaDevRem As Integer = 0
|
|
||||||
|
|
||||||
'CARGA REMISIONES DE LA VENTA DEVUELTA
|
|
||||||
If ObjInventario.GetDevolucionRemisionesFacturadas(CveVenta) Then
|
|
||||||
DtDevRem = ObjInventario.DtResultados.FiltraParametros("CantidadAlmacen > 0")
|
|
||||||
Else
|
|
||||||
ErrorCancelar = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
'CARGA CONCEPTOS DEVUELTOS EN LA VENTA
|
|
||||||
If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then
|
|
||||||
DtMovtosDev = ObjInventario.DtResultados
|
|
||||||
Else
|
|
||||||
ErrorCancelar = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If DtDevRem.Rows.Count > 0 And DtMovtosDev.Rows.Count > 0 Then
|
|
||||||
|
|
||||||
For Each DrMovtos As DataRow In DtDevRem.FiltraParametros("", "CveRem", {"CveRem", "CveAlmacenTraspasoDestino"}).Rows
|
|
||||||
|
|
||||||
'CHECO SI NO SE VA A CANCELAR
|
|
||||||
Dim SeCancela As Boolean = False
|
|
||||||
If ChkCanRem.Checked Then
|
|
||||||
For Each Gvr As GridViewRow In GvCancelarRemisiones.Rows
|
|
||||||
If Gvr.FCCheckBox("ChkCancelarRemision").Checked AndAlso DrMovtos("CveRem").ToString.ToEntero = Gvr.DataKey("CveVenta").ToString.ToEntero Then
|
|
||||||
SeCancela = True
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not SeCancela Then
|
|
||||||
|
|
||||||
CveAlmacenTraspasoDestinoDevRem = DrMovtos("CveAlmacenTraspasoDestino").ToString.ToEntero
|
|
||||||
If Not CveAlmacenTraspasoDestinoDevRem > 0 Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al obtener el almacén de devolucion de remisión."
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
|
|
||||||
'SALIDA GENERAL
|
|
||||||
CveMovimientoSalidaDevRem = ObjInventario.AddMovimiento(CveAlmacenDevolucion, 8, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, DrMovtos("CveRem").ToString.ToEntero, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=CveAlmacenTraspasoDestinoDevRem)
|
|
||||||
FolioMovimientoSalidaDevRem = ObjInventario.Folio
|
|
||||||
|
|
||||||
'ENTRADA ADELANTADO
|
|
||||||
CveMovimientoEntradaDevRem = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestinoDevRem, 9, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, DrMovtos("CveRem").ToString.ToEntero, -1, -1, Observaciones:="", Guia:="", CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimientoSalidaDevRem, CveAlmacenDestino:=CveAlmacenDevolucion)
|
|
||||||
FolioMovimientoEntradaDevRem = ObjInventario.Folio
|
|
||||||
|
|
||||||
If Not (CveMovimientoSalidaDevRem > 0 And CveMovimientoEntradaDevRem > 0) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al generar los movimientos de devolución a remisión."
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
'SALIDA POR TRAPASO DE GENERAL
|
|
||||||
For Each DrRem As DataRow In DtDevRem.FiltraParametros($"CveRem = {DrMovtos("CveRem")}").Rows
|
|
||||||
CveVentaDetalleRem = DrRem("CveVentaDetalleRem").ToString.ToEntero
|
|
||||||
CantidadRem = DrRem("CantidadFacturada").ToString.ToDecimal
|
|
||||||
'CantidadDevolver = DtMovtosDev.FiltroPrimeroValor("Cantidad", $"CveVentaDetalle = {DrRem("CveVentaDetalle").ToString.ToEntero}").ToDouble
|
|
||||||
'If (Dr("Cantidad").ToString.ToDouble > CantidadRem, CantidadRem, Dr("Cantidad").ToString.ToDouble) Then
|
|
||||||
|
|
||||||
If Not CveVentaDetalleRem > 0 Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al obtener la relación de la venta con la remisión."
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
|
|
||||||
For Each Dr As DataRow In DtMovtosDev.FiltraParametros($"CveVentaDetalle = {DrRem("CveVentaDetalle").ToString.ToEntero}").Rows
|
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaDevRem, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=CveVentaDetalleRem, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al guardar los movimientos de salida de traspaso de devolucion de remisión."
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
If ErrorCancelar Then
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
If ErrorCancelar Then
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
|
|
||||||
'ENTRADA POR TRAPASO A ENTREGA POR ADELANTADO
|
|
||||||
If ObjInventario.GetMovimientosDetalle(CveMovimientoSalidaDevRem, UsuarioActual.CveEmpresa) Then
|
|
||||||
For Each Dr As DataRow In ObjInventario.DtResultados.Rows
|
|
||||||
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaDevRem, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al guardar los movimientos de entrada de traspaso de devolucion de remisión."
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
If ErrorCancelar Then
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
|
|
||||||
Else
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al obtener los detalles de la devolución de almacén"
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
If Not ObjVentas.UpdateVentasDevolucionAlmacen(0, DrMovtos("CveRem").ToString.ToEntero) Then
|
|
||||||
MensajeError = "Ocurrió un error al hacer la devolucion hacia la remision. Por favor vuelva a intentar."
|
|
||||||
ErrorCancelar = True
|
|
||||||
Exit For
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
Next
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
MensajeError = "Ocurrió un error al hacer la devolucion a remisión. Por favor vuelva a intentar."
|
|
||||||
ErrorCancelar = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
'QUEMA DEVOLUCION | QUEMA = LA QUITA DE PENDIENTE POR RECIBIR (DEVOLVER)
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If Not ObjVentas.UpdateVentasDevolucionAlmacen(2, CveVenta) Then
|
|
||||||
MensajeError = "Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar."
|
|
||||||
ErrorCancelar = True
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'AGREGA BITACORA A VENTA
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
Dim MensajeBitacora = "Devuelta"
|
|
||||||
If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: <a href=""/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}"" target=""_blank"">{1}</a>", CveMovimiento, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVenta) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
'DESVINCULA REMISIONES PREDECESORAS
|
|
||||||
If Not EsRefacturacion Then
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") Then
|
|
||||||
If Not ChkCanRem.Checked Then
|
|
||||||
If Not ObjVentas.LiberarRemisionesFacturadas(CveVenta) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al desvincular las remisiones."
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
For Each Gvr As GridViewRow In GvCancelarRemisiones.Rows
|
|
||||||
If Not Gvr.FCCheckBox("ChkCancelarRemision").Checked Then
|
|
||||||
If Not ObjVentas.LiberarRemisionesFacturadas(CveVenta, Gvr.DataKey("CveVenta").ToEntero) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al desvincular las remisiones."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
'ACTUALIZA ESTATUS
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
Select Case DdlTipoComprobante.SelectedValue
|
|
||||||
Case "Rem"
|
|
||||||
CveEstatus = 12
|
|
||||||
Case "Com"
|
|
||||||
CveEstatus = 9
|
|
||||||
End Select
|
|
||||||
'0 Sin Refacturacion, 1 Refacturacion en Proceso, 3. Refacturación en proceso sin aceptación
|
|
||||||
Me.CveEstatusRefacturacion = 0
|
|
||||||
If EsRefacturacion Then
|
If EsRefacturacion Then
|
||||||
If CveEstatus = 5 Then
|
resp = ObjFactura.CancelarPorRefacturacion()
|
||||||
CveEstatusRefacturacion = 3 ' refacturación en proceso sin autorización de cancelación
|
|
||||||
Else
|
|
||||||
CveEstatusRefacturacion = 1 ' refacturación en proceso con autorización de cancelación
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
If Not ObjVentas.UpdateEstatusFactura(CveEstatus, FolioFiscal, CancelacionAcuse, CancelacionFecha, CveVenta, IDPoliza, CvePAC:=CvePACCancelacion, CveEstatusRefacturacion:=CveEstatusRefacturacion,
|
|
||||||
CveUsuarioCambiaEstatus:=UsuarioActual.CveUsuario, FechaCambioEstatus:=Now.ToString("yyyy-MM-dd hh:mm:ss.mmm")) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al guardar el estatus de cancelación."
|
|
||||||
End If
|
|
||||||
|
|
||||||
If ChkCanRem.Checked Then
|
|
||||||
For Each Gvr As GridViewRow In GvCancelarRemisiones.Rows
|
|
||||||
If Gvr.FCCheckBox("ChkCancelarRemision").Checked Then
|
|
||||||
If Not SeCancelaRemisionProceso Then
|
|
||||||
If Not ObjVentas.UpdateEstatusFactura(12, "", "", CancelacionFecha, Gvr.DataKey("CveVenta").ToEntero) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al guardar el estatus de cancelación de la remisión."
|
|
||||||
End If
|
|
||||||
Else
|
|
||||||
If Not ObjVentas.AddRemisionesXCancelar(CveVenta, Gvr.DataKey("CveVenta").ToEntero) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al guardar la remisión x cancelar."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
End If
|
|
||||||
If SeCancelaRemisionProceso Then
|
|
||||||
If Not ObjVentas.UpdateCancelaRemision(CveVenta, SeCancelaRemisionProceso) Then
|
|
||||||
ErrorCancelar = True
|
|
||||||
MensajeError = "Ocurrió un error al actualizar que la remision sea cancelable."
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Not ErrorCancelar Then
|
|
||||||
ObjVentas.Commit()
|
|
||||||
|
|
||||||
If CveEstatus = 5 Then
|
|
||||||
Dim MensajeAlert As New StringBuilder
|
|
||||||
MensajeAlert.Append("El Documento se canceló correctamente.")
|
|
||||||
MensajeAlert.Append($"</br> <a href='/Compras/PopUpVerFactura.aspx?P={Encripta($"OP=CAN&CVEVTA={CveVenta}")}' class='Texto' target='_blank'>Imprimir Acuse</a>")
|
|
||||||
MensajeAlert.Append("</br></br> ¿Desea enviar el Acuse de Cancelación al Cliente?")
|
|
||||||
Alert(MensajeAlert.ToString, TipoMensaje.MsgConfirmacion, JSBtnAceptar:="BtnEnviarMailCancelacion();", TextoConfirmacion:=" Si ", TextoCancelacion:=" <a onclick='Recargar()'>No</> ")
|
|
||||||
|
|
||||||
Else
|
Else
|
||||||
If Not EsRefacturacion Then
|
Dim ListaRemisionesCancelar As New List(Of Integer)
|
||||||
Alert("El documento se canceló exitosamente.", TipoMensaje.MsgInformacion, JSBtnAceptar:="BtnRefrescarPagina();")
|
If ChkCanRem.Checked Then
|
||||||
Else
|
For Each Gvr As GridViewRow In GvCancelarRemisiones.Rows
|
||||||
Response.Redirect($"/Ventas/RepCancelacionesPorRespuesta.aspx?CveVenta={Me.CveVenta}")
|
If Gvr.FCCheckBox("ChkCancelarRemision").Checked Then
|
||||||
|
ListaRemisionesCancelar.Add(Gvr.DataKey("CveVenta").ToEntero)
|
||||||
|
End If
|
||||||
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
If ChkDevAlm.Checked Then
|
||||||
|
ObjFactura.CveAlmacenDevolucion = CveAlmacenDevolucion
|
||||||
|
End If
|
||||||
|
|
||||||
|
resp = ObjFactura.CancelarFactura(ChkDevAlm.Checked, ListaRemisionesCancelar)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Me.CveEstatus = CveEstatus
|
If resp.CveEstatus = 5 Then
|
||||||
If CveEstatus = 5 Then LbCancelarDocumento.Enabled = False
|
Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:="BtnEnviarMailCancelacion();", TextoConfirmacion:=" Si ", TextoCancelacion:=" <a onclick='Recargar()'>No</> ")
|
||||||
If ObjAC IsNot Nothing Then ObjAC.Commit()
|
Else
|
||||||
Else
|
Alert(resp.Mensaje, resp.TipoMensaje, JSBtnAceptar:="BtnRefrescarPagina();")
|
||||||
Alert(MensajeError, TipoMensaje.MsgError)
|
End If
|
||||||
ObjVentas.RollBack()
|
|
||||||
If ObjAC IsNot Nothing Then ObjAC.RollBack()
|
|
||||||
End If
|
|
||||||
|
|
||||||
ObjVentas.Dispose()
|
ObjFactura.CveAlmacen = -1
|
||||||
ObjBancos.Dispose()
|
Else
|
||||||
ObjInventario.Dispose()
|
Alert("Ocurrió un error al generar la cancelación", TipoMensaje.MsgError)
|
||||||
ObjContrato.Dispose()
|
End If
|
||||||
ObjConta.Dispose()
|
|
||||||
If ObjAC IsNot Nothing Then ObjAC.Dispose()
|
|
||||||
|
|
||||||
UpEstatus.Update()
|
UpEstatus.Update()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user