Files
SQL-Scripts/vw_utility_invoices.sql
AzureAD\SylvainDUVERNAY 022f4e0a2a First initial commit
2026-01-07 14:38:55 +01:00

32 lines
1.1 KiB
SQL

-- View: public.vw_utility_invoices
-- DROP VIEW public.vw_utility_invoices;
CREATE OR REPLACE VIEW public.vw_utility_invoices AS
SELECT ai.id AS "intInvoiceId",
ai.company AS "intCompanyId",
cparty.name AS "strCompanyName",
ai.number AS "strInvoiceNumber",
ai.invoice_date AS "dtmInvoiceDate",
p.name AS "strPartyName",
ai.type AS "strInvoiceType",
aipt.name AS "strPaymentTerm",
ai.accounting_date AS "dtmAccountingDate",
ai.currency AS "intCurrencyId",
cc.name AS "strCurrencyCode",
ai.state AS "strInvoiceState",
ai.move AS "intMoveId",
ai.account AS "intAccountId",
aa.name AS "strAccountName"
FROM account_invoice ai
JOIN currency_currency cc ON ai.currency = cc.id
JOIN party_party p ON ai.party = p.id
JOIN company_company comp ON ai.company = comp.id
JOIN party_party cparty ON comp.party = cparty.id
JOIN account_invoice_payment_term aipt ON ai.payment_term = aipt.id
LEFT JOIN account_account aa ON ai.account = aa.id
WHERE 1 = 1;
ALTER TABLE public.vw_utility_invoices
OWNER TO postgres;