7065 lines
491 KiB
C#
7065 lines
491 KiB
C#
using Exferia_Aplicacion.General;
|
|
using Exferia_Aplicacion.Herencia.Capas;
|
|
using Exferia_Aplicacion.Modelos_Contabilidad;
|
|
using Exferia_Aplicacion.Modelos_Generales;
|
|
using Exferia_Aplicacion.Modelos_Listado_Filtros;
|
|
using Exferia_Aplicacion.Modelos_Ventas;
|
|
using Exferia_Aplicacion.Modelos_Volcado;
|
|
using Exferia_EntityFramework;
|
|
using Exferia_General;
|
|
using Exferia_General._0_Modelos;
|
|
using Exferia_Ventas._0_Modelos;
|
|
using Exferia_Ventas.General;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Transactions;
|
|
using static Exferia_Aplicacion.General.Enumerados;
|
|
|
|
namespace Exferia_Ventas._1_Datos
|
|
{
|
|
public class VTA_FacturasCabecera_Datos : ABS_Datos
|
|
{
|
|
#region Listado
|
|
|
|
public List<INTERNO_VTA_FacturasCabecera_Listado_Modelo> g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo = new List<INTERNO_VTA_FacturasCabecera_Listado_Modelo>();
|
|
|
|
public override List<dynamic> Obtener_Listado(long _lng_idEmpresaSeleccionada, long _lng_idEjercicioActual, List<string> _lst_CamposConRelacionABuscar, List<INTERNO_Filtro_OpcionPadre_Modelo> _lst_INTERNO_Filtro_OpcionPadre_Modelo, List<INTERNO_Filtro_Modelo> _lst_INTERNO_Filtro_Modelo)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
List<dynamic> lst_MAE = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
// Consulta .....................................................
|
|
ConsultaRellenar_Listado(obj_Exferia_Entities, _lng_idEmpresaSeleccionada, _lng_idEjercicioActual, Datos_Generales.GEN_Empresas_Devolver_EmpresasCompartidas_SegunFichero(_lng_idEmpresaSeleccionada, typeof(VTA_FacturasCabecera).Name), _lst_CamposConRelacionABuscar, -1, null, _lst_INTERNO_Filtro_OpcionPadre_Modelo, _lst_INTERNO_Filtro_Modelo);
|
|
// ..............................................................
|
|
|
|
if ((g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo != null) && (g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Count() > 0))
|
|
{
|
|
lst_MAE = g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cast<dynamic>().ToList();
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_Listado), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return lst_MAE;
|
|
}
|
|
public override dynamic Obtener_RegistroListado(long _lng_idEmpresaSeleccionada, long _lng_idEjercicioActual, List<string> _lst_CamposConRelacionABuscar, List<INTERNO_Filtro_OpcionPadre_Modelo> _lst_INTERNO_Filtro_OpcionPadre_Modelo, List<INTERNO_Filtro_Modelo> _lst_INTERNO_Filtro_Modelo, long _lng_id, List<long> _lst_ids)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
dynamic dnm_MAE = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
// Consulta .....................................................
|
|
ConsultaRellenar_Listado(obj_Exferia_Entities, _lng_idEmpresaSeleccionada, _lng_idEjercicioActual, Datos_Generales.GEN_Empresas_Devolver_EmpresasCompartidas_SegunFichero(_lng_idEmpresaSeleccionada, typeof(VTA_FacturasCabecera).Name), _lst_CamposConRelacionABuscar, _lng_id, _lst_ids, _lst_INTERNO_Filtro_OpcionPadre_Modelo, _lst_INTERNO_Filtro_Modelo);
|
|
// ..............................................................
|
|
|
|
if ((g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo != null) && (g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Count() > 0))
|
|
{
|
|
dnm_MAE = g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cast<dynamic>().ToList();
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_RegistroListado), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return dnm_MAE;
|
|
}
|
|
|
|
|
|
protected override void ConsultaRellenar_Listado(Exferia_Entities _obj_Exferia_Entities, long _lng_idEmpresaSeleccionada, long _lng_idEjercicioActual, List<long> _lst_idEmpresasRelacionadas, List<string> _lst_CamposConRelacionABuscar, long _lng_id, List<long> _lst_ids, List<INTERNO_Filtro_OpcionPadre_Modelo> _lst_INTERNO_Filtro_OpcionPadre_Modelo, List<INTERNO_Filtro_Modelo> _lst_INTERNO_Filtro_Modelo)
|
|
{
|
|
try
|
|
{
|
|
|
|
string str_Filtro_Empresa = Funciones.Formar_ContenidoIN_ParaConsultaWhere(nameof(VTA_FacturasCabecera),
|
|
nameof(VTA_FacturasCabecera.idEmpresa),
|
|
G_ENUM_FORMARCONTENIDOIN_CONDICIONANTES.OR_INICIO,
|
|
_lst_idEmpresasRelacionadas);
|
|
|
|
|
|
//Datos del Padre si los tuviera .........................
|
|
long lng_Padre_id = -1;
|
|
string str_Padre_Opcion = "";
|
|
|
|
bool bol_FiltrarEjercicio = false;
|
|
DateTime? dtt_TemporadaInicio = null;
|
|
DateTime? dtt_TemporadaFin = null;
|
|
|
|
long lng_idDelegacion = -1;
|
|
|
|
long lng_idFacturaCabecera = -1;
|
|
string str_OpcionFacturaCabecera = "";
|
|
|
|
|
|
string str_Estado = "";
|
|
|
|
if (_lst_INTERNO_Filtro_OpcionPadre_Modelo != null && _lst_INTERNO_Filtro_OpcionPadre_Modelo.Count > 0)
|
|
{
|
|
foreach (INTERNO_Filtro_OpcionPadre_Modelo mdl_INTERNO_Filtro_OpcionPadre_Modelo in _lst_INTERNO_Filtro_OpcionPadre_Modelo)
|
|
{
|
|
//Ejercicio
|
|
if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idEjercicio)))
|
|
{
|
|
//Buscar el Modelo de Ejercicio
|
|
GEN_EjerciciosActivos_Empresa mdl_GEN_EjerciciosActivos_Empresa = Datos_Generales.GEN_EjerciciosActivos_Empresa_Obtener_Por_Id(mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR);
|
|
|
|
if (mdl_GEN_EjerciciosActivos_Empresa != null)
|
|
{
|
|
bol_FiltrarEjercicio = true;
|
|
dtt_TemporadaInicio = mdl_GEN_EjerciciosActivos_Empresa.temporadaFechaInicio;
|
|
dtt_TemporadaFin = mdl_GEN_EjerciciosActivos_Empresa.temporadaFechaFin;
|
|
}
|
|
}
|
|
//DELEGACION
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idDelegacion)))
|
|
{
|
|
lng_idDelegacion = mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR;
|
|
}
|
|
//Estado
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.estado)))
|
|
{
|
|
str_Estado = (string)mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR_AUXILIAR;
|
|
}
|
|
//cliente o socio
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idCliente)) ||
|
|
mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idSocio)))
|
|
{
|
|
str_Padre_Opcion = mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO;
|
|
lng_Padre_id = mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR;
|
|
}
|
|
//FACTURASCABECERA
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(Variables.G_STR_OPCION_VTA_FACTURACABECERA))
|
|
{
|
|
lng_idFacturaCabecera = mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR;
|
|
str_OpcionFacturaCabecera = mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.id) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.numeroFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.fecha) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.fechaIntroduccion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaIntroduccion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.estado) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.estado) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.claveEmisora) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.claveEmisora) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.descripcion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.guid) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.guid) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.descuentoProntoPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descuentoProntoPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.descuentoFinalFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descuentoFinalFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.referencia) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.referencia) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.recargo) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.recargo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.situacionPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.situacionPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.observaciones) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.observaciones) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.aplicarRetencion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.aplicarRetencion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.noDeclararModelosOficiales) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.noDeclararModelosOficiales) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.criterioCaja) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.criterioCaja) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.retencion_Base) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Base) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.retencion_Porcentaje) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Porcentaje) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.retencion_Valor) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Valor) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_bruto) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_bruto) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_descuentoProntoPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoProntoPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_descuentoFinalFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoFinalFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_baseImponible) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_baseImponible) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_impuesto) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_impuesto) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_recargo) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_recargo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_retencion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_retencion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_Final) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_Final) + "," +
|
|
//ids
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idCliente) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idSocio) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idDelegacion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idFormaPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idFormaPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idEmpresa) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idPredefinidoCabecera) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idPredefinidoCabecera) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idLiquidacionTributaria) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idLiquidacionTributaria) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idMoneda) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idMoneda) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idImpuestoCabecera) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idImpuestoCabecera) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idEmpleado) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpleado) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_Preventa) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Preventa) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_PreventaHabitual) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_Repartidor) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_Cobrador) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_CobradorHabitual) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_Autoventa) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Autoventa) + "," +
|
|
//Cliente_Codigo
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_Codigo)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_Codigo) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.codigo) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_Codigo) + " = '',"
|
|
)
|
|
) +
|
|
//Cliente_RazonSocial
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_RazonSocial)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_RazonSocial) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.razonSocial) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_RazonSocial) + " = '',"
|
|
)
|
|
) +
|
|
//Cliente_NombreComercial
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_NombreComercial)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_NombreComercial) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.nombreComercial) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_NombreComercial) + " = '',"
|
|
)
|
|
) +
|
|
//Cliente_Cif
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_CIF)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_CIF) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.cif) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_CIF) + " = '',"
|
|
)
|
|
) +
|
|
//Socio
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_Codigo) + " = " + nameof(GTT_Socios) + "." + nameof(GTT_Socios.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_Descripcion) + " = " + nameof(GTT_Socios) + "." + nameof(GTT_Socios.razonSocial) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_FechaBorrado) + " = " + nameof(GTT_Socios) + "." + nameof(GTT_Socios.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Delegacion
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_Codigo) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_Descripcion) + " =" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_FechaBorrado) + " =" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//LiquidacionTributaria
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.LiquidacionTributaria)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.LiquidacionTributaria_Codigo) + " = " + nameof(GTT_LiquidacionesTributarias) + "." + nameof(GTT_LiquidacionesTributarias.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.LiquidacionTributaria_Descripcion) + " =" + nameof(GTT_LiquidacionesTributarias) + "." + nameof(GTT_LiquidacionesTributarias.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.LiquidacionTributaria_FechaBorrado) + " =" + nameof(GTT_LiquidacionesTributarias) + "." + nameof(GTT_LiquidacionesTributarias.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.LiquidacionTributaria_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.LiquidacionTributaria_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.LiquidacionTributaria_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Empresa
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_Codigo) + " = " + nameof(GEN_Empresas) + "." + nameof(GEN_Empresas.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_Descripcion) + " =" + nameof(GEN_Empresas) + "." + nameof(GEN_Empresas.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_FechaBorrado) + " =" + nameof(GEN_Empresas) + "." + nameof(GEN_Empresas.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Moneda
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_Codigo) + " = " + nameof(GEN_Monedas) + "." + nameof(GEN_Monedas.moneda) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_Descripcion) + " =" + nameof(GEN_Monedas) + "." + nameof(GEN_Monedas.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_FechaBorrado) + " =" + nameof(GEN_Monedas) + "." + nameof(GEN_Monedas.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//ImpuestoCabecera
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_Codigo) + " = " + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_Descripcion) + " =" + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_FechaBorrado) + " =" + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Empleado
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_Codigo) + " = " + nameof(MAE_Empleados) + "." + nameof(MAE_Empleados.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_Nombre) + " =" + nameof(MAE_Empleados) + "." + nameof(MAE_Empleados.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_FechaBorrado) + " =" + nameof(MAE_Empleados) + "." + nameof(MAE_Empleados.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//FormaPago
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_Codigo) + " = " + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_Nombre) + " =" + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_FechaBorrado) + " =" + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(Preventa)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_1." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_1." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_FechaBorrado) + " " + nameof(MAE_Vendedores) + "_AUX_1." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(PreventaHabitual)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_2." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_2." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_FechaBorrado) + " = " + nameof(MAE_Vendedores) + "_AUX_2." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(Repartidor)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_3." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_3." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_FechaBorrado) + " = " + nameof(MAE_Vendedores) + "_AUX_3." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(Cobrador)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_4." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_4." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_FechaBorrado) + " = " + nameof(MAE_Vendedores) + "_AUX_4." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(CobradorHabitual)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_5." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_5." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_FechaBorrado) + " = " + nameof(MAE_Vendedores) + "_AUX_5." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(Autoventa)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_6." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_6." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_FechaBorrado) + " = " + nameof(MAE_Vendedores) + "_AUX_6." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//PredefinidoCabecera (Factura)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_Codigo) + " = " + nameof(CTA_PredefinidosCabeceras) + "_AUX_1." + nameof(CTA_PredefinidosCabeceras.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_Descripcion) + " = " + nameof(CTA_PredefinidosCabeceras) + "_AUX_1." + nameof(CTA_PredefinidosCabeceras.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_FechaBorrado) + " = " + nameof(CTA_PredefinidosCabeceras) + "_AUX_1." + nameof(CTA_PredefinidosCabeceras.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//ClaveAnalitica
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_Codigo) + " = " + nameof(CTA_ClavesAnaliticas) + "." + nameof(CTA_ClavesAnaliticas.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_Descripcion) + " = " + nameof(CTA_ClavesAnaliticas) + "." + nameof(CTA_ClavesAnaliticas.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_FechaBorrado) + " = " + nameof(CTA_ClavesAnaliticas) + "." + nameof(CTA_ClavesAnaliticas.fechaBorrado)
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_FechaBorrado) + " = NULL "
|
|
)
|
|
) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
//Cliente
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_Codigo)) ||
|
|
_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_RazonSocial)) ||
|
|
_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_NombreComercial)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Clientes) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Socio
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GTT_Socios) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " = " + nameof(GTT_Socios) + "." + nameof(GTT_Socios.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Delegacion
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//LiquidacionTributaria
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.LiquidacionTributaria)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GTT_LiquidacionesTributarias) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idLiquidacionTributaria) + " = " + nameof(GTT_LiquidacionesTributarias) + "." + nameof(GTT_LiquidacionesTributarias.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Empresa
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GEN_Empresas) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + " = " + nameof(GEN_Empresas) + "." + nameof(GEN_Empresas.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Moneda
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GEN_Monedas) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idMoneda) + " = " + nameof(GEN_Monedas) + "." + nameof(GEN_Monedas.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//ImpuestoCabecera
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GEN_ImpuestosCabecera) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idImpuestoCabecera) + " = " + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Empleado
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Empleados) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpleado) + " = " + nameof(MAE_Empleados) + "." + nameof(MAE_Empleados.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//FormaPago
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_FormasPago) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idFormaPago) + " = " + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(Preventa)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_1 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Preventa) + " = " + nameof(MAE_Vendedores) + "_AUX_1." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(PreventaHabitual)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_2 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + " = " + nameof(MAE_Vendedores) + "_AUX_2." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(Repartidor)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_3 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + " = " + nameof(MAE_Vendedores) + "_AUX_3." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(Cobrador)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_4 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + " = " + nameof(MAE_Vendedores) + "_AUX_4." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(CobradorHabitual)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_5 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + " = " + nameof(MAE_Vendedores) + "_AUX_5." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(Autoventa)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_6 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Autoventa) + " = " + nameof(MAE_Vendedores) + "_AUX_6." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//PredefinidoCabeceraFactura
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(CTA_PredefinidosCabeceras) + " AS " + nameof(CTA_PredefinidosCabeceras) + "_AUX_1 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idPredefinidoCabecera) + " = " + nameof(CTA_PredefinidosCabeceras) + "_AUX_1." + nameof(CTA_PredefinidosCabeceras.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//ClaveAnalitica
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(CTA_ClavesAnaliticas) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idClaveAnalitica) + " = " + nameof(CTA_ClavesAnaliticas) + "." + nameof(CTA_ClavesAnaliticas.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
" WHERE " +
|
|
//fechaBorrado
|
|
" ( " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null ) AND " +
|
|
//id
|
|
" ( " +
|
|
(
|
|
(_lng_id > -1)
|
|
? (nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=@id ")
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) AND " +
|
|
//idEmpresa
|
|
" ( " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + "=" + _lng_idEmpresaSeleccionada + str_Filtro_Empresa +
|
|
" ) AND " +
|
|
//Filtro por datos del padre relacionado
|
|
" ( " +
|
|
(
|
|
!str_Padre_Opcion.Equals("")
|
|
//Cliente
|
|
? str_Padre_Opcion.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idCliente))
|
|
? lng_Padre_id > -1
|
|
? nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + "=" + lng_Padre_id
|
|
: nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " is null "
|
|
//Socio
|
|
: (str_Padre_Opcion.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idSocio)))
|
|
? lng_Padre_id > -1
|
|
? nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + "=" + lng_Padre_id
|
|
: nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " is null "
|
|
: " 1 = 1 "
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) and " +
|
|
//FacturasCabecera distintas
|
|
" ( " +
|
|
(
|
|
str_OpcionFacturaCabecera != ""
|
|
? nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "<>" + lng_idFacturaCabecera
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) and " +
|
|
//Delegacion
|
|
" ( " +
|
|
(
|
|
lng_idDelegacion > -1
|
|
? nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + "=" + lng_idDelegacion
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) and " +
|
|
//estado
|
|
" ( " +
|
|
(
|
|
(str_Estado.Trim().Length > 0)
|
|
? nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.estado) + "<>@estado "
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) and " +
|
|
//Ejercicio
|
|
" ( " +
|
|
(
|
|
bol_FiltrarEjercicio == true
|
|
? (nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " <=@TemporadaFin AND " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " >=@TemporadaInicio ")
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) ";
|
|
|
|
//Parametros
|
|
List<SqlParameter> lst_Parametros = new List<SqlParameter>();
|
|
if (_lng_id > -1)
|
|
{
|
|
lst_Parametros.Add(new SqlParameter("@id", _lng_id));
|
|
}
|
|
|
|
if (str_Estado.Trim().Length > 0)
|
|
{
|
|
lst_Parametros.Add(new SqlParameter("@estado", str_Estado));
|
|
}
|
|
|
|
if (bol_FiltrarEjercicio)
|
|
{
|
|
lst_Parametros.Add(new SqlParameter("@TemporadaFin", dtt_TemporadaFin.Value));
|
|
lst_Parametros.Add(new SqlParameter("@TemporadaInicio", dtt_TemporadaInicio.Value));
|
|
}
|
|
|
|
object[] arr_Parametros = lst_Parametros.ToArray();
|
|
|
|
//Rellenar el Modelo
|
|
g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo = _obj_Exferia_Entities.Database.SqlQuery<INTERNO_VTA_FacturasCabecera_Listado_Modelo>(str_SQL, arr_Parametros).ToList();
|
|
|
|
//Añadir los Ejercicios
|
|
if (g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo != null && g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Count > 0)
|
|
{
|
|
Agregar_Ejercicios(_obj_Exferia_Entities, _lng_idEmpresaSeleccionada);
|
|
}
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(ConsultaRellenar_Listado), true);
|
|
}
|
|
}
|
|
|
|
private void Agregar_Ejercicios(Exferia_Entities _obj_Exferia_Entities, long _lng_idEmpresaSeleccionada)
|
|
{
|
|
try
|
|
{
|
|
List<GEN_EjerciciosActivos_Empresa> lst_GEN_EjerciciosActivos_Empresa = Datos_Generales.GEN_EjerciciosActivos_Empresa_Obtener_Listado_Por_Empresa(_lng_idEmpresaSeleccionada);
|
|
|
|
Dictionary<long, AUX_FacturasCabecera_Importes_Modelo> lst_AUX_FacturasCabecera_Importes_Modelo = null;
|
|
if (lst_GEN_EjerciciosActivos_Empresa != null)
|
|
{
|
|
var _lst_ids = g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Select(_mdl => _mdl.id).ToArray();
|
|
string having = _lst_ids.Length > 20 ?
|
|
$"HAVING P.{nameof(AUX_FacturasCabecera_Importes_Modelo.IdFacturaCabecera)}>={_lst_ids.Min(m => m)} AND P.{nameof(AUX_FacturasCabecera_Importes_Modelo.IdFacturaCabecera)}<={_lst_ids.Max(m => m)}" :
|
|
$"HAVING P.{nameof(AUX_FacturasCabecera_Importes_Modelo.IdFacturaCabecera)} IN({String.Join(",", _lst_ids)})";
|
|
string str_SQL_Resumen_Facturas = $@"{Obtener_ImportesTotales_Consulta()}
|
|
{having}";
|
|
|
|
lst_AUX_FacturasCabecera_Importes_Modelo = _obj_Exferia_Entities.Database
|
|
.SqlQuery<AUX_FacturasCabecera_Importes_Modelo>(str_SQL_Resumen_Facturas, new object[] { })
|
|
.ToDictionary(mdl => mdl.IdFacturaCabecera, mdl => mdl);
|
|
|
|
//Rellenar el Listado
|
|
foreach (INTERNO_VTA_FacturasCabecera_Listado_Modelo mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo in g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo)
|
|
{
|
|
mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Ejercicios_Empresa = lst_GEN_EjerciciosActivos_Empresa.Where(m => m.temporadaFechaFin >= mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.fecha &&
|
|
m.temporadaFechaInicio <= mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.fecha)
|
|
.FirstOrDefault();
|
|
mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Total_Factura_Importe =
|
|
lst_AUX_FacturasCabecera_Importes_Modelo.ContainsKey(mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.id) ? lst_AUX_FacturasCabecera_Importes_Modelo[mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.id].Total_Factura_Importe : 0;
|
|
mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Total_Cobro_Importe =
|
|
lst_AUX_FacturasCabecera_Importes_Modelo.ContainsKey(mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.id) ? lst_AUX_FacturasCabecera_Importes_Modelo[mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.id].Total_Cobro_Importe : 0;
|
|
mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Total_Devolucion_Importe =
|
|
lst_AUX_FacturasCabecera_Importes_Modelo.ContainsKey(mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.id) ? lst_AUX_FacturasCabecera_Importes_Modelo[mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.id].Total_Devolucion_Importe : 0;
|
|
}
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Agregar_Ejercicios), true);
|
|
}
|
|
}
|
|
|
|
private string Obtener_ImportesTotales_Consulta()
|
|
{
|
|
return $@"
|
|
SELECT
|
|
{nameof(AUX_FacturasCabecera_Importes_Modelo.IdFacturaCabecera)} = P.{nameof(AUX_FacturasCabecera_Importes_Modelo.IdFacturaCabecera)}
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Factura_Importe)} = sum({nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Factura_Importe)})
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Cobro_Importe)} = sum({nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Cobro_Importe)})
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Devolucion_Importe)} = sum({nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Devolucion_Importe)})
|
|
FROM
|
|
(
|
|
SELECT
|
|
{nameof(AUX_FacturasCabecera_Importes_Modelo.IdFacturaCabecera)} = {nameof(VTA_FacturasCabecera)}.{nameof(VTA_FacturasCabecera.id)}
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Factura_Importe)} = {nameof(VTA_FacturasCabecera)}.{nameof(VTA_FacturasCabecera.total_Final)}
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Cobro_Importe)} = 0
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Devolucion_Importe)} = 0
|
|
FROM
|
|
{nameof(VTA_FacturasCabecera)}
|
|
WHERE
|
|
{nameof(VTA_FacturasCabecera)}.{nameof(VTA_FacturasCabecera.fechaBorrado)} is null
|
|
UNION ALL
|
|
SELECT
|
|
{nameof(AUX_FacturasCabecera_Importes_Modelo.IdFacturaCabecera)} = {nameof(VTA_AlbaranesCabecera)}.{nameof(VTA_AlbaranesCabecera.idFacturaCabecera)}
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Factura_Importe)} = 0
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Cobro_Importe)} = {nameof(VTA_CobrosAlbaranes)}.{nameof(VTA_CobrosAlbaranes.importe)}
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Devolucion_Importe)} = 0
|
|
FROM
|
|
{nameof(VTA_CobrosAlbaranes)}
|
|
INNER JOIN
|
|
{nameof(VTA_AlbaranesCabecera)}
|
|
ON
|
|
{nameof(VTA_CobrosAlbaranes)}.{nameof(VTA_CobrosAlbaranes.idAlbaranCabecera)} = {nameof(VTA_AlbaranesCabecera)}.{nameof(VTA_AlbaranesCabecera.id)}
|
|
and {nameof(VTA_AlbaranesCabecera)}.{nameof(VTA_AlbaranesCabecera.fechaBorrado)} is null
|
|
WHERE
|
|
{nameof(VTA_CobrosAlbaranes)}.{nameof(VTA_CobrosAlbaranes.fechaBorrado)} is null
|
|
UNION ALL
|
|
SELECT
|
|
{nameof(AUX_FacturasCabecera_Importes_Modelo.IdFacturaCabecera)} = {nameof(VTA_FacturasCabecera)}.{nameof(VTA_FacturasCabecera.id)}
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Factura_Importe)} = 0
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Cobro_Importe)} = {nameof(VTA_Cobros)}.{nameof(VTA_Cobros.importe)}
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Devolucion_Importe)} = 0
|
|
FROM
|
|
{nameof(VTA_FacturasCabecera)}
|
|
INNER JOIN
|
|
{nameof(VTA_Vencimientos)}
|
|
ON
|
|
{nameof(VTA_FacturasCabecera)}.{nameof(VTA_FacturasCabecera.id)} = {nameof(VTA_Vencimientos)}.{nameof(VTA_Vencimientos.idFacturaCabecera)}
|
|
and {nameof(VTA_Vencimientos)}.{nameof(VTA_Vencimientos.fechaBorrado)} is null
|
|
INNER JOIN
|
|
{nameof(VTA_Cobros)}
|
|
ON
|
|
{nameof(VTA_Vencimientos)}.id = {nameof(VTA_Cobros)}.{nameof(VTA_Cobros.idVencimiento)}
|
|
and {nameof(VTA_Cobros)}.{nameof(VTA_Cobros.fechaBorrado)} is null
|
|
WHERE
|
|
{nameof(VTA_FacturasCabecera)}.{nameof(VTA_FacturasCabecera.fechaBorrado)} is null
|
|
UNION ALL
|
|
SELECT
|
|
{nameof(AUX_FacturasCabecera_Importes_Modelo.IdFacturaCabecera)} = {nameof(VTA_FacturasCabecera)}.{nameof(VTA_FacturasCabecera.id)}
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Factura_Importe)} = 0
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Cobro_Importe)} = 0
|
|
, {nameof(AUX_FacturasCabecera_Importes_Modelo.Total_Devolucion_Importe)} = {nameof(VTA_DevolucionesCobros)}.{nameof(VTA_DevolucionesCobros.importe)}
|
|
FROM
|
|
{nameof(VTA_FacturasCabecera)}
|
|
INNER JOIN
|
|
{nameof(VTA_Vencimientos)}
|
|
ON
|
|
{nameof(VTA_FacturasCabecera)}.{nameof(VTA_FacturasCabecera.id)} = {nameof(VTA_Vencimientos)}.{nameof(VTA_Vencimientos.idFacturaCabecera)}
|
|
and {nameof(VTA_Vencimientos)}.{nameof(VTA_Vencimientos.fechaBorrado)} is null
|
|
INNER JOIN
|
|
{nameof(VTA_Cobros)}
|
|
ON
|
|
{nameof(VTA_Vencimientos)}.{nameof(VTA_Vencimientos.id)} = {nameof(VTA_Cobros)}.{nameof(VTA_Cobros.idVencimiento)}
|
|
and {nameof(VTA_Cobros)}.{nameof(VTA_Cobros.fechaBorrado)} is null
|
|
INNER JOIN
|
|
{nameof(VTA_DevolucionesCobros)}
|
|
ON
|
|
{nameof(VTA_Cobros)}.{nameof(VTA_Cobros.id)} = {nameof(VTA_DevolucionesCobros)}.{nameof(VTA_DevolucionesCobros.idCobro)}
|
|
and {nameof(VTA_DevolucionesCobros)}.{nameof(VTA_DevolucionesCobros.fechaBorrado)} is null
|
|
WHERE
|
|
{nameof(VTA_FacturasCabecera)}.{nameof(VTA_FacturasCabecera.fechaBorrado)} is null
|
|
)
|
|
as P
|
|
GROUP BY
|
|
P.{nameof(AUX_FacturasCabecera_Importes_Modelo.IdFacturaCabecera)}";
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Listado Secundario
|
|
public List<INTERNO_VTA_FacturasCabecera_Listado_Modelo> g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO = new List<INTERNO_VTA_FacturasCabecera_Listado_Modelo>();
|
|
|
|
public override List<dynamic> Obtener_Listado_Secundario(long _lng_idEmpresaSeleccionada, long _lng_idEjercicioActual, List<string> _lst_CamposConRelacionABuscar, List<INTERNO_Filtro_OpcionPadre_Modelo> _lst_INTERNO_Filtro_OpcionPadre_Modelo, List<INTERNO_Filtro_Modelo> _lst_INTERNO_Filtro_Modelo)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
List<dynamic> lst_AUX = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
// Consulta .....................................................
|
|
ConsultaRellenar_Listado_Secundario(obj_Exferia_Entities, _lng_idEmpresaSeleccionada, _lng_idEjercicioActual, Datos_Generales.GEN_Empresas_Devolver_EmpresasCompartidas_SegunFichero(_lng_idEmpresaSeleccionada, typeof(VTA_FacturasCabecera).Name), _lst_CamposConRelacionABuscar, -1, null, _lst_INTERNO_Filtro_OpcionPadre_Modelo, _lst_INTERNO_Filtro_Modelo);
|
|
// ..............................................................
|
|
|
|
if ((g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO != null) && (g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO.Count() > 0))
|
|
{
|
|
lst_AUX = g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO.Cast<dynamic>().ToList();
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_Listado_Secundario), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return lst_AUX;
|
|
}
|
|
public override dynamic Obtener_RegistroListado_Secundario(long _lng_idEmpresaSeleccionada, long _lng_idEjercicioActual, List<string> _lst_CamposConRelacionABuscar, List<INTERNO_Filtro_OpcionPadre_Modelo> _lst_INTERNO_Filtro_OpcionPadre_Modelo, List<INTERNO_Filtro_Modelo> _lst_INTERNO_Filtro_Modelo, long _lng_id, List<long> _lst_ids)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
dynamic dnm_AUX = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
// Consulta .....................................................
|
|
ConsultaRellenar_Listado_Secundario(obj_Exferia_Entities, _lng_idEmpresaSeleccionada, _lng_idEjercicioActual, Datos_Generales.GEN_Empresas_Devolver_EmpresasCompartidas_SegunFichero(_lng_idEmpresaSeleccionada, typeof(VTA_FacturasCabecera).Name), _lst_CamposConRelacionABuscar, _lng_id, _lst_ids, _lst_INTERNO_Filtro_OpcionPadre_Modelo, _lst_INTERNO_Filtro_Modelo);
|
|
// ..............................................................
|
|
|
|
if ((g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO != null) && (g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO.Count() > 0))
|
|
{
|
|
dnm_AUX = g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO.Cast<dynamic>().ToList();
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_RegistroListado_Secundario), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return dnm_AUX;
|
|
}
|
|
|
|
protected override void ConsultaRellenar_Listado_Secundario(Exferia_Entities _obj_Exferia_Entities, long _lng_idEmpresaSeleccionada, long _lng_idEjercicioActual, List<long> _lst_idEmpresasRelacionadas, List<string> _lst_CamposConRelacionABuscar, long _lng_id, List<long> _lst_ids, List<INTERNO_Filtro_OpcionPadre_Modelo> _lst_INTERNO_Filtro_OpcionPadre_Modelo, List<INTERNO_Filtro_Modelo> _lst_INTERNO_Filtro_Modelo)
|
|
{
|
|
try
|
|
{
|
|
string str_Filtro_Empresa = Funciones.Formar_ContenidoIN_ParaConsultaWhere(nameof(VTA_FacturasCabecera),
|
|
nameof(VTA_FacturasCabecera.idEmpresa),
|
|
G_ENUM_FORMARCONTENIDOIN_CONDICIONANTES.OR_INICIO,
|
|
_lst_idEmpresasRelacionadas);
|
|
|
|
//Datos del Padre si los tuviera .........................
|
|
long lng_idCliente = -1;
|
|
string str_Opcion_Cliente = "";
|
|
|
|
long lng_idArticulo = -1;
|
|
string str_Opcion_Articulo = "";
|
|
|
|
long lng_idArticuloComodin = -1;
|
|
string str_Opcion_ArticuloComodin = "";
|
|
|
|
bool bol_FiltrarEjercicio = false;
|
|
DateTime? dtt_TemporadaInicio = null;
|
|
DateTime? dtt_TemporadaFin = null;
|
|
|
|
if (_lst_INTERNO_Filtro_OpcionPadre_Modelo != null && _lst_INTERNO_Filtro_OpcionPadre_Modelo.Count > 0)
|
|
{
|
|
foreach (INTERNO_Filtro_OpcionPadre_Modelo mdl_INTERNO_Filtro_OpcionPadre_Modelo in _lst_INTERNO_Filtro_OpcionPadre_Modelo)
|
|
{
|
|
//Ejercicio
|
|
if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idEjercicio)))
|
|
{
|
|
//Buscar el Modelo de Ejercicio
|
|
GEN_EjerciciosActivos_Empresa mdl_GEN_EjerciciosActivos_Empresa = Datos_Generales.GEN_EjerciciosActivos_Empresa_Obtener_Por_Id(mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR);
|
|
|
|
if (mdl_GEN_EjerciciosActivos_Empresa != null)
|
|
{
|
|
bol_FiltrarEjercicio = true;
|
|
dtt_TemporadaInicio = mdl_GEN_EjerciciosActivos_Empresa.temporadaFechaInicio;
|
|
dtt_TemporadaFin = mdl_GEN_EjerciciosActivos_Empresa.temporadaFechaFin;
|
|
}
|
|
}
|
|
//CLIENTE
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(Variables.G_STR_OPCION_MAE_CLIENTE))
|
|
{
|
|
lng_idCliente = mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR;
|
|
str_Opcion_Cliente = mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO;
|
|
}
|
|
//ARTICULO
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(Variables.G_STR_OPCION_MAE_ARTICULO))
|
|
{
|
|
lng_idArticulo = mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR;
|
|
str_Opcion_Articulo = mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO;
|
|
}
|
|
//ARTICULOCOMODIN
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(Variables.G_STR_OPCION_MAE_ARTICULOCOMODIN))
|
|
{
|
|
lng_idArticuloComodin = mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR;
|
|
str_Opcion_ArticuloComodin = mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO;
|
|
}
|
|
}
|
|
}
|
|
|
|
//Si tiene filto por articulo y por articulo comodin y los dos estan a -1 se deja solo uno
|
|
if (str_Opcion_Articulo.Trim().Length > 0 &&
|
|
str_Opcion_ArticuloComodin.Trim().Length > 0)
|
|
{
|
|
if (lng_idArticulo == -1 &&
|
|
lng_idArticuloComodin > -1)
|
|
{
|
|
str_Opcion_Articulo = "";
|
|
}
|
|
else if (lng_idArticuloComodin == -1 &&
|
|
lng_idArticulo > -1)
|
|
{
|
|
str_Opcion_ArticuloComodin = "";
|
|
}
|
|
else
|
|
{
|
|
str_Opcion_ArticuloComodin = "";
|
|
}
|
|
}
|
|
|
|
#region Factura Lineas Por Articulo
|
|
List<long> lst_idsFacturaCabecera_PorArticulo = null;
|
|
|
|
if (lng_idArticulo > -1)
|
|
{
|
|
VTA_AlbaranesFacturasLineas_Datos obj_VTA_AlbaranesFacturasLineas_Datos = new VTA_AlbaranesFacturasLineas_Datos();
|
|
lst_idsFacturaCabecera_PorArticulo = obj_VTA_AlbaranesFacturasLineas_Datos.Obtener_IdsFacturaCabecera_PorIdArticulo(lng_idArticulo);
|
|
}
|
|
if (lst_idsFacturaCabecera_PorArticulo == null)
|
|
{
|
|
lst_idsFacturaCabecera_PorArticulo = new List<long>();
|
|
}
|
|
string str_Filtro_FacturasPorArticulo = Funciones.Formar_ContenidoIN_ParaConsultaWhere(nameof(VTA_FacturasCabecera),
|
|
nameof(VTA_FacturasCabecera.id),
|
|
G_ENUM_FORMARCONTENIDOIN_CONDICIONANTES.NADA,
|
|
lst_idsFacturaCabecera_PorArticulo);
|
|
#endregion
|
|
|
|
#region Factura Lineas Por Articulo Comodin
|
|
List<long> lst_idsFacturaCabecera_PorArticuloComodin = null;
|
|
|
|
if (lng_idArticuloComodin > -1)
|
|
{
|
|
VTA_AlbaranesFacturasLineas_Datos obj_VTA_AlbaranesFacturasLineas_Datos = new VTA_AlbaranesFacturasLineas_Datos();
|
|
lst_idsFacturaCabecera_PorArticuloComodin = obj_VTA_AlbaranesFacturasLineas_Datos.Obtener_IdsFacturaCabecera_PorIdArticuloComodin(lng_idArticuloComodin);
|
|
}
|
|
if (lst_idsFacturaCabecera_PorArticuloComodin == null)
|
|
{
|
|
lst_idsFacturaCabecera_PorArticuloComodin = new List<long>();
|
|
}
|
|
string str_Filtro_FacturasPorArticuloComodin = Funciones.Formar_ContenidoIN_ParaConsultaWhere(nameof(VTA_FacturasCabecera),
|
|
nameof(VTA_FacturasCabecera.id),
|
|
G_ENUM_FORMARCONTENIDOIN_CONDICIONANTES.NADA,
|
|
lst_idsFacturaCabecera_PorArticuloComodin);
|
|
#endregion
|
|
|
|
|
|
string str_Filtro_Facturas = Funciones.Formar_ContenidoIN_ParaConsultaWhere(nameof(VTA_FacturasCabecera),
|
|
nameof(VTA_FacturasCabecera.id),
|
|
G_ENUM_FORMARCONTENIDOIN_CONDICIONANTES.AND_FIN,
|
|
_lst_ids);
|
|
|
|
|
|
string cif = "cif";// nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.MAE_Clientes.cif);
|
|
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.id) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.numeroFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.fecha) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.fechaIntroduccion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaIntroduccion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.estado) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.estado) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.claveEmisora) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.claveEmisora) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.descripcion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.guid) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.guid) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.descuentoProntoPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descuentoProntoPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.descuentoFinalFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descuentoFinalFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.referencia) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.referencia) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.recargo) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.recargo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.situacionPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.situacionPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.observaciones) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.observaciones) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.aplicarRetencion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.aplicarRetencion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.noDeclararModelosOficiales) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.noDeclararModelosOficiales) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.criterioCaja) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.criterioCaja) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.retencion_Base) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Base) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.retencion_Porcentaje) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Porcentaje) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.retencion_Valor) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Valor) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_bruto) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_bruto) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_descuentoProntoPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoProntoPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_descuentoFinalFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoFinalFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_baseImponible) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_baseImponible) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_impuesto) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_impuesto) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_recargo) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_recargo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_retencion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_retencion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.total_Final) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_Final) + "," +
|
|
//ids
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idCliente) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idSocio) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idDelegacion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idFormaPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idFormaPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idEmpresa) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idPredefinidoCabecera) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idPredefinidoCabecera) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idLiquidacionTributaria) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idLiquidacionTributaria) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idMoneda) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idMoneda) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idImpuestoCabecera) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idImpuestoCabecera) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idEmpleado) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpleado) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_Preventa) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Preventa) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_PreventaHabitual) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_Repartidor) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_Cobrador) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_CobradorHabitual) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idVendedor_Autoventa) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Autoventa) + "," +
|
|
//Cliente_Codigo
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_Codigo)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_Codigo) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.codigo) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_Codigo) + " = '',"
|
|
)
|
|
) +
|
|
//Cliente_RazonSocial
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_RazonSocial)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_RazonSocial) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.razonSocial) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_RazonSocial) + " = '',"
|
|
)
|
|
) +
|
|
//Cliente_NombreComercial
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_NombreComercial)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_NombreComercial) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.nombreComercial) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_NombreComercial) + " = '',"
|
|
)
|
|
) +
|
|
//Cliente_Cif
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(cif/*nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.MAE_Clientes.cif)*/))
|
|
?
|
|
(
|
|
cif/*nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.MAE_Clientes.cif)*/ + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.cif) + ","
|
|
)
|
|
:
|
|
(
|
|
cif/*nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.MAE_Clientes.cif)*/ + " = '',"
|
|
)
|
|
) +
|
|
//Socio
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_Codigo) + " = " + nameof(GTT_Socios) + "." + nameof(GTT_Socios.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_Descripcion) + " = " + nameof(GTT_Socios) + "." + nameof(GTT_Socios.razonSocial) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_FechaBorrado) + " = " + nameof(GTT_Socios) + "." + nameof(GTT_Socios.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Delegacion
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_Codigo) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_Descripcion) + " =" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_FechaBorrado) + " =" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Empresa
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_Codigo) + " = " + nameof(GEN_Empresas) + "." + nameof(GEN_Empresas.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_Descripcion) + " =" + nameof(GEN_Empresas) + "." + nameof(GEN_Empresas.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_FechaBorrado) + " =" + nameof(GEN_Empresas) + "." + nameof(GEN_Empresas.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Moneda
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_Codigo) + " = " + nameof(GEN_Monedas) + "." + nameof(GEN_Monedas.moneda) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_Descripcion) + " =" + nameof(GEN_Monedas) + "." + nameof(GEN_Monedas.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_FechaBorrado) + " =" + nameof(GEN_Monedas) + "." + nameof(GEN_Monedas.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//ImpuestoCabecera
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_Codigo) + " = " + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_Descripcion) + " =" + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_FechaBorrado) + " =" + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Empleado
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_Codigo) + " = " + nameof(MAE_Empleados) + "." + nameof(MAE_Empleados.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_Nombre) + " =" + nameof(MAE_Empleados) + "." + nameof(MAE_Empleados.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_FechaBorrado) + " =" + nameof(MAE_Empleados) + "." + nameof(MAE_Empleados.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//FormaPago
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_Codigo) + " = " + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_Nombre) + " =" + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_FechaBorrado) + " =" + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(Preventa)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_1." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_1." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_FechaBorrado) + " " + nameof(MAE_Vendedores) + "_AUX_1." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(PreventaHabitual)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_2." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_2." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_FechaBorrado) + " = " + nameof(MAE_Vendedores) + "_AUX_2." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(Repartidor)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_3." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_3." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_FechaBorrado) + " = " + nameof(MAE_Vendedores) + "_AUX_3." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(Cobrador)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_4." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_4." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_FechaBorrado) + " = " + nameof(MAE_Vendedores) + "_AUX_4." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(CobradorHabitual)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_5." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_5." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_FechaBorrado) + " = " + nameof(MAE_Vendedores) + "_AUX_5." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//Vendedor(Autoventa)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_Codigo) + " = " + nameof(MAE_Vendedores) + "_AUX_6." + nameof(MAE_Vendedores.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_Nombre) + " = " + nameof(MAE_Vendedores) + "_AUX_6." + nameof(MAE_Vendedores.nombre) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_FechaBorrado) + " = " + nameof(MAE_Vendedores) + "_AUX_6." + nameof(MAE_Vendedores.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_Nombre) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//PredefinidoCabecera (Factura)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_Codigo) + " = " + nameof(CTA_PredefinidosCabeceras) + "_AUX_1." + nameof(CTA_PredefinidosCabeceras.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_Descripcion) + " = " + nameof(CTA_PredefinidosCabeceras) + "_AUX_1." + nameof(CTA_PredefinidosCabeceras.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_FechaBorrado) + " = " + nameof(CTA_PredefinidosCabeceras) + "_AUX_1." + nameof(CTA_PredefinidosCabeceras.fechaBorrado) + ","
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura_FechaBorrado) + " = NULL, "
|
|
)
|
|
) +
|
|
//ClaveAnalitica
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica)))
|
|
?
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_Codigo) + " = " + nameof(CTA_ClavesAnaliticas) + "." + nameof(CTA_ClavesAnaliticas.codigo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_Descripcion) + " = " + nameof(CTA_ClavesAnaliticas) + "." + nameof(CTA_ClavesAnaliticas.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_FechaBorrado) + " = " + nameof(CTA_ClavesAnaliticas) + "." + nameof(CTA_ClavesAnaliticas.fechaBorrado)
|
|
)
|
|
:
|
|
(
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_Codigo) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_Descripcion) + " = ''," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica_FechaBorrado) + " = NULL "
|
|
)
|
|
) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
//Cliente
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_Codigo)) ||
|
|
_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_RazonSocial)) ||
|
|
_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Cliente_NombreComercial)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Clientes) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Socio
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Socio)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GTT_Socios) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " = " + nameof(GTT_Socios) + "." + nameof(GTT_Socios.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Delegacion
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Delegacion)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Empresa
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empresa)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GEN_Empresas) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + " = " + nameof(GEN_Empresas) + "." + nameof(GEN_Empresas.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Moneda
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Moneda)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GEN_Monedas) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idMoneda) + " = " + nameof(GEN_Monedas) + "." + nameof(GEN_Monedas.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//ImpuestoCabecera
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ImpuestoCabecera)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(GEN_ImpuestosCabecera) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idImpuestoCabecera) + " = " + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Empleado
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Empleado)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Empleados) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpleado) + " = " + nameof(MAE_Empleados) + "." + nameof(MAE_Empleados.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//FormaPago
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.FormaPago)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_FormasPago) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idFormaPago) + " = " + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(Preventa)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Preventa)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_1 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Preventa) + " = " + nameof(MAE_Vendedores) + "_AUX_1." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(PreventaHabitual)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_PreventaHabitual)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_2 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + " = " + nameof(MAE_Vendedores) + "_AUX_2." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(Repartidor)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Repartidor)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_3 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + " = " + nameof(MAE_Vendedores) + "_AUX_3." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(Cobrador)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Cobrador)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_4 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + " = " + nameof(MAE_Vendedores) + "_AUX_4." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(CobradorHabitual)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_CobradorHabitual)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_5 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + " = " + nameof(MAE_Vendedores) + "_AUX_5." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//Vendedor(Autoventa)
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.Vendedor_Autoventa)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(MAE_Vendedores) + " as " + nameof(MAE_Vendedores) + "_AUX_6 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Autoventa) + " = " + nameof(MAE_Vendedores) + "_AUX_6." + nameof(MAE_Vendedores.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//PredefinidoCabeceraFactura
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.PredefinidoCabeceraFactura)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(CTA_PredefinidosCabeceras) + " AS " + nameof(CTA_PredefinidosCabeceras) + "_AUX_1 ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idPredefinidoCabecera) + " = " + nameof(CTA_PredefinidosCabeceras) + "_AUX_1." + nameof(CTA_PredefinidosCabeceras.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
//ClaveAnalitica
|
|
(
|
|
(_lst_CamposConRelacionABuscar.Contains(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.ClaveAnalitica)))
|
|
?
|
|
(
|
|
" LEFT JOIN " + nameof(CTA_ClavesAnaliticas) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idClaveAnalitica) + " = " + nameof(CTA_ClavesAnaliticas) + "." + nameof(CTA_ClavesAnaliticas.id)
|
|
)
|
|
: ("")
|
|
) +
|
|
" WHERE " +
|
|
//fechaBorrado
|
|
" ( " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null ) AND " +
|
|
//id
|
|
" ( " +
|
|
(
|
|
(_lng_id > -1)
|
|
? (nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=@id ")
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) AND " +
|
|
str_Filtro_Facturas +
|
|
//Empresa
|
|
" ( " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + "=" + _lng_idEmpresaSeleccionada + str_Filtro_Empresa +
|
|
" ) AND " +
|
|
" ( " +
|
|
(
|
|
str_Opcion_Cliente != ""
|
|
? (
|
|
" ( not " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " is null) and " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + "=" + lng_idCliente
|
|
)
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) AND " +
|
|
//Articulo
|
|
" ( " +
|
|
(
|
|
str_Opcion_Articulo != ""
|
|
?
|
|
(
|
|
lst_idsFacturaCabecera_PorArticulo.Count > 0
|
|
? str_Filtro_FacturasPorArticulo
|
|
: " 1 <> 1 "
|
|
)
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) AND " +
|
|
//ArticuloComodin
|
|
" ( " +
|
|
(
|
|
str_Opcion_ArticuloComodin != ""
|
|
?
|
|
(
|
|
lst_idsFacturaCabecera_PorArticuloComodin.Count > 0
|
|
? str_Filtro_FacturasPorArticuloComodin
|
|
: " 1 <> 1 "
|
|
)
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) AND " +
|
|
//Ejercicio
|
|
" ( " +
|
|
(
|
|
bol_FiltrarEjercicio == true
|
|
? (nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " <=@TemporadaFin AND " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " >=@TemporadaInicio ")
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) ";
|
|
|
|
//Parametros
|
|
List<SqlParameter> lst_Parametros = new List<SqlParameter>();
|
|
if (_lng_id > -1)
|
|
{
|
|
lst_Parametros.Add(new SqlParameter("@id", _lng_id));
|
|
}
|
|
|
|
if (bol_FiltrarEjercicio)
|
|
{
|
|
lst_Parametros.Add(new SqlParameter("@TemporadaFin", dtt_TemporadaFin.Value));
|
|
lst_Parametros.Add(new SqlParameter("@TemporadaInicio", dtt_TemporadaInicio.Value));
|
|
}
|
|
|
|
object[] arr_Parametros = lst_Parametros.ToArray();
|
|
|
|
//Rellenar el Modelo
|
|
g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO = _obj_Exferia_Entities.Database.SqlQuery<INTERNO_VTA_FacturasCabecera_Listado_Modelo>(str_SQL, arr_Parametros).ToList();
|
|
|
|
//Añadir los Ejercicios
|
|
if (g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO != null && g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO.Count > 0)
|
|
{
|
|
Agregar_Ejercicios_ListadoSecundario(_lng_idEmpresaSeleccionada);
|
|
}
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(ConsultaRellenar_Listado_Secundario), true);
|
|
}
|
|
}
|
|
|
|
private void Agregar_Ejercicios_ListadoSecundario(long _lng_idEmpresaSeleccionada)
|
|
{
|
|
try
|
|
{
|
|
List<GEN_EjerciciosActivos_Empresa> lst_GEN_EjerciciosActivos_Empresa = Datos_Generales.GEN_EjerciciosActivos_Empresa_Obtener_Listado_Por_Empresa(_lng_idEmpresaSeleccionada);
|
|
|
|
if (lst_GEN_EjerciciosActivos_Empresa != null)
|
|
{
|
|
//Rellenar el Listado
|
|
foreach (INTERNO_VTA_FacturasCabecera_Listado_Modelo mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo in g_lst_INTERNO_VTA_FacturasCabecera_Listado_Modelo_LISTADOSECUNDARIO)
|
|
{
|
|
mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.Ejercicios_Empresa = lst_GEN_EjerciciosActivos_Empresa.Where(m => m.temporadaFechaFin >= mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.fecha &&
|
|
m.temporadaFechaInicio <= mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo.fecha)
|
|
.FirstOrDefault();
|
|
}
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Agregar_Ejercicios), true);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region F3
|
|
private INTERNO_VTA_FacturasCabecera_Listado_Modelo g_mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo_F3 = null;
|
|
|
|
public override dynamic Obtener_F3(string _str_filtro, string _str_CampoBusqueda, long _lng_idEmpresaSeleccionada, long _lng_idEjercicioActual, List<INTERNO_Filtro_OpcionPadre_Modelo> _lst_INTERNO_Filtro_OpcionPadre_Modelo, List<INTERNO_Filtro_Modelo> _lst_INTERNO_Filtro_Modelo)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
dynamic dnm_MAE = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
//Consulta ......................................................
|
|
ConsultaRellenar_F3(obj_Exferia_Entities, _lng_idEmpresaSeleccionada, _lng_idEjercicioActual, Datos_Generales.GEN_Empresas_Devolver_EmpresasCompartidas_SegunFichero(_lng_idEmpresaSeleccionada, typeof(VTA_FacturasCabecera).Name), _str_CampoBusqueda, _str_filtro, -1, _lst_INTERNO_Filtro_OpcionPadre_Modelo, _lst_INTERNO_Filtro_Modelo);
|
|
// ..............................................................
|
|
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo_F3 != null)
|
|
{
|
|
dnm_MAE = g_mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo_F3;
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_F3), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return dnm_MAE;
|
|
}
|
|
public override dynamic Obtener_F3_PorId(long _lng_id, long _lng_idEmpresaSeleccionada, long _lng_idEjercicioActual, List<INTERNO_Filtro_OpcionPadre_Modelo> _lst_INTERNO_Filtro_OpcionPadre_Modelo, List<INTERNO_Filtro_Modelo> _lst_INTERNO_Filtro_Modelo)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
dynamic dnm_MAE = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
//Conuslta ......................................................
|
|
ConsultaRellenar_F3(obj_Exferia_Entities, _lng_idEmpresaSeleccionada, _lng_idEjercicioActual, Datos_Generales.GEN_Empresas_Devolver_EmpresasCompartidas_SegunFichero(_lng_idEmpresaSeleccionada, typeof(VTA_FacturasCabecera).Name), "", "", _lng_id, _lst_INTERNO_Filtro_OpcionPadre_Modelo, _lst_INTERNO_Filtro_Modelo);
|
|
// ..............................................................
|
|
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo_F3 != null)
|
|
{
|
|
dnm_MAE = g_mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo_F3;
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_F3_PorId), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return dnm_MAE;
|
|
}
|
|
|
|
protected override void ConsultaRellenar_F3(Exferia_Entities _obj_Exferia_Entities, long _lng_idEmpresaSeleccionada, long _lng_idEjercicioActual, List<long> _lst_idEmpresasRelacionadas, string _str_CampoBusqueda, string _str_Filtro, long _lng_id, List<INTERNO_Filtro_OpcionPadre_Modelo> _lst_INTERNO_Filtro_OpcionPadre_Modelo, List<INTERNO_Filtro_Modelo> _lst_INTERNO_Filtro_Modelo)
|
|
{
|
|
try
|
|
{
|
|
string str_Filtro_Empresa = Funciones.Formar_ContenidoIN_ParaConsultaWhere(nameof(VTA_FacturasCabecera),
|
|
nameof(VTA_FacturasCabecera.idEmpresa),
|
|
G_ENUM_FORMARCONTENIDOIN_CONDICIONANTES.OR_INICIO,
|
|
_lst_idEmpresasRelacionadas);
|
|
|
|
//Datos del Padre si los tuviera .........................
|
|
long lng_Padre_id = -1;
|
|
string str_Padre_Opcion = "";
|
|
|
|
bool bol_FiltrarEjercicio = false;
|
|
DateTime? dtt_TemporadaInicio = null;
|
|
DateTime? dtt_TemporadaFin = null;
|
|
|
|
long lng_idFacturaCabecera = -1;
|
|
string str_OpcionFacturaCabecera = "";
|
|
|
|
long lng_idDelegacion = -1;
|
|
|
|
string str_Estado = "";
|
|
|
|
if (_lst_INTERNO_Filtro_OpcionPadre_Modelo != null && _lst_INTERNO_Filtro_OpcionPadre_Modelo.Count > 0)
|
|
{
|
|
foreach (INTERNO_Filtro_OpcionPadre_Modelo mdl_INTERNO_Filtro_OpcionPadre_Modelo in _lst_INTERNO_Filtro_OpcionPadre_Modelo)
|
|
{
|
|
//Ejercicio
|
|
if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idEjercicio)))
|
|
{
|
|
//Buscar el Modelo de Ejercicio
|
|
GEN_EjerciciosActivos_Empresa mdl_GEN_EjerciciosActivos_Empresa = Datos_Generales.GEN_EjerciciosActivos_Empresa_Obtener_Por_Id(mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR);
|
|
|
|
if (mdl_GEN_EjerciciosActivos_Empresa != null)
|
|
{
|
|
bol_FiltrarEjercicio = true;
|
|
dtt_TemporadaInicio = mdl_GEN_EjerciciosActivos_Empresa.temporadaFechaInicio;
|
|
dtt_TemporadaFin = mdl_GEN_EjerciciosActivos_Empresa.temporadaFechaFin;
|
|
}
|
|
}
|
|
//DELEGACION
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idDelegacion)))
|
|
{
|
|
lng_idDelegacion = mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR;
|
|
}
|
|
//FACTURASCABECERA
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(Variables.G_STR_OPCION_VTA_FACTURACABECERA))
|
|
{
|
|
lng_idFacturaCabecera = mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR;
|
|
str_OpcionFacturaCabecera = mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO;
|
|
}
|
|
//Estado
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.estado)))
|
|
{
|
|
str_Estado = (string)mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR_AUXILIAR;
|
|
}
|
|
//cliente o socio
|
|
else if (mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idCliente)) ||
|
|
mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idSocio)))
|
|
{
|
|
str_Padre_Opcion = mdl_INTERNO_Filtro_OpcionPadre_Modelo.NOMBRE_CAMPO;
|
|
lng_Padre_id = mdl_INTERNO_Filtro_OpcionPadre_Modelo.VALOR;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
long lng_Filtro = 0;
|
|
if (Funciones.IsNumeric(_str_Filtro))
|
|
{
|
|
lng_Filtro = long.Parse(_str_Filtro);
|
|
}
|
|
|
|
|
|
string str_SQL =
|
|
" SELECT distinct " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.id) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.numeroFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.fechaBorrado) + " IS null AND " +
|
|
" ( " +
|
|
(
|
|
_lng_id > -1
|
|
? (nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " = " + _lng_id)
|
|
: (nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + " = " + lng_Filtro)
|
|
) +
|
|
" ) AND " +
|
|
//Empresa
|
|
" ( " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + "=" + _lng_idEmpresaSeleccionada + str_Filtro_Empresa +
|
|
" ) AND " +
|
|
//Filtro por datos del padre relacionado
|
|
" ( " +
|
|
(
|
|
!str_Padre_Opcion.Equals("")
|
|
//Cliente
|
|
? str_Padre_Opcion.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idCliente))
|
|
? lng_Padre_id > -1
|
|
? nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + "=" + lng_Padre_id
|
|
: nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " is null "
|
|
//Socio
|
|
: (str_Padre_Opcion.Equals(nameof(INTERNO_VTA_FacturasCabecera_Listado_Modelo.idSocio)))
|
|
? lng_Padre_id > -1
|
|
? nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + "=" + lng_Padre_id
|
|
: nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " is null "
|
|
: " 1 = 1 "
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) and " +
|
|
//FacturasCabecera distintas
|
|
" ( " +
|
|
(
|
|
str_OpcionFacturaCabecera != ""
|
|
? nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "<>" + lng_idFacturaCabecera
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) and " +
|
|
//Delegacion
|
|
" ( " +
|
|
(
|
|
lng_idDelegacion > -1
|
|
? nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + "=" + lng_idDelegacion
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) and " +
|
|
//estado
|
|
" ( " +
|
|
(
|
|
(str_Estado.Trim().Length > 0)
|
|
? nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.estado) + "<>@estado "
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) and " +
|
|
//Ejercicio
|
|
" ( " +
|
|
(
|
|
bol_FiltrarEjercicio == true
|
|
? (nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " <=@TemporadaFin AND " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " >=@TemporadaInicio ")
|
|
: " 1 = 1 "
|
|
) +
|
|
" ) ";
|
|
|
|
//Parametros
|
|
List<SqlParameter> lst_Parametros = new List<SqlParameter>();
|
|
|
|
if (str_Estado.Trim().Length > 0)
|
|
{
|
|
lst_Parametros.Add(new SqlParameter("@estado", str_Estado));
|
|
}
|
|
if (bol_FiltrarEjercicio)
|
|
{
|
|
lst_Parametros.Add(new SqlParameter("@TemporadaFin", dtt_TemporadaFin.Value));
|
|
lst_Parametros.Add(new SqlParameter("@TemporadaInicio", dtt_TemporadaInicio.Value));
|
|
}
|
|
|
|
object[] arr_Parametros = lst_Parametros.ToArray();
|
|
|
|
//Rellenar el Modelo
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Listado_Modelo_F3 = _obj_Exferia_Entities.Database.SqlQuery<INTERNO_VTA_FacturasCabecera_Listado_Modelo>(str_SQL, arr_Parametros).FirstOrDefault();
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(ConsultaRellenar_F3), true);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Obtener
|
|
#region Obtener Simple
|
|
private dynamic g_dnm_Modelo_Obtener = null;
|
|
|
|
private static int g_int_TotalHilos_Obtener = 20;
|
|
private bool[] g_bol_Hilos_Terminados_Obtener = new bool[g_int_TotalHilos_Obtener];
|
|
public override dynamic Obtener(long _lng_id)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.id) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.numeroFactura) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idCliente) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idSocio) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idDelegacion) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idFormaPago) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idFormaPago) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.fecha) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.fechaIntroduccion) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaIntroduccion) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idEmpresa) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.estado) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.estado) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idPredefinidoCabecera) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idPredefinidoCabecera) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.fechaBorrado) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idLiquidacionTributaria) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idLiquidacionTributaria) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.claveEmisora) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.claveEmisora) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.descripcion) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descripcion) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.guid) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.guid) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idMoneda) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idMoneda) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idImpuestoCabecera) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idImpuestoCabecera) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.descuentoProntoPago) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descuentoProntoPago) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.descuentoFinalFactura) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descuentoFinalFactura) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idEmpleado) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpleado) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idVendedor_Preventa) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Preventa) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idVendedor_PreventaHabitual) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idVendedor_Repartidor) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idVendedor_Cobrador) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idVendedor_CobradorHabitual) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idVendedor_Autoventa) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Autoventa) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.referencia) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.referencia) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.recargo) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.recargo) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.situacionPago) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.situacionPago) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.observaciones) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.observaciones) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idClaveAnalitica) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idClaveAnalitica) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.aplicarRetencion) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.aplicarRetencion) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.noDeclararModelosOficiales) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.noDeclararModelosOficiales) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.criterioCaja) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.criterioCaja) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.retencion_Porcentaje) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Porcentaje) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.retencion_Valor) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Valor) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.retencion_Base) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Base) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_bruto) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_bruto) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_descuentoProntoPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoProntoPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_descuentoFinalFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoFinalFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_baseImponible) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_baseImponible) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_impuesto) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_impuesto) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_recargo) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_recargo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_retencion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_retencion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_Final) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_Final) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.id) + "=@id ";
|
|
|
|
//Parametros
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
|
|
//Rellenar el Modelo
|
|
g_dnm_Modelo_Obtener = obj_Exferia_Entities.Database.SqlQuery<INTERNO_VTA_FacturasCabecera_Modelo>(str_SQL, arr_Parametros).FirstOrDefault();
|
|
|
|
#region Rellenar Tablas Relacionadas
|
|
if (g_dnm_Modelo_Obtener != null)
|
|
{
|
|
//reiniciar Valores de los hilos
|
|
for (int int_Contador = 0; int_Contador < g_int_TotalHilos_Obtener; int_Contador++)
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[int_Contador] = false;
|
|
}
|
|
|
|
//GEN_Delegaciones ##########################################################################################
|
|
ThreadStart obj_ThreadStart_DELEGACION = new ThreadStart(Obtener_Delegacion_Modelo_OBTENER);
|
|
Thread obj_Thread_DELEGACION = new Thread(obj_ThreadStart_DELEGACION);
|
|
obj_Thread_DELEGACION.Start();
|
|
|
|
|
|
//MAE_Clientes ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idCliente != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_CLIENTE = new ThreadStart(Obtener_Cliente_Modelo_OBTENER);
|
|
Thread obj_Thread_CLIENTE = new Thread(obj_ThreadStart_CLIENTE);
|
|
obj_Thread_CLIENTE.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[1] = true;
|
|
}
|
|
|
|
//GTT_Socios ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idSocio != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_SOCIO = new ThreadStart(Obtener_Socio_Modelo_OBTENER);
|
|
Thread obj_Thread_SOCIO = new Thread(obj_ThreadStart_SOCIO);
|
|
obj_Thread_SOCIO.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[2] = true;
|
|
}
|
|
|
|
//GEN_Monedas ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idMoneda != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_MONEDA = new ThreadStart(Obtener_Moneda_Modelo_OBTENER);
|
|
Thread obj_Thread_MONEDA = new Thread(obj_ThreadStart_MONEDA);
|
|
obj_Thread_MONEDA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[3] = true;
|
|
}
|
|
|
|
//GEN_ImpuestosCabecera ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idImpuestoCabecera != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_IMPUESTOCABECERA = new ThreadStart(Obtener_ImpuestoCabecera_Modelo_OBTENER);
|
|
Thread obj_Thread_IMPUESTOCABECERA = new Thread(obj_ThreadStart_IMPUESTOCABECERA);
|
|
obj_Thread_IMPUESTOCABECERA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[4] = true;
|
|
}
|
|
|
|
//MAE_Empleados ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idEmpleado != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_EMPLEADO = new ThreadStart(Obtener_Empleado_Modelo_OBTENER);
|
|
Thread obj_Thread_EMPLEADO = new Thread(obj_ThreadStart_EMPLEADO);
|
|
obj_Thread_EMPLEADO.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[5] = true;
|
|
}
|
|
|
|
//MAE_FormasPago ##########################################################################################
|
|
ThreadStart obj_ThreadStart_FORMAPAGO = new ThreadStart(Obtener_FormaPago_Modelo_OBTENER);
|
|
Thread obj_Thread_FORMAPAGO = new Thread(obj_ThreadStart_FORMAPAGO);
|
|
obj_Thread_FORMAPAGO.Start();
|
|
|
|
//MAE_Vendedores ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idVendedor_Preventa != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_VENDEDOR_PREVENTA = new ThreadStart(Obtener_VendedorPreventa_Modelo_OBTENER);
|
|
Thread obj_Thread_VENDEDOR_PREVENTA = new Thread(obj_ThreadStart_VENDEDOR_PREVENTA);
|
|
obj_Thread_VENDEDOR_PREVENTA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[7] = true;
|
|
}
|
|
|
|
//MAE_Vendedores1 ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idVendedor_PreventaHabitual != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_VENDEDOR_PREVENTAHABITUAL = new ThreadStart(Obtener_VendedorPreventaHabitual_Modelo_OBTENER);
|
|
Thread obj_Thread_VENDEDOR_PREVENTAHABITUAL = new Thread(obj_ThreadStart_VENDEDOR_PREVENTAHABITUAL);
|
|
obj_Thread_VENDEDOR_PREVENTAHABITUAL.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[8] = true;
|
|
}
|
|
|
|
//MAE_Vendedores2 ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idVendedor_Repartidor != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_VENDEDOR_REPARTIDOR = new ThreadStart(Obtener_VendedorRepartidor_Modelo_OBTENER);
|
|
Thread obj_Thread_VENDEDOR_REPARTIDOR = new Thread(obj_ThreadStart_VENDEDOR_REPARTIDOR);
|
|
obj_Thread_VENDEDOR_REPARTIDOR.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[9] = true;
|
|
}
|
|
|
|
//MAE_Vendedores3 ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idVendedor_Cobrador != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_VENDEDOR_COBRADOR = new ThreadStart(Obtener_VendedorCobrador_Modelo_OBTENER);
|
|
Thread obj_Thread_VENDEDOR_COBRADOR = new Thread(obj_ThreadStart_VENDEDOR_COBRADOR);
|
|
obj_Thread_VENDEDOR_COBRADOR.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[10] = true;
|
|
}
|
|
|
|
//MAE_Vendedores4 ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idVendedor_CobradorHabitual != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_VENDEDOR_COBRADORHABITUAL = new ThreadStart(Obtener_VendedorCobradorHabitual_Modelo_OBTENER);
|
|
Thread obj_Thread_VENDEDOR_COBRADORHABITUAL = new Thread(obj_ThreadStart_VENDEDOR_COBRADORHABITUAL);
|
|
obj_Thread_VENDEDOR_COBRADORHABITUAL.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[11] = true;
|
|
}
|
|
|
|
//MAE_Vendedores5 ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idVendedor_Autoventa != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_VENDEDOR_AUTOVENTA = new ThreadStart(Obtener_VendedorAutoVenta_Modelo_OBTENER);
|
|
Thread obj_Thread_VENDEDOR_AUTOVENTA = new Thread(obj_ThreadStart_VENDEDOR_AUTOVENTA);
|
|
obj_Thread_VENDEDOR_AUTOVENTA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[12] = true;
|
|
}
|
|
|
|
//CTA_PredefinidosCabeceras ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idPredefinidoCabecera != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_PREDEFINIDOCABECERA = new ThreadStart(Obtener_PredefinidoCabecera_Modelo_OBTENER);
|
|
Thread obj_Thread_PREDEFINIDOCABECERA = new Thread(obj_ThreadStart_PREDEFINIDOCABECERA);
|
|
obj_Thread_PREDEFINIDOCABECERA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[13] = true;
|
|
}
|
|
|
|
//CTA_ClavesAnaliticas ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idClaveAnalitica != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_CLAVEANALITICA = new ThreadStart(Obtener_ClaveAnalitica_Modelo_OBTENER);
|
|
Thread obj_Thread_CLAVEANALITICA = new Thread(obj_ThreadStart_CLAVEANALITICA);
|
|
obj_Thread_CLAVEANALITICA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[14] = true;
|
|
}
|
|
|
|
//VTA_FacturasCabecera_Anexos ##########################################################################################
|
|
ThreadStart obj_ThreadStart_ANEXOS = new ThreadStart(Obtener_Anexos_Modelo_OBTENER);
|
|
Thread obj_Thread_ANEXOS = new Thread(obj_ThreadStart_ANEXOS);
|
|
obj_Thread_ANEXOS.Start();
|
|
|
|
//VTA_FacturasCabecera_DatosViaje ##########################################################################################
|
|
ThreadStart obj_ThreadStart_DATOSVIAJE = new ThreadStart(Obtener_DatosViaje_Modelo_OBTENER);
|
|
Thread obj_Thread_DATOSVIAJE = new Thread(obj_ThreadStart_DATOSVIAJE);
|
|
obj_Thread_DATOSVIAJE.Start();
|
|
|
|
//VTA_AlbaranesFacturasLineas ##########################################################################################
|
|
ThreadStart obj_ThreadStart_FACTURASLINEAS = new ThreadStart(Obtener_FacturasLineas_Modelo_OBTENER);
|
|
Thread obj_Thread_FACTURASLINEAS = new Thread(obj_ThreadStart_FACTURASLINEAS);
|
|
obj_Thread_FACTURASLINEAS.Start();
|
|
|
|
// VTA_FacturasCabecera_Resumen ##########################################################################################
|
|
ThreadStart obj_ThreadStart_RESUMEN = new ThreadStart(Obtener_Resumen_Modelo_OBTENER);
|
|
Thread obj_Thread_RESUMEN = new Thread(obj_ThreadStart_RESUMEN);
|
|
obj_Thread_RESUMEN.Start();
|
|
|
|
// GTT_LiquidacionesTributarias ##########################################################################################
|
|
if (g_dnm_Modelo_Obtener.idLiquidacionTributaria != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_LIQUIDACIONESTRIBUTARIAS = new ThreadStart(Obtener_LiquidacionesTributarias_Modelo_OBTENER);
|
|
Thread obj_Thread_LIQUIDACIONESTRIBUTARIAS = new Thread(obj_ThreadStart_LIQUIDACIONESTRIBUTARIAS);
|
|
obj_Thread_LIQUIDACIONESTRIBUTARIAS.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[19] = true;
|
|
}
|
|
|
|
//Esperando a que terminen todos los hilos .........................................
|
|
bool bol_Termino = false;
|
|
while (bol_Termino == false)
|
|
{
|
|
bol_Termino = true;
|
|
foreach (bool bol_Termino_Hilo in g_bol_Hilos_Terminados_Obtener)
|
|
{
|
|
if (bol_Termino_Hilo == false)
|
|
{
|
|
bol_Termino = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Thread.Sleep(10);
|
|
}
|
|
//.................................................................................
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return g_dnm_Modelo_Obtener;
|
|
}
|
|
|
|
#region Tablas Relacionadas
|
|
private void Obtener_Delegacion_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
g_dnm_Modelo_Obtener.GEN_Delegaciones = Datos_Generales.GEN_Delegaciones_Obtener_Modelo_Por_Id(g_dnm_Modelo_Obtener.idDelegacion);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[0] = true;
|
|
}
|
|
}
|
|
private void Obtener_Cliente_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAECLIENTES_OBTENERMODELO_POR_ID_AUX_1, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idCliente, false, false, false, false, false, true };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.MAE_Clientes = (MAE_Clientes)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[1] = true;
|
|
}
|
|
}
|
|
private void Obtener_Socio_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GESTIONTASAS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GESTIONTASAS + "." + Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS_PROCEDIMIENTO_GTTSOCIOS_OBTENERMODELO_POR_ID_AUX_1, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idSocio, false, false, false, false };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.GTT_Socios = (GTT_Socios)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[2] = true;
|
|
}
|
|
}
|
|
private void Obtener_Moneda_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
g_dnm_Modelo_Obtener.GEN_Monedas = Datos_Generales.GEN_Monedas_Obtener_Modelo_Por_Id(g_dnm_Modelo_Obtener.idMoneda);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[3] = true;
|
|
}
|
|
}
|
|
private void Obtener_ImpuestoCabecera_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
g_dnm_Modelo_Obtener.GEN_ImpuestosCabecera = Datos_Generales.GEN_ImpuestosCabecera_Obtener_Modelo_Por_Id(g_dnm_Modelo_Obtener.idImpuestoCabecera);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[4] = true;
|
|
}
|
|
}
|
|
private void Obtener_Empleado_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEEMPLEADOS_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idEmpleado };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.MAE_Empleados = (MAE_Empleados)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[5] = true;
|
|
}
|
|
}
|
|
private void Obtener_FormaPago_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEFORMASDEPAGO_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idFormaPago };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.MAE_FormasPago = (MAE_FormasPago)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[6] = true;
|
|
}
|
|
}
|
|
private void Obtener_VendedorPreventa_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEVENDEDORES_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idVendedor_Preventa };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.MAE_Vendedores = (MAE_Vendedores)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[7] = true;
|
|
}
|
|
}
|
|
private void Obtener_VendedorPreventaHabitual_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEVENDEDORES_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idVendedor_PreventaHabitual };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.MAE_Vendedores1 = (MAE_Vendedores)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[8] = true;
|
|
}
|
|
}
|
|
private void Obtener_VendedorRepartidor_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEVENDEDORES_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idVendedor_Repartidor };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.MAE_Vendedores2 = (MAE_Vendedores)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[9] = true;
|
|
}
|
|
}
|
|
private void Obtener_VendedorCobrador_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEVENDEDORES_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idVendedor_Cobrador };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.MAE_Vendedores3 = (MAE_Vendedores)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[10] = true;
|
|
}
|
|
}
|
|
private void Obtener_VendedorCobradorHabitual_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEVENDEDORES_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idVendedor_CobradorHabitual };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.MAE_Vendedores4 = (MAE_Vendedores)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[11] = true;
|
|
}
|
|
}
|
|
private void Obtener_VendedorAutoVenta_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEVENDEDORES_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idVendedor_Autoventa };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.MAE_Vendedores5 = (MAE_Vendedores)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[12] = true;
|
|
}
|
|
}
|
|
private void Obtener_PredefinidoCabecera_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_CONTABILIDAD + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_CONTABILIDAD + "." + Variables.G_STR_LIBRERIA_DATOSCONTABILIDAD);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSCONTABILIDAD_PROCEDIMIENTO_CTAPREDEFINIDOCABECERA_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idPredefinidoCabecera };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.CTA_PredefinidosCabeceras = (CTA_PredefinidosCabeceras)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[13] = true;
|
|
}
|
|
}
|
|
private void Obtener_ClaveAnalitica_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_CONTABILIDAD + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_CONTABILIDAD + "." + Variables.G_STR_LIBRERIA_DATOSCONTABILIDAD);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSCONTABILIDAD_PROCEDIMIENTO_CTACLAVESANALITICAS_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idClaveAnalitica };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.CTA_ClavesAnaliticas = (CTA_ClavesAnaliticas)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[14] = true;
|
|
}
|
|
}
|
|
private void Obtener_Anexos_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
VTA_FacturasCabecera_Anexos_Datos obj_VTA_FacturasCabecera_Anexos_Datos = new VTA_FacturasCabecera_Anexos_Datos();
|
|
g_dnm_Modelo_Obtener.VTA_FacturasCabecera_Anexos = obj_VTA_FacturasCabecera_Anexos_Datos.Obtener_ModeloListado_Por_FacturaCabecera(g_dnm_Modelo_Obtener.id, true, true, true, true);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[15] = true;
|
|
}
|
|
}
|
|
private void Obtener_DatosViaje_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
VTA_FacturasCabecera_DatosViaje_Datos obj_VTA_FacturasCabecera_DatosViaje_Datos = new VTA_FacturasCabecera_DatosViaje_Datos();
|
|
g_dnm_Modelo_Obtener.VTA_FacturasCabecera_DatosViaje = obj_VTA_FacturasCabecera_DatosViaje_Datos.Obtener_ModeloListado_Por_FacturaCabecera(g_dnm_Modelo_Obtener.id);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[16] = true;
|
|
}
|
|
}
|
|
private void Obtener_FacturasLineas_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
VTA_AlbaranesFacturasLineas_Datos obj_VTA_AlbaranesFacturasLineas_Datos = new VTA_AlbaranesFacturasLineas_Datos();
|
|
g_dnm_Modelo_Obtener.AlbaranesFacturasLineas = obj_VTA_AlbaranesFacturasLineas_Datos.Obtener_Registros_Para_Listado_Por_FacturaCabecera(g_dnm_Modelo_Obtener.id);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[17] = true;
|
|
}
|
|
}
|
|
private void Obtener_Resumen_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
VTA_FacturasCabecera_Resumen_Datos obj_VTA_FacturasCabecera_Resumen_Datos = new VTA_FacturasCabecera_Resumen_Datos();
|
|
g_dnm_Modelo_Obtener.VTA_FacturasCabecera_Resumen = obj_VTA_FacturasCabecera_Resumen_Datos.Obtener_ModeloListado_Por_FacturaCabecera(g_dnm_Modelo_Obtener.id);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[18] = true;
|
|
}
|
|
}
|
|
private void Obtener_LiquidacionesTributarias_Modelo_OBTENER()
|
|
{
|
|
try
|
|
{
|
|
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GESTIONTASAS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GESTIONTASAS + "." + Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS_PROCEDIMIENTO_GTTLIQUIDACIONESTRIBUTARIAS_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_dnm_Modelo_Obtener.idLiquidacionTributaria };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_dnm_Modelo_Obtener.GTT_LiquidacionesTributarias = (GTT_LiquidacionesTributarias)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener[19] = true;
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
public override dynamic Obtener_Registro_PorCampo(string _str_Filtro, string _str_CampoBusqueda, long _lng_idEmpresaSeleccionada, long _lng_idEjercicioActual)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public bool EsTipoSocio(long _lng_id)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
bool bol_ValorDevuelto = false;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(VTA_FacturasCabecera.id) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera.fechaBorrado) + " is null and " +
|
|
nameof(VTA_FacturasCabecera.id) + "=@id and " +
|
|
"( not " + nameof(VTA_FacturasCabecera.idSocio) + " is null ) ";
|
|
|
|
//Parametros
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
|
|
//Rellenar el Modelo
|
|
long? lng_id = obj_Exferia_Entities.Database.SqlQuery<long>(str_SQL, arr_Parametros).FirstOrDefault();
|
|
|
|
if (lng_id != null && lng_id.Value > 0)
|
|
{
|
|
bol_ValorDevuelto = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(EsTipoSocio), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return bol_ValorDevuelto;
|
|
}
|
|
|
|
#region Obtener Auxiliar
|
|
private INTERNO_VTA_FacturasCabecera_Modelo g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR = null;
|
|
|
|
private static int g_int_TotalHilos_Obtener_AUXILIAR = 12;
|
|
private bool[] g_bol_Hilos_Terminados_Obtener_AUXILIAR = new bool[g_int_TotalHilos_Obtener_AUXILIAR];
|
|
|
|
public INTERNO_VTA_FacturasCabecera_Modelo Obtener_Auxiliar(long _lng_id)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.id) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.numeroFactura) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idCliente) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idSocio) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idDelegacion) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_bruto) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_bruto) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_descuentoProntoPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoProntoPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_descuentoFinalFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoFinalFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_baseImponible) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_baseImponible) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_impuesto) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_impuesto) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_recargo) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_recargo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_retencion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_retencion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.total_Final) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_Final) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.fecha) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idEmpresa) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.fechaBorrado) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.claveEmisora) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.claveEmisora) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idLiquidacionTributaria) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idLiquidacionTributaria) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idVendedor_CobradorHabitual) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + " , " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Modelo.idPredefinidoCabecera) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idPredefinidoCabecera) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=@id";
|
|
|
|
//Parametros
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
|
|
//Rellenar el Modelo
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR = obj_Exferia_Entities.Database.SqlQuery<INTERNO_VTA_FacturasCabecera_Modelo>(str_SQL, arr_Parametros).FirstOrDefault();
|
|
|
|
#region Rellenar Tablas Relacionadas
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR != null)
|
|
{
|
|
//reiniciar Valores de los hilos
|
|
for (int int_Contador = 0; int_Contador < g_int_TotalHilos_Obtener_AUXILIAR; int_Contador++)
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[int_Contador] = false;
|
|
}
|
|
|
|
//MAE_Clientes ##########################################################################################
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idCliente != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_CLIENTE = new ThreadStart(Obtener_Cliente_Modelo_AUXILIAR);
|
|
Thread obj_Thread_CLIENTE = new Thread(obj_ThreadStart_CLIENTE);
|
|
obj_Thread_CLIENTE.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[0] = true;
|
|
}
|
|
|
|
//GTT_Socios ##########################################################################################
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idSocio != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_SOCIO = new ThreadStart(Obtener_Socio_Modelo_AUXILIAR);
|
|
Thread obj_Thread_SOCIO = new Thread(obj_ThreadStart_SOCIO);
|
|
obj_Thread_SOCIO.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[1] = true;
|
|
}
|
|
|
|
//GEN_Empresas ##########################################################################################
|
|
ThreadStart obj_ThreadStart_EMPRESA = new ThreadStart(Obtener_Empresa_Modelo_AUXILIAR);
|
|
Thread obj_Thread_EMPRESA = new Thread(obj_ThreadStart_EMPRESA);
|
|
obj_Thread_EMPRESA.Start();
|
|
|
|
//GEN_Delegaciones ##########################################################################################
|
|
ThreadStart obj_ThreadStart_DELEGACION = new ThreadStart(Obtener_Delegacion_Modelo_AUXILIAR);
|
|
Thread obj_Thread_DELEGACION = new Thread(obj_ThreadStart_DELEGACION);
|
|
obj_Thread_DELEGACION.Start();
|
|
|
|
//GTT_LiquidacionesTributarias ##########################################################################################
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idLiquidacionTributaria != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_LIQUIDACIONTRIBUTARIA = new ThreadStart(Obtener_LiquidacionTributaria_Modelo_AUXILIAR);
|
|
Thread obj_Thread_LIQUIDACIONTRIBUTARIA = new Thread(obj_ThreadStart_LIQUIDACIONTRIBUTARIA);
|
|
obj_Thread_LIQUIDACIONTRIBUTARIA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[4] = true;
|
|
}
|
|
|
|
//VTA_Vencimientos ##########################################################################################
|
|
ThreadStart obj_ThreadStart_VENCIMIENTOS = new ThreadStart(Obtener_Vencimiento_Modelo_AUXILIAR);
|
|
Thread obj_Thread_VENCIMIENTOS = new Thread(obj_ThreadStart_VENCIMIENTOS);
|
|
obj_Thread_VENCIMIENTOS.Start();
|
|
|
|
//CTA_PredefinidosCabeceras ##########################################################################################
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idPredefinidoCabecera != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_PREDEFINIDOCABECERA = new ThreadStart(Obtener_PredefinidoCabecera_Modelo_AUXILIAR);
|
|
Thread obj_Thread_PREDEFINIDOCABECERA = new Thread(obj_ThreadStart_PREDEFINIDOCABECERA);
|
|
obj_Thread_PREDEFINIDOCABECERA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[6] = true;
|
|
}
|
|
|
|
//ImporteTotal Vencimiento ##########################################################################################
|
|
ThreadStart obj_ThreadStart_IMPORTETOTAL_VENCIMIENTOS = new ThreadStart(Obtener_ImporteTotalVencimientos_Modelo_AUXILIAR);
|
|
Thread obj_Thread_IMPORTETOTAL_VENCIMIENTOS = new Thread(obj_ThreadStart_IMPORTETOTAL_VENCIMIENTOS);
|
|
obj_Thread_IMPORTETOTAL_VENCIMIENTOS.Start();
|
|
|
|
//ImporteTotal Cobros ##########################################################################################
|
|
ThreadStart obj_ThreadStart_IMPORTETOTAL_COBROS = new ThreadStart(Obtener_ImporteTotalCobros_Modelo_AUXILIAR);
|
|
Thread obj_Thread_IMPORTETOTAL_COBROS = new Thread(obj_ThreadStart_IMPORTETOTAL_COBROS);
|
|
obj_Thread_IMPORTETOTAL_COBROS.Start();
|
|
|
|
//ImporteTotal Devoluciones ##########################################################################################
|
|
ThreadStart obj_ThreadStart_IMPORTETOTAL_DEVOLUCIONES = new ThreadStart(Obtener_ImporteTotalDevoluciones_Modelo_AUXILIAR);
|
|
Thread obj_Thread_IMPORTETOTAL_DEVOLUCIONES = new Thread(obj_ThreadStart_IMPORTETOTAL_DEVOLUCIONES);
|
|
obj_Thread_IMPORTETOTAL_DEVOLUCIONES.Start();
|
|
|
|
//Ejercicio ##########################################################################################
|
|
ThreadStart obj_ThreadStart_EJERCICIO = new ThreadStart(Obtener_Ejercicio_Modelo_AUXILIAR);
|
|
Thread obj_Thread_EJERCICIO = new Thread(obj_ThreadStart_EJERCICIO);
|
|
obj_Thread_EJERCICIO.Start();
|
|
|
|
//MAE_CuentasBancariasSEPA_Cobros ##########################################################################################
|
|
ThreadStart obj_ThreadStart_CUENTABANCARIA = new ThreadStart(Obtener_CuentabancariaPorDefecto_Modelo_AUXILIAR);
|
|
Thread obj_Thread_CUENTABANCARIA = new Thread(obj_ThreadStart_CUENTABANCARIA);
|
|
obj_Thread_CUENTABANCARIA.Start();
|
|
|
|
//Esperando a que terminen todos los hilos .........................................
|
|
bool bol_Termino = false;
|
|
while (bol_Termino == false)
|
|
{
|
|
bol_Termino = true;
|
|
foreach (bool bol_Termino_Hilo in g_bol_Hilos_Terminados_Obtener_AUXILIAR)
|
|
{
|
|
if (bol_Termino_Hilo == false)
|
|
{
|
|
bol_Termino = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Thread.Sleep(10);
|
|
}
|
|
//.................................................................................
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_Auxiliar), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR;
|
|
}
|
|
|
|
#region Tablas Relacionadas
|
|
private void Obtener_Cliente_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAECLIENTES_OBTENERMODELO_POR_ID_AUX_1, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idCliente.Value, true, true, true, true, true, true };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.MAE_Clientes = (MAE_Clientes)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[0] = true;
|
|
}
|
|
}
|
|
private void Obtener_Socio_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GESTIONTASAS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GESTIONTASAS + "." + Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS_PROCEDIMIENTO_GTTSOCIOS_OBTENERMODELO_POR_ID_AUX_1, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idSocio.Value, false, false, false, false };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.GTT_Socios = (GTT_Socios)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[1] = true;
|
|
}
|
|
}
|
|
private void Obtener_Empresa_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.GEN_Empresas = Datos_Generales.GEN_Empresas_Obtener_Modelo_Por_Id(g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idEmpresa, false, false, false, false);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[2] = true;
|
|
}
|
|
}
|
|
private void Obtener_Delegacion_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.GEN_Delegaciones = Datos_Generales.GEN_Delegaciones_Obtener_Modelo_Por_Id(g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idDelegacion);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[3] = true;
|
|
}
|
|
}
|
|
private void Obtener_LiquidacionTributaria_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GESTIONTASAS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GESTIONTASAS + "." + Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS_PROCEDIMIENTO_GTTLIQUIDACIONESTRIBUTARIAS_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idLiquidacionTributaria.Value };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.GTT_LiquidacionesTributarias = (GTT_LiquidacionesTributarias)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[4] = true;
|
|
}
|
|
}
|
|
private void Obtener_Vencimiento_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
VTA_Vencimientos_Datos obj_VTA_Vencimientos_Datos = new VTA_Vencimientos_Datos();
|
|
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.VTA_Vencimientos = obj_VTA_Vencimientos_Datos.Obtener_ModeloListado_Por_FacturaCabecera(g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.id);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[5] = true;
|
|
}
|
|
}
|
|
private void Obtener_PredefinidoCabecera_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_CONTABILIDAD + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_CONTABILIDAD + "." + Variables.G_STR_LIBRERIA_DATOSCONTABILIDAD);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSCONTABILIDAD_PROCEDIMIENTO_CTAPREDEFINIDOCABECERA_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idPredefinidoCabecera };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.CTA_PredefinidosCabeceras = (CTA_PredefinidosCabeceras)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[6] = true;
|
|
}
|
|
}
|
|
private void Obtener_ImporteTotalVencimientos_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
VTA_Vencimientos_Datos obj_VTA_Vencimientos_Datos = new VTA_Vencimientos_Datos();
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.Importe_Vencimientos = obj_VTA_Vencimientos_Datos.Obtener_ImporteTotal_Por_FacturaCabecera(g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.id);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[7] = true;
|
|
}
|
|
}
|
|
private void Obtener_ImporteTotalCobros_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
VTA_Cobros_Datos obj_VTA_Cobros_Datos = new VTA_Cobros_Datos();
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.Importe_Cobros = obj_VTA_Cobros_Datos.Obtener_ImporteTotal_Por_FacturaCabecera(g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.id);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[8] = true;
|
|
}
|
|
}
|
|
private void Obtener_ImporteTotalDevoluciones_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
VTA_DevolucionesCobros_Datos obj_VTA_DevolucionesCobros_Datos = new VTA_DevolucionesCobros_Datos();
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.Importe_Devoluciones = obj_VTA_DevolucionesCobros_Datos.Obtener_ImporteTotal_Por_FacturaCabecera(g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.id);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[9] = true;
|
|
}
|
|
}
|
|
private void Obtener_Ejercicio_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
List<GEN_EjerciciosActivos_Empresa> lst_GEN_EjerciciosActivos_Empresa = Datos_Generales.GEN_EjerciciosActivos_Empresa_Obtener_Listado_Por_Empresa(g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idEmpresa);
|
|
if (lst_GEN_EjerciciosActivos_Empresa != null)
|
|
{
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.Ejercicio = lst_GEN_EjerciciosActivos_Empresa.Where(m => m.temporadaFechaFin >= g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.fecha &&
|
|
m.temporadaFechaInicio <= g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.fecha)
|
|
.FirstOrDefault();
|
|
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[10] = true;
|
|
}
|
|
}
|
|
private void Obtener_CuentabancariaPorDefecto_Modelo_AUXILIAR()
|
|
{
|
|
try
|
|
{
|
|
string str_Opcion = "";
|
|
long lng_idEntidad = -1;
|
|
//CLientes
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idCliente != null)
|
|
{
|
|
str_Opcion = Variables.G_STR_OPCION_MAE_CLIENTE;
|
|
lng_idEntidad = g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idCliente.Value;
|
|
}
|
|
//Socios
|
|
else if (g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idSocio != null)
|
|
{
|
|
str_Opcion = Variables.G_STR_OPCION_GTT_SOCIO;
|
|
lng_idEntidad = g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idSocio.Value;
|
|
}
|
|
|
|
//Cuenta Bancaria Por Defecto
|
|
//Cargamos el ensamblado #########################################################################################################################################################################
|
|
Assembly m_assembly_1 = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type_1 = m_assembly_1.GetType("" + Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase_1 = Activator.CreateInstance(m_type_1);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo_1 = obj_Clase_1.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAECUENTASBANCARIASSEPACOBROS_OBTENERMODELO_POR_DEFECTO, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros_1 = { str_Opcion, lng_idEntidad, g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.idEmpresa };
|
|
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.CuentaBancaria_PorDefecto = (MAE_CuentasBancariasSEPA_Cobros)obj_MethodInfo_1.Invoke(obj_Clase_1, arr_Parametros_1);
|
|
//##################################################################################################################################################################################################
|
|
|
|
//Entidad Bancaria
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.CuentaBancaria_PorDefecto != null)
|
|
{
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.EntidadesBancarias = Datos_Generales.GEN_EntidadesBancarias_Obtener_Modelo_Por_Codigo(g_mdl_INTERNO_VTA_FacturasCabecera_Modelo_AUXILIAR.CuentaBancaria_PorDefecto.iban.Substring(4, 4));
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_AUXILIAR[11] = true;
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
public List<INTERNO_FacturasAsociados_Modelo> Obtener_FacturasAsociados_Pedidos(long _lng_idPedidoCabecera, long _lng_idPedidoLinea, List<long> _lst_idsPedidosLineas)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
List<INTERNO_FacturasAsociados_Modelo> lst_INTERNO_FacturasAsociados_Modelo = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_Filtro_PedidosLineas = Funciones.Formar_ContenidoIN_ParaConsultaWhere(nameof(VTA_PedidosLineas),
|
|
nameof(VTA_PedidosLineas.id),
|
|
G_ENUM_FORMARCONTENIDOIN_CONDICIONANTES.NADA,
|
|
_lst_idsPedidosLineas);
|
|
|
|
string str_SQL = " SELECT distinct " + nameof(VTA_PedidosLineas) + "." + nameof(VTA_PedidosLineas.id) + " as " + nameof(INTERNO_FacturasAsociados_Modelo.idPedidoLinea) + ", " +
|
|
nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + " + '/' + convert(varchar(50), " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + ") as " + nameof(INTERNO_FacturasAsociados_Modelo.NumeroFactura) +
|
|
" FROM " + nameof(VTA_PedidosLineas) +
|
|
" INNER JOIN " + nameof(VTA_AlbaranesFacturasLineas) + " ON " + nameof(VTA_AlbaranesFacturasLineas) + "." + nameof(VTA_AlbaranesFacturasLineas.idPedidoLinea) + " = " + nameof(VTA_PedidosLineas) + "." + nameof(VTA_PedidosLineas.id) + " " +
|
|
" INNER JOIN " + nameof(VTA_FacturasCabecera) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " = " + nameof(VTA_AlbaranesFacturasLineas) + "." + nameof(VTA_AlbaranesFacturasLineas.idFacturaCabecera) + " " +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + " " +
|
|
" WHERE " +
|
|
(_lng_idPedidoCabecera > 0 ? (nameof(VTA_PedidosLineas) + "." + nameof(VTA_PedidosLineas.idPedidoCabecera) + "= " + _lng_idPedidoCabecera) : "1=1") + " AND " +
|
|
(_lng_idPedidoLinea > 0 ? (nameof(VTA_PedidosLineas) + "." + nameof(VTA_PedidosLineas.id) + "= " + _lng_idPedidoLinea) : "1=1") + " AND " +
|
|
((_lst_idsPedidosLineas != null && _lst_idsPedidosLineas.Count > 0) ? str_Filtro_PedidosLineas : " 1=1 ");
|
|
|
|
lst_INTERNO_FacturasAsociados_Modelo = obj_Exferia_Entities.Database.SqlQuery<INTERNO_FacturasAsociados_Modelo>(str_SQL).ToList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_FacturasAsociados_Pedidos), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return lst_INTERNO_FacturasAsociados_Modelo;
|
|
}
|
|
|
|
#region Para Volcado
|
|
private INTERNO_VTA_FacturasCabecera_Volcado_Modelo g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo = null;
|
|
|
|
private static int g_int_TotalHilos_Obtener_PARAVOLCADO = 8;
|
|
private bool[] g_bol_Hilos_Terminados_Obtener_PARAVOLCADO = new bool[g_int_TotalHilos_Obtener_PARAVOLCADO];
|
|
|
|
public INTERNO_VTA_FacturasCabecera_Volcado_Modelo Obtener_Volcado(long _lng_id)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.id) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.numeroFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.fecha) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.fechaIntroduccion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaIntroduccion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.estado) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.estado) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.claveEmisora) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.claveEmisora) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.descripcion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descripcion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.guid) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.guid) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.descuentoProntoPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descuentoProntoPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.descuentoFinalFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descuentoFinalFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.referencia) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.referencia) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.recargo) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.recargo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.situacionPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.situacionPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.observaciones) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.observaciones) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.aplicarRetencion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.aplicarRetencion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.noDeclararModelosOficiales) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.noDeclararModelosOficiales) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.criterioCaja) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.criterioCaja) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.retencion_Base) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Base) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.retencion_Porcentaje) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Porcentaje) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.retencion_Valor) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Valor) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.total_bruto) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_bruto) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.total_descuentoProntoPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoProntoPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.total_descuentoFinalFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoFinalFactura) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.total_baseImponible) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_baseImponible) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.total_impuesto) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_impuesto) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.total_recargo) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_recargo) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.total) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.total_retencion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_retencion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.total_Final) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_Final) + "," +
|
|
//ids
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idCliente) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idSocio) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idDelegacion) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idFormaPago) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idFormaPago) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idEmpresa) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idPredefinidoCabecera) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idPredefinidoCabecera) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idLiquidacionTributaria) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idLiquidacionTributaria) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idMoneda) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idMoneda) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idImpuestoCabecera) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idImpuestoCabecera) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idEmpleado) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpleado) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_Preventa) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Preventa) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_PreventaHabitual) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_Repartidor) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_Cobrador) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_CobradorHabitual) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + "," +
|
|
nameof(INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_Autoventa) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Autoventa) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.id) + "=@id ";
|
|
|
|
//Parametros
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
|
|
//Rellenar el Modelo
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo = obj_Exferia_Entities.Database.SqlQuery<INTERNO_VTA_FacturasCabecera_Volcado_Modelo>(str_SQL, arr_Parametros).FirstOrDefault();
|
|
|
|
#region Rellenar Tablas Relacionadas
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo != null)
|
|
{
|
|
//reiniciar Valores de los hilos
|
|
for (int int_Contador = 0; int_Contador < g_int_TotalHilos_Obtener_PARAVOLCADO; int_Contador++)
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[int_Contador] = false;
|
|
}
|
|
|
|
//MAE_Clientes ##########################################################################################
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idCliente != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_CLIENTE = new ThreadStart(Obtener_Cliente_Modelo_PARAVOLCADO);
|
|
Thread obj_Thread_CLIENTE = new Thread(obj_ThreadStart_CLIENTE);
|
|
obj_Thread_CLIENTE.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[0] = true;
|
|
}
|
|
|
|
//GTT_Socios ##########################################################################################
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idSocio != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_SOCIO = new ThreadStart(Obtener_Socio_Modelo_PARAVOLCADO);
|
|
Thread obj_Thread_SOCIO = new Thread(obj_ThreadStart_SOCIO);
|
|
obj_Thread_SOCIO.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[1] = true;
|
|
}
|
|
|
|
|
|
//GEN_Delegaciones ##########################################################################################
|
|
ThreadStart obj_ThreadStart_DELEGACION = new ThreadStart(Obtener_Delegacion_Modelo_PARAVOLCADO);
|
|
Thread obj_Thread_DELEGACION = new Thread(obj_ThreadStart_DELEGACION);
|
|
obj_Thread_DELEGACION.Start();
|
|
|
|
//GEN_ImpuestosCabecera ##########################################################################################
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idImpuestoCabecera != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_IMPUESTOCABECERA = new ThreadStart(Obtener_ImpuestoCabecera_Modelo_Obtener_Volcado);
|
|
Thread obj_Thread_IMPUESTOCABECERA = new Thread(obj_ThreadStart_IMPUESTOCABECERA);
|
|
obj_Thread_IMPUESTOCABECERA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[3] = true;
|
|
}
|
|
|
|
//VTA_FacturasCabecera_Resumen ##########################################################################################
|
|
ThreadStart obj_ThreadStart_FACTURASRESUMEN = new ThreadStart(Obtener_FacturasResumen_Modelo_Obtener_Volcado);
|
|
Thread obj_Thread_FACTURASRESUMEN = new Thread(obj_ThreadStart_FACTURASRESUMEN);
|
|
obj_Thread_FACTURASRESUMEN.Start();
|
|
|
|
//MAE_Vendedores(PREVENTA) ##########################################################################################
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_Preventa != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_VENDEDOR_PREVENTA = new ThreadStart(Obtener_VendedorPreventa_Modelo_Obtener_Volcado);
|
|
Thread obj_Thread_VENDEDOR_PREVENTA = new Thread(obj_ThreadStart_VENDEDOR_PREVENTA);
|
|
obj_Thread_VENDEDOR_PREVENTA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[5] = true;
|
|
}
|
|
|
|
//MAE_Vendedores(AUTOVENTA) ##########################################################################################
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_Autoventa != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_VENDEDOR_AUTOVENTA = new ThreadStart(Obtener_VendedorAutoventa_Modelo_Obtener_Volcado);
|
|
Thread obj_Thread_VENDEDOR_AUTOVENTA = new Thread(obj_ThreadStart_VENDEDOR_AUTOVENTA);
|
|
obj_Thread_VENDEDOR_AUTOVENTA.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[6] = true;
|
|
}
|
|
|
|
//MAE_Vendedores(REPARTIDOR) ##########################################################################################
|
|
if (g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_Repartidor != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_VENDEDOR_REPARTIDOR = new ThreadStart(Obtener_VendedorRepartidor_Modelo_Obtener_Volcado);
|
|
Thread obj_Thread_VENDEDOR_REPARTIDOR = new Thread(obj_ThreadStart_VENDEDOR_REPARTIDOR);
|
|
obj_Thread_VENDEDOR_REPARTIDOR.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[7] = true;
|
|
}
|
|
|
|
|
|
//Esperando a que terminen todos los hilos .........................................
|
|
bool bol_Termino = false;
|
|
while (bol_Termino == false)
|
|
{
|
|
bol_Termino = true;
|
|
foreach (bool bol_Termino_Hilo in g_bol_Hilos_Terminados_Obtener_PARAVOLCADO)
|
|
{
|
|
if (bol_Termino_Hilo == false)
|
|
{
|
|
bol_Termino = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Thread.Sleep(10);
|
|
}
|
|
//.................................................................................
|
|
}
|
|
#endregion
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_Volcado), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo;
|
|
}
|
|
|
|
#region Tablas Relacionadas
|
|
private void Obtener_Cliente_Modelo_PARAVOLCADO()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAECLIENTES_OBTENERMODELO_POR_ID_AUX_1, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idCliente.Value, true, true, true, true, true, true };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.MAE_Clientes = (MAE_Clientes)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[0] = true;
|
|
}
|
|
}
|
|
private void Obtener_Socio_Modelo_PARAVOLCADO()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GESTIONTASAS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GESTIONTASAS + "." + Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS_PROCEDIMIENTO_GTTSOCIOS_OBTENERMODELO_POR_ID_AUX_1, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idSocio.Value, false, false, false, false };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.GTT_Socios = (GTT_Socios)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[1] = true;
|
|
}
|
|
}
|
|
private void Obtener_Delegacion_Modelo_PARAVOLCADO()
|
|
{
|
|
try
|
|
{
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.GEN_Delegaciones = Datos_Generales.GEN_Delegaciones_Obtener_Modelo_Por_Id(g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idDelegacion);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[2] = true;
|
|
}
|
|
}
|
|
private void Obtener_ImpuestoCabecera_Modelo_Obtener_Volcado()
|
|
{
|
|
try
|
|
{
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.GEN_ImpuestosCabecera = Datos_Generales.GEN_ImpuestosCabecera_Obtener_Modelo_Por_Id_Aux_1(g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idImpuestoCabecera.Value, true);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[3] = true;
|
|
}
|
|
}
|
|
private void Obtener_FacturasResumen_Modelo_Obtener_Volcado()
|
|
{
|
|
try
|
|
{
|
|
VTA_FacturasCabecera_Resumen_Datos obj_VTA_FacturasCabecera_Resumen_Datos = new VTA_FacturasCabecera_Resumen_Datos();
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.VTA_FacturasCabecera_Resumen = obj_VTA_FacturasCabecera_Resumen_Datos.Obtener_ModeloListado_Por_FacturaCabecera(g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.id);
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[4] = true;
|
|
}
|
|
}
|
|
private void Obtener_VendedorPreventa_Modelo_Obtener_Volcado()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEVENDEDORES_OBTENERMODELO_POR_ID_AUX_2, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_Preventa.Value, false, true };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.MAE_Vendedores = (MAE_Vendedores)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[5] = true;
|
|
}
|
|
}
|
|
private void Obtener_VendedorAutoventa_Modelo_Obtener_Volcado()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEVENDEDORES_OBTENERMODELO_POR_ID_AUX_2, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_Autoventa.Value, false, true };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.MAE_Vendedores5 = (MAE_Vendedores)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[6] = true;
|
|
}
|
|
}
|
|
private void Obtener_VendedorRepartidor_Modelo_Obtener_Volcado()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAEVENDEDORES_OBTENERMODELO_POR_ID_AUX_2, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.idVendedor_Repartidor.Value, false, true };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_INTERNO_VTA_FacturasCabecera_Volcado_Modelo.MAE_Vendedores2 = (MAE_Vendedores)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Obtener_PARAVOLCADO[7] = true;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
public List<long> Obtener_Socios_ConFacturas(string _str_Listado_Socios, DateTime _dtt_Fecha_InicioEjercicio)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
List<long> lst_idSocios_ConFacturas_Antiguas = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL = " SELECT " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null AND " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " < '" + _dtt_Fecha_InicioEjercicio.ToString("dd/MM/yyyy") + "' AND " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " IN (" + _str_Listado_Socios + ") " +
|
|
" GROUP BY " + nameof(VTA_FacturasCabecera.idSocio) +
|
|
" HAVING count(" + nameof(VTA_FacturasCabecera.idSocio) + ")>0 ";
|
|
|
|
lst_idSocios_ConFacturas_Antiguas = obj_Exferia_Entities.Database.SqlQuery<long>(str_SQL).ToList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_Socios_ConFacturas), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return lst_idSocios_ConFacturas_Antiguas;
|
|
}
|
|
public int Facturas_DelSocio(long _lng_idSocio, long _lng_idFactura_Actual, DateTime _dtt_Fecha_InicioEjercicio, DateTime _dtt_Fecha_FinEjercicio)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
int int_CantidadFacturas_Socio = 0;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL = " SELECT count(" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + ") " +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null AND " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " <> " + _lng_idFactura_Actual + " AND " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " < '" + _dtt_Fecha_InicioEjercicio.ToString("dd/MM/yyyy") + "' AND " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " = " + _lng_idSocio +
|
|
" GROUP BY " + nameof(VTA_FacturasCabecera.idSocio);
|
|
|
|
int? int_TotalFacturas = obj_Exferia_Entities.Database.SqlQuery<int>(str_SQL).FirstOrDefault();
|
|
|
|
if (int_TotalFacturas != null && int_TotalFacturas.Value > 0)
|
|
{
|
|
int_CantidadFacturas_Socio = int_TotalFacturas.Value;
|
|
}
|
|
else
|
|
{
|
|
//Bolsa de Clientes .........................................................................................................
|
|
//Cargamos el ensamblado #########################################################################################################################################################################
|
|
Assembly m_assembly_1 = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GESTIONTASAS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type_1 = m_assembly_1.GetType("" + Variables.G_STR_LIBRERIA_GESTIONTASAS + "." + Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS);
|
|
//creamos la instancia
|
|
var obj_Clase_1 = Activator.CreateInstance(m_type_1);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo_1 = obj_Clase_1.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS_PROCEDIMIENTO_GTTSOCIOS_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros_1 = { _lng_idSocio };
|
|
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
GTT_Socios mdl_GTT_Socios = (GTT_Socios)obj_MethodInfo_1.Invoke(obj_Clase_1, arr_Parametros_1);
|
|
//##################################################################################################################################################################################################
|
|
|
|
//Comprobar si la fecha de alta es del ejercicio Actual, sino se pone permanencia
|
|
if (mdl_GTT_Socios != null &&
|
|
_dtt_Fecha_InicioEjercicio <= mdl_GTT_Socios.fechaAlta &&
|
|
_dtt_Fecha_FinEjercicio >= mdl_GTT_Socios.fechaAlta)
|
|
{
|
|
int_CantidadFacturas_Socio = 0;
|
|
}
|
|
else
|
|
{
|
|
int_CantidadFacturas_Socio = 1;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Facturas_DelSocio), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return int_CantidadFacturas_Socio;
|
|
}
|
|
|
|
public List<INTERNO_GeneracionAutomatica_Modelo> Obtener_Facturas_ParaRemesas(string _str_Opcion,
|
|
long _lng_idEmpresa,
|
|
List<VTA_RemesasCabecera_TipoCapturaDocumento> _lst_VTA_RemesasCabecera_TipoCapturaDocumento,
|
|
bool _bol_UtilizarBolsa,
|
|
bool _bol_Sancion,
|
|
bool _bol_GeneraRemesa)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
List<INTERNO_GeneracionAutomatica_Modelo> lst_INTERNO_GeneracionAutomatica_Modelo = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_Listado_Clientes = "";
|
|
string str_Listado_Socios = "";
|
|
|
|
//Consultar las Bolsas Si Hiciera Falta ......................................
|
|
if (_bol_UtilizarBolsa)
|
|
{
|
|
if (_str_Opcion.Equals(Variables.G_STR_OPCION_VTA_REMESASCABECERA))
|
|
{
|
|
|
|
//Bolsa de Clientes .........................................................................................................
|
|
//Cargamos el ensamblado #########################################################################################################################################################################
|
|
Assembly m_assembly_1 = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type_1 = m_assembly_1.GetType("" + Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase_1 = Activator.CreateInstance(m_type_1);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo_1 = obj_Clase_1.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAECLIENTESBOLSA_OBTENERLISTADO_IDS_POR_USUARIO, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros_1 = { Variables.G_MDL_USUARIOVALIDADO_MODELO.id };
|
|
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
List<long> lst_MAE_Clientes_Bolsa = (List<long>)obj_MethodInfo_1.Invoke(obj_Clase_1, arr_Parametros_1);
|
|
//##################################################################################################################################################################################################
|
|
|
|
if (lst_MAE_Clientes_Bolsa != null && lst_MAE_Clientes_Bolsa.Count > 0)
|
|
{
|
|
str_Listado_Clientes = Funciones.Formar_ContenidoIN_ParaConsultaWhere(lst_MAE_Clientes_Bolsa);
|
|
}
|
|
}
|
|
else if (_str_Opcion.Equals(Variables.G_STR_OPCION_VTA_REMESASCABECERA_AUX_1))
|
|
{
|
|
//Bolsa de Socios .........................................................................................................
|
|
//Cargamos el ensamblado #########################################################################################################################################################################
|
|
Assembly m_assembly_2 = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GESTIONTASAS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type_2 = m_assembly_2.GetType("" + Variables.G_STR_LIBRERIA_GESTIONTASAS + "." + Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS);
|
|
//creamos la instancia
|
|
var obj_Clase_2 = Activator.CreateInstance(m_type_2);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo_2 = obj_Clase_2.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS_PROCEDIMIENTO_GTTSOCIOSBOLSA_OBTENERLISTADO_POR_USUARIO, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros_2 = { Variables.G_MDL_USUARIOVALIDADO_MODELO.id };
|
|
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
List<long> lst_GTT_Socios_Bolsa = (List<long>)obj_MethodInfo_2.Invoke(obj_Clase_2, arr_Parametros_2);
|
|
//##################################################################################################################################################################################################
|
|
|
|
if (lst_GTT_Socios_Bolsa != null && lst_GTT_Socios_Bolsa.Count > 0)
|
|
{
|
|
str_Listado_Socios = Funciones.Formar_ContenidoIN_ParaConsultaWhere(lst_GTT_Socios_Bolsa);
|
|
}
|
|
}
|
|
}
|
|
|
|
long lng_Documento_Inicio = 0;
|
|
long lng_Documento_Fin = 0;
|
|
|
|
//.....................................................
|
|
List<INTERNO_GeneracionAutomatica_Modelo> lst_INTERNO_GeneracionAutomatica_Modelo_Auxiliar = new List<INTERNO_GeneracionAutomatica_Modelo>();
|
|
List<INTERNA_SQLQUERY_COBROS> lst_INTERNA_SQLQUERY_COBROS = new List<INTERNA_SQLQUERY_COBROS>();
|
|
List<INTERNA_SQLQUERY_DEVOLUCIONESCOBROS> lst_INTERNA_SQLQUERY_DEVOLUCIONESCOBROS = new List<INTERNA_SQLQUERY_DEVOLUCIONESCOBROS>();
|
|
List<INTERNO_CuentasBancarias_Modelo> lst_INTERNO_CuentasBancarias_Modelo = new List<INTERNO_CuentasBancarias_Modelo>();
|
|
|
|
//Listado de CuentasBancarias
|
|
//Cargamos el ensamblado #########################################################################################################################################################################
|
|
Assembly m_assembly_3 = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type_3 = m_assembly_3.GetType("" + Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase_3 = Activator.CreateInstance(m_type_3);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo_3 = obj_Clase_3.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAECUENTASBANCARIASSEPACOBROS_OBTENERLISTADO_RELACIONREMESASLINEAS, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros_3 = { str_Listado_Socios, str_Listado_Clientes };
|
|
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
lst_INTERNO_CuentasBancarias_Modelo = (List<INTERNO_CuentasBancarias_Modelo>)obj_MethodInfo_3.Invoke(obj_Clase_3, arr_Parametros_3);
|
|
//##################################################################################################################################################################################################
|
|
|
|
string str_Where = "";
|
|
foreach (VTA_RemesasCabecera_TipoCapturaDocumento mdl_VTA_RemesasCabecera_TipoCapturaDocumento in _lst_VTA_RemesasCabecera_TipoCapturaDocumento)
|
|
{
|
|
str_Where = (_bol_GeneraRemesa ? (nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.generaRemesa) + " = 1 and ") : "") +
|
|
nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.fechaBorrado) + " is null and " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " >= '" + mdl_VTA_RemesasCabecera_TipoCapturaDocumento.fechaInicio.ToString() + "' and " +
|
|
nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + " = " + mdl_VTA_RemesasCabecera_TipoCapturaDocumento.idDelegacion + " and " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " <= '" + mdl_VTA_RemesasCabecera_TipoCapturaDocumento.fechaFinal.ToString() + "' and " +
|
|
nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.estado) + " != '" + Variables.G_STR_ESTADO_CONTABILIDAD_ABIERTO + "' " +
|
|
(_bol_Sancion ? (" and " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.sancion) + " = 1 ") : " and (" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.sancion) + " IS NULL or " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.sancion) + " = 0) ") +
|
|
//Documento Inicial
|
|
(lng_Documento_Inicio > 0 ? (" and " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + " >= " + lng_Documento_Inicio) : " ") +
|
|
//Documento Inicial
|
|
(lng_Documento_Fin > 0 ? (" and " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "<= " + lng_Documento_Fin) : " ") +
|
|
(str_Listado_Clientes.Trim().Length > 0 ? (" and " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " IN (" + str_Listado_Clientes + ")") : "") +
|
|
(str_Listado_Socios.Trim().Length > 0 ? (" and " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " IN (" + str_Listado_Socios + ")") : "");
|
|
|
|
|
|
//VENCIMIENTOS ######################################################################################################################################################################################################
|
|
string str_SQL_Vencimientos = " SELECT " + nameof(INTERNO_GeneracionAutomatica_Modelo.id) + " = " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.id) + ", " +
|
|
nameof(INTERNO_GeneracionAutomatica_Modelo.idCliente) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + ", " +
|
|
nameof(INTERNO_GeneracionAutomatica_Modelo.idSocio) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + ", " +
|
|
nameof(INTERNO_GeneracionAutomatica_Modelo.idVendedor) + " = " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.idVendedor) + ", " +
|
|
nameof(INTERNO_GeneracionAutomatica_Modelo.Importe) + " = " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.importe) + ", " +
|
|
nameof(INTERNO_GeneracionAutomatica_Modelo.Factura_Fecha) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + ", " +
|
|
nameof(INTERNO_GeneracionAutomatica_Modelo.Factura_Numero) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + ", " +
|
|
nameof(INTERNO_GeneracionAutomatica_Modelo.Delegacion_Codigo) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + ", " +
|
|
nameof(INTERNO_GeneracionAutomatica_Modelo.Vencimiento_Codigo) + " = " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.codigo) + " " +
|
|
" FROM " + nameof(VTA_Vencimientos) +
|
|
" INNER JOIN " + nameof(VTA_FacturasCabecera) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " = " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.idFacturaCabecera) + " and " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" INNER JOIN " + nameof(MAE_FormasPago) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idFormaPago) + " = " + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.id) +
|
|
" WHERE " + str_Where;
|
|
//Listado de Vencimientos
|
|
lst_INTERNO_GeneracionAutomatica_Modelo_Auxiliar = obj_Exferia_Entities.Database.SqlQuery<INTERNO_GeneracionAutomatica_Modelo>(str_SQL_Vencimientos).ToList();
|
|
|
|
if (lst_INTERNO_GeneracionAutomatica_Modelo_Auxiliar != null && lst_INTERNO_GeneracionAutomatica_Modelo_Auxiliar.Count > 0)
|
|
{
|
|
//COBROS ######################################################################################################################################################################################################
|
|
string str_SQL_Cobros = " SELECT " + nameof(INTERNA_SQLQUERY_COBROS.id) + " = " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.id) + ", " +
|
|
nameof(INTERNA_SQLQUERY_COBROS.idVencimiento) + " = " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.idVencimiento) + ", " +
|
|
nameof(INTERNA_SQLQUERY_COBROS.importe) + " = " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.importe) + ", " +
|
|
nameof(INTERNA_SQLQUERY_COBROS.codigo) + " = " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.codigo) + " " +
|
|
" FROM " + nameof(VTA_Cobros) +
|
|
" INNER JOIN " + nameof(VTA_Vencimientos) + " on " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.idVencimiento) + " = " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.id) + " and " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(VTA_FacturasCabecera) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " = " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.idFacturaCabecera) + " and " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" INNER JOIN " + nameof(MAE_FormasPago) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idFormaPago) + " = " + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.id) +
|
|
" WHERE " +
|
|
nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.fechaBorrado) + " is null and " +
|
|
str_Where;
|
|
//Listado de Cobros
|
|
lst_INTERNA_SQLQUERY_COBROS = obj_Exferia_Entities.Database.SqlQuery<INTERNA_SQLQUERY_COBROS>(str_SQL_Cobros).ToList();
|
|
|
|
if (lst_INTERNA_SQLQUERY_COBROS != null && lst_INTERNA_SQLQUERY_COBROS.Count > 0)
|
|
{
|
|
//DEVOLUCIONESCOBROS ######################################################################################################################################################################################################
|
|
string str_SQL_DevolucionesCobros = " SELECT " + nameof(INTERNA_SQLQUERY_DEVOLUCIONESCOBROS.id) + " = " + nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.id) + ", " +
|
|
nameof(INTERNA_SQLQUERY_DEVOLUCIONESCOBROS.idVencimiento) + " = " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.id) + ", " +
|
|
nameof(INTERNA_SQLQUERY_DEVOLUCIONESCOBROS.importe) + " = " + nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.importe) + " " +
|
|
" FROM " + nameof(VTA_DevolucionesCobros) +
|
|
" INNER JOIN " + nameof(VTA_Cobros) + " on " + nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.idCobro) + " = " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.id) + " and " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(VTA_Vencimientos) + " on " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.idVencimiento) + " = " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.id) + " and " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(VTA_FacturasCabecera) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " = " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.idFacturaCabecera) + " and " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" INNER JOIN " + nameof(MAE_FormasPago) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idFormaPago) + " = " + nameof(MAE_FormasPago) + "." + nameof(MAE_FormasPago.id) +
|
|
" WHERE " +
|
|
nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.fechaBorrado) + " is null and " +
|
|
str_Where;
|
|
//Listado de Devoluciones
|
|
lst_INTERNA_SQLQUERY_DEVOLUCIONESCOBROS = obj_Exferia_Entities.Database.SqlQuery<INTERNA_SQLQUERY_DEVOLUCIONESCOBROS>(str_SQL_DevolucionesCobros).ToList();
|
|
}
|
|
|
|
|
|
lst_INTERNO_GeneracionAutomatica_Modelo_Auxiliar.ForEach(m =>
|
|
{
|
|
m.Importe_Cobros = lst_INTERNA_SQLQUERY_COBROS.Where(x => x.idVencimiento.Equals(m.id)).Sum(t => t.importe);
|
|
m.Importe_Devoluciones = lst_INTERNA_SQLQUERY_DEVOLUCIONESCOBROS.Where(x => x.idVencimiento.Equals(m.id)).Sum(t => t.importe);
|
|
m.Cobros_UltimoCodigo = lst_INTERNA_SQLQUERY_COBROS.Where(x => x.idVencimiento.Equals(m.id)).Select(x => x.codigo).OrderByDescending(t => t).FirstOrDefault();
|
|
if (lst_INTERNO_CuentasBancarias_Modelo != null && lst_INTERNO_CuentasBancarias_Modelo.Count > 0)
|
|
{
|
|
m.CuentasBancariasSEPA_Cobros = lst_INTERNO_CuentasBancarias_Modelo.Where(x => x.porDefecto != null &&
|
|
x.porDefecto.Value &&
|
|
(m.idSocio != null
|
|
? (x.idSocio != null && x.idSocio.Value.Equals(m.idSocio))
|
|
: (m.idCliente != null
|
|
? (x.idCliente != null && x.idCliente.Value.Equals(m.idCliente))
|
|
: 1 != 1
|
|
)
|
|
)
|
|
).FirstOrDefault();
|
|
}
|
|
});
|
|
|
|
|
|
//Instancio si esta a nulo
|
|
if (lst_INTERNO_GeneracionAutomatica_Modelo == null)
|
|
{
|
|
lst_INTERNO_GeneracionAutomatica_Modelo = new List<INTERNO_GeneracionAutomatica_Modelo>();
|
|
}
|
|
|
|
//Añado al Final
|
|
lst_INTERNO_GeneracionAutomatica_Modelo.AddRange(lst_INTERNO_GeneracionAutomatica_Modelo_Auxiliar);
|
|
}
|
|
|
|
//Quitar los que sean iguales
|
|
if (lst_INTERNO_GeneracionAutomatica_Modelo != null)
|
|
{
|
|
lst_INTERNO_GeneracionAutomatica_Modelo = lst_INTERNO_GeneracionAutomatica_Modelo.Distinct().ToList();
|
|
}
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_Facturas_ParaRemesas), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return lst_INTERNO_GeneracionAutomatica_Modelo;
|
|
}
|
|
|
|
|
|
public List<INTERNO_Listado_Simple_Modelo> Buscar_Datos_Filtros_Relacionados(string _str_Where)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
List<INTERNO_Listado_Simple_Modelo> lst_INTERNO_Listado_Simple_Modelo = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
if (_str_Where.Trim().Length > 0)
|
|
{
|
|
_str_Where = " WHERE " + _str_Where;
|
|
}
|
|
|
|
//Formar Consulta SQLServer ....................................................
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " as " + nameof(INTERNO_Listado_Simple_Modelo.ID) + "," +
|
|
" (convert(varchar(12), " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + ") + '/' + " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + ") as " + nameof(INTERNO_Listado_Simple_Modelo.CODIGO) + "," +
|
|
" convert(varchar(10)," + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + ",103) as " + nameof(INTERNO_Listado_Simple_Modelo.DESCRIPCION) + "," +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " as " + nameof(INTERNO_Listado_Simple_Modelo.FECHABORRADO) + "," +
|
|
"( '(' + " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.codigo) + " + ') ' + " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.razonSocial) + ") as " + nameof(INTERNO_Listado_Simple_Modelo.AUXILIAR_1) + " " +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + " " +
|
|
" INNER JOIN " + nameof(MAE_Clientes) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.id) + " "
|
|
+ _str_Where;
|
|
|
|
//Ejecutar Consulta
|
|
lst_INTERNO_Listado_Simple_Modelo = obj_Exferia_Entities.Database.SqlQuery<INTERNO_Listado_Simple_Modelo>(str_SQL).ToList();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Buscar_Datos_Filtros_Relacionados), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return lst_INTERNO_Listado_Simple_Modelo;
|
|
}
|
|
|
|
|
|
#region Para CTU_Cartera_Ventas
|
|
|
|
public List<INTERNO_CTU_Cartera_Ventas_Modelo> CTU_Cartera_Ventas_Obtener_Por_Cliente(long _lng_idCliente, long _lng_idEmpresa)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
List<INTERNO_CTU_Cartera_Ventas_Modelo> lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final = new List<INTERNO_CTU_Cartera_Ventas_Modelo>();
|
|
List<INTERNO_CTU_Cartera_Ventas_Modelo> lst_INTERNO_CTU_Cartera_Ventas_Modelo = new List<INTERNO_CTU_Cartera_Ventas_Modelo>();
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
if (_lng_idCliente > -1)
|
|
{
|
|
|
|
string str_SQL_Resumen_Facturas = CTU_Cartera_Ventas_Consulta()
|
|
//WHERE FACTURAS
|
|
.Replace("XXXXXXXX_1", nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " =@idCliente ")
|
|
//WHERE ALBARANES
|
|
.Replace("XXXXXXXX_2", nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.idCliente) + " =@idCliente ")
|
|
//WHERE COBROSALBARANES
|
|
.Replace("XXXXXXXX_3", nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.idCliente) + " =@idCliente ")
|
|
//WHERE VENCIMIENTOS
|
|
.Replace("XXXXXXXX_4", nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " =@idCliente ")
|
|
//WHERE COBROS
|
|
.Replace("XXXXXXXX_5", nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " =@idCliente ")
|
|
//WHERE DEVOLUCIONES
|
|
.Replace("XXXXXXXX_6", nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " =@idCliente ");
|
|
|
|
//Parametros
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@idCliente", _lng_idCliente)
|
|
};
|
|
|
|
lst_INTERNO_CTU_Cartera_Ventas_Modelo = obj_Exferia_Entities.Database.SqlQuery<INTERNO_CTU_Cartera_Ventas_Modelo>(str_SQL_Resumen_Facturas, arr_Parametros).ToList();
|
|
}
|
|
|
|
//Añadir Ejercicios y Saldos
|
|
lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final = CTU_Cartera_Ventas_Rellenar_EjerciciosSaldos(lst_INTERNO_CTU_Cartera_Ventas_Modelo, _lng_idEmpresa);
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(CTU_Cartera_Ventas_Obtener_Por_Cliente), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final;
|
|
}
|
|
|
|
public List<INTERNO_CTU_Cartera_Ventas_Modelo> CTU_Cartera_Ventas_Obtener_Por_FacturaCabeceraVenta(long _lng_idFacturaCabeceraVenta, long _lng_idEmpresa)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
List<INTERNO_CTU_Cartera_Ventas_Modelo> lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final = new List<INTERNO_CTU_Cartera_Ventas_Modelo>();
|
|
List<INTERNO_CTU_Cartera_Ventas_Modelo> lst_INTERNO_CTU_Cartera_Ventas_Modelo = new List<INTERNO_CTU_Cartera_Ventas_Modelo>();
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
if (_lng_idFacturaCabeceraVenta > -1)
|
|
{
|
|
|
|
string str_SQL_Resumen_Facturas = CTU_Cartera_Ventas_Consulta()
|
|
//WHERE FACTURAS
|
|
.Replace("XXXXXXXX_1", nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " =@idFacturaCabecera ")
|
|
//WHERE ALBARANES
|
|
.Replace("XXXXXXXX_2", nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.idFacturaCabecera) + " =@idFacturaCabecera ")
|
|
//WHERE COBROSALBARANES
|
|
.Replace("XXXXXXXX_3", nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.idFacturaCabecera) + " =@idFacturaCabecera ")
|
|
//WHERE VENCIMIENTOS
|
|
.Replace("XXXXXXXX_4", nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " =@idFacturaCabecera ")
|
|
//WHERE COBROS
|
|
.Replace("XXXXXXXX_5", nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " =@idFacturaCabecera ")
|
|
//WHERE DEVOLUCIONES
|
|
.Replace("XXXXXXXX_6", nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " =@idFacturaCabecera ");
|
|
|
|
//Parametros
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@idFacturaCabecera", _lng_idFacturaCabeceraVenta)
|
|
};
|
|
|
|
lst_INTERNO_CTU_Cartera_Ventas_Modelo = obj_Exferia_Entities.Database.SqlQuery<INTERNO_CTU_Cartera_Ventas_Modelo>(str_SQL_Resumen_Facturas, arr_Parametros).ToList();
|
|
}
|
|
|
|
//Añadir Ejercicios y Saldos
|
|
lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final = CTU_Cartera_Ventas_Rellenar_EjerciciosSaldos(lst_INTERNO_CTU_Cartera_Ventas_Modelo, _lng_idEmpresa);
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(CTU_Cartera_Ventas_Obtener_Por_FacturaCabeceraVenta), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final;
|
|
}
|
|
|
|
public List<INTERNO_CTU_Cartera_Ventas_Modelo> CTU_Cartera_Ventas_Obtener_Por_AlbaranCabeceraVenta(long _lng_idAlbaranCabeceraVenta, long _lng_idEmpresa)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
List<INTERNO_CTU_Cartera_Ventas_Modelo> lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final = new List<INTERNO_CTU_Cartera_Ventas_Modelo>();
|
|
List<INTERNO_CTU_Cartera_Ventas_Modelo> lst_INTERNO_CTU_Cartera_Ventas_Modelo = new List<INTERNO_CTU_Cartera_Ventas_Modelo>();
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
if (_lng_idAlbaranCabeceraVenta > -1)
|
|
{
|
|
//Ver si tiene idFacturaCabecera
|
|
VTA_AlbaranesCabecera_Datos obj_VTA_AlbaranesCabecera_Datos = new VTA_AlbaranesCabecera_Datos();
|
|
long lng_idFacturaCabecera = obj_VTA_AlbaranesCabecera_Datos.Obtener_IdFacturaCabecera(_lng_idAlbaranCabeceraVenta);
|
|
|
|
if (lng_idFacturaCabecera == -1)
|
|
{
|
|
string str_SQL_Resumen_Albaran = CTU_Cartera_Ventas_Consulta_Albaran()
|
|
//WHERE ALABRAN
|
|
.Replace("XXXXXXXX_1", nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.id) + " = @idAlbaranCabecera ")
|
|
//WHERE COBROALBARAN
|
|
.Replace("XXXXXXXX_2", nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.idAlbaranCabecera) + " =@idAlbaranCabecera ");
|
|
|
|
//Parametros
|
|
object[] arr_Parametros_Albaran = new object[]
|
|
{
|
|
new SqlParameter("@idAlbaranCabecera", _lng_idAlbaranCabeceraVenta)
|
|
};
|
|
|
|
lst_INTERNO_CTU_Cartera_Ventas_Modelo = obj_Exferia_Entities.Database.SqlQuery<INTERNO_CTU_Cartera_Ventas_Modelo>(str_SQL_Resumen_Albaran, arr_Parametros_Albaran).ToList();
|
|
|
|
//Añadir Ejercicios y Saldos
|
|
lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final = CTU_Cartera_Ventas_Rellenar_EjerciciosSaldos(lst_INTERNO_CTU_Cartera_Ventas_Modelo, _lng_idEmpresa);
|
|
}
|
|
else
|
|
{
|
|
lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final = CTU_Cartera_Ventas_Obtener_Por_FacturaCabeceraVenta(lng_idFacturaCabecera, _lng_idEmpresa);
|
|
}
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(CTU_Cartera_Ventas_Obtener_Por_AlbaranCabeceraVenta), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final;
|
|
}
|
|
|
|
private List<INTERNO_CTU_Cartera_Ventas_Modelo> CTU_Cartera_Ventas_Rellenar_EjerciciosSaldos(List<INTERNO_CTU_Cartera_Ventas_Modelo> _lst_INTERNO_CTU_Cartera_Ventas_Modelo, long _lng_idEmpresa)
|
|
{
|
|
List<INTERNO_CTU_Cartera_Ventas_Modelo> lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final = new List<INTERNO_CTU_Cartera_Ventas_Modelo>();
|
|
|
|
//Añadirle los ejercicios y saldos
|
|
if (_lst_INTERNO_CTU_Cartera_Ventas_Modelo != null && _lst_INTERNO_CTU_Cartera_Ventas_Modelo.Count > 0)
|
|
{
|
|
//obtener el listado de Ejercicios
|
|
List<GEN_EjerciciosActivos_Empresa> lst_GEN_EjerciciosActivos_Empresa = Datos_Generales.GEN_EjerciciosActivos_Empresa_Obtener_Listado_Por_Empresa(_lng_idEmpresa);
|
|
|
|
//Rellenar el Listado
|
|
bool bol_Add_regsitro = true;
|
|
foreach (INTERNO_CTU_Cartera_Ventas_Modelo mdl_INTERNO_CTU_Cartera_Ventas_Modelo in _lst_INTERNO_CTU_Cartera_Ventas_Modelo)
|
|
{
|
|
bol_Add_regsitro = true;
|
|
|
|
//SALDO ##############################################
|
|
//Si es una factura
|
|
if (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_FACTURA.Codigo)
|
|
{
|
|
//Sumar todos los albranes de la factura
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe = _lst_INTERNO_CTU_Cartera_Ventas_Modelo.Where(m => m.Factura_Id.Equals(mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) && m.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_ALBARAN.Codigo && m.Albaran_Importe != null).Sum(m => m.Cobro_Importe);
|
|
if (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe == 0m)
|
|
{
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe = null;
|
|
}
|
|
|
|
//Sumar todos los vencimientos de la factura
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe = _lst_INTERNO_CTU_Cartera_Ventas_Modelo.Where(m => m.Factura_Id.Equals(mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) && m.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_VENCIMIENTO.Codigo && m.Vencimiento_Importe != null).Sum(m => m.Vencimiento_Importe);
|
|
if (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe == 0m)
|
|
{
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe = null;
|
|
}
|
|
|
|
//Sumar todos los cobros de la factura
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe = _lst_INTERNO_CTU_Cartera_Ventas_Modelo.Where(m => m.Factura_Id.Equals(mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) && (m.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_COBRO.Codigo || m.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_COBROALBARAN.Codigo) && m.Cobro_Importe != null).Sum(m => m.Cobro_Importe);
|
|
if (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe == 0m)
|
|
{
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe = null;
|
|
}
|
|
|
|
//Sumar todos las devoluciones de la factura
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe = _lst_INTERNO_CTU_Cartera_Ventas_Modelo.Where(m => m.Factura_Id.Equals(mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) && m.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_DEVOLUCION.Codigo && m.Devolucion_Importe != null).Sum(m => m.Devolucion_Importe);
|
|
if (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe == 0m)
|
|
{
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe = null;
|
|
}
|
|
|
|
//Saldo
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Saldo = ((mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe != null ? mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe.Value : 0) - (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe != null ? mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe.Value : 0)) + (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe != null ? mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe.Value : 0);
|
|
|
|
}
|
|
//Si es un ALBARAN
|
|
else if (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_ALBARAN.Codigo)
|
|
{
|
|
//Sumar todos los cobros del albaran
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe = _lst_INTERNO_CTU_Cartera_Ventas_Modelo.Where(m => m.Factura_Id.Equals(mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) && m.Albaran_Id.Equals(mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) && m.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_COBROALBARAN.Codigo && m.Cobro_Importe != null).Sum(m => m.Cobro_Importe);
|
|
if (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe == 0m)
|
|
{
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe = null;
|
|
|
|
bol_Add_regsitro = false;
|
|
}
|
|
|
|
//Saldo
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Saldo = ((mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe != null ? mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe.Value : 0) - (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe != null ? mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe.Value : 0)) + (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe != null ? mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe.Value : 0);
|
|
|
|
}
|
|
//Si es un vencimiento
|
|
else if (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_VENCIMIENTO.Codigo)
|
|
{
|
|
//Sumar todos los cobros del vencimiento
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe = _lst_INTERNO_CTU_Cartera_Ventas_Modelo.Where(m => m.Vencimiento_Id.Equals(mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) && m.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_COBRO.Codigo && m.Cobro_Importe != null).Sum(m => m.Cobro_Importe);
|
|
if (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe == 0m)
|
|
{
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe = null;
|
|
}
|
|
|
|
//Sumar todos las devoluciones del vencimiento
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe = _lst_INTERNO_CTU_Cartera_Ventas_Modelo.Where(m => m.Vencimiento_Id.Equals(mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) && m.Documento_Tipo == Variables.G_MDL_TIPODOCUMENTOS_VENTA_DEVOLUCION.Codigo && m.Devolucion_Importe != null).Sum(m => m.Devolucion_Importe);
|
|
if (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe == 0m)
|
|
{
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe = null;
|
|
}
|
|
|
|
//Saldo
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Saldo = ((mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe != null ? mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe.Value : 0) - (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe != null ? mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe.Value : 0)) + (mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe != null ? mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe.Value : 0);
|
|
}
|
|
|
|
//EJERCICIO ############################################
|
|
if (lst_GEN_EjerciciosActivos_Empresa != null)
|
|
{
|
|
mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Ejercicios_Empresa = lst_GEN_EjerciciosActivos_Empresa.Where(m => m.temporadaFechaFin >= mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha &&
|
|
m.temporadaFechaInicio <= mdl_INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha)
|
|
.FirstOrDefault();
|
|
}
|
|
|
|
//Añadir al listado final
|
|
if (bol_Add_regsitro)
|
|
{
|
|
lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final.Add(mdl_INTERNO_CTU_Cartera_Ventas_Modelo);
|
|
}
|
|
}
|
|
}
|
|
|
|
return lst_INTERNO_CTU_Cartera_Ventas_Modelo_Final;
|
|
}
|
|
|
|
private string CTU_Cartera_Ventas_Consulta()
|
|
{
|
|
return " SELECT " +
|
|
// Delegacion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "," +
|
|
// Factura
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "," +
|
|
// Albaranes
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "," +
|
|
// Vencimiento
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "," +
|
|
// Cobro
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "," +
|
|
// Devolucion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "," +
|
|
//Remesa_Codigo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "," +
|
|
//Remesa_Importe
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "," +
|
|
//Documento_Tipo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "," +
|
|
//Documento_Estado
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) +
|
|
" FROM " +
|
|
" ( " +
|
|
//FACTURAS
|
|
" SELECT " +
|
|
// Delegacion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
// Factura
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_Final) + "," +
|
|
// Albaran
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "= null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "=null," +
|
|
// Vencimiento
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "= null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "=null," +
|
|
// Cobro
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "=null," +
|
|
// Devolucion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "=null," +
|
|
//Remesa_Codigo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "=null," +
|
|
//Remesa_Importe
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "=null," +
|
|
//Documento_Tipo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "='" + Variables.G_MDL_TIPODOCUMENTOS_VENTA_FACTURA.Codigo + "'," +
|
|
//Documento_Estado
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.estado) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null and " +
|
|
" XXXXXXXX_1 " +
|
|
" UNION ALL " +
|
|
//ALBARANES
|
|
" SELECT " +
|
|
// Delegacion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
// Factura
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_Final) + "," +
|
|
// Albaranes
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "= " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.numeroAlbaran) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.total) + "," +
|
|
// Vencimiento
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "= null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "=null," +
|
|
// Cobro
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "=null," +
|
|
// Devolucion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "=null," +
|
|
//Remesa_Codigo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "=null," +
|
|
//Remesa_Importe
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "=null," +
|
|
//Documento_Tipo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "='" + Variables.G_MDL_TIPODOCUMENTOS_VENTA_ALBARAN.Codigo + "'," +
|
|
//Documento_Estado
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.estado) +
|
|
" FROM " + nameof(VTA_AlbaranesCabecera) +
|
|
" INNER JOIN " + nameof(VTA_FacturasCabecera) + " ON " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.idFacturaCabecera) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " and " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.idDelegacion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" WHERE " +
|
|
nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.fechaBorrado) + " is null and " +
|
|
" XXXXXXXX_2 " +
|
|
" UNION ALL " +
|
|
//COBROSALBARANES
|
|
" SELECT " +
|
|
// Delegacion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
// Factura
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_Final) + "," +
|
|
// Albaranes
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "= " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.numeroAlbaran) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.total) + "," +
|
|
// Vencimiento
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "= null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "=null," +
|
|
// Cobro
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "=" + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "=" + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "=" + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "=" + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.importe) + "," +
|
|
// Devolucion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "=null," +
|
|
//Remesa_Codigo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "=null," +
|
|
//Remesa_Importe
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "=null," +
|
|
//Documento_Tipo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "='" + Variables.G_MDL_TIPODOCUMENTOS_VENTA_COBROALBARAN.Codigo + "'," +
|
|
//Documento_Estado
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) + "=" + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.estado) +
|
|
" FROM " + nameof(VTA_CobrosAlbaranes) +
|
|
" INNER JOIN " + nameof(VTA_AlbaranesCabecera) + " ON " + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.idAlbaranCabecera) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.id) + " and " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(VTA_FacturasCabecera) + " ON " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.idFacturaCabecera) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " and " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.idDelegacion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" WHERE " +
|
|
nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.fechaBorrado) + " is null and " +
|
|
" XXXXXXXX_3 " +
|
|
" UNION ALL " +
|
|
//VENCIMIENTOS
|
|
" SELECT " +
|
|
// Delegacion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
// Factura
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "=null," +
|
|
// Albaran
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "= null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "=null," +
|
|
// Vencimiento
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.fechaVencimiento) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.importe) + "," +
|
|
// Cobro
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "=null," +
|
|
// Devolucion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "=null," +
|
|
//Remesa_Codigo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "=null," +
|
|
//Remesa_Importe
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "=null," +
|
|
//Documento_Tipo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "='" + Variables.G_MDL_TIPODOCUMENTOS_VENTA_VENCIMIENTO.Codigo + "'," +
|
|
//Documento_Estado
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.estado) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" INNER JOIN " + nameof(VTA_Vencimientos) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.idFacturaCabecera) + " and " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.fechaBorrado) + " is null " +
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null and " +
|
|
" XXXXXXXX_4 " +
|
|
" UNION ALL " +
|
|
//COBROS
|
|
" SELECT " +
|
|
// Delegacion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
// Factura
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "=null," +
|
|
// Albaran
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "= null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "=null," +
|
|
// Vencimiento
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.fechaVencimiento) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "=null," +
|
|
// Cobro
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.importe) + "," +
|
|
// Devolucion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "=null," +
|
|
//Remesa_Codigo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "=" + nameof(VTA_RemesasCabecera) + "." + nameof(VTA_RemesasCabecera.codigo) + "," +
|
|
//Remesa_Importe
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "=" + nameof(VTA_RemesasCabecera) + "." + nameof(VTA_RemesasCabecera.importe) + "," +
|
|
//Documento_Tipo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "='" + Variables.G_MDL_TIPODOCUMENTOS_VENTA_COBRO.Codigo + "'," +
|
|
//Documento_Estado
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.estado) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" INNER JOIN " + nameof(VTA_Vencimientos) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.idFacturaCabecera) + " and " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(VTA_Cobros) + " ON " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.id) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.idVencimiento) + " and " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.fechaBorrado) + " is null " +
|
|
" LEFT JOIN " + nameof(VTA_RemesasLinea) + " ON " + nameof(VTA_RemesasLinea) + "." + nameof(VTA_RemesasLinea.id) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.idRemesaLinea) + " and " + nameof(VTA_RemesasLinea) + "." + nameof(VTA_RemesasLinea.fechaBorrado) + " is null " +
|
|
" LEFT JOIN " + nameof(VTA_RemesasCabecera) + " ON " + nameof(VTA_RemesasCabecera) + "." + nameof(VTA_RemesasCabecera.id) + "=" + nameof(VTA_RemesasLinea) + "." + nameof(VTA_RemesasLinea.idRemesaCabecera) + " and " + nameof(VTA_RemesasCabecera) + "." + nameof(VTA_RemesasCabecera.fechaBorrado) + " is null " +
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null and " +
|
|
" XXXXXXXX_5 " +
|
|
" UNION ALL " +
|
|
//DEVOLUCIONES
|
|
" SELECT " +
|
|
// Delegacion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
// Factura
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "=" + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "=null," +
|
|
// Albaran
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "= null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "=null," +
|
|
// Vencimiento
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.fechaVencimiento) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "=null," +
|
|
// Cobro
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "=null," +
|
|
// Devolucion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "=" + nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "=" + nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "=" + nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "=" + nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.importe) + "," +
|
|
//Remesa_Codigo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "=null," +
|
|
//Remesa_Importe
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "=null," +
|
|
//Documento_Tipo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "='" + Variables.G_MDL_TIPODOCUMENTOS_VENTA_DEVOLUCION.Codigo + "'," +
|
|
//Documento_Estado
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) + "=" + nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.estado) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" INNER JOIN " + nameof(VTA_Vencimientos) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=" + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.idFacturaCabecera) + " and " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(VTA_Cobros) + " ON " + nameof(VTA_Vencimientos) + "." + nameof(VTA_Vencimientos.id) + "=" + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.idVencimiento) + " and " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(VTA_DevolucionesCobros) + " ON " + nameof(VTA_Cobros) + "." + nameof(VTA_Cobros.id) + "=" + nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.idCobro) + " and " + nameof(VTA_DevolucionesCobros) + "." + nameof(VTA_DevolucionesCobros.fechaBorrado) + " is null " +
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null and " +
|
|
" XXXXXXXX_6 " +
|
|
" ) AS P ";
|
|
}
|
|
private string CTU_Cartera_Ventas_Consulta_Albaran()
|
|
{
|
|
return " SELECT " +
|
|
// Delegacion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "," +
|
|
// Factura
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "," +
|
|
// Albaranes
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "," +
|
|
// Vencimiento
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "," +
|
|
// Cobro
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "," +
|
|
// Devolucion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "," +
|
|
//Remesa_Codigo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "," +
|
|
//Remesa_Importe
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "," +
|
|
//Documento_Tipo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "," +
|
|
//Documento_Estado
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) + "=" + "P." + nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) +
|
|
" FROM " +
|
|
" ( " +
|
|
//ALBARANES
|
|
" SELECT " +
|
|
// Delegacion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
// Factura
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "=convert(datetime,'01/01/2020')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "= null," +
|
|
// Albaranes
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "= " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.numeroAlbaran) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.total) + "," +
|
|
// Vencimiento
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "= null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "=null," +
|
|
// Cobro
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "=null," +
|
|
// Devolucion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "=null," +
|
|
//Remesa_Codigo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "=null," +
|
|
//Remesa_Importe
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "=null," +
|
|
//Documento_Tipo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "='" + Variables.G_MDL_TIPODOCUMENTOS_VENTA_ALBARAN.Codigo + "'," +
|
|
//Documento_Estado
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.estado) +
|
|
" FROM " + nameof(VTA_AlbaranesCabecera) +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.idDelegacion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" WHERE " +
|
|
nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.fechaBorrado) + " is null and " +
|
|
" XXXXXXXX_1 " +
|
|
" UNION ALL " +
|
|
//COBROSALBARANES
|
|
" SELECT " +
|
|
// Delegacion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Id) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Codigo) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Delegacion_Descripcion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
// Factura
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Numero) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Fecha) + "= convert(datetime,'01/01/2020')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Factura_Importe) + "= null," +
|
|
// Albaranes
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Id) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Numero) + "= " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.numeroAlbaran) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Fecha) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Albaran_Importe) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.total) + "," +
|
|
// Vencimiento
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Numero) + "= null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Vencimiento_Importe) + "=null," +
|
|
// Cobro
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Id) + "=" + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.id) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Numero) + "=" + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.codigo) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Fecha) + "=" + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.fecha) + "," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Cobro_Importe) + "=" + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.importe) + "," +
|
|
// Devolucion
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Id) + "=convert(bigint,'-1')," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Numero) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Fecha) + "=null," +
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Devolucion_Importe) + "=null," +
|
|
//Remesa_Codigo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Codigo) + "=null," +
|
|
//Remesa_Importe
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Remesa_Importe) + "=null," +
|
|
//Documento_Tipo
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Tipo) + "='" + Variables.G_MDL_TIPODOCUMENTOS_VENTA_COBROALBARAN.Codigo + "'," +
|
|
//Documento_Estado
|
|
nameof(INTERNO_CTU_Cartera_Ventas_Modelo.Documento_Estado) + "=" + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.estado) +
|
|
" FROM " + nameof(VTA_CobrosAlbaranes) +
|
|
" INNER JOIN " + nameof(VTA_AlbaranesCabecera) + " ON " + nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.idAlbaranCabecera) + "=" + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.id) + " and " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.fechaBorrado) + " is null " +
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_AlbaranesCabecera) + "." + nameof(VTA_AlbaranesCabecera.idDelegacion) + "=" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
" WHERE " +
|
|
nameof(VTA_CobrosAlbaranes) + "." + nameof(VTA_CobrosAlbaranes.fechaBorrado) + " is null and " +
|
|
" XXXXXXXX_2 " +
|
|
" ) AS P ";
|
|
}
|
|
|
|
#endregion
|
|
|
|
public string Obtener_Estado(long _lng_id)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
string str_Estado = "";
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.estado) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" WHERE " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " IS null AND " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=@id ";
|
|
|
|
//Parametros
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
|
|
//Rellenar el Modelo
|
|
str_Estado = obj_Exferia_Entities.Database.SqlQuery<string>(str_SQL, arr_Parametros).FirstOrDefault();
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_Estado), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return str_Estado;
|
|
}
|
|
|
|
public int? Obtener_SituacionPago(long _lng_id)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
int? int_Situacionpago = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.situacionPago) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" WHERE " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=@id ";
|
|
|
|
//Parametros
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
|
|
//Rellenar el Modelo
|
|
int_Situacionpago = obj_Exferia_Entities.Database.SqlQuery<int?>(str_SQL, arr_Parametros).FirstOrDefault();
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_SituacionPago), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return int_Situacionpago;
|
|
}
|
|
|
|
public decimal Obtener_Total(long _lng_id)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
decimal dcm_Total = 0m;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_Final) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
" WHERE " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=@id ";
|
|
|
|
//Parametros
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
|
|
//Rellenar el Modelo
|
|
dcm_Total = obj_Exferia_Entities.Database.SqlQuery<decimal>(str_SQL, arr_Parametros).FirstOrDefault();
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_Total), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return dcm_Total;
|
|
}
|
|
|
|
#region Obtener Para Resumen de Impuestos
|
|
public List<INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo> Obtener_ParaResumenImpuestos(DateTime _dtt_FechaDesde, DateTime _dtt_FechaHasta, long? _lng_idDelegacion, List<long> _lst_IdCliente)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
List<INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo> lst_INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo = null;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_Filtro_IDSCliente = "";
|
|
if (_lst_IdCliente != null && _lst_IdCliente.Count > 0)
|
|
{
|
|
|
|
str_Filtro_IDSCliente = Funciones.Formar_ContenidoIN_ParaConsultaWhere(nameof(VTA_FacturasCabecera),
|
|
nameof(VTA_FacturasCabecera.idCliente),
|
|
G_ENUM_FORMARCONTENIDOIN_CONDICIONANTES.AND_INICIO,
|
|
_lst_IdCliente);
|
|
}
|
|
|
|
string str_SQL =
|
|
" SELECT " +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.id) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.NumeroFactura) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Fecha) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.estado) + " = " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.estado) + "," +
|
|
//VTA_FacturasCabecera_Resumen
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.BaseImponible) + " = " + nameof(VTA_FacturasCabecera_Resumen) + "." + nameof(VTA_FacturasCabecera_Resumen.baseImponible) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Impuesto_Porcentaje) + " = " + nameof(VTA_FacturasCabecera_Resumen) + "." + nameof(VTA_FacturasCabecera_Resumen.impuesto_Porcentaje) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Impuesto_Valor) + " = " + nameof(VTA_FacturasCabecera_Resumen) + "." + nameof(VTA_FacturasCabecera_Resumen.impuesto_Valor) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Recargo_Porcentaje) + " = " + nameof(VTA_FacturasCabecera_Resumen) + "." + nameof(VTA_FacturasCabecera_Resumen.recargo_Porcentaje) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Recargo_Valor) + " = " + nameof(VTA_FacturasCabecera_Resumen) + "." + nameof(VTA_FacturasCabecera_Resumen.recargo_Valor) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.total) + " = " + nameof(VTA_FacturasCabecera_Resumen) + "." + nameof(VTA_FacturasCabecera_Resumen.total) + "," +
|
|
//GEN_ImpuestosTipos
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.ImpuestoTipo_Id) + " = " + nameof(GEN_ImpuestosTipos) + "." + nameof(GEN_ImpuestosTipos.id) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.ImpuestoTipo_Descripcion) + " = " + nameof(GEN_ImpuestosTipos) + "." + nameof(GEN_ImpuestosTipos.descripcion) + "," +
|
|
//MAE_Clientes
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Cliente_Id) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.id) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Cliente_Codigo) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.codigo) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Cliente_RazonSocial) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.razonSocial) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Cliente_CIF) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.cif) + "," +
|
|
//GEN_Delegaciones
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Delegacion_Id) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Delegacion_Codigo) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.codigo) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.Delegacion_Descripcion) + " =" + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.descripcion) + "," +
|
|
//GEN_ImpuestosCabecera
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.ImpuestoCabecera_Id) + " = " + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.id) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.ImpuestoCabecera_Codigo) + " = " + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.codigo) + "," +
|
|
nameof(INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo.ImpuestoCabecera_Descripcion) + " =" + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.descripcion) +
|
|
" FROM " + nameof(VTA_FacturasCabecera) +
|
|
//Cliente
|
|
" INNER JOIN " + nameof(MAE_Clientes) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " = " + nameof(MAE_Clientes) + "." + nameof(MAE_Clientes.id) +
|
|
//Delegacion
|
|
" INNER JOIN " + nameof(GEN_Delegaciones) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " = " + nameof(GEN_Delegaciones) + "." + nameof(GEN_Delegaciones.id) +
|
|
//ImpuestoCabecera
|
|
" INNER JOIN " + nameof(GEN_ImpuestosCabecera) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idImpuestoCabecera) + " = " + nameof(GEN_ImpuestosCabecera) + "." + nameof(GEN_ImpuestosCabecera.id) +
|
|
//FacturasCabecera_Resumen
|
|
" INNER JOIN " + nameof(VTA_FacturasCabecera_Resumen) + " ON " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " = " + nameof(VTA_FacturasCabecera_Resumen) + "." + nameof(VTA_FacturasCabecera_Resumen.idFacturaCabecera) +
|
|
//ImpuestosTipos
|
|
" INNER JOIN " + nameof(GEN_ImpuestosTipos) + " ON " + nameof(GEN_ImpuestosTipos) + "." + nameof(GEN_ImpuestosTipos.id) + " = " + nameof(VTA_FacturasCabecera_Resumen) + "." + nameof(VTA_FacturasCabecera_Resumen.idImpuestoTipo) +
|
|
" WHERE " +
|
|
//fechaBorrado
|
|
" ( " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null ) AND " +
|
|
//Fecha Desde
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + ">=@fechaDesde AND " +
|
|
//fecha hasta
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + "<=@fechaHasta AND " +
|
|
//baseImponible
|
|
nameof(VTA_FacturasCabecera_Resumen) + "." + nameof(VTA_FacturasCabecera_Resumen.baseImponible) + "<>0 AND " +
|
|
//Delegacion
|
|
(_lng_idDelegacion != null ? (nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + "=@idDelegacion ") : " 1=1 ") +
|
|
str_Filtro_IDSCliente;
|
|
|
|
//Parametros
|
|
List<SqlParameter> lst_SqlParameter = new List<SqlParameter>();
|
|
lst_SqlParameter.Add(new SqlParameter("@fechaDesde", _dtt_FechaDesde));
|
|
lst_SqlParameter.Add(new SqlParameter("@fechaHasta", _dtt_FechaHasta));
|
|
|
|
if (_lng_idDelegacion != null)
|
|
{
|
|
lst_SqlParameter.Add(new SqlParameter("@idDelegacion", _lng_idDelegacion.Value));
|
|
}
|
|
|
|
//Rellenar el Modelo
|
|
lst_INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo = obj_Exferia_Entities.Database.SqlQuery<INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo>(str_SQL, lst_SqlParameter.ToArray()).ToList();
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_ParaResumenImpuestos), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return lst_INTERNO_ResumenImpuestos_Repercutido_Listado_Modelo;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region MODELOS
|
|
|
|
#region Modelo Simple
|
|
private VTA_FacturasCabecera g_mdl_VTA_FacturasCabecera = null;
|
|
public VTA_FacturasCabecera Obtener_Modelo_Por_Id(long _lng_id,
|
|
bool _bol_Cargar_Clientes,
|
|
bool _bol_Cargar_Socios,
|
|
bool _bol_Cargar_Delegaciones,
|
|
bool _bol_Cargar_LiquidacionesTributarias)
|
|
{
|
|
try
|
|
{
|
|
string str_SQL = Obtener_Consulta_Modelo() +
|
|
//WHERE
|
|
" WHERE " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=@id";
|
|
|
|
//Parametros
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
|
|
//Ejecutar y rellenar el modelo
|
|
Ejecutar_Consulta_Modelo(str_SQL,
|
|
arr_Parametros,
|
|
_bol_Cargar_Clientes,
|
|
_bol_Cargar_Socios,
|
|
_bol_Cargar_Delegaciones,
|
|
_bol_Cargar_LiquidacionesTributarias);
|
|
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_Modelo_Por_Id), true);
|
|
}
|
|
|
|
return g_mdl_VTA_FacturasCabecera;
|
|
}
|
|
|
|
#region Ejecutar Consulta Modelo
|
|
private static int g_int_TotalHilos_Modelo = 4;
|
|
private bool[] g_bol_Hilos_Terminados_Modelo = new bool[g_int_TotalHilos_Modelo];
|
|
|
|
private void Ejecutar_Consulta_Modelo(string _str_SQL,
|
|
object[] _arr_Parametros,
|
|
bool _bol_Cargar_Clientes,
|
|
bool _bol_Cargar_Socios,
|
|
bool _bol_Cargar_Delegaciones,
|
|
bool _bol_Cargar_LiquidacionesTributarias)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
try
|
|
{
|
|
//Conexion
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
//Rellenar el Modelo
|
|
g_mdl_VTA_FacturasCabecera = obj_Exferia_Entities.Database.SqlQuery<VTA_FacturasCabecera>(_str_SQL, _arr_Parametros).FirstOrDefault();
|
|
|
|
#region Rellenar Tablas Relacionadas
|
|
if (g_mdl_VTA_FacturasCabecera != null)
|
|
{
|
|
//reiniciar Valores de los hilos
|
|
for (int int_Contador = 0; int_Contador < g_int_TotalHilos_Modelo; int_Contador++)
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo[int_Contador] = false;
|
|
}
|
|
|
|
//MAE_Clientes ##########################################################################################
|
|
if (_bol_Cargar_Clientes &&
|
|
g_mdl_VTA_FacturasCabecera.idCliente != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_CLIENTES = new ThreadStart(Obtener_Clientes_Modelo);
|
|
Thread obj_Thread_CLIENTES = new Thread(obj_ThreadStart_CLIENTES);
|
|
obj_Thread_CLIENTES.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo[0] = true;
|
|
}
|
|
|
|
//GTT_Socios ##########################################################################################
|
|
if (_bol_Cargar_Socios &&
|
|
g_mdl_VTA_FacturasCabecera.idSocio != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_SOCIOS = new ThreadStart(Obtener_Socios_Modelo);
|
|
Thread obj_Thread_SOCIOS = new Thread(obj_ThreadStart_SOCIOS);
|
|
obj_Thread_SOCIOS.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo[1] = true;
|
|
}
|
|
|
|
//GEN_Delegaciones ##########################################################################################
|
|
if (_bol_Cargar_Delegaciones)
|
|
{
|
|
ThreadStart obj_ThreadStart_DELEGACIONES = new ThreadStart(Obtener_Delegaciones_Modelo);
|
|
Thread obj_Thread_DELEGACIONES = new Thread(obj_ThreadStart_DELEGACIONES);
|
|
obj_Thread_DELEGACIONES.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo[2] = true;
|
|
}
|
|
|
|
//GTT_LiquidacionesTributarias ##########################################################################################
|
|
if (_bol_Cargar_LiquidacionesTributarias &&
|
|
g_mdl_VTA_FacturasCabecera.idLiquidacionTributaria != null)
|
|
{
|
|
ThreadStart obj_ThreadStart_LIQUIDACIONESTRIBUTARIAS = new ThreadStart(Obtener_LiquidacionesTributarias_Modelo);
|
|
Thread obj_Thread_LIQUIDACIONESTRIBUTARIAS = new Thread(obj_ThreadStart_LIQUIDACIONESTRIBUTARIAS);
|
|
obj_Thread_LIQUIDACIONESTRIBUTARIAS.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo[3] = true;
|
|
}
|
|
|
|
//Esperando a que terminen todos los hilos .........................................
|
|
bool bol_Termino = false;
|
|
while (bol_Termino == false)
|
|
{
|
|
bol_Termino = true;
|
|
foreach (bool bol_Termino_Hilo in g_bol_Hilos_Terminados_Modelo)
|
|
{
|
|
if (bol_Termino_Hilo == false)
|
|
{
|
|
bol_Termino = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Thread.Sleep(10);
|
|
}
|
|
//.................................................................................
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Ejecutar_Consulta_Modelo), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
}
|
|
|
|
#region Tablas Relacionadas
|
|
private void Obtener_Clientes_Modelo()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAECLIENTES_OBTENERMODELO_POR_ID_AUX_1, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_VTA_FacturasCabecera.idCliente.Value, true, true, true, true, true, true };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_VTA_FacturasCabecera.MAE_Clientes = (MAE_Clientes)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo[0] = true;
|
|
}
|
|
}
|
|
private void Obtener_Socios_Modelo()
|
|
{
|
|
try
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GESTIONTASAS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GESTIONTASAS + "." + Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS_PROCEDIMIENTO_GTTSOCIOS_OBTENERMODELO_POR_ID_AUX_1, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_VTA_FacturasCabecera.idSocio.Value, false, false, false, false };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_VTA_FacturasCabecera.GTT_Socios = (GTT_Socios)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo[1] = true;
|
|
}
|
|
}
|
|
private void Obtener_Delegaciones_Modelo()
|
|
{
|
|
try
|
|
{
|
|
g_mdl_VTA_FacturasCabecera.GEN_Delegaciones = Datos_Generales.GEN_Delegaciones_Obtener_Modelo_Por_Id(g_mdl_VTA_FacturasCabecera.idDelegacion);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo[2] = true;
|
|
}
|
|
}
|
|
private void Obtener_LiquidacionesTributarias_Modelo()
|
|
{
|
|
try
|
|
{
|
|
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GESTIONTASAS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GESTIONTASAS + "." + Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS_PROCEDIMIENTO_GTTLIQUIDACIONESTRIBUTARIAS_OBTENERMODELO_POR_ID, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { g_mdl_VTA_FacturasCabecera.idLiquidacionTributaria.Value };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_mdl_VTA_FacturasCabecera.GTT_LiquidacionesTributarias = (GTT_LiquidacionesTributarias)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo[3] = true;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Modelo Listado
|
|
private List<VTA_FacturasCabecera> g_lst_VTA_FacturasCabecera = null;
|
|
|
|
public List<VTA_FacturasCabecera> Obtener_ModeloListado_Por_FacturasLineas(List<long> _lst_idFacturaLinea)
|
|
{
|
|
try
|
|
{
|
|
|
|
string str_Filtro_FACTURASLINEAS = Funciones.Formar_ContenidoIN_ParaConsultaWhere(nameof(VTA_AlbaranesFacturasLineas),
|
|
nameof(VTA_AlbaranesFacturasLineas.id),
|
|
G_ENUM_FORMARCONTENIDOIN_CONDICIONANTES.NADA,
|
|
_lst_idFacturaLinea);
|
|
|
|
//Consulta
|
|
string str_SQL = Obtener_Consulta_Modelo() +
|
|
//INNER JOIN
|
|
" INNER JOIN " + nameof(VTA_AlbaranesFacturasLineas) + " on " + nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + "=" + nameof(VTA_AlbaranesFacturasLineas) + "." + nameof(VTA_AlbaranesFacturasLineas.idFacturaCabecera) +
|
|
//WHERE
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null and " +
|
|
"( not " + nameof(VTA_AlbaranesFacturasLineas) + "." + nameof(VTA_AlbaranesFacturasLineas.idAlbaranCabecera) + " is null ) and " +
|
|
str_Filtro_FACTURASLINEAS;
|
|
|
|
//Ejecutar y rellenar el listado
|
|
Ejecutar_Consulta_Modelo_Listado(str_SQL,
|
|
new object[] { },
|
|
true,
|
|
false,
|
|
false,
|
|
false);
|
|
|
|
if (g_lst_VTA_FacturasCabecera != null && g_lst_VTA_FacturasCabecera.Count > 0)
|
|
{
|
|
|
|
//Quitar las Cabeceras repetidas (no se puede hacer un distinct porque hay un campo tipo text)
|
|
List<VTA_FacturasCabecera> lst_VTA_FacturasCabecera = new List<VTA_FacturasCabecera>();
|
|
|
|
foreach (VTA_FacturasCabecera mdl_VTA_FacturasCabecera in g_lst_VTA_FacturasCabecera)
|
|
{
|
|
if (!lst_VTA_FacturasCabecera.Exists(m => m.id.Equals(mdl_VTA_FacturasCabecera.id)))
|
|
{
|
|
lst_VTA_FacturasCabecera.Add(mdl_VTA_FacturasCabecera);
|
|
}
|
|
}
|
|
|
|
g_lst_VTA_FacturasCabecera = lst_VTA_FacturasCabecera;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_ModeloListado_Por_FacturasLineas), true);
|
|
}
|
|
|
|
return g_lst_VTA_FacturasCabecera;
|
|
}
|
|
|
|
public List<VTA_FacturasCabecera> Obtener_ModeloListado_Por_Ids(List<long> _lst_ids,
|
|
bool _bol_Cargar_AlbaranesFacturasLineas,
|
|
bool _bol_Cargar_Clientes,
|
|
bool _bol_Cargar_Socios,
|
|
bool _bol_Cargar_Delegaciones)
|
|
{
|
|
try
|
|
{
|
|
|
|
string str_Filtro_FACTURAS = Funciones.Formar_ContenidoIN_ParaConsultaWhere(nameof(VTA_FacturasCabecera),
|
|
nameof(VTA_FacturasCabecera.id),
|
|
G_ENUM_FORMARCONTENIDOIN_CONDICIONANTES.NADA,
|
|
_lst_ids);
|
|
|
|
//Consulta
|
|
string str_SQL = Obtener_Consulta_Modelo() +
|
|
//WHERE
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " is null and " +
|
|
str_Filtro_FACTURAS;
|
|
|
|
//Ejecutar y rellenar el listado
|
|
Ejecutar_Consulta_Modelo_Listado(str_SQL,
|
|
new object[] { },
|
|
_bol_Cargar_AlbaranesFacturasLineas,
|
|
_bol_Cargar_Clientes,
|
|
_bol_Cargar_Socios,
|
|
_bol_Cargar_Delegaciones
|
|
);
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Obtener_ModeloListado_Por_Ids), true);
|
|
}
|
|
|
|
return g_lst_VTA_FacturasCabecera;
|
|
}
|
|
|
|
#region Ejecutar Consulta
|
|
|
|
//Listado de modelos Relacionados
|
|
private List<VTA_AlbaranesFacturasLineas> g_lst_VTA_AlbaranesFacturasLineas = null;
|
|
private List<MAE_Clientes> g_lst_MAE_Clientes = null;
|
|
private List<GTT_Socios> g_lst_GTT_Socios = null;
|
|
private List<GEN_Delegaciones> g_lst_GEN_Delegaciones = null;
|
|
|
|
//Hilos
|
|
private static int g_int_TotalHilos_Modelo_Listado = 4;
|
|
private bool[] g_bol_Hilos_Terminados_Modelo_Listado = new bool[g_int_TotalHilos_Modelo_Listado];
|
|
|
|
private void Ejecutar_Consulta_Modelo_Listado(string _str_SQL,
|
|
object[] _arr_Parametros,
|
|
bool _bol_Cargar_AlbaranesFacturasLineas,
|
|
bool _bol_Cargar_Clientes,
|
|
bool _bol_Cargar_Socios,
|
|
bool _bol_Cargar_Delegaciones)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
try
|
|
{
|
|
//Conexion
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
//Rellenar el modelo
|
|
g_lst_VTA_FacturasCabecera = obj_Exferia_Entities.Database.SqlQuery<VTA_FacturasCabecera>(_str_SQL, _arr_Parametros).ToList();
|
|
|
|
#region Rellenar tablas Relacionadas
|
|
if (g_lst_VTA_FacturasCabecera != null && g_lst_VTA_FacturasCabecera.Count > 0)
|
|
{
|
|
if (_bol_Cargar_AlbaranesFacturasLineas ||
|
|
_bol_Cargar_Clientes ||
|
|
_bol_Cargar_Socios ||
|
|
_bol_Cargar_Delegaciones)
|
|
{
|
|
#region PRIMERO BUSCO LOS DATOS DE LAS TABLAS RELACIONADAS
|
|
//reiniciar Valores de los hilos
|
|
for (int int_Contador = 0; int_Contador < g_int_TotalHilos_Modelo_Listado; int_Contador++)
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo_Listado[int_Contador] = false;
|
|
}
|
|
|
|
//VTA_AlbaranesFacturasLineas #############################################
|
|
if (_bol_Cargar_AlbaranesFacturasLineas)
|
|
{
|
|
ThreadStart obj_ThreadStart_ALBARANESFACTURASLINEAS = new ThreadStart(Obtener_AlbaranesFacturasLineas_Modelo_Listado);
|
|
Thread obj_Thread_ALBARANESFACTURASLINEAS = new Thread(obj_ThreadStart_ALBARANESFACTURASLINEAS);
|
|
obj_Thread_ALBARANESFACTURASLINEAS.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo_Listado[0] = true;
|
|
}
|
|
|
|
//MAE_Clientes #############################################
|
|
if (_bol_Cargar_Clientes)
|
|
{
|
|
ThreadStart obj_ThreadStart_CLIENTES = new ThreadStart(Obtener_Cliente_Modelo_Listado);
|
|
Thread obj_Thread_CLIENTES = new Thread(obj_ThreadStart_CLIENTES);
|
|
obj_Thread_CLIENTES.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo_Listado[1] = true;
|
|
}
|
|
|
|
//GTT_Socios #############################################
|
|
if (_bol_Cargar_Socios)
|
|
{
|
|
ThreadStart obj_ThreadStart_SOCIOS = new ThreadStart(Obtener_Socios_Modelo_Listado);
|
|
Thread obj_Thread_SOCIOS = new Thread(obj_ThreadStart_SOCIOS);
|
|
obj_Thread_SOCIOS.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo_Listado[2] = true;
|
|
}
|
|
|
|
//GEN_Delegaciones #############################################
|
|
if (_bol_Cargar_Delegaciones)
|
|
{
|
|
ThreadStart obj_ThreadStart_DELEGACIONES = new ThreadStart(Obtener_Delegaciones_Modelo_Listado);
|
|
Thread obj_Thread_DELEGACIONES = new Thread(obj_ThreadStart_DELEGACIONES);
|
|
obj_Thread_DELEGACIONES.Start();
|
|
}
|
|
else
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo_Listado[3] = true;
|
|
}
|
|
|
|
|
|
//Esperando a que terminen todos los hilos .........................................
|
|
bool bol_Termino = false;
|
|
while (bol_Termino == false)
|
|
{
|
|
bol_Termino = true;
|
|
foreach (bool bol_Termino_Hilo in g_bol_Hilos_Terminados_Modelo_Listado)
|
|
{
|
|
if (bol_Termino_Hilo == false)
|
|
{
|
|
bol_Termino = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Thread.Sleep(10);
|
|
}
|
|
//.................................................................................
|
|
|
|
#endregion
|
|
|
|
#region DESPUES SE LO VOY ASIGNANDO A LOS REGISTRO UNO A UNO
|
|
foreach (VTA_FacturasCabecera mdl_VTA_FacturasCabecera in g_lst_VTA_FacturasCabecera)
|
|
{
|
|
//VTA_AlbaranesFacturasLineas #############################################
|
|
if (_bol_Cargar_AlbaranesFacturasLineas &&
|
|
g_lst_VTA_AlbaranesFacturasLineas != null &&
|
|
g_lst_VTA_AlbaranesFacturasLineas.Count > 0)
|
|
{
|
|
mdl_VTA_FacturasCabecera.VTA_AlbaranesFacturasLineas = g_lst_VTA_AlbaranesFacturasLineas.Where(m => m.idFacturaCabecera == mdl_VTA_FacturasCabecera.id).ToList();
|
|
}
|
|
|
|
//MAE_Clientes #############################################
|
|
if (_bol_Cargar_Clientes &&
|
|
mdl_VTA_FacturasCabecera.idCliente != null &&
|
|
g_lst_MAE_Clientes != null &&
|
|
g_lst_MAE_Clientes.Count > 0)
|
|
{
|
|
mdl_VTA_FacturasCabecera.MAE_Clientes = g_lst_MAE_Clientes.Where(m => m.id == mdl_VTA_FacturasCabecera.idCliente.Value).FirstOrDefault();
|
|
}
|
|
|
|
//GTT_Socios #############################################
|
|
if (_bol_Cargar_Socios &&
|
|
mdl_VTA_FacturasCabecera.idSocio != null &&
|
|
g_lst_GTT_Socios != null &&
|
|
g_lst_GTT_Socios.Count > 0)
|
|
{
|
|
mdl_VTA_FacturasCabecera.GTT_Socios = g_lst_GTT_Socios.Where(m => m.id == mdl_VTA_FacturasCabecera.idSocio.Value).FirstOrDefault();
|
|
}
|
|
|
|
//GEN_Delegaciones #############################################
|
|
if (_bol_Cargar_Delegaciones &&
|
|
g_lst_GEN_Delegaciones != null &&
|
|
g_lst_GEN_Delegaciones.Count > 0)
|
|
{
|
|
mdl_VTA_FacturasCabecera.GEN_Delegaciones = g_lst_GEN_Delegaciones.Where(m => m.id == mdl_VTA_FacturasCabecera.idDelegacion).FirstOrDefault();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Ejecutar_Consulta_Modelo_Listado), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
}
|
|
#region TablasRelacionadas
|
|
private void Obtener_AlbaranesFacturasLineas_Modelo_Listado()
|
|
{
|
|
try
|
|
{
|
|
VTA_AlbaranesFacturasLineas_Datos obj_VTA_AlbaranesFacturasLineas_Datos = new VTA_AlbaranesFacturasLineas_Datos();
|
|
g_lst_VTA_AlbaranesFacturasLineas = obj_VTA_AlbaranesFacturasLineas_Datos.Obtener_ModeloListado_Por_FacturasCabecera(g_lst_VTA_FacturasCabecera.Select(m => m.id).ToList());
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo_Listado[0] = true;
|
|
}
|
|
}
|
|
private void Obtener_Cliente_Modelo_Listado()
|
|
{
|
|
try
|
|
{
|
|
List<long> lst_ids = g_lst_VTA_FacturasCabecera.Where(m => m.idCliente != null).Select(m => m.idCliente.Value).ToList();
|
|
|
|
if (lst_ids != null && lst_ids.Count > 0)
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MAESTROS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_MAESTROS + "." + Variables.G_STR_LIBRERIA_DATOSMAESTROS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMAESTROS_PROCEDIMIENTO_MAECLIENTES_OBTENERMODELOLISTADO_POR_IDS, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { lst_ids };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_lst_MAE_Clientes = (List<MAE_Clientes>)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo_Listado[1] = true;
|
|
}
|
|
}
|
|
private void Obtener_Socios_Modelo_Listado()
|
|
{
|
|
try
|
|
{
|
|
List<long> lst_ids = g_lst_VTA_FacturasCabecera.Where(m => m.idSocio != null).Select(m => m.idSocio.Value).ToList();
|
|
|
|
if (lst_ids != null && lst_ids.Count > 0)
|
|
{
|
|
//Cargamos el ensamblado
|
|
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GESTIONTASAS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GESTIONTASAS + "." + Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS);
|
|
//creamos la instancia
|
|
var obj_Clase = Activator.CreateInstance(m_type);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSGESTIONTASAS_PROCEDIMIENTO_GTTSOCIOS_OBTENERMODELOLISTADO_POR_IDS_AUX_1, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros = { lst_ids, false, false };
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
g_lst_GTT_Socios = (List<GTT_Socios>)obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
|
|
}
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo_Listado[2] = true;
|
|
}
|
|
}
|
|
private void Obtener_Delegaciones_Modelo_Listado()
|
|
{
|
|
try
|
|
{
|
|
g_lst_GEN_Delegaciones = Datos_Generales.GEN_Delegaciones_Obtener_Modelo_Listado_Por_Ids(g_lst_VTA_FacturasCabecera.Select(m => m.idDelegacion).ToList());
|
|
}
|
|
catch (Control_Errores)
|
|
{ }
|
|
finally
|
|
{
|
|
g_bol_Hilos_Terminados_Modelo_Listado[3] = true;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
private string Obtener_Consulta_Modelo()
|
|
{
|
|
return
|
|
" SELECT " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.id) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.numeroFactura) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idCliente) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idSocio) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idDelegacion) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idFormaPago) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_bruto) + "," +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoProntoPago) + "," +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_descuentoFinalFactura) + "," +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_baseImponible) + "," +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_impuesto) + "," +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_recargo) + "," +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total) + "," +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fecha) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaIntroduccion) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpresa) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.estado) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idPredefinidoCabecera) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.fechaBorrado) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idLiquidacionTributaria) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.claveEmisora) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descripcion) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.guid) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idMoneda) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idImpuestoCabecera) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descuentoProntoPago) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.descuentoFinalFactura) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idEmpleado) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Preventa) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idVendedor_Autoventa) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.referencia) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.recargo) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.situacionPago) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.observaciones) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.idClaveAnalitica) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.aplicarRetencion) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.noDeclararModelosOficiales) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.criterioCaja) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Porcentaje) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Valor) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.retencion_Base) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_retencion) + " , " +
|
|
nameof(VTA_FacturasCabecera) + "." + nameof(VTA_FacturasCabecera.total_Final) +
|
|
" FROM " + nameof(VTA_FacturasCabecera);
|
|
}
|
|
#endregion
|
|
|
|
#region Grabar
|
|
public override INTERNO_ValorDevuelto_Modelo Grabar(object _mdl_obj)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
VTA_FacturasCabecera mdl_VTA_FacturasCabecera_AGrabar = (VTA_FacturasCabecera)_mdl_obj;
|
|
VTA_FacturasCabecera mdl_VTA_FacturasCabecera_DatosViejos = new VTA_FacturasCabecera();
|
|
|
|
// Ver si existe ######################################################################
|
|
VTA_FacturasCabecera mdl_VTA_FacturasCabecera_Final = Obtener_Modelo_Por_Id(mdl_VTA_FacturasCabecera_AGrabar.id, false, false, false, false);
|
|
//######################################################################################
|
|
|
|
if (mdl_VTA_FacturasCabecera_Final != null)
|
|
{
|
|
//Tipo de Accion que se va a realizar
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TipoAccion = G_ENUM_TIPOACCION.INT_MODIFICAR;
|
|
|
|
//Datos viejos para la trazabilidad
|
|
Funciones.CopiarPropiedadesObjetos(mdl_VTA_FacturasCabecera_Final, mdl_VTA_FacturasCabecera_DatosViejos, false, false);
|
|
|
|
//Cargar los Datos del Modelo
|
|
Funciones.CopiarPropiedadesObjetos(mdl_VTA_FacturasCabecera_AGrabar, mdl_VTA_FacturasCabecera_Final, false, false);
|
|
|
|
#region Update
|
|
string str_SQL_Update = " UPDATE " + nameof(VTA_FacturasCabecera) +
|
|
" SET " +
|
|
nameof(VTA_FacturasCabecera.numeroFactura) + "=@numeroFactura," +
|
|
nameof(VTA_FacturasCabecera.idCliente) + "=@idCliente," +
|
|
nameof(VTA_FacturasCabecera.idSocio) + "=@idSocio," +
|
|
nameof(VTA_FacturasCabecera.idDelegacion) + "=@idDelegacion," +
|
|
nameof(VTA_FacturasCabecera.idFormaPago) + "=@idFormaPago," +
|
|
nameof(VTA_FacturasCabecera.fecha) + "=@fecha," +
|
|
nameof(VTA_FacturasCabecera.fechaIntroduccion) + "=@fechaIntroduccion," +
|
|
nameof(VTA_FacturasCabecera.idEmpresa) + "=@idEmpresa," +
|
|
nameof(VTA_FacturasCabecera.estado) + "=@estado," +
|
|
nameof(VTA_FacturasCabecera.idPredefinidoCabecera) + "=@idPredefinidoCabecera," +
|
|
nameof(VTA_FacturasCabecera.fechaBorrado) + "=@fechaBorrado," +
|
|
nameof(VTA_FacturasCabecera.idLiquidacionTributaria) + "=@idLiquidacionTributaria," +
|
|
nameof(VTA_FacturasCabecera.claveEmisora) + "=@claveEmisora," +
|
|
nameof(VTA_FacturasCabecera.descripcion) + "=@descripcion," +
|
|
nameof(VTA_FacturasCabecera.guid) + "=@guid," +
|
|
nameof(VTA_FacturasCabecera.idMoneda) + "=@idMoneda," +
|
|
nameof(VTA_FacturasCabecera.idImpuestoCabecera) + "=@idImpuestoCabecera," +
|
|
nameof(VTA_FacturasCabecera.descuentoProntoPago) + "=@descuentoProntoPago," +
|
|
nameof(VTA_FacturasCabecera.descuentoFinalFactura) + "=@descuentoFinalFactura," +
|
|
nameof(VTA_FacturasCabecera.idEmpleado) + "=@idEmpleado," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Preventa) + "=@idVendedor_Preventa," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + "=@idVendedor_PreventaHabitual," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + "=@idVendedor_Repartidor," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + "=@idVendedor_Cobrador," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + "=@idVendedor_CobradorHabitual," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Autoventa) + "=@idVendedor_Autoventa," +
|
|
nameof(VTA_FacturasCabecera.referencia) + "=@referencia," +
|
|
nameof(VTA_FacturasCabecera.recargo) + "=@recargo," +
|
|
nameof(VTA_FacturasCabecera.situacionPago) + "=@situacionPago," +
|
|
nameof(VTA_FacturasCabecera.observaciones) + "=@observaciones," +
|
|
nameof(VTA_FacturasCabecera.idClaveAnalitica) + "=@idClaveAnalitica," +
|
|
nameof(VTA_FacturasCabecera.aplicarRetencion) + "=@aplicarRetencion," +
|
|
nameof(VTA_FacturasCabecera.noDeclararModelosOficiales) + "=@noDeclararModelosOficiales," +
|
|
nameof(VTA_FacturasCabecera.criterioCaja) + "=@criterioCaja," +
|
|
nameof(VTA_FacturasCabecera.retencion_Porcentaje) + "=@retencion_Porcentaje," +
|
|
nameof(VTA_FacturasCabecera.retencion_Valor) + "=@retencion_Valor," +
|
|
nameof(VTA_FacturasCabecera.retencion_Base) + "=@retencion_Base," +
|
|
nameof(VTA_FacturasCabecera.total_bruto) + "=@total_bruto, " +
|
|
nameof(VTA_FacturasCabecera.total_descuentoProntoPago) + "=@total_descuentoProntoPago, " +
|
|
nameof(VTA_FacturasCabecera.total_descuentoFinalFactura) + "=@total_descuentoFinalFactura, " +
|
|
nameof(VTA_FacturasCabecera.total_baseImponible) + "=@total_baseImponible, " +
|
|
nameof(VTA_FacturasCabecera.total_impuesto) + "=@total_impuesto, " +
|
|
nameof(VTA_FacturasCabecera.total_recargo) + "=@total_recargo, " +
|
|
nameof(VTA_FacturasCabecera.total) + "=@total, " +
|
|
nameof(VTA_FacturasCabecera.total_retencion) + "=@total_retencion, " +
|
|
nameof(VTA_FacturasCabecera.total_Final) + "=@total_Final " +
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera.id) + "=@id";
|
|
//Parametros
|
|
object[] arr_Parametros_Update = new object[]
|
|
{
|
|
new SqlParameter("@numeroFactura", mdl_VTA_FacturasCabecera_Final.numeroFactura),
|
|
mdl_VTA_FacturasCabecera_Final.idCliente!=null
|
|
? new SqlParameter("@idCliente", mdl_VTA_FacturasCabecera_Final.idCliente.Value)
|
|
: new SqlParameter("@idCliente", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idSocio!=null
|
|
? new SqlParameter("@idSocio", mdl_VTA_FacturasCabecera_Final.idSocio.Value)
|
|
: new SqlParameter("@idSocio", DBNull.Value),
|
|
new SqlParameter("@idDelegacion", mdl_VTA_FacturasCabecera_Final.idDelegacion),
|
|
new SqlParameter("@idFormaPago", mdl_VTA_FacturasCabecera_Final.idFormaPago),
|
|
new SqlParameter("@fecha", mdl_VTA_FacturasCabecera_Final.fecha),
|
|
new SqlParameter("@fechaIntroduccion", mdl_VTA_FacturasCabecera_Final.fechaIntroduccion),
|
|
new SqlParameter("@idEmpresa", mdl_VTA_FacturasCabecera_Final.idEmpresa),
|
|
new SqlParameter("@estado", mdl_VTA_FacturasCabecera_Final.estado),
|
|
mdl_VTA_FacturasCabecera_Final.idPredefinidoCabecera!=null
|
|
? new SqlParameter("@idPredefinidoCabecera", mdl_VTA_FacturasCabecera_Final.idPredefinidoCabecera.Value)
|
|
: new SqlParameter("@idPredefinidoCabecera", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.fechaBorrado!=null
|
|
? new SqlParameter("@fechaBorrado", mdl_VTA_FacturasCabecera_Final.fechaBorrado.Value)
|
|
: new SqlParameter("@fechaBorrado", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idLiquidacionTributaria!=null
|
|
? new SqlParameter("@idLiquidacionTributaria", mdl_VTA_FacturasCabecera_Final.idLiquidacionTributaria.Value)
|
|
: new SqlParameter("@idLiquidacionTributaria", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.claveEmisora!=null
|
|
? new SqlParameter("@claveEmisora", mdl_VTA_FacturasCabecera_Final.claveEmisora)
|
|
: new SqlParameter("@claveEmisora", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.descripcion!=null
|
|
? new SqlParameter("@descripcion", mdl_VTA_FacturasCabecera_Final.descripcion)
|
|
: new SqlParameter("@descripcion", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.guid!=null
|
|
? new SqlParameter("@guid", mdl_VTA_FacturasCabecera_Final.guid)
|
|
: new SqlParameter("@guid", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idMoneda!=null
|
|
? new SqlParameter("@idMoneda", mdl_VTA_FacturasCabecera_Final.idMoneda.Value)
|
|
: new SqlParameter("@idMoneda", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idImpuestoCabecera!=null
|
|
? new SqlParameter("@idImpuestoCabecera", mdl_VTA_FacturasCabecera_Final.idImpuestoCabecera.Value)
|
|
: new SqlParameter("@idImpuestoCabecera", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.descuentoProntoPago!=null
|
|
? new SqlParameter("@descuentoProntoPago", mdl_VTA_FacturasCabecera_Final.descuentoProntoPago.Value)
|
|
: new SqlParameter("@descuentoProntoPago", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.descuentoFinalFactura!=null
|
|
? new SqlParameter("@descuentoFinalFactura", mdl_VTA_FacturasCabecera_Final.descuentoFinalFactura.Value)
|
|
: new SqlParameter("@descuentoFinalFactura", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idEmpleado!=null
|
|
? new SqlParameter("@idEmpleado", mdl_VTA_FacturasCabecera_Final.idEmpleado.Value)
|
|
: new SqlParameter("@idEmpleado", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Preventa!=null
|
|
? new SqlParameter("@idVendedor_Preventa", mdl_VTA_FacturasCabecera_Final.idVendedor_Preventa.Value)
|
|
: new SqlParameter("@idVendedor_Preventa", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_PreventaHabitual!=null
|
|
? new SqlParameter("@idVendedor_PreventaHabitual", mdl_VTA_FacturasCabecera_Final.idVendedor_PreventaHabitual.Value)
|
|
: new SqlParameter("@idVendedor_PreventaHabitual", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Repartidor!=null
|
|
? new SqlParameter("@idVendedor_Repartidor", mdl_VTA_FacturasCabecera_Final.idVendedor_Repartidor.Value)
|
|
: new SqlParameter("@idVendedor_Repartidor", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Cobrador!=null
|
|
? new SqlParameter("@idVendedor_Cobrador", mdl_VTA_FacturasCabecera_Final.idVendedor_Cobrador.Value)
|
|
: new SqlParameter("@idVendedor_Cobrador", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_CobradorHabitual!=null
|
|
? new SqlParameter("@idVendedor_CobradorHabitual", mdl_VTA_FacturasCabecera_Final.idVendedor_CobradorHabitual.Value)
|
|
: new SqlParameter("@idVendedor_CobradorHabitual", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Autoventa!=null
|
|
? new SqlParameter("@idVendedor_Autoventa", mdl_VTA_FacturasCabecera_Final.idVendedor_Autoventa.Value)
|
|
: new SqlParameter("@idVendedor_Autoventa", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.referencia!=null
|
|
? new SqlParameter("@referencia", mdl_VTA_FacturasCabecera_Final.referencia)
|
|
: new SqlParameter("@referencia", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.recargo!=null
|
|
? new SqlParameter("@recargo", mdl_VTA_FacturasCabecera_Final.recargo.Value)
|
|
: new SqlParameter("@recargo", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.situacionPago!=null
|
|
? new SqlParameter("@situacionPago", mdl_VTA_FacturasCabecera_Final.situacionPago.Value)
|
|
: new SqlParameter("@situacionPago", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.observaciones!=null
|
|
? new SqlParameter("@observaciones", mdl_VTA_FacturasCabecera_Final.observaciones)
|
|
: new SqlParameter("@observaciones", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idClaveAnalitica!=null
|
|
? new SqlParameter("@idClaveAnalitica", mdl_VTA_FacturasCabecera_Final.idClaveAnalitica.Value)
|
|
: new SqlParameter("@idClaveAnalitica", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.aplicarRetencion!=null
|
|
? new SqlParameter("@aplicarRetencion", mdl_VTA_FacturasCabecera_Final.aplicarRetencion.Value)
|
|
: new SqlParameter("@aplicarRetencion", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.noDeclararModelosOficiales!=null
|
|
? new SqlParameter("@noDeclararModelosOficiales", mdl_VTA_FacturasCabecera_Final.noDeclararModelosOficiales.Value)
|
|
: new SqlParameter("@noDeclararModelosOficiales", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.criterioCaja!=null
|
|
? new SqlParameter("@criterioCaja", mdl_VTA_FacturasCabecera_Final.criterioCaja.Value)
|
|
: new SqlParameter("@criterioCaja", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.retencion_Porcentaje!=null
|
|
? new SqlParameter("@retencion_Porcentaje", mdl_VTA_FacturasCabecera_Final.retencion_Porcentaje.Value)
|
|
: new SqlParameter("@retencion_Porcentaje", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.retencion_Valor!=null
|
|
? new SqlParameter("@retencion_Valor", mdl_VTA_FacturasCabecera_Final.retencion_Valor.Value)
|
|
: new SqlParameter("@retencion_Valor", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.retencion_Base!=null
|
|
? new SqlParameter("@retencion_Base", mdl_VTA_FacturasCabecera_Final.retencion_Base.Value)
|
|
: new SqlParameter("@retencion_Base", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_bruto!=null
|
|
? new SqlParameter("@total_bruto", mdl_VTA_FacturasCabecera_Final.total_bruto)
|
|
: new SqlParameter("@total_bruto", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_descuentoProntoPago!=null
|
|
? new SqlParameter("@total_descuentoProntoPago", mdl_VTA_FacturasCabecera_Final.total_descuentoProntoPago)
|
|
: new SqlParameter("@total_descuentoProntoPago", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_descuentoFinalFactura!=null
|
|
? new SqlParameter("@total_descuentoFinalFactura", mdl_VTA_FacturasCabecera_Final.total_descuentoFinalFactura)
|
|
: new SqlParameter("@total_descuentoFinalFactura", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_baseImponible!=null
|
|
? new SqlParameter("@total_baseImponible", mdl_VTA_FacturasCabecera_Final.total_baseImponible)
|
|
: new SqlParameter("@total_baseImponible", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_impuesto!=null
|
|
? new SqlParameter("@total_impuesto", mdl_VTA_FacturasCabecera_Final.total_impuesto)
|
|
: new SqlParameter("@total_impuesto", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_recargo!=null
|
|
? new SqlParameter("@total_recargo", mdl_VTA_FacturasCabecera_Final.total_recargo)
|
|
: new SqlParameter("@total_recargo", DBNull.Value),
|
|
new SqlParameter("@total", mdl_VTA_FacturasCabecera_Final.total),
|
|
mdl_VTA_FacturasCabecera_Final.total_retencion!=null
|
|
? new SqlParameter("@total_retencion", mdl_VTA_FacturasCabecera_Final.total_retencion)
|
|
: new SqlParameter("@total_retencion", DBNull.Value),
|
|
new SqlParameter("@total_Final", mdl_VTA_FacturasCabecera_Final.total_Final),
|
|
new SqlParameter("@id", mdl_VTA_FacturasCabecera_Final.id)
|
|
};
|
|
#endregion
|
|
|
|
//Update
|
|
obj_Exferia_Entities.Database.ExecuteSqlCommand(str_SQL_Update, arr_Parametros_Update);
|
|
|
|
//Id de la tabla
|
|
mdl_INTERNO_ValorDevuelto_Modelo.Id = mdl_VTA_FacturasCabecera_Final.id;
|
|
}
|
|
else
|
|
{
|
|
mdl_VTA_FacturasCabecera_Final = new VTA_FacturasCabecera();
|
|
|
|
//Tipo de Accion que se va a realizar
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TipoAccion = G_ENUM_TIPOACCION.INT_INSERTAR;
|
|
|
|
//Cargar los Datos del Modelo
|
|
Funciones.CopiarPropiedadesObjetos(mdl_VTA_FacturasCabecera_AGrabar, mdl_VTA_FacturasCabecera_Final, false, false);
|
|
|
|
#region INSERT
|
|
string str_SQL_Insert = " INSERT INTO " + nameof(VTA_FacturasCabecera) +
|
|
" (" +
|
|
nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(VTA_FacturasCabecera.idCliente) + "," +
|
|
nameof(VTA_FacturasCabecera.idSocio) + "," +
|
|
nameof(VTA_FacturasCabecera.idDelegacion) + "," +
|
|
nameof(VTA_FacturasCabecera.idFormaPago) + "," +
|
|
nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(VTA_FacturasCabecera.fechaIntroduccion) + "," +
|
|
nameof(VTA_FacturasCabecera.idEmpresa) + "," +
|
|
nameof(VTA_FacturasCabecera.estado) + "," +
|
|
nameof(VTA_FacturasCabecera.idPredefinidoCabecera) + "," +
|
|
nameof(VTA_FacturasCabecera.fechaBorrado) + "," +
|
|
nameof(VTA_FacturasCabecera.idLiquidacionTributaria) + "," +
|
|
nameof(VTA_FacturasCabecera.claveEmisora) + "," +
|
|
nameof(VTA_FacturasCabecera.descripcion) + "," +
|
|
nameof(VTA_FacturasCabecera.guid) + "," +
|
|
nameof(VTA_FacturasCabecera.idMoneda) + "," +
|
|
nameof(VTA_FacturasCabecera.idImpuestoCabecera) + "," +
|
|
nameof(VTA_FacturasCabecera.descuentoProntoPago) + "," +
|
|
nameof(VTA_FacturasCabecera.descuentoFinalFactura) + "," +
|
|
nameof(VTA_FacturasCabecera.idEmpleado) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Preventa) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Autoventa) + "," +
|
|
nameof(VTA_FacturasCabecera.referencia) + "," +
|
|
nameof(VTA_FacturasCabecera.recargo) + "," +
|
|
nameof(VTA_FacturasCabecera.situacionPago) + "," +
|
|
nameof(VTA_FacturasCabecera.observaciones) + "," +
|
|
nameof(VTA_FacturasCabecera.idClaveAnalitica) + "," +
|
|
nameof(VTA_FacturasCabecera.aplicarRetencion) + "," +
|
|
nameof(VTA_FacturasCabecera.noDeclararModelosOficiales) + "," +
|
|
nameof(VTA_FacturasCabecera.criterioCaja) + "," +
|
|
nameof(VTA_FacturasCabecera.retencion_Porcentaje) + "," +
|
|
nameof(VTA_FacturasCabecera.retencion_Valor) + "," +
|
|
nameof(VTA_FacturasCabecera.retencion_Base) + "," +
|
|
nameof(VTA_FacturasCabecera.total_bruto) + "," +
|
|
nameof(VTA_FacturasCabecera.total_descuentoProntoPago) + "," +
|
|
nameof(VTA_FacturasCabecera.total_descuentoFinalFactura) + "," +
|
|
nameof(VTA_FacturasCabecera.total_baseImponible) + "," +
|
|
nameof(VTA_FacturasCabecera.total_impuesto) + "," +
|
|
nameof(VTA_FacturasCabecera.total_recargo) + "," +
|
|
nameof(VTA_FacturasCabecera.total) + "," +
|
|
nameof(VTA_FacturasCabecera.total_retencion) + "," +
|
|
nameof(VTA_FacturasCabecera.total_Final) +
|
|
" ) " +
|
|
" OUTPUT INSERTED." + nameof(VTA_FacturasCabecera.id) +
|
|
" VALUES " +
|
|
" ( " +
|
|
"@numeroFactura," +
|
|
"@idCliente," +
|
|
"@idSocio," +
|
|
"@idDelegacion," +
|
|
"@idFormaPago," +
|
|
"@fecha," +
|
|
"@fechaIntroduccion," +
|
|
"@idEmpresa," +
|
|
"@estado," +
|
|
"@idPredefinidoCabecera," +
|
|
"@fechaBorrado," +
|
|
"@idLiquidacionTributaria," +
|
|
"@claveEmisora," +
|
|
"@descripcion," +
|
|
"@guid," +
|
|
"@idMoneda," +
|
|
"@idImpuestoCabecera," +
|
|
"@descuentoProntoPago," +
|
|
"@descuentoFinalFactura," +
|
|
"@idEmpleado," +
|
|
"@idVendedor_Preventa," +
|
|
"@idVendedor_PreventaHabitual," +
|
|
"@idVendedor_Repartidor," +
|
|
"@idVendedor_Cobrador," +
|
|
"@idVendedor_CobradorHabitual," +
|
|
"@idVendedor_Autoventa," +
|
|
"@referencia," +
|
|
"@recargo," +
|
|
"@situacionPago," +
|
|
"@observaciones," +
|
|
"@idClaveAnalitica," +
|
|
"@aplicarRetencion," +
|
|
"@noDeclararModelosOficiales," +
|
|
"@criterioCaja," +
|
|
"@retencion_Porcentaje," +
|
|
"@retencion_Valor," +
|
|
"@retencion_Base," +
|
|
"@total_bruto," +
|
|
"@total_descuentoProntoPago," +
|
|
"@total_descuentoFinalFactura," +
|
|
"@total_baseImponible," +
|
|
"@total_impuesto," +
|
|
"@total_recargo," +
|
|
"@total," +
|
|
"@total_retencion," +
|
|
"@total_Final" +
|
|
" ) ";
|
|
//Parametros
|
|
object[] arr_Parametros_Insert = new object[]
|
|
{
|
|
new SqlParameter("@numeroFactura", mdl_VTA_FacturasCabecera_Final.numeroFactura),
|
|
mdl_VTA_FacturasCabecera_Final.idCliente!=null
|
|
? new SqlParameter("@idCliente", mdl_VTA_FacturasCabecera_Final.idCliente.Value)
|
|
: new SqlParameter("@idCliente", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idSocio!=null
|
|
? new SqlParameter("@idSocio", mdl_VTA_FacturasCabecera_Final.idSocio.Value)
|
|
: new SqlParameter("@idSocio", DBNull.Value),
|
|
new SqlParameter("@idDelegacion", mdl_VTA_FacturasCabecera_Final.idDelegacion),
|
|
new SqlParameter("@idFormaPago", mdl_VTA_FacturasCabecera_Final.idFormaPago),
|
|
new SqlParameter("@fecha", mdl_VTA_FacturasCabecera_Final.fecha),
|
|
new SqlParameter("@fechaIntroduccion", mdl_VTA_FacturasCabecera_Final.fechaIntroduccion),
|
|
new SqlParameter("@idEmpresa", mdl_VTA_FacturasCabecera_Final.idEmpresa),
|
|
new SqlParameter("@estado", mdl_VTA_FacturasCabecera_Final.estado),
|
|
mdl_VTA_FacturasCabecera_Final.idPredefinidoCabecera!=null
|
|
? new SqlParameter("@idPredefinidoCabecera", mdl_VTA_FacturasCabecera_Final.idPredefinidoCabecera.Value)
|
|
: new SqlParameter("@idPredefinidoCabecera", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.fechaBorrado!=null
|
|
? new SqlParameter("@fechaBorrado", mdl_VTA_FacturasCabecera_Final.fechaBorrado.Value)
|
|
: new SqlParameter("@fechaBorrado", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idLiquidacionTributaria!=null
|
|
? new SqlParameter("@idLiquidacionTributaria", mdl_VTA_FacturasCabecera_Final.idLiquidacionTributaria.Value)
|
|
: new SqlParameter("@idLiquidacionTributaria", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.claveEmisora!=null
|
|
? new SqlParameter("@claveEmisora", mdl_VTA_FacturasCabecera_Final.claveEmisora)
|
|
: new SqlParameter("@claveEmisora", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.descripcion!=null
|
|
? new SqlParameter("@descripcion", mdl_VTA_FacturasCabecera_Final.descripcion)
|
|
: new SqlParameter("@descripcion", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.guid!=null
|
|
? new SqlParameter("@guid", mdl_VTA_FacturasCabecera_Final.guid)
|
|
: new SqlParameter("@guid", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idMoneda!=null
|
|
? new SqlParameter("@idMoneda", mdl_VTA_FacturasCabecera_Final.idMoneda.Value)
|
|
: new SqlParameter("@idMoneda", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idImpuestoCabecera!=null
|
|
? new SqlParameter("@idImpuestoCabecera", mdl_VTA_FacturasCabecera_Final.idImpuestoCabecera.Value)
|
|
: new SqlParameter("@idImpuestoCabecera", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.descuentoProntoPago!=null
|
|
? new SqlParameter("@descuentoProntoPago", mdl_VTA_FacturasCabecera_Final.descuentoProntoPago.Value)
|
|
: new SqlParameter("@descuentoProntoPago", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.descuentoFinalFactura!=null
|
|
? new SqlParameter("@descuentoFinalFactura", mdl_VTA_FacturasCabecera_Final.descuentoFinalFactura.Value)
|
|
: new SqlParameter("@descuentoFinalFactura", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idEmpleado!=null
|
|
? new SqlParameter("@idEmpleado", mdl_VTA_FacturasCabecera_Final.idEmpleado.Value)
|
|
: new SqlParameter("@idEmpleado", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Preventa!=null
|
|
? new SqlParameter("@idVendedor_Preventa", mdl_VTA_FacturasCabecera_Final.idVendedor_Preventa.Value)
|
|
: new SqlParameter("@idVendedor_Preventa", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_PreventaHabitual!=null
|
|
? new SqlParameter("@idVendedor_PreventaHabitual", mdl_VTA_FacturasCabecera_Final.idVendedor_PreventaHabitual.Value)
|
|
: new SqlParameter("@idVendedor_PreventaHabitual", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Repartidor!=null
|
|
? new SqlParameter("@idVendedor_Repartidor", mdl_VTA_FacturasCabecera_Final.idVendedor_Repartidor.Value)
|
|
: new SqlParameter("@idVendedor_Repartidor", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Cobrador!=null
|
|
? new SqlParameter("@idVendedor_Cobrador", mdl_VTA_FacturasCabecera_Final.idVendedor_Cobrador.Value)
|
|
: new SqlParameter("@idVendedor_Cobrador", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_CobradorHabitual!=null
|
|
? new SqlParameter("@idVendedor_CobradorHabitual", mdl_VTA_FacturasCabecera_Final.idVendedor_CobradorHabitual.Value)
|
|
: new SqlParameter("@idVendedor_CobradorHabitual", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Autoventa!=null
|
|
? new SqlParameter("@idVendedor_Autoventa", mdl_VTA_FacturasCabecera_Final.idVendedor_Autoventa.Value)
|
|
: new SqlParameter("@idVendedor_Autoventa", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.referencia!=null
|
|
? new SqlParameter("@referencia", mdl_VTA_FacturasCabecera_Final.referencia)
|
|
: new SqlParameter("@referencia", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.recargo!=null
|
|
? new SqlParameter("@recargo", mdl_VTA_FacturasCabecera_Final.recargo.Value)
|
|
: new SqlParameter("@recargo", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.situacionPago!=null
|
|
? new SqlParameter("@situacionPago", mdl_VTA_FacturasCabecera_Final.situacionPago.Value)
|
|
: new SqlParameter("@situacionPago", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.observaciones!=null
|
|
? new SqlParameter("@observaciones", mdl_VTA_FacturasCabecera_Final.observaciones)
|
|
: new SqlParameter("@observaciones", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idClaveAnalitica!=null
|
|
? new SqlParameter("@idClaveAnalitica", mdl_VTA_FacturasCabecera_Final.idClaveAnalitica.Value)
|
|
: new SqlParameter("@idClaveAnalitica", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.aplicarRetencion!=null
|
|
? new SqlParameter("@aplicarRetencion", mdl_VTA_FacturasCabecera_Final.aplicarRetencion.Value)
|
|
: new SqlParameter("@aplicarRetencion", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.noDeclararModelosOficiales!=null
|
|
? new SqlParameter("@noDeclararModelosOficiales", mdl_VTA_FacturasCabecera_Final.noDeclararModelosOficiales.Value)
|
|
: new SqlParameter("@noDeclararModelosOficiales", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.criterioCaja!=null
|
|
? new SqlParameter("@criterioCaja", mdl_VTA_FacturasCabecera_Final.criterioCaja.Value)
|
|
: new SqlParameter("@criterioCaja", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.retencion_Porcentaje!=null
|
|
? new SqlParameter("@retencion_Porcentaje", mdl_VTA_FacturasCabecera_Final.retencion_Porcentaje.Value)
|
|
: new SqlParameter("@retencion_Porcentaje", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.retencion_Valor!=null
|
|
? new SqlParameter("@retencion_Valor", mdl_VTA_FacturasCabecera_Final.retencion_Valor.Value)
|
|
: new SqlParameter("@retencion_Valor", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.retencion_Base!=null
|
|
? new SqlParameter("@retencion_Base", mdl_VTA_FacturasCabecera_Final.retencion_Base.Value)
|
|
: new SqlParameter("@retencion_Base", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_bruto!=null
|
|
? new SqlParameter("@total_bruto", mdl_VTA_FacturasCabecera_Final.total_bruto)
|
|
: new SqlParameter("@total_bruto", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_descuentoProntoPago!=null
|
|
? new SqlParameter("@total_descuentoProntoPago", mdl_VTA_FacturasCabecera_Final.total_descuentoProntoPago)
|
|
: new SqlParameter("@total_descuentoProntoPago", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_descuentoFinalFactura!=null
|
|
? new SqlParameter("@total_descuentoFinalFactura", mdl_VTA_FacturasCabecera_Final.total_descuentoFinalFactura)
|
|
: new SqlParameter("@total_descuentoFinalFactura", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_baseImponible!=null
|
|
? new SqlParameter("@total_baseImponible", mdl_VTA_FacturasCabecera_Final.total_baseImponible)
|
|
: new SqlParameter("@total_baseImponible", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_impuesto!=null
|
|
? new SqlParameter("@total_impuesto", mdl_VTA_FacturasCabecera_Final.total_impuesto)
|
|
: new SqlParameter("@total_impuesto", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_recargo!=null
|
|
? new SqlParameter("@total_recargo", mdl_VTA_FacturasCabecera_Final.total_recargo)
|
|
: new SqlParameter("@total_recargo", DBNull.Value),
|
|
new SqlParameter("@total", mdl_VTA_FacturasCabecera_Final.total) ,
|
|
mdl_VTA_FacturasCabecera_Final.total_retencion!=null
|
|
? new SqlParameter("@total_retencion", mdl_VTA_FacturasCabecera_Final.total_retencion)
|
|
: new SqlParameter("@total_retencion", DBNull.Value),
|
|
new SqlParameter("@total_Final", mdl_VTA_FacturasCabecera_Final.total_Final)
|
|
};
|
|
#endregion
|
|
|
|
//Id de la tabla
|
|
mdl_INTERNO_ValorDevuelto_Modelo.Id = obj_Exferia_Entities.Database.SqlQuery<long>(str_SQL_Insert, arr_Parametros_Insert).Single();
|
|
}
|
|
|
|
// Grabar un registro de trazabilidad con los datos de la transaccion realizada.
|
|
Datos_Generales.USR_Trazabilidad_Grabar(typeof(VTA_FacturasCabecera), mdl_VTA_FacturasCabecera_DatosViejos, mdl_VTA_FacturasCabecera_Final, mdl_INTERNO_ValorDevuelto_Modelo.TipoAccion, obj_Exferia_Entities);
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Grabar), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
public INTERNO_ValorDevuelto_Modelo Insertar(VTA_FacturasCabecera _mdl_VTA_FacturasCabecera_AGrabar)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
VTA_FacturasCabecera mdl_VTA_FacturasCabecera_DatosViejos = new VTA_FacturasCabecera();
|
|
VTA_FacturasCabecera mdl_VTA_FacturasCabecera_Final = new VTA_FacturasCabecera();
|
|
|
|
//Tipo de Accion que se va a realizar
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TipoAccion = G_ENUM_TIPOACCION.INT_INSERTAR;
|
|
|
|
//Cargar los Datos del Modelo
|
|
Funciones.CopiarPropiedadesObjetos(_mdl_VTA_FacturasCabecera_AGrabar, mdl_VTA_FacturasCabecera_Final, false, false);
|
|
|
|
#region INSERT
|
|
string str_SQL_Insert = " INSERT INTO " + nameof(VTA_FacturasCabecera) +
|
|
" (" +
|
|
nameof(VTA_FacturasCabecera.numeroFactura) + "," +
|
|
nameof(VTA_FacturasCabecera.idCliente) + "," +
|
|
nameof(VTA_FacturasCabecera.idSocio) + "," +
|
|
nameof(VTA_FacturasCabecera.idDelegacion) + "," +
|
|
nameof(VTA_FacturasCabecera.idFormaPago) + "," +
|
|
nameof(VTA_FacturasCabecera.fecha) + "," +
|
|
nameof(VTA_FacturasCabecera.fechaIntroduccion) + "," +
|
|
nameof(VTA_FacturasCabecera.idEmpresa) + "," +
|
|
nameof(VTA_FacturasCabecera.estado) + "," +
|
|
nameof(VTA_FacturasCabecera.idPredefinidoCabecera) + "," +
|
|
nameof(VTA_FacturasCabecera.fechaBorrado) + "," +
|
|
nameof(VTA_FacturasCabecera.idLiquidacionTributaria) + "," +
|
|
nameof(VTA_FacturasCabecera.claveEmisora) + "," +
|
|
nameof(VTA_FacturasCabecera.descripcion) + "," +
|
|
nameof(VTA_FacturasCabecera.guid) + "," +
|
|
nameof(VTA_FacturasCabecera.idMoneda) + "," +
|
|
nameof(VTA_FacturasCabecera.idImpuestoCabecera) + "," +
|
|
nameof(VTA_FacturasCabecera.descuentoProntoPago) + "," +
|
|
nameof(VTA_FacturasCabecera.descuentoFinalFactura) + "," +
|
|
nameof(VTA_FacturasCabecera.idEmpleado) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Preventa) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + "," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Autoventa) + "," +
|
|
nameof(VTA_FacturasCabecera.referencia) + "," +
|
|
nameof(VTA_FacturasCabecera.recargo) + "," +
|
|
nameof(VTA_FacturasCabecera.situacionPago) + "," +
|
|
nameof(VTA_FacturasCabecera.observaciones) + "," +
|
|
nameof(VTA_FacturasCabecera.idClaveAnalitica) + "," +
|
|
nameof(VTA_FacturasCabecera.aplicarRetencion) + "," +
|
|
nameof(VTA_FacturasCabecera.noDeclararModelosOficiales) + "," +
|
|
nameof(VTA_FacturasCabecera.criterioCaja) + "," +
|
|
nameof(VTA_FacturasCabecera.retencion_Porcentaje) + "," +
|
|
nameof(VTA_FacturasCabecera.retencion_Valor) + "," +
|
|
nameof(VTA_FacturasCabecera.retencion_Base) + "," +
|
|
nameof(VTA_FacturasCabecera.total_bruto) + "," +
|
|
nameof(VTA_FacturasCabecera.total_descuentoProntoPago) + "," +
|
|
nameof(VTA_FacturasCabecera.total_descuentoFinalFactura) + "," +
|
|
nameof(VTA_FacturasCabecera.total_baseImponible) + "," +
|
|
nameof(VTA_FacturasCabecera.total_impuesto) + "," +
|
|
nameof(VTA_FacturasCabecera.total_recargo) + "," +
|
|
nameof(VTA_FacturasCabecera.total) + "," +
|
|
nameof(VTA_FacturasCabecera.total_retencion) + "," +
|
|
nameof(VTA_FacturasCabecera.total_Final) +
|
|
" ) " +
|
|
" OUTPUT INSERTED." + nameof(VTA_FacturasCabecera.id) +
|
|
" VALUES " +
|
|
" ( " +
|
|
"@numeroFactura," +
|
|
"@idCliente," +
|
|
"@idSocio," +
|
|
"@idDelegacion," +
|
|
"@idFormaPago," +
|
|
"@fecha," +
|
|
"@fechaIntroduccion," +
|
|
"@idEmpresa," +
|
|
"@estado," +
|
|
"@idPredefinidoCabecera," +
|
|
"@fechaBorrado," +
|
|
"@idLiquidacionTributaria," +
|
|
"@claveEmisora," +
|
|
"@descripcion," +
|
|
"@guid," +
|
|
"@idMoneda," +
|
|
"@idImpuestoCabecera," +
|
|
"@descuentoProntoPago," +
|
|
"@descuentoFinalFactura," +
|
|
"@idEmpleado," +
|
|
"@idVendedor_Preventa," +
|
|
"@idVendedor_PreventaHabitual," +
|
|
"@idVendedor_Repartidor," +
|
|
"@idVendedor_Cobrador," +
|
|
"@idVendedor_CobradorHabitual," +
|
|
"@idVendedor_Autoventa," +
|
|
"@referencia," +
|
|
"@recargo," +
|
|
"@situacionPago," +
|
|
"@observaciones," +
|
|
"@idClaveAnalitica," +
|
|
"@aplicarRetencion," +
|
|
"@noDeclararModelosOficiales," +
|
|
"@criterioCaja," +
|
|
"@retencion_Porcentaje," +
|
|
"@retencion_Valor," +
|
|
"@retencion_Base," +
|
|
"@total_bruto," +
|
|
"@total_descuentoProntoPago," +
|
|
"@total_descuentoFinalFactura," +
|
|
"@total_baseImponible," +
|
|
"@total_impuesto," +
|
|
"@total_recargo," +
|
|
"@total," +
|
|
"@total_retencion," +
|
|
"@total_Final" +
|
|
" ) ";
|
|
//Parametros
|
|
object[] arr_Parametros_Insert = new object[]
|
|
{
|
|
new SqlParameter("@numeroFactura", mdl_VTA_FacturasCabecera_Final.numeroFactura),
|
|
mdl_VTA_FacturasCabecera_Final.idCliente!=null
|
|
? new SqlParameter("@idCliente", mdl_VTA_FacturasCabecera_Final.idCliente.Value)
|
|
: new SqlParameter("@idCliente", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idSocio!=null
|
|
? new SqlParameter("@idSocio", mdl_VTA_FacturasCabecera_Final.idSocio.Value)
|
|
: new SqlParameter("@idSocio", DBNull.Value),
|
|
new SqlParameter("@idDelegacion", mdl_VTA_FacturasCabecera_Final.idDelegacion),
|
|
new SqlParameter("@idFormaPago", mdl_VTA_FacturasCabecera_Final.idFormaPago),
|
|
new SqlParameter("@fecha", mdl_VTA_FacturasCabecera_Final.fecha),
|
|
new SqlParameter("@fechaIntroduccion", mdl_VTA_FacturasCabecera_Final.fechaIntroduccion),
|
|
new SqlParameter("@idEmpresa", mdl_VTA_FacturasCabecera_Final.idEmpresa),
|
|
new SqlParameter("@estado", mdl_VTA_FacturasCabecera_Final.estado),
|
|
mdl_VTA_FacturasCabecera_Final.idPredefinidoCabecera!=null
|
|
? new SqlParameter("@idPredefinidoCabecera", mdl_VTA_FacturasCabecera_Final.idPredefinidoCabecera.Value)
|
|
: new SqlParameter("@idPredefinidoCabecera", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.fechaBorrado!=null
|
|
? new SqlParameter("@fechaBorrado", mdl_VTA_FacturasCabecera_Final.fechaBorrado.Value)
|
|
: new SqlParameter("@fechaBorrado", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idLiquidacionTributaria!=null
|
|
? new SqlParameter("@idLiquidacionTributaria", mdl_VTA_FacturasCabecera_Final.idLiquidacionTributaria.Value)
|
|
: new SqlParameter("@idLiquidacionTributaria", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.claveEmisora!=null
|
|
? new SqlParameter("@claveEmisora", mdl_VTA_FacturasCabecera_Final.claveEmisora)
|
|
: new SqlParameter("@claveEmisora", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.descripcion!=null
|
|
? new SqlParameter("@descripcion", mdl_VTA_FacturasCabecera_Final.descripcion)
|
|
: new SqlParameter("@descripcion", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.guid!=null
|
|
? new SqlParameter("@guid", mdl_VTA_FacturasCabecera_Final.guid)
|
|
: new SqlParameter("@guid", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idMoneda!=null
|
|
? new SqlParameter("@idMoneda", mdl_VTA_FacturasCabecera_Final.idMoneda.Value)
|
|
: new SqlParameter("@idMoneda", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idImpuestoCabecera!=null
|
|
? new SqlParameter("@idImpuestoCabecera", mdl_VTA_FacturasCabecera_Final.idImpuestoCabecera.Value)
|
|
: new SqlParameter("@idImpuestoCabecera", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.descuentoProntoPago!=null
|
|
? new SqlParameter("@descuentoProntoPago", mdl_VTA_FacturasCabecera_Final.descuentoProntoPago.Value)
|
|
: new SqlParameter("@descuentoProntoPago", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.descuentoFinalFactura!=null
|
|
? new SqlParameter("@descuentoFinalFactura", mdl_VTA_FacturasCabecera_Final.descuentoFinalFactura.Value)
|
|
: new SqlParameter("@descuentoFinalFactura", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idEmpleado!=null
|
|
? new SqlParameter("@idEmpleado", mdl_VTA_FacturasCabecera_Final.idEmpleado.Value)
|
|
: new SqlParameter("@idEmpleado", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Preventa!=null
|
|
? new SqlParameter("@idVendedor_Preventa", mdl_VTA_FacturasCabecera_Final.idVendedor_Preventa.Value)
|
|
: new SqlParameter("@idVendedor_Preventa", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_PreventaHabitual!=null
|
|
? new SqlParameter("@idVendedor_PreventaHabitual", mdl_VTA_FacturasCabecera_Final.idVendedor_PreventaHabitual.Value)
|
|
: new SqlParameter("@idVendedor_PreventaHabitual", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Repartidor!=null
|
|
? new SqlParameter("@idVendedor_Repartidor", mdl_VTA_FacturasCabecera_Final.idVendedor_Repartidor.Value)
|
|
: new SqlParameter("@idVendedor_Repartidor", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Cobrador!=null
|
|
? new SqlParameter("@idVendedor_Cobrador", mdl_VTA_FacturasCabecera_Final.idVendedor_Cobrador.Value)
|
|
: new SqlParameter("@idVendedor_Cobrador", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_CobradorHabitual!=null
|
|
? new SqlParameter("@idVendedor_CobradorHabitual", mdl_VTA_FacturasCabecera_Final.idVendedor_CobradorHabitual.Value)
|
|
: new SqlParameter("@idVendedor_CobradorHabitual", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idVendedor_Autoventa!=null
|
|
? new SqlParameter("@idVendedor_Autoventa", mdl_VTA_FacturasCabecera_Final.idVendedor_Autoventa.Value)
|
|
: new SqlParameter("@idVendedor_Autoventa", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.referencia!=null
|
|
? new SqlParameter("@referencia", mdl_VTA_FacturasCabecera_Final.referencia)
|
|
: new SqlParameter("@referencia", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.recargo!=null
|
|
? new SqlParameter("@recargo", mdl_VTA_FacturasCabecera_Final.recargo.Value)
|
|
: new SqlParameter("@recargo", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.situacionPago!=null
|
|
? new SqlParameter("@situacionPago", mdl_VTA_FacturasCabecera_Final.situacionPago.Value)
|
|
: new SqlParameter("@situacionPago", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.observaciones!=null
|
|
? new SqlParameter("@observaciones", mdl_VTA_FacturasCabecera_Final.observaciones)
|
|
: new SqlParameter("@observaciones", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.idClaveAnalitica!=null
|
|
? new SqlParameter("@idClaveAnalitica", mdl_VTA_FacturasCabecera_Final.idClaveAnalitica.Value)
|
|
: new SqlParameter("@idClaveAnalitica", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.aplicarRetencion!=null
|
|
? new SqlParameter("@aplicarRetencion", mdl_VTA_FacturasCabecera_Final.aplicarRetencion.Value)
|
|
: new SqlParameter("@aplicarRetencion", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.noDeclararModelosOficiales!=null
|
|
? new SqlParameter("@noDeclararModelosOficiales", mdl_VTA_FacturasCabecera_Final.noDeclararModelosOficiales.Value)
|
|
: new SqlParameter("@noDeclararModelosOficiales", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.criterioCaja!=null
|
|
? new SqlParameter("@criterioCaja", mdl_VTA_FacturasCabecera_Final.criterioCaja.Value)
|
|
: new SqlParameter("@criterioCaja", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.retencion_Porcentaje!=null
|
|
? new SqlParameter("@retencion_Porcentaje", mdl_VTA_FacturasCabecera_Final.retencion_Porcentaje.Value)
|
|
: new SqlParameter("@retencion_Porcentaje", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.retencion_Valor!=null
|
|
? new SqlParameter("@retencion_Valor", mdl_VTA_FacturasCabecera_Final.retencion_Valor.Value)
|
|
: new SqlParameter("@retencion_Valor", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.retencion_Base!=null
|
|
? new SqlParameter("@retencion_Base", mdl_VTA_FacturasCabecera_Final.retencion_Base.Value)
|
|
: new SqlParameter("@retencion_Base", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_bruto!=null
|
|
? new SqlParameter("@total_bruto", mdl_VTA_FacturasCabecera_Final.total_bruto)
|
|
: new SqlParameter("@total_bruto", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_descuentoProntoPago!=null
|
|
? new SqlParameter("@total_descuentoProntoPago", mdl_VTA_FacturasCabecera_Final.total_descuentoProntoPago)
|
|
: new SqlParameter("@total_descuentoProntoPago", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_descuentoFinalFactura!=null
|
|
? new SqlParameter("@total_descuentoFinalFactura", mdl_VTA_FacturasCabecera_Final.total_descuentoFinalFactura)
|
|
: new SqlParameter("@total_descuentoFinalFactura", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_baseImponible!=null
|
|
? new SqlParameter("@total_baseImponible", mdl_VTA_FacturasCabecera_Final.total_baseImponible)
|
|
: new SqlParameter("@total_baseImponible", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_impuesto!=null
|
|
? new SqlParameter("@total_impuesto", mdl_VTA_FacturasCabecera_Final.total_impuesto)
|
|
: new SqlParameter("@total_impuesto", DBNull.Value),
|
|
mdl_VTA_FacturasCabecera_Final.total_recargo!=null
|
|
? new SqlParameter("@total_recargo", mdl_VTA_FacturasCabecera_Final.total_recargo)
|
|
: new SqlParameter("@total_recargo", DBNull.Value),
|
|
new SqlParameter("@total", mdl_VTA_FacturasCabecera_Final.total),
|
|
mdl_VTA_FacturasCabecera_Final.total_retencion!=null
|
|
? new SqlParameter("@total_retencion", mdl_VTA_FacturasCabecera_Final.total_retencion)
|
|
: new SqlParameter("@total_retencion", DBNull.Value),
|
|
new SqlParameter("@total_Final", mdl_VTA_FacturasCabecera_Final.total_Final)
|
|
};
|
|
#endregion
|
|
|
|
//Id de la tabla
|
|
mdl_INTERNO_ValorDevuelto_Modelo.Id = obj_Exferia_Entities.Database.SqlQuery<long>(str_SQL_Insert, arr_Parametros_Insert).Single();
|
|
|
|
#region TABLAS RELACIONADAS
|
|
//ANEXOS
|
|
if (_mdl_VTA_FacturasCabecera_AGrabar.VTA_FacturasCabecera_Anexos != null && _mdl_VTA_FacturasCabecera_AGrabar.VTA_FacturasCabecera_Anexos.Count > 0)
|
|
{
|
|
VTA_FacturasCabecera_Anexos_Datos obj_VTA_FacturasCabecera_Anexos_Datos = new VTA_FacturasCabecera_Anexos_Datos();
|
|
|
|
foreach (VTA_FacturasCabecera_Anexos mdl_VTA_FacturasCabecera_Anexos in _mdl_VTA_FacturasCabecera_AGrabar.VTA_FacturasCabecera_Anexos)
|
|
{
|
|
//Añadir el idFacturaCabecera
|
|
mdl_VTA_FacturasCabecera_Anexos.idFacturaCabecera = mdl_INTERNO_ValorDevuelto_Modelo.Id;
|
|
|
|
//Insertar
|
|
obj_VTA_FacturasCabecera_Anexos_Datos.Insertar(mdl_VTA_FacturasCabecera_Anexos);
|
|
}
|
|
}
|
|
|
|
//DATOS VIAJE
|
|
if (_mdl_VTA_FacturasCabecera_AGrabar.VTA_FacturasCabecera_DatosViaje != null && _mdl_VTA_FacturasCabecera_AGrabar.VTA_FacturasCabecera_DatosViaje.Count > 0)
|
|
{
|
|
VTA_FacturasCabecera_DatosViaje_Datos obj_VTA_FacturasCabecera_DatosViaje_Datos = new VTA_FacturasCabecera_DatosViaje_Datos();
|
|
|
|
foreach (VTA_FacturasCabecera_DatosViaje mdl_VTA_FacturasCabecera_DatosViaje in _mdl_VTA_FacturasCabecera_AGrabar.VTA_FacturasCabecera_DatosViaje)
|
|
{
|
|
//Añadir el idFacturaCabecera
|
|
mdl_VTA_FacturasCabecera_DatosViaje.idFacturaCabecera = mdl_INTERNO_ValorDevuelto_Modelo.Id;
|
|
|
|
//Insertar
|
|
obj_VTA_FacturasCabecera_DatosViaje_Datos.Insertar(mdl_VTA_FacturasCabecera_DatosViaje);
|
|
}
|
|
}
|
|
|
|
//RESUMEN
|
|
if (_mdl_VTA_FacturasCabecera_AGrabar.VTA_FacturasCabecera_Resumen != null && _mdl_VTA_FacturasCabecera_AGrabar.VTA_FacturasCabecera_Resumen.Count > 0)
|
|
{
|
|
VTA_FacturasCabecera_Resumen_Datos obj_VTA_FacturasCabecera_Resumen_Datos = new VTA_FacturasCabecera_Resumen_Datos();
|
|
|
|
foreach (VTA_FacturasCabecera_Resumen mdl_VTA_FacturasCabecera_Resumen in _mdl_VTA_FacturasCabecera_AGrabar.VTA_FacturasCabecera_Resumen)
|
|
{
|
|
//Añadir el idFacturaCabecera
|
|
mdl_VTA_FacturasCabecera_Resumen.idFacturaCabecera = mdl_INTERNO_ValorDevuelto_Modelo.Id;
|
|
|
|
//Insertar
|
|
obj_VTA_FacturasCabecera_Resumen_Datos.Insertar_Final(mdl_VTA_FacturasCabecera_Resumen);
|
|
}
|
|
}
|
|
|
|
//LINEAS
|
|
if (_mdl_VTA_FacturasCabecera_AGrabar.VTA_AlbaranesFacturasLineas != null && _mdl_VTA_FacturasCabecera_AGrabar.VTA_AlbaranesFacturasLineas.Count > 0)
|
|
{
|
|
VTA_AlbaranesFacturasLineas_Datos obj_VTA_AlbaranesFacturasLineas_Datos = new VTA_AlbaranesFacturasLineas_Datos();
|
|
|
|
foreach (VTA_AlbaranesFacturasLineas mdl_VTA_AlbaranesFacturasLineas in _mdl_VTA_FacturasCabecera_AGrabar.VTA_AlbaranesFacturasLineas)
|
|
{
|
|
//Añadir el idFacturaCabecera
|
|
mdl_VTA_AlbaranesFacturasLineas.idFacturaCabecera = mdl_INTERNO_ValorDevuelto_Modelo.Id;
|
|
|
|
//Insertar
|
|
obj_VTA_AlbaranesFacturasLineas_Datos.Insertar(_mdl_VTA_FacturasCabecera_AGrabar, null, mdl_VTA_AlbaranesFacturasLineas);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Insertar), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
|
|
public INTERNO_ValorDevuelto_Modelo Actualizar_Estado(long _lng_id, string _str_Estado)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL_Update =
|
|
" UPDATE " + nameof(VTA_FacturasCabecera) +
|
|
" set " + nameof(VTA_FacturasCabecera.estado) + "='" + _str_Estado + "' " +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.id) + "=" + _lng_id;
|
|
|
|
obj_Exferia_Entities.Database.ExecuteSqlCommand(str_SQL_Update);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Actualizar_Estado), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
public INTERNO_ValorDevuelto_Modelo Actualizar_Fecha(long _lng_id, DateTime _dtt_Fecha)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL_Update =
|
|
" UPDATE " + nameof(VTA_FacturasCabecera) +
|
|
" set " +
|
|
nameof(VTA_FacturasCabecera.fecha) + "='" + _dtt_Fecha.ToString("dd/MM/yyyy") + "' " +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.id) + "=" + _lng_id;
|
|
|
|
obj_Exferia_Entities.Database.ExecuteSqlCommand(str_SQL_Update);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Actualizar_Fecha), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
public INTERNO_ValorDevuelto_Modelo Actualizar_VariosCampos(long _lng_id,
|
|
long _lng_idCliente,
|
|
long _lng_idImpuestoCabecera,
|
|
long? _lng_idMoneda,
|
|
long? _lng_idVendedorPreventaHabitual,
|
|
DateTime _dtt_Fecha,
|
|
decimal _dcm_DescuentoProntoPago,
|
|
decimal _dcm_DescuentoFinalFactura,
|
|
bool _bol_Recargo)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL_Update =
|
|
" UPDATE " + nameof(VTA_FacturasCabecera) +
|
|
" set " + nameof(VTA_FacturasCabecera.descuentoProntoPago) + "=" + _dcm_DescuentoProntoPago.ToString().Replace(",", ".") + ", " +
|
|
nameof(VTA_FacturasCabecera.descuentoFinalFactura) + "=" + _dcm_DescuentoFinalFactura.ToString().Replace(",", ".") + ", " +
|
|
nameof(VTA_FacturasCabecera.idCliente) + "=" + _lng_idCliente + ", " +
|
|
nameof(VTA_FacturasCabecera.idImpuestoCabecera) + "=" + _lng_idImpuestoCabecera + ", " +
|
|
nameof(VTA_FacturasCabecera.idMoneda) + "=" + (_lng_idMoneda != null ? _lng_idMoneda.Value.ToString() : " NULL ") + ", " +
|
|
nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + "=" + (_lng_idVendedorPreventaHabitual != null ? _lng_idVendedorPreventaHabitual.Value.ToString() : " NULL ") + ", " +
|
|
nameof(VTA_FacturasCabecera.recargo) + "=" + (_bol_Recargo ? "1" : "0") + ", " +
|
|
nameof(VTA_FacturasCabecera.fecha) + "='" + _dtt_Fecha + "' " +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.id) + "=" + _lng_id;
|
|
|
|
obj_Exferia_Entities.Database.ExecuteSqlCommand(str_SQL_Update);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Actualizar_VariosCampos), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
|
|
public INTERNO_ValorDevuelto_Modelo Actualizar_Totales(long _lng_id,
|
|
decimal _dcm_total_bruto,
|
|
decimal _dcm_total_descuentoProntoPago,
|
|
decimal _dcm_total_descuentoFinalFactura,
|
|
decimal _dcm_total_baseImponible,
|
|
decimal _dcm_total_impuesto,
|
|
decimal _dcm_total_recargo,
|
|
decimal _dcm_total,
|
|
decimal _dcm_total_retencion,
|
|
decimal _dcm_total_Final)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
|
|
string str_SQL_Update =
|
|
" UPDATE " + nameof(VTA_FacturasCabecera) +
|
|
" set " + nameof(VTA_FacturasCabecera.total_bruto) + "=" + _dcm_total_bruto.ToString().Replace(",", ".") + ", " +
|
|
nameof(VTA_FacturasCabecera.total_descuentoProntoPago) + "=" + _dcm_total_descuentoProntoPago.ToString().Replace(",", ".") + ", " +
|
|
nameof(VTA_FacturasCabecera.total_descuentoFinalFactura) + "=" + _dcm_total_descuentoFinalFactura.ToString().Replace(",", ".") + ", " +
|
|
nameof(VTA_FacturasCabecera.total_baseImponible) + "=" + _dcm_total_baseImponible.ToString().Replace(",", ".") + ", " +
|
|
nameof(VTA_FacturasCabecera.total_impuesto) + "=" + _dcm_total_impuesto.ToString().Replace(",", ".") + ", " +
|
|
nameof(VTA_FacturasCabecera.total_recargo) + "=" + _dcm_total_recargo.ToString().Replace(",", ".") + ", " +
|
|
nameof(VTA_FacturasCabecera.total) + "=" + _dcm_total.ToString().Replace(",", ".") + ", " +
|
|
nameof(VTA_FacturasCabecera.total_retencion) + "=" + _dcm_total_retencion.ToString().Replace(",", ".") + ", " +
|
|
nameof(VTA_FacturasCabecera.total_Final) + "=" + _dcm_total_Final.ToString().Replace(",", ".") +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.id) + "=" + _lng_id;
|
|
|
|
obj_Exferia_Entities.Database.ExecuteSqlCommand(str_SQL_Update);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Actualizar_Totales), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
|
|
|
|
|
|
public INTERNO_ValorDevuelto_Modelo Actualizar_Otros(long _lng_id,
|
|
long _lng_idMoneda,
|
|
long? _lng_idEmpleado,
|
|
long? _lng_idVendedor_Preventa,
|
|
long? _lng_idVendedor_PreventaHabitual,
|
|
long? _lng_idVendedor_Repartidor,
|
|
long? _lng_idVendedor_Cobrador,
|
|
long? _lng_idVendedor_CobradorHabitual,
|
|
long? _lng_idVendedor_Autoventa,
|
|
string _str_referencia)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
|
|
string str_SQL_Update =
|
|
" UPDATE " + nameof(VTA_FacturasCabecera) +
|
|
" set " + nameof(VTA_FacturasCabecera.idMoneda) + "= @idMoneda," +
|
|
nameof(VTA_FacturasCabecera.idEmpleado) + "= @idEmpleado," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Preventa) + "= @idVendedor_Preventa," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_PreventaHabitual) + "= @idVendedor_PreventaHabitual," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Repartidor) + "= @idVendedor_Repartidor," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Cobrador) + "= @idVendedor_Cobrador," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_CobradorHabitual) + "= @idVendedor_CobradorHabitual," +
|
|
nameof(VTA_FacturasCabecera.idVendedor_Autoventa) + "= @idVendedor_Autoventa," +
|
|
nameof(VTA_FacturasCabecera.referencia) + "= @referencia" +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.id) + "=@id";
|
|
|
|
//Parametros
|
|
object[] arr_Parametros_Update = new object[]
|
|
{
|
|
new SqlParameter("@idMoneda", _lng_idMoneda),
|
|
_lng_idEmpleado != null
|
|
? new SqlParameter("@idEmpleado", _lng_idEmpleado.Value)
|
|
: new SqlParameter("@idEmpleado", DBNull.Value),
|
|
_lng_idVendedor_Preventa != null
|
|
? new SqlParameter("@idVendedor_Preventa", _lng_idVendedor_Preventa.Value)
|
|
: new SqlParameter("@idVendedor_Preventa", DBNull.Value),
|
|
_lng_idVendedor_PreventaHabitual != null
|
|
? new SqlParameter("@idVendedor_PreventaHabitual", _lng_idVendedor_PreventaHabitual.Value)
|
|
: new SqlParameter("@idVendedor_PreventaHabitual", DBNull.Value),
|
|
_lng_idVendedor_Repartidor != null
|
|
? new SqlParameter("@idVendedor_Repartidor", _lng_idVendedor_Repartidor.Value)
|
|
: new SqlParameter("@idVendedor_Repartidor", DBNull.Value),
|
|
_lng_idVendedor_Cobrador != null
|
|
? new SqlParameter("@idVendedor_Cobrador", _lng_idVendedor_Cobrador.Value)
|
|
: new SqlParameter("@idVendedor_Cobrador", DBNull.Value),
|
|
_lng_idVendedor_CobradorHabitual != null
|
|
? new SqlParameter("@idVendedor_CobradorHabitual", _lng_idVendedor_CobradorHabitual.Value)
|
|
: new SqlParameter("@idVendedor_CobradorHabitual", DBNull.Value),
|
|
_lng_idVendedor_Autoventa != null
|
|
? new SqlParameter("@idVendedor_Autoventa", _lng_idVendedor_Autoventa.Value)
|
|
: new SqlParameter("@idVendedor_Autoventa", DBNull.Value),
|
|
_str_referencia != null
|
|
? new SqlParameter("@referencia", _str_referencia)
|
|
: new SqlParameter("@referencia", DBNull.Value),
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
|
|
obj_Exferia_Entities.Database.ExecuteSqlCommand(str_SQL_Update, arr_Parametros_Update);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Actualizar_Otros), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
|
|
public INTERNO_ValorDevuelto_Modelo Actualizar_Observaciones(long _lng_id,
|
|
string _str_observaciones)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
|
|
string str_SQL_Update =
|
|
" UPDATE " + nameof(VTA_FacturasCabecera) +
|
|
" set " + nameof(VTA_FacturasCabecera.observaciones) + "= @observaciones" +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.id) + "=@id";
|
|
|
|
//Parametros
|
|
object[] arr_Parametros_Update = new object[]
|
|
{
|
|
_str_observaciones != null
|
|
? new SqlParameter("@observaciones", _str_observaciones)
|
|
: new SqlParameter("@observaciones", DBNull.Value),
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
|
|
obj_Exferia_Entities.Database.ExecuteSqlCommand(str_SQL_Update, arr_Parametros_Update);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Actualizar_Observaciones), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
|
|
public INTERNO_ValorDevuelto_Modelo Actualizar_Delegacion(long _lng_id, long _lng_idDelegacion)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL_Update =
|
|
" UPDATE " + nameof(VTA_FacturasCabecera) +
|
|
" set " +
|
|
nameof(VTA_FacturasCabecera.idDelegacion) + "=" + _lng_idDelegacion +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.id) + "=" + _lng_id;
|
|
|
|
obj_Exferia_Entities.Database.ExecuteSqlCommand(str_SQL_Update);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Actualizar_Delegacion), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
|
|
public INTERNO_ValorDevuelto_Modelo Actualizar_SituacionPago(long? _lng_idFacturaCabecera, long? _lng_idVencimiento, long? _lng_idCobro, long? _lng_idDevolucion)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
VTA_Cobros_Datos obj_VTA_Cobros_Datos = new VTA_Cobros_Datos();
|
|
VTA_DevolucionesCobros_Datos obj_VTA_DevolucionesCobros_Datos = new VTA_DevolucionesCobros_Datos();
|
|
|
|
#region Obtener el idFacturaCabecera
|
|
long lng_id = -1;
|
|
|
|
//facturaCabcera
|
|
if (_lng_idFacturaCabecera != null)
|
|
{
|
|
lng_id = _lng_idFacturaCabecera.Value;
|
|
}
|
|
//Vencimiento
|
|
else if (_lng_idVencimiento != null)
|
|
{
|
|
VTA_Vencimientos_Datos obj_VTA_Vencimientos_Datos = new VTA_Vencimientos_Datos();
|
|
lng_id = obj_VTA_Vencimientos_Datos.Obtener_IdFacturaCabecera(_lng_idVencimiento.Value);
|
|
}
|
|
//Cobro
|
|
else if (_lng_idCobro != null)
|
|
{
|
|
lng_id = obj_VTA_Cobros_Datos.Obtener_IdFacturaCabecera(_lng_idCobro.Value);
|
|
}
|
|
//Devolucion
|
|
else if (_lng_idDevolucion != null)
|
|
{
|
|
lng_id = obj_VTA_DevolucionesCobros_Datos.Obtener_IdFacturaCabecera(_lng_idDevolucion.Value);
|
|
}
|
|
#endregion
|
|
|
|
//Obtener Total Factura
|
|
decimal dm_Total_Factura = Obtener_Total(lng_id);
|
|
|
|
//Obtener Total Cobros
|
|
decimal dcm_Cobros = obj_VTA_Cobros_Datos.Obtener_ImporteTotal_Por_FacturaCabecera(lng_id);
|
|
|
|
//Obtener Total Devoluciones
|
|
decimal dcm_Devoluciones = obj_VTA_DevolucionesCobros_Datos.Obtener_ImporteTotal_Por_FacturaCabecera(lng_id);
|
|
|
|
int int_SituacionPago = int.Parse(Variables.G_MDL_TIPOSITUACIONPAGO_FACTURA_PENDIENTE.Codigo);
|
|
if ((dcm_Cobros - dcm_Devoluciones) != 0m)
|
|
{
|
|
//Total pagado
|
|
if (dm_Total_Factura == (dcm_Cobros - dcm_Devoluciones))
|
|
{
|
|
int_SituacionPago = int.Parse(Variables.G_MDL_TIPOSITUACIONPAGO_FACTURA_PAGADO.Codigo);
|
|
}
|
|
//Parte pendiente
|
|
else if (dm_Total_Factura != (dcm_Cobros - dcm_Devoluciones))
|
|
{
|
|
int_SituacionPago = int.Parse(Variables.G_MDL_TIPOSITUACIONPAGO_FACTURA_PARTEPENDIENTE.Codigo);
|
|
}
|
|
}
|
|
|
|
string str_SQL_Update =
|
|
" UPDATE " + nameof(VTA_FacturasCabecera) +
|
|
" set " +
|
|
nameof(VTA_FacturasCabecera.situacionPago) + "=" + int_SituacionPago +
|
|
" WHERE " + nameof(VTA_FacturasCabecera.id) + "=" + lng_id;
|
|
|
|
obj_Exferia_Entities.Database.ExecuteSqlCommand(str_SQL_Update);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Actualizar_SituacionPago), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
#endregion
|
|
|
|
#region Borrar
|
|
public override INTERNO_ValorDevuelto_Modelo Borrar(long _lng_id)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
|
|
INTERNO_ValorDevuelto_Modelo mdl_INTERNO_ValorDevuelto_Modelo = new INTERNO_ValorDevuelto_Modelo();
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TodoCorrecto = true;
|
|
//Tipo de Accion que se va a realizar
|
|
mdl_INTERNO_ValorDevuelto_Modelo.TipoAccion = G_ENUM_TIPOACCION.INT_ELIMINAR;
|
|
|
|
VTA_AlbaranesFacturasLineas_Datos obj_VTA_AlbaranesFacturasLineas_Datos = new VTA_AlbaranesFacturasLineas_Datos();
|
|
VTA_AlbaranesCabecera_Datos obj_VTA_AlbaranesCabecera_Datos = new VTA_AlbaranesCabecera_Datos();
|
|
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
// Ver si existe ######################################################################
|
|
VTA_FacturasCabecera mdl_VTA_FacturasCabecera_Final = Obtener_Modelo_Por_Id(_lng_id, false, false, false, false);
|
|
//######################################################################################
|
|
|
|
//Buscar idsPedidosLinea
|
|
List<long> lst_idsFacturaCabecera = new List<long>();
|
|
lst_idsFacturaCabecera.Add(_lng_id);
|
|
List<long> lst_idsPedidoLinea_Relacionados = obj_VTA_AlbaranesFacturasLineas_Datos.Obtener_IdsPedidoLinea_PorListado_Factura(lst_idsFacturaCabecera);
|
|
|
|
if (mdl_VTA_FacturasCabecera_Final != null)
|
|
{
|
|
// Se graba la fecha de baja
|
|
#region Update
|
|
string str_SQL_Update = " UPDATE " + nameof(VTA_FacturasCabecera) +
|
|
" SET " +
|
|
nameof(VTA_FacturasCabecera.fechaBorrado) + "=@fechaBorrado " +
|
|
" WHERE " +
|
|
nameof(VTA_FacturasCabecera.id) + "=@id";
|
|
//Parametros
|
|
object[] arr_Parametros_Update = new object[]
|
|
{
|
|
new SqlParameter("@fechaBorrado", DateTime.Now),
|
|
new SqlParameter("@id", _lng_id)
|
|
};
|
|
#endregion
|
|
|
|
//Update
|
|
obj_Exferia_Entities.Database.ExecuteSqlCommand(str_SQL_Update, arr_Parametros_Update);
|
|
|
|
//Quitar el idFacturaCabecera de la tabla de VTA_AlbaranesFacturasLineas
|
|
obj_VTA_AlbaranesFacturasLineas_Datos.Quitar_IdFacturaCabecera(_lng_id, mdl_VTA_FacturasCabecera_Final.fecha, mdl_VTA_FacturasCabecera_Final.idDelegacion);
|
|
|
|
//Quitar el idFacturaCabecera de la tabla de VTA_AlbaranesCabecera
|
|
obj_VTA_AlbaranesCabecera_Datos.Quitar_IdFacturaCabecera(_lng_id);
|
|
|
|
//Quitar el IdAlbaranCabecera de la tabla de MYT_Partes
|
|
Assembly m_assembly_1 = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_MYTHOS + ".dll");
|
|
//Obtenemos el tipo de la clase
|
|
Type m_type_1 = m_assembly_1.GetType("" + Variables.G_STR_LIBRERIA_MYTHOS + "." + Variables.G_STR_LIBRERIA_DATOSMYTHOS);
|
|
//creamos la instancia
|
|
var obj_Clase_1 = Activator.CreateInstance(m_type_1);
|
|
//Cargamos el metodo solicitado
|
|
MethodInfo obj_MethodInfo_1 = obj_Clase_1.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSMYTHOS_PROCEDIMIENTO_MYTPARTES_QUITAR_FACTURACABECERA, BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
//Obtener valores
|
|
object[] arr_Parametros_1 = { _lng_id };
|
|
|
|
//Pasamos los parametros al metodo y lo ejecutamos
|
|
mdl_INTERNO_ValorDevuelto_Modelo = (INTERNO_ValorDevuelto_Modelo)obj_MethodInfo_1.Invoke(obj_Clase_1, arr_Parametros_1);
|
|
//########################################################################################################################################################################
|
|
|
|
//Recalcular Situacion pedido si fuese necesario
|
|
INTERNO_ValorDevuelto_Modelo mdl_ValorDevuelto_Modelo_Auxiliar = Funciones_Ventas.Recalcular_Situacion_Pedidos_AlbaranFactura(lst_idsPedidoLinea_Relacionados, null, null, null);
|
|
if (mdl_ValorDevuelto_Modelo_Auxiliar.TodoCorrecto == false)
|
|
{
|
|
mdl_INTERNO_ValorDevuelto_Modelo = mdl_ValorDevuelto_Modelo_Auxiliar;
|
|
}
|
|
|
|
//Grabar un registro de trazabilidad con los datos de la transaccion realizada.
|
|
Datos_Generales.USR_Trazabilidad_Grabar(typeof(VTA_FacturasCabecera), null, mdl_VTA_FacturasCabecera_Final, G_ENUM_TIPOACCION.INT_ELIMINAR, obj_Exferia_Entities);
|
|
|
|
}
|
|
|
|
// Devolver también el Objeto
|
|
mdl_INTERNO_ValorDevuelto_Modelo.Id = _lng_id;
|
|
|
|
}
|
|
catch (Control_Errores)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(Borrar), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
|
|
return mdl_INTERNO_ValorDevuelto_Modelo;
|
|
}
|
|
public override INTERNO_ValorDevuelto_Modelo Borrar(long _lng_id, long _lng_idAuxiliar)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
public override INTERNO_ValorDevuelto_Modelo Borrar(object _mdl_obj)
|
|
{
|
|
return null;
|
|
}
|
|
#endregion
|
|
|
|
public List<INTERNO_ResultadoDeclaracion> ObtenerDeclaracionClientes(DateTime dtm_FechaDesde, DateTime dtm_FechaHasta)
|
|
{
|
|
Exferia_Entities obj_Exferia_Entities = null;
|
|
try
|
|
{
|
|
obj_Exferia_Entities = new Exferia_Entities();
|
|
obj_Exferia_Entities.Configuration.LazyLoadingEnabled = false;
|
|
|
|
string str_SQL = $@"
|
|
SELECT
|
|
c.{nameof(MAE_Clientes.id)} as idCliente
|
|
, c.{nameof(MAE_Clientes.cif)}
|
|
, fc.{nameof(VTA_FacturasCabecera.total_Final)} as totalFinal
|
|
, fc.{nameof(VTA_FacturasCabecera.fecha)}
|
|
, pro.{nameof(GEN_Provincias.codigo)} as codigoProvincia
|
|
, pa.{nameof(GEN_Paises.codigo_ISO2D)} as codigoPais
|
|
FROM
|
|
{nameof(VTA_FacturasCabecera)} as fc
|
|
LEFT JOIN {nameof(MAE_Clientes)} as c ON fc.{nameof(VTA_FacturasCabecera.idCliente)} = c.{nameof(VTA_FacturasCabecera.id)}
|
|
LEFT JOIN {nameof(GEN_Direcciones)} as dir ON dir.{nameof(GEN_Direcciones.idCliente)} = c.{nameof(MAE_Clientes.id)}
|
|
LEFT JOIN {nameof(GEN_Paises)} as pa ON dir.{nameof(GEN_Direcciones.idPais)} = pa.{nameof(GEN_Paises.id)}
|
|
LEFT JOIN {nameof(GEN_Provincias)} as pro ON dir.{nameof(GEN_Direcciones.idProvincia)} = pro.{nameof(GEN_Provincias.id)}
|
|
WHERE
|
|
fc.{nameof(VTA_FacturasCabecera.fecha)} BETWEEN @fechaDesde AND @fechaHasta
|
|
AND dir.tipoDireccion = 2";
|
|
object[] arr_Parametros = new object[]
|
|
{
|
|
new SqlParameter("@fechaDesde", dtm_FechaDesde),
|
|
new SqlParameter("@fechaHasta", dtm_FechaHasta),
|
|
};
|
|
|
|
return obj_Exferia_Entities.Database.SqlQuery<INTERNO_ResultadoDeclaracion>(str_SQL, arr_Parametros)?.ToList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Control_Errores("", ex, nameof(VTA_FacturasCabecera_Datos) + "/" + nameof(ObtenerDeclaracionClientes), true);
|
|
}
|
|
finally
|
|
{
|
|
obj_Exferia_Entities.Database.Connection.Close();
|
|
obj_Exferia_Entities.Dispose();
|
|
}
|
|
}
|
|
|
|
#region Clases Internas
|
|
internal class INTERNA_SQLQUERY_COBROS
|
|
{
|
|
public long id { get; set; }
|
|
public long idVencimiento { get; set; }
|
|
public long codigo { get; set; }
|
|
public decimal importe { get; set; }
|
|
}
|
|
internal class INTERNA_SQLQUERY_DEVOLUCIONESCOBROS
|
|
{
|
|
public long id { get; set; }
|
|
public long idVencimiento { get; set; }
|
|
public decimal importe { get; set; }
|
|
}
|
|
#endregion
|
|
}
|
|
} |