diarioprint.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 <unistd.h>
00022 
00023 #include "diarioprint.h"
00024 #include "listcuentasview1.h"
00025 #include "empresa.h"
00026 
00027 
00029 
00032 DiarioPrint::DiarioPrint(Empresa  *emp) : PEmpresaBase(emp) {
00033     _depura("DiarioPrint::DiarioPrint", 0);
00034     fichero = NULL;
00035     _depura("END DiarioPrint::DiarioPrint", 0);
00036 }
00037 
00038 
00040 
00042 DiarioPrint::~DiarioPrint() {
00043     _depura("DiarioPrint::~DiarioPrint", 0);
00044     _depura("END DiarioPrint::~DiarioPrint", 0);
00045 }
00046 
00047 
00049 
00053 void DiarioPrint::inicializa1(char *finicial1, char *ffinal1) {
00054     _depura("DiarioPrint::inicializa1", 0);
00055     finicial = finicial1;
00056     ffinal = ffinal1;
00057     _depura("DiarioPrint::inicializa1", 0);
00058 }
00059 
00060 
00062 
00065 void DiarioPrint::inicializa2(char *fich) {
00066     _depura("DiarioPrint::inicializa2", 0);
00067     fichero = fich;
00068     _depura("DiarioPrint::inicializa2", 0);
00069 }
00070 
00071 
00073 
00075 void DiarioPrint::accept() {
00076     _depura("DiarioPrint::accept", 0);
00077     float debe, haber;
00078     int idcuenta;
00079     int idasiento;
00080     string fecha;
00081     string fechaasiento;
00082     string descripcion;
00083     string concepto;
00084     string codigocuenta;
00085     string cad;
00086     cursor2 *cursoraux, *cursoraux1, *cursoraux2;
00087 
00088     FILE *mifile;
00089     mifile = fopen("diario.txt", "wt");
00090     if (mifile != NULL) {
00091         fprintf(mifile, "Fecha Inicial: %s, Fecha Final: %s\n", finicial, ffinal);
00092         fprintf(mifile, "%5.5s %10.10s %10s %30.30s %9.2s %9.2s\n", "ASIENTO", "FECHA", "SUBCUENTA", "DESCRIPCION", "DEBE", "HABER");
00093         fprintf(mifile, "----------------------------------------------------------------------------------------------------------\n");
00094         empresaBase()->begin();
00095         cursoraux = empresaBase()->cargaasientosfecha(finicial, ffinal);
00096         for (; !cursoraux->eof(); cursoraux->siguienteregistro()) {
00097             fprintf(stderr, "bucle\n");
00098             fechaasiento = cursoraux->valor(2).toAscii().constData();
00099             idasiento = atoi(cursoraux->valor(0).toAscii());
00100             cursoraux1 = empresaBase()->cargaapuntes(idasiento);
00101             for (; !cursoraux1->eof(); cursoraux1->siguienteregistro()) {
00102                 fecha = cursoraux1->valor(4).toAscii().constData();
00103                 descripcion = cursoraux1->valor(5).toAscii().constData();
00104                 concepto = cursoraux->valor(1).toAscii().constData();
00105                 debe = atof(cursoraux1->valor(8).toAscii());
00106                 haber = atof(cursoraux1->valor(9).toAscii());
00107                 idcuenta = atoi(cursoraux1->valor(6).toAscii());
00108 
00109                 cursoraux2 = empresaBase()->cargacuenta(idcuenta, NULL);
00110                 if (!cursoraux2->eof()) {
00111                     codigocuenta = cursoraux2->valor(1).toAscii().constData();
00112                 } // end if
00113                 cursoraux2->cerrar();
00114                 delete cursoraux2;
00115                 fprintf(mifile, "%5d %-10.10s %10s %-30.30s %9.2f %9.2f\n", idasiento, fecha.c_str(), codigocuenta.c_str(), descripcion.c_str(), debe, haber);
00116             } // end for
00117             cursoraux1->cerrar();
00118             delete cursoraux1;
00119             fprintf(mifile, "\n");
00120         } // end for
00121         delete cursoraux;
00122         empresaBase()->commit();
00123         fclose(mifile);
00124     } // end if
00125 
00127     QString cadaux = confpr->valor(CONF_EDITOR) + " diario.txt";
00128     system(cadaux.toAscii().constData());
00129     _depura("END DiarioPrint::accept", 0);
00130 }
00131 

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