1 #region Referencias WindowsForms 4 using System.Collections.Generic;
10 #endregion Referencias WindowsForms 12 #region Referencias Sage50c 34 #endregion Referencias Sage50c 46 private readonly
int _nDesplazamientoInicial = AMORTIZA._Get_Objeto_Amortiza().DesplazamientoInicial;
50 private readonly
bool _lDesplazamientoInverso = AMORTIZA._Get_Objeto_Amortiza().DesplazamientoInverso;
55 private readonly
bool usarSecundariasFlag = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_secundar")) && (Convert.ToInt32(EW_GLOBAL._GetVariable(
"wn_TipoProd", 0)) > 0);
60 private readonly
bool lbColPorcentajeVisible = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"Wl_DistSec"));
65 protected DateTime ldFechaIniPeriodo = Convert.ToDateTime(EW_GLOBAL._GetVariable(
"wd_periodoini"));
70 private bool lIncluirDetalleAnal =
false;
75 private bool lResumenNivel3 =
false;
80 private bool lIncluirPartidasAmortizadas =
false;
85 private enum TipoResumen
91 private TipoResumen tipoResumen = 0;
96 private enum IncluirPardidas
102 private IncluirPardidas incluirPardidas = 0;
108 private string cEjercicio =
"";
110 private int nMesIni = 0;
112 private string cNivel3 =
" ";
113 private string cSecundaria =
"";
114 private string cPrincipal =
"";
115 private string cCodPlan =
"";
117 decimal nAnyBaja = 0;
119 private decimal nCuentaTotalAct = 0.0M;
120 private decimal nCuentaPdteAct = 0.0M;
121 private decimal nCuentaTotalActFis = 0.0M;
122 private decimal nCuentaPdteActFis = 0.0M;
123 private decimal nCuentaTotalCont = 0.0M;
124 private decimal nCuentaPdteCont = 0.0M;
125 private decimal nCuentaImporte = 0.0M;
126 private decimal nCuentaTotalFis = 0.0M;
127 private decimal nCuentaPdteFis = 0.0M;
129 private decimal nTotalTotalAct = 0.0M;
130 private decimal nTotalPdteAct = 0.0M;
131 private decimal nTotalTotalActFis = 0.0M;
132 private decimal nTotalPdteActFis = 0.0M;
133 private decimal nTotalTotalCont = 0.0M;
134 private decimal nTotalPdteCont = 0.0M;
135 private decimal nTotalImporte = 0.0M;
136 private decimal nTotalTotalFis = 0.0M;
137 private decimal nTotalPdteFis = 0.0M;
139 private decimal nSecunTotalAct = 0.0M;
140 private decimal nSecunPdteAct = 0.0M;
141 private decimal nSecunTotalActFis = 0.0M;
142 private decimal nSecunPdteActFis = 0.0M;
143 private decimal nSecunTotalCont = 0.0M;
144 private decimal nSecunPdteCont = 0.0M;
145 private decimal nSecunImporte = 0.0M;
146 private decimal nSecunTotalFis = 0.0M;
147 private decimal nSecunPdteFis = 0.0M;
149 private decimal nPrinTotalAct = 0.0M;
150 private decimal nPrinPdteAct = 0.0M;
151 private decimal nPrinTotalActFis = 0.0M;
152 private decimal nPrinPdteActFis = 0.0M;
153 private decimal nPrinTotalCont = 0.0M;
154 private decimal nPrinPdteCont = 0.0M;
155 private decimal nPrinImporte = 0.0M;
156 private decimal nPrinTotalFis = 0.0M;
157 private decimal nPrinPdteFis = 0.0M;
162 public override String _ReportFile
166 if (tipoResumen == TipoResumen.Comparativo)
168 if (usarSecundariasFlag && lIncluirDetalleAnal)
170 return "resumenamortizacion_comparativo_secun.report";
174 return "resumenamortizacion_comparativo.report";
179 if (usarSecundariasFlag && lIncluirDetalleAnal)
181 return "resumenamortizacion_secun.report";
185 return "resumenamortizacion.report";
199 lIncluirDetalleAnal = _Opcion_Logico(
"lIncluirdetalleanal");
201 lResumenNivel3 = _Opcion_Logico(
"lPresentarresumende");
203 tipoResumen = (TipoResumen)_Opcion_Entero(
"nContableFiscalCom");
205 incluirPardidas = (IncluirPardidas)_Opcion_Entero(
"nAltaBajaTodascomb");
207 lIncluirPartidasAmortizadas = _Opcion_Logico(
"lIncluirPartidasyaa");
210 string lcFiltros =
"";
215 if (usarSecundariasFlag && lIncluirDetalleAnal)
218 lcFiltros += _Filtro_String(_Filtros,
_Tipo_Filtro_String.PlanAnalitico,
"pi",
"plancont");
220 lcFiltros += _Filtro_String(_Filtros,
_Tipo_Filtro_String.AnaliticaNivel2,
"pi",
"secnivel2");
224 nMesIni = ldFechaIniPeriodo.Month;
226 DataTable dtResult =
new DataTable();
228 if (tipoResumen == TipoResumen.Comparativo)
230 dtResult = ResumenComparativo(lcFiltros);
234 dtResult = ResumenContableFiscal(lcFiltros);
245 public override void _SetDefaultValues(Dictionary<string, object> toControlsFiltros = null, Dictionary<string, object> toControlsOpciones = null)
247 base._SetDefaultValues(toControlsFiltros, toControlsOpciones);
249 string lcFiltro =
" left(CODIGO, 3) in (select codigo from " + DB.SQLDatabase(
"GESTION",
"nivel3") +
" where amortiza = 1) ";
251 if (toControlsFiltros.ContainsKey(
"txtCuentaDesdeHasta"))
253 ew.txtbox.UserControls.txtCuentaDesdeHasta loCuenta = (ew.txtbox.UserControls.txtCuentaDesdeHasta)toControlsFiltros[
"txtCuentaDesdeHasta"];
254 loCuenta._oFiltroDesde._Browser_Condicion = lcFiltro;
255 loCuenta._oFiltroHasta._Browser_Condicion = lcFiltro;
258 if (toControlsOpciones != null && toControlsOpciones.ContainsKey(
"chIncluirdetalleanal"))
260 ew.objetos.ewcheckbox loCheckSecundarias = (ew.objetos.ewcheckbox)toControlsOpciones[
"chIncluirdetalleanal"];
261 loCheckSecundarias.Enabled = loCheckSecundarias.Visible = usarSecundariasFlag;
264 if (toControlsOpciones != null && toControlsOpciones.ContainsKey(
"chPresentarresumende"))
266 ew.objetos.ewcheckbox loCheckCuentasNivel3 = (ew.objetos.ewcheckbox)toControlsOpciones[
"chPresentarresumende"];
267 loCheckCuentasNivel3.Checked =
true;
271 lIncluirDetalleAnal = _Opcion_Logico(
"lIncluirdetalleanal");
273 lResumenNivel3 = _Opcion_Logico(
"lPresentarresumende");
275 tipoResumen = (TipoResumen)_Opcion_Entero(
"nContableFiscalCom");
277 incluirPardidas = (IncluirPardidas)_Opcion_Entero(
"nAltaBajaTodascomb");
279 lIncluirPartidasAmortizadas = _Opcion_Logico(
"lIncluirPartidasyaa");
282 if (toControlsOpciones != null && toControlsOpciones.ContainsKey(
"cmbAltaBajaTodascomb"))
284 ew.objetos.ewcombobox loIncluirPartidas = (ew.objetos.ewcombobox)toControlsOpciones[
"cmbAltaBajaTodascomb"];
286 loIncluirPartidas.SelectedIndex = (int)IncluirPardidas.Todas;
287 incluirPardidas = IncluirPardidas.Todas;
290 if (toControlsOpciones != null && toControlsOpciones.ContainsKey(
"chIncluirpartidasyaa"))
292 ew.objetos.ewcheckbox loCheckPartidasAmortizadas = (ew.objetos.ewcheckbox)toControlsOpciones[
"chIncluirpartidasyaa"];
306 if (diccionarioControlesFiltros.ContainsKey(
"txtPeriodoExtendidoDesdeHasta"))
308 ew.txtbox.UserControls.txtPeriodoExtendidoDesdeHasta loEjercicio = (ew.txtbox.UserControls.txtPeriodoExtendidoDesdeHasta)diccionarioControlesFiltros[
"txtPeriodoExtendidoDesdeHasta"];
309 cEjercicio = loEjercicio._Desde;
320 if (this._Resultados == null)
324 foreach (DataColumn ldc
in this._Resultados.Columns)
327 ldc.ExtendedProperties.Add(
"SortMode", DataGridViewColumnSortMode.NotSortable);
329 switch (ldc.ColumnName.ToString().Trim())
333 ldc.ExtendedProperties.Add(
"Mascara",
"dd/MM/yyyy");
339 ldc.ExtendedProperties.Add(
"Mascara", this._Mascara_TPC_IVA);
350 ldc.ExtendedProperties.Add(
"Mascara", this._Mascara_Importe);
355 base._SetColumnMasks();
361 public override List<string> _ReportColumns
365 _dicDefEntidades =
new Dictionary<string, ew.interficies.IDefEntidad>
367 {
"cuenta",
new DefEntidad() { _DB =
"GESTION", _Tabla =
"CUENTAS", _Campo =
"CODIGO", _Relacion =
"", _Empresa =
false } },
368 {
"codigo",
new DefEntidad() { _DB =
"GESTION", _Tabla =
"NIVEL3", _Campo =
"CODIGO", _Relacion =
"", _Empresa =
false } },
369 {
"referencia",
new DefEntidad() { _DB =
"AMORTIZA", _Tabla =
"PARTINVE", _Campo =
"REFERENCIA", _Relacion =
"", _Empresa =
true } }
372 List<string> listaCampos =
new List<string>
380 if (tipoResumen == TipoResumen.Comparativo)
381 listaCampos.Add(
"porfis");
383 listaCampos.Add(
"importe");
384 listaCampos.Add(
"totalcont");
386 if (tipoResumen == TipoResumen.Comparativo)
387 listaCampos.Add(
"totalfis");
389 listaCampos.Add(
"pdtecont");
391 if (tipoResumen == TipoResumen.Comparativo)
392 listaCampos.Add(
"pdtefis");
394 listaCampos.Add(
"totalact");
396 if (tipoResumen == TipoResumen.Comparativo)
397 listaCampos.Add(
"totalactfis");
399 listaCampos.Add(
"pdteact");
401 if (tipoResumen == TipoResumen.Comparativo)
402 listaCampos.Add(
"pdteactfis");
404 listaCampos.Add(
"concepto");
405 listaCampos.Add(
"bajainmo");
407 if (usarSecundariasFlag && lIncluirDetalleAnal)
409 listaCampos.Add(
"codplan");
410 listaCampos.Add(
"codigona1");
411 if (lbColPorcentajeVisible)
412 listaCampos.Add(
"porcenna1");
414 listaCampos.Add(
"codigona2");
415 if (lbColPorcentajeVisible)
416 listaCampos.Add(
"porcenna2");
429 Dictionary<string, string> ldTranslate =
new Dictionary<string, string>
431 {
"porcont", (tipoResumen == TipoResumen.Fiscal) ?
"@% Fiscal" :
"@% Contable" },
432 {
"porfis",
"@% Fiscal" },
433 {
"importe",
"@Importe" },
434 {
"totalcont", (tipoResumen != TipoResumen.Comparativo) ?
"Amortizado" :
"Amortizado contable" },
435 {
"totalfis",
"Amortizado fiscal" },
436 {
"pdtecont", (tipoResumen != TipoResumen.Comparativo) ?
"Pendiente" :
"Pendiente contable" },
437 {
"pdtefis",
"Pendiente fiscal" },
438 {
"totalact", (tipoResumen != TipoResumen.Comparativo) ?
"Amortizado año" :
"Amortizado año contable" },
439 {
"totalactfis",
"Amortizado año fiscal" },
440 {
"pdteact", (tipoResumen != TipoResumen.Comparativo) ?
"Pendiente año" :
"Pendiente año contable" },
441 {
"pdteactfis",
"Pendiente año fiscal" },
442 {
"concepto",
"Observaciones" },
443 {
"bajainmo",
"Fecha baja" }
445 if (usarSecundariasFlag && lIncluirDetalleAnal)
447 ldTranslate.Add(
"codplan",
"Plan analítico");
448 ldTranslate.Add(
"codigona1",
"Nivel analítico 1");
449 if (lbColPorcentajeVisible)
450 ldTranslate.Add(
"porcenna1",
"% na1");
452 ldTranslate.Add(
"codigona2",
"Nivel analítico 2");
453 if (lbColPorcentajeVisible)
454 ldTranslate.Add(
"porcenna2",
"% na2");
457 base._SetColumnCaptions(ldTranslate);
465 Dictionary<string, int> ldTranslate =
new Dictionary<string, int>
470 {
"totalcont", 200 },
475 {
"totalactfis", 200 },
477 {
"pdteactfis", 200 }
480 base._SetColumnWidth(ldTranslate);
487 public override Dictionary<string, Dictionary<string, object>> AnalisisResultados
491 return new Dictionary<string, Dictionary<string, object>>() {
492 {
"[bajainmo] is not null",
new Dictionary<string, object>() {
493 {
"backcolor",
System.Drawing.Color.White },
494 {
"forecolor",
System.Drawing.Color.Red } }
499 base.AnalisisResultados = value;
506 public override Dictionary<string, string> _NavigateButtons
510 return new Dictionary<string, string>() { {
"Partida",
"Ver partida" } };
514 base._NavigateButtons = value;
522 public override void _Navigate(String tcKeyNavigate, DataRow trRow)
528 switch (tcKeyNavigate)
532 string lcEmpresa = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_empresa"));
533 string lcCuenta = Convert.ToString(trRow[
"cuenta"]).TrimEnd();
534 string lcReferencia = Convert.ToString(trRow[
"referencia"]).TrimEnd();
535 if (!
string.IsNullOrWhiteSpace(lcCuenta) && !
string.IsNullOrWhiteSpace(lcReferencia))
537 Mantes.Partidas loPartida =
new Mantes.Partidas
539 _Empresa = lcEmpresa,
541 _Referencia = lcReferencia
556 private DataTable ResumenComparativo(
string lcFiltros)
558 InicializarVariables();
560 DataTable dtDades =
new DataTable();
561 dtDades.Columns.Add(
"concepto", typeof(
string));
562 dtDades.Columns.Add(
"empresa", typeof(
string));
563 dtDades.Columns.Add(
"bajainmo", typeof(DateTime));
564 dtDades.Columns.Add(
"cuenta", typeof(
string));
565 dtDades.Columns.Add(
"referencia", typeof(
string));
566 dtDades.Columns.Add(
"totalact", typeof(decimal));
567 dtDades.Columns.Add(
"pdteact", typeof(decimal));
568 dtDades.Columns.Add(
"totalactfis", typeof(decimal));
569 dtDades.Columns.Add(
"pdteactfis", typeof(decimal));
570 dtDades.Columns.Add(
"totalcont", typeof(decimal));
571 dtDades.Columns.Add(
"pdtecont", typeof(decimal));
572 dtDades.Columns.Add(
"porcont", typeof(decimal));
573 dtDades.Columns.Add(
"importe", typeof(decimal));
574 dtDades.Columns.Add(
"fecha", typeof(DateTime));
575 dtDades.Columns.Add(
"totalfis", typeof(decimal));
576 dtDades.Columns.Add(
"pdtefis", typeof(decimal));
577 dtDades.Columns.Add(
"porfis", typeof(decimal));
578 dtDades.Columns.Add(
"codplan", typeof(
string));
579 dtDades.Columns.Add(
"codigona1", typeof(
string));
580 dtDades.Columns.Add(
"porcenna1", typeof(decimal));
581 dtDades.Columns.Add(
"codigona2", typeof(
string));
582 dtDades.Columns.Add(
"porcenna2", typeof(decimal));
583 dtDades.Columns.Add(
"nivel3", typeof(
string));
584 dtDades.Columns.Add(
"bold", typeof(Boolean));
589 DataTable dtTmp_d1e =
new DataTable();
590 DataTable dtTmp_d1 =
new DataTable();
591 DataTable dtTmp_d2e =
new DataTable();
592 DataTable dtTmp_d2 =
new DataTable();
593 DataTable dtTmp_d =
new DataTable();
595 lcSql =
" SELECT SPACE(200) as concepto, p.empresa, MAX(p.bajainmo) as bajainmo, p.cuenta, p.referencia, " +
596 " 00000000.0000 as TotalAct, 00000000.00 as PdteAct, 00000000.0000 as TotalActFis, 00000000.00 as PdteActFis, " +
597 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLTrue(),
"t.M_01",
"000000000.00"),
"000000000.00") +
") +" +
598 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLTrue(),
"t.M_02",
"000000000.00"),
"000000000.00") +
") +" +
599 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLTrue(),
"t.M_03",
"000000000.00"),
"000000000.00") +
") +" +
600 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLTrue(),
"t.M_04",
"000000000.00"),
"000000000.00") +
") +" +
601 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLTrue(),
"t.M_05",
"000000000.00"),
"000000000.00") +
") +" +
602 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLTrue(),
"t.M_06",
"000000000.00"),
"000000000.00") +
") +" +
603 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLTrue(),
"t.M_07",
"000000000.00"),
"000000000.00") +
") +" +
604 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLTrue(),
"t.M_08",
"000000000.00"),
"000000000.00") +
") +" +
605 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLTrue(),
"t.M_09",
"000000000.00"),
"000000000.00") +
") +" +
606 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLTrue(),
"t.M_10",
"000000000.00"),
"000000000.00") +
") +" +
607 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLTrue(),
"t.M_11",
"000000000.00"),
"000000000.00") +
") +" +
608 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLTrue(),
"t.M_12",
"000000000.00"),
"000000000.00") +
") as TotalCont, " +
609 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLFalse(),
"t.M_01",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
610 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLFalse(),
"t.M_02",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
611 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLFalse(),
"t.M_03",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
612 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLFalse(),
"t.M_04",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
613 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLFalse(),
"t.M_05",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
614 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLFalse(),
"t.M_06",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
615 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLFalse(),
"t.M_07",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
616 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLFalse(),
"t.M_08",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
617 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLFalse(),
"t.M_09",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
618 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLFalse(),
"t.M_10",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
619 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLFalse(),
"t.M_11",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
620 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLFalse(),
"t.M_12",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") as PdteCont, " +
621 " MAX(p.porcont) as porcont, MAX(p.importe) as importe, MAX(p.fecha) as fecha, MAX(p.porfis) as PorFis, " +
622 (usarSecundariasFlag && lIncluirDetalleAnal ? (
" pi.plancont as codplan, pi.secun as codigona1, 000000000.00 as porcenna1, pi.secnivel2 as codigona2, " + DB.SQLNvl(
"MAX(pi.porcen)",
"000000000.00") +
" as porcenna2, ") : (
" SPACE(200) as codplan, SPACE(200) as codigona1, SPACE(30) as porcenna1, SPACE(200) as codigona2, SPACE(30) as porcenna2, ")) +
623 " MAX(LEFT(p.cuenta, 3)) as Nivel3 " +
624 " FROM " + DB.SQLDatabase(
"AMORTIZA",
"PARTINVE") +
" p " +
625 " LEFT JOIN " + DB.SQLDatabase(
"AMORTIZA",
"TABLA_AM") +
" t ON p.empresa+p.cuenta+p.referencia = t.empresa+t.cuenta+t.referencia AND t.periodo < " + DB.SQLString(cEjercicio) +
626 (usarSecundariasFlag && lIncluirDetalleAnal ?
" LEFT JOIN " + DB.SQLDatabase(
"AMORTIZA",
"PI_SECUN") +
" pi ON p.empresa = pi.empresa AND p.cuenta = pi.cuenta AND p.referencia = pi.referencia " :
"") +
627 " WHERE p.empresa = " + DB.SQLString(EW_GLOBAL._GetVariable(
"wc_empresa")) + lcFiltros +
628 (incluirPardidas == IncluirPardidas.Baja ?
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.bajainmo)" :
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.inici_amor)") +
629 " GROUP BY p.empresa, " + (usarSecundariasFlag && lIncluirDetalleAnal ?
"p.cuenta, p.referencia, pi.plancont, pi.secun, pi.secnivel2 " :
"p.cuenta, p.referencia") +
630 " ORDER BY p.empresa, " + (usarSecundariasFlag && lIncluirDetalleAnal ?
"p.cuenta, p.referencia, pi.plancont, pi.secun, pi.secnivel2" :
"p.cuenta, p.referencia");
632 DB.SQLExec(lcSql, ref dtTmp_d1e);
634 if (dtTmp_d1e != null && dtTmp_d1e.Rows.Count > 0)
636 dtTmp_d1 = InsertarRegistrosTabla(dtTmp_d1e);
639 lcSql1 =
" SELECT p.empresa, p.cuenta, p.referencia, MAX(p.bajainmo) as bajainmo, " +
640 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLTrue(),
"t.M_01",
"000000000.00"),
"000000000.00") +
") +" +
641 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLTrue(),
"t.M_02",
"000000000.00"),
"000000000.00") +
") +" +
642 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLTrue(),
"t.M_03",
"000000000.00"),
"000000000.00") +
") +" +
643 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLTrue(),
"t.M_04",
"000000000.00"),
"000000000.00") +
") +" +
644 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLTrue(),
"t.M_05",
"000000000.00"),
"000000000.00") +
") +" +
645 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLTrue(),
"t.M_06",
"000000000.00"),
"000000000.00") +
") +" +
646 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLTrue(),
"t.M_07",
"000000000.00"),
"000000000.00") +
") +" +
647 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLTrue(),
"t.M_08",
"000000000.00"),
"000000000.00") +
") +" +
648 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLTrue(),
"t.M_09",
"000000000.00"),
"000000000.00") +
") +" +
649 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLTrue(),
"t.M_10",
"000000000.00"),
"000000000.00") +
") +" +
650 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLTrue(),
"t.M_11",
"000000000.00"),
"000000000.00") +
") +" +
651 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLTrue(),
"t.M_12",
"000000000.00"),
"000000000.00") +
") as TotalFis, " +
652 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLFalse(),
"t.M_01",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
653 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLFalse(),
"t.M_02",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
654 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLFalse(),
"t.M_03",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
655 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLFalse(),
"t.M_04",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
656 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLFalse(),
"t.M_05",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
657 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLFalse(),
"t.M_06",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
658 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLFalse(),
"t.M_07",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
659 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLFalse(),
"t.M_08",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
660 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLFalse(),
"t.M_09",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
661 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLFalse(),
"t.M_10",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
662 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLFalse(),
"t.M_11",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
663 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLFalse(),
"t.M_12",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") as PdteFis, " +
664 " MAX(p.porcont) as porcont, MAX(p.importe) as importe, MAX(p.fecha) as fecha, MAX(p.porfis) as PorFis, " +
665 (usarSecundariasFlag && lIncluirDetalleAnal ? (
" pi.plancont as codplan, pi.secun as codigona1, 000000000.00 as porcenna1, pi.secnivel2 as codigona2, " + DB.SQLNvl(
"MAX(pi.porcen)",
"000000000.00") +
" as porcenna2, ") : (
" SPACE(200) as codplan, SPACE(200) as codigona1, SPACE(30) as porcenna1, SPACE(200) as codigona2, SPACE(30) as porcenna2, ")) +
666 " MAX(LEFT(p.cuenta, 3)) as Nivel3 " +
667 " FROM " + DB.SQLDatabase(
"AMORTIZA",
"PARTINVE") +
" p " +
668 " LEFT JOIN " + DB.SQLDatabase(
"AMORTIZA",
"TABLA_FI") +
" t ON p.empresa+p.cuenta+p.referencia = t.empresa+t.cuenta+t.referencia AND t.periodo < " + DB.SQLString(cEjercicio) +
669 (usarSecundariasFlag && lIncluirDetalleAnal ?
" LEFT JOIN " + DB.SQLDatabase(
"AMORTIZA",
"PI_SECUN") +
" pi ON p.empresa = pi.empresa AND p.cuenta = pi.cuenta AND p.referencia = pi.referencia " :
"") +
670 " WHERE p.empresa = " + DB.SQLString(EW_GLOBAL._GetVariable(
"wc_empresa")) + lcFiltros +
671 (incluirPardidas == IncluirPardidas.Baja ?
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.bajainmo)" :
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.inici_amor)") +
672 " GROUP BY p.empresa, " + (usarSecundariasFlag && lIncluirDetalleAnal ?
"p.cuenta, pi.plancont, pi.secun, pi.secnivel2, p.referencia" :
"p.cuenta, p.referencia") +
673 " ORDER BY p.empresa, " + (usarSecundariasFlag && lIncluirDetalleAnal ?
"p.cuenta, pi.plancont, pi.secun, pi.secnivel2, p.referencia" :
"p.cuenta, p.referencia");
675 DB.SQLExec(lcSql1, ref dtTmp_d2e);
677 if (dtTmp_d2e != null && dtTmp_d2e.Rows.Count > 0)
679 dtTmp_d2 = InsertarRegistrosTabla(dtTmp_d2e);
682 if (usarSecundariasFlag && lIncluirDetalleAnal)
684 dtTmp_d = (from a in dtTmp_d1.AsEnumerable()
685 join b in dtTmp_d2.AsEnumerable()
688 empresa = a.Field<
string>(
"empresa"),
689 cuenta = a.Field<
string>(
"cuenta"),
690 referencia = a.Field<
string>(
"referencia"),
691 codplan = a.Field<
string>(
"codplan"),
692 codigona1 = a.Field<
string>(
"codigona1"),
693 codigona2 = a.Field<
string>(
"codigona2")
697 empresa = b.Field<
string>(
"empresa"),
698 cuenta = b.Field<
string>(
"cuenta"),
699 referencia = b.Field<
string>(
"referencia"),
700 codplan = b.Field<
string>(
"codplan"),
701 codigona1 = b.Field<
string>(
"codigona1"),
702 codigona2 = b.Field<
string>(
"codigona2")
705 from c in leftJoin.DefaultIfEmpty()
708 empresa = a.Field<
string>(
"empresa"),
709 cuenta = a.Field<
string>(
"cuenta"),
710 referencia = a.Field<
string>(
"referencia"),
711 concepto = a.Field<
string>(
"concepto"),
712 bajainmo = (DateTime?)a.Field<DateTime?>(
"bajainmo"),
713 totalact = a.Field<decimal>(
"totalact"),
714 pdteact = a.Field<decimal>(
"pdteact"),
715 totalactfis = a.Field<decimal>(
"totalactfis"),
716 pdteactfis = a.Field<decimal>(
"pdteactfis"),
717 totalfis = (c != null ? c.Field<decimal>(
"totalfis") : Convert.ToDecimal(0)),
718 pdtefis = (c != null ? c.Field<decimal>(
"pdtefis") : Convert.ToDecimal(0)),
719 totalcont = a.Field<decimal>(
"totalcont"),
720 pdtecont = a.Field<decimal>(
"pdtecont"),
721 porcont = a.Field<decimal>(
"porcont"),
722 importe = a.Field<decimal>(
"importe"),
723 fecha = (DateTime?)a.Field<DateTime?>(
"fecha"),
724 porfis = a.Field<decimal>(
"porfis"),
725 codplan = (c != null ? c.Field<
string>(
"codplan") :
string.Empty),
726 codigona1 = (c != null ? c.Field<
string>(
"codigona1") :
string.Empty),
727 porcenna1 = (c != null ? c.Field<decimal>(
"porcenna1") : Convert.ToDecimal(0)),
728 codigona2 = (c != null ? c.Field<
string>(
"codigona2") :
string.Empty),
729 porcenna2 = (c != null ? c.Field<decimal>(
"porcenna2") : Convert.ToDecimal(0)),
730 nivel3 = a.Field<
string>(
"nivel3")
731 }).__CopyToDataTable();
735 dtTmp_d = (from a in dtTmp_d1.AsEnumerable()
736 join b in dtTmp_d2.AsEnumerable()
739 empresa = a.Field<
string>(
"empresa"),
740 cuenta = a.Field<
string>(
"cuenta"),
741 referencia = a.Field<
string>(
"referencia"),
745 empresa = b.Field<
string>(
"empresa"),
746 cuenta = b.Field<
string>(
"cuenta"),
747 referencia = b.Field<
string>(
"referencia"),
750 from c in leftJoin.DefaultIfEmpty()
753 empresa = a.Field<
string>(
"empresa"),
754 cuenta = a.Field<
string>(
"cuenta"),
755 referencia = a.Field<
string>(
"referencia"),
756 concepto = a.Field<
string>(
"concepto"),
757 bajainmo = (DateTime?)a.Field<DateTime?>(
"bajainmo"),
758 totalact = a.Field<decimal>(
"totalact"),
759 pdteact = a.Field<decimal>(
"pdteact"),
760 totalactfis = a.Field<decimal>(
"totalactfis"),
761 pdteactfis = a.Field<decimal>(
"pdteactfis"),
762 totalfis = (c != null ? c.Field<decimal>(
"totalfis") : Convert.ToDecimal(0)),
763 pdtefis = (c != null ? c.Field<decimal>(
"pdtefis") : Convert.ToDecimal(0)),
764 totalcont = a.Field<decimal>(
"totalcont"),
765 pdtecont = a.Field<decimal>(
"pdtecont"),
766 porcont = a.Field<decimal>(
"porcont"),
767 importe = a.Field<decimal>(
"importe"),
768 fecha = (DateTime?)a.Field<DateTime?>(
"fecha"),
769 porfis = a.Field<decimal>(
"porfis"),
770 codplan =
string.Empty,
771 codigona1 =
string.Empty,
772 porcenna1 = Convert.ToDecimal(0),
773 codigona2 =
string.Empty,
774 porcenna2 = Convert.ToDecimal(0),
775 nivel3 = a.Field<
string>(
"nivel3")
776 }).__CopyToDataTable();
779 if (dtTmp_d != null && dtTmp_d.Rows.Count > 0)
781 if (usarSecundariasFlag && lIncluirDetalleAnal && lbColPorcentajeVisible)
783 Calcularporcentajena1(dtTmp_d);
786 PintarResultados(dtDades, dtTmp_d);
788 PintarTotales(dtDades);
799 private DataTable ResumenContableFiscal(
string lcFiltros)
801 InicializarVariables();
803 DataTable dtDades =
new DataTable();
804 dtDades.Columns.Add(
"concepto", typeof(
string));
805 dtDades.Columns.Add(
"cuenta", typeof(
string));
806 dtDades.Columns.Add(
"referencia", typeof(
string));
807 dtDades.Columns.Add(
"nivel3", typeof(
string));
808 dtDades.Columns.Add(
"totalact", typeof(decimal));
809 dtDades.Columns.Add(
"pdteact", typeof(decimal));
810 dtDades.Columns.Add(
"totalcont", typeof(decimal));
811 dtDades.Columns.Add(
"pdtecont", typeof(decimal));
812 dtDades.Columns.Add(
"porcont", typeof(decimal));
813 dtDades.Columns.Add(
"importe", typeof(decimal));
814 dtDades.Columns.Add(
"fecha", typeof(DateTime));
815 dtDades.Columns.Add(
"empresa", typeof(
string));
816 dtDades.Columns.Add(
"bajainmo", typeof(DateTime));
817 dtDades.Columns.Add(
"porcen", typeof(
string));
818 dtDades.Columns.Add(
"codplan", typeof(
string));
819 dtDades.Columns.Add(
"codigona1", typeof(
string));
820 dtDades.Columns.Add(
"porcenna1", typeof(decimal));
821 dtDades.Columns.Add(
"codigona2", typeof(
string));
822 dtDades.Columns.Add(
"porcenna2", typeof(decimal));
823 dtDades.Columns.Add(
"bold", typeof(Boolean));
827 string lcCondicion =
"";
829 if (_nDesplazamientoInicial > 0)
834 DataTable dtTmp_e =
new DataTable();
835 DataTable dtTmp_d =
new DataTable();
837 if (tipoResumen == TipoResumen.Contable)
842 if (usarSecundariasFlag && lIncluirDetalleAnal)
844 #region CONTABLE, SECUNDARIA E INCLUIR DETALLE ANALITICO 845 lcSql =
" SELECT p.cuenta, p.referencia, SPACE(200) as concepto, MAX(LEFT(p.cuenta,3)) as Nivel3, " +
846 " 00000000.0000 as TotalAct, 00000000.00 as PdteAct, " +
847 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLTrue(),
"t.M_01",
"000000000.00"),
"000000000.00") +
") +" +
848 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLTrue(),
"t.M_02",
"000000000.00"),
"000000000.00") +
") +" +
849 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLTrue(),
"t.M_03",
"000000000.00"),
"000000000.00") +
") +" +
850 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLTrue(),
"t.M_04",
"000000000.00"),
"000000000.00") +
") +" +
851 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLTrue(),
"t.M_05",
"000000000.00"),
"000000000.00") +
") +" +
852 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLTrue(),
"t.M_06",
"000000000.00"),
"000000000.00") +
") +" +
853 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLTrue(),
"t.M_07",
"000000000.00"),
"000000000.00") +
") +" +
854 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLTrue(),
"t.M_08",
"000000000.00"),
"000000000.00") +
") +" +
855 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLTrue(),
"t.M_09",
"000000000.00"),
"000000000.00") +
") +" +
856 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLTrue(),
"t.M_10",
"000000000.00"),
"000000000.00") +
") +" +
857 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLTrue(),
"t.M_11",
"000000000.00"),
"000000000.00") +
") +" +
858 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLTrue(),
"t.M_12",
"000000000.00"),
"000000000.00") +
") as TotalCont, " +
859 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLFalse(),
"t.M_01",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
860 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLFalse(),
"t.M_02",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
861 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLFalse(),
"t.M_03",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
862 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLFalse(),
"t.M_04",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
863 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLFalse(),
"t.M_05",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
864 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLFalse(),
"t.M_06",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
865 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLFalse(),
"t.M_07",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
866 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLFalse(),
"t.M_08",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
867 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLFalse(),
"t.M_09",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
868 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLFalse(),
"t.M_10",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
869 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLFalse(),
"t.M_11",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
870 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLFalse(),
"t.M_12",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") as PdteCont, " +
871 " MAX(p.porcont) as porcont, MAX(p.importe) as importe, MAX(p.fecha) as fecha, p.empresa, MAX(p.bajainmo) as bajainmo, " +
872 DB.SQLNvl(
"MAX(pi.porcen)",
"000000000.00000") +
"as porcen, " +
873 " MAX(pi.plancont) as codplan, MAX(pi.secun) as codigona1, SPACE(30) as porcenna1, MAX(pi.secnivel2) as codigona2, MAX(pi.porcen) as porcenna2 " +
874 " FROM " + DB.SQLDatabase(
"AMORTIZA",
"PARTINVE") +
" p " +
875 " LEFT JOIN " + DB.SQLDatabase(
"AMORTIZA", cTabla) +
" t ON p.empresa = t.empresa AND p.cuenta = t.cuenta AND p.referencia = t.referencia AND t.periodo <= " + DB.SQLString(cEjercicio) +
876 " LEFT JOIN " + DB.SQLDatabase(
"AMORTIZA",
"PI_SECUN") +
" pi ON p.empresa = pi.empresa AND p.cuenta = pi.cuenta AND p.referencia = pi.referencia " +
877 " WHERE p.empresa = " + DB.SQLString(EW_GLOBAL._GetVariable(
"wc_empresa")) + lcFiltros +
878 (incluirPardidas == IncluirPardidas.Baja ?
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.bajainmo)" :
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.inici_amor)") + lcCondicion +
879 " GROUP BY p.empresa, p.cuenta, p.referencia, pi.plancont, pi.secun, pi.secnivel2 " +
880 " ORDER BY p.empresa, p.cuenta, p.referencia, pi.plancont, pi.secun, pi.secnivel2";
882 #endregion CONTABLE, SECUNDARIA E INCLUIR DETALLE ANALITICOS 887 lcSql =
" SELECT SPACE(200) AS concepto, MAX(LEFT(p.cuenta, 3)) as Nivel3, p.cuenta, p.referencia, 00000000.0000 as TotalAct, 00000000.00 as PdteAct, " +
888 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLTrue(),
"t.M_01",
"000000000.00"),
"000000000.00") +
") +" +
889 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLTrue(),
"t.M_02",
"000000000.00"),
"000000000.00") +
") +" +
890 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLTrue(),
"t.M_03",
"000000000.00"),
"000000000.00") +
") +" +
891 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLTrue(),
"t.M_04",
"000000000.00"),
"000000000.00") +
") +" +
892 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLTrue(),
"t.M_05",
"000000000.00"),
"000000000.00") +
") +" +
893 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLTrue(),
"t.M_06",
"000000000.00"),
"000000000.00") +
") +" +
894 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLTrue(),
"t.M_07",
"000000000.00"),
"000000000.00") +
") +" +
895 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLTrue(),
"t.M_08",
"000000000.00"),
"000000000.00") +
") +" +
896 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLTrue(),
"t.M_09",
"000000000.00"),
"000000000.00") +
") +" +
897 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLTrue(),
"t.M_10",
"000000000.00"),
"000000000.00") +
") +" +
898 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLTrue(),
"t.M_11",
"000000000.00"),
"000000000.00") +
") +" +
899 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLTrue(),
"t.M_12",
"000000000.00"),
"000000000.00") +
") as TotalCont, " +
900 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLFalse(),
"t.M_01",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
901 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLFalse(),
"t.M_02",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
902 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLFalse(),
"t.M_03",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
903 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLFalse(),
"t.M_04",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
904 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLFalse(),
"t.M_05",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
905 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLFalse(),
"t.M_06",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
906 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLFalse(),
"t.M_07",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
907 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLFalse(),
"t.M_08",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
908 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLFalse(),
"t.M_09",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
909 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLFalse(),
"t.M_10",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
910 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLFalse(),
"t.M_11",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
911 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLFalse(),
"t.M_12",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") as PdteCont, " +
912 " MAX(p.porcont) as porcont, MAX(p.importe) as importe, MAX(p.fecha) as fecha, p.empresa, MAX(p.bajainmo) as bajainmo, " +
913 " SPACE(200) as codplan, SPACE(200) as codigona1, SPACE(30) as porcenna1, SPACE(200) as codigona2, SPACE(30) as porcenna2 " +
914 " FROM " + DB.SQLDatabase(
"AMORTIZA",
"PARTINVE") +
" p " +
915 " LEFT JOIN " + DB.SQLDatabase(
"AMORTIZA", cTabla) +
" t ON p.empresa = t.empresa AND p.cuenta = t.cuenta AND p.referencia = t.referencia AND t.periodo <= " + DB.SQLString(cEjercicio) +
916 " WHERE p.empresa = " + DB.SQLString(EW_GLOBAL._GetVariable(
"wc_empresa")) + lcFiltros +
917 (incluirPardidas == IncluirPardidas.Baja ?
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.bajainmo)" :
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.inici_amor)") + lcCondicion +
918 " GROUP BY p.empresa, p.cuenta, p.referencia " +
919 " ORDER BY p.empresa, p.cuenta, p.referencia ";
929 if (usarSecundariasFlag && lIncluirDetalleAnal)
931 #region FISCAL O COMPARATICO Y SECUNDARIA E INCLUIR DETALLE ANALITICO 932 lcSql =
" SELECT p.cuenta, p.referencia, SPACE(200) AS concepto, MAX(LEFT(p.cuenta, 3)) as Nivel3, " +
933 " 00000000.0000 as TotalAct, 00000000.00 as PdteAct, " +
934 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLTrue(),
"t.M_01",
"000000000.00"),
"000000000.00") +
") +" +
935 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLTrue(),
"t.M_02",
"000000000.00"),
"000000000.00") +
") +" +
936 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLTrue(),
"t.M_03",
"000000000.00"),
"000000000.00") +
") +" +
937 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLTrue(),
"t.M_04",
"000000000.00"),
"000000000.00") +
") +" +
938 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLTrue(),
"t.M_05",
"000000000.00"),
"000000000.00") +
") +" +
939 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLTrue(),
"t.M_06",
"000000000.00"),
"000000000.00") +
") +" +
940 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLTrue(),
"t.M_07",
"000000000.00"),
"000000000.00") +
") +" +
941 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLTrue(),
"t.M_08",
"000000000.00"),
"000000000.00") +
") +" +
942 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLTrue(),
"t.M_09",
"000000000.00"),
"000000000.00") +
") +" +
943 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLTrue(),
"t.M_10",
"000000000.00"),
"000000000.00") +
") +" +
944 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLTrue(),
"t.M_11",
"000000000.00"),
"000000000.00") +
") +" +
945 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLTrue(),
"t.M_12",
"000000000.00"),
"000000000.00") +
") as TotalCont, " +
946 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLFalse(),
"t.M_01",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
947 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLFalse(),
"t.M_02",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
948 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLFalse(),
"t.M_03",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
949 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLFalse(),
"t.M_04",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
950 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLFalse(),
"t.M_05",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
951 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLFalse(),
"t.M_06",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
952 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLFalse(),
"t.M_07",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
953 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLFalse(),
"t.M_08",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
954 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLFalse(),
"t.M_09",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
955 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLFalse(),
"t.M_10",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
956 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLFalse(),
"t.M_11",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
957 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLFalse(),
"t.M_12",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") as PdteCont, " +
958 " MAX(p.porcont) as porcont, MAX(p.importe) as importe, MAX(p.fecha) as fecha, p.empresa, MAX(p.bajainmo) as bajainmo, " +
959 DB.SQLNvl(
"MAX(pi.porcen)",
"000000000.00000") +
"as porcen, " +
960 " MAX(pi.plancont) as codplan, MAX(pi.secun) as codigona1, SPACE(30) as porcenna1, MAX(pi.secnivel2) as codigona2, MAX(pi.porcen) as porcenna2 " +
961 " FROM " + DB.SQLDatabase(
"AMORTIZA",
"PARTINVE") +
" p " +
962 " LEFT JOIN " + DB.SQLDatabase(
"AMORTIZA", cTabla) +
" t ON p.empresa = t.empresa AND p.cuenta = t.cuenta AND p.referencia = t.referencia AND t.periodo <= " + DB.SQLString(cEjercicio) +
963 " LEFT JOIN " + DB.SQLDatabase(
"AMORTIZA",
"PI_SECUN") +
" pi ON p.empresa = pi.empresa AND p.cuenta = pi.cuenta AND p.referencia = pi.referencia " +
964 " WHERE p.empresa = " + DB.SQLString(EW_GLOBAL._GetVariable(
"wc_empresa")) + lcFiltros +
965 (incluirPardidas == IncluirPardidas.Baja ?
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.bajainmo)" :
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.inici_amor)") + lcCondicion +
966 " GROUP BY p.empresa, p.cuenta, p.referencia, pi.plancont, pi.secun, pi.secnivel2 " +
967 " ORDER BY p.empresa, p.cuenta, p.referencia, pi.plancont, pi.secun, pi.secnivel2";
969 #endregion FISCAL O COMPARATICO Y SECUNDARIA E INCLUIR DETALLE ANALITICO 973 #region FISCAL O COMPARATICO 974 lcSql =
" SELECT SPACE(200) AS concepto, MAX(LEFT(p.cuenta, 3)) as Nivel3, p.cuenta, p.referencia, 00000000.0000 as TotalAct, 00000000.00 as PdteAct, " +
975 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLTrue(),
"t.M_01",
"000000000.00"),
"000000000.00") +
") +" +
976 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLTrue(),
"t.M_02",
"000000000.00"),
"000000000.00") +
") +" +
977 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLTrue(),
"t.M_03",
"000000000.00"),
"000000000.00") +
") +" +
978 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLTrue(),
"t.M_04",
"000000000.00"),
"000000000.00") +
") +" +
979 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLTrue(),
"t.M_05",
"000000000.00"),
"000000000.00") +
") +" +
980 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLTrue(),
"t.M_06",
"000000000.00"),
"000000000.00") +
") +" +
981 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLTrue(),
"t.M_07",
"000000000.00"),
"000000000.00") +
") +" +
982 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLTrue(),
"t.M_08",
"000000000.00"),
"000000000.00") +
") +" +
983 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLTrue(),
"t.M_09",
"000000000.00"),
"000000000.00") +
") +" +
984 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLTrue(),
"t.M_10",
"000000000.00"),
"000000000.00") +
") +" +
985 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLTrue(),
"t.M_11",
"000000000.00"),
"000000000.00") +
") +" +
986 " SUM(" + DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLTrue(),
"t.M_12",
"000000000.00"),
"000000000.00") +
") as TotalCont, " +
987 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_01 = " + DB.SQLFalse(),
"t.M_01",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
988 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_02 = " + DB.SQLFalse(),
"t.M_02",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
989 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_03 = " + DB.SQLFalse(),
"t.M_03",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
990 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_04 = " + DB.SQLFalse(),
"t.M_04",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
991 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_05 = " + DB.SQLFalse(),
"t.M_05",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
992 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_06 = " + DB.SQLFalse(),
"t.M_06",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
993 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_07 = " + DB.SQLFalse(),
"t.M_07",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
994 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_08 = " + DB.SQLFalse(),
"t.M_08",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
995 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_09 = " + DB.SQLFalse(),
"t.M_09",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
996 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_10 = " + DB.SQLFalse(),
"t.M_10",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
997 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_11 = " + DB.SQLFalse(),
"t.M_11",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") +" +
998 " SUM(" + DB.SQLIif((
"p.bajainmo is null"), DB.SQLNvl(DB.SQLIif(
"t.A_12 = " + DB.SQLFalse(),
"t.M_12",
"000000000.00"),
"000000000.00"),
"000000000.00") +
") as PdteCont, " +
999 " MAX(p.porfis) as porcont, MAX(p.importe) as importe, MAX(p.fecha) as fecha, p.empresa, MAX(p.bajainmo) as bajainmo, " +
1000 " SPACE(200) as codplan, SPACE(200) as codigona1, SPACE(30) as porcenna1, SPACE(200) as codigona2, SPACE(30) as porcenna2 " +
1001 " FROM " + DB.SQLDatabase(
"AMORTIZA",
"PARTINVE") +
" p " +
1002 " LEFT JOIN " + DB.SQLDatabase(
"AMORTIZA", cTabla) +
" t ON p.empresa = t.empresa AND p.cuenta = t.cuenta AND p.referencia = t.referencia AND t.periodo <= " + DB.SQLString(cEjercicio) +
1003 " WHERE p.empresa = " + DB.SQLString(EW_GLOBAL._GetVariable(
"wc_empresa")) + lcFiltros +
1004 (incluirPardidas == IncluirPardidas.Baja ?
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.bajainmo)" :
" AND " + DB.SQLString(cEjercicio) +
" >= YEAR(p.inici_amor)") + lcCondicion +
1005 " GROUP BY p.empresa, p.cuenta, p.referencia " +
1006 " ORDER BY p.empresa, p.cuenta, p.referencia ";
1007 #endregion FISCAL O COMPARATICO 1011 DB.SQLExec(lcSql, ref dtTmp_e);
1013 if (dtTmp_e != null && dtTmp_e.Rows.Count > 0)
1015 dtTmp_d = InsertarRegistrosTabla(dtTmp_e);
1018 if (dtTmp_d != null && dtTmp_d.Rows.Count > 0)
1020 if (usarSecundariasFlag && lIncluirDetalleAnal && lbColPorcentajeVisible)
1022 Calcularporcentajena1(dtTmp_d);
1025 PintarResultados(dtDades, dtTmp_d);
1027 PintarTotales(dtDades);
1038 private DataTable InsertarRegistrosTabla(DataTable dtTableValores)
1040 DataTable dtTableResult =
new DataTable();
1041 dtTableResult = dtTableValores.Clone();
1043 if (incluirPardidas != IncluirPardidas.Alta)
1045 #region BAJAS O COMPARATIVA 1046 foreach (DataRow row1
in dtTableValores.Rows)
1048 if (row1[
"bajainmo"] != DBNull.Value)
1050 if (incluirPardidas == IncluirPardidas.Todas)
1052 dtTableResult.ImportRow(row1);
1056 if (Convert.ToDateTime(row1[
"bajainmo"]).Month <= nMesIni && _nDesplazamientoInicial > 0)
1058 if (Convert.ToInt32(cEjercicio) <= Convert.ToDateTime(row1[
"bajainmo"]).Year - 1)
1060 dtTableResult.ImportRow(row1);
1065 if (incluirPardidas == IncluirPardidas.Todas)
1067 dtTableResult.ImportRow(row1);
1071 if (Convert.ToDateTime(row1[
"bajainmo"]).Year <= Convert.ToInt32(cEjercicio))
1073 dtTableResult.ImportRow(row1);
1081 if (incluirPardidas == IncluirPardidas.Todas)
1083 dtTableResult.ImportRow(row1);
1087 #endregion BAJAS O COMPARATIVA 1092 foreach (DataRow row1
in dtTableValores.Rows)
1094 if (row1[
"bajainmo"] != DBNull.Value)
1096 if (Convert.ToDateTime(row1[
"bajainmo"]).Month < nMesIni && _nDesplazamientoInicial > 0)
1098 if (Convert.ToInt32(cEjercicio) <= Convert.ToDateTime(row1[
"bajainmo"]).Year - 1)
1100 dtTableResult.ImportRow(row1);
1105 if (Convert.ToInt32(cEjercicio) < Convert.ToDateTime(row1[
"bajainmo"]).Year)
1107 dtTableResult.ImportRow(row1);
1113 dtTableResult.ImportRow(row1);
1119 return dtTableResult;
1126 private void EditarRegistrosBaja(ref DataTable dtTableResult)
1128 foreach (DataRow row
in dtTableResult.Rows)
1130 if (row[
"bajainmo"] != DBNull.Value)
1132 if (Convert.ToDateTime(row[
"bajainmo"]).Year <= Convert.ToInt32(cEjercicio))
1134 DataTable dtDatos =
new DataTable();
1135 string lcSql =
" SELECT * FROM " + DB.SQLDatabase(
"AMORTIZA",
"PARTINVE") +
1136 " WHERE empresa = " + DB.SQLString(row[
"empresa"].ToString()) +
" AND cuenta = " + DB.SQLString(row[
"cuenta"].ToString()) +
1137 " AND referencia = " + DB.SQLString(row[
"referencia"].ToString());
1139 DB.SQLExec(lcSql, ref dtDatos);
1141 if (dtDatos != null && dtDatos.Rows.Count > 0)
1143 row[
"totalcont"] = Convert.ToDecimal(dtDatos.Rows[0][
"totalcont"]);
1144 if (dtTableResult.Columns.Contains(
"totalfis"))
1145 row[
"totalfis"] = Convert.ToDecimal(dtDatos.Rows[0][
"totalfis"]);
1155 private void InicializarVariables()
1164 nCuentaTotalAct = 0.0M;
1165 nCuentaPdteAct = 0.0M;
1166 nCuentaTotalActFis = 0.0M;
1167 nCuentaPdteActFis = 0.0M;
1168 nCuentaTotalCont = 0.0M;
1169 nCuentaPdteCont = 0.0M;
1170 nCuentaImporte = 0.0M;
1171 nCuentaTotalFis = 0.0M;
1172 nCuentaPdteFis = 0.0M;
1174 nTotalTotalAct = 0.0M;
1175 nTotalPdteAct = 0.0M;
1176 nTotalTotalActFis = 0.0M;
1177 nTotalPdteActFis = 0.0M;
1178 nTotalTotalCont = 0.0M;
1179 nTotalPdteCont = 0.0M;
1180 nTotalImporte = 0.0M;
1181 nTotalTotalFis = 0.0M;
1182 nTotalPdteFis = 0.0M;
1184 nSecunTotalAct = 0.0M;
1185 nSecunPdteAct = 0.0M;
1186 nSecunTotalActFis = 0.0M;
1187 nSecunPdteActFis = 0.0M;
1188 nSecunTotalCont = 0.0M;
1189 nSecunPdteCont = 0.0M;
1190 nSecunImporte = 0.0M;
1191 nSecunTotalFis = 0.0M;
1192 nSecunPdteFis = 0.0M;
1194 nPrinTotalAct = 0.0M;
1195 nPrinPdteAct = 0.0M;
1196 nPrinTotalActFis = 0.0M;
1197 nPrinPdteActFis = 0.0M;
1198 nPrinTotalCont = 0.0M;
1199 nPrinPdteCont = 0.0M;
1200 nPrinImporte = 0.0M;
1201 nPrinTotalFis = 0.0M;
1202 nPrinPdteFis = 0.0M;
1209 private void Calcularporcentajena1(DataTable dtTmp_d)
1211 foreach (DataRow row
in dtTmp_d.Rows)
1213 if (!
string.IsNullOrEmpty(row[
"codplan"].ToString().Trim()) && !
string.IsNullOrEmpty(row[
"codigona1"].ToString().Trim()))
1215 decimal nPorcenna2 = 0M;
1216 if (!
string.IsNullOrEmpty(row[
"porcenna2"].ToString().Trim()))
1218 nPorcenna2 = Convert.ToDecimal(row[
"porcenna2"]);
1220 if (nPorcenna2 > 0M)
1222 DataTable dtPiSecun =
new DataTable();
1223 string lcSql =
" SELECT * FROM " + DB.SQLDatabase(
"AMORTIZA",
"PI_SECUN") +
1224 " WHERE empresa = " + DB.SQLString(row[
"empresa"].ToString()) +
" AND cuenta = " + DB.SQLString(row[
"cuenta"].ToString()) +
1225 " AND referencia = " + DB.SQLString(row[
"referencia"].ToString()) +
" AND plancont = " + DB.SQLString(row[
"codplan"].ToString()) +
1226 " AND secun = " + DB.SQLString(row[
"codigona1"].ToString());
1228 DB.SQLExec(lcSql, ref dtPiSecun);
1230 decimal nPorcen = 0M;
1231 if (dtPiSecun != null && dtPiSecun.Rows.Count > 0)
1233 foreach (DataRow loRow
in dtPiSecun.Rows)
1235 nPorcen += Convert.ToDecimal(loRow[
"porcen"]);
1238 row[
"porcenna1"] = nPorcen;
1249 private void PintarResultados(DataTable dtDades, DataTable dtTmp_d)
1251 EditarRegistrosBaja(ref dtTmp_d);
1255 if (dtTmp_d != null && dtTmp_d.Rows.Count > 0)
1257 cNivel3 = dtTmp_d.Rows[0][
"nivel3"].ToString();
1258 cSecundaria = dtTmp_d.Rows[0][
"codplan"].ToString().Trim();
1259 cPrincipal = dtTmp_d.Rows[0][
"cuenta"].ToString();
1260 string cRowCta =
"";
1261 string cRowRef =
"";
1262 string cRowCodplan =
"";
1263 string cRowCodigona1 =
"";
1264 string cRowCodigona2 =
"";
1265 bool lbPrimerReg =
true;
1267 foreach (DataRow row
in dtTmp_d.Rows)
1270 string cNivel1 =
"";
1271 string cNivel2 =
"";
1274 if (usarSecundariasFlag && lIncluirDetalleAnal)
1276 if (tipoResumen != TipoResumen.Comparativo)
1284 bool lbIniSecun =
false;
1285 if (cSecundaria != row[
"codplan"].ToString().Trim() && !
string.IsNullOrEmpty(cSecundaria))
1287 if (!
string.IsNullOrEmpty(cSecundaria))
1288 cPlan =
" - " + DB.SQLValor(
"PLANS",
"CODIGO", cSecundaria,
"NOMBRE").ToString();
1297 if (
string.IsNullOrEmpty(cSecundaria))
1303 nSecunTotalAct = 0.0M;
1304 nSecunPdteAct = 0.0M;
1305 nSecunTotalCont = 0.0M;
1306 nSecunPdteCont = 0.0M;
1307 nSecunImporte = 0.0M;
1308 cSecundaria = row[
"codplan"].ToString().Trim();
1309 if (tipoResumen == TipoResumen.Comparativo)
1311 nSecunTotalActFis = 0.0M;
1312 nSecunPdteActFis = 0.0M;
1313 nSecunTotalFis = 0.0M;
1314 nSecunPdteFis = 0.0M;
1319 if (cPrincipal != row[
"cuenta"].ToString())
1321 dr = dtDades.NewRow();
1322 dr[
"cuenta"] = cPrincipal;
1323 dr[
"referencia"] =
"";
1324 dr[
"totalact"] = nPrinTotalAct;
1325 dr[
"pdteact"] = nPrinPdteAct;
1326 dr[
"totalcont"] = nPrinTotalCont;
1327 dr[
"pdtecont"] = nPrinPdteCont;
1328 dr[
"importe"] = nPrinImporte;
1329 dr[
"concepto"] = DB.SQLValor(
"CUENTAS",
"CODIGO", cPrincipal,
"NOMBRE").ToString();
1331 if (tipoResumen == TipoResumen.Comparativo)
1333 dr[
"totalactfis"] = nPrinTotalActFis;
1334 dr[
"pdteactfis"] = nPrinPdteActFis;
1335 dr[
"totalfis"] = nPrinTotalFis;
1336 dr[
"pdtefis"] = nPrinPdteFis;
1338 dtDades.Rows.Add(dr);
1340 nPrinTotalAct = 0.0M;
1341 nPrinPdteAct = 0.0M;
1342 nPrinTotalCont = 0.0M;
1343 nPrinPdteCont = 0.0M;
1344 nPrinImporte = 0.0M;
1345 cPrincipal = row[
"cuenta"].ToString();
1346 cCodPlan = row[
"codplan"].ToString();
1347 if (tipoResumen == TipoResumen.Comparativo)
1349 nPrinTotalActFis = 0.0M;
1350 nPrinPdteActFis = 0.0M;
1351 nPrinTotalFis = 0.0M;
1352 nPrinPdteFis = 0.0M;
1356 if (cNivel3 != row[
"nivel3"].ToString() && lResumenNivel3)
1358 string cNivel3Digitos = cNivel3.Substring(0, 3);
1359 dr = dtDades.NewRow();
1360 dr[
"cuenta"] = cNivel3;
1361 dr[
"referencia"] =
"";
1362 dr[
"totalact"] = nCuentaTotalAct;
1363 dr[
"pdteact"] = nCuentaPdteAct;
1364 dr[
"totalcont"] = nCuentaTotalCont;
1365 dr[
"pdtecont"] = nCuentaPdteCont;
1366 dr[
"importe"] = nCuentaImporte;
1367 dr[
"concepto"] = DB.SQLValor(
"NIVEL3",
"CODIGO", cNivel3Digitos,
"NOMBRE").ToString();
1370 if (tipoResumen == TipoResumen.Comparativo)
1372 dr[
"totalactfis"] = nCuentaTotalActFis;
1373 dr[
"pdteactfis"] = nCuentaPdteActFis;
1374 dr[
"totalfis"] = nCuentaTotalFis;
1375 dr[
"pdtefis"] = nCuentaPdteFis;
1377 dtDades.Rows.Add(dr);
1379 nCuentaTotalAct = 0.0M;
1380 nCuentaPdteAct = 0.0M;
1381 nCuentaTotalCont = 0.0M;
1382 nCuentaPdteCont = 0.0M;
1383 nCuentaImporte = 0.0M;
1384 cNivel3 = row[
"nivel3"].ToString();
1385 if (tipoResumen == TipoResumen.Comparativo)
1387 nCuentaTotalActFis = 0.0M;
1388 nCuentaPdteActFis = 0.0M;
1389 nCuentaTotalFis = 0.0M;
1390 nCuentaPdteFis = 0.0M;
1395 dr = dtDades.NewRow();
1396 dr[
"concepto"] = row[
"concepto"].ToString();
1397 dr[
"empresa"] = row[
"empresa"].ToString();
1398 if (row[
"bajainmo"] != DBNull.Value)
1400 dr[
"bajainmo"] = Convert.ToDateTime(row[
"bajainmo"].ToString());
1404 if (row[
"bajainmo"].ToString() !=
"")
1405 dr[
"bajainmo"] = DBNull.Value;
1407 dr[
"cuenta"] = row[
"cuenta"].ToString();
1408 dr[
"referencia"] = row[
"referencia"].ToString();
1409 dr[
"totalact"] = row[
"totalact"].ToString();
1410 dr[
"pdteact"] = row[
"pdteact"].ToString();
1411 dr[
"totalcont"] = row[
"totalcont"].ToString();
1412 dr[
"pdtecont"] = row[
"pdtecont"].ToString();
1413 dr[
"porcont"] = row[
"porcont"].ToString();
1414 dr[
"importe"] = row[
"importe"].ToString();
1415 dr[
"fecha"] = row[
"fecha"].ToString();
1416 if (!
string.IsNullOrEmpty(row[
"codplan"].ToString().Trim()))
1417 cPlan =
" - " + DB.SQLValor(
"PLANS",
"CODIGO", row[
"codplan"].ToString(),
"NOMBRE").ToString();
1419 if (!
string.IsNullOrEmpty(row[
"codigona1"].ToString().Trim()))
1420 cNivel1 =
" - " + DB.SQLValor(
"SECUNDAR",
"CODIGO", row[
"codigona1"].ToString(),
"NOMBRE").ToString();
1422 if (!
string.IsNullOrEmpty(row[
"codigona2"].ToString().Trim()))
1423 cNivel2 =
" - " + DB.SQLValor(
"SECUNDAR",
"CODIGO", row[
"codigona2"].ToString(),
"NOMBRE").ToString();
1425 dr[
"codplan"] = row[
"codplan"].ToString().Trim() + cPlan;
1426 dr[
"codigona1"] = row[
"codigona1"].ToString().Trim() + cNivel1;
1427 if (
string.IsNullOrEmpty(row[
"porcenna1"].ToString().Trim()))
1429 dr[
"porcenna1"] = 0M;
1433 dr[
"porcenna1"] = row[
"porcenna1"].ToString();
1435 dr[
"codigona2"] = row[
"codigona2"].ToString().Trim() + cNivel2;
1436 if (
string.IsNullOrEmpty(row[
"porcenna2"].ToString().Trim()))
1438 dr[
"porcenna2"] = 0M;
1442 dr[
"porcenna2"] = row[
"porcenna2"].ToString();
1444 dr[
"nivel3"] = row[
"nivel3"].ToString();
1445 if (tipoResumen == TipoResumen.Comparativo)
1447 dr[
"totalactfis"] = row[
"totalactfis"].ToString();
1448 dr[
"pdteactfis"] = row[
"pdteactfis"].ToString();
1449 dr[
"totalfis"] = row[
"totalfis"].ToString();
1450 dr[
"pdtefis"] = row[
"pdtefis"].ToString();
1451 dr[
"porfis"] = row[
"porfis"].ToString();
1455 if (tipoResumen == TipoResumen.Fiscal)
1457 if (Convert.ToDecimal(dr[
"porcont"]) == 0)
1458 dr[
"totalcont"] = 0;
1464 if (row[
"bajainmo"] == DBNull.Value || row[
"bajainmo"].ToString().Trim() ==
"")
1466 nAnyBaja = 20000000;
1470 nAnyBaja = Convert.ToDateTime(row[
"bajainmo"]).Year * 100;
1471 nAnyBaja += Convert.ToDateTime(row[
"bajainmo"]).Month;
1473 string[] laCampos =
new string[3] {
"empresa",
"cuenta",
"referencia" };
1474 object[] laValores =
new object[3] { row[
"empresa"].ToString(), row[
"cuenta"].ToString(), row[
"referencia"].ToString() };
1476 dr[
"concepto"] = DB.SQLValor(
"PARTINVE", laCampos, laValores,
"concepto",
"AMORTIZA");
1478 if (!
string.IsNullOrEmpty(dr[
"concepto"].ToString().Trim()))
1480 if (dr[
"concepto"].ToString().Trim().Length > 200)
1482 dr[
"concepto"] = dr[
"concepto"].ToString().Substring(0, 200);
1486 if (tipoResumen == TipoResumen.Comparativo || tipoResumen == TipoResumen.Contable)
1488 DataTable dtcurPeriodo =
new DataTable();
1489 string lcSql2 =
" SELECT * FROM " + DB.SQLDatabase(
"AMORTIZA",
"TABLA_AM") +
1490 " WHERE empresa = " + DB.SQLString(row[
"empresa"].ToString()) +
" AND cuenta = " + DB.SQLString(row[
"cuenta"].ToString()) +
1491 " AND referencia = " + DB.SQLString(row[
"referencia"].ToString()) +
" AND periodo = " + DB.SQLString(cEjercicio);
1493 DB.SQLExec(lcSql2, ref dtcurPeriodo);
1495 decimal nTotal = 0.0M;
1496 decimal nPendiente = 0.0M;
1497 decimal nPorcen = 0.0M;
1499 if (dtcurPeriodo != null && dtcurPeriodo.Rows.Count > 0)
1501 decimal totalCont_ini = Convert.ToDecimal(dr[
"totalcont"]);
1503 foreach (DataRow loRow
in dtcurPeriodo.Rows)
1505 for (
int n = 1; n <= 12; n++)
1507 string cValor = loRow[
"A_" + Convert.ToString(n).PadLeft(2,
'0')].ToString();
1508 string cValor2 = loRow[
"M_" + Convert.ToString(n).PadLeft(2,
'0')].ToString();
1509 bool lbValor = Convert.ToBoolean(cValor);
1511 if ((((Convert.ToInt32(cEjercicio)) * 100) + n) <= nAnyBaja)
1515 if ((((Convert.ToInt32(cEjercicio)) * 100) + n) == nAnyBaja)
1517 Int32 nDias = DateTime.DaysInMonth(Convert.ToInt16(cEjercicio), n);
1518 nPorcen = ((nDias == Convert.ToDateTime(dr[
"bajainmo"]).Day) ? 1 : Convert.ToInt32((Convert.ToDateTime(dr[
"bajainmo"]).Day - 1 / nDias)));
1519 nTotal += Convert.ToDecimal(cValor2) * nPorcen;
1523 nTotal += Convert.ToDecimal(cValor2);
1528 nPendiente += Convert.ToDecimal(cValor2);
1533 if (tipoResumen != TipoResumen.Comparativo)
1535 if (usarSecundariasFlag && lIncluirDetalleAnal && Convert.ToDecimal(row[
"porcen"]) != 0)
1542 dr[
"totalact"] = nTotal;
1543 dr[
"pdteact"] = nPendiente;
1545 if (tipoResumen == TipoResumen.Comparativo)
1547 dr[
"totalcont"] = Convert.ToDecimal(dr[
"totalcont"]) + nTotal;
1551 if (dr[
"bajainmo"] != DBNull.Value)
1553 if (Convert.ToInt32(cEjercicio) > Convert.ToDateTime(dr[
"bajainmo"]).Year)
1559 if (tipoResumen == TipoResumen.Comparativo)
1561 dr[
"totalcont"] = totalCont_ini;
1564 DataTable dtcurAmorti =
new DataTable();
1565 string lcSql3 =
" SELECT * FROM " + DB.SQLDatabase(
"AMORTIZA",
"TABLA_AM") +
1566 " WHERE empresa = " + DB.SQLString(row[
"empresa"].ToString()) +
" AND cuenta = " + DB.SQLString(row[
"cuenta"].ToString()) +
1567 " AND referencia = " + DB.SQLString(row[
"referencia"].ToString()) +
" AND periodo < " + DB.SQLString(cEjercicio);
1569 DB.SQLExec(lcSql3, ref dtcurAmorti);
1571 decimal nAmorti = 0;
1572 foreach (DataRow rowA
in dtcurAmorti.Rows)
1574 nAmorti += Convert.ToDecimal(rowA[
"importe"]);
1577 dr[
"totalact"] = Convert.ToDecimal(dr[
"totalcont"]) - nAmorti ;
1581 dr[
"pdtecont"] = Convert.ToDecimal(dr[
"importe"]) - Convert.ToDecimal(dr[
"totalcont"]);
1587 if (tipoResumen == TipoResumen.Comparativo || tipoResumen == TipoResumen.Fiscal)
1589 DataTable dtcurPeriodo2 =
new DataTable();
1590 string lcSql3 =
" SELECT * FROM " + DB.SQLDatabase(
"AMORTIZA",
"TABLA_FI") +
1591 " WHERE empresa = " + DB.SQLString(row[
"empresa"].ToString()) +
" AND cuenta = " + DB.SQLString(row[
"cuenta"].ToString()) +
1592 " AND referencia = " + DB.SQLString(row[
"referencia"].ToString()) +
" AND periodo = " + DB.SQLString(cEjercicio);
1594 DB.SQLExec(lcSql3, ref dtcurPeriodo2);
1596 decimal nTotal2 = 0.0M;
1597 decimal nPendiente2 = 0.0M;
1598 decimal nPorcen2 = 0.0M;
1600 if (dtcurPeriodo2 != null && dtcurPeriodo2.Rows.Count > 0)
1602 decimal totalfis_ini =(tipoResumen != TipoResumen.Comparativo ? 0 : Convert.ToDecimal(dr[
"totalfis"]));
1604 foreach (DataRow loRow
in dtcurPeriodo2.Rows)
1606 for (
int n = 1; n <= 12; n++)
1608 string cValor = loRow[
"A_" + Convert.ToString(n).PadLeft(2,
'0')].ToString();
1609 string cValor2 = loRow[
"M_" + Convert.ToString(n).PadLeft(2,
'0')].ToString();
1610 bool lbValor = Convert.ToBoolean(cValor);
1612 if ((((Convert.ToInt32(cEjercicio)) * 100) + n) <= nAnyBaja)
1616 if ((((Convert.ToInt32(cEjercicio)) * 100) + n) == nAnyBaja)
1618 Int32 nDias = DateTime.DaysInMonth(Convert.ToInt16(cEjercicio), n);
1619 nPorcen2 = ((nDias == Convert.ToDateTime(dr[
"bajainmo"]).Day) ? 1 : Convert.ToInt32((Convert.ToDateTime(dr[
"bajainmo"]).Day - 1 / nDias)));
1620 nTotal2 += Convert.ToDecimal(cValor2) * nPorcen2;
1624 nTotal2 += Convert.ToDecimal(cValor2);
1629 nPendiente2 += Convert.ToDecimal(cValor2);
1634 if (tipoResumen != TipoResumen.Comparativo)
1636 if (usarSecundariasFlag && lIncluirDetalleAnal && Convert.ToDecimal(row[
"porcen"]) != 0)
1643 if (tipoResumen == TipoResumen.Fiscal)
1645 dr[
"totalact"] = nTotal2;
1646 dr[
"pdteact"] = nPendiente2;
1648 dr[
"pdtecont"] = Convert.ToDecimal(dr[
"importe"]) - Convert.ToDecimal(dr[
"totalcont"]);
1652 dr[
"totalfis"] = Convert.ToDecimal(dr[
"totalfis"]) + nTotal2;
1653 dr[
"pdtefis"] = Convert.ToDecimal(dr[
"importe"]) - Convert.ToDecimal(dr[
"totalfis"]);
1654 dr[
"totalactfis"] = nTotal2;
1655 dr[
"pdteactfis"] = nPendiente2;
1659 if (dr[
"bajainmo"] != DBNull.Value && dr[
"bajainmo"].ToString().Trim() !=
"")
1661 if (Convert.ToInt32(cEjercicio) > Convert.ToDateTime(dr[
"bajainmo"]).Year)
1663 if (tipoResumen == TipoResumen.Fiscal)
1674 if (tipoResumen == TipoResumen.Comparativo)
1676 dr[
"totalfis"] = totalfis_ini;
1679 DataTable dtcurAmorti =
new DataTable();
1680 string lcSql4 =
" SELECT * FROM " + DB.SQLDatabase(
"AMORTIZA",
"TABLA_FI") +
1681 " WHERE empresa = " + DB.SQLString(row[
"empresa"].ToString()) +
" AND cuenta = " + DB.SQLString(row[
"cuenta"].ToString()) +
1682 " AND referencia = " + DB.SQLString(row[
"referencia"].ToString()) +
" AND periodo < " + DB.SQLString(cEjercicio);
1684 DB.SQLExec(lcSql4, ref dtcurAmorti);
1686 decimal nAmorti = 0;
1687 foreach (DataRow rowA
in dtcurAmorti.Rows)
1689 nAmorti += Convert.ToDecimal(rowA[
"importe"]);
1691 if (tipoResumen == TipoResumen.Fiscal)
1693 dr[
"totalact"] = Convert.ToDecimal(dr[
"totalcont"]) - nAmorti;
1697 dr[
"totalactfis"] = Convert.ToDecimal(dr[
"totalfis"]) - nAmorti;
1698 dr[
"pdtefis"] = Convert.ToDecimal(dr[
"importe"]) - Convert.ToDecimal(dr[
"totalfis"]);
1707 if ((cRowCta ==
"" && cRowRef ==
"" ) || (cRowCta != row[
"cuenta"].ToString()) || (cRowCta == row[
"cuenta"].ToString() && cRowRef != row[
"referencia"].ToString()))
1713 if (usarSecundariasFlag && lIncluirDetalleAnal && cRowCta !=
"" && cRowRef !=
"")
1715 string[] preservar = null;
1716 if (row[
"codplan"].ToString() == cRowCodplan && row[
"codigona1"].ToString() == cRowCodigona1)
1718 if (row[
"codigona2"].ToString() != cRowCodigona2)
1720 preservar =
new string[] {
"codigona2",
"porcenna2" };
1724 preservar =
new string[] {
"codplan",
"codigona1",
"codigona2",
"porcenna1",
"porcenna2" };
1729 if (row[
"codplan"].ToString() == cRowCodplan)
1731 preservar =
new string[] {
"codigona1",
"codigona2",
"porcenna1",
"porcenna2" };
1735 preservar =
new string[] {
"codplan",
"codigona1",
"codigona2",
"porcenna1",
"porcenna2" };
1739 for (
int i = 0; i < dtTmp_d.Columns.Count; i++)
1741 string columname = dtTmp_d.Columns[i].ColumnName;
1742 if (Array.Exists(preservar, element => element == columname))
1746 dr[i] = DBNull.Value;
1751 dtDades.Rows.Add(dr);
1756 nCuentaTotalAct = nCuentaTotalAct + Convert.ToDecimal(dr[
"totalact"]);
1757 nCuentaPdteAct = nCuentaPdteAct + Convert.ToDecimal(dr[
"pdteact"]);
1758 nCuentaTotalCont = nCuentaTotalCont + Convert.ToDecimal(dr[
"totalcont"]);
1759 nCuentaPdteCont = nCuentaPdteCont + (Convert.ToDecimal(dr[
"importe"]) - Convert.ToDecimal(dr[
"totalcont"]));
1760 nCuentaImporte = nCuentaImporte + Convert.ToDecimal(dr[
"importe"]);
1762 nTotalTotalAct = nTotalTotalAct + Convert.ToDecimal(dr[
"totalact"]);
1763 nTotalPdteAct = nTotalPdteAct + Convert.ToDecimal(dr[
"pdteact"]);
1764 nTotalTotalCont = nTotalTotalCont + Convert.ToDecimal(dr[
"totalcont"]);
1765 nTotalPdteCont = nTotalPdteCont + (Convert.ToDecimal(dr[
"importe"]) - Convert.ToDecimal(dr[
"totalcont"]));
1766 nTotalImporte = nTotalImporte + Convert.ToDecimal(dr[
"importe"]);
1768 if (tipoResumen == TipoResumen.Comparativo)
1770 nCuentaTotalActFis = nCuentaTotalActFis + Convert.ToDecimal(dr[
"totalactfis"]);
1771 nCuentaPdteActFis = nCuentaPdteActFis + Convert.ToDecimal(dr[
"pdteactfis"]);
1772 nCuentaTotalFis = nCuentaTotalFis + Convert.ToDecimal(dr[
"totalfis"]);
1773 nCuentaPdteFis = nCuentaPdteFis + Convert.ToDecimal(dr[
"totalfis"]);
1775 nTotalTotalActFis = nTotalTotalActFis + Convert.ToDecimal(dr[
"totalactfis"]);
1776 nTotalPdteActFis = nTotalPdteActFis + Convert.ToDecimal(dr[
"pdteactfis"]);
1777 nTotalTotalFis = nTotalTotalFis + Convert.ToDecimal(dr[
"totalfis"]);
1778 nTotalPdteFis = nTotalPdteFis + Convert.ToDecimal(dr[
"totalfis"]);
1781 if (usarSecundariasFlag && lIncluirDetalleAnal)
1783 nSecunTotalAct = nSecunTotalAct + Convert.ToDecimal(dr[
"totalact"]);
1784 nSecunPdteAct = nSecunPdteAct + Convert.ToDecimal(dr[
"pdteact"]);
1785 nSecunTotalCont = nSecunTotalCont + Convert.ToDecimal(dr[
"totalcont"]);
1786 nSecunPdteCont = nSecunPdteCont + Convert.ToDecimal(dr[
"pdtecont"]);
1787 nSecunImporte = nSecunImporte + Convert.ToDecimal(dr[
"importe"]);
1789 if (tipoResumen == TipoResumen.Comparativo)
1791 nSecunTotalActFis = nSecunTotalActFis + Convert.ToDecimal(dr[
"totalactfis"]);
1792 nSecunPdteActFis = nSecunPdteActFis + Convert.ToDecimal(dr[
"pdteactfis"]);
1793 nSecunTotalFis = nSecunTotalFis + Convert.ToDecimal(dr[
"totalfis"]);
1794 nSecunPdteFis = nSecunPdteFis + Convert.ToDecimal(dr[
"pdtefis"]);
1798 nPrinTotalAct = nPrinTotalAct + Convert.ToDecimal(dr[
"totalact"]);
1799 nPrinPdteAct = nPrinPdteAct + Convert.ToDecimal(dr[
"pdteact"]);
1800 nPrinTotalCont = nPrinTotalCont + Convert.ToDecimal(dr[
"totalcont"]);
1801 nPrinPdteCont = nPrinPdteCont + Convert.ToDecimal(dr[
"pdtecont"]);
1802 nPrinImporte = nPrinImporte + Convert.ToDecimal(dr[
"importe"]);
1804 if (tipoResumen == TipoResumen.Comparativo)
1806 nPrinTotalActFis = nPrinTotalActFis + Convert.ToDecimal(dr[
"totalactfis"]);
1807 nPrinPdteActFis = nPrinPdteActFis + Convert.ToDecimal(dr[
"pdteactfis"]);
1808 nPrinTotalFis = nPrinTotalFis + Convert.ToDecimal(dr[
"totalfis"]);
1809 nPrinPdteFis = nPrinPdteFis + Convert.ToDecimal(dr[
"pdtefis"]);
1813 cRowCta = row[
"cuenta"].ToString();
1814 cRowRef = row[
"referencia"].ToString();
1815 cRowCodplan = row[
"codplan"].ToString();
1816 cRowCodigona1 = row[
"codigona1"].ToString();
1817 cRowCodigona2 = row[
"codigona2"].ToString();
1818 lbPrimerReg =
false;
1822 if (dtTmp_d.Columns.Contains(
"porcen"))
1823 dtTmp_d.Columns.Remove(
"porcen");
1825 if (dtDades.Columns.Contains(
"porcen"))
1826 dtDades.Columns.Remove(
"porcen");
1833 private void PintarTotales(DataTable dtDades)
1837 if (usarSecundariasFlag && lIncluirDetalleAnal)
1840 if (!
string.IsNullOrEmpty(cSecundaria))
1841 cPlan =
" - " + DB.SQLValor(
"PLANS",
"CODIGO", cSecundaria,
"NOMBRE").ToString();
1845 dr = dtDades.NewRow();
1846 dr[
"cuenta"] = cPrincipal;
1847 dr[
"referencia"] =
"";
1848 dr[
"totalact"] = nPrinTotalAct;
1849 dr[
"pdteact"] = nPrinPdteAct;
1850 dr[
"totalcont"] = nPrinTotalCont;
1851 dr[
"pdtecont"] = nPrinPdteCont;
1852 dr[
"importe"] = nPrinImporte;
1853 dr[
"concepto"] = DB.SQLValor(
"CUENTAS",
"CODIGO", cPrincipal,
"NOMBRE").ToString();
1855 if (tipoResumen == TipoResumen.Comparativo)
1857 dr[
"totalactfis"] = nPrinTotalActFis;
1858 dr[
"pdteactfis"] = nPrinPdteActFis;
1859 dr[
"totalfis"] = nPrinTotalFis;
1860 dr[
"pdtefis"] = nPrinPdteFis;
1862 dtDades.Rows.Add(dr);
1866 string cNivel3Digitos = cNivel3.Substring(0, 3);
1867 dr = dtDades.NewRow();
1868 dr[
"cuenta"] = cNivel3;
1869 dr[
"referencia"] =
"";
1870 dr[
"totalact"] = nCuentaTotalAct;
1871 dr[
"pdteact"] = nCuentaPdteAct;
1872 dr[
"totalcont"] = nCuentaTotalCont;
1873 dr[
"pdtecont"] = nCuentaPdteCont;
1874 dr[
"importe"] = nCuentaImporte;
1875 dr[
"concepto"] = DB.SQLValor(
"NIVEL3",
"CODIGO", cNivel3Digitos,
"NOMBRE").ToString();
1877 if (tipoResumen == TipoResumen.Comparativo)
1879 dr[
"totalactfis"] = nCuentaTotalActFis;
1880 dr[
"pdteactfis"] = nCuentaPdteActFis;
1881 dr[
"totalfis"] = nCuentaTotalFis;
1882 dr[
"pdtefis"] = nCuentaPdteFis;
1884 dtDades.Rows.Add(dr);
1887 dr = dtDades.NewRow();
1888 dr[
"cuenta"] =
"TOTAL";
1889 dr[
"referencia"] =
"";
1890 dr[
"totalact"] = nTotalTotalAct;
1891 dr[
"pdteact"] = nTotalPdteAct;
1892 dr[
"totalcont"] = nTotalTotalCont;
1893 dr[
"pdtecont"] = nTotalPdteCont;
1894 dr[
"importe"] = nTotalImporte;
1896 if (tipoResumen == TipoResumen.Comparativo)
1898 dr[
"totalactfis"] = nTotalTotalActFis;
1899 dr[
"pdteactfis"] = nTotalPdteActFis;
1900 dr[
"totalfis"] = nTotalTotalFis;
1901 dr[
"pdtefis"] = nTotalPdteFis;
1903 dtDades.Rows.Add(dr);
override void _SetDefaultValues(Dictionary< string, object > toControlsFiltros=null, Dictionary< string, object > toControlsOpciones=null)
Override del _SetDefaultValues para ocultar si se requiere la opción de cuentas secundarias ...
override void _SetColumnWidth(Dictionary< string, int > tldTranslate=null)
Especifica el tamaño que tendrá la columan en Pixels para que en el grid no todas las columnas tengan...
Clase parcial para listados, en esta definición se especificarán los métodos comunes para las demás c...
Es como el tipo de entrada asientos pero por negocio, sin formulario, pq quiero que me haga las propu...
override void _SetColumnMasks()
Overrides _SetColumnMasks
override void _Navigate(String tcKeyNavigate, DataRow trRow)
Añadir navegación al asiento
Clase de negocio ResumenAmortizacion
override DataTable _DataTable()
Método de obtención de los datos específico para el listado
Entidad de relación (Columnas adicionales en listados)
override void _SetColumnCaptions(Dictionary< string, string > tldTranslate=null)
Overrides _SetColumnCaptions
_Tipo_Filtro_String
Enumeración de los posibles filtros de tipo STRING a realizar xxxDesde => Valor mínimo del filtro xxx...