campingmontagut/test/tax_rate.sql
jordi fita mas 17f7520876 Add customer and invoices sections
Copied as much as i could from Numerus, and made as few modifications as
i could to adapt to this code base; it is, quite frankly, a piece of
shit.

We need to be able to create invoices from scratch “just in case”,
apparently, but it is not yet possible to create an invoice from a
booking.
2024-04-28 20:28:45 +02:00

35 lines
801 B
PL/PgSQL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Test tax_rate
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(7);
set search_path to camper, public;
select has_domain('tax_rate');
select domain_type_is('tax_rate', 'numeric');
select lives_ok($$ select 0.21::tax_rate $$, 'Should be able to cast valid positive decimals to tax rate');
select lives_ok($$ select (-0.15)::tax_rate $$, 'Should be able to cast valid negative decimals to tax rate');
select lives_ok($$ select 0::tax_rate $$, 'Should be able to cast valid zero to tax rate');
select throws_ok(
$$ SELECT 1::tax_rate $$,
23514, null,
'Should reject 100 % tax rate'
);
select throws_ok(
$$ SELECT (-1)::tax_rate $$,
23514, null,
'Should reject -100 % tax rate'
);
select *
from finish();
rollback;