Fix on PAYE computation

Home Forums Baraza HCM Fix on PAYE computation

Tagged: ,

This topic contains 0 replies, has 1 voice, and was last updated by  dennis@dennis.me.ke 1 month, 3 weeks ago.

  • Author
    Posts
  • #475

    dennis@dennis.me.ke
    Participant

    CREATE OR REPLACE FUNCTION getAdjustment(int, int) RETURNS float AS $$
    DECLARE
    adjustment float;
    BEGIN

    IF ($2 = 1) THEN
    SELECT (Basic_Pay + getAdjustment(Employee_Month_ID, 4, 31) + getAdjustment(Employee_Month_ID, 4, 32)
    + getAdjustment(Employee_Month_ID, 4, 23))
    INTO adjustment
    FROM Employee_Month
    WHERE (Employee_Month_ID = $1);
    ELSIF ($2 = 2) THEN
    SELECT (Basic_Pay + getAdjustment(Employee_Month_ID, 4, 31) + getAdjustment(Employee_Month_ID, 4, 32)
    + getAdjustment(Employee_Month_ID, 4, 23)
    – getAdjustment(Employee_Month_ID, 4, 12) – getAdjustment(Employee_Month_ID, 4, 24))
    INTO adjustment
    FROM Employee_Month
    WHERE (Employee_Month_ID = $1);
    ELSIF ($2 = 3) THEN
    SELECT (Basic_Pay + getAdjustment(Employee_Month_ID, 4, 31) + getAdjustment(Employee_Month_ID, 4, 32))
    INTO adjustment
    FROM Employee_Month
    WHERE (Employee_Month_ID = $1);
    ELSE
    adjustment := 0;
    END IF;

    IF(adjustment is null) THEN
    adjustment := 0;
    END IF;

    RETURN adjustment;
    END;
    $$ LANGUAGE plpgsql;

You must be logged in to reply to this topic.