CREATE OR REPLACE FUNCTION office.is_periodic_inventory(_office_id integer)
RETURNS boolean
LANGUAGE plpgsql
AS $function$
DECLARE config boolean;
BEGIN
SELECT value = 'Periodic' INTO config
FROM office.configuration
WHERE config_id=1
AND office_id=$1;
IF(config IS NULL) THEN
RETURN false;
--RAISE EXCEPTION '%', 'ERROR M9001: Invalid MixERP database schema. Please consult with your administrator.';
END IF;
RETURN config;
END
$function$