====== pears.SDSRequired ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."SDSRequired"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "COID" char(20),in "PID" char(20) )
returns smallint
not deterministic
begin
if "WPKMaintainGetSwitchValue"('IR35SDSON','','L') = 'N' then return 0
end if;
-- if exists (select 1 from company where PrivateSector = 1 and companyid = COID) then return 0
-- end if;
if exists(select 1 from "pay_employee" where "personid" = "PID" and "taxmethod" = 1) then return 0
end if;
if exists(select 1 from "pay_employee" where "personid" = "PID" and "HMRCEngagementDetail" = 'F') then return 0
end if;
if exists(select 1 from "companySDS" where "personid" = "PID" and "companyid" = "COID") then return 0
end if;
return 1
end