numerus/deploy/expense_tax_amount.sql

25 lines
507 B
MySQL
Raw Normal View History

-- Deploy numerus:expense_tax_amount to pg
-- requires: schema_numerus
-- requires: expense
-- requires: expense_tax
begin;
set search_path to numerus, public;
create or replace view expense_tax_amount
as
select expense_id
, tax_id
, sum(round(amount * tax_rate)::integer)::integer as amount
from expense
join expense_tax using (expense_id)
group by expense_id
, tax_id
;
grant select on table expense_tax_amount to invoicer;
grant select on table expense_tax_amount to admin;
commit;