Mehr Frieden -General Kyrylo Budanov:
[kivitendo-erp.git] / sql / Pg-upgrade2 / periodic_invoices.sql
1 -- @tag: periodic_invoices
2 -- @description: Neue Tabellen und Spalten für Wiederkehrende Rechnungen
3 -- @depends: release_2_6_1
4 CREATE TABLE periodic_invoices_configs (
5        id                      integer     NOT NULL DEFAULT nextval('id'),
6        oe_id                   integer     NOT NULL,
7        periodicity             varchar(10) NOT NULL,
8        print                   boolean               DEFAULT 'f',
9        printer_id              integer,
10        copies                  integer,
11        active                  boolean               DEFAULT 't',
12        terminated              boolean               DEFAULT 'f',
13        start_date              date,
14        end_date                date,
15        ar_chart_id             integer     NOT NULL,
16        extend_automatically_by integer,
17
18        PRIMARY KEY (id),
19        FOREIGN KEY (oe_id)       REFERENCES oe       (id),
20        FOREIGN KEY (printer_id)  REFERENCES printers (id),
21        FOREIGN KEY (ar_chart_id) REFERENCES chart    (id)
22 );
23
24 CREATE TABLE periodic_invoices (
25        id                integer   NOT NULL DEFAULT nextval('id'),
26        config_id         integer   NOT NULL,
27        ar_id             integer   NOT NULL,
28        period_start_date date      NOT NULL,
29        itime             timestamp          DEFAULT now(),
30
31        PRIMARY KEY (id),
32        FOREIGN KEY (config_id) REFERENCES periodic_invoices_configs (id),
33        FOREIGN KEY (ar_id)     REFERENCES ar                        (id)
34 );