Starting working on non working days

This commit is contained in:
Aurélie Delhaie
2022-10-16 14:49:10 +02:00
parent 63d1ca329f
commit 6a44c4afd9
6 changed files with 83 additions and 125 deletions

View File

@@ -203,6 +203,8 @@ void MainWindow::compute_time() {
overtime += (w->total() - week_template->total()) + w->getTimeDeltaInHours();
}
}
late -= current_week->getTimeDeltaInHours();
overtime += - current_week->getTimeDeltaInHours();
ui->late_time_label->setText(Tools::double_to_string_time((late > 0.0) ? late : 0.0));
ui->overtime_time_label->setText(Tools::double_to_string_time((overtime > 0.0) ? overtime : 0.0));
}

View File

@@ -28,6 +28,9 @@ Day::~Day()
}
float Day::get_total() {
if (notWorking) {
return 0.0;
}
int sec = start.secsTo(end);
int minutes = sec / 60;
float breakTime = get_time_break();
@@ -48,6 +51,11 @@ void Day::set_validate(bool value) {
validate = value;
}
void Day::set_working(bool value)
{
this->notWorking = value;
}
void Day::setBreaks(QVector<BreakPoint*> breaks)
{
this->breaks = breaks;
@@ -119,6 +127,11 @@ bool Day::get_validate() {
return validate;
}
bool Day::not_working()
{
return notWorking;
}
float Day::get_time_break()
{
float result = 0;
@@ -133,6 +146,7 @@ void Day::update(Day *old)
this->start = old->start;
this->end = old->end;
this->validate = old->validate;
this->notWorking = old->notWorking;
foreach (BreakPoint *bp, breaks) {
delete bp;

View File

@@ -21,6 +21,7 @@ private:
QTime end;
QVector<BreakPoint*> breaks;
bool validate;
bool notWorking;
public:
Day();
@@ -30,12 +31,14 @@ public:
void set_start(QTime value);
void set_end(QTime value);
void set_validate(bool);
void set_working(bool);
void setBreaks(QVector<BreakPoint*>);
QTime get_start();
QTime get_end();
QVector<BreakPoint*> getBreaks();
bool get_validate();
bool not_working();
float get_time_break();
void update(Day *);
QJsonObject to_json();

View File

@@ -55,7 +55,7 @@ void SetDayDialog::accept()
}
void SetDayDialog::validate_and_accept() {
copy->set_validate(true);
copy->set_validate(!copy->not_working());
this->accept();
}