--
-- PostgreSQL database dump
--

\restrict kNYhdwOhwE9I3bgAzdljyYgB5xyEpjhiaSCeYZfp84v3ey1GpvsdxX4U8Y8fQM3

-- Dumped from database version 18.1
-- Dumped by pg_dump version 18.1

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: account; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.account (
    id integer NOT NULL,
    number smallint NOT NULL,
    "financialYearId" integer NOT NULL,
    description text NOT NULL,
    sru smallint
);


--
-- Name: accountBalance; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public."accountBalance" (
    "accountNumber" integer NOT NULL,
    "financialYearId" integer NOT NULL,
    "in" numeric(12,2) DEFAULT 0 NOT NULL,
    "out" numeric(12,2) DEFAULT 0 NOT NULL,
    "inQuantity" integer,
    "outQuantity" integer
);


--
-- Name: account_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.account_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: account_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.account_id_seq OWNED BY public.account.id;


--
-- Name: aliasesToSupplier; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public."aliasesToSupplier" (
    id integer NOT NULL,
    "supplierId" integer NOT NULL,
    alias text NOT NULL
);


--
-- Name: aliasesToSupplier_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public."aliasesToSupplier_id_seq"
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: aliasesToSupplier_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public."aliasesToSupplier_id_seq" OWNED BY public."aliasesToSupplier".id;


--
-- Name: dimension; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.dimension (
    id integer NOT NULL,
    number smallint NOT NULL,
    name text
);


--
-- Name: dimension_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.dimension_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: dimension_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.dimension_id_seq OWNED BY public.dimension.id;


--
-- Name: entry; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.entry (
    id integer NOT NULL,
    "financialYearId" integer NOT NULL,
    "journalId" integer NOT NULL,
    number integer NOT NULL,
    "transactionDate" date NOT NULL,
    description text,
    "entryDate" date NOT NULL,
    signature text
);


--
-- Name: entry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.entry_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: entry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.entry_id_seq OWNED BY public.entry.id;


--
-- Name: file; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.file (
    id integer NOT NULL,
    filename text CONSTRAINT file_file_not_null NOT NULL
);


--
-- Name: file_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.file_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: file_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.file_id_seq OWNED BY public.file.id;


--
-- Name: filesToInvoice; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public."filesToInvoice" (
    "invoiceId" integer NOT NULL,
    "fileId" integer NOT NULL
);


--
-- Name: financialYear; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public."financialYear" (
    id integer NOT NULL,
    year integer NOT NULL,
    "startDate" date NOT NULL,
    "endDate" date NOT NULL
);


--
-- Name: financialYear_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public."financialYear_id_seq"
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: financialYear_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public."financialYear_id_seq" OWNED BY public."financialYear".id;


--
-- Name: invoice; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.invoice (
    id integer NOT NULL,
    "financialYearId" integer,
    "supplierId" integer NOT NULL,
    "fiskenNumber" integer,
    "phmNumber" integer,
    "invoiceNumber" text,
    "invoiceDate" date,
    "dueDate" date,
    ocr text,
    amount numeric(12,2)
);


--
-- Name: invoice_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.invoice_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: invoice_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.invoice_id_seq OWNED BY public.invoice.id;


--
-- Name: journal; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.journal (
    id integer NOT NULL,
    identifier text NOT NULL,
    description text
);


--
-- Name: journal_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.journal_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: journal_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.journal_id_seq OWNED BY public.journal.id;


--
-- Name: object; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.object (
    id integer NOT NULL,
    "dimensionId" integer NOT NULL,
    number smallint NOT NULL,
    name text
);


--
-- Name: object_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.object_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: object_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.object_id_seq OWNED BY public.object.id;


--
-- Name: supplier; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.supplier (
    id integer NOT NULL,
    name text,
    "supplierTypeId" integer NOT NULL,
    "taxId" text
);


--
-- Name: supplierType; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public."supplierType" (
    id integer NOT NULL,
    name text NOT NULL
);


--
-- Name: supplierType_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public."supplierType_id_seq"
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: supplierType_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public."supplierType_id_seq" OWNED BY public."supplierType".id;


--
-- Name: supplier_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.supplier_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: supplier_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.supplier_id_seq OWNED BY public.supplier.id;


--
-- Name: transaction; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.transaction (
    id integer NOT NULL,
    "entryId" integer NOT NULL,
    "accountNumber" smallint NOT NULL,
    amount numeric(12,2) NOT NULL,
    "objectId" integer,
    description text,
    "transactionDate" date,
    quantity numeric(12,2),
    signature text,
    "invoiceId" integer
);


--
-- Name: transaction_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.transaction_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: transaction_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.transaction_id_seq OWNED BY public.transaction.id;


--
-- Name: transactionsToObjects; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public."transactionsToObjects" (
    "transactionId" integer NOT NULL,
    "objectId" integer NOT NULL
);


--
-- Name: account id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.account ALTER COLUMN id SET DEFAULT nextval('public.account_id_seq'::regclass);


--
-- Name: aliasesToSupplier id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."aliasesToSupplier" ALTER COLUMN id SET DEFAULT nextval('public."aliasesToSupplier_id_seq"'::regclass);


--
-- Name: dimension id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.dimension ALTER COLUMN id SET DEFAULT nextval('public.dimension_id_seq'::regclass);


--
-- Name: entry id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.entry ALTER COLUMN id SET DEFAULT nextval('public.entry_id_seq'::regclass);


--
-- Name: file id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.file ALTER COLUMN id SET DEFAULT nextval('public.file_id_seq'::regclass);


--
-- Name: financialYear id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."financialYear" ALTER COLUMN id SET DEFAULT nextval('public."financialYear_id_seq"'::regclass);


--
-- Name: invoice id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invoice ALTER COLUMN id SET DEFAULT nextval('public.invoice_id_seq'::regclass);


--
-- Name: journal id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.journal ALTER COLUMN id SET DEFAULT nextval('public.journal_id_seq'::regclass);


--
-- Name: object id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.object ALTER COLUMN id SET DEFAULT nextval('public.object_id_seq'::regclass);


--
-- Name: supplier id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplier ALTER COLUMN id SET DEFAULT nextval('public.supplier_id_seq'::regclass);


--
-- Name: supplierType id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."supplierType" ALTER COLUMN id SET DEFAULT nextval('public."supplierType_id_seq"'::regclass);


--
-- Name: transaction id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.transaction ALTER COLUMN id SET DEFAULT nextval('public.transaction_id_seq'::regclass);


--
-- Name: accountBalance accountBalance_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."accountBalance"
    ADD CONSTRAINT "accountBalance_pkey" PRIMARY KEY ("accountNumber", "financialYearId");


--
-- Name: account account_number_financialYearId_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.account
    ADD CONSTRAINT "account_number_financialYearId_key" UNIQUE (number, "financialYearId");


--
-- Name: account account_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.account
    ADD CONSTRAINT account_pkey PRIMARY KEY (id);


--
-- Name: aliasesToSupplier aliasesToSupplier_alias_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."aliasesToSupplier"
    ADD CONSTRAINT "aliasesToSupplier_alias_key" UNIQUE (alias);


--
-- Name: aliasesToSupplier aliasesToSupplier_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."aliasesToSupplier"
    ADD CONSTRAINT "aliasesToSupplier_pkey" PRIMARY KEY (id);


--
-- Name: dimension dimension_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.dimension
    ADD CONSTRAINT dimension_pkey PRIMARY KEY (id);


--
-- Name: entry entry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.entry
    ADD CONSTRAINT entry_pkey PRIMARY KEY (id);


--
-- Name: file file_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.file
    ADD CONSTRAINT file_pkey PRIMARY KEY (id);


--
-- Name: filesToInvoice filesToInvoice_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."filesToInvoice"
    ADD CONSTRAINT "filesToInvoice_pkey" PRIMARY KEY ("invoiceId", "fileId");


--
-- Name: financialYear financialYear_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."financialYear"
    ADD CONSTRAINT "financialYear_pkey" PRIMARY KEY (id);


--
-- Name: financialYear financialYear_startDate_endDate_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."financialYear"
    ADD CONSTRAINT "financialYear_startDate_endDate_key" UNIQUE ("startDate", "endDate");


--
-- Name: financialYear financialYear_year_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."financialYear"
    ADD CONSTRAINT "financialYear_year_key" UNIQUE (year);


--
-- Name: invoice invoice_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invoice
    ADD CONSTRAINT invoice_pkey PRIMARY KEY (id);


--
-- Name: journal journal_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.journal
    ADD CONSTRAINT journal_pkey PRIMARY KEY (id);


--
-- Name: object object_dimensionId_number_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.object
    ADD CONSTRAINT "object_dimensionId_number_key" UNIQUE ("dimensionId", number);


--
-- Name: object object_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.object
    ADD CONSTRAINT object_pkey PRIMARY KEY (id);


--
-- Name: supplierType supplierType_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."supplierType"
    ADD CONSTRAINT "supplierType_pkey" PRIMARY KEY (id);


--
-- Name: supplier supplier_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplier
    ADD CONSTRAINT supplier_pkey PRIMARY KEY (id);


--
-- Name: supplier supplier_taxId_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplier
    ADD CONSTRAINT "supplier_taxId_key" UNIQUE ("taxId");


--
-- Name: transaction transaction_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.transaction
    ADD CONSTRAINT transaction_pkey PRIMARY KEY (id);


--
-- Name: transactionsToObjects transactionsToObjects_transactionId_objectId_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."transactionsToObjects"
    ADD CONSTRAINT "transactionsToObjects_transactionId_objectId_key" UNIQUE ("transactionId", "objectId");


--
-- Name: aliasesToSupplier aliasesToSupplier_supplierId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."aliasesToSupplier"
    ADD CONSTRAINT "aliasesToSupplier_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES public.supplier(id);


--
-- Name: filesToInvoice filesToInvoice_fileId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."filesToInvoice"
    ADD CONSTRAINT "filesToInvoice_fileId_fkey" FOREIGN KEY ("fileId") REFERENCES public.file(id);


--
-- Name: filesToInvoice filesToInvoice_invoiceId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."filesToInvoice"
    ADD CONSTRAINT "filesToInvoice_invoiceId_fkey" FOREIGN KEY ("invoiceId") REFERENCES public.invoice(id);


--
-- Name: invoice invoice_financialYearId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invoice
    ADD CONSTRAINT "invoice_financialYearId_fkey" FOREIGN KEY ("financialYearId") REFERENCES public."financialYear"(id);


--
-- Name: invoice invoice_supplierId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invoice
    ADD CONSTRAINT "invoice_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES public.supplier(id);


--
-- Name: object object_dimensionId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.object
    ADD CONSTRAINT "object_dimensionId_fkey" FOREIGN KEY ("dimensionId") REFERENCES public.dimension(id);


--
-- Name: supplier supplier_supplierTypeId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.supplier
    ADD CONSTRAINT "supplier_supplierTypeId_fkey" FOREIGN KEY ("supplierTypeId") REFERENCES public."supplierType"(id);


--
-- Name: transaction transaction_entryId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.transaction
    ADD CONSTRAINT "transaction_entryId_fkey" FOREIGN KEY ("entryId") REFERENCES public.entry(id);


--
-- Name: transaction transaction_invoiceId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.transaction
    ADD CONSTRAINT "transaction_invoiceId_fkey" FOREIGN KEY ("invoiceId") REFERENCES public.invoice(id);


--
-- Name: transaction transaction_objectId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.transaction
    ADD CONSTRAINT "transaction_objectId_fkey" FOREIGN KEY ("objectId") REFERENCES public.object(id);


--
-- Name: transactionsToObjects transactionsToObjects_objectId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."transactionsToObjects"
    ADD CONSTRAINT "transactionsToObjects_objectId_fkey" FOREIGN KEY ("objectId") REFERENCES public.object(id);


--
-- Name: transactionsToObjects transactionsToObjects_transactionId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public."transactionsToObjects"
    ADD CONSTRAINT "transactionsToObjects_transactionId_fkey" FOREIGN KEY ("transactionId") REFERENCES public.transaction(id);


--
-- PostgreSQL database dump complete
--

\unrestrict kNYhdwOhwE9I3bgAzdljyYgB5xyEpjhiaSCeYZfp84v3ey1GpvsdxX4U8Y8fQM3

