Subversion Repositories public

Rev

Rev 64 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
43 root 1
/***************************************************************************
52 andreas 2
 *   Copyright (C) 2007 by Andreas Theofilu                                *
3
 *   andreas@TheoSys.at                                                    *
43 root 4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
52 andreas 7
 *   the Free Software Foundation version 3 of the License.                *
43 root 8
 *                                                                         *
9
 *   This program is distributed in the hope that it will be useful,       *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 *   GNU General Public License for more details.                          *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
19
 
20
#include <klineedit.h>
21
#include <kmessagebox.h>
22
#include <klocale.h>
23
#include <kdatewidget.h>
24
#include <kcombobox.h>
25
#include <knuminput.h>
60 andreas 26
#include <kfiledialog.h>
43 root 27
#include <qcheckbox.h>
52 andreas 28
#include <qradiobutton.h>
60 andreas 29
#include <qdir.h>
30
#include <qfile.h>
43 root 31
 
32
#include <stdlib.h>
60 andreas 33
//#include <iostream.h>
43 root 34
#include "helper.h"
35
#include "tilgungsplanwidget.h"
36
#include "ziaendwidget.h"
60 andreas 37
#include "ratenplanwidget.h"
43 root 38
 
39
tilgungsplanWidget::tilgungsplanWidget ( QWidget* parent, const char* name, WFlags fl )
40
		: tilgungsplanWidgetBase ( parent,name,fl )
41
{
60 andreas 42
	dirty = FALSE;
43
	mamma = parent;		// Parent window needed to exit application
43 root 44
 
60 andreas 45
	// Zuletzt verwendete Maskenparameter aus der Datei holen, sofern
46
	// es diese Datei bereits gibt.
47
	readValues();
43 root 48
}
49
 
50
tilgungsplanWidget::~tilgungsplanWidget()
60 andreas 51
{
52
QString hdir = QDir::homeDirPath ();
53
QFile tmpFile;
43 root 54
 
60 andreas 55
	if (!dirty)
56
	   return;
57
 
58
	// Zuletzt verwendete Maskenparameter in eine Datei schreiben.
59
	hdir.append("/.tilgpars.dat");
60
	tmpFile.setName(hdir);
61
 
62
	if (tmpFile.open(IO_ReadWrite | IO_Truncate) == FALSE)
63
	{
64
	   KMessageBox::error(0, QString("Could not open file for writing: %1").arg(tmpFile.errorString()));
65
	   return;
66
	}
67
 
68
	moveValues();
69
	write (tmpFile.handle(), &TpPars, sizeof(TPPARS));
70
	tmpFile.close();
71
}
72
 
73
void tilgungsplanWidget::moveValues()
43 root 74
{
60 andreas 75
QDate dt;
76
int ret;
43 root 77
 
60 andreas 78
	memset(&TpPars, 0, sizeof(TPPARS));
43 root 79
	// Zuweisen der Inhalte der Widgets zur internen Parameterstruktur.
80
	TpPars.effformel = 0.0;
81
	TpPars.gewicht = 0.0;
52 andreas 82
	TpPars.tageb = comboBox_tageber->currentItem() + 1;
83
 
84
	switch (comboBox_verzart->currentItem())
85
	{
86
	   case 0: TpPars.verzart = 0; break;	// Dekursiv
87
	   case 1: TpPars.verzart = 3; break;	// Antizipativ
88
	   case 2: TpPars.verzart = 7; break;	// Dekursiv; Zinsen am Beg.d. Absclussp.
89
	   case 3: TpPars.verzart = 4; break;	// Unverzinst
90
	}
91
 
43 root 92
	TpPars.ratenart = comboBox_Ratart->currentItem();
93
	TpPars.valuta = comboBox_valuta->currentItem();
94
	TpPars.zssoll = kDoubleNumInput_Zinssatz->value();
46 andreas 95
	TpPars.zuschfix = kDoubleNumInput_ZuschFix->value();
96
	TpPars.zuschprz = kDoubleNumInput_ZiZuschuss->value();
43 root 97
	TpPars.zuschannu = kDoubleNumInput_AnnZuschuss->value();
98
	dt = kDateWidget_Auszahlung->date();
99
	TpPars.ragab = make_date(dt.day(), dt.month(), dt.year());
100
	dt = kDateWidget_Abschluss->date();
101
	TpPars.abschl = make_date(dt.day(), dt.month(), dt.year());
102
	TpPars.ultimo = checkBox_RechUltimo->isChecked();
103
	TpPars.anzraten = kIntNumInput_AnzRaten->value();
104
	ret = comboBox_Abschl->currentItem();
105
 
106
	switch (ret)
107
	{
108
           case 0: TpPars.abschlry = 0; break;
109
	   case 1: TpPars.abschlry = 1; break;
110
	   case 2: TpPars.abschlry = 3; break;
111
	   case 3: TpPars.abschlry = 6; break;
112
	   case 4: TpPars.abschlry = 12; break;
113
	   case 5: TpPars.abschlry = 41; break;
114
	   case 6: TpPars.abschlry = 43; break;
115
	   case 7: TpPars.abschlry = 46; break;
116
	   case 8: TpPars.abschlry = 47; break;
117
	   case 9: TpPars.abschlry = 48; break;
118
	   case 10: TpPars.abschlry = 52; break;
119
        }
120
 
60 andreas 121
	TpPars.zuschver = 0;		// wird derzeit nicht verwendet!
43 root 122
	TpPars.spesen = kDoubleNumInput_Fixspesen->value();
70 andreas 123
	TpPars.kosten = kDoubleNumInput_Kosten->value();
43 root 124
	TpPars.rahmen = kDoubleNumInput_Betrag->value();
125
	TpPars.kapital = 0.0;
44 andreas 126
	TpPars.raplan[0] = checkBox_RaJan->isChecked();
127
	TpPars.raplan[1] = checkBox_RaFeb->isChecked();
128
	TpPars.raplan[2] = checkBox_RaMar->isChecked();
129
	TpPars.raplan[3] = checkBox_RaApr->isChecked();
130
	TpPars.raplan[4] = checkBox_RaMai->isChecked();
131
	TpPars.raplan[5] = checkBox_RaJun->isChecked();
132
	TpPars.raplan[6] = checkBox_RaJul->isChecked();
133
	TpPars.raplan[7] = checkBox_RaAug->isChecked();
134
	TpPars.raplan[8] = checkBox_RaSep->isChecked();
135
	TpPars.raplan[9] = checkBox_RaOkt->isChecked();
136
	TpPars.raplan[10] = checkBox_RaNov->isChecked();
137
	TpPars.raplan[11] = checkBox_RaDez->isChecked();
43 root 138
	TpPars.rate = kDoubleNumInput_Rate->value();
139
	dt = kDateWidget_RaVon->date();
140
	TpPars.dvon = make_date(dt.day(), dt.month(), dt.year());
141
	dt = kDateWidget_RaBis->date();
142
	TpPars.dbis = make_date(dt.day(), dt.month(), dt.year());
143
	dt = kDateWidget_Endfael->date();
144
	TpPars.endfaell = make_date(dt.day(), dt.month(), dt.year());
145
	TpPars.runden = checkBox_Runden->isChecked();
146
	TpPars.mehrfach = FALSE;
147
	TpPars.laufstop = FALSE;
52 andreas 148
#ifdef _ZINSAENDERUNG
149
	TpPars.ziaend = checkBox_ZiChange->isChecked();
150
#else
43 root 151
	TpPars.ziaend = FALSE;
52 andreas 152
#endif
60 andreas 153
	TpPars.effekt = FALSE;
43 root 154
	TpPars.fixrate = checkBox_Rate->isChecked();
60 andreas 155
}
43 root 156
 
60 andreas 157
void tilgungsplanWidget::readValues(const char *fname, BOOL home)
158
{
159
QDate dt;
160
QString hdir = QDir::homeDirPath ();
161
QFile tmpFile;
162
int fd, day, mon, year;
163
 
164
	// Zuletzt verwendete Maskenparameter aus der Datei holen, sofern
165
	// es diese Datei bereits gibt.
166
	if (home)
167
	{
168
	   hdir = QDir::homeDirPath();
169
	   hdir.append(fname);
170
	}
171
	else
172
	   hdir = QString(fname);
173
 
174
	tmpFile.setName(hdir);
175
 
176
	if (tmpFile.open(IO_ReadOnly) == FALSE)
177
	{
178
	   // Maske mit sinnvollen Parametern versorgen
179
	   comboBox_tageber->setCurrentItem(3);
180
	   comboBox_Ratart->setCurrentItem(1);
181
	   comboBox_Abschl->setCurrentItem(10);
182
	   kDoubleNumInput_Zinssatz->setValue(5.5);
183
	   kDateWidget_Auszahlung->setDate(QDate::currentDate());
184
	   // Datum: Der 5. des nächsten Monats
185
	   dt = QDate::currentDate();
186
	   dt = dt.addMonths(1);
187
	   dt.setYMD(dt.year(), dt.month(), 5);
188
	   kDateWidget_RaVon->setDate(dt);
189
	   dt = dt.addYears(1);
190
	   kDateWidget_RaBis->setDate(dt);
191
	   kDateWidget_ZiGiltAb->setDate(QDate::currentDate());
192
	   kDoubleNumInput_Betrag->setValue(100000.0);
193
	   checkBox_RaJan->setChecked(TRUE);
194
	   checkBox_RaFeb->setChecked(TRUE);
195
	   checkBox_RaMar->setChecked(TRUE);
196
	   checkBox_RaApr->setChecked(TRUE);
197
	   checkBox_RaMai->setChecked(TRUE);
198
	   checkBox_RaJun->setChecked(TRUE);
199
	   checkBox_RaJul->setChecked(TRUE);
200
	   checkBox_RaAug->setChecked(TRUE);
201
	   checkBox_RaSep->setChecked(TRUE);
202
	   checkBox_RaOkt->setChecked(TRUE);
203
	   checkBox_RaNov->setChecked(TRUE);
204
	   checkBox_RaDez->setChecked(TRUE);
205
#ifndef _ZINSAENDERUNG
206
	   checkBox_ZiChange->setProperty("enabled", QVariant("FALSE"));
207
#endif
208
	   return;
209
	}
210
 
211
	fd = tmpFile.handle();
212
	read (fd, &TpPars, sizeof(TPPARS));
213
	tmpFile.close();
214
	kDoubleNumInput_Betrag->setValue(TpPars.rahmen);
70 andreas 215
	kDoubleNumInput_Kosten->setValue(TpPars.kosten);
60 andreas 216
	date_int(&day, &mon, &year, TpPars.ragab);
217
	dt.setYMD(year, mon, day);
218
	kDateWidget_Auszahlung->setDate(dt);
219
	comboBox_tageber->setCurrentItem(TpPars.tageb-1);
220
 
221
	switch (TpPars.verzart)
222
	{
223
	   case 0: comboBox_verzart->setCurrentItem(0); break;
224
	   case 3: comboBox_verzart->setCurrentItem(1); break;
225
	   case 7: comboBox_verzart->setCurrentItem(2); break;
226
	   case 4: comboBox_verzart->setCurrentItem(3); break;
227
	}
228
 
229
	kDoubleNumInput_Fixspesen->setValue(TpPars.spesen);
230
	kDoubleNumInput_Zinssatz->setValue(TpPars.zssoll);
231
#ifdef _ZINSAENDERUNG
232
	checkBox_ZiChange->setChecked(TpPars.ziaend);
233
#else
234
	checkBox_ZiChange->setProperty("enabled", QVariant("FALSE"));
235
#endif
236
	date_int(&day, &mon, &year, TpPars.ragab);
237
	dt.setYMD(year, mon, day);
238
	kDateWidget_ZiGiltAb->setDate(dt);		// Dummy!
239
	checkBox_RechUltimo->setChecked(TpPars.ultimo);
240
	kDoubleNumInput_ZiZuschuss->setValue(TpPars.zuschprz);
241
	kDoubleNumInput_ZuschFix->setValue(TpPars.zuschfix);
242
 
243
	if (TpPars.zuschprz > 0.0)
244
	{
245
	   radioButton_ZuschP->setChecked(TRUE);
246
	   radioButton_ZuschF->setChecked(FALSE);
247
	}
248
	else
249
	{
250
	   radioButton_ZuschP->setChecked(FALSE);
251
	   radioButton_ZuschF->setChecked(TRUE);
252
	}
253
 
254
	kDoubleNumInput_AnnZuschuss->setValue(TpPars.zuschannu);
255
	checkBox_Runden->setChecked(TpPars.runden);
256
	kIntNumInput_AnzRaten->setValue(TpPars.anzraten);
257
	kDoubleNumInput_Rate->setValue(TpPars.rate);
258
	date_int(&day, &mon, &year, TpPars.endfaell);
259
	dt.setYMD(year, mon, day);
260
	kDateWidget_Endfael->setDate(dt);
261
	date_int(&day, &mon, &year, TpPars.dvon);
262
	dt.setYMD(year, mon, day);
263
	kDateWidget_RaVon->setDate(dt);
264
	checkBox_Rate->setChecked(TpPars.fixrate);
265
	comboBox_Ratart->setCurrentItem(TpPars.ratenart);
266
	checkBox_RaJan->setChecked(TpPars.raplan[0]);
267
	checkBox_RaFeb->setChecked(TpPars.raplan[1]);
268
	checkBox_RaMar->setChecked(TpPars.raplan[2]);
269
	checkBox_RaApr->setChecked(TpPars.raplan[3]);
270
	checkBox_RaMai->setChecked(TpPars.raplan[4]);
271
	checkBox_RaJun->setChecked(TpPars.raplan[5]);
272
	checkBox_RaJul->setChecked(TpPars.raplan[6]);
273
	checkBox_RaAug->setChecked(TpPars.raplan[7]);
274
	checkBox_RaSep->setChecked(TpPars.raplan[8]);
275
	checkBox_RaOkt->setChecked(TpPars.raplan[9]);
276
	checkBox_RaNov->setChecked(TpPars.raplan[10]);
277
	checkBox_RaDez->setChecked(TpPars.raplan[11]);
278
	date_int(&day, &mon, &year, TpPars.dbis);
279
	dt.setYMD(year, mon, day);
280
	kDateWidget_RaBis->setDate(dt);
281
	comboBox_valuta->setCurrentItem(TpPars.valuta);
282
 
283
	switch (TpPars.abschlry)
284
	{
285
	   case 0: comboBox_Abschl->setCurrentItem(0); break;
286
	   case 1: comboBox_Abschl->setCurrentItem(1); break;
287
	   case 3: comboBox_Abschl->setCurrentItem(2); break;
288
	   case 6: comboBox_Abschl->setCurrentItem(3); break;
289
	   case 12: comboBox_Abschl->setCurrentItem(4); break;
290
	   case 41: comboBox_Abschl->setCurrentItem(5); break;
291
	   case 43: comboBox_Abschl->setCurrentItem(6); break;
292
	   case 46: comboBox_Abschl->setCurrentItem(7); break;
293
	   case 47: comboBox_Abschl->setCurrentItem(8); break;
294
	   case 48: comboBox_Abschl->setCurrentItem(9); break;
295
	   case 52: comboBox_Abschl->setCurrentItem(10); break;
296
	}
297
 
298
	date_int (&day, &mon, &year, TpPars.abschl);
299
	dt.setYMD(year, mon, day);
300
	kDateWidget_Abschluss->setDate(dt);
301
}
302
 
303
/*$SPECIALIZATION$*/
304
void tilgungsplanWidget::mnCalcTPSumSlot()
305
{
306
QDate dt, dt1;
307
QString str, zia;
308
TRech *tp;
309
int ret, day1, day2, mon1, mon2, year1, year2;
310
char hv0[255];
311
double ezins, rate;
312
TPPARS pars;
313
 
314
	// Zuweisen der Inhalte der Widgets zur internen Parameterstruktur.
315
	moveValues();
316
 
43 root 317
	if (TpPars.dbis > TpPars.endfaell)
318
	   TpPars.endfaell = TpPars.dbis;
319
 
60 andreas 320
	if (TpPars.fixrate)
321
	{
322
	   TpPars.endfaell = 0L;
323
	   TpPars.dbis = 0L;
324
	}
325
 
326
	// Parameter für spätere Effektivzinsberechnung wegspeichern
327
	memmove (&pars, &TpPars, sizeof(TPPARS));
328
 
43 root 329
	// Berechnung anstossen
330
	tp = new TRech (&TpPars);
331
 
332
	if ((ret = tp->tilgpl()) != 0)
333
	{
334
	   switch (ret)
335
	   {
336
	      case 1: str = QString::fromUtf8("Fehler beim Erzeugen einer Temporärdatei!"); break;
337
	      case 2: str = QString::fromUtf8("Erste Einschränkung nicht vorhanden!"); break;
338
	      case 3:
339
		 date_int (&day1, &mon1, &year1, TpPars.ragab);
340
		 date_int (&day2, &mon2, &year2, TpPars.dvon);
341
		 sprintf (hv0, "Das Auszahlungsdatum (%02d.%02d.%d) muss kleiner als das Datum der ersten Einschränkung sein (%02d.%02d.%d)!",
342
			day1, mon1, year1, day2, mon2, year2);
343
		 str = QString::fromUtf8(hv0); break;
344
	      case 4:
345
		 date_int (&day1, &mon1, &year1, TpPars.abschl);
346
		 date_int (&day2, &mon2, &year2, TpPars.ragab);
347
		 sprintf (hv0, "Das Abschlussdatum (%02d.%02d.%d) darf nicht kleiner als das Auszahlungsdatum (%02d, %02d.%d) sein!",
348
			day1, mon1, year1, day2, mon2, year2);
349
		 str = QString::fromUtf8(hv0); break;
350
	      case 5:
351
		 date_int (&day1, &mon1, &year1, TpPars.dvon);
352
		 date_int (&day2, &mon2, &year2, TpPars.dbis);
353
		 sprintf (hv0, "Die erste Einschränkung (%02d.%02d.%d) darf nicht größer als die letzte Einschränkung (%02d.%02d.%d) sein!",
354
			day1, mon1, year1, day2, mon2, year2);
355
		 str = QString::fromUtf8(hv0); break;
356
	      case 6:
357
		 date_int (&day1, &mon1, &year1, TpPars.dbis);
358
		 date_int (&day2, &mon2, &year2, TpPars.endfaell);
359
		 sprintf (hv0, "Die letzte Einschränkung (%02d.%02d.%d) darf nicht größer die Endfälligkeit (%02d.%02d.%d) sein!",
360
			day1, mon1, year1, day2, mon2, year2);
361
		 str = QString::fromUtf8(hv0); break;
362
	      case 7: str = QString::fromUtf8("Es wurde keine Rate angegeben!"); break;
363
	      case 8: str = QString::fromUtf8("Kein, oder ungültiges Auszahlungsdatum!"); break;
364
	      case 9: str = QString::fromUtf8("Die Verzinsung in Bezug auf den Abschlussrythmus ist ungültig!"); break;
365
	      case 10: str = QString::fromUtf8("Das Abschlussdatum fehlt oder ist ungültig!"); break;
366
	      case 11:
367
		 sprintf(hv0, "Der Abschlussrythmus ist ungültig! (%d)",TpPars.abschlry);
368
		 str = QString::fromUtf8(hv0); break;
369
	      case 12: str = QString::fromUtf8("Die Verzinsungsart ist ungültig!"); break;
370
	      case 13: str = QString::fromUtf8("Die Ratenart ist ungültig!"); break;
371
	      case 14: str = QString::fromUtf8("Die Laufzeit ist über 100 Jahre!"); break;
372
	      case 15: str = QString::fromUtf8("Es wurde keine Rate vorgegeben!"); break;
373
	      case 16: str = QString::fromUtf8("Die vorgegebene Rate darf nicht kleiner als 0 sein!"); break;
374
	      case 18: str = QString::fromUtf8("Die erste Einschränkung oder die Ratenleiste ist ungültig!"); break;
375
	      case 19: str = QString::fromUtf8("Die letzte Einschränkung oder die Ratenleiste ist ungültig!"); break;
60 andreas 376
	      case 20: str = QString::fromUtf8("Interner Rechenfehler!"); break;
43 root 377
	      case 22: str = QString::fromUtf8("Nicht genügend Speicher!"); break;
378
	      case 23: str = QString::fromUtf8("\"Antizipativ\" erlaubt keine Zinssatzänderung!"); break;
44 andreas 379
	      case 24: 
380
	      case 25: str = QString::fromUtf8("Fehler beim Lesen der Zinssatzänderungen!"); break;
60 andreas 381
	      case 26: str = QString::fromUtf8("Interner Fehler bei der Effektivzinsberechnung! Der Abschlussrhythmus muss jährlich sein!"); break;
382
	      case 27: str = QString::fromUtf8("Interner Fehler bei der Effektivzinsberechnung! Die Laufzeit muss genau 1 Jahr betragen!"); break;
383
	      case 28: str = QString::fromUtf8("Eine Effektivzinsberechnung ist bei <b>dekursiver</b> Verzinsung möglich!"); break;
384
	      case 29: str = QString::fromUtf8("Für die Effektivzinsberechnung muss eine Rate größer 0 angegeben werden!"); break;
43 root 385
	      default:
60 andreas 386
//		 sprintf (hv0, "Unbekannter Fehler \"%d\"! Prüfen Sie die Eingaben.", ret);
387
	         str = QString("Unbekannter Fehler \"%1\"! Prüfen Sie die Eingaben.").arg(ret);
43 root 388
	   }
389
 
390
	   KMessageBox::error(0, str, i18n("Fehler"));
391
	   lineEdit_EffZi->clear();
392
	   lineEdit_GesBelast->clear();
44 andreas 393
	   lineEdit_ErgRate->clear();
394
	   lineEdit_ErgLRate->clear();
395
	   lineEdit_ErgZinsen->clear();
396
	   lineEdit_ErgZiZusch->clear();
397
	   lineEdit_ErgAnnZusch->clear();
398
	   lineEdit_ErgSumAnnZusch->clear();
60 andreas 399
	   delete tp;
43 root 400
	   return;
401
	}
60 andreas 402
/*
52 andreas 403
	if (TpPars.effformel > 0.0)
404
	   PointNumber(TpPars.effformel, 3, &hv0[0]);
405
	else
406
	   PointNumber(TpPars.gewicht, 3, &hv0[0]);
407
 
43 root 408
	lineEdit_EffZi->clear();
409
	lineEdit_EffZi->insert(hv0);
60 andreas 410
*/
43 root 411
	PointNumber(TpPars.gesamt, 2, &hv0[0]);
412
	lineEdit_GesBelast->clear();
413
	lineEdit_GesBelast->insert(hv0);
44 andreas 414
 
43 root 415
	kIntNumInput_AnzRaten->setValue(TpPars.anzraten);
44 andreas 416
 
43 root 417
	date_int(&day1, &mon1, &year1, TpPars.dbis);
418
	dt.setYMD(year1, mon1, day1);
419
	kDateWidget_RaBis->setDate(dt);
44 andreas 420
 
43 root 421
	date_int(&day1, &mon1, &year1, TpPars.endfaell);
422
	dt.setYMD(year1, mon1, day1);
423
	kDateWidget_Endfael->setDate(dt);
44 andreas 424
 
60 andreas 425
	rate = TpPars.ergrate;
44 andreas 426
	PointNumber(TpPars.ergrate, 2, hv0);
427
	lineEdit_ErgRate->clear();
428
	lineEdit_ErgRate->insert(hv0);
429
 
430
	PointNumber(TpPars.lrate, 2, hv0);
431
	lineEdit_ErgLRate->clear();
432
	lineEdit_ErgLRate->insert(hv0);
433
 
434
	PointNumber(TpPars.ezins, 2, hv0);
435
	lineEdit_ErgZinsen->clear();
436
	lineEdit_ErgZinsen->insert(hv0);
437
 
438
	PointNumber(TpPars.zuschuss, 2, hv0);
439
	lineEdit_ErgZiZusch->clear();
440
	lineEdit_ErgZiZusch->insert(hv0);
441
 
442
	PointNumber(TpPars.anzuschuss, 2, hv0);
443
	lineEdit_ErgAnnZusch->clear();
444
	lineEdit_ErgAnnZusch->insert(hv0);
445
 
446
	PointNumber(TpPars.antotal, 2, hv0);
447
	lineEdit_ErgSumAnnZusch->clear();
448
	lineEdit_ErgSumAnnZusch->insert(hv0);
60 andreas 449
 
450
	// Effektivzinssatz berechnen
64 andreas 451
	pars.effekt = TRUE;
60 andreas 452
	pars.zuschfix = 0.0;
453
	pars.zuschprz = 0.0;
454
	pars.zuschannu = 0.0;
455
	pars.ergrate = 0.0;
456
	pars.lrate = 0.0;
457
	pars.ezins = 0.0;
458
	pars.zuschuss = 0.0;
459
	pars.gewicht = 0.0;
70 andreas 460
	pars.kosten = 0.0;
60 andreas 461
 
462
	if (TpPars.abschlry > 40)
463
	   pars.abschlry = 52;
464
	else
465
	   pars.abschlry = 12;
466
 
467
	pars.spesen = 0.0;
468
	pars.rate = TpPars.ergrate;
469
	pars.endfaell = 0L;
470
	pars.fixrate = TRUE;
471
	pars.ziaend = FALSE;
472
 
473
	tp->setPars(&pars);
474
 
475
	if ((ret = tp->tilgpl()) != 0)
476
	{
477
	   KMessageBox::error(0, QString("Interner Fehler \"%1\"!").arg(ret), i18n("Fehler"));
478
	   delete tp;
479
	   return;
480
	}
481
 
64 andreas 482
//	PointNumber(100.0 / TpPars.ezins * pars.ezins, 3, &hv0[0]);
483
	PointNumber(pars.effformel, 3, &hv0[0]);
60 andreas 484
	lineEdit_EffZi->clear();
485
	lineEdit_EffZi->insert(hv0);
64 andreas 486
/*
60 andreas 487
KMessageBox::information(this, QString("O-EZins: %1\nN-EZins: %2\nGesamt1: %3\nGesamt2: %4")
488
	.arg(TpPars.ezins)
489
	.arg(pars.ezins)
490
	.arg(TpPars.gesamt)
491
	.arg(pars.gesamt));
492
*/
493
	delete tp;
43 root 494
}
495
 
496
void tilgungsplanWidget::txRaDezSlot()
60 andreas 497
{
498
	dirty = TRUE;
499
}
43 root 500
 
501
void tilgungsplanWidget::txRaNovSlot()
60 andreas 502
{
503
	dirty = TRUE;
504
}
43 root 505
 
506
void tilgungsplanWidget::txRaOktSlot()
60 andreas 507
{
508
	dirty = TRUE;
509
}
43 root 510
 
511
void tilgungsplanWidget::txRaSepSlot()
60 andreas 512
{
513
	dirty = TRUE;
514
}
43 root 515
 
516
void tilgungsplanWidget::txRaAugSlot()
60 andreas 517
{
518
	dirty = TRUE;
519
}
43 root 520
 
521
void tilgungsplanWidget::txRaJulSlot()
60 andreas 522
{
523
	dirty = TRUE;
524
}
43 root 525
 
526
void tilgungsplanWidget::txRaJunSlot()
60 andreas 527
{
528
	dirty = TRUE;
529
}
43 root 530
 
531
void tilgungsplanWidget::txRaMaiSlot()
60 andreas 532
{
533
	dirty = TRUE;
534
}
43 root 535
 
536
void tilgungsplanWidget::txRaMarSlot()
60 andreas 537
{
538
	dirty = TRUE;
539
}
43 root 540
 
541
void tilgungsplanWidget::txRaFebSlot()
60 andreas 542
{
543
	dirty = TRUE;
544
}
43 root 545
 
546
void tilgungsplanWidget::txRaJanSlot()
60 andreas 547
{
548
	dirty = TRUE;
549
}
43 root 550
 
551
void tilgungsplanWidget::txRaAprSlot()
60 andreas 552
{
553
	dirty = TRUE;
554
}
43 root 555
 
556
void tilgungsplanWidget::txGesBelastSlot()
60 andreas 557
{
558
	dirty = TRUE;
559
}
43 root 560
 
561
void tilgungsplanWidget::txEffZiSlot()
60 andreas 562
{
563
	dirty = TRUE;
564
}
43 root 565
 
566
void tilgungsplanWidget::intAnzRatenSlot()
60 andreas 567
{
568
	dirty = TRUE;
569
}
43 root 570
 
571
void tilgungsplanWidget::numAnnZuschSlot()
60 andreas 572
{
573
	dirty = TRUE;
574
}
43 root 575
 
576
void tilgungsplanWidget::dtZiGiltAbSlot()
60 andreas 577
{
578
	dirty = TRUE;
579
}
43 root 580
 
581
void tilgungsplanWidget::dtRaVonSlot()
60 andreas 582
{
583
	dirty = TRUE;
584
}
43 root 585
 
586
void tilgungsplanWidget::dtRaBisSlot()
60 andreas 587
{
588
	dirty = TRUE;
589
}
43 root 590
 
591
void tilgungsplanWidget::dtEndfaelSlot()
60 andreas 592
{
593
	dirty = TRUE;
594
}
43 root 595
 
596
void tilgungsplanWidget::dtAuszahlSlot()
60 andreas 597
{
598
	kDateWidget_ZiGiltAb->setDate(kDateWidget_Auszahlung->date());
599
	dirty = TRUE;
600
}
43 root 601
 
602
void tilgungsplanWidget::dtAbschlussSlot()
60 andreas 603
{
604
	dirty = TRUE;
605
}
43 root 606
 
607
void tilgungsplanWidget::lbRatartSlot()
60 andreas 608
{
609
	dirty = TRUE;
610
}
43 root 611
 
612
void tilgungsplanWidget::cbZiChangeSlot()
60 andreas 613
{
614
	dirty = TRUE;
615
}
43 root 616
 
617
void tilgungsplanWidget::cbUltimoSlot()
60 andreas 618
{
619
	dirty = TRUE;
620
}
43 root 621
 
622
void tilgungsplanWidget::cbRateSlot()
60 andreas 623
{
624
	dirty = TRUE;
625
}
43 root 626
 
627
void tilgungsplanWidget::mnCalcTPSlot()
60 andreas 628
{
629
ratenplanWidget *dlg = new ratenplanWidget(this, "ratenplanWidgetBase", TRUE, 0);
43 root 630
 
60 andreas 631
	dlg->exec();
632
	delete dlg;
633
}
634
 
44 andreas 635
void tilgungsplanWidget::mnInputZiSlot()
636
{
60 andreas 637
#ifdef _ZINSAENDERUNG
44 andreas 638
ziaendWidget *dlg = new ziaendWidget(this, "ziaendWidgetBase", TRUE, 0);
639
 
52 andreas 640
	dlg->exec();
44 andreas 641
	delete dlg;
60 andreas 642
#else
643
	KMessageBox::information(0, i18n("This module was omitted at compile time! To activate it, define \"_ZINSAENDERUNG\" globaly and recompile the program."));
644
#endif
44 andreas 645
}
646
 
43 root 647
void tilgungsplanWidget::lbVerzartSlot()
60 andreas 648
{
649
	dirty = TRUE;
650
}
43 root 651
 
652
void tilgungsplanWidget::lbTageberSlot()
60 andreas 653
{
654
	dirty = TRUE;
655
}
43 root 656
 
657
void tilgungsplanWidget::numZuzaehlSlot()
60 andreas 658
{
659
	dirty = TRUE;
660
}
43 root 661
 
662
void tilgungsplanWidget::numBeaGebSlot()
60 andreas 663
{
664
	dirty = TRUE;
665
}
43 root 666
 
667
void tilgungsplanWidget::numZisatzSlot()
60 andreas 668
{
669
	dirty = TRUE;
670
}
43 root 671
 
672
void tilgungsplanWidget::numZiZuschSlot()
60 andreas 673
{
674
	dirty = TRUE;
675
}
43 root 676
 
677
void tilgungsplanWidget::numRateSlot()
60 andreas 678
{
679
	dirty = TRUE;
680
}
43 root 681
 
682
void tilgungsplanWidget::numFixspesenSlot()
60 andreas 683
{
684
	dirty = TRUE;
685
}
43 root 686
 
52 andreas 687
void tilgungsplanWidget::rbZuschPSlot()
688
{
689
	if (radioButton_ZuschP->isChecked())
690
	{
691
	   kDoubleNumInput_ZiZuschuss->setProperty("enabled", QVariant("TRUE"));
692
	   kDoubleNumInput_ZuschFix->setProperty("enabled", QVariant("FALSE"));
693
	   radioButton_ZuschF->setChecked(FALSE);
694
	}
695
	else
696
	{
697
	   kDoubleNumInput_ZiZuschuss->setProperty("enabled", QVariant("FALSE"));
698
	   kDoubleNumInput_ZuschFix->setProperty("enabled", QVariant("TRUE"));
699
	   radioButton_ZuschF->setChecked(TRUE);
700
	}
701
}
702
 
703
void tilgungsplanWidget::rbZuschFSlot()
704
{
705
	if (radioButton_ZuschF->isChecked())
706
	{
707
	   kDoubleNumInput_ZiZuschuss->setProperty("enabled", QVariant("FALSE"));
708
	   kDoubleNumInput_ZuschFix->setProperty("enabled", QVariant("TRUE"));
709
	   radioButton_ZuschP->setChecked(FALSE);
710
	}
711
	else
712
	{
713
	   kDoubleNumInput_ZiZuschuss->setProperty("enabled", QVariant("TRUE"));
714
	   kDoubleNumInput_ZuschFix->setProperty("enabled", QVariant("FALSE"));
715
	   radioButton_ZuschP->setChecked(TRUE);
716
	}
717
}
718
 
43 root 719
void tilgungsplanWidget::cbRundenSlot()
60 andreas 720
{
721
	dirty = TRUE;
722
}
43 root 723
 
724
void tilgungsplanWidget::numBetragSlot()
60 andreas 725
{
726
	dirty = TRUE;
727
}
43 root 728
 
70 andreas 729
void tilgungsplanWidget::numKostenSlot()
730
{
731
	dirty = TRUE;
732
}
733
 
43 root 734
void tilgungsplanWidget::helpAbout()
735
{}
736
 
737
void tilgungsplanWidget::helpContents()
738
{}
739
 
740
void tilgungsplanWidget::helpIndex()
741
{}
742
 
743
void tilgungsplanWidget::editFind()
744
{}
745
 
746
void tilgungsplanWidget::editPaste()
747
{}
748
 
749
void tilgungsplanWidget::editCopy()
750
{}
751
 
752
void tilgungsplanWidget::editCut()
753
{}
754
 
755
void tilgungsplanWidget::editRedo()
756
{}
757
 
758
void tilgungsplanWidget::editUndo()
759
{}
760
 
761
void tilgungsplanWidget::fileExit()
44 andreas 762
{
60 andreas 763
	mamma->close();
44 andreas 764
}
765
 
43 root 766
void tilgungsplanWidget::filePrint()
767
{}
768
 
769
void tilgungsplanWidget::fileSaveAs()
60 andreas 770
{
771
QString fname = KFileDialog::getSaveFileName(QString("tilgpars.dat"), QString("*.dat"), this, QString("Tilgungsplan"));
772
QFile tmpFile;
43 root 773
 
60 andreas 774
	if (fname.isEmpty())
775
	   return;
776
 
777
	tmpFile.setName(fname);
778
 
779
	if (tmpFile.open(IO_ReadWrite | IO_Truncate) == FALSE)
780
	{
781
	   KMessageBox::error(0, QString("Could not open file for writing: %1").arg(tmpFile.errorString()));
782
	   return;
783
	}
784
 
785
	moveValues();
786
	write (tmpFile.handle(), &TpPars, sizeof(TPPARS));
787
	tmpFile.close();
788
}
789
 
43 root 790
void tilgungsplanWidget::fileSave()
60 andreas 791
{
792
QString hdir = QDir::homeDirPath ();
793
QFile tmpFile;
43 root 794
 
60 andreas 795
	if (!dirty)
796
	   return;
797
 
798
	// Zuletzt verwendete Maskenparameter in eine Datei schreiben.
799
	hdir.append("/.tilgpars.dat");
800
	tmpFile.setName(hdir);
801
 
802
	if (tmpFile.open(IO_ReadWrite | IO_Truncate) == FALSE)
803
	{
804
	   KMessageBox::error(0, QString("Could not open file for writing: %1").arg(tmpFile.errorString()));
805
	   return;
806
	}
807
 
808
	moveValues();
809
	write (tmpFile.handle(), &TpPars, sizeof(TPPARS));
810
	tmpFile.close();
811
	KMessageBox::information(this, i18n("Die Daten der Eingabemaske wurden erfolgreich gespeichert."));
812
}
813
 
43 root 814
void tilgungsplanWidget::fileOpen()
60 andreas 815
{
816
QString fname = KFileDialog::getOpenFileName(QString::null, QString("*.dat"), this, QString("Tilgungsplan"));
43 root 817
 
60 andreas 818
	if (fname.isEmpty())
819
	   return;
820
 
821
	readValues(fname.ascii());
822
}
823
 
43 root 824
void tilgungsplanWidget::fileNew()
825
{}
826
 
827
void tilgungsplanWidget::lbValutaSlot()
60 andreas 828
{
829
	dirty = TRUE;
830
}
43 root 831
 
832
void tilgungsplanWidget::cbAbschlSlot()
833
{
834
int item = comboBox_Abschl->currentItem();
835
char hv0[256];
836
 
837
	switch (item)
838
	{
839
           case 0: TpPars.abschlry = 0; break;
840
	   case 1: TpPars.abschlry = 1; break;
841
	   case 2: TpPars.abschlry = 3; break;
842
	   case 3: TpPars.abschlry = 6; break;
843
	   case 4: TpPars.abschlry = 12; break;
844
	   case 5: TpPars.abschlry = 41; break;
845
	   case 6: TpPars.abschlry = 43; break;
846
	   case 7: TpPars.abschlry = 46; break;
847
	   case 8: TpPars.abschlry = 47; break;
848
	   case 9: TpPars.abschlry = 48; break;
849
	   case 10: TpPars.abschlry = 52; break;
850
	   default:
851
	      sprintf (hv0, "Gewähltes Item: %d", item);
852
	      KMessageBox::information(0, i18n(hv0));
60 andreas 853
	}
854
 
855
	dirty = TRUE;
43 root 856
}
857
 
858
#include "tilgungsplanwidget.moc"
859