DatosAdicionalesBase.cs
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Linq;
6 using System.Text;
10 using sage.ew.db;
11 using sage.ew.empresa;
12 using sage.ew.functions;
13 using sage.ew.functions.Clases;
14 using sage.ew.global;
16 using sage.ew.objetos;
17 using Sage.ES.Verifactu.Interfaces.Entities.ComModel.V1_0;
18 using SBWinCrypt;
19 
20 namespace sage.addons.factucert.Negocio.Clases
21 {
26  public abstract class DatosAdicionalesBase
27  {
28  #region PROPIEDADES PROTECTED
29 
30  protected String _cUsuario = "";
31  protected String _cEmpresa = "";
32  protected String _cEjercicio = "";
33  protected String _cNumero = "";
34  protected String _cNumeroLoad = "";
35  protected String _cLetra = "";
36  protected TipoDocCrearFactura _oTipoCert = TipoDocCrearFactura.NoCertificada;
37  protected String _cTBAI = "";
38  protected String _cQRTBAI = "";
39  protected DateTime? _dHora = null;
40  protected String _cMensajeError;
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;
43  protected HuellaDetalle _oHuellaDetalle = new HuellaDetalle(), _oHuellaAntDetalle = new HuellaDetalle();
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;
50 
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;
61  protected TipoDocumentoCertificar _oTipoDocumentoCertificar = TipoDocumentoCertificar.Factura;
62 
67 
68  #endregion PROPIEDADES PROTECTED
69 
70  #region Constructor
71  public DatosAdicionalesBase()
75  {
76  ValoresConfiguracion();
77  }
78  #endregion Constructor
79 
80  #region PROPIEDADES PÚBLICAS
81 
85  public String _Usuario
86  {
87  get
88  {
89  if (string.IsNullOrWhiteSpace(_cUsuario))
90  _cUsuario = Convert.ToString(EW_GLOBAL._GetVariable("wc_usuario")) + "_NET";
91 
92  return _cUsuario;
93  }
94  set
95  {
96  _cUsuario = value;
97  }
98  }
99 
103  public String _Empresa
104  {
105  get
106  {
107  return _cEmpresa;
108  }
109  set
110  {
111  _cEmpresa = value;
112  }
113  }
114 
118  public String _Ejercicio
119  {
120  get
121  {
122  if (string.IsNullOrWhiteSpace(_cEjercicio))
123  _cEjercicio = Convert.ToString(EW_GLOBAL._GetVariable("wc_any"));
124 
125  return _cEjercicio;
126  }
127  set
128  {
129  _cEjercicio = value;
130  }
131  }
132 
136  public String _Numero
137  {
138  get
139  {
140  return _cNumero;
141  }
142  set
143  {
144  _cNumero = value;
145  }
146  }
147 
151  public String _Letra
152  {
153  get
154  {
155  return _cLetra;
156  }
157  set
158  {
159  _cLetra = value;
160  }
161  }
162 
166  public TipoDocumentoCertificar _TipoDocumentoCertificar
167  {
168  get
169  {
170  return _oTipoDocumentoCertificar;
171  }
172  set
173  {
174  _oTipoDocumentoCertificar = value;
175  }
176  }
177 
182  public TipoDocCrearFactura _TipoCert
183  {
184  get
185  {
186  return _oTipoCert;
187  }
188  set
189  {
190  _oTipoCert = value;
191  }
192  }
193 
197  public string _TBAI
198  {
199  get
200  {
201  return _cTBAI;
202  }
203  set
204  {
205  _cTBAI = value;
206  }
207  }
208 
212  public string _QRTBAI
213  {
214  get
215  {
216  return _cQRTBAI;
217  }
218  set
219  {
220  _cQRTBAI = value;
221  }
222  }
223 
227  [DefaultValue(null)]
228  public DateTime? _Hora
229  {
230  get { return _dHora; }
231  set { _dHora = value; }
232  }
233 
237  public string _Borrador
238  {
239  get { return _cBorrador; }
240  set { _cBorrador = value; }
241  }
242 
246  public int _Sistema
247  {
248  get { return _nSistema; }
249  set { _nSistema = value; }
250  }
251 
255  public int _Territorio
256  {
257  get { return _nTerritorio; }
258  set { _nTerritorio = value; }
259  }
260 
264  public string _Firma
265  {
266  get { return _cFirma; }
267  set { _cFirma = value; }
268  }
269 
273  public string _Huella
274  {
275  get { return _cHuella; }
276  set
277  {
278  _cHuella = value;
279  _HuellaDetalle = FunctionsFactuCert._HuellaDeserializar(value);
280  }
281  }
282 
286  public string _Huella_Ant
287  {
288  get { return _cHuella_Ant; }
289  set
290  {
291  _cHuella_Ant = value;
292  _HuellaAntDetalle = FunctionsFactuCert._HuellaDeserializar(value);
293  }
294  }
295 
300  public int _Estado
301  {
302  get { return _nEstado; }
303  set { _nEstado = value; }
304  }
305 
309  public string _NSerie
310  {
311  get { return _cNSerie; }
312  set { _cNSerie = value; }
313  }
314 
315 
319  public HuellaDetalle _HuellaDetalle
320  {
321  get { return _oHuellaDetalle; }
322  set { _oHuellaDetalle = value; }
323  }
324 
328  public HuellaDetalle _HuellaAntDetalle
329  {
330  get { return _oHuellaAntDetalle; }
331  set { _oHuellaAntDetalle = value; }
332  }
333 
343  public int _Anulado
344  {
345  get { return _nAnulado; }
346  set { _nAnulado = value; }
347  }
348 
352  public int _TipoEnvio
353  {
354  get { return _nTipoEnvio; }
355  set { _nTipoEnvio = value; }
356  }
357 
358 
362  public String _MensajeError
363  {
364  get
365  {
366  return _cMensajeError;
367  }
368  set
369  {
370  _cMensajeError = value;
371  }
372  }
373 
377  public List<RegistroCertificacion> _RegistrosCertificacion
378  {
379  get
380  {
381  if (lstRegistrosCertificacion == null)
382  LoadRegistrosCertificacion();
383 
384  return lstRegistrosCertificacion;
385  }
386  }
387 
391  public bool _CertificadaTercerosNoEnviada
392  {
393  get { return _lCertificadaTercerosNoEnviada; }
394  set { _lCertificadaTercerosNoEnviada = value; }
395  }
396 
400  public decimal _Base
401  {
402  get
403  {
404  return _nBase;
405  }
406  set
407  {
408  _nBase = value;
409  }
410  }
411 
415  public decimal _TotalDocumento
416  {
417  get
418  {
419  return _nTotaldoc;
420  }
421  set
422  {
423  _nTotaldoc = value;
424  }
425  }
426 
430  public string _Divisa
431  {
432  get
433  {
434  return _cDivisa;
435  }
436  set
437  {
438  _cDivisa = value;
439  }
440  }
441 
445  public decimal _TotalDivisa
446  {
447  get
448  {
449  return _nTotaldiv;
450  }
451  set
452  {
453  _nTotaldiv = value;
454  }
455  }
456 
460  public string _Cliente
461  {
462  get
463  {
464  return _cCliente;
465  }
466  set
467  {
468  _cCliente = value;
469  }
470  }
471 
472  public string _NombreCliente
473  {
474  get
475  {
476  return Convert.ToString(DB.SQLValor("CLIENTES", "CODIGO", _Cliente, "NOMBRE"));
477  }
478  }
479 
483  public DateTime? _Fecha_fac
484  {
485  get
486  {
487  return _dFecha_fac;
488  }
489  set
490  {
491  _dFecha_fac = value;
492  }
493  }
494 
498  public string _Terminal
499  {
500  get
501  {
502  return Convert.ToString(EW_GLOBAL._GetVariable("wc_terminal"));
503  }
504  set
505  {
506  _cTerminal = value;
507  }
508  }
509 
513  public string _HusoHora
514  {
515  get
516  {
517  string lchuso = TimeZoneInfo.Local.BaseUtcOffset.ToString();
518  int lnPosFin = lchuso.LastIndexOf(":");
519 
520  if (!string.IsNullOrEmpty(lchuso) && lnPosFin > 0)
521  {
522  _cHusoHora = lchuso.Substring(0, lnPosFin);
523 
524  if (!_cHusoHora.Contains("-"))
525  {
526  _cHusoHora = "+" + _cHusoHora;
527  }
528  }
529  return _cHusoHora;
530  }
531  set
532  {
533  _cHusoHora = value;
534  }
535  }
536 
540  public string _FicheroXML
541  {
542  get
543  {
544  return _cFicheroXML;
545  }
546  set
547  {
548  _cFicheroXML = value;
549  }
550  }
551 
555  public string _CSV
556  {
557  get
558  {
559  return _cCSV;
560  }
561  set
562  {
563  _cCSV = value;
564  }
565  }
566 
567 
571  public DateTime _FechaRegistro
572  {
573  get
574  {
575  return _dFechaRegistro;
576  }
577  set
578  {
579  _dFechaRegistro = value;
580  }
581  }
582 
586  public string _QRVERIFAC
587  {
588  get
589  {
590  return _cQRVERIFAC;
591  }
592  set
593  {
594  _cQRVERIFAC = value;
595  }
596  }
597 
601  public string _Guid_id
602  {
603  get
604  {
605  return _cGuid_id;
606  }
607  set
608  {
609  _cGuid_id = value;
610  }
611  }
612 
616  public string _Guid_Emp
617  {
618  get
619  {
620  return _cGuid_Emp;
621  }
622  set
623  {
624  _cGuid_Emp = value;
625  }
626  }
627 
628  #endregion PROPIEDADES PÚBLICAS
629 
630  #region METODOS PROTECTED
631  protected void _Load(DataRow tdrDocumento)
636  {
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"]);
644 
645  TipoDocCrearFactura loTipoDocCrearFactura;
646 
647  _TipoCert = Enum.TryParse<TipoDocCrearFactura>(Convert.ToString(tdrDocumento["tipo_cert"]), out loTipoDocCrearFactura) ? loTipoDocCrearFactura : TipoDocCrearFactura.NoCertificada;
648 
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"]);
657 
658  if (tdrDocumento["hora"] == DBNull.Value)
659  _dHora = null;
660  else
661  _dHora = Convert.ToDateTime(tdrDocumento["hora"]);
662 
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"]);
667 
668  _nBase = Convert.ToDecimal(tdrDocumento["base"]);
669  _nTotaldoc = Convert.ToDecimal(tdrDocumento["totaldoc"]);
670  _cCliente = Convert.ToString(tdrDocumento["cliente"]);
671 
672  if (tdrDocumento["fecha_fac"] == DBNull.Value)
673  _dFecha_fac = null;
674  else
675  _dFecha_fac = Convert.ToDateTime(tdrDocumento["fecha_fac"]);
676 
677  _cHusoHora = Convert.ToString(tdrDocumento["husohora"]);
678  _cQRVERIFAC = Convert.ToString(tdrDocumento["qr_verifac"]);
679  _cTerminal = Convert.ToString(tdrDocumento["terminal"]);
680  }
681 
688  protected string _UpdateFields()
689  {
690  _cBorrador = NumeroBorrador(); // Cuando crea el documento es necesario realizar la asignación del borrador
691 
692  bool llCambio = (_NumeroUpdate() != _Numero);
693 
694  if (llCambio)
695  SerieTerminal(); // Refrescamos la serie del terminal
696 
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 + // Una vez certificado ya no actualizamos actualizar el número de serie , = alguien entra a consultar el documento en otro terminal ...
719  (!llCambio ? " ,BORRADOR = " + DB.SQLString(NumeroBorrador()) + Environment.NewLine : "") +
720  (llCambio ? " ,NUMERO = " + DB.SQLString(_Numero) : ""); // Cuando pasamos de borrador a certificado tenemos de actualizar el número
721 
722  return lcSql;
723  }
724 
729  protected string _UpdateEstvericerFields()
730  {
731  ModconfiDTO modconfi = DataAccess.ObtenerDatosModconfi(_Empresa);
732  RegistroFactuvenDTO cfactuven = null;
733 
734  if (_oTipoDocumentoCertificar != TipoDocumentoCertificar.Ticket)
735  {
736  cfactuven = DataAccess.ObtenerRegistroFactuven(_Empresa, _Numero);
737 
738  if (cfactuven == null)
739  {
740  cfactuven = DataAccess.ObtenerRegistroFactuven(_Empresa, _Borrador);
741  }
742  }
743 
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;
774 
775  return lcSql;
776  }
777 
782  protected string _InsertFields()
783  {
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 ";
788 
789  return lcSql;
790  }
791 
796  protected string _InsertEstvericerFields()
797  {
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 ";
803 
804  return lcSql;
805  }
806 
811  protected string _InsertValues()
812  {
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);
819 
820  return lcSql;
821  }
822 
827  protected string _InsertEstvericerValues()
828  {
829  ModconfiDTO modconfi = DataAccess.ObtenerDatosModconfi(_Empresa);
830  RegistroFactuvenDTO cfactuven = null;
831 
832  if (_oTipoDocumentoCertificar != TipoDocumentoCertificar.Ticket)
833  {
834  cfactuven = DataAccess.ObtenerRegistroFactuven(_Empresa, _Numero);
835 
836  if (cfactuven == null)
837  {
838  cfactuven = DataAccess.ObtenerRegistroFactuven(_Empresa, _Borrador);
839  }
840  }
841 
842  var siinumder = cfactuven != null ? cfactuven.Siinumder : "";
843  var siiframod = cfactuven != null ? cfactuven.Siiframod : "";
844 
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) + " , " +
848  DB.SQLString(_oTipoDocumentoCertificar == TipoDocumentoCertificar.Ticket ? "" : siiframod) + " , " +
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);
854 
855  return lcSql;
856  }
857 
865  protected string _NumeroUpdate()
866  {
867  if (!string.IsNullOrWhiteSpace(_cNumeroLoad))
868  return _cNumeroLoad;
869  else
870  return _Numero;
871  }
872  #endregion METODOS PROTECTED
873 
874  #region MÉTODOS PUBLIC VIRTUAL
875 
879  public virtual bool _IsFacturaCERTIFICADA()
880  {
881  return _TipoCert == TipoDocCrearFactura.Certificada;
882  }
883 
887  public virtual bool _IsFacturaCERTIFICADAEnviada()
888  {
889  return _IsFacturaCERTIFICADA() && _Estado >= 2;
890  }
891 
895  public virtual bool _IsFacturaCetificadaTerceros()
896  {
897  return _TipoCert == TipoDocCrearFactura.CertificadaTerceros;
898  }
899 
903  public virtual void _DescargarDatos()
904  {
905  _MensajeError = "";
906  _Usuario = string.Empty;
907  _Empresa = string.Empty;
908  _Ejercicio = string.Empty;
909  _Numero = string.Empty;
910 
911  _cNumeroLoad = string.Empty;
912  _cBorrador = string.Empty;
913 
914  ValoresConfiguracion();
915 
916  _TBAI = string.Empty;
917  _cQRTBAI = string.Empty;
918  _cFirma = string.Empty;
919 
920  _cHuella = string.Empty;
921  _nEstado = 0;
922  _nAnulado = 0;
923  _nTipoEnvio = 0;
924  _cHuella_Ant = string.Empty;
925  _dHora = null;
926  _cNSerie = string.Empty;
927  _oHuellaDetalle = new HuellaDetalle();
928  _oHuellaAntDetalle = new HuellaDetalle();
929 
930  lstRegistrosCertificacion?.Clear();
931  _lCertificadaTercerosNoEnviada = false;
932 
933  _nBase = 0;
934  _nTotaldoc = 0;
935  _cCliente = string.Empty;
936  _dFecha_fac = null;
937 
938  }
939 
940  #endregion MÉTODOS PUBLIC VIRTUAL
941 
942  #region MÉTODOS PRIVADOS
943  private string NumeroBorrador()
948  {
949  string lcBorrador = _cBorrador;
950 
951  //Bug 184742 - Cuando se guardaban los datos de IVA, se modificaba el valor del campo "borrador"
952  if (_TipoCert == TipoDocCrearFactura.Borrador && string.IsNullOrWhiteSpace(_cBorrador))
953  lcBorrador = _cNumero;
954 
955  return lcBorrador;
956  }
957 
961  private void ValoresConfiguracion()
962  {
963  _nSistema = FACTUCERT._FactuCertConfig._Sistema;
964  _nTerritorio = FACTUCERT._FactuCertConfig._Territorio;
965  _oTipoCert = TipoDocCrearFactura.NoCertificada;
966 
967  SerieTerminal();
968  }
969 
974  private void SerieTerminal()
975  {
976  _cNSerie = FunctionsFactuCert._SerieTerminal();
977  }
978 
983  private bool LoadRegistrosCertificacion()
984  {
985  DataTable ldtRegistrosCert = new DataTable();
986  bool llOk = true;
987 
988  if (lstRegistrosCertificacion == null)
989  lstRegistrosCertificacion = new List<RegistroCertificacion>();
990  else
991  lstRegistrosCertificacion.Clear();
992 
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);
1001 
1002  foreach (DataRow ldrRegistro in ldtRegistrosCert.Rows)
1003  lstRegistrosCertificacion.Add(new RegistroCertificacion(ldrRegistro));
1004 
1005  FUNCTIONS._DisposeDatatable(ref ldtRegistrosCert);
1006 
1007  return llOk;
1008  }
1009  #endregion MÉTODOS PRIVADOS
1010 
1011  #region MÉTODOS PUBLIC ABSTRACT
1012 
1013  public abstract bool _Delete();
1014 
1015  public abstract bool _Delete(String tcEmpresa, String tcNumero);
1016 
1017  public abstract bool _Load(dynamic documento);
1018 
1019  #endregion MÉTODOS PUBLIC ABSTRACT
1020  }
1021 }
TipoDocumentoCertificar
Posibles tipos de documentos para certificar.
Definition: Enums.cs:218
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
Definition: ModconfiDTO.cs:7
TipoDocCrearFactura
Enumeración para la creación de las facturas
Definition: Enums.cs:163
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
Clase que se utilizará como base para "DatosAdicionalesFacturarAlbaran" y "DatosAdicionalesTicket" qu...
Clase para extraer la información de la huella
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