Subversion Repositories public

Rev

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