-- Deploy camper:down_payment to pg
-- requires: roles
-- requires: schema_camper
-- requires: payment

begin;

set search_path to camper, public;

create or replace function down_payment(p payment) returns integer as
$$
	select round(p.total * p.down_payment_percent)::integer;
$$
	language sql
	stable
;

revoke execute on function down_payment(payment) from public;
grant execute on function down_payment(payment) to guest;
grant execute on function down_payment(payment) to employee;
grant execute on function down_payment(payment) to admin;

commit;
