sozsoft-platform/configs/seeds/postgres/object/Hr_S_DevelopmentPlanSync.sql
2026-10-06 14:24:30 +03:00

17 lines
727 B
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

CREATE OR REPLACE PROCEDURE public."Hr_S_DevelopmentPlanSync"(
p_PlanId uuid
)
LANGUAGE plpgsql
AS $$
BEGIN
-- Eğitim aksiyonu, çalışan o eğitime "Katıldı" olarak işlendiyse kendiliğinden tamamlanır;
-- tamamlanan aksiyonun ilerlemesi her zaman %100'dür.
UPDATE "Hr_T_DevelopmentPlan" dp
SET "Status" = 'Completed', "Progress" = 100
WHERE dp."Id" = p_PlanId AND dp."IsDeleted" = FALSE AND dp."Status" <> 'Cancelled'
AND (dp."Status" = 'Completed' OR EXISTS (
SELECT 1 FROM "Hr_T_TrainingParticipant" tp
WHERE tp."TrainingId" = dp."TrainingId" AND tp."UserId" = dp."EmployeeId"
AND tp."AttendanceStatus" = 'Attended' AND tp."IsDeleted" = FALSE));
END
$$;