Zeiterfassung Update Monatsabschluss/Verrechnung
* Berechnungen aller Ü50/Ü100/M25 sowie Steuerfrei und Pflichtig * Transfer Mehrstunden auf Ü50/Ü100/M25 * Anpassungen der Exports LZs MehrstundenGL ÜGL Ü50,Ü100,M25 * Autoberechnung der anteiligen Mehrstunden * automatische Ü100 Rausrechnung laut gesetzlichen Vorgaben Bugfixes: * Start und Enddatum eines Mitarbeiters werden nun überall berücksichtigt. * Textuelle Bereinigungen * Umfangreiche Testscenarien Verechnung/Exports
This commit is contained in:
@@ -55,6 +55,9 @@ class TimerecordingBillingController extends mfBaseController
|
||||
{
|
||||
$r = $this->request;
|
||||
$month = $r->get("month");
|
||||
$monthstart = strtotime("01." . $month);
|
||||
$monthend = strtotime("last day of this month", $monthstart);
|
||||
|
||||
if (!$month) {
|
||||
$this->redirect("TimerecordingBilling");
|
||||
}
|
||||
@@ -64,16 +67,17 @@ class TimerecordingBillingController extends mfBaseController
|
||||
} else {
|
||||
$month = strtotime("01." . $month);
|
||||
$timerecordingsEmolyees = TimerecordingEmployeeModel::getAll();
|
||||
$timerecordingReport = new TimerecordingReportController();
|
||||
foreach ($timerecordingsEmolyees as $timerecordingsEmolyee) {
|
||||
if ($timerecordingsEmolyee->bmd_active == 0) continue;
|
||||
if ($timerecordingsEmolyee->bmd_active == 0 || $timerecordingsEmolyee->startdate > $monthend || ($timerecordingsEmolyee->enddate && $timerecordingsEmolyee->enddate < $monthstart)) continue;
|
||||
$user = new User($timerecordingsEmolyee->user_id);
|
||||
$employee_number = (string)$user->getFlag('employee_number');
|
||||
$timerecordingReport = new TimerecordingReportController();
|
||||
$timerecordings[$timerecordingsEmolyee->user_id]['user_id'] = $timerecordingsEmolyee->user_id;
|
||||
$timerecordings[$timerecordingsEmolyee->user_id]['user_name'] = $timerecordingsEmolyee->user->name;
|
||||
$timerecordings[$timerecordingsEmolyee->user_id]['employee_number'] = $employee_number;
|
||||
$timerecordings[$timerecordingsEmolyee->user_id]['data'] = $timerecordingReport->getTimerecordingsTimes('2', $month, $month, $month, $timerecordingsEmolyee->user_id, 0);
|
||||
}
|
||||
|
||||
$this->layout()->set("timerecordings", $timerecordings);
|
||||
$this->layout()->setTemplate("TimerecordingBilling/Detail");
|
||||
$this->layout()->set("month", date("m.Y", $month));
|
||||
@@ -103,6 +107,9 @@ class TimerecordingBillingController extends mfBaseController
|
||||
case "completemonth":
|
||||
$return = $this->completemonth($month);
|
||||
break;
|
||||
case "abortmonth":
|
||||
$return = $this->abortmonth($month);
|
||||
break;
|
||||
case "saveovertime":
|
||||
$return = $this->saveovertime();
|
||||
break;
|
||||
@@ -121,7 +128,6 @@ class TimerecordingBillingController extends mfBaseController
|
||||
protected function addAction()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function editAction()
|
||||
@@ -186,7 +192,6 @@ class TimerecordingBillingController extends mfBaseController
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
protected function deleteAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
@@ -195,7 +200,6 @@ class TimerecordingBillingController extends mfBaseController
|
||||
$this->layout()->setFlash("Timerecording nicht gefunden.", "error");
|
||||
$this->redirect("TimerecordingBilling");
|
||||
}
|
||||
|
||||
$timerecordingbillings->delete();
|
||||
$this->redirect("TimerecordingBilling");
|
||||
}
|
||||
@@ -229,6 +233,7 @@ class TimerecordingBillingController extends mfBaseController
|
||||
$employeetypesbmd = TimerecordingEmployeeModel::$employeetypesbmd;
|
||||
$employee_type = $employeetypesbmd[$timerecordingBillingEmployee->timerecordingEmployee->type];
|
||||
$overtimebase = 0;
|
||||
$plushoursbase = 0;
|
||||
if ($nlz == 0) {
|
||||
$hours = $timerecordingBillingEmployee->ishours / 3600;
|
||||
$hours = round($hours, 2);
|
||||
@@ -237,20 +242,62 @@ class TimerecordingBillingController extends mfBaseController
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, $employee_type, $hours, "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
}
|
||||
if ($timerecordingBillingEmployee->plushours25 > 0) {
|
||||
$plushours25 = $timerecordingBillingEmployee->plushours25 / 3600;
|
||||
$plushours25 = round($plushours25, 2);
|
||||
$plushoursbase = $plushoursbase + $plushours25;
|
||||
$plushours25 = str_replace(".", ",", $plushours25);
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3050", $plushours25, "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
}
|
||||
if ($timerecordingBillingEmployee->overtime50free > 0) {
|
||||
$overtime50free = $timerecordingBillingEmployee->overtime50free / 3600;
|
||||
$overtime50free = round($overtime50free, 2);
|
||||
$overtimebase = $overtimebase + $overtime50free;
|
||||
$overtime50free = str_replace(".", ",", $overtime50free);
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3110", $overtime50free, "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
|
||||
if ($timerecordingBillingEmployee->overtime50free > 64800) {
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3110", "18", "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
$diffsum = $timerecordingBillingEmployee->overtime50free - 64800;
|
||||
$diffsum = $diffsum / 3600;
|
||||
$diffsum = round($diffsum, 2);
|
||||
$diffsum = str_replace(".", ",", $diffsum);
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3120", $diffsum, "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
} else {
|
||||
$overtime50free = str_replace(".", ",", $overtime50free);
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3110", $overtime50free, "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if ($timerecordingBillingEmployee->overtime100free > 0) {
|
||||
$overtime100free = $timerecordingBillingEmployee->overtime100free / 3600;
|
||||
$overtime100free = round($overtime100free, 2);
|
||||
$overtimebase = $overtimebase + $overtime100free;
|
||||
$overtime100free = str_replace(".", ",", $overtime100free);
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3160", $overtime100free, "", "", "", "", "", ""];
|
||||
if ($timerecordingBillingEmployee->overtime100free > 64800) {
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3160", "18", "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
$diffsum = $timerecordingBillingEmployee->overtime100free - 64800;
|
||||
$diffsum = $diffsum / 3600;
|
||||
$diffsum = round($diffsum, 2);
|
||||
$diffsum = str_replace(".", ",", $diffsum);
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3150", $diffsum, "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
} else {
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3160", $overtime100free, "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
}
|
||||
|
||||
}
|
||||
if ($timerecordingBillingEmployee->overtime100 > 0) {
|
||||
$overtime100 = $timerecordingBillingEmployee->overtime100 / 3600;
|
||||
$overtime100 = round($overtime100, 2);
|
||||
$overtimebase = $overtimebase + $overtime100;
|
||||
$overtime100free = str_replace(".", ",", $overtime100);
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3150", $overtime100, "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
}
|
||||
if ($overtimebase > 0) {
|
||||
@@ -258,6 +305,11 @@ class TimerecordingBillingController extends mfBaseController
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3100", $overtimebase, "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
}
|
||||
if ($plushoursbase > 0) {
|
||||
$plushoursbase = str_replace(".", ",", $plushoursbase);
|
||||
$bodyarray = [$monthbmd, "1", $employee_number, "3000", $plushoursbase, "", "", "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
}
|
||||
|
||||
if ($timerecordingBillingEmployee->homeoffice > 0) {
|
||||
$homeoffice = $timerecordingBillingEmployee->homeoffice;
|
||||
@@ -273,8 +325,6 @@ class TimerecordingBillingController extends mfBaseController
|
||||
|
||||
$bodyarray = [$companybmd, $employee_number, 1, $nlztime['categoryshort'], $nlztime['catExtended'], "3", $nlztime['start'], $nlztime['end'], $nlztime['time'], $nlztime['pay']];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,12 +333,8 @@ class TimerecordingBillingController extends mfBaseController
|
||||
$dietsum = str_replace(".", ",", $dietsum);
|
||||
$bodyarray = [$monthbmd, $companybmd, $employee_number, "2500", "", "", $dietsum, "", "", "", ""];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fclose($file);
|
||||
exit;
|
||||
}
|
||||
@@ -317,13 +363,11 @@ class TimerecordingBillingController extends mfBaseController
|
||||
//last of month
|
||||
$monthend = date("Y-m-d", strtotime("last day of this month", $month));
|
||||
$monthend = strtotime($monthend . " 23:59:59");
|
||||
|
||||
|
||||
$monthbmd = date("n", $month);
|
||||
$companybmd = "1";
|
||||
$timerecordingsEmolyees = TimerecordingEmployeeModel::getAll();
|
||||
foreach ($timerecordingsEmolyees as $timerecordingsEmolyee) {
|
||||
if ($timerecordingsEmolyee->bmd_active == 0) continue;
|
||||
if ($timerecordingsEmolyee->bmd_active == 0 || $timerecordingsEmolyee->startdate > $monthend || ($timerecordingsEmolyee->enddate && $timerecordingsEmolyee->enddate < $month)) continue;
|
||||
$user = new User($timerecordingsEmolyee->user_id);
|
||||
$employee_number = (string)$user->getFlag('employee_number');
|
||||
$employeetypesbmd = TimerecordingEmployeeModel::$employeetypesbmd;
|
||||
@@ -332,9 +376,11 @@ class TimerecordingBillingController extends mfBaseController
|
||||
$timerecording = $timerecordingReport->getTimerecordingsTimes('2', $month, $month, $month, $timerecordingsEmolyee->user_id, 0);
|
||||
if ($export == 0) {
|
||||
$reponse[$employee_number]['employee_id'] = $timerecordingsEmolyee->id;
|
||||
$reponse[$employee_number]['user_id'] = $timerecordingsEmolyee->user_id;
|
||||
$reponse[$employee_number]['homeoffice'] = $timerecording['time']['homeoffice'];
|
||||
$reponse[$employee_number]['istimeall'] = $timerecording['time']['isorder'];
|
||||
$reponse[$employee_number]['musttime'] = $timerecording['time']['mustorder'];
|
||||
$reponse[$employee_number]['overtimes'] = $timerecording['time']['overtimes'];
|
||||
}
|
||||
|
||||
foreach ($timerecording['time']['isclean'] as $key => $value) {
|
||||
@@ -446,21 +492,63 @@ class TimerecordingBillingController extends mfBaseController
|
||||
protected function completemonth($month)
|
||||
{
|
||||
$id = $this->saveAction();
|
||||
$user = new User($timerecordingsEmolyee->user_id);
|
||||
$employee_number = (string)$user->getFlag('employee_number');
|
||||
$enddate = strtotime("01." . $month);
|
||||
$enddate = strtotime("last day of this month", $enddate);
|
||||
$enddate = strtotime("23:59:59", $enddate);
|
||||
|
||||
$timerecordings = $this->generateBmdExport($month, 0, 0);
|
||||
$timerecordingworkinghours = TimerecordingEmployeeWorkingHourModel::getAllArray();
|
||||
|
||||
foreach ($timerecordings as $employeenumber => $timerecording) {
|
||||
|
||||
$timerecordingworkinghour = $timerecordingworkinghours[$timerecording['user_id']]['secondcounter'];
|
||||
if ($timerecordingworkinghour == 138600) {
|
||||
$maxplushours = 23400;
|
||||
} else {
|
||||
$maxplushours = (138600 - $timerecordingworkinghour) * 4.33;
|
||||
$maxplushours = round($maxplushours, 0);
|
||||
$maxplushours = $maxplushours + 23400;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['timerecordingBilling_id'] = $id;
|
||||
$data['timerecordingEmployee_id'] = $timerecording['employee_id'];
|
||||
$data['musthours'] = $timerecording['musttime'];
|
||||
$data['overtime50'] = $timerecording['overtimes']['O50pfl'];
|
||||
$data['overtime50free'] = $timerecording['overtimes']['O50free'];
|
||||
$data['overtime100'] = $timerecording['overtimes']['O100pfl'];
|
||||
$data['overtime100free'] = $timerecording['overtimes']['O100free'];
|
||||
$data['transfer_plushours'] = $timerecording['overtimes']['Osum'];
|
||||
|
||||
$diff = $timerecording['istimeall'] - $timerecording['musttime'];
|
||||
|
||||
if ($diff > $maxplushours) {
|
||||
$data['overtime50free'] = $data['overtime50free'] + ($diff - $maxplushours);
|
||||
$data['transfer_plushours'] = $data['transfer_plushours'] + ($diff - $maxplushours);
|
||||
}
|
||||
|
||||
|
||||
if ($data['transfer_plushours'] > 0) {
|
||||
$timerecordingEmployee = new TimerecordingEmployee($timerecording['employee_id']);
|
||||
$dataemployee = [];
|
||||
$dataemployee['plushours_now'] = $timerecordingEmployee->plushours_now - $data['transfer_plushours'];
|
||||
$dataemployee['plushours'] = $timerecordingEmployee->plushours - $data['transfer_plushours'];
|
||||
$timerecordingEmployee->update($dataemployee);
|
||||
$timerecordingEmployee->save();
|
||||
}
|
||||
$timerecordingController = new TimerecordingController();
|
||||
$plushours = $timerecordingController->updatePlushours($timerecording['user_id'], $enddate);
|
||||
$data['plushours_all'] = $plushours['plushours'];
|
||||
|
||||
|
||||
if ($timerecording['istime']) {
|
||||
$data['ishours'] = $timerecording['istime'];
|
||||
} else {
|
||||
$data['ishours'] = 0;
|
||||
}
|
||||
$data['ishourssum'] = $timerecording['istimeall'];
|
||||
|
||||
|
||||
$data['diet'] = $timerecording['diet'];
|
||||
if ($timerecording['nlz']) {
|
||||
$data['nlz_detail'] = json_encode($timerecording['nlz']);
|
||||
@@ -486,6 +574,28 @@ class TimerecordingBillingController extends mfBaseController
|
||||
die();
|
||||
}
|
||||
|
||||
protected function abortmonth($month)
|
||||
{
|
||||
$timerecordingBilling = TimerecordingBillingModel::search(["month" => $month]);
|
||||
$timerecordingBillingEmployees = TimerecordingBillingEmployeeModel::search(["timerecordingBilling_id" => $timerecordingBilling[0]->id]);
|
||||
|
||||
foreach ($timerecordingBillingEmployees as $timerecordingBillingEmployee) {
|
||||
$timerecordingEmployee = new TimerecordingEmployee($timerecordingBillingEmployee->timerecordingEmployee->id);
|
||||
$dataemployee = [];
|
||||
$dataemployee['plushours_now'] = $timerecordingEmployee->plushours_now + $timerecordingBillingEmployee->transfer_plushours;
|
||||
$dataemployee['plushours'] = $timerecordingEmployee->plushours + $timerecordingBillingEmployee->transfer_plushours;
|
||||
$dataemployee['overtime_now'] = $timerecordingEmployee->overtime_now + $timerecordingBillingEmployee->transfer_overtime;
|
||||
$dataemployee['overtime'] = $timerecordingEmployee->overtime + $timerecordingBillingEmployee->transfer_overtime;
|
||||
$timerecordingEmployee->update($dataemployee);
|
||||
$timerecordingEmployee->save();
|
||||
}
|
||||
$timerecordingBilling[0]->delete();
|
||||
$result['state'] = "success";
|
||||
echo json_encode($result);
|
||||
die();
|
||||
|
||||
}
|
||||
|
||||
protected function saveovertime()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
@@ -513,6 +623,7 @@ class TimerecordingBillingController extends mfBaseController
|
||||
|
||||
}
|
||||
if ($data) {
|
||||
$data['transfer_overtime'] = $timerecordingbillingsemployee->transfer_overtime + $sum;
|
||||
$timerecordingbillingsemployee->update($data);
|
||||
$timerecordingbillingsemployee->save();
|
||||
$timerecordingbillingsemployee->timerecordingEmployee->id;
|
||||
@@ -526,6 +637,10 @@ class TimerecordingBillingController extends mfBaseController
|
||||
} else if ($type == "difference") {
|
||||
$sum = 0;
|
||||
$data = [];
|
||||
if ($this->request->plushours25) {
|
||||
$data['plushours25'] = $timerecordingbillingsemployee->plushours25 + $this->request->plushours25 * 3600;
|
||||
$sum += $this->request->plushours25 * 3600;
|
||||
}
|
||||
if ($this->request->overtime50) {
|
||||
$data['overtime50free'] = $timerecordingbillingsemployee->overtime50free + $this->request->overtime50 * 3600;
|
||||
$sum += $this->request->overtime50 * 3600;
|
||||
@@ -542,12 +657,18 @@ class TimerecordingBillingController extends mfBaseController
|
||||
$sum += $this->request->overtimebpa * 3600;
|
||||
$timerecordingEmployee->update($dataemployee);
|
||||
$timerecordingEmployee->save();
|
||||
|
||||
}
|
||||
if ($sum > 0) {
|
||||
$data['ishourssum'] = $timerecordingbillingsemployee->ishourssum - $sum;
|
||||
$data['transfer_plushours'] = $timerecordingbillingsemployee->transfer_plushours + $sum;
|
||||
$data['plushours_all'] = $timerecordingbillingsemployee->plushours_all - $sum;
|
||||
$timerecordingbillingsemployee->update($data);
|
||||
$timerecordingbillingsemployee->save();
|
||||
$timerecordingEmployee = new TimerecordingEmployee($timerecordingbillingsemployee->timerecordingEmployee->id);
|
||||
$dataemployee = [];
|
||||
$dataemployee['plushours_now'] = $timerecordingEmployee->plushours_now - $sum;
|
||||
$dataemployee['plushours'] = $timerecordingEmployee->plushours - $sum;
|
||||
$timerecordingEmployee->update($dataemployee);
|
||||
$timerecordingEmployee->save();
|
||||
}
|
||||
}
|
||||
$response['state'] = "success";
|
||||
|
||||
Reference in New Issue
Block a user