CREATE OR REPLACE FUNCTION food600.prep_meny(
	menaz integer,
	menana integer,
	hodnota numeric(20,10))
    RETURNS numeric(20,10)
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE
AS $BODY$
DECLARE ret numeric(20,10);
zaokruhlenie INTEGER DEFAULT 10;
BEGIN
CASE
	WHEN (menaz=1 AND menana=1) OR (menaz=2 AND menana=2) THEN 
		ret:= round(CAST(hodnota AS numeric),zaokruhlenie);
	WHEN menaz=1 AND menana=2 THEN 
		ret:=round(CAST(hodnota AS numeric)/30.1260,zaokruhlenie);
	WHEN menaz IS NULL OR menana IS NULL THEN
		ret:= round(CAST(hodnota AS numeric),zaokruhlenie);
	ELSE ret:=round(CAST(hodnota AS numeric)*30.1260,zaokruhlenie);
END CASE; 
return ret;
END
$BODY$;
