campingmontagut/deploy/payment_reference.sql
jordi fita mas f2143cd0e6 Add the admin page to see payments
Had to do a couple of changes to the database: add the currency_code to
the payment relation, to format the price according to the payment’s
currency instead of the company’s; and the reference SQL function, to
replace the equivalent golang function, so that i can use it to index
payments.

The rest is mostly the same as any other page, except that the
individual payment’s page is not a form, but a regular info dump.

I also moved the payment settings as a sub-route of payments, as i
believe this makes more sense than an additional user menu item.
2024-02-14 04:54:42 +01:00

24 lines
559 B
PL/PgSQL

-- Deploy camper:order_code to pg
-- requires: roles
-- requires: schema_camper
-- requires: payment
begin;
set search_path to camper, public;
create or replace function reference(p payment) returns text as
$$
select lpad(p.payment_id::text, 8, '0') || substring(p.slug::text from 1 for 4);
$$
language sql
stable
;
revoke execute on function reference(payment) from public;
grant execute on function reference(payment) to guest;
grant execute on function reference(payment) to employee;
grant execute on function reference(payment) to admin;
commit;