====== pears.ValuesForInvoiceFixedWTRLine ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."ValuesForInvoiceFixedWTRLine"( in "tsid" char(20),in "tslineid" char(20),in "RecordType" char(1) )
returns long varchar
-- can do line specific stuff with timesheet line id
begin
declare "rv" long varchar;
declare "vex" integer;
set "rv" = null;
case "RecordType"
when 'D' then
-- could lookup percentage
set "rv" = 'Fixed WTR'
when 'N' then
select "analysis" into "rv" from "temptimesheet" key join "placement"
key join "staff" key join "agencydetails" where "temptimesheetid" = "tsid";
set "rv" = "string"('1000',"rv")
when 'V' then
select "companyaccount"."vatexempt" into "vex" from "temptimesheet" key join "placement" key join "employment" key join "company" key join "companyaccount" where "temptimesheetid" = "tsid";
if "vex" = 1 then set "rv" = 'E'
else set "rv" = 'S'
end if
end case;
return("rv")
end