listiva.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 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 "listiva.h"
00022 #include "empresa.h"
00023 #include "funcaux.h"
00024 
00025 
00027 
00030 ListIva::ListIva(Empresa *comp) {
00031     _depura("ListIva::ListIva", 0);
00032     companyact = comp;
00033     mdb_idregistroiva = "";
00034     _depura("END ListIva::ListIva", 0);
00035 }
00036 
00037 
00039 
00041 ListIva::ListIva() {
00042     _depura("Constructor de ListIva\n", 0);
00043     companyact = NULL;
00044     mdb_idregistroiva = "";
00045 }
00046 
00047 
00049 
00051 ListIva::~ListIva() {
00052     _depura("ListIva::~ListIva", 0);
00053     _depura("ListIva::~ListIva", 0);
00054 }
00055 
00056 
00058 
00062 Iva *ListIva::linpos(int pos) {
00063     _depura("ListIva::linpos", 0);
00064     _depura("END ListIva::linpos", 0);
00065     return m_lista.at(pos);
00066 }
00067 
00068 
00070 
00074 int ListIva::cargaListIva(QString idregistroiva) {
00075     _depura("ListIva::cargaListIva\n", 0);
00076     int error = 0;
00077     vaciar();
00078     mdb_idregistroiva = idregistroiva;
00079 
00080     cursor2 * cur= companyact->cargacursor("SELECT * FROM  tipoiva LEFT JOIN (SELECT * FROM iva WHERE idregistroiva = " + idregistroiva + " ) AS t1 ON t1.idtipoiva = tipoiva.idtipoiva LEFT JOIN cuenta on tipoiva.idcuenta = cuenta.idcuenta  ORDER BY codigo");
00081     if (cur->error()) {
00082         error = 1;
00083     } // end if
00084     while (!cur->eof()) {
00086         Iva *lin = new Iva(companyact, cur);
00087         m_lista.append(lin);
00088         cur->siguienteregistro();
00089     } // end while
00090     delete cur;
00091 
00093     if (error) {
00094         _depura("Error en la carga de Iva\n", 0);
00095         return 1;
00096     } // end if
00097 
00098     _depura("END ListIva::cargaListIva\n", 0);
00099     return 0;
00100 }
00101 
00102 
00104 
00106 void ListIva::guardaListIva() {
00107     _depura("ListIva::guardaListIva", 0);
00108     Iva *linea;
00109 
00110     QMutableListIterator<Iva*> m_ilista(m_lista);
00112     m_ilista.toFront();
00114     while (m_ilista.hasNext()) {
00116         linea = m_ilista.next();
00117         if (linea->baseiva() != "") {
00118             linea->guardaIva();
00119         } // end if
00120     } // end while
00121 
00122     _depura("END ListIva::guardaListIva", 0);
00123 }
00124 
00125 
00127 
00130 Fixed ListIva::calculabase() {
00131     _depura("ListIva::calculabase", 0);
00132     Fixed base("0.00");
00133     Iva *linea;
00134 
00135     QMutableListIterator<Iva*> m_ilista(m_lista);
00137     m_ilista.toFront();
00139     while (m_ilista.hasNext()) {
00141         linea = m_ilista.next();
00142         base = base + Fixed(linea->baseiva());
00143     } // end while
00144     _depura("END ListIva::calculabase", 0);
00145     return base;
00146 }
00147 
00148 
00150 
00153 Fixed ListIva::calculaiva() {
00154     _depura("ListIva::calculaiva", 0);
00155     Fixed iva("0.00");
00156     Iva *linea;
00157 
00158     QMutableListIterator<Iva*> m_ilista(m_lista);
00160     m_ilista.toFront();
00162     while (m_ilista.hasNext()) {
00164         linea = m_ilista.next();
00165         iva = iva + Fixed(linea->ivaiva());
00166     } // end while
00167     _depura("END ListIva::calculaiva", 0);
00168     return iva;
00169 }
00170 
00171 
00173 
00175 void ListIva::vaciar() {
00176     _depura("ListIva::vaciar", 0);
00177     mdb_idregistroiva = "";
00178     m_lista.clear();
00179     _depura("END ListIva::vaciar", 0);
00180 }
00181 
00182 
00184 
00187 void ListIva::borrar() {
00188     _depura("ListIva::borrar", 0);
00189     if (mdb_idregistroiva != "")  {
00190         companyact->begin();
00191         int error = companyact->ejecuta("DELETE FROM iva WHERE idregistroiva = " + mdb_idregistroiva);
00192         if (error) {
00193             companyact->rollback();
00194             return;
00195         } // end if
00196         companyact->commit();
00197     } // end if
00198     _depura("END ListIva::borrar", 0);
00199 }
00200 
00201 
00203 
00206 void ListIva::borraIva(int pos) {
00207     _depura("ListIva::borraIva", 0);
00208     Iva *linea;
00209     linea = m_lista.at(pos);
00210     linea->borrar();
00211     m_lista.removeAt(pos);
00212     pintaListIva();
00213     _depura("ListIva::borraIva", 0);
00214 }
00215 

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