diff --git a/be/app/Services/Karat/Api.php b/be/app/Services/Karat/Api.php index dce8a46..7419e19 100644 --- a/be/app/Services/Karat/Api.php +++ b/be/app/Services/Karat/Api.php @@ -68,9 +68,11 @@ class Api public static function setTimesheet($timesheet) { + echo 'Setting timesheet for project ' . $timesheet->subtask->mastertask->project->code . PHP_EOL; + $body = [ 'command' => 'TM_SET_vykaz', - 'zakazka' => $timesheet->subtask->project->code, + 'zakazka' => $timesheet->subtask->mastertask->project->code, 'zdroj' => $timesheet->user->code, 'hodin' => $timesheet->time, 'datum' => $timesheet->created_at->format('Y-m-d'), diff --git a/be/app/Services/Karat/KaratService.php b/be/app/Services/Karat/KaratService.php index b2b5e49..f34b04c 100644 --- a/be/app/Services/Karat/KaratService.php +++ b/be/app/Services/Karat/KaratService.php @@ -134,6 +134,9 @@ class KaratService $notSyncedTimesheets = Timesheet::whereNull('synced_to_karat')->get(); $notSyncedTimesheets->each(function ($timesheet) { + if (!$timesheet->subtask || !$timesheet->subtask->mastertask->project) + return false; + $this->syncTimesheet($timesheet); }); } @@ -141,7 +144,7 @@ class KaratService private function syncTimesheet(Timesheet $timesheet) { $this->api->setTimesheet($timesheet); - $timesheet->synced_to_karat = true; + $timesheet->synced_to_karat = Carbon::now(); $timesheet->save(); }