2 using System.Collections.Generic;
3 using System.ComponentModel;
17 using Sage.
ES.Verifactu.Interfaces.Entities.ComModel.V1_0;
28 #region PROPIEDADES PROTECTED 30 protected String _cUsuario =
"";
31 protected String _cEmpresa =
"";
32 protected String _cEjercicio =
"";
33 protected String _cNumero =
"";
34 protected String _cNumeroLoad =
"";
35 protected String _cLetra =
"";
37 protected String _cTBAI =
"";
38 protected String _cQRTBAI =
"";
39 protected DateTime? _dHora = null;
41 protected string _cFirma =
string.Empty, _cHuella =
string.Empty, _cHuella_Ant =
string.Empty, _cBorrador =
string.Empty, _cNSerie =
string.Empty;
42 protected int _nSistema = 0, _nTerritorio = 0, _nEstado = 0, _nAnulado = 0, _nTipoEnvio=0;
44 protected List<RegistroCertificacion> lstRegistrosCertificacion = null;
45 protected bool _lCertificadaTercerosNoEnviada =
false;
46 protected decimal _nBase = 0;
47 protected decimal _nTotaldoc = 0;
48 protected string _cCliente =
string.Empty;
49 protected DateTime? _dFecha_fac = null;
51 protected string _cQRVERIFAC =
"";
52 protected string _cTerminal =
"";
53 protected string _cHusoHora =
"";
54 protected string _cFicheroXML =
"";
55 protected string _cCSV =
"";
56 protected DateTime _dFechaRegistro = DateTime.MinValue;
57 protected string _cGuid_id =
"";
58 protected string _cGuid_Emp =
"";
59 protected string _cDivisa =
"";
60 protected decimal _nTotaldiv = 0;
68 #endregion PROPIEDADES PROTECTED 76 ValoresConfiguracion();
78 #endregion Constructor 80 #region PROPIEDADES PÚBLICAS 85 public String _Usuario
89 if (
string.IsNullOrWhiteSpace(_cUsuario))
90 _cUsuario = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_usuario")) +
"_NET";
103 public String _Empresa
118 public String _Ejercicio
122 if (
string.IsNullOrWhiteSpace(_cEjercicio))
123 _cEjercicio = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_any"));
136 public String _Numero
170 return _oTipoDocumentoCertificar;
174 _oTipoDocumentoCertificar = value;
212 public string _QRTBAI
228 public DateTime? _Hora
230 get {
return _dHora; }
231 set { _dHora = value; }
237 public string _Borrador
239 get {
return _cBorrador; }
240 set { _cBorrador = value; }
248 get {
return _nSistema; }
249 set { _nSistema = value; }
255 public int _Territorio
257 get {
return _nTerritorio; }
258 set { _nTerritorio = value; }
266 get {
return _cFirma; }
267 set { _cFirma = value; }
273 public string _Huella
275 get {
return _cHuella; }
279 _HuellaDetalle = FunctionsFactuCert._HuellaDeserializar(value);
286 public string _Huella_Ant
288 get {
return _cHuella_Ant; }
291 _cHuella_Ant = value;
292 _HuellaAntDetalle = FunctionsFactuCert._HuellaDeserializar(value);
302 get {
return _nEstado; }
303 set { _nEstado = value; }
309 public string _NSerie
311 get {
return _cNSerie; }
312 set { _cNSerie = value; }
321 get {
return _oHuellaDetalle; }
322 set { _oHuellaDetalle = value; }
330 get {
return _oHuellaAntDetalle; }
331 set { _oHuellaAntDetalle = value; }
345 get {
return _nAnulado; }
346 set { _nAnulado = value; }
352 public int _TipoEnvio
354 get {
return _nTipoEnvio; }
355 set { _nTipoEnvio = value; }
362 public String _MensajeError
366 return _cMensajeError;
370 _cMensajeError = value;
377 public List<RegistroCertificacion> _RegistrosCertificacion
381 if (lstRegistrosCertificacion == null)
382 LoadRegistrosCertificacion();
384 return lstRegistrosCertificacion;
391 public bool _CertificadaTercerosNoEnviada
393 get {
return _lCertificadaTercerosNoEnviada; }
394 set { _lCertificadaTercerosNoEnviada = value; }
415 public decimal _TotalDocumento
430 public string _Divisa
445 public decimal _TotalDivisa
460 public string _Cliente
472 public string _NombreCliente
476 return Convert.ToString(DB.SQLValor(
"CLIENTES",
"CODIGO", _Cliente,
"NOMBRE"));
483 public DateTime? _Fecha_fac
498 public string _Terminal
502 return Convert.ToString(EW_GLOBAL._GetVariable(
"wc_terminal"));
513 public string _HusoHora
517 string lchuso = TimeZoneInfo.Local.BaseUtcOffset.ToString();
518 int lnPosFin = lchuso.LastIndexOf(
":");
520 if (!
string.IsNullOrEmpty(lchuso) && lnPosFin > 0)
522 _cHusoHora = lchuso.Substring(0, lnPosFin);
524 if (!_cHusoHora.Contains(
"-"))
526 _cHusoHora =
"+" + _cHusoHora;
540 public string _FicheroXML
548 _cFicheroXML = value;
571 public DateTime _FechaRegistro
575 return _dFechaRegistro;
579 _dFechaRegistro = value;
586 public string _QRVERIFAC
601 public string _Guid_id
616 public string _Guid_Emp
628 #endregion PROPIEDADES PÚBLICAS 630 #region METODOS PROTECTED 631 protected void _Load(DataRow tdrDocumento)
637 _Usuario = Convert.ToString(tdrDocumento[
"usuario"]);
638 _Empresa = Convert.ToString(tdrDocumento[
"empresa"]);
639 _Ejercicio = Convert.ToString(tdrDocumento[
"ejercicio"]);
640 _Numero = Convert.ToString(tdrDocumento[
"numero"]);
641 _cBorrador = Convert.ToString(tdrDocumento[
"borrador"]);
642 _nSistema = Convert.ToInt16(tdrDocumento[
"sistema"]);
643 _nTerritorio = Convert.ToInt16(tdrDocumento[
"territorio"]);
649 _TBAI = Convert.ToString(tdrDocumento[
"tbai"]);
650 _QRTBAI = Convert.ToString(tdrDocumento[
"qr_tbai"]);
651 _cFirma = Convert.ToString(tdrDocumento[
"firma"]);
652 _cHuella = Convert.ToString(tdrDocumento[
"huella"]);
653 _nEstado = Convert.ToInt32(tdrDocumento[
"estado"]);
654 _nAnulado = Convert.ToInt32(tdrDocumento[
"anulado"]);
655 _nTipoEnvio = Convert.ToInt32(tdrDocumento[
"tipoenvio"]);
656 _cHuella_Ant = Convert.ToString(tdrDocumento[
"huella_ant"]);
658 if (tdrDocumento[
"hora"] == DBNull.Value)
661 _dHora = Convert.ToDateTime(tdrDocumento[
"hora"]);
663 _cNSerie = Convert.ToString(tdrDocumento[
"n_serie"]);
664 _oHuellaDetalle = FunctionsFactuCert._HuellaDeserializar(_cHuella);
665 _oHuellaAntDetalle = FunctionsFactuCert._HuellaDeserializar(_cHuella_Ant);
666 _lCertificadaTercerosNoEnviada = Convert.ToBoolean(tdrDocumento[
"ter_no_env"]);
668 _nBase = Convert.ToDecimal(tdrDocumento[
"base"]);
669 _nTotaldoc = Convert.ToDecimal(tdrDocumento[
"totaldoc"]);
670 _cCliente = Convert.ToString(tdrDocumento[
"cliente"]);
672 if (tdrDocumento[
"fecha_fac"] == DBNull.Value)
675 _dFecha_fac = Convert.ToDateTime(tdrDocumento[
"fecha_fac"]);
677 _cHusoHora = Convert.ToString(tdrDocumento[
"husohora"]);
678 _cQRVERIFAC = Convert.ToString(tdrDocumento[
"qr_verifac"]);
679 _cTerminal = Convert.ToString(tdrDocumento[
"terminal"]);
690 _cBorrador = NumeroBorrador();
692 bool llCambio = (_NumeroUpdate() != _Numero);
697 string lcSql =
" USUARIO = " + DB.SQLString(_Usuario) +
", " + Environment.NewLine +
698 " SISTEMA = " + DB.SQLString(_nSistema) +
", " + Environment.NewLine +
699 " TERRITORIO = " + DB.SQLString(_nTerritorio) +
", " + Environment.NewLine +
700 " TIPO_CERT = " + DB.SQLString(Convert.ToInt32(_TipoCert)) +
", " + Environment.NewLine +
701 " TBAI = " + DB.SQLString(_TBAI) +
", " + Environment.NewLine +
702 " QR_TBAI = " + DB.SQLString(_QRTBAI) +
", " + Environment.NewLine +
703 " FIRMA = " + DB.SQLString(_cFirma) +
", " + Environment.NewLine +
704 " ESTADO = " + DB.SQLString(_nEstado) +
", " + Environment.NewLine +
705 " ANULADO = " + DB.SQLString(_nAnulado) +
", " + Environment.NewLine +
706 " TIPOENVIO = " + DB.SQLString(_nTipoEnvio) +
", " + Environment.NewLine +
707 " HUELLA = " + DB.SQLString(_cHuella) +
", " + Environment.NewLine +
708 " HUELLA_ANT = " + DB.SQLString(_cHuella_Ant) +
", " + Environment.NewLine +
709 " HORA = " + DB.SQLString(_dHora) +
", " + Environment.NewLine +
710 " BASE = " + DB.SQLString(_nBase) +
", " + Environment.NewLine +
711 " TOTALDOC = " + DB.SQLString(_nTotaldoc) +
", " + Environment.NewLine +
712 " CLIENTE = " + DB.SQLString(_cCliente) +
", " + Environment.NewLine +
713 " FECHA_FAC = " + DB.SQLString(_dFecha_fac) +
", " + Environment.NewLine +
714 " TER_NO_ENV = " + DB.SQLString(_lCertificadaTercerosNoEnviada) +
", " + Environment.NewLine +
715 " HUSOHORA = " + DB.SQLString(_HusoHora) + Environment.NewLine +
", " + Environment.NewLine +
716 " QR_VERIFAC = " + DB.SQLString(_QRVERIFAC) + Environment.NewLine +
", " + Environment.NewLine +
717 " TERMINAL = " + DB.SQLString(_Terminal) + Environment.NewLine +
718 (llCambio ?
" ,N_SERIE = " + DB.SQLString(_cNSerie) :
"") + Environment.NewLine +
719 (!llCambio ?
" ,BORRADOR = " + DB.SQLString(NumeroBorrador()) + Environment.NewLine :
"") +
720 (llCambio ?
" ,NUMERO = " + DB.SQLString(_Numero) :
"");
738 if (cfactuven == null)
744 string lcSql =
" EMPRESA = " + DB.SQLString(_Empresa) +
", " + Environment.NewLine +
745 " EJERCICIO = " + DB.SQLString(_Ejercicio) +
", " + Environment.NewLine +
746 " ID_FC = " + DB.SQLString(_Guid_id) +
", " + Environment.NewLine +
747 " ESTADO = " + DB.SQLString(0) +
", " + Environment.NewLine +
748 " ESTADOADM = " + DB.SQLString(0) +
", " + Environment.NewLine +
749 " TIPOREG = " + DB.SQLString(_oTipoDocumentoCertificar ==
TipoDocumentoCertificar.Ticket ? 4 :0 ) +
", " + Environment.NewLine +
750 " CODIGO_CLI = " + DB.SQLString(_Cliente) +
", " + Environment.NewLine +
751 " NOMBRE_CLI = " + DB.SQLString(_NombreCliente) +
", " + Environment.NewLine +
752 " NUMERO = " + DB.SQLString(_Numero) +
", " + Environment.NewLine +
753 " LINEA = " + DB.SQLString(1) +
", " + Environment.NewLine +
754 $
" {(cfactuven != null ? "SIIFRAMOD =
" + DB.SQLString(_oTipoDocumentoCertificar == TipoDocumentoCertificar.Ticket ? "" :cfactuven.Siiframod) + ",
" + Environment.NewLine : "")} " +
755 $
" {(cfactuven != null ? "SIINUMDER =
" + DB.SQLString(_oTipoDocumentoCertificar == TipoDocumentoCertificar.Ticket ? "" :cfactuven.Siinumder) + ",
" + Environment.NewLine : "")} " +
756 " TOTALDOC = " + DB.SQLString(_TotalDocumento) +
", " + Environment.NewLine +
757 " DIVISA = " + DB.SQLString(_Divisa) +
", " + Environment.NewLine +
758 " TOTALDIV = " + DB.SQLString(_TotalDivisa) +
", " + Environment.NewLine +
759 " MODAUTORIZ = " + DB.SQLString(
"") +
", " + Environment.NewLine +
760 " MODAUTORIF = " + DB.SQLString(
"") +
", " + Environment.NewLine +
761 " SISTEMA = " + DB.SQLString(_Sistema) +
", " + Environment.NewLine +
762 " TERRITORIO = " + DB.SQLString(_Territorio) +
", " + Environment.NewLine +
763 " TIPOENVIO = " + DB.SQLString(_TipoEnvio) +
", " + Environment.NewLine +
764 " TERMINAL = " + DB.SQLString(_Terminal) +
" , " + Environment.NewLine +
765 $
" {(modconfi != null ? "GUID_ID =
" + DB.SQLString(modconfi.Guid_id) + " ,
" + Environment.NewLine : "")} " +
766 $
" {(modconfi != null ? "CIF_EMP =
" + DB.SQLString(modconfi.Nif) + " ,
" + Environment.NewLine : "")} " +
767 " XML_CE = " + DB.SQLString(_FicheroXML) +
" , " + Environment.NewLine +
768 " FECHAREG = " + DB.SQLString(_FechaRegistro) +
" , " + Environment.NewLine +
769 " HUSOHORA = " + DB.SQLString(_HusoHora) +
" , " + Environment.NewLine +
770 " XMLRESP = " + DB.SQLString(
"") +
" , " + Environment.NewLine +
771 " CSV = " + DB.SQLString(
"") +
" , " + Environment.NewLine +
772 " INCIDENCIA = " + DB.SQLString(
"") +
" , " + Environment.NewLine +
773 " LETRA = " + DB.SQLString(_Letra) + Environment.NewLine;
784 string lcSql =
"USUARIO, EMPRESA, EJERCICIO, NUMERO, " + Environment.NewLine +
785 "BORRADOR, SISTEMA, TERRITORIO, TIPO_CERT, " + Environment.NewLine +
786 "TBAI, QR_TBAI, FIRMA, HUELLA, HUELLA_ANT, ESTADO, ANULADO, TIPOENVIO, HORA, TER_NO_ENV, " + Environment.NewLine +
787 "N_SERIE, BASE, TOTALDOC, CLIENTE, FECHA_FAC, HUSOHORA, QR_VERIFAC, TERMINAL ";
798 string lcSql =
"EMPRESA, EJERCICIO, ID_FC, " + Environment.NewLine +
799 "ESTADO, ESTADOADM, TIPOREG, CODIGO_CLI, NOMBRE_CLI, NUMERO, LINEA, " + Environment.NewLine +
800 "SIIFRAMOD, SIINUMDER, TOTALDOC, DIVISA, TOTALDIV, MODAUTORIZ, MODAUTORIF, SISTEMA, TERRITORIO, TIPOENVIO, " + Environment.NewLine +
801 "TERMINAL, GUID_EMP, CIF_EMP, XML_CE, FECHAREG, HUSOHORA, " + Environment.NewLine +
802 "XMLRESP, CSV, INCIDENCIA, LETRA ";
813 string lcSql = DB.SQLString(_Usuario) +
" , " + DB.SQLString(_Empresa) +
" , " + DB.SQLString(_Ejercicio) +
" , " + DB.SQLString(_Numero) +
" , " + Environment.NewLine +
814 DB.SQLString(NumeroBorrador()) +
" , " + DB.SQLString(_nSistema) +
" , " + DB.SQLString(_nTerritorio) +
" , " + DB.SQLString(Convert.ToInt32(_TipoCert)) +
" , " + Environment.NewLine +
815 DB.SQLString(_TBAI) +
" , " + DB.SQLString(_QRTBAI) +
" , " + DB.SQLString(_cFirma) +
" , " + DB.SQLString(_cHuella) +
" , " + DB.SQLString(_cHuella_Ant) +
" , " + Environment.NewLine +
816 DB.SQLString(_nEstado) +
" , " + DB.SQLString(_nAnulado) +
" , " + DB.SQLString(_nTipoEnvio) +
" , " + DB.SQLString(_dHora) +
" , " + DB.SQLString(_lCertificadaTercerosNoEnviada) +
" , " + Environment.NewLine +
817 DB.SQLString(_cNSerie) +
", " + DB.SQLString(_nBase) +
", " + DB.SQLString(_nTotaldoc) +
", " + DB.SQLString(_cCliente) +
", " + DB.SQLString(_dFecha_fac) + Environment.NewLine +
", " + Environment.NewLine +
818 DB.SQLString(_cHusoHora) +
", " + DB.SQLString(_cQRVERIFAC) +
", " + DB.SQLString(_Terminal);
836 if (cfactuven == null)
842 var siinumder = cfactuven != null ? cfactuven.
Siinumder :
"";
843 var siiframod = cfactuven != null ? cfactuven.
Siiframod :
"";
845 string lcSql = DB.SQLString(_Empresa) +
" , " + DB.SQLString(_Ejercicio) +
" , " + DB.SQLString(_Guid_id) +
" , " + DB.SQLString(0) +
" , " + Environment.NewLine +
846 DB.SQLString(0) +
" , " + DB.SQLString(_oTipoDocumentoCertificar ==
TipoDocumentoCertificar.Ticket ? 4 :0) +
" , " + DB.SQLString(_Cliente) +
" , " + DB.SQLString(_NombreCliente) +
" , " + Environment.NewLine +
847 DB.SQLString(_Numero) +
" , " + DB.SQLString(1) +
" , " +
849 DB.SQLString(_oTipoDocumentoCertificar ==
TipoDocumentoCertificar.Ticket ?
"" : siinumder) +
" , " + Environment.NewLine +
850 DB.SQLString(_TotalDocumento) +
" , " + DB.SQLString(_Divisa) +
" , " + DB.SQLString(_TotalDivisa) +
" , " + Environment.NewLine +
851 DB.SQLString(
"") +
" , " + DB.SQLString(
"") +
" , " + DB.SQLString(_Sistema) +
" , " + DB.SQLString(_Territorio) +
" , " + DB.SQLString(_TipoEnvio) +
" , " +
852 DB.SQLString(_Terminal) +
", " + DB.SQLString(modconfi.
Guid_id) +
", " + DB.SQLString(modconfi.
Nif) +
", " + DB.SQLString(_FicheroXML) +
", " + DB.SQLString(_FechaRegistro) +
" , " + Environment.NewLine +
853 DB.SQLString(_HusoHora) +
", " + DB.SQLString(
"") +
", " + DB.SQLString(
"") +
", " + DB.SQLString(
"") +
", " + DB.SQLString(_Letra);
867 if (!
string.IsNullOrWhiteSpace(_cNumeroLoad))
872 #endregion METODOS PROTECTED 874 #region MÉTODOS PUBLIC VIRTUAL 889 return _IsFacturaCERTIFICADA() && _Estado >= 2;
906 _Usuario =
string.Empty;
907 _Empresa =
string.Empty;
908 _Ejercicio =
string.Empty;
909 _Numero =
string.Empty;
911 _cNumeroLoad =
string.Empty;
912 _cBorrador =
string.Empty;
914 ValoresConfiguracion();
916 _TBAI =
string.Empty;
917 _cQRTBAI =
string.Empty;
918 _cFirma =
string.Empty;
920 _cHuella =
string.Empty;
924 _cHuella_Ant =
string.Empty;
926 _cNSerie =
string.Empty;
930 lstRegistrosCertificacion?.Clear();
931 _lCertificadaTercerosNoEnviada =
false;
935 _cCliente =
string.Empty;
940 #endregion MÉTODOS PUBLIC VIRTUAL 942 #region MÉTODOS PRIVADOS 943 private string NumeroBorrador()
949 string lcBorrador = _cBorrador;
953 lcBorrador = _cNumero;
961 private void ValoresConfiguracion()
963 _nSistema = FACTUCERT._FactuCertConfig._Sistema;
964 _nTerritorio = FACTUCERT._FactuCertConfig._Territorio;
974 private void SerieTerminal()
976 _cNSerie = FunctionsFactuCert._SerieTerminal();
983 private bool LoadRegistrosCertificacion()
985 DataTable ldtRegistrosCert =
new DataTable();
988 if (lstRegistrosCertificacion == null)
989 lstRegistrosCertificacion =
new List<RegistroCertificacion>();
991 lstRegistrosCertificacion.Clear();
993 llOk = DB.SQLExec(
"SELECT usuario, empresa, ejercicio, letra, numero, borrador, linea, fecha, tipo_doc, tipo, motivo, xmlresp " + Environment.NewLine +
994 " FROM " + DB.SQLDatabase(FACTUCERT._NombreAddOn,
"fcregcert") + Environment.NewLine +
995 " WHERE empresa=" + DB.SQLString(_Empresa) + Environment.NewLine +
996 " AND ejercicio=" + DB.SQLString(_Ejercicio) + Environment.NewLine +
997 " AND letra=" + DB.SQLString(_Letra) + Environment.NewLine +
998 " AND borrador=" + DB.SQLString(_Borrador) + Environment.NewLine +
999 " AND numero=" + DB.SQLString(_Numero) + Environment.NewLine +
1000 " ORDER BY linea", ref ldtRegistrosCert);
1002 foreach (DataRow ldrRegistro
in ldtRegistrosCert.Rows)
1003 lstRegistrosCertificacion.Add(
new RegistroCertificacion(ldrRegistro));
1005 FUNCTIONS._DisposeDatatable(ref ldtRegistrosCert);
1009 #endregion MÉTODOS PRIVADOS 1011 #region MÉTODOS PUBLIC ABSTRACT 1013 public abstract bool _Delete();
1015 public abstract bool _Delete(String tcEmpresa, String tcNumero);
1017 public abstract bool _Load(dynamic documento);
1019 #endregion MÉTODOS PUBLIC ABSTRACT TipoDocumentoCertificar
Posibles tipos de documentos para certificar.
DTO de la tabla GESTION.C_FACTUVEN
string _InsertValues()
Devuelve el set de los campos para realizar el Insert de los campos comunes
ModconfiDTO ObtenerDatosModconfi(string codigoEmpresa)
Obtiene los datos de configuracion de modelos
string _UpdateEstvericerFields()
Devuelve el set para realizar el Update de los campos comunes
Este es el espacio de nombres de su módulo. Puede encontrar más información y ayuda en el fichero rea...
RegistroFactuvenDTO ObtenerRegistroFactuven(string codigoEmpresa, string numfra)
Obtiene los datos de la factura de la tabla GESTION.C_FACTUVEN
string _NumeroUpdate()
Devuelve el numero del documento para realizar el UPDATE
object Retrieve(Type T)
Resuelve objeto de tipo T
string _InsertFields()
Devuelve los campos para realizar el Insert de los campos comunes
Es como el tipo de entrada asientos pero por negocio, sin formulario, pq quiero que me haga las propu...
DTO de la tabla GESTION.MODCONFI
TipoDocCrearFactura
Enumeración para la creación de las facturas
virtual bool _IsFacturaCERTIFICADAEnviada()
Devuelve si el albarán está en una factura certificada enviada
string _InsertEstvericerValues()
Devuelve el set de los campos para realizar el Insert de los campos comunes
string _InsertEstvericerFields()
Devuelve los campos para realizar el Insert de los campos comunes
string _UpdateFields()
Devuelve el set para realizar el Update de los campos comunes
virtual void _DescargarDatos()
Descargar datos
Clase que se utilizará como base para "DatosAdicionalesFacturarAlbaran" y "DatosAdicionalesTicket" qu...
Clase para extraer la información de la huella
static DependencyInjector Instance
Instancia
Interficie de acceso a datos para la certificación
virtual bool _IsFacturaCetificadaTerceros()
Devuelve si es un documento generado por terceros
virtual bool _IsFacturaCERTIFICADA()
Devuelve si el albarán está en una factura certificada (enviada o no enviada, da igual) ...
Clase Inyector de dependencias para resolver las dependencias