pears.EntityRateFilter
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
Original SQL
CREATE FUNCTION "pears"."EntityRateFilter"( IN "FilterNo" SMALLINT,IN "WeekNo" INTEGER,IN "VacID" CHAR(20),IN "PersID" CHAR(20),IN "PlacID" CHAR(20),IN "ShiftID" CHAR(20) ) RETURNS CHAR(4) BEGIN DECLARE "rv" CHAR(4); DECLARE "qual" INTEGER; -- Used to filter the rate tables -- Return null if specified FilterNo is not applicable to this entity SET "rv" = NULL; IF "filterno" = 1 THEN -- AWR IF "weekno" IS NULL THEN RETURN NULL -- Filter only applied in timesheet entry END IF; SET "qual" = "AWRQualified"(NULL,"WeekNo","VacID","PersID","PlacID","ShiftID"); IF "qual" IS NULL THEN RETURN NULL ELSE IF "qual" = 0 THEN RETURN 'N' ELSE RETURN 'Y' END IF END IF END IF; IF "filterno" = 2 THEN -- Ltd Co. IF "trim"("isnull"("persid",'')) <> '' THEN -- Note empty parameters cannot be relied upon to be null IF EXISTS(SELECT * FROM "pay_employee" WHERE "personid" = "persid" AND "taxmethod" = 2) THEN SET "rv" = 'Y' ELSE SET "rv" = 'N' -- If persid not supplied then leave rv as NULL for don't know END IF END IF END IF; IF "filterno" = 3 THEN RETURN "EntitySpeciality"("VacID","PersID","PlacID","ShiftID") END IF; RETURN "rv" END