pears.GetTempMargin
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
Original SQL
CREATE FUNCTION "pears"."GetTempMargin"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ IN "chargerate" DOUBLE,IN "payrate" DOUBLE,IN "temp" SMALLINT,IN "taxmethod" SMALLINT,IN "directengagement" SMALLINT, IN "actualNotPercent" SMALLINT,IN "holpayPercent" DOUBLE,IN "NIPercent" DOUBLE,IN "NIonHolpay" SMALLINT ) RETURNS CHAR(10) deterministic BEGIN DECLARE "margin" DOUBLE; DECLARE "HolidayCost" DOUBLE; DECLARE "NICost" DOUBLE; IF "isnull"("temp",0) = 0 THEN RETURN NULL END IF; SET "margin" = "chargerate"-"isnull"("payrate",0.0); IF "isnull"("taxmethod",1) = 1 AND "isnull"("directengagement",0) = 0 AND "payrate" IS NOT NULL THEN SET "HolidayCost" = "isnull"("holpayPercent",0)*"PayRate"/100; SET "NICost" = "isnull"("NIPercent",0)*(IF "isnull"("NIonHolPay",0) = 1 THEN "PayRate"+"HolidayCost" ELSE "PayRate" endif)/100; SET "margin" = "margin"-("HolidayCost"+"NICost") END IF; IF "isnull"("actualNotPercent",0) = 1 OR "isnull"("Margin",0) = 0 OR "isnull"("chargerate",0) = 0 THEN RETURN "str"("Margin",10,2) ELSE RETURN "string"("str"(("Margin"/"ChargeRate")*100,8,2),' %') END IF END