correctorwidget.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Tomeu Borras Riera                              *
00003  *   tborras@conetxia.com                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include "asiento1view.h"
00022 #include "correctorwidget.h"
00023 #include "confreglasview.h"
00024 
00025 
00032 correctorwidget::correctorwidget(QWidget* parent, Qt::WFlags fl)
00033         : QWidget(parent, fl) {
00034     _depura("correctorwidget::correctorwidget", 0);
00035     setupUi(this);
00036     QObject::connect(mui_browser, SIGNAL(anchorClicked(const QUrl)), this, SLOT(alink(const QUrl)));
00037     _depura("END correctorwidget::correctorwidget", 0);
00038 }
00039 
00040 
00042 
00044 correctorwidget::~correctorwidget() {
00045     _depura("Salida del plugin Corrector", 10);
00046 }
00047 
00048 
00053 void correctorwidget::on_mui_configurar_clicked() {
00054     _depura("correctorwidget::on_mui_configurar_clicked", 0);
00055     confreglasview *conf = new confreglasview();
00056     conf->exec();
00057     delete conf;
00058     _depura("END correctorwidget::on_mui_configurar_clicked", 0);
00059 }
00060 
00061 
00067 void correctorwidget::on_mui_corregir_clicked() {
00068     _depura("correctorwidget::on_mui_corregir_clicked", 0);
00069     textBrowser = "<HTML><BODY BGCOLOR='#FFFFFF'>";
00070     cursor2 *cur;
00071 
00073     QString query;
00074     query.sprintf("SELECT *, asiento.idasiento AS idas FROM asiento LEFT JOIN (SELECT count(idborrador) AS numborr, idasiento FROM borrador GROUP BY idasiento) AS borr ON borr.idasiento = asiento.idasiento LEFT JOIN (SELECT count(idapunte) AS numap, idasiento FROM apunte GROUP BY idasiento) AS apunt ON apunt.idasiento = asiento.idasiento WHERE apunt.numap = 0 OR numap ISNULL");
00075     cur = conexionbase->cargacursor(query);
00076     while (!cur->eof()) {
00077         QString cadena;
00078         cadena.sprintf("<img src='/usr/share/bulmages/icons/messagebox_warning.png'>&nbsp;&nbsp;<B><I>Warning:</I></B><BR>El asiento num. <B>%s</B> con fecha <B>%s</B> esta abierto, esto causa que el asiento no modifique el estado de las cuentas.", cur->valor("ordenasiento").toAscii().constData(), cur->valor("fecha").toAscii().constData());
00079         agregarError(cadena, "asiento", "idasiento=" + cur->valor("idas"));
00080         cur->siguienteregistro();
00081     } // end while
00082     delete cur;
00083 
00086     query.sprintf("SELECT * FROM asiento, apunte, cuenta WHERE apunte.idcuenta = cuenta.idcuenta AND cuenta.idcuenta IN (SELECT padre FROM cuenta) AND apunte.idasiento = asiento.idasiento");
00087     cur = conexionbase->cargacursor(query);
00088     while (!cur->eof()) {
00089         QString cadena;
00090         cadena.sprintf("<img src='/usr/share/bulmages/icons/messagebox_critical.png'>&nbsp;&nbsp;<B><I>Critial Error:</I></B><BR>El asiento num. <B>%s</B> tiene un apunte con la cuenta <B>%s</B> no hija..", cur->valor("ordenasiento").toAscii().constData(), cur->valor("codigo").toAscii().constData());
00091         agregarError(cadena, "asiento", "idasiento=" + cur->valor("idasiento"));
00092         cur->siguienteregistro();
00093     } // end while
00094     delete cur;
00095 
00098     query = " SELECT asiento.idasiento AS idasiento, asiento.ordenasiento AS ordenasiento, ingresos, activos, gastos, netos, pasivos FROM asiento ";
00099     query += " LEFT JOIN (SELECT idasiento, sum(apunte.debe) - sum(apunte.haber) AS ingresos FROM cuenta, apunte WHERE apunte.idcuenta = cuenta.idcuenta AND cuenta.tipocuenta = 4 GROUP BY idasiento) AS ing ON asiento.idasiento = ing.idasiento ";
00100     query +=" LEFT JOIN (SELECT idasiento, sum(apunte.debe) - sum(apunte.haber) AS gastos FROM cuenta, apunte WHERE apunte.idcuenta = cuenta.idcuenta AND cuenta.tipocuenta = 5 GROUP BY idasiento) AS gas ON asiento.idasiento = gas.idasiento ";
00101     query += " LEFT JOIN (SELECT idasiento, sum(apunte.debe) - sum(apunte.haber) AS activos FROM cuenta, apunte WHERE apunte.idcuenta = cuenta.idcuenta AND cuenta.tipocuenta = 1 GROUP BY idasiento) AS act ON act.idasiento = asiento.idasiento ";
00102     query += " LEFT JOIN (SELECT idasiento, sum(apunte.debe) - sum(apunte.haber) AS pasivos FROM cuenta, apunte WHERE apunte.idcuenta = cuenta.idcuenta AND cuenta.tipocuenta = 2 GROUP BY idasiento) AS pas ON pas.idasiento = asiento.idasiento ";
00103     query += " LEFT JOIN (SELECT idasiento, sum(apunte.debe) - sum(apunte.haber) AS netos FROM cuenta, apunte WHERE apunte.idcuenta = cuenta.idcuenta AND cuenta.tipocuenta = 3 GROUP BY idasiento) AS net ON net.idasiento = asiento.idasiento ";
00104     query += " ORDER BY ordenasiento";
00105     cur = conexionbase->cargacursor(query);
00106     while (!cur->eof()) {
00107         float ing, gas, act, pas, net;
00108         ing = cur->valor("ingresos").toFloat();
00109         gas = cur->valor("gastos").toFloat();
00110         act = cur->valor("activos").toFloat();
00111         pas = cur->valor("pasivos").toFloat();
00112         net = cur->valor("netos").toFloat();
00113         if ((-act - gas - pas - net + ing) > 0.01) {
00114             QString cadena;
00115             cadena.sprintf("<img src='/usr/share/bulmages/icons/messagebox_critical.png'>&nbsp;&nbsp;<B><I>Error critico:</I></B><BR>El asiento num. <B>%s</B> no cumple la ecuacion fundamental.%2.2f + %2.2f = %2.2f + %2.2f + %2.2f", cur->valor("ordenasiento").toAscii().constData(), act, gas, pas, net, ing);
00116             agregarError(cadena, "asiento", "idasiento=" + cur->valor("idasiento"));
00117         } // end if
00118         cur->siguienteregistro();
00119     } // end while
00120     delete cur;
00121 
00124     query.sprintf("SELECT * FROM asiento, apunte, cuenta WHERE apunte.idcuenta = cuenta.idcuenta AND cuenta.nodebe AND apunte.idasiento = asiento.idasiento AND apunte.debe <> 0");
00125     _depura(query, 10);
00126     cur = conexionbase->cargacursor(query, "hola1");
00127     while (!cur->eof()) {
00128         QString cadena;
00129         cadena.sprintf("<img src='/usr/share/bulmages/icons/messagebox_warning.png'>&nbsp;&nbsp;<B><I>Warning:</I></B><BR>El asiento num. <B>%s</B> tiene una inserci� en el debe de la cuenta <B>%s</B> que no permite inserciones en el debe de dicha cuenta.", cur->valor("ordenasiento").toAscii().constData(), cur->valor("codigo").toAscii().constData());
00130         agregarError(cadena, "asiento","idasiento=" + cur->valor("idasiento"));
00131         cur->siguienteregistro();
00132     } // end while
00133     delete cur;
00134 
00137     query.sprintf("SELECT * FROM asiento, apunte, cuenta WHERE apunte.idcuenta = cuenta.idcuenta AND cuenta.nohaber AND apunte.idasiento = asiento.idasiento AND apunte.haber <> 0");
00138     cur = conexionbase->cargacursor(query);
00139     while (!cur->eof()) {
00140         QString cadena;
00141         cadena.sprintf("<img src='/usr/share/bulmages/icons/messagebox_warning.png'>&nbsp;&nbsp;<B><I>Warning:</I></B><BR>El asiento num. <B>%s</B> tiene una insercion en el haber de la cuenta <B>%s</B> que no permite inserciones en el haber de dicha cuenta.", cur->valor("ordenasiento").toAscii().constData(), cur->valor("codigo").toAscii().constData());
00142         agregarError(cadena, "asiento", "idasiento=" + cur->valor("idasiento"));
00143         cur->siguienteregistro();
00144     } // end while
00145     delete cur;
00146 
00149     query = "SELECT * FROM linamortizacion WHERE fechaprevista < now() AND idasiento IS NULL";
00150     cur = conexionbase->cargacursor(query);
00151     while (!cur->eof()) {
00152         QString cadena;
00153         cadena.sprintf("<img src='/usr/share/bulmages/icons/messagebox_warning.png'>&nbsp;&nbsp;<B><I>Warning:</I></B><BR>La amortizacion num. <B>%s</B> tiene un plazo expirado <B>%s</B>.", cur->valor("idamortizacion").toAscii().constData(), cur->valor("fechaprevista").toAscii().constData());
00154         agregarError(cadena, "amortizacion","idamortizacion=" + cur->valor("idamortizacion"));
00155         cur->siguienteregistro();
00156     } // end while
00157     delete cur;
00158 
00161     query = "SELECT * FROM borrador, cuenta WHERE cuenta.idcuenta = borrador.idcuenta AND codigo LIKE '%47%' AND idasiento NOT IN (SELECT idasiento FROM registroiva)";
00162     cur = conexionbase->cargacursor(query);
00163     while (!cur->eof()) {
00164         QString cadena;
00165         cadena.sprintf("<img src='/usr/share/bulmages/icons/messagebox_warning.png'>&nbsp;&nbsp;<B><I>Warning:</I></B><BR>El asiento num. <B>%s</B> tiene una insercion en cuentas de IVA (%s) sin que haya una factura asociada.", cur->valor("orden").toAscii().constData(), cur->valor("codigo").toAscii().constData());
00166         agregarError(cadena, "asiento", "idasiento=" + cur->valor("idasiento"));
00167         cur->siguienteregistro();
00168     } // end while
00169     delete cur;
00170 
00171     textBrowser += "</BODY></HTML>";
00172     mui_browser->setHtml(textBrowser);
00173     _depura("END correctorwidget::on_mui_corregir_clicked", 0);
00174 }
00175 
00176 
00184 void correctorwidget::alink(const QUrl &url) {
00185     _depura("correctorwidget::alink", 0);
00186 
00187     QString linker = url.fragment();
00188     QStringList list = linker.split("=");
00189 
00191     if (list[0] == "ver") {
00192         empresaactual->muestracuentas();
00193     } else if (list[0] == "idasiento") {
00194         Asiento1View *view = empresaactual->intapuntsempresa();
00195         bool ok;
00196         view->muestraasiento(list[1].toInt(&ok));
00197         view->hide();
00198         view->show();
00199     } else {
00200 /*        Asiento1View *view = empresaactual->intapuntsempresa();
00201         bool ok;
00202         view->muestraasiento(linker.toInt(&ok));
00203 */
00204         QMessageBox::warning(0, tr("Opcion no implementada"), tr("No se puede acceder al error"), 0, 1, 2);
00205     } // endif
00206     _depura("END correctorwidget::alink", 0);
00207 }
00208 
00209 
00218 void correctorwidget::agregarError(QString texto, QString texto1, QString texto2) {
00219    _depura("correctorwidget::agregarError", 0);
00220    textBrowser += "<HR><table><tr><td colspan=2>" + texto + "</td></tr><tr><td><!-- a name='masinfo' href='#" + texto1 + "'>+ info</a --></td><td><a name='" + texto1 + "' href='#" + texto2 + "'>ver error</a></td></tr></table>";
00221    _depura("END correctorwidget::agregarError", 0);
00222 }

Generated on Sat Dec 15 00:00:58 2007 for BulmaGes by  doxygen 1.5.1