numerus/deploy/invoice_amount.sql

23 lines
520 B
MySQL
Raw Permalink Normal View History

-- Deploy numerus:invoice_amount to pg
-- requires: schema_numerus
-- requires: invoice_product
-- requires: invoice_product_amount
begin;
set search_path to numerus, public;
create or replace view invoice_amount as
select invoice_id
, sum(subtotal)::integer as subtotal
, sum(total)::integer as total
from invoice_product
join invoice_product_amount using (invoice_product_id)
group by invoice_id
;
grant select on table invoice_amount to invoicer;
grant select on table invoice_amount to admin;
commit;