clsTipoIVA.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Data;
6 using System.ComponentModel;
7 using sage.ew.objetos;
8 using sage.ew.global;
9 using sage.ew.db;
10 using sage.ew.ewbase;
11 using sage.ew.contabilidad;
12 using System.Windows.Forms;
13 using sage.ew.formul.Forms;
14 using sage.ew.interficies;
15 using sage.ew.articulo.Forms;
16 using sage.ew.enumerations;
17 
18 namespace sage.ew.articulo
19 {
23  public class TipoIVA : ewMante , IManteAsistente
24  {
25  // Variables de entorno
26  //
27  bool _lRecc = Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_recc"));
28 
29  // Regla de la prorrata activada si/no
30  //
31  bool _lProrrata = Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_prorrata_aplicar"));
32 
33  string _cNombreImpuesto = Convert.ToString(EW_GLOBAL._GetVariable("wc_iva"));
34 
35  string _cIvaRep3 = Convert.ToString(EW_GLOBAL._GetVariable("wc_IvaRep","477")).Substring(0,3);
36  string _cIvaSop3 = Convert.ToString(EW_GLOBAL._GetVariable("wc_IvaSop","472")).Substring(0,3);
37 
38  string _cIvaRecSop3 = Convert.ToString(EW_GLOBAL._GetVariable("wc_recsop", "472")).Substring(0, 3);
39  string _cIvaRecRep3 = Convert.ToString(EW_GLOBAL._GetVariable("wc_recrep", "477")).Substring(0, 3);
40 
41  string _cIvaPendSop3 = Convert.ToString(EW_GLOBAL._GetVariable("wc_pendedsop", "")).Substring(0, 3);
42  string _cIvaRecPendSop3 = Convert.ToString(EW_GLOBAL._GetVariable("wc_recsopcdev", "")).Substring(0, 3);
43  string _cIvaPendRep3 = Convert.ToString(EW_GLOBAL._GetVariable("wc_pendevrep", "")).Substring(0, 3);
44  string _cIvaRecPendRep3 = Convert.ToString(EW_GLOBAL._GetVariable("wc_recrepcdev", "")).Substring(0, 3);
45 
46  // Cuentas relacionadas con la regla de la Prorrata.
47  //
48  // Iva soportado no deducible (prorrata)
49  //
50  string _cIvaSop3_Nodeduc = Convert.ToString(EW_GLOBAL._GetVariable("wc_prtivsopnd", "472")).Substring(0, 3);
51 
52  // Iva soportado no deducible pendiente de devengo (prorrata)
53  //
54  string _cIvaPendSop3_Nodeduc = Convert.ToString(EW_GLOBAL._GetVariable("wc_prtivsndpd", "")).Substring(0, 3);
55 
56 
57  //FPE-105134
58 
59  #region PROPIEDADES PUBLICAS
60 
64  public override AccionTraspasoUltimoEjercicio _TraspasoUltimoEjercicio { get; } = AccionTraspasoUltimoEjercicio.Informar;
65 
69  public decimal _IVA
70  {
71  get
72  {
73  if (_lisCampos.ContainsKey("IVA"))
74  return Convert.ToDecimal(_lisCampos["IVA"]._NewVal);
75  else
76  return 0;
77  }
78  set
79  {
80  if (_lisCampos.ContainsKey("IVA"))
81  {
82  _lisCampos["IVA"]._NewVal = value;
83 
84  _Exportar_Null();
85  }
86  }
87  }
88 
92  public decimal _Recargo
93  {
94  get
95  {
96  // PARTE 83952
97  if (_lisCampos.ContainsKey("RECARG"))
98  return Convert.ToDecimal(_lisCampos["RECARG"]._NewVal);
99  else
100  return 0;
101  }
102  set
103  {
104  if (_lisCampos.ContainsKey("RECARG"))
105  {
106  _lisCampos["RECARG"]._NewVal = value;
107 
108  _Exportar_Null();
109  }
110  // FPARTE 83952
111  }
112  }
113 
117  public enum TipoImpuesto
118  {
122  IVA,
126  IGIC
127  }
128 
132  public TipoImpuesto _Tipo
133  {
134  get
135  {
136  TipoImpuesto loTipo;
137 
138  return (_lisCampos.ContainsKey("TIPO") && Enum.TryParse<TipoImpuesto>(Convert.ToString(_lisCampos["TIPO"]._NewVal), out loTipo)) ? loTipo : TipoImpuesto.IVA;
139  }
140  set
141  {
142  if (_lisCampos.ContainsKey("TIPO")) _lisCampos["TIPO"]._NewVal = Convert.ToInt32(value);
143  }
144  }
145 
149  public Boolean _IGICImplicito
150  {
151  get
152  {
153  return (_lisCampos.ContainsKey("IGIC_IMPLI") && _Tipo == TipoImpuesto.IGIC) ? Convert.ToBoolean(_lisCampos["IGIC_IMPLI"]._NewVal) : false;
154  }
155  set
156  {
157  if (_lisCampos.ContainsKey("IGIC_IMPLI")) _lisCampos["IGIC_IMPLI"]._NewVal = value;
158  }
159  }
160 
161 
165  public string _Cta_IVA_Sop
166  {
167  get
168  {
169  if (_lisCampos.ContainsKey("CTA_IV_SOP"))
170  return _lisCampos["CTA_IV_SOP"]._NewVal.ToString();
171  else
172  return "";
173  }
174  set
175  {
176  if (_lisCampos.ContainsKey("CTA_IV_SOP"))
177  {
178  if (_ValidaCuenta(value, _cIvaSop3, _cNombreImpuesto + " soportado"))
179  {
180  _lisCampos["CTA_IV_SOP"]._NewVal = value;
181  _Exportar_Null();
182  }
183  }
184  }
185  }
186 
190  public string _Cta_IVA_Rep
191  {
192  get
193  {
194  if (_lisCampos.ContainsKey("CTA_IV_REP"))
195  return _lisCampos["CTA_IV_REP"]._NewVal.ToString();
196  else
197  return "";
198  }
199  set
200  {
201  if (_lisCampos.ContainsKey("CTA_IV_REP"))
202  {
203  if (_ValidaCuenta(value, _cIvaRep3, _cNombreImpuesto + " repercutido"))
204  {
205  _lisCampos["CTA_IV_REP"]._NewVal = value;
206  _Exportar_Null();
207  }
208  }
209  }
210  }
211 
215  public string _Cta_REC_Sop
216  {
217  get
218  {
219  if (_lisCampos.ContainsKey("CTA_RE_SOP"))
220  return _lisCampos["CTA_RE_SOP"]._NewVal.ToString();
221  else
222  return "";
223  }
224  set
225  {
226  if (_lisCampos.ContainsKey("CTA_RE_SOP"))
227  {
228  if (_ValidaCuenta(value, _cIvaRecSop3, " recargo soportado"))
229  {
230  _lisCampos["CTA_RE_SOP"]._NewVal = value;
231  _Exportar_Null();
232  }
233  }
234  }
235  }
236 
240  public string _Cta_REC_Rep
241  {
242  get
243  {
244  if (_lisCampos.ContainsKey("CTA_RE_REP"))
245  return _lisCampos["CTA_RE_REP"]._NewVal.ToString();
246  else
247  return "";
248  }
249  set
250  {
251  if (_lisCampos.ContainsKey("CTA_RE_REP"))
252  {
253  if (_ValidaCuenta(value, _cIvaRecRep3, " recargo repercutido"))
254  {
255  _lisCampos["CTA_RE_REP"]._NewVal = value;
256  _Exportar_Null();
257  }
258  }
259  }
260  }
261 
265  public string _Pendevrep
266  {
267  get
268  {
269  if (_lisCampos.ContainsKey("PENDEVREP"))
270  return _lisCampos["PENDEVREP"]._NewVal.ToString();
271  else
272  return "";
273  }
274  set
275  {
276  if (_lisCampos.ContainsKey("PENDEVREP"))
277  {
278  if (_ValidaCuenta(value, String.IsNullOrWhiteSpace(_cIvaPendRep3) ? _cIvaRep3 : _cIvaPendRep3, " repercutido pendiente devengo", _cNombreImpuesto + " repercutido"))
279  {
280  _lisCampos["PENDEVREP"]._NewVal = value;
281  _Exportar_Null();
282  }
283  }
284  }
285  }
286 
290  public string _Pendedsop
291  {
292  get
293  {
294  if (_lisCampos.ContainsKey("PENDEDSOP"))
295  return _lisCampos["PENDEDSOP"]._NewVal.ToString();
296  else
297  return "";
298  }
299  set
300  {
301  if (_lisCampos.ContainsKey("PENDEDSOP"))
302  {
303  if (_ValidaCuenta(value, String.IsNullOrWhiteSpace(_cIvaPendSop3) ? _cIvaSop3 : _cIvaPendSop3, " soportado pendiente devengo", _cNombreImpuesto + " soportado"))
304  {
305  _lisCampos["PENDEDSOP"]._NewVal = value;
306  _Exportar_Null();
307  }
308  }
309  }
310  }
311 
315  public string _Recrepcdev
316  {
317  get
318  {
319  if (_lisCampos.ContainsKey("RECREPCDEV"))
320  return _lisCampos["RECREPCDEV"]._NewVal.ToString();
321  else
322  return "";
323  }
324  set
325  {
326  if (_lisCampos.ContainsKey("RECREPCDEV"))
327  {
328  if (_ValidaCuenta(value, String.IsNullOrWhiteSpace(_cIvaRecPendRep3) ? _cIvaRecRep3 : _cIvaRecPendRep3, "recargo repercutido pendiente devengo", "recargo repercutido"))
329  {
330  _lisCampos["RECREPCDEV"]._NewVal = value;
331  _Exportar_Null();
332  }
333  }
334  }
335  }
336 
337 
341  public string _Recsopcdev
342  {
343  get
344  {
345  if (_lisCampos.ContainsKey("RECSOPCDEV"))
346  return _lisCampos["RECSOPCDEV"]._NewVal.ToString();
347  else
348  return "";
349  }
350  set
351  {
352  if (_lisCampos.ContainsKey("RECSOPCDEV"))
353  {
354  if (_ValidaCuenta(value, String.IsNullOrWhiteSpace(_cIvaRecPendSop3) ? _cIvaRecSop3 : _cIvaRecPendSop3, "recargo soportado pendiente devengo", "recargo soportado"))
355  {
356  _lisCampos["RECSOPCDEV"]._NewVal = value;
357  _Exportar_Null();
358  }
359  }
360  }
361  }
362 
363 
364 
368  public string _Cta_IVA_Sop_Nodeduc
369  {
370  get
371  {
372  if (_lisCampos.ContainsKey("PRTIVSOPND"))
373  return _lisCampos["PRTIVSOPND"]._NewVal.ToString();
374  else
375  return "";
376  }
377  set
378  {
379  if (_lisCampos.ContainsKey("PRTIVSOPND"))
380  {
381  if (_ValidaCuenta(value, _cIvaSop3_Nodeduc, _cNombreImpuesto + " soportado no deducible", _cNombreImpuesto + " soportado no deducible (Prorrata)"))
382  {
383  _lisCampos["PRTIVSOPND"]._NewVal = value;
384  _Exportar_Null();
385  }
386  }
387  }
388  }
389 
390 
394  public string _Pendedsop_Nodeduc
395  {
396  get
397  {
398  if (_lisCampos.ContainsKey("PRTIVSNDPD"))
399  return _lisCampos["PRTIVSNDPD"]._NewVal.ToString();
400  else
401  return "";
402  }
403  set
404  {
405  if (_lisCampos.ContainsKey("PRTIVSNDPD"))
406  {
407  if (_ValidaCuenta(value, String.IsNullOrWhiteSpace(_cIvaPendSop3_Nodeduc) ? _cIvaSop3_Nodeduc : _cIvaPendSop3_Nodeduc, _cNombreImpuesto + " soportado no deducible pendiente devengo", _cNombreImpuesto + " soportado no deducible pendiente devengo (Prorrata)"))
408  {
409  _lisCampos["PRTIVSNDPD"]._NewVal = value;
410  _Exportar_Null();
411  }
412  }
413  }
414  }
415 
416 
417 
426  private bool _ValidaCuenta(String tcCuenta, String tcPrefijo, String tcDescripcion, String tcDescripcionStandard)
427  {
428  String lcErrorMessage = "";
429 
430  if (!_ValidaCuenta(tcCuenta, tcPrefijo, tcDescripcion, tcDescripcionStandard, ref lcErrorMessage))
431  {
432  _Error_Message = lcErrorMessage;
433  return false;
434  }
435  return true;
436  }
437 
445  private bool _ValidaCuenta(String tcCuenta, String tcPrefijo, String tcDescripcion)
446  {
447  return _ValidaCuenta(tcCuenta, tcPrefijo, tcDescripcion, tcDescripcion);
448  }
449 
458  private bool _ValidaCuenta(String tcCuenta, String tcPrefijo, String tcDescripcion, ref String lcErrorMessage)
459  {
460  return _ValidaCuenta(tcCuenta, tcPrefijo, tcDescripcion, tcDescripcion, ref lcErrorMessage);
461  }
462 
472  private bool _ValidaCuenta(String tcCuenta, String tcPrefijo, String tcDescripcion, String tcDescripcionStandard, ref String lcErrorMessage)
473  {
474  Boolean llOk = true;
475 
476  if(!String.IsNullOrWhiteSpace(tcCuenta))
477  {
478  String lcCuenta = DB.SQLValor("CUENTAS", "CODIGO", tcCuenta, "CODIGO", "GESTION").ToString();
479 
480  if (!String.IsNullOrEmpty(lcCuenta))
481  {
482  if (!String.IsNullOrWhiteSpace(tcPrefijo))
483  {
484  if (lcCuenta.Substring(0, 3) != tcPrefijo )
485  {
486  lcErrorMessage = String.Format("La cuenta de {1} es incorrecta.{2}La cuenta debe empezar por {0}.", tcPrefijo, tcDescripcion, Environment.NewLine);
487  llOk = false;
488  }
489  }
490  else
491  {
492  lcErrorMessage = String.Format("La cuenta contable estándar {0} no esta informada, antes de continuar debe informarla.", tcDescripcionStandard);
493  llOk = false;
494  }
495  }
496  else
497  {
498  lcErrorMessage = String.Format("La cuenta {0} no existe.", tcCuenta);
499  llOk = false;
500  }
501  }
502  return llOk;
503  }
504 
505 
506 
507 
511  public string _IVA_CEE
512  {
513  get
514  {
515  if (_lisCampos.ContainsKey("IVA_CEE"))
516  return _lisCampos["IVA_CEE"]._NewVal.ToString();
517  else
518  return "";
519  }
520  set
521  {
522  if (_lisCampos.ContainsKey("IVA_CEE"))
523  {
524  if (!string.IsNullOrWhiteSpace(value)) //PE-102527: si está vacío no hacer la comprobación de si existe
525  {
526  String lcCuenta = DB.SQLValor("TIPO_IVA", "CODIGO", value, "CODIGO", "GESTION").ToString();
527  if (!string.IsNullOrEmpty(lcCuenta))
528  {
529  _lisCampos["IVA_CEE"]._NewVal = value;
530 
531  _Exportar_Null();
532  }
533  else
534  _Error_Message = "El código no existe.";
535  }
536  else
537  {
538  _lisCampos["IVA_CEE"]._NewVal = value;
539 
540  _Exportar_Null();
541  }
542  }
543  }
544  }
545 
549  public bool _IVA_Deducible
550  {
551  get
552  {
553  if (_lisCampos.ContainsKey("DEDUCE"))
554  return Convert.ToBoolean(_lisCampos["DEDUCE"]._NewVal);
555  else
556  return false;
557  }
558  set
559  {
560  if (_lisCampos.ContainsKey("DEDUCE"))
561  {
562  _lisCampos["DEDUCE"]._NewVal = value;
563 
564  _Exportar_Null();
565  }
566  }
567  }
568 
572  public bool _IVA_Servicios
573  {
574  get
575  {
576  if (_lisCampos.ContainsKey("INMOVIL"))
577  return Convert.ToBoolean(_lisCampos["INMOVIL"]._NewVal);
578  else
579  return false;
580  }
581  set
582  {
583  if (_lisCampos.ContainsKey("INMOVIL"))
584  {
585  _lisCampos["INMOVIL"]._NewVal = value;
586 
587  _Exportar_Null();
588  }
589  }
590  }
591 
595  public int _Tipo_Imp
596  {
597  get
598  {
599  if (_lisCampos.ContainsKey("TIPO_IMP"))
600  return Convert.ToInt16(_lisCampos["TIPO_IMP"]._NewVal);
601  else
602  return 0;
603  }
604  set
605  {
606  if (_lisCampos.ContainsKey("TIPO_IMP"))
607  {
608  _lisCampos["TIPO_IMP"]._NewVal = value;
609 
610  _Exportar_Null();
611  }
612  }
613  }
614 
615 
616 
620  public bool _IVA_BienesInversion
621  {
622  get
623  {
624  if (_lisCampos.ContainsKey("B_INV"))
625  return Convert.ToBoolean(_lisCampos["B_INV"]._NewVal);
626  else
627  return false;
628  }
629  set
630  {
631  if (_lisCampos.ContainsKey("B_INV"))
632  {
633  _lisCampos["B_INV"]._NewVal = value;
634 
635  _Exportar_Null();
636  }
637  }
638  }
639 
657  public bool _IGIC_Sujeto0
658  {
659  get
660  {
661  if (_lisCampos.ContainsKey("CERO"))
662  return Convert.ToBoolean(_lisCampos["CERO"]._NewVal);
663  else
664  return false;
665  }
666  set
667  {
668  if (_lisCampos.ContainsKey("CERO"))
669  {
670  _lisCampos["CERO"]._NewVal = value;
671 
672  _Exportar_Null();
673  }
674  }
675  }
676 
694  public bool _IVA_Sujeto0
695  {
696  get
697  {
698  return _IGIC_Sujeto0;
699  }
700  set
701  {
702  _IGIC_Sujeto0 = value;
703  }
704  }
705 
706 
710  public bool _IVA_Exento
711  {
712  get
713  {
714  if (_lisCampos.ContainsKey("EXENTO"))
715  return Convert.ToBoolean(_lisCampos["EXENTO"]._NewVal);
716  else
717  return false;
718  }
719  set
720  {
721  if (_lisCampos.ContainsKey("EXENTO"))
722  {
723  _lisCampos["EXENTO"]._NewVal = value;
724 
725  _Exportar_Null();
726  }
727  }
728  }
729 
733  public bool _Viajes
734  {
735  get
736  {
737  if (_lisCampos.ContainsKey("AG_VIAJE"))
738  return Convert.ToBoolean(_lisCampos["AG_VIAJE"]._NewVal);
739  else
740  return false;
741  }
742  set
743  {
744  if (_lisCampos.ContainsKey("AG_VIAJE"))
745  {
746  _lisCampos["AG_VIAJE"]._NewVal = value;
747 
748  _Exportar_Null();
749  }
750  }
751  }
752 
756  public Boolean _UtilizarAsistenteListasPrevias
757  {
758  get
759  {
760  return Convert.ToBoolean(EW_GLOBAL._GetVariable("WL_LISTASPREVM", false));
761  }
762  }
763 
767  public string _Guid
768  {
769  get
770  {
771  return Convert.ToString(_Campo("GUID"));
772  }
773  set
774  {
775  _Campo("GUID", value);
776  }
777  }
778 
779  #endregion PROPIEDADES PUBLICAS
780 
781  #region CONSTRUCTORS
782 
786  public TipoIVA()
787  {
788  // Asignamos las propiedades para Familias
789  this._Clave = "Codigo";
790  this._DataBase = "Gestion";
791  this._Tabla = "Tipo_IVA";
792  this._Pantalla = "Tipo_IVA"; //Para determinar si es de solo lectura
793  bool _lRecc = Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_recc"));
794  bool _lProrrata = Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_prorrata_aplicar"));
795 
796  _Browser_Titulos_Campos = "Código, Nombre, % IVA, IVA sopor., IVA reper., " +
797  "Recargo sopor., Recargo reper. " +
798  (! _lRecc ? "" : ", IVA Sopor. pdte. dev., IVA Reper. pdte. dev., Recargo sopor. pdte. dev., Recargo reper. pdte. dev. " ) +
799  (!_lProrrata ? "" : ", IVA sopor. no deduc., IVA sopor. no deduc. pdte. dev. " );
800  _Browser_Campos = "CODIGO, NOMBRE, IVA, CTA_IV_SOP, CTA_IV_REP, " +
801  "CTA_RE_SOP, CTA_RE_REP " +
802  (!_lRecc ? "" : ", PENDEDSOP, PENDEVREP, RECSOPCDEV, RECREPCDEV ") +
803  (!_lProrrata ? "" : ", PRTIVSOPND, PRTIVSNDPD");
804 
805  // IVA o IGIC en funcion de opcflag wl_igic
806  string lc_iva = Convert.ToString(EW_GLOBAL._GetVariable("wc_iva"));
807  lc_iva = lc_iva.Trim();
808 
809  this._TituloMantenimiento = String.Format("Mantenimiento de tipos de {0}", lc_iva);
810  this._TituloCabecera = String.Format("Tipos de {0}", lc_iva);
811 
812  this._FormManteBaseType = typeof(sage.ew.formul.Forms.frmTiposIVA); // PARTE 83953
813  }
814 
815  #endregion CONSTRUCTORS
816 
817  #region METODOS PUBLICOS
818 
823  public override bool _Delete()
824  {
825  bool llOk = true;
826  List<string> loList = new List<string>();
827 
828  // Taules de GESTION
829  loList.Clear();
830  loList.Add("D_PEDIVE");
831  loList.Add("D_ALBDEP");
832  loList.Add("IVAREPER");
833  loList.Add("IVASOPOR");
834  loList.Add("ASIDEFIN");
835  loList.Add("D_ALBVEN");
836  loList.Add("PROVEED");
837  loList.Add("ARTICULO");
838  loList.Add("D_ALBCOM");
839  loList.Add("D_PEDICO");
840  loList.Add("EMPRESA");
841  loList.Add("CLIENTES");
842  loList.Add("D_PRESUV");
843  loList.Add("D_PLAPR");
844  loList.Add("PORTES");
845  loList.Add("PORTES_PDV");
846  loList.Add("PORTES_PRV");
847  loList.Add("PORTES_DPV");
848  loList.Add("PORTESC");
849  loList.Add("ENTRE_CL");
850  loList.Add("LOTES");
851  loList.Add("D_PRECOM");
852  loList.Add("D_CERTIF");
853  loList.Add("D_DEPCOM");
854  loList.Add("MODTIPO");
855  loList.Add("MOD349R");
856  loList.Add("ORD_SOPT");
857  loList.Add("IVRECPLUS");
858  loList.Add("IVSOCPLUS");
859 
860  llOk = llOk && !_Existen_Registros("GESTION", loList, "TIPO_IVA");
861 
862  // Taules de COMUNES
863  loList.Clear();
864  loList.Add("MODELO");
865  loList.Add("CONCEP");
866  loList.Add("OBRA");
867  loList.Add("IVACJREPER");
868  loList.Add("IVACJSOPOR");
869 
870  llOk = llOk && !_Existen_Registros("COMUNES", loList, "TIPO_IVA");
871 
872 
873  if (llOk)
874  return base._Delete();
875  else
876  {
877 
878  // IVA o IGIC en funcion de opcflag wl_igic
879  string lc_iva = Convert.ToString(EW_GLOBAL._GetVariable("wc_iva"));
880  lc_iva = lc_iva.Trim();
881 
882  this._Error_Message = "Este código de tipo de "+lc_iva+" está siendo utilizado por el programa. No se puede borrar el código de tipo de "+lc_iva+".";
883  }
884 
885  return llOk;
886  }
887 
892  public bool HayMovimientos()
893  {
894  List<string> loList = new List<string>();
895 
896  loList.Add("IVAREPER");
897  loList.Add("IVASOPOR");
898  loList.Add("IVA_EXEN");
899 
900  return _Existen_Registros("GESTION", loList, "TIPO_IVA");
901  }
902 
903  // PARTE 101238
910  public DataTable _Control_Iva_Deducible(string tcCampoCuenta,string tcValorCuenta)
911  {
912  string lcSql;
913  DataTable ldtDeducible = new DataTable();
914 
915  lcSql = "SELECT codigo, nombre " +
916  "FROM " + DB.SQLDatabase("gestion", "tipo_iva") + " " +
917  "WHERE codigo != " + DB.SQLString(this._Codigo) + " " +
918  "AND deduce = ";
919 
920  if (this._IVA_Deducible)
921  lcSql = lcSql + DB.SQLString(true);
922  else
923  lcSql = lcSql + DB.SQLString(false);
924 
925  DB.SQLExec(lcSql + "AND " + tcCampoCuenta + " = " + DB.SQLString(tcValorCuenta), ref ldtDeducible);
926 
927  return ldtDeducible;
928  }
929 
930 
946  public bool _Comprobar_Ctas_Iva(string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, string tcProrrataIvaSop, string tcProrrataCriIvaSop, out string tcMensaje)
947  {
948  return _Comprobar_Ctas_Iva(this._cNombreImpuesto, tcIvaSop, tcIvaRep, tcRecSop, tcRecRep, tcCriIvaSop, tcCriIvaRep, tcCriRecSop, tcCriRecRep, tcProrrataIvaSop, tcProrrataCriIvaSop, out tcMensaje);
949  }
950 
967  public bool _Comprobar_Ctas_Iva(string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, string tcProrrataIvaSop, string tcProrrataCriIvaSop, out string tcMensaje, string tcEjercicio)
968  {
969  return _Comprobar_Ctas_Iva(this._cNombreImpuesto, tcIvaSop, tcIvaRep, tcRecSop, tcRecRep, tcCriIvaSop, tcCriIvaRep, tcCriRecSop, tcCriRecRep, tcProrrataIvaSop, tcProrrataCriIvaSop, out tcMensaje, tcEjercicio);
970  }
971 
988  public bool _Comprobar_Ctas_Iva(string tcTipoImpuesto, string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, string tcProrrataIvaSop, string tcProrrataCriIvaSop, out string tcMensaje)
989  {
990  return _Comprobar_Ctas_Iva(this._cNombreImpuesto, tcIvaSop, tcIvaRep, tcRecSop, tcRecRep, tcCriIvaSop, tcCriIvaRep, tcCriRecSop, tcCriRecRep, tcProrrataIvaSop, tcProrrataCriIvaSop, out tcMensaje, "GESTION");
991  }
992 
1010  private bool _Comprobar_Ctas_Iva(string tcTipoImpuesto, string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, string tcProrrataIvaSop, string tcProrrataCriIvaSop, out string tcMensaje, string tcEjercicio = "GESTION")
1011  {
1012  string lcSql, lcWhere = string.Empty;
1013  DataTable ldtIvas = new DataTable();
1014  string lcIva = string.Empty;
1015  bool llOk = true;
1016  string lcSql1 = "";
1017 
1018  tcMensaje = "";
1019 
1020  // 2 COMPROBACIONES
1021 
1022 
1023  // COMPROBACION 1:
1024  // Primero comprobaremos si existe otro TIPO de IVA que tenga la misma cuenta de ivareper o ivasopor o recreper o recsopor que éste en el que estamos en el mismo campo, si existe, avisaremos
1025  // pero dejaremos continuar.
1026 
1027  lcSql = "SELECT CODIGO, NOMBRE, TIPO FROM " + DB.SQLDatabase(tcEjercicio, "TIPO_IVA") +
1028  " WHERE codigo != " + DB.SQLString(this._Codigo);
1029  lcSql1 = lcSql;
1030 
1031  // Cuentas de IVA y recargo equiv.
1032  if (!string.IsNullOrWhiteSpace(tcIvaSop))
1033  {
1034  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_sop = " + DB.SQLString(tcIvaSop) + " ";
1035  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_sop = " + DB.SQLString(tcIvaSop) + " ";
1036  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "pendedsop = " + DB.SQLString(tcIvaSop) + " ";
1037  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "recsopcdev = " + DB.SQLString(tcIvaSop) + " ";
1038  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsopnd = " + DB.SQLString(tcIvaSop) + " ";
1039  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsndpd = " + DB.SQLString(tcIvaSop) + " ";
1040  }
1041 
1042  if (!string.IsNullOrWhiteSpace(tcIvaRep))
1043  {
1044  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_rep = " + DB.SQLString(tcIvaRep) + " ";
1045  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_rep = " + DB.SQLString(tcIvaRep) + " ";
1046  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "pendevrep = " + DB.SQLString(tcIvaRep) + " ";
1047  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "recrepcdev = " + DB.SQLString(tcIvaRep) + " ";
1048  }
1049 
1050  if (!string.IsNullOrWhiteSpace(tcRecSop))
1051  {
1052  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_sop = " + DB.SQLString(tcRecSop) + " ";
1053  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_sop = " + DB.SQLString(tcRecSop) + " ";
1054  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "pendedsop = " + DB.SQLString(tcRecSop) + " ";
1055  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "recsopcdev = " + DB.SQLString(tcRecSop) + " ";
1056  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsopnd = " + DB.SQLString(tcRecSop) + " ";
1057  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsndpd = " + DB.SQLString(tcRecSop) + " ";
1058  }
1059 
1060  if (!string.IsNullOrWhiteSpace(tcRecRep))
1061  {
1062  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_rep = " + DB.SQLString(tcRecRep) + " ";
1063  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_rep = " + DB.SQLString(tcRecRep) + " ";
1064  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "pendevrep = " + DB.SQLString(tcRecRep) + " ";
1065  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "recrepcdev = " + DB.SQLString(tcRecRep) + " ";
1066  }
1067 
1068  if (!string.IsNullOrWhiteSpace(tcCriIvaSop))
1069  {
1070  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_sop = " + DB.SQLString(tcCriIvaSop) + " ";
1071  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_sop = " + DB.SQLString(tcCriIvaSop) + " ";
1072  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "pendedsop = " + DB.SQLString(tcCriIvaSop) + " ";
1073  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "recsopcdev = " + DB.SQLString(tcCriIvaSop) + " ";
1074  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsopnd = " + DB.SQLString(tcCriIvaSop) + " ";
1075  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsndpd = " + DB.SQLString(tcCriIvaSop) + " ";
1076  }
1077 
1078  if (!string.IsNullOrWhiteSpace(tcCriIvaRep))
1079  {
1080  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_rep = " + DB.SQLString(tcCriIvaRep) + " ";
1081  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_rep = " + DB.SQLString(tcCriIvaRep) + " ";
1082  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "pendevrep = " + DB.SQLString(tcCriIvaRep) + " ";
1083  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "recrepcdev = " + DB.SQLString(tcCriIvaRep) + " ";
1084  }
1085 
1086  if (!string.IsNullOrWhiteSpace(tcCriRecSop))
1087  {
1088  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_sop = " + DB.SQLString(tcCriRecSop) + " ";
1089  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_sop = " + DB.SQLString(tcCriRecSop) + " ";
1090  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "pendedsop = " + DB.SQLString(tcCriRecSop) + " ";
1091  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "recsopcdev = " + DB.SQLString(tcCriRecSop) + " ";
1092  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsopnd = " + DB.SQLString(tcCriRecSop) + " ";
1093  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsndpd = " + DB.SQLString(tcCriRecSop) + " ";
1094  }
1095 
1096  if (!string.IsNullOrWhiteSpace(tcCriRecRep))
1097  {
1098  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_rep = " + DB.SQLString(tcCriRecRep) + " ";
1099  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_rep = " + DB.SQLString(tcCriRecRep) + " ";
1100  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "pendevrep = " + DB.SQLString(tcCriRecRep) + " ";
1101  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "recrepcdev = " + DB.SQLString(tcCriRecRep) + " ";
1102  }
1103 
1104  if (!string.IsNullOrWhiteSpace(tcProrrataIvaSop))
1105  {
1106  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_sop = " + DB.SQLString(tcProrrataIvaSop) + " ";
1107  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_sop = " + DB.SQLString(tcProrrataIvaSop) + " ";
1108  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "pendedsop = " + DB.SQLString(tcProrrataIvaSop) + " ";
1109  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "recsopcdev = " + DB.SQLString(tcProrrataIvaSop) + " ";
1110  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsopnd = " + DB.SQLString(tcProrrataIvaSop) + " ";
1111  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsndpd = " + DB.SQLString(tcProrrataIvaSop) + " ";
1112  }
1113 
1114  if (!string.IsNullOrWhiteSpace(tcProrrataCriIvaSop))
1115  {
1116  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_sop = " + DB.SQLString(tcProrrataCriIvaSop) + " ";
1117  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_sop = " + DB.SQLString(tcProrrataCriIvaSop) + " ";
1118  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "pendedsop = " + DB.SQLString(tcProrrataCriIvaSop) + " ";
1119  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "recsopcdev = " + DB.SQLString(tcProrrataCriIvaSop) + " ";
1120  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsopnd = " + DB.SQLString(tcProrrataCriIvaSop) + " ";
1121  lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "prtivsndpd = " + DB.SQLString(tcProrrataCriIvaSop) + " ";
1122  }
1123 
1124  if (!string.IsNullOrWhiteSpace(lcWhere))
1125  {
1126  lcSql += " AND ( " + lcWhere + ") ";
1127 
1128  DB.SQLExec(lcSql, ref ldtIvas);
1129 
1130  if (ldtIvas != null && ldtIvas.Rows.Count > 0)
1131  {
1132  foreach (DataRow loRow in ldtIvas.Rows)
1133  {
1134  lcIva = String.Format("{2} con código {0} y nombre {1}", Convert.ToString(loRow["CODIGO"]), Convert.ToString(loRow["NOMBRE"]).Trim(), Convert.ToInt32(loRow["TIPO"]) == 0 ? "IVA" : "IGIC");
1135  tcMensaje += String.Format("El tipo de {0} comparte alguna cuenta contable con el tipo de {1} actual.{2}{2}", lcIva, tcTipoImpuesto, Environment.NewLine);
1136  }
1137  tcMensaje += "No se permiten utilizar cuentas ya utilizadas en otros tipos de IVA/IGIC.";
1138  llOk = false;
1139  }
1140  }
1141 
1142 
1143  // COMPROBACION 2:
1144  // Luego comprobaremos si existe otro TIPO de IVA que tenga en la cuenta de iva lo que en éste tenemos en recargo o viceversa o
1145  // Idem para las cuentas de criterio.
1146  //lcSql = lcSql1;
1147  //lcWhere = "";
1148 
1150  //if (!string.IsNullOrWhiteSpace(tcIvaSop))
1151  // lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_sop = " + DB.SQLString(tcIvaSop) + (_lRecc ? " or recsopcdev= " + DB.SQLString(tcIvaSop) : "") + " ";
1152 
1153  //if (!string.IsNullOrWhiteSpace(tcIvaRep))
1154  // lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_rep = " + DB.SQLString(tcIvaRep) + (_lRecc ? " or recrepcdev= " + DB.SQLString(tcIvaRep): "") + " ";
1155 
1156  //if (!string.IsNullOrWhiteSpace(tcRecSop))
1157  // lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_sop = " + DB.SQLString(tcRecSop) + (_lRecc ? " or pendedsop= " + DB.SQLString(tcIvaRep) : "") + " ";
1158 
1159  //if (!string.IsNullOrWhiteSpace(tcRecRep))
1160  // lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_rep = " + DB.SQLString(tcRecRep) + (_lRecc ? " or pendevrep= " + DB.SQLString(tcIvaRep) : "") + " ";
1161 
1163  //if (_lRecc)
1164  //{
1165  // if (!string.IsNullOrWhiteSpace(tcCriIvaSop))
1166  // lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_sop = " + DB.SQLString(tcCriIvaSop) + " or recsopcdev= " + DB.SQLString(tcCriIvaSop) + " ";
1167 
1168  // if (!string.IsNullOrWhiteSpace(tcCriIvaRep))
1169  // lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_re_rep = " + DB.SQLString(tcCriIvaRep) + " or recrepcdev= " + DB.SQLString(tcCriIvaRep) + " ";
1170 
1171  // if (!string.IsNullOrWhiteSpace(tcCriRecSop))
1172  // lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_sop = " + DB.SQLString(tcCriRecSop) + " or pendedsop= " + DB.SQLString(tcCriRecSop)+" ";
1173 
1174  // if (!string.IsNullOrWhiteSpace(tcCriRecRep))
1175  // lcWhere += (!string.IsNullOrWhiteSpace(lcWhere) ? " OR " : "") + "cta_iv_rep = " + DB.SQLString(tcCriRecRep) + " or pendevrep= " + DB.SQLString(tcCriRecRep) + " ";
1176  //}
1177 
1178  //if (!string.IsNullOrWhiteSpace(lcWhere))
1179  //{
1180  // lcSql += " AND ( " + lcWhere + ") ";
1181 
1182  // DB.SQLExec(lcSql, ref ldtIvas);
1183 
1184  // if (ldtIvas != null && ldtIvas.Rows.Count > 0)
1185  // {
1186  // lcIva = Convert.ToString(ldtIvas.Rows[0]["CODIGO"]) + " - " + Convert.ToString(ldtIvas.Rows[0]["NOMBRE"]).Trim();
1187  // if (!string.IsNullOrWhiteSpace(lcIva))
1188  // {
1189  // // Se avisa pero se permite continuar.
1190  // tcMensaje = "Conflicto de cuentas contables entre el tipo de " + this._cNombreImpuesto + " actual "+
1191  // "y el tipo de " + this._cNombreImpuesto + " "+lcIva + Environment.NewLine+ Environment.NewLine+
1192  // "Alguna de las cuentas contables de soportado o repercutido en el tipo de " + this._cNombreImpuesto + " " + lcIva + " " +
1193  // "se encuentran también declaradas como cuentas de recargo en el tipo de "+this._cNombreImpuesto+" actual, o viceversa."+ Environment.NewLine+ Environment.NewLine+
1194  // "Por favor, revise la configuración de cuentas contables en el tipo de " + this._cNombreImpuesto + " actual.";
1195  // // Avisaremos y no permitiremos continuar.
1196  // llOk=false;
1197  // }
1198  // }
1199  //}
1200 
1201  return llOk;
1202  }
1203 
1204 
1218  public bool _Comprobar_Ctas_Iva(string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, out string tcMensaje)
1219  {
1220  bool llOk = this._Comprobar_Ctas_Iva(tcIvaSop, tcIvaRep, tcRecSop, tcRecRep, tcCriIvaSop, tcCriIvaRep, tcCriRecSop, tcCriRecRep, "", "", out tcMensaje);
1221 
1222  return llOk;
1223  }
1224 
1239  public bool _Comprobar_Ctas_Iva(string tcTipoImpuesto, string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, out string tcMensaje)
1240  {
1241  bool llOk = this._Comprobar_Ctas_Iva(tcTipoImpuesto, tcIvaSop, tcIvaRep, tcRecSop, tcRecRep, tcCriIvaSop, tcCriIvaRep, tcCriRecSop, tcCriRecRep, "", "", out tcMensaje);
1242 
1243  return llOk;
1244  }
1245 
1253  protected override bool _TraspasarSiguienteEjercicio(TipoExecute toTipoExecute, string tcEjercicio, bool tbIsNew)
1254  {
1255  if (toTipoExecute == TipoExecute.Before && !_Comprobar_Ctas_Iva(_Cta_IVA_Sop, _Cta_IVA_Rep, _Cta_REC_Sop, _Cta_REC_Rep, _Pendedsop, _Pendevrep, _Recsopcdev, _Recrepcdev, _Cta_IVA_Sop_Nodeduc, _Pendedsop_Nodeduc, out string lcMensajeError, tcEjercicio))
1256  {
1257  lcMensajeError = lcMensajeError.Replace($"{Environment.NewLine}{Environment.NewLine}", Environment.NewLine);
1258  lcMensajeError = lcMensajeError.Replace($"actual", "a traspasar");
1259 
1260  _ShowMessageValidacionTrapaso($"No se puede crear el Tipo de Iva en el siguiente ejercicio ({tcEjercicio}):{Environment.NewLine}{lcMensajeError}", tcEjercicio, tbIsNew);
1261 
1262  return false;
1263  }
1264  else
1265  {
1266  return base._TraspasarSiguienteEjercicio(toTipoExecute, tcEjercicio, tbIsNew);
1267  }
1268  }
1269 
1274  public override bool _Save_Before()
1275  {
1276  Boolean llOk;
1277  String lcErrorMessage, lcErrorMessageTotal = "";
1278  Dictionary<String, String> loErrores = new Dictionary<String, String>();
1279 
1280  if (this._FormMante != null) this._FormMante._oErrorProvider.Clear();
1281 
1282  llOk = base._Save_Before();
1283 
1284  if (_Estado == _EstadosMantenimiento.EntrandoNuevo || _Estado == _EstadosMantenimiento.EditandoRegistro)
1285  {
1286  string lcIva = Convert.ToString(EW_GLOBAL._GetVariable("wc_iva"));
1287  if (string.IsNullOrWhiteSpace(lcIva))
1288  lcIva = "IVA";
1289 
1290  //Validamos que las cuentas contables estadard esten informadas
1291  if (String.IsNullOrWhiteSpace(_cIvaSop3) || String.IsNullOrWhiteSpace(_cIvaRep3) || String.IsNullOrWhiteSpace(_cIvaRecRep3) || String.IsNullOrWhiteSpace(_cIvaRecSop3) || (this._lProrrata && String.IsNullOrEmpty(this._cIvaSop3_Nodeduc)))
1292  {
1293  if (String.IsNullOrWhiteSpace(_cIvaSop3)) lcErrorMessageTotal += " " + lcIva + " soportado";
1294  if (String.IsNullOrWhiteSpace(_cIvaRep3)) lcErrorMessageTotal += String.Format("{0} {1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : ",", lcIva + " repercutido");
1295  if (String.IsNullOrWhiteSpace(_cIvaRecRep3)) lcErrorMessageTotal += String.Format("{0} {1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : ",", "recargo soportado");
1296  if (String.IsNullOrWhiteSpace(_cIvaRecSop3)) lcErrorMessageTotal += String.Format("{0} {1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : ",", "recargo repercutido");
1297  if (this._lProrrata && String.IsNullOrEmpty(this._cIvaSop3_Nodeduc)) lcErrorMessageTotal += String.Format("{0} {1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : ",", lcIva + " soportado no deducible (Prorrata)'");
1298 
1299  if (lcErrorMessageTotal.Contains(","))
1300  {
1301  lcErrorMessageTotal = String.Format("{0} y {1}", lcErrorMessageTotal.Substring(0, lcErrorMessageTotal.LastIndexOf(",")), lcErrorMessageTotal.Substring(lcErrorMessageTotal.LastIndexOf(",") + 1));
1302  lcErrorMessageTotal = String.Format("Las cuentas contables estándar {0} no estan informadas, antes de continuar debe informarlas.", lcErrorMessageTotal);
1303  }
1304  else
1305  {
1306  lcErrorMessageTotal = String.Format("La cuenta contable estándar {0} no esta informada, antes de continuar debe informarla.", lcErrorMessageTotal);
1307  }
1308  _Error_Message = lcErrorMessageTotal;
1309  llOk = false;
1310  }
1311 
1312  if (llOk)
1313  {
1314  lcErrorMessageTotal = "";
1315 
1316  if (_Tipo == TipoIVA.TipoImpuesto.IGIC && this._IVA_Exento)
1317  {
1318  if (llOk && this._IVA != 0)
1319  {
1320  lcErrorMessage = $"No se pueden marcar como exentos, los tipos de {lcIva} que tenga un % de {lcIva} diferente de 0.";
1321  lcErrorMessageTotal += lcErrorMessage;
1322  _AddError(loErrores, "_IVA", lcErrorMessage);
1323  llOk = false;
1324  }
1325 
1326  if (llOk && this._Recargo != 0 )
1327  {
1328  lcErrorMessage = $"No se pueden marcar como exentos, los tipos de {lcIva} que tenga un % de recargo diferente de 0.";
1329  lcErrorMessageTotal += lcErrorMessage;
1330  _AddError(loErrores, "_Recargo", lcErrorMessage);
1331  llOk = false;
1332  }
1333  }
1334 
1335  if (llOk && this._Recargo != 0 && this._IVA == 0)
1336  {
1337  lcErrorMessage = $"No se puede especificar % recargo en un tipo de {lcIva} que tenga 0 % de {lcIva}";
1338  lcErrorMessageTotal += lcErrorMessage;
1339  _AddError(loErrores, "_Recargo", lcErrorMessage);
1340  llOk = false;
1341  }
1342 
1343  _Error_Message = lcErrorMessageTotal;
1344  _SetErrorControl(loErrores);
1345  }
1346 
1347  //Validamos campos vacios
1348  if (llOk)
1349  {
1350  if (String.IsNullOrWhiteSpace(this._Cta_IVA_Sop))
1351  {
1352  lcErrorMessage = "La cuenta de " + lcIva + " soportado no puede quedar vacía.";
1353  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1354  _AddError(loErrores, "_Cta_IVA_Sop", lcErrorMessage);
1355  llOk = false;
1356  }
1357 
1358  if (String.IsNullOrWhiteSpace(this._Cta_IVA_Rep))
1359  {
1360  lcErrorMessage = "La cuenta de " + lcIva + " repercutido no puede quedar vacía.";
1361  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1362  _AddError(loErrores,"_Cta_IVA_Rep", lcErrorMessage);
1363  llOk = false;
1364  }
1365 
1366  if (this._Recargo != 0)
1367  {
1368  if (String.IsNullOrWhiteSpace(this._Cta_REC_Sop))
1369  {
1370  lcErrorMessage = "La cuenta de recargo soportado no puede quedar vacía pues ha declarado % recargo (" + this._Recargo.ToString().Trim() + ").";
1371  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1372  _AddError(loErrores,"_Cta_REC_Sop", lcErrorMessage);
1373  llOk = false;
1374  }
1375 
1376  if (String.IsNullOrWhiteSpace(this._Cta_REC_Rep))
1377  {
1378  lcErrorMessage = "La cuenta de recargo repercutido no puede quedar vacía pues ha declarado % recargo (" + this._Recargo.ToString().Trim() + ").";
1379  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1380  _AddError(loErrores,"_Cta_REC_Rep", lcErrorMessage);
1381  llOk = false;
1382  }
1383  }
1384 
1385  if (this._lProrrata)
1386  {
1387  if (String.IsNullOrWhiteSpace(this._Cta_IVA_Sop_Nodeduc))
1388  {
1389  lcErrorMessage = "La cuenta de " + lcIva + " soportado no deducible no puede quedar vacía.";
1390  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1391  _AddError(loErrores,"_Cta_IVA_Sop_Nodeduc", lcErrorMessage);
1392  llOk = false;
1393  }
1394  }
1395 
1396  if (_lRecc)
1397  {
1398  if (string.IsNullOrWhiteSpace(_Pendedsop)) //Soportado pendiente devengado (Criterio de caja)
1399  {
1400  lcErrorMessage = "La cuenta de soportado pendiente devengo para criterio de caja no puede estar vacía";
1401  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1402  _AddError(loErrores,"_Pendedsop", lcErrorMessage);
1403  llOk = false;
1404  }
1405 
1406  if (string.IsNullOrWhiteSpace(_Pendevrep)) //Repercutido pendiente devengado (Criterio de caja)
1407  {
1408  lcErrorMessage = "La cuenta de repercutido pendiente devengo para criterio de caja no puede estar vacía";
1409  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1410  _AddError(loErrores,"_Pendevrep", lcErrorMessage);
1411  llOk = false;
1412  }
1413 
1414  if (this._Recargo != 0)
1415  {
1416  if (String.IsNullOrWhiteSpace(this._Recsopcdev))
1417  {
1418  lcErrorMessage = "La cuenta de recargo soportado pendiente devengo no puede quedar vacía pues ha declarado % recargo (" + this._Recargo.ToString().Trim() + ").";
1419  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1420  _AddError(loErrores,"_Recsopcdev", lcErrorMessage);
1421  llOk = false;
1422  }
1423 
1424  if (String.IsNullOrWhiteSpace(this._Recrepcdev))
1425  {
1426  lcErrorMessage = "La cuenta de recargo repercutido pendiente devengo no puede quedar vacía pues ha declarado % recargo (" + this._Recargo.ToString().Trim() + ").";
1427  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1428  _AddError(loErrores,"_Recrepcdev", lcErrorMessage);
1429  llOk = false;
1430  }
1431  }
1432 
1433  if (this._lProrrata)
1434  {
1435  // Al igual que si tenemos activado el criterio de caja obligamos a declarar las dos cuentas de soportado y
1436  // repercutido de criterio de caja, si además tenemos activado la regla de la prorrata también obligamos
1437  // a introducir la cuenta de soportado no deducible pendiente de devengo.
1438  //
1439  if (string.IsNullOrWhiteSpace(_Pendedsop_Nodeduc)) // Soportado no deducible pendiente devengo (Prorrata y Criterio de caja)
1440  {
1441  lcErrorMessage = "La cuenta de "+lcIva+" soportado no deducible pendiente devengo para criterio de caja no puede estar vacía";
1442  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1443  _AddError(loErrores,"_Pendedsop_Nodeduc", lcErrorMessage);
1444  llOk = false;
1445  }
1446  }
1447  }
1448 
1449  if (!llOk)
1450  {
1451  _SetErrorControl(loErrores);
1452  _Error_Message = lcErrorMessageTotal;
1453  }
1454  }
1455 
1456  if (llOk)
1457  {
1458  lcErrorMessage = lcErrorMessageTotal = "";
1459 
1460  if (!_ValidaCuenta(_Cta_IVA_Sop, _cIvaSop3, lcIva + " soportado", ref lcErrorMessage))
1461  {
1462  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1463  _AddError(loErrores,"_Cta_IVA_Sop", lcErrorMessage);
1464  llOk = false;
1465  }
1466 
1467  if (!_ValidaCuenta(_Cta_REC_Sop, _cIvaRecSop3, " recargo soportado", ref lcErrorMessage))
1468  {
1469  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1470  _AddError(loErrores,"_Cta_REC_Sop", lcErrorMessage);
1471  llOk = false;
1472  }
1473 
1474  if (_lRecc && !_ValidaCuenta(_Pendedsop, String.IsNullOrWhiteSpace(_cIvaPendSop3) ? _cIvaSop3 : _cIvaPendSop3, "criterio de caja soportado pendiente devengo", ref lcErrorMessage))
1475  {
1476  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1477  _AddError(loErrores,"_Pendedsop", lcErrorMessage);
1478  llOk = false;
1479  }
1480 
1481  if (_lRecc && !_ValidaCuenta(_Recsopcdev, String.IsNullOrWhiteSpace(_cIvaRecPendSop3) ? _cIvaRecSop3 : _cIvaRecPendSop3, "recargo soportado pendiente devengo", ref lcErrorMessage))
1482  {
1483  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1484  _AddError(loErrores,"_Recsopcdev", lcErrorMessage);
1485  llOk = false;
1486  }
1487 
1488  if (_lProrrata)
1489  {
1490  if (!_ValidaCuenta(_Cta_IVA_Sop_Nodeduc, _cIvaSop3_Nodeduc, lcIva + " soportado no deducible", ref lcErrorMessage))
1491  {
1492  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1493  _AddError(loErrores,"_Cta_IVA_Sop_Nodeduc", lcErrorMessage);
1494  llOk = false;
1495  }
1496 
1497  if (_lRecc)
1498  {
1499  if (!_ValidaCuenta(_Pendedsop_Nodeduc, String.IsNullOrWhiteSpace(_cIvaPendSop3_Nodeduc) ? _cIvaSop3 : _cIvaPendSop3_Nodeduc, "criterio de caja soportado no deducible pendiente de devengo", ref lcErrorMessage))
1500  {
1501  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1502  _AddError(loErrores,"_Pendedsop_Nodeduc", lcErrorMessage);
1503  llOk = false;
1504  }
1505  }
1506  }
1507 
1508  if (!_ValidaCuenta(_Cta_IVA_Rep, _cIvaRep3, lcIva + " repercutido", ref lcErrorMessage))
1509  {
1510  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1511  _AddError(loErrores,"_Cta_IVA_Rep", lcErrorMessage);
1512  llOk = false;
1513  }
1514 
1515  if (!_ValidaCuenta(_Cta_REC_Rep, _cIvaRecRep3, " recargo repercutido", ref lcErrorMessage))
1516  {
1517  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1518  _AddError(loErrores,"_Cta_REC_Rep", lcErrorMessage);
1519  llOk = false;
1520  }
1521 
1522  if (_lRecc && !_ValidaCuenta(_Pendevrep, String.IsNullOrWhiteSpace(_cIvaPendRep3) ? _cIvaRep3 : _cIvaPendRep3, "criterio de caja repercutido pendiente devengo", ref lcErrorMessage))
1523  {
1524  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1525  _AddError(loErrores,"_Pendevrep", lcErrorMessage);
1526  llOk = false;
1527  }
1528 
1529  if (_lRecc && !_ValidaCuenta(_Recrepcdev, String.IsNullOrWhiteSpace(_cIvaRecPendRep3) ? _cIvaRecRep3 : _cIvaRecPendRep3, "recargo repercutido pendiente devengo", ref lcErrorMessage))
1530  {
1531  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1532  _AddError(loErrores,"_Recrepcdev", lcErrorMessage);
1533  llOk = false;
1534  }
1535 
1536  if (!llOk)
1537  {
1538  _SetErrorControl(loErrores);
1539  _Error_Message = lcErrorMessageTotal;
1540  }
1541  }
1542 
1543  if (llOk)
1544  {
1545  // Comienzo la validación de la cuenta de IVA soportado normal.
1546  //
1547  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Sop) && !string.IsNullOrWhiteSpace(this._Cta_REC_Sop) && this._Cta_IVA_Sop == this._Cta_REC_Sop)
1548  {
1549  lcErrorMessage = "Las cuentas de " + lcIva + " soportado y de recargo soportado deben ser distintas (" + this._Cta_IVA_Sop + ").";
1550  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1551  _AddError(loErrores, "_Cta_IVA_Sop", lcErrorMessage);
1552  _AddError(loErrores, "_Cta_REC_Sop", lcErrorMessage);
1553  llOk = false;
1554  }
1555 
1556 
1557  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Sop) && !string.IsNullOrWhiteSpace(this._Pendedsop) && this._Cta_IVA_Sop == this._Pendedsop)
1558  {
1559  lcErrorMessage = "Las cuentas de " + lcIva + " soportado y de criterio de caja soportado pendiente devengo deben ser distintas (" + this._Cta_IVA_Sop + ").";
1560  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1561  _AddError(loErrores, new List<string>() { "_Pendedsop", "_Cta_IVA_Sop" }, lcErrorMessage);
1562  llOk = false;
1563  }
1564 
1565  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Sop) && !string.IsNullOrWhiteSpace(this._Recsopcdev) && this._Cta_IVA_Sop == this._Recsopcdev)
1566  {
1567  lcErrorMessage = "Las cuentas de " + lcIva + " soportado y de recargo soportado pendiente devengo deben ser distintas (" + this._Cta_IVA_Sop + ").";
1568  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1569  _AddError(loErrores, new List<string>() { "_Recsopcdev", "_Cta_IVA_Sop" }, lcErrorMessage);
1570  llOk = false;
1571  }
1572 
1573  if (this._lProrrata)
1574  {
1575  // Continuamos validando la cuenta de IVA soportado normal contra las dos nuevas cuentas del apartado Prorrata.
1576  //
1577  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Sop) && !string.IsNullOrWhiteSpace(this._Cta_IVA_Sop_Nodeduc)
1578  && this._Cta_IVA_Sop == this._Cta_IVA_Sop_Nodeduc)
1579  {
1580  lcErrorMessage = "Las cuentas de " + lcIva + " soportado y de " + lcIva + " soportado no deducible deben ser distintas (" + this._Cta_IVA_Sop_Nodeduc + ").";
1581  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1582  _AddError(loErrores, new List<string>() { "_Cta_IVA_Sop_Nodeduc", "_Cta_IVA_Sop" }, lcErrorMessage);
1583  llOk = false;
1584  }
1585 
1586  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Sop) && !string.IsNullOrWhiteSpace(this._Pendedsop_Nodeduc)
1587  && this._Cta_IVA_Sop == this._Pendedsop_Nodeduc)
1588  {
1589  lcErrorMessage = "Las cuentas de " + lcIva + " soportado y de "+lcIva+" soportado no deducible pendiente devengo deben ser distintas (" + this._Cta_IVA_Sop + ").";
1590  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1591  _AddError(loErrores, new List<string>() { "_Pendedsop_Nodeduc", "_Cta_IVA_Sop" }, lcErrorMessage);
1592  llOk = false;
1593  }
1594 
1595  // Comienzo la validación de la cuenta de IVA soportado no deducible.
1596  //
1597  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Sop_Nodeduc) && !string.IsNullOrWhiteSpace(this._Cta_REC_Sop)
1598  && this._Cta_IVA_Sop_Nodeduc == this._Cta_REC_Sop)
1599  {
1600  lcErrorMessage = "Las cuentas de " + lcIva + " soportado no deducible y de recargo soportado deben ser distintas (" + this._Cta_IVA_Sop_Nodeduc + ").";
1601  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1602  _AddError(loErrores, new List<string>() { "_Cta_IVA_Sop_Nodeduc", "_Cta_REC_Sop" }, lcErrorMessage);
1603  llOk = false;
1604  }
1605 
1606  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Sop_Nodeduc) && !string.IsNullOrWhiteSpace(this._Pendedsop)
1607  && this._Cta_IVA_Sop_Nodeduc == this._Pendedsop)
1608  {
1609  lcErrorMessage = "Las cuentas de " + lcIva + " soportado no deducible y de criterio de caja soportado pendiente devengo deben ser distintas (" + this._Cta_IVA_Sop_Nodeduc + ").";
1610  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1611  _AddError(loErrores, new List<string>() { "_Cta_IVA_Sop_Nodeduc", "_Pendedsop" }, lcErrorMessage);
1612  llOk = false;
1613  }
1614 
1615 
1616  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Sop_Nodeduc) && !string.IsNullOrWhiteSpace(this._Recsopcdev)
1617  && this._Cta_IVA_Sop_Nodeduc == this._Recsopcdev)
1618  {
1619  lcErrorMessage = "Las cuentas de " + lcIva + " soportado no deducible y de recargo soportado pendiente devengo deben ser distintas (" + this._Cta_IVA_Sop_Nodeduc + ").";
1620  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1621  _AddError(loErrores, new List<string>() { "_Recsopcdev", "_Cta_IVA_Sop_Nodeduc" }, lcErrorMessage);
1622  llOk = false;
1623  }
1624 
1625  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Sop_Nodeduc) && !string.IsNullOrWhiteSpace(this._Pendedsop_Nodeduc)
1626  && this._Cta_IVA_Sop_Nodeduc == this._Pendedsop_Nodeduc)
1627  {
1628  lcErrorMessage = "Las cuentas de " + lcIva + " soportado no deducible y de " + lcIva + " soportado no deducible pendiente devengo deben ser distintas (" + this._Cta_IVA_Sop_Nodeduc + ").";
1629  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1630  _AddError(loErrores, new List<string>() { "_Pendedsop_Nodeduc", "_Cta_IVA_Sop_Nodeduc" }, lcErrorMessage);
1631  llOk = false;
1632  }
1633  }
1634 
1635  // Validacion de la cuenta de IVA soportado pendiente de devengo.
1636  //
1637  if (!string.IsNullOrWhiteSpace(this._Pendedsop) && !string.IsNullOrWhiteSpace(this._Cta_REC_Sop) && this._Pendedsop == this._Cta_REC_Sop)
1638  {
1639  lcErrorMessage = "Las cuentas de criterio de caja soportado pendiente devengo y recargo soportado deben ser distintas (" + this._Pendedsop + ").";
1640  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1641  _AddError(loErrores, new List<string>() { "_Pendedsop", "_Cta_REC_Sop" }, lcErrorMessage);
1642  llOk = false;
1643  }
1644 
1645  if (!string.IsNullOrWhiteSpace(this._Pendedsop) && !string.IsNullOrWhiteSpace(this._Recsopcdev) && this._Pendedsop == this._Recsopcdev)
1646  {
1647  lcErrorMessage = "Las cuentas de criterio de caja soportado pendiente devengo y recargo soportado pendiente devengo deben ser distintas (" + this._Pendedsop + ").";
1648  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1649  _AddError(loErrores, new List<string>() { "_Recsopcdev", "_Pendedsop" }, lcErrorMessage);
1650  llOk = false;
1651  }
1652 
1653  if (this._lProrrata)
1654  {
1655  // Continuo validando la cuenta de IVA soportado pendiente devengo contra las cuentas del apartado PRORRATA.
1656  //
1657  if (!string.IsNullOrWhiteSpace(this._Pendedsop) && !string.IsNullOrWhiteSpace(this._Pendedsop_Nodeduc) && this._Pendedsop == this._Pendedsop_Nodeduc)
1658  {
1659  lcErrorMessage = "Las cuentas de criterio de caja soportado pendiente devengo y "+lcIva+" soportado no deducible pendiente devengo deben ser distintas (" + this._Pendedsop + ").";
1660  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1661  _AddError(loErrores, new List<string>() { "_Pendedsop_Nodeduc", "_Pendedsop" }, lcErrorMessage);
1662  llOk = false;
1663  }
1664 
1665  // Iniciamos validación cuenta IVA soportado no deducible pendiente de devengo.
1666  //
1667  if (!string.IsNullOrWhiteSpace(this._Pendedsop_Nodeduc) && !string.IsNullOrWhiteSpace(this._Cta_REC_Sop) && this._Pendedsop_Nodeduc == this._Cta_REC_Sop)
1668  {
1669  lcErrorMessage = "Las cuentas de recargo soportado y " + lcIva + " soportado no deducible pendiente devengo deben ser distintas (" + this._Pendedsop_Nodeduc + ").";
1670  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1671  _AddError(loErrores, new List<string>() { "_Pendedsop_Nodeduc", "_Cta_REC_Sop" }, lcErrorMessage);
1672  llOk = false;
1673  }
1674 
1675  if (!string.IsNullOrWhiteSpace(this._Pendedsop_Nodeduc) && !string.IsNullOrWhiteSpace(this._Recsopcdev) && this._Pendedsop_Nodeduc == this._Recsopcdev)
1676  {
1677  lcErrorMessage = "Las cuentas de recargo soportado pendiente de devengo y " + lcIva + " soportado no deducible pendiente devengo deben ser distintas (" + this._Pendedsop_Nodeduc + ").";
1678  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1679  _AddError(loErrores, new List<string>() { "_Pendedsop_Nodeduc", "_Recsopcdev" }, lcErrorMessage);
1680  llOk = false;
1681  }
1682  }
1683 
1684  if (!string.IsNullOrWhiteSpace(this._Recsopcdev) && !string.IsNullOrWhiteSpace(this._Cta_REC_Sop)
1685  && this._Recsopcdev == this._Cta_REC_Sop)
1686  {
1687  lcErrorMessage = "Las cuentas de recargo soportado y criterio de caja recargo soportado pendiente devengo deben ser distintas (" + this._Cta_IVA_Sop + ").";
1688  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1689  _AddError(loErrores, new List<string>() { "_Recsopcdev", "_Cta_REC_Sop" }, lcErrorMessage);
1690  llOk = false;
1691  }
1692 
1693  // IVA REPERCUTIDO
1694  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Rep) && !string.IsNullOrWhiteSpace(this._Cta_REC_Rep) && this._Cta_IVA_Rep == this._Cta_REC_Rep)
1695  {
1696 
1697  lcErrorMessage = "Las cuentas de " + lcIva + " repercutido y de recargo repercutido deben ser distintas (" + this._Cta_IVA_Rep + ").";
1698  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1699  _AddError(loErrores, new List<string>() { "_Cta_REC_Rep", "_Cta_IVA_Rep" }, lcErrorMessage);
1700  llOk = false;
1701  }
1702 
1703  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Rep) && !string.IsNullOrWhiteSpace(this._Recrepcdev) && this._Cta_IVA_Rep == this._Recrepcdev)
1704  {
1705  lcErrorMessage = "Las cuentas de " + lcIva + " repercutido y de recargo repercutido pendiente devengo deben ser distintas (" + this._Cta_IVA_Rep + ").";
1706  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1707  _AddError(loErrores, new List<string>() { "_Recrepcdev", "_Cta_IVA_Rep" }, lcErrorMessage);
1708  llOk = false;
1709  }
1710 
1711  if (!string.IsNullOrWhiteSpace(this._Cta_IVA_Rep) && !string.IsNullOrWhiteSpace(this._Pendevrep) && this._Cta_IVA_Rep == this._Pendevrep)
1712  {
1713  lcErrorMessage = "Las cuentas de " + lcIva + " repercutido y de recargo repercutido pendiente devengo deben ser distintas (" + this._Cta_IVA_Rep + ").";
1714  lcErrorMessageTotal += String.Format("{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1715  _AddError(loErrores, new List<string>() { "_Recrepcdev", "_Cta_IVA_Rep" }, lcErrorMessage);
1716  llOk = false;
1717  }
1718 
1719  if (!string.IsNullOrWhiteSpace(this._Pendevrep) && !string.IsNullOrWhiteSpace(this._Recrepcdev) && this._Pendevrep == this._Recrepcdev)
1720  {
1721  lcErrorMessage = "Las cuentas de criterio de caja repercutido pendiente devengo y recargo repercutido pendiente devengo deben ser distintas (" + this._Pendevrep + ").";
1722  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1723  _AddError(loErrores, new List<string>() { "_Pendevrep", "_Recrepcdev" }, lcErrorMessage);
1724  llOk = false;
1725  }
1726 
1727  if (!string.IsNullOrWhiteSpace(this._Recrepcdev) && !string.IsNullOrWhiteSpace(this._Cta_REC_Rep) && this._Recrepcdev == this._Cta_REC_Rep)
1728  {
1729  lcErrorMessage = "Las cuentas de criterio de caja repercutido pendiente devengo y recargo repercutido deben ser distintas (" + this._Pendevrep + ").";
1730  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1731  _AddError(loErrores, new List<string>() { "_Recrepcdev", "_Cta_REC_Rep" }, lcErrorMessage);
1732  llOk = false;
1733  }
1734 
1735  if (!string.IsNullOrWhiteSpace(this._Pendevrep) && !string.IsNullOrWhiteSpace(this._Cta_REC_Rep) && this._Pendevrep == this._Cta_REC_Rep)
1736  {
1737  lcErrorMessage = "Las cuentas de recargo repercutido y criterio de caja repercutido pendiente devengo deben ser distintas (" + this._Pendevrep + ").";
1738  lcErrorMessageTotal += String.Format("{0}{0}{1}", String.IsNullOrEmpty(lcErrorMessageTotal) ? "" : Environment.NewLine, lcErrorMessage);
1739  _AddError(loErrores, new List<string>() { "_Pendevrep", "_Cta_REC_Rep" }, lcErrorMessage);
1740  llOk = false;
1741  }
1742 
1743  if(!llOk)
1744  {
1745  _SetErrorControl(loErrores);
1746  _Error_Message = lcErrorMessageTotal;
1747  }
1748  else
1749  {
1750  string lcMensajeError;
1751  llOk = _Comprobar_Ctas_Iva(_Cta_IVA_Sop, _Cta_IVA_Rep, _Cta_REC_Sop, _Cta_REC_Rep, _Pendedsop, _Pendevrep, _Recsopcdev, _Recrepcdev, _Cta_IVA_Sop_Nodeduc, _Pendedsop_Nodeduc, out lcMensajeError);
1752  if (!llOk)
1753  _Error_Message = lcMensajeError;
1754  }
1755  }
1756 
1757  }
1758  return llOk;
1759  }
1760 
1761  private void _AddError(Dictionary<String, String> toErrores, List<String> tcListKeys, String tcError)
1762  {
1763  foreach(String lcKey in tcListKeys) _AddError(toErrores, lcKey, tcError);
1764  }
1765 
1766  private void _AddError(Dictionary<String, String> toErrores, String tcKey, String tcError)
1767  {
1768  if(toErrores.ContainsKey(tcKey))
1769  {
1770  if (!toErrores[tcKey].EndsWith(".")) toErrores[tcKey] += ".";
1771  toErrores[tcKey] += tcError;
1772  }
1773  else
1774  {
1775  toErrores.Add(tcKey, tcError);
1776  }
1777  }
1778 
1779  private void _SetErrorControl(Dictionary<String, String> toErrores)
1780  {
1781  if (this._FormMante != null && toErrores is Dictionary<String, String> && toErrores.Count > 0)
1782  {
1783 
1784  this._FormMante._SetFocusOnProperty(toErrores.First().Key);
1785 
1786  foreach (KeyValuePair<String, String> loKeyValuePair in toErrores)
1787  {
1788  this._FormMante._SetError_OnControl(loKeyValuePair.Key, loKeyValuePair.Value);
1789  }
1790  }
1791 
1792  }
1793 
1794  // FPARTE 101238
1795 
1800  public bool _EsIvaCee()
1801  {
1802  bool llEsIvaCee = false;
1803 
1804  if (string.IsNullOrWhiteSpace(_Codigo))
1805  return false;
1806 
1807  string lcIvaOrigen = Convert.ToString(DB.SQLValor("tipo_iva", "iva_cee", _Codigo, "codigo"));
1808 
1809  llEsIvaCee = !string.IsNullOrWhiteSpace(lcIvaOrigen);
1810 
1811  return llEsIvaCee;
1812  }
1813 
1818  public static bool ContieneUnicamenteTiposParaIVA()
1819  {
1820  return ObtenerValoresDeTipo().All(t => t == 0);
1821  }
1822 
1827  public static bool ContieneUnicamenteTiposParaIGIC()
1828  {
1829  return ObtenerValoresDeTipo().All(t => t == 1);
1830  }
1831 
1836  private static IEnumerable<int> ObtenerValoresDeTipo()
1837  {
1838  DataTable datos = new DataTable();
1839 
1840  var lcSql = "SELECT TIPO FROM " + DB.SQLDatabase("GESTION", "TIPO_IVA");
1841  if (DB.SQLExec(lcSql, ref datos) && datos.Rows.Count > 0)
1842  {
1843  foreach (DataRow row in datos.Rows)
1844  {
1845  yield return Convert.ToInt32(row["tipo"]);
1846  }
1847  }
1848  else
1849  {
1850  //Sin tipos de IVA
1851  throw new NotSupportedException();
1852  }
1853  }
1854 
1855  #endregion METODOS PUBLICOS
1856 
1857  #region Métodos auxiliares
1858 
1864  public static bool _EsCuentaRecc(string tcCuenta)
1865  {
1866  string pendevrep = Convert.ToString(EW_GLOBAL._GetVariable("wc_pendevrep"));
1867  string pendedsop = Convert.ToString(EW_GLOBAL._GetVariable("wc_pendedsop"));
1868  string recrepcdev = Convert.ToString(EW_GLOBAL._GetVariable("wc_recrepcdev"));
1869  string recsopcdev = Convert.ToString(EW_GLOBAL._GetVariable("wc_recsopcdev"));
1870 
1871  //Valido los genéricos del CODCOM
1872  bool esReccDelCodcom = (pendevrep.StartsWith(tcCuenta) || pendedsop.StartsWith(tcCuenta) ||
1873  recrepcdev.StartsWith(tcCuenta) || recsopcdev.StartsWith(tcCuenta));
1874 
1875  if (esReccDelCodcom)
1876  return true;
1877 
1878  //Limpio el input
1879  tcCuenta = tcCuenta.Trim();
1880  string cuentaSqlString = DB.SQLString(tcCuenta); //Para no realizar el proceso 4 veces
1881 
1882  DataTable ldtDatos = new DataTable();
1883 
1884  string lcSql = "SELECT COUNT(CODIGO) AS CONTA FROM " + DB.SQLDatabase("GESTION", "TIPO_IVA") +
1885  " WHERE PENDEVREP = " + cuentaSqlString +
1886  " OR PENDEDSOP = " + cuentaSqlString +
1887  " OR RECSOPCDEV = " + cuentaSqlString +
1888  " OR RECREPCDEV = " + cuentaSqlString;
1889  if(DB.SQLExec(lcSql, ref ldtDatos) && ldtDatos.Rows.Count > 0)
1890  {
1891  int vecesQueAparece = Convert.ToInt32(ldtDatos.Rows[0]["CONTA"]);
1892  return (vecesQueAparece > 0);
1893  }
1894  return false;
1895  }
1896 
1901  public static bool _EsIvaCee(string tcTipoIva)
1902  {
1903  bool llEsIvaCee = false;
1904 
1905  if (string.IsNullOrWhiteSpace(tcTipoIva))
1906  return false;
1907 
1908  string lcIvaOrigen = Convert.ToString(DB.SQLValor("tipo_iva", "iva_cee", tcTipoIva, "codigo"));
1909 
1910  llEsIvaCee = !string.IsNullOrWhiteSpace(lcIvaOrigen);
1911 
1912  return llEsIvaCee;
1913  }
1914 
1920  public bool _ShowAsistente(String tcNuevoCodigo = "")
1921  {
1922  TipoImpuesto loTipo = Convert.ToString(EW_GLOBAL._GetVariable("wc_iva")).Trim() == "IVA" ? TipoImpuesto.IVA : TipoImpuesto.IGIC;
1923 
1924  frmAsistenteTiposIvas loForm = new frmAsistenteTiposIvas(tcNuevoCodigo, loTipo, true);
1925  loForm.FormClosing += new FormClosingEventHandler(ewMante_FormClosing);
1926  loForm._ShowDialog();
1927 
1928  if (!String.IsNullOrEmpty(loForm._CodigoCreado)) _Codigo = loForm._CodigoCreado;
1929 
1930  return true;
1931  }
1932 
1933  #endregion Métodos auxiliares
1934  }
1935 }
Clase de negocio base para mantenimientos
Definition: clsEwBase.cs:1643
TipoImpuesto
Tipo de impuesto
Definition: clsTipoIVA.cs:117
DataTable _Control_Iva_Deducible(string tcCampoCuenta, string tcValorCuenta)
Cuando marcamos que el Tipo de IVA es deducible es neceasrio realizar una serie de controles ...
Definition: clsTipoIVA.cs:910
static bool ContieneUnicamenteTiposParaIGIC()
Determina si tenemos definidos tipos que corresponden a IGIC (tipo 1)
Definition: clsTipoIVA.cs:1827
AccionTraspasoUltimoEjercicio
Indica la acción a arealizar si hay que traspasar los datos al siguiente ejercicio ...
Definition: generales.cs:1001
bool _EsIvaCee()
Devuelve true si el código de IVA cargado en el objeto es el equivalente CEE de otro tipo de IVA ...
Definition: clsTipoIVA.cs:1800
Indica que es un mantenimiento con asistente
Definition: IAsistente.cs:22
bool HayMovimientos()
Indica si hay movimientos es las tabas de iva
Definition: clsTipoIVA.cs:892
Formulario de mantenimiento de tipos de iva.
Definition: frmTiposIVA.cs:20
TipoIVA()
Constructor vacío
Definition: clsTipoIVA.cs:786
String _CodigoCreado
Indica el codigo generado
bool _Comprobar_Ctas_Iva(string tcTipoImpuesto, string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, string tcProrrataIvaSop, string tcProrrataCriIvaSop, out string tcMensaje)
Comprueba si existen otros tipos de IVA con las cuentas contables incompatibles con el que se está ed...
Definition: clsTipoIVA.cs:988
bool _Comprobar_Ctas_Iva(string tcTipoImpuesto, string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, out string tcMensaje)
Comprueba si existen otros tipos de IVA con las cuentas contables incompatibles con el que se está ed...
Definition: clsTipoIVA.cs:1239
override bool _TraspasarSiguienteEjercicio(TipoExecute toTipoExecute, string tcEjercicio, bool tbIsNew)
Hacemos las validaciones de los ivas en el siguiente ejercicio
Definition: clsTipoIVA.cs:1253
bool _Comprobar_Ctas_Iva(string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, out string tcMensaje)
Comprueba si existen otros tipos de IVA con las cuentas contables incompatibles con el que se está ed...
Definition: clsTipoIVA.cs:1218
TipoExecute
Tipos de ejecución de los métodos
Definition: IDocModulos.cs:16
_EstadosMantenimiento
Declaro un enum para los estados del mantenimiento.
Definition: clsEwBase.cs:1671
static bool _EsIvaCee(string tcTipoIva)
Devuelve true si el código de IVA cargado en el objeto es el equivalente CEE de otro tipo de IVA ...
Definition: clsTipoIVA.cs:1901
override bool _Save_Before()
Validamos el tipo de IVA exento
Definition: clsTipoIVA.cs:1274
override bool _Delete()
Borra el tipo de IVA cargado
Definition: clsTipoIVA.cs:823
bool _Comprobar_Ctas_Iva(string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, string tcProrrataIvaSop, string tcProrrataCriIvaSop, out string tcMensaje, string tcEjercicio)
Comprueba si existen otros tipos de IVA con las cuentas contables incompatibles con el que se está ed...
Definition: clsTipoIVA.cs:967
Lisatdo base para los listados de IVA Repercutido, Soportado ...
Definition: IVA.cs:30
bool _ShowAsistente(String tcNuevoCodigo="")
Abre la pantalla del asistente
Definition: clsTipoIVA.cs:1920
static bool _EsCuentaRecc(string tcCuenta)
Determina si la cuenta es de RECC mediante la consulta de que esté aplicada en algún tipo de IVA...
Definition: clsTipoIVA.cs:1864
bool _Comprobar_Ctas_Iva(string tcIvaSop, string tcIvaRep, string tcRecSop, string tcRecRep, string tcCriIvaSop, string tcCriIvaRep, string tcCriRecSop, string tcCriRecRep, string tcProrrataIvaSop, string tcProrrataCriIvaSop, out string tcMensaje)
Comprueba si existen otros tipos de IVA con las cuentas contables incompatibles con el que se está ed...
Definition: clsTipoIVA.cs:946
static bool ContieneUnicamenteTiposParaIVA()
Determina si tenemos definidos tipos que corresponden a IVA (tipo 0)
Definition: clsTipoIVA.cs:1818