
CREATE OR REPLACE FUNCTION public.calculate_job_line()
 RETURNS trigger
 LANGUAGE plpgsql
AS $function$
DECLARE
  _new record;
BEGIN
  _new := NEW;
 _new."price_diff" = _new."db_price" - _new."act_price";

if _new."db_price" > 0 then 
_new."price_diff_pc" = (_new."db_price" - _new."act_price") / _new."db_price";

end if;

  RETURN _new;
END;
$function$
;