listlinprevcobro.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 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 "listlinprevcobro.h"
00022 #include "empresa.h"
00023 #include "linprevcobro.h"
00024 
00025 
00027 
00029 void ListLinPrevCobro::inicializaVariables() {
00030     _depura("ListLinPrevCobro::inicializaVariables", 0);
00031     m_companyact = NULL;
00032     mdb_idregistroiva = "";
00033     mfilt_idregistroiva = "";
00034     mfilt_tipoprevcobro = "";
00035     mfilt_codigocuentaprevcobro = "";
00036     mfilt_finprevcobro = "";
00037     mfilt_ffiprevcobro = "";
00038     _depura("END ListLinPrevCobro::inicializaVariables", 0);
00039 }
00040 
00041 
00043 
00046 ListLinPrevCobro::ListLinPrevCobro(Empresa *comp) {
00047     _depura("ListLinPrevCobro::ListLinPrevCobro", 0);
00048     inicializaVariables();
00049     m_companyact = comp;
00050     _depura("END ListLinPrevCobro::ListLinPrevCobro", 0);
00051 }
00052 
00054 
00056 ListLinPrevCobro::ListLinPrevCobro() {
00057     _depura("ListLinPrevCobro::ListLinPrevCobro", 0);
00058     inicializaVariables();
00059     _depura("END ListLinPrevCobro::ListLinPrevCobro", 0);
00060 }
00061 
00062 
00064 
00066 ListLinPrevCobro::~ListLinPrevCobro() {
00067     _depura("ListLinPrevCobro::~ListLinPrevCobro", 0);
00068     _depura("END ListLinPrevCobro::~ListLinPrevCobro", 0);
00069 }
00070 
00071 
00073 
00089 void ListLinPrevCobro::nuevalinea(QString desc, QString cantl, QString pvpl, QString descl,QString idart, QString codart, QString nomart, QString ivapres, QString k, QString l, QString m, QString idctacliente, QString codigoctacliente, QString nomctacliente) {
00090     linprevcobro *lin = new linprevcobro(m_companyact, "", desc,  cantl, pvpl,
00091                                          descl, idart, codart, nomart,
00092                                          mdb_idregistroiva, ivapres, k,
00093                                          l, m, idctacliente, codigoctacliente, nomctacliente);
00094     m_lista.append(lin);
00095 }
00096 
00097 
00099 
00103 linprevcobro *ListLinPrevCobro::linpos(int pos) {
00104     _depura("ListLinPrevCobro::linpos", 0);
00105     _depura("END ListLinPrevCobro::linpos", 0);
00106     return m_lista.at(pos);
00107 }
00108 
00109 
00111 
00114 int ListLinPrevCobro::chargeBudgetLines() {
00115     QString cadwhere = "";
00116     vaciar();
00117     fprintf(stderr, "ListLinPrevCobro::chargeBudgetLines\n");
00118     fprintf(stderr, "Hacemos la carga del cursor\n");
00119     if (mfilt_idregistroiva != "")
00120         cadwhere = " AND idregistroiva = " + mfilt_idregistroiva;
00121     if (mfilt_finprevcobro != "")
00122         cadwhere += " AND fcobroprevcobro >= '" + mfilt_finprevcobro + "'";
00123     if (mfilt_codigocuentaprevcobro != "")
00124         cadwhere += " AND idcuenta = id_cuenta('" + mfilt_codigocuentaprevcobro + "')";
00125     if (mfilt_tipoprevcobro != "")
00126         cadwhere += " AND tipoprevcobro = '" + mfilt_tipoprevcobro + "'";
00127     if (mfilt_procesado == "PROCESADO")
00128         cadwhere += " AND idasiento IS NOT NULL ";
00129     if (mfilt_procesado == "NO PROCESADO")
00130         cadwhere += " AND idasiento IS NULL ";
00131 
00132     cursor2 *cur= m_companyact->cargacursor("SELECT * FROM prevcobro "
00133                                             " LEFT JOIN cuenta ON cuenta.idcuenta = prevcobro.idcuenta "
00134                                             " LEFT JOIN (SELECT idcuenta AS idctacliente, codigo AS codigoctacliente, descripcion AS nomctacliente FROM cuenta) AS T1 ON t1.idctacliente = prevcobro.idctacliente "
00135                                             " WHERE 1 = 1 "+ cadwhere + " ORDER BY fcobroprevcobro ");
00136 
00137     int i = 0;
00138     while (!cur->eof()) {
00140         linprevcobro *lin = new linprevcobro(m_companyact,
00141                                              cur->valor("idprevcobro"),
00142                                              cur->valor("fprevistaprevcobro"),
00143                                              cur->valor("fcobroprevcobro"),
00144                                              cur->valor("idfpago"),
00145                                              cur->valor("idcuenta"),
00146                                              cur->valor("idasiento"),
00147                                              cur->valor("cantidadprevistaprevcobro"),
00148                                              cur->valor("cantidadprevcobro"),
00149                                              cur->valor("idregistroiva"),
00150                                              cur->valor("tipoprevcobro"),
00151                                              cur->valor("docprevcobro"),
00152                                              cur->valor("codigo"),
00153                                              cur->valor("descripcion"),
00154                                              cur->valor("idctacliente"),
00155                                              cur->valor("codigoctacliente"),
00156                                              cur->valor("nomctacliente"));
00157         m_lista.append(lin);
00158         i++;
00159         cur->siguienteregistro();
00160     } // end while
00161     delete cur;
00162     _depura("END de ListLinPrevCobro::chargeBudgetLines\n");
00163     return 0;
00164 }
00165 
00166 
00168 
00170 void ListLinPrevCobro::guardaListLinPrevCobro() {
00171     _depura("guardaListLinPrevCobro()");
00172     linprevcobro *linea;
00173 
00174     QMutableListIterator<linprevcobro*> m_ilista(m_lista);
00176     m_ilista.toFront();
00178     while (m_ilista.hasNext()) {
00180         linea = m_ilista.next();
00181         linea->guardalinprevcobro();
00182     } // end while
00183 }
00184 
00185 
00187 
00189 void ListLinPrevCobro::vaciar() {
00190     _depura("ListLinPrevCobro::vaciar", 0);
00191     m_lista.clear();
00192     _depura("END ListLinPrevCobro::vaciar", 0);
00193 }
00194 
00195 
00197 
00199 void ListLinPrevCobro::borrar() {
00200     _depura("ListLinPrevCobro::borrar", 0);
00201     if (mdb_idregistroiva != "")  {
00202         m_companyact->begin();
00203         m_companyact->ejecuta("DELETE FROM prevcobro WHERE idregistroiva = " + mdb_idregistroiva);
00204         m_companyact->commit();
00205     } // end if
00206     _depura("END ListLinPrevCobro::borrar", 0);
00207 }
00208 
00210 
00212 void ListLinPrevCobro::borralinprevcobro(int pos) {
00213     _depura("ListLinPrevCobro::borralinprevcobro", 0);
00214     linprevcobro *linea;
00215     linea = m_lista.at(pos);
00216     linea->borrar();
00217     m_lista.removeAt(pos);
00218     pintaListLinPrevCobro();
00219     _depura("END ListLinPrevCobro::borralinprevcobro", 0);
00220 }
00221 
00222 
00224 
00227 Fixed ListLinPrevCobro::totalCobro() {
00228     _depura("ListLinPrevCobro::totalCobro", 0);
00229     linprevcobro *linea;
00230     Fixed tcobro("0");
00231 
00232     QMutableListIterator<linprevcobro*> m_ilista(m_lista);
00234     m_ilista.toFront();
00236     while (m_ilista.hasNext()) {
00238         linea = m_ilista.next();
00239         if (linea->tipoprevcobro() == "t") {
00240             tcobro = tcobro + Fixed(linea->cantidadprevcobro());
00241         } // end if
00242     } // end while
00243     _depura("END ListLinPrevCobro::totalCobro", 0);
00244     return tcobro;
00245 }
00246 
00247 
00249 
00252 Fixed ListLinPrevCobro::totalPago() {
00253     _depura("ListLinPrevCobro::totalPago", 0);
00254     linprevcobro *linea;
00255     Fixed tpago("0");
00256 
00257     QMutableListIterator<linprevcobro*> m_ilista(m_lista);
00259     m_ilista.toFront();
00261     while (m_ilista.hasNext()) {
00263         linea = m_ilista.next();
00264         if (linea->tipoprevcobro() == "f") {
00265             tpago = tpago + Fixed(linea->cantidadprevcobro());
00266         } // end if
00267     } // end while
00268     _depura("END ListLinPrevCobro::totalPago", 0);
00269     return tpago;
00270 }
00271 

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