campingmontagut/test/payment_option.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

50 lines
1.9 KiB
PL/PgSQL

-- Test payment_option
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(27);
set search_path to camper, public;
select has_table('payment_option');
select has_pk('payment_option');
select col_is_pk('payment_option', array['payment_id', 'campsite_type_option_id']);
select table_privs_are('payment_option', 'guest', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
select table_privs_are('payment_option', 'employee', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
select table_privs_are('payment_option', 'admin', array['SELECT', 'INSERT', 'UPDATE', 'DELETE']);
select table_privs_are('payment_option', 'authenticator', array[]::text[]);
select has_column('payment_option', 'payment_id');
select col_is_fk('payment_option', 'payment_id');
select fk_ok('payment_option', 'payment_id', 'payment', 'payment_id');
select col_type_is('payment_option', 'payment_id', 'integer');
select col_not_null('payment_option', 'payment_id');
select col_hasnt_default('payment_option', 'payment_id');
select has_column('payment_option', 'campsite_type_option_id');
select col_is_fk('payment_option', 'campsite_type_option_id');
select fk_ok('payment_option', 'campsite_type_option_id', 'campsite_type_option', 'campsite_type_option_id');
select col_type_is('payment_option', 'campsite_type_option_id', 'integer');
select col_not_null('payment_option', 'campsite_type_option_id');
select col_hasnt_default('payment_option', 'campsite_type_option_id');
select has_column('payment_option', 'units');
select col_type_is('payment_option', 'units', 'positive_integer');
select col_not_null('payment_option', 'units');
select col_hasnt_default('payment_option', 'units');
select has_column('payment_option', 'subtotal');
select col_type_is('payment_option', 'subtotal', 'nonnegative_integer');
select col_not_null('payment_option', 'subtotal');
select col_hasnt_default('payment_option', 'subtotal');
select *
from finish();
rollback;