implement latest changes to employee payroll process
- Add ContractDaysWeek - Add Sickness Days to employee export sheet - Add Gesundheitsbonus value per employee - Additional fixes
This commit is contained in:
@@ -211,7 +211,8 @@ CREATE TABLE public."DyflexisEmployee" (
|
||||
"contractHoursWeek" double precision NOT NULL,
|
||||
"contractSalaryHour" double precision NOT NULL,
|
||||
"contractTypeName" text,
|
||||
"internalId" uuid DEFAULT gen_random_uuid() NOT NULL
|
||||
"internalId" uuid DEFAULT gen_random_uuid() NOT NULL,
|
||||
"contractDaysWeek" integer DEFAULT 0 NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -591,6 +592,23 @@ CREATE TABLE public."Tour" (
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: TourFile; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE public."TourFile" (
|
||||
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
||||
"tourId" text NOT NULL,
|
||||
"ticketId" text NOT NULL,
|
||||
"storagePath" text NOT NULL,
|
||||
"originalFilename" text NOT NULL,
|
||||
"mimeType" text NOT NULL,
|
||||
"fileSizeBytes" integer NOT NULL,
|
||||
"dlUploadStatus" text DEFAULT 'pending'::text NOT NULL,
|
||||
"createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: TourSource; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1025,6 +1043,14 @@ ALTER TABLE ONLY public."Ticket"
|
||||
ADD CONSTRAINT "Ticket_pkey" PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: TourFile TourFile_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."TourFile"
|
||||
ADD CONSTRAINT "TourFile_pkey" PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: TourSource TourSource_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1104,6 +1130,13 @@ ALTER TABLE ONLY public._prisma_migrations
|
||||
CREATE UNIQUE INDEX "CostType_id_key" ON public."CostType" USING btree (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: TourFile_tourId_ticketId_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX "TourFile_tourId_ticketId_idx" ON public."TourFile" USING btree ("tourId", "ticketId");
|
||||
|
||||
|
||||
--
|
||||
-- Name: Tour_operationId_key; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
@@ -5,6 +5,7 @@ SELECT
|
||||
de.surname,
|
||||
de."contractStart",
|
||||
de."contractEnd",
|
||||
de."contractDaysWeek",
|
||||
de."contractHoursWeek",
|
||||
de."contractSalaryHour",
|
||||
de."contractTypeName",
|
||||
@@ -119,6 +120,25 @@ SELECT
|
||||
COUNT(CASE WHEN was_punctual THEN 1 END) AS punctual_days
|
||||
FROM daily_comparison;
|
||||
|
||||
-- name: IsEmployeesDepartmentNotLeitstelle :one
|
||||
SELECT COALESCE(
|
||||
(
|
||||
(
|
||||
bool_or(department LIKE '%KTW%')
|
||||
OR bool_or(department LIKE '%BTW%')
|
||||
OR bool_or(department LIKE '%TSW%')
|
||||
)
|
||||
AND
|
||||
bool_and(department <> 'Leitstelle')
|
||||
),
|
||||
false
|
||||
)::bool as meets_requirements
|
||||
FROM "PlannedTime"
|
||||
WHERE
|
||||
"userId"::int = @employee_id::bigint
|
||||
AND "startDate" BETWEEN @start_date AND @end_date
|
||||
AND department IS NOT NULL;
|
||||
|
||||
-- name: IsEmployeesDepartmentKTW :one
|
||||
SELECT COALESCE(
|
||||
(
|
||||
@@ -152,16 +172,7 @@ WITH ToursInPeriod AS (
|
||||
CASE
|
||||
WHEN "occupiedKm" <= 30 THEN 1.0
|
||||
ELSE ROUND("occupiedKm" / 30.0)
|
||||
END AS tour_value,
|
||||
CASE
|
||||
WHEN EXTRACT(ISODOW FROM "startDate") = 6 AND "occupiedKm" <= 30 THEN 0.5
|
||||
ELSE 0.0
|
||||
END AS weekend_bonus,
|
||||
"infectionName",
|
||||
CASE
|
||||
WHEN "infectionName" = 'Covid-19' THEN 0.5
|
||||
ELSE 0.0
|
||||
END AS infection_bonus
|
||||
END AS tour_value
|
||||
FROM
|
||||
"Tour"
|
||||
WHERE
|
||||
@@ -193,7 +204,7 @@ WITH ToursInPeriod AS (
|
||||
DailyCounts AS (
|
||||
SELECT
|
||||
day,
|
||||
SUM(tour_value) + SUM(weekend_bonus) + SUM(infection_bonus) AS tour_amount
|
||||
SUM(tour_value) AS tour_amount
|
||||
FROM
|
||||
ToursInPeriod
|
||||
GROUP BY
|
||||
@@ -214,4 +225,15 @@ TourenGeld AS (
|
||||
)
|
||||
SELECT
|
||||
COALESCE(tourengeld, 0.0)
|
||||
FROM TourenGeld;
|
||||
FROM TourenGeld;
|
||||
|
||||
-- name: ListSickdaysForEmployee :many
|
||||
SELECT
|
||||
"start",
|
||||
"end",
|
||||
"days",
|
||||
locked
|
||||
FROM "Sickdays"
|
||||
WHERE
|
||||
"employeeId" = @employee_id
|
||||
ORDER BY start asc;
|
||||
Reference in New Issue
Block a user