diff --git a/cbooking.cpp b/cbooking.cpp index 263f6e1..1119ce8 100644 --- a/cbooking.cpp +++ b/cbooking.cpp @@ -165,7 +165,7 @@ qint32 cBooking::pauseSecs() return(p1); } - if(w < 21600) + if(w <= 21600) return(0); if(p < 1800) @@ -519,6 +519,7 @@ void cBookingList::recalculate(const QDate& date) bFirst = true; qint32 ueberstunden = 0; + qint32 correction = 0; for(;i != end(); i++) { @@ -534,14 +535,20 @@ void cBookingList::recalculate(const QDate& date) (*i)->setPrevDiff(0); } else - (*i)->setPrevDiff((*(i-1))->currentDiff()-ueberstunden); + (*i)->setPrevDiff((*(i-1))->currentDiff()-ueberstunden+correction); cMonthlyBooking* lpMonthlyBooking = m_lpMonthlyBookingList->find((*i)->date()); if(lpMonthlyBooking) + { + correction = lpMonthlyBooking->correction(); ueberstunden = lpMonthlyBooking->ueberstunden(); + } else + { + correction = 0; ueberstunden = 0; + } oldVacation = (*i)->vacation(); diff --git a/cmainwindow.cpp b/cmainwindow.cpp index 33a5b39..bed56db 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -180,6 +180,7 @@ void cMainWindow::openDB() query.prepare("CREATE TABLE monthlyBooking " "( " " datum DATE PRIMARY KEY UNIQUE, " + " correction INTEGER, " " ueberstunden INTEGER, " " salery BLOB, " " timesheet BLOB " diff --git a/cmonthlybooking.cpp b/cmonthlybooking.cpp index 070335f..68a5533 100644 --- a/cmonthlybooking.cpp +++ b/cmonthlybooking.cpp @@ -8,6 +8,7 @@ cMonthlyBooking::cMonthlyBooking(const QDate& date, QObject *parent) : QObject(parent), m_date(date), + m_correction(0), m_ueberstunden(0) { } @@ -17,6 +18,16 @@ QDate cMonthlyBooking::date() return(m_date); } +void cMonthlyBooking::setCorrection(qint32 correction) +{ + m_correction = correction; +} + +qint32 cMonthlyBooking::correction() +{ + return(m_correction); +} + void cMonthlyBooking::setUeberstunden(qint32 ueberstunden) { m_ueberstunden = ueberstunden; @@ -62,13 +73,15 @@ bool cMonthlyBooking::save() if(query.next()) query.prepare("UPDATE monthlyBooking " - "SET ueberstunden=:ueberstunden, " + "SET correction=:correction," + " ueberstunden=:ueberstunden, " " salery=:salery, " " timesheet=:timesheet " "WHERE datum=:datum;"); else query.prepare("INSERT INTO monthlyBooking ( " " datum, " + " correction, " " ueberstunden, " " salery, " " timesheet " @@ -76,12 +89,14 @@ bool cMonthlyBooking::save() "VALUES " " ( " " :datum, " + " :correction, " " :ueberstunden, " " :salery, " " :timesheet " " );"); query.bindValue(":datum", date()); + query.bindValue(":correction", correction()); query.bindValue(":ueberstunden", ueberstunden()); query.bindValue(":salery", salery()); query.bindValue(":timesheet", timesheet()); @@ -101,6 +116,7 @@ bool cMonthlyBookingList::load() QSqlQuery query; query.prepare("SELECT datum, " + " correction, " " ueberstunden, " " salery, " " timesheet " @@ -119,6 +135,7 @@ bool cMonthlyBookingList::load() if(lpBooking) { + lpBooking->setCorrection(query.value("correction").toInt()); lpBooking->setUeberstunden(query.value("ueberstunden").toInt()); lpBooking->setSalery(query.value("salery").toByteArray()); lpBooking->setTimesheet(query.value("timesheet").toByteArray()); diff --git a/cmonthlybooking.h b/cmonthlybooking.h index af8c020..dee66d7 100644 --- a/cmonthlybooking.h +++ b/cmonthlybooking.h @@ -19,6 +19,9 @@ public: QDate date(); + void setCorrection(qint32 correction); + qint32 correction(); + void setUeberstunden(qint32 ueberstunden); qint32 ueberstunden(); @@ -32,6 +35,7 @@ public: private: QDate m_date; + qint32 m_correction; qint32 m_ueberstunden; QByteArray m_salery; QByteArray m_timesheet; diff --git a/cmonthlyview.cpp b/cmonthlyview.cpp index ea10658..c079e53 100644 --- a/cmonthlyview.cpp +++ b/cmonthlyview.cpp @@ -28,8 +28,11 @@ cMonthlyView::cMonthlyView(const QDate& date, const QMap code, { ui->setupUi(this); + QRegExp rxNeg("-?(?:\\d\\d\\d):(?:[0-5]\\d):(?:[0-5]\\d)"); QRegExp rx("(?:\\d\\d\\d):(?:[0-5]\\d):(?:[0-5]\\d)"); m_lpValidator = new QRegExpValidator(rx, this); + m_lpValidatorNeg = new QRegExpValidator(rxNeg, this); + ui->m_lpCorrection->setValidator(m_lpValidatorNeg); ui->m_lpUeberstunden->setValidator(m_lpValidator); m_lpMonthlyListModel = new QStandardItemModel(0, 1); @@ -58,6 +61,7 @@ cMonthlyView::cMonthlyView(const QDate& date, const QMap code, connect(ui->m_lpNextMonth, &QToolButton::clicked, this, &cMonthlyView::onNextMonth); connect(ui->m_lpMonth, &QDateEdit::dateChanged, this, &cMonthlyView::onDateChanged); + connect(ui->m_lpCorrection, &QLineEdit::textChanged, this, &cMonthlyView::onCorrectionChanged); connect(ui->m_lpUeberstunden, &QLineEdit::textChanged, this, &cMonthlyView::onUeberstundenChanged); connect(ui->m_lpTimesheetView, &QPushButton::clicked, this, &cMonthlyView::onTimesheetView); @@ -215,6 +219,7 @@ void cMonthlyView::setDate(const QDate& date) ui->m_lpShouldLabel->setText(QString(tr("SOLL Arbeitszeit (%1):")).arg(date.toString("MMMM yyyy"))); ui->m_lpIsLabel->setText(QString(tr("IST Arbeitszeit (%1):")).arg(date.toString("MMMM yyyy"))); ui->m_lpResturlaubLabel->setText(QString(tr("Resturlaub %1:")).arg(date.addMonths(-1).toString("MMMM yyyy"))); + ui->m_lpCorrection->setText(secs2String(m_lpMonthlyBooking->correction(), 3)); ui->m_lpUeberstunden->setText(secs2String(m_lpMonthlyBooking->ueberstunden(), 3)); updatePDF(); @@ -341,11 +346,23 @@ void cMonthlyView::onDateChanged(const QDate& date) setDate(date); } +void cMonthlyView::onCorrectionChanged(const QString& string) +{ + m_lpMonthlyBooking->setCorrection(string2Secs(string)); + m_lpMonthlyBooking->save(); + + m_lpBookingList->recalculate(); + + displaySummary(); +} + void cMonthlyView::onUeberstundenChanged(const QString& string) { m_lpMonthlyBooking->setUeberstunden(string2Secs(string)); m_lpMonthlyBooking->save(); + m_lpBookingList->recalculate(); + displaySummary(); } @@ -600,7 +617,7 @@ void cMonthlyView::displaySummary() ui->m_lpShould->setText(secs2String(soll)); ui->m_lpIs->setText(secs2String(ist)); ui->m_lpSaldo->setText(secs2String(ist-soll)); - ui->m_lpUebertragNaechsterMonat->setText(secs2String(lpFirstBooking->prevDiff()+ist-soll-m_lpMonthlyBooking->ueberstunden())); + ui->m_lpUebertragNaechsterMonat->setText(secs2String(lpFirstBooking->prevDiff()+ist-soll-m_lpMonthlyBooking->ueberstunden()+m_lpMonthlyBooking->correction())); ui->m_lpResturlaub->setText(QString::number(lpFirstBooking->vacation())); ui->m_lpUebertragUrlaub->setText(QString::number(lpFirstBooking->vacation()-u)); diff --git a/cmonthlyview.h b/cmonthlyview.h index f5bcd43..1b895b3 100644 --- a/cmonthlyview.h +++ b/cmonthlyview.h @@ -40,6 +40,7 @@ private: QDate m_date; cMonthlyBooking* m_lpMonthlyBooking; QRegExpValidator* m_lpValidator; + QRegExpValidator* m_lpValidatorNeg; QStringList m_temporaryFileList; void setBackground(const int day, const QString& code); @@ -55,6 +56,7 @@ private slots: void onTimeChanged(const int day, const int field, const QTime& time); void onTextChanged(const int day, const int field, const QString& text); void onDateChanged(const QDate& date); + void onCorrectionChanged(const QString& string); void onUeberstundenChanged(const QString& string); void onTimesheetView(); void onTimesheetDownload(); diff --git a/cmonthlyview.ui b/cmonthlyview.ui index 42ee877..efb7ed9 100644 --- a/cmonthlyview.ui +++ b/cmonthlyview.ui @@ -97,7 +97,7 @@ 0 0 861 - 263 + 237 @@ -117,26 +117,6 @@ - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - @@ -147,23 +127,6 @@ - - - - Krank - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - @@ -171,16 +134,6 @@ - - - - Resturlaub: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - @@ -197,8 +150,8 @@ - - + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -207,23 +160,6 @@ - - - - - - - - - - - ausbezahlte Überstunden: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - @@ -234,7 +170,95 @@ - + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + Übertrag: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + Urlaub + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + Krank + + + + @@ -333,7 +357,17 @@ - + + + + Übertrag nächster Monat: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + Saldo: @@ -343,8 +377,15 @@ - - + + + + Sonderurlaub + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -353,13 +394,6 @@ - - - - Training - - - @@ -367,13 +401,6 @@ - - - - Urlaub - - - @@ -390,7 +417,20 @@ - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -400,74 +440,10 @@ - - - - Sonderurlaub - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - + - Übertrag nächster Monat: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Übertrag: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - - - - Übertrag Urlaub: + ausbezahlte Überstunden: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -484,18 +460,59 @@ - - - - Qt::Horizontal + + + + Training - - - 40 - 20 - + + + + + + - + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + Resturlaub: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Übertrag Urlaub: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Correction: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + diff --git a/common.cpp b/common.cpp index c3f1a6a..51886c6 100644 --- a/common.cpp +++ b/common.cpp @@ -28,11 +28,18 @@ QString secs2String(const qint32& secs, qint8 leading) qint32 string2Secs(const QString& string) { + qint32 secs; QStringList list = string.split(":"); qint32 h = list[0].toInt(); qint32 m = list[1].toInt(); qint32 s = list[2].toInt(); - return(h*3600+m*60+s); + + secs = h*3600+m*60+s; + + if(string[0] == "-") + secs = -secs; + + return(secs); } qint32 time2Secs(const QTime& time)