Subversion Repositories public

Rev

Rev 70 | 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>
125 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
125 andreas 451
	pars.effekt = false;
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
 
125 andreas 462
/*	if (TpPars.abschlry > 40)
60 andreas 463
	   pars.abschlry = 52;
464
	else
465
	   pars.abschlry = 12;
125 andreas 466
*/
60 andreas 467
	pars.spesen = 0.0;
468
	pars.rate = TpPars.ergrate;
469
	pars.endfaell = 0L;
470
	pars.fixrate = TRUE;
471
	pars.ziaend = FALSE;
125 andreas 472
	pars.zssoll = TpPars.zssoll - 1.0;
473
	int i = 0;
60 andreas 474
 
125 andreas 475
	// Der Zinssatz kann nur ermittelt werden, in dem mittels Iteration
476
	// jener Zinssatz gefunden wird, bei dem das errechnete Endkapital
477
	// dem echten am naechsten kommt.
478
	while (i < 10000 && pars.gesamt <= TpPars.gesamt)
479
	{
480
	   pars.zssoll += 0.001;
481
	   pars.gesamt = 0.0;
60 andreas 482
 
125 andreas 483
	   tp->setPars(&pars);
484
 
485
	   if ((ret = tp->tilgpl()) != 0)
486
	   {
487
	      KMessageBox::error(0, QString("Interner Fehler \"%1\"!").arg(ret), i18n("Fehler"));
488
	      delete tp;
489
	      return;
490
	   }
491
 
492
	   pars.ezins = pars.zssoll;
493
	   i++;
60 andreas 494
	}
495
 
125 andreas 496
	if (i >= 10000)
497
	   pars.ezins = 0.0;
498
 
499
//	PointNumber(pars.effformel, 3, &hv0[0]);
500
	PointNumber(pars.ezins, 3, &hv0[0]);
60 andreas 501
	lineEdit_EffZi->clear();
502
	lineEdit_EffZi->insert(hv0);
64 andreas 503
/*
60 andreas 504
KMessageBox::information(this, QString("O-EZins: %1\nN-EZins: %2\nGesamt1: %3\nGesamt2: %4")
505
	.arg(TpPars.ezins)
506
	.arg(pars.ezins)
507
	.arg(TpPars.gesamt)
508
	.arg(pars.gesamt));
509
*/
510
	delete tp;
43 root 511
}
512
 
513
void tilgungsplanWidget::txRaDezSlot()
60 andreas 514
{
515
	dirty = TRUE;
516
}
43 root 517
 
518
void tilgungsplanWidget::txRaNovSlot()
60 andreas 519
{
520
	dirty = TRUE;
521
}
43 root 522
 
523
void tilgungsplanWidget::txRaOktSlot()
60 andreas 524
{
525
	dirty = TRUE;
526
}
43 root 527
 
528
void tilgungsplanWidget::txRaSepSlot()
60 andreas 529
{
530
	dirty = TRUE;
531
}
43 root 532
 
533
void tilgungsplanWidget::txRaAugSlot()
60 andreas 534
{
535
	dirty = TRUE;
536
}
43 root 537
 
538
void tilgungsplanWidget::txRaJulSlot()
60 andreas 539
{
540
	dirty = TRUE;
541
}
43 root 542
 
543
void tilgungsplanWidget::txRaJunSlot()
60 andreas 544
{
545
	dirty = TRUE;
546
}
43 root 547
 
548
void tilgungsplanWidget::txRaMaiSlot()
60 andreas 549
{
550
	dirty = TRUE;
551
}
43 root 552
 
553
void tilgungsplanWidget::txRaMarSlot()
60 andreas 554
{
555
	dirty = TRUE;
556
}
43 root 557
 
558
void tilgungsplanWidget::txRaFebSlot()
60 andreas 559
{
560
	dirty = TRUE;
561
}
43 root 562
 
563
void tilgungsplanWidget::txRaJanSlot()
60 andreas 564
{
565
	dirty = TRUE;
566
}
43 root 567
 
568
void tilgungsplanWidget::txRaAprSlot()
60 andreas 569
{
570
	dirty = TRUE;
571
}
43 root 572
 
573
void tilgungsplanWidget::txGesBelastSlot()
60 andreas 574
{
575
	dirty = TRUE;
576
}
43 root 577
 
578
void tilgungsplanWidget::txEffZiSlot()
60 andreas 579
{
580
	dirty = TRUE;
581
}
43 root 582
 
583
void tilgungsplanWidget::intAnzRatenSlot()
60 andreas 584
{
585
	dirty = TRUE;
586
}
43 root 587
 
588
void tilgungsplanWidget::numAnnZuschSlot()
60 andreas 589
{
590
	dirty = TRUE;
591
}
43 root 592
 
593
void tilgungsplanWidget::dtZiGiltAbSlot()
60 andreas 594
{
595
	dirty = TRUE;
596
}
43 root 597
 
598
void tilgungsplanWidget::dtRaVonSlot()
60 andreas 599
{
600
	dirty = TRUE;
601
}
43 root 602
 
603
void tilgungsplanWidget::dtRaBisSlot()
60 andreas 604
{
605
	dirty = TRUE;
606
}
43 root 607
 
608
void tilgungsplanWidget::dtEndfaelSlot()
60 andreas 609
{
610
	dirty = TRUE;
611
}
43 root 612
 
613
void tilgungsplanWidget::dtAuszahlSlot()
60 andreas 614
{
615
	kDateWidget_ZiGiltAb->setDate(kDateWidget_Auszahlung->date());
616
	dirty = TRUE;
617
}
43 root 618
 
619
void tilgungsplanWidget::dtAbschlussSlot()
60 andreas 620
{
621
	dirty = TRUE;
622
}
43 root 623
 
624
void tilgungsplanWidget::lbRatartSlot()
60 andreas 625
{
626
	dirty = TRUE;
627
}
43 root 628
 
629
void tilgungsplanWidget::cbZiChangeSlot()
60 andreas 630
{
631
	dirty = TRUE;
632
}
43 root 633
 
634
void tilgungsplanWidget::cbUltimoSlot()
60 andreas 635
{
636
	dirty = TRUE;
637
}
43 root 638
 
639
void tilgungsplanWidget::cbRateSlot()
60 andreas 640
{
641
	dirty = TRUE;
642
}
43 root 643
 
644
void tilgungsplanWidget::mnCalcTPSlot()
60 andreas 645
{
646
ratenplanWidget *dlg = new ratenplanWidget(this, "ratenplanWidgetBase", TRUE, 0);
43 root 647
 
60 andreas 648
	dlg->exec();
649
	delete dlg;
650
}
651
 
44 andreas 652
void tilgungsplanWidget::mnInputZiSlot()
653
{
60 andreas 654
#ifdef _ZINSAENDERUNG
44 andreas 655
ziaendWidget *dlg = new ziaendWidget(this, "ziaendWidgetBase", TRUE, 0);
656
 
52 andreas 657
	dlg->exec();
44 andreas 658
	delete dlg;
60 andreas 659
#else
660
	KMessageBox::information(0, i18n("This module was omitted at compile time! To activate it, define \"_ZINSAENDERUNG\" globaly and recompile the program."));
661
#endif
44 andreas 662
}
663
 
43 root 664
void tilgungsplanWidget::lbVerzartSlot()
60 andreas 665
{
666
	dirty = TRUE;
667
}
43 root 668
 
669
void tilgungsplanWidget::lbTageberSlot()
60 andreas 670
{
671
	dirty = TRUE;
672
}
43 root 673
 
674
void tilgungsplanWidget::numZuzaehlSlot()
60 andreas 675
{
676
	dirty = TRUE;
677
}
43 root 678
 
679
void tilgungsplanWidget::numBeaGebSlot()
60 andreas 680
{
681
	dirty = TRUE;
682
}
43 root 683
 
684
void tilgungsplanWidget::numZisatzSlot()
60 andreas 685
{
686
	dirty = TRUE;
687
}
43 root 688
 
689
void tilgungsplanWidget::numZiZuschSlot()
60 andreas 690
{
691
	dirty = TRUE;
692
}
43 root 693
 
694
void tilgungsplanWidget::numRateSlot()
60 andreas 695
{
696
	dirty = TRUE;
697
}
43 root 698
 
699
void tilgungsplanWidget::numFixspesenSlot()
60 andreas 700
{
701
	dirty = TRUE;
702
}
43 root 703
 
52 andreas 704
void tilgungsplanWidget::rbZuschPSlot()
705
{
706
	if (radioButton_ZuschP->isChecked())
707
	{
708
	   kDoubleNumInput_ZiZuschuss->setProperty("enabled", QVariant("TRUE"));
709
	   kDoubleNumInput_ZuschFix->setProperty("enabled", QVariant("FALSE"));
710
	   radioButton_ZuschF->setChecked(FALSE);
711
	}
712
	else
713
	{
714
	   kDoubleNumInput_ZiZuschuss->setProperty("enabled", QVariant("FALSE"));
715
	   kDoubleNumInput_ZuschFix->setProperty("enabled", QVariant("TRUE"));
716
	   radioButton_ZuschF->setChecked(TRUE);
717
	}
718
}
719
 
720
void tilgungsplanWidget::rbZuschFSlot()
721
{
722
	if (radioButton_ZuschF->isChecked())
723
	{
724
	   kDoubleNumInput_ZiZuschuss->setProperty("enabled", QVariant("FALSE"));
725
	   kDoubleNumInput_ZuschFix->setProperty("enabled", QVariant("TRUE"));
726
	   radioButton_ZuschP->setChecked(FALSE);
727
	}
728
	else
729
	{
730
	   kDoubleNumInput_ZiZuschuss->setProperty("enabled", QVariant("TRUE"));
731
	   kDoubleNumInput_ZuschFix->setProperty("enabled", QVariant("FALSE"));
732
	   radioButton_ZuschP->setChecked(TRUE);
733
	}
734
}
735
 
43 root 736
void tilgungsplanWidget::cbRundenSlot()
60 andreas 737
{
738
	dirty = TRUE;
739
}
43 root 740
 
741
void tilgungsplanWidget::numBetragSlot()
60 andreas 742
{
743
	dirty = TRUE;
744
}
43 root 745
 
70 andreas 746
void tilgungsplanWidget::numKostenSlot()
747
{
748
	dirty = TRUE;
749
}
750
 
43 root 751
void tilgungsplanWidget::helpAbout()
752
{}
753
 
754
void tilgungsplanWidget::helpContents()
755
{}
756
 
757
void tilgungsplanWidget::helpIndex()
758
{}
759
 
760
void tilgungsplanWidget::editFind()
761
{}
762
 
763
void tilgungsplanWidget::editPaste()
764
{}
765
 
766
void tilgungsplanWidget::editCopy()
767
{}
768
 
769
void tilgungsplanWidget::editCut()
770
{}
771
 
772
void tilgungsplanWidget::editRedo()
773
{}
774
 
775
void tilgungsplanWidget::editUndo()
776
{}
777
 
778
void tilgungsplanWidget::fileExit()
44 andreas 779
{
60 andreas 780
	mamma->close();
44 andreas 781
}
782
 
43 root 783
void tilgungsplanWidget::filePrint()
784
{}
785
 
786
void tilgungsplanWidget::fileSaveAs()
60 andreas 787
{
788
QString fname = KFileDialog::getSaveFileName(QString("tilgpars.dat"), QString("*.dat"), this, QString("Tilgungsplan"));
789
QFile tmpFile;
43 root 790
 
60 andreas 791
	if (fname.isEmpty())
792
	   return;
793
 
794
	tmpFile.setName(fname);
795
 
796
	if (tmpFile.open(IO_ReadWrite | IO_Truncate) == FALSE)
797
	{
798
	   KMessageBox::error(0, QString("Could not open file for writing: %1").arg(tmpFile.errorString()));
799
	   return;
800
	}
801
 
802
	moveValues();
803
	write (tmpFile.handle(), &TpPars, sizeof(TPPARS));
804
	tmpFile.close();
805
}
806
 
43 root 807
void tilgungsplanWidget::fileSave()
60 andreas 808
{
809
QString hdir = QDir::homeDirPath ();
810
QFile tmpFile;
43 root 811
 
60 andreas 812
	if (!dirty)
813
	   return;
814
 
815
	// Zuletzt verwendete Maskenparameter in eine Datei schreiben.
816
	hdir.append("/.tilgpars.dat");
817
	tmpFile.setName(hdir);
818
 
819
	if (tmpFile.open(IO_ReadWrite | IO_Truncate) == FALSE)
820
	{
821
	   KMessageBox::error(0, QString("Could not open file for writing: %1").arg(tmpFile.errorString()));
822
	   return;
823
	}
824
 
825
	moveValues();
826
	write (tmpFile.handle(), &TpPars, sizeof(TPPARS));
827
	tmpFile.close();
828
	KMessageBox::information(this, i18n("Die Daten der Eingabemaske wurden erfolgreich gespeichert."));
829
}
830
 
43 root 831
void tilgungsplanWidget::fileOpen()
60 andreas 832
{
833
QString fname = KFileDialog::getOpenFileName(QString::null, QString("*.dat"), this, QString("Tilgungsplan"));
43 root 834
 
60 andreas 835
	if (fname.isEmpty())
836
	   return;
837
 
838
	readValues(fname.ascii());
839
}
840
 
43 root 841
void tilgungsplanWidget::fileNew()
842
{}
843
 
844
void tilgungsplanWidget::lbValutaSlot()
60 andreas 845
{
846
	dirty = TRUE;
847
}
43 root 848
 
849
void tilgungsplanWidget::cbAbschlSlot()
850
{
851
int item = comboBox_Abschl->currentItem();
852
char hv0[256];
853
 
854
	switch (item)
855
	{
856
           case 0: TpPars.abschlry = 0; break;
857
	   case 1: TpPars.abschlry = 1; break;
858
	   case 2: TpPars.abschlry = 3; break;
859
	   case 3: TpPars.abschlry = 6; break;
860
	   case 4: TpPars.abschlry = 12; break;
861
	   case 5: TpPars.abschlry = 41; break;
862
	   case 6: TpPars.abschlry = 43; break;
863
	   case 7: TpPars.abschlry = 46; break;
864
	   case 8: TpPars.abschlry = 47; break;
865
	   case 9: TpPars.abschlry = 48; break;
866
	   case 10: TpPars.abschlry = 52; break;
867
	   default:
868
	      sprintf (hv0, "Gewähltes Item: %d", item);
869
	      KMessageBox::information(0, i18n(hv0));
60 andreas 870
	}
871
 
872
	dirty = TRUE;
43 root 873
}
874
 
875
#include "tilgungsplanwidget.moc"
876