From 4148500c61c74b602c22a208b4671e0a9f02ffb2 Mon Sep 17 00:00:00 2001
From: carlosjr <carlosjr@verdnatura.es>
Date: Wed, 30 Jun 2021 14:05:16 +0200
Subject: [PATCH] workers without active contract no longer set calendar and
 timeControl at fault

---
 modules/worker/front/calendar/index.js     | 6 ++++--
 modules/worker/front/time-control/index.js | 7 ++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js
index d60fa06471..014a35b635 100644
--- a/modules/worker/front/calendar/index.js
+++ b/modules/worker/front/calendar/index.js
@@ -91,8 +91,10 @@ class Controller extends Section {
     }
 
     getActiveContract() {
-        this.$http.get(`Workers/${this.worker.id}/activeContract`)
-            .then(res => this.businessId = res.data.businessFk);
+        this.$http.get(`Workers/${this.worker.id}/activeContract`).then(res => {
+            if (res.data)
+                this.businessId = res.data.businessFk;
+        });
     }
 
     getContractHolidays() {
diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js
index b980243c97..2631c82d24 100644
--- a/modules/worker/front/time-control/index.js
+++ b/modules/worker/front/time-control/index.js
@@ -90,7 +90,10 @@ class Controller extends Section {
 
     getActiveContract() {
         return this.$http.get(`Workers/${this.worker.id}/activeContract`)
-            .then(res => this.businessId = res.data.businessFk);
+            .then(res => {
+                if (res.data)
+                    this.businessId = res.data.businessFk;
+            });
     }
 
     fetchHours() {
@@ -111,6 +114,8 @@ class Controller extends Section {
     }
 
     getAbsences() {
+        if (!this.businessId) return;
+
         const fullYear = this.started.getFullYear();
         let params = {
             businessFk: this.businessId,