Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c8a3fef7

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID c8a3fef75e56acb4a3a513c4c0ea783a6f49e516
  • Vorgänger c73c19e0
  • Nachfolger 0c4110e2

Belegvorlagen: Datenbankschema, Rose-Models

Unterschiede anzeigen:

SL/DB/Helper/ALL.pm
91 91
use SL::DB::ProjectStatus;
92 92
use SL::DB::ProjectType;
93 93
use SL::DB::PurchaseInvoice;
94
use SL::DB::RecordLink;
95 94
use SL::DB::ReconciliationLink;
95
use SL::DB::RecordLink;
96
use SL::DB::RecordTemplate;
97
use SL::DB::RecordTemplateItem;
96 98
use SL::DB::RequirementSpecAcceptanceStatus;
97 99
use SL::DB::RequirementSpecComplexity;
98 100
use SL::DB::RequirementSpecDependency;
SL/DB/Helper/Mappings.pm
171 171
  project_roles                  => 'project_role',
172 172
  project_statuses               => 'project_status',
173 173
  project_types                  => 'project_type',
174
  record_links                   => 'record_link',
175 174
  reconciliation_links           => 'reconciliation_link',
175
  record_links                   => 'record_link',
176
  record_templates               => 'record_template',
177
  record_template_items          => 'record_template_item',
176 178
  requirement_spec_acceptance_statuses => 'RequirementSpecAcceptanceStatus',
177 179
  requirement_spec_complexities        => 'RequirementSpecComplexity',
178 180
  requirement_spec_item_dependencies   => 'RequirementSpecDependency',
SL/DB/Manager/RecordTemplate.pm
1
package SL::DB::Manager::RecordTemplate;
2

  
3
use strict;
4

  
5
use base qw(SL::DB::Helper::Manager);
6

  
7
use SL::DB::Helper::Paginated;
8
use SL::DB::Helper::Sorted;
9

  
10
sub object_class { 'SL::DB::RecordTemplate' }
11

  
12
__PACKAGE__->make_manager_methods;
13

  
14
sub _sort_spec {
15
  return (
16
    default => [ 'template_name', 1 ],
17
    columns => {
18
      SIMPLE        => 'ALL',
19
      template_name => 'lower(template_name)',
20
    },
21
  );
22
}
23

  
24
1;
SL/DB/Manager/RecordTemplateItem.pm
1
package SL::DB::Manager::RecordTemplateItem;
2

  
3
use strict;
4

  
5
use parent qw(SL::DB::Helper::Manager);
6

  
7
sub object_class { 'SL::DB::RecordTemplateItem' }
8

  
9
__PACKAGE__->make_manager_methods;
10

  
11
1;
SL/DB/MetaSetup/RecordTemplate.pm
1
# This file has been auto-generated. Do not modify it; it will be overwritten
2
# by rose_auto_create_model.pl automatically.
3
package SL::DB::RecordTemplate;
4

  
5
use strict;
6

  
7
use parent qw(SL::DB::Object);
8

  
9
__PACKAGE__->meta->table('record_templates');
10

  
11
__PACKAGE__->meta->columns(
12
  ar_ap_chart_id => { type => 'integer' },
13
  cb_transaction => { type => 'boolean', default => 'false', not_null => 1 },
14
  currency_id    => { type => 'integer', not_null => 1 },
15
  customer_id    => { type => 'integer' },
16
  department_id  => { type => 'integer' },
17
  description    => { type => 'text' },
18
  direct_debit   => { type => 'boolean', default => 'false', not_null => 1 },
19
  employee_id    => { type => 'integer' },
20
  id             => { type => 'serial', not_null => 1 },
21
  itime          => { type => 'timestamp', default => 'now()', not_null => 1 },
22
  mtime          => { type => 'timestamp', default => 'now()', not_null => 1 },
23
  notes          => { type => 'text' },
24
  ob_transaction => { type => 'boolean', default => 'false', not_null => 1 },
25
  ordnumber      => { type => 'text' },
26
  project_id     => { type => 'integer' },
27
  reference      => { type => 'text' },
28
  taxincluded    => { type => 'boolean', default => 'false', not_null => 1 },
29
  template_name  => { type => 'text', not_null => 1 },
30
  template_type  => { type => 'enum', check_in => [ 'ar_transaction', 'ap_transaction', 'gl_transaction' ], db_type => 'record_template_type', not_null => 1 },
31
  vendor_id      => { type => 'integer' },
32
);
33

  
34
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
35

  
36
__PACKAGE__->meta->allow_inline_column_values(1);
37

  
38
__PACKAGE__->meta->foreign_keys(
39
  ar_ap_chart => {
40
    class       => 'SL::DB::Chart',
41
    key_columns => { ar_ap_chart_id => 'id' },
42
  },
43

  
44
  currency => {
45
    class       => 'SL::DB::Currency',
46
    key_columns => { currency_id => 'id' },
47
  },
48

  
49
  customer => {
50
    class       => 'SL::DB::Customer',
51
    key_columns => { customer_id => 'id' },
52
  },
53

  
54
  department => {
55
    class       => 'SL::DB::Department',
56
    key_columns => { department_id => 'id' },
57
  },
58

  
59
  employee => {
60
    class       => 'SL::DB::Employee',
61
    key_columns => { employee_id => 'id' },
62
  },
63

  
64
  project => {
65
    class       => 'SL::DB::Project',
66
    key_columns => { project_id => 'id' },
67
  },
68

  
69
  vendor => {
70
    class       => 'SL::DB::Vendor',
71
    key_columns => { vendor_id => 'id' },
72
  },
73
);
74

  
75
1;
76
;
SL/DB/MetaSetup/RecordTemplateItem.pm
1
# This file has been auto-generated. Do not modify it; it will be overwritten
2
# by rose_auto_create_model.pl automatically.
3
package SL::DB::RecordTemplateItem;
4

  
5
use strict;
6

  
7
use parent qw(SL::DB::Object);
8

  
9
__PACKAGE__->meta->table('record_template_items');
10

  
11
__PACKAGE__->meta->columns(
12
  amount1            => { type => 'numeric', not_null => 1, precision => 15, scale => 5 },
13
  amount2            => { type => 'numeric', precision => 15, scale => 5 },
14
  chart_id           => { type => 'integer', not_null => 1 },
15
  id                 => { type => 'serial', not_null => 1 },
16
  memo               => { type => 'text' },
17
  project_id         => { type => 'integer' },
18
  record_template_id => { type => 'integer', not_null => 1 },
19
  source             => { type => 'text' },
20
  tax_id             => { type => 'integer', not_null => 1 },
21
);
22

  
23
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
24

  
25
__PACKAGE__->meta->foreign_keys(
26
  chart => {
27
    class       => 'SL::DB::Chart',
28
    key_columns => { chart_id => 'id' },
29
  },
30

  
31
  project => {
32
    class       => 'SL::DB::Project',
33
    key_columns => { project_id => 'id' },
34
  },
35

  
36
  record_template => {
37
    class       => 'SL::DB::RecordTemplate',
38
    key_columns => { record_template_id => 'id' },
39
  },
40

  
41
  tax => {
42
    class       => 'SL::DB::Tax',
43
    key_columns => { tax_id => 'id' },
44
  },
45
);
46

  
47
1;
48
;
SL/DB/RecordTemplate.pm
1
package SL::DB::RecordTemplate;
2

  
3
use strict;
4

  
5
use SL::DB::MetaSetup::RecordTemplate;
6
use SL::DB::Manager::RecordTemplate;
7

  
8
__PACKAGE__->meta->add_relationship(
9
  record_template_items => {
10
    type       => 'one to many',
11
    class      => 'SL::DB::RecordTemplateItem',
12
    column_map => { id => 'record_template_id' },
13
  },
14
);
15

  
16
__PACKAGE__->meta->initialize;
17

  
18
sub items { goto &record_template_items; }
19

  
20
1;
SL/DB/RecordTemplateItem.pm
1
package SL::DB::RecordTemplateItem;
2

  
3
use strict;
4

  
5
use SL::DB::MetaSetup::RecordTemplateItem;
6
use SL::DB::Manager::RecordTemplateItem;
7

  
8
__PACKAGE__->meta->initialize;
9

  
10
1;
sql/Pg-upgrade2/create_record_template_tables.sql
1
-- @tag: create_record_template_tables
2
-- @description: Einführung echter Vorlagen in der Finanzbuchhaltung anstelle der Entwurfsfunktion
3
-- @depends: release_3_4_1
4

  
5
DROP TABLE IF EXISTS record_template_items;
6
DROP TABLE IF EXISTS record_templates;
7
DROP TYPE IF EXISTS record_template_type;
8

  
9
CREATE TYPE record_template_type AS ENUM ('ar_transaction', 'ap_transaction', 'gl_transaction');
10
CREATE TABLE record_templates (
11
  id             SERIAL,
12
  template_name  TEXT                 NOT NULL,
13
  template_type  record_template_type NOT NULL,
14

  
15
  customer_id    INTEGER,
16
  vendor_id      INTEGER,
17
  currency_id    INTEGER              NOT NULL,
18
  department_id  INTEGER,
19
  project_id     INTEGER,
20
  employee_id    INTEGER,
21
  taxincluded    BOOLEAN              NOT NULL DEFAULT FALSE,
22
  direct_debit   BOOLEAN              NOT NULL DEFAULT FALSE,
23
  ob_transaction BOOLEAN              NOT NULL DEFAULT FALSE,
24
  cb_transaction BOOLEAN              NOT NULL DEFAULT FALSE,
25

  
26
  reference      TEXT,
27
  description    TEXT,
28
  ordnumber      TEXT,
29
  notes          TEXT,
30
  ar_ap_chart_id INTEGER,
31

  
32
  itime          TIMESTAMP            NOT NULL DEFAULT now(),
33
  mtime          TIMESTAMP            NOT NULL DEFAULT now(),
34

  
35
  PRIMARY KEY (id),
36
  CONSTRAINT record_templates_customer_id_fkey    FOREIGN KEY (customer_id)    REFERENCES customer   (id) ON DELETE SET NULL,
37
  CONSTRAINT record_templates_vendor_id_fkey      FOREIGN KEY (vendor_id)      REFERENCES vendor     (id) ON DELETE SET NULL,
38
  CONSTRAINT record_templates_currency_id_fkey    FOREIGN KEY (currency_id)    REFERENCES currencies (id) ON DELETE CASCADE,
39
  CONSTRAINT record_templates_department_id_fkey  FOREIGN KEY (department_id)  REFERENCES department (id) ON DELETE SET NULL,
40
  CONSTRAINT record_templates_project_id_fkey     FOREIGN KEY (project_id)     REFERENCES project    (id) ON DELETE SET NULL,
41
  CONSTRAINT record_templates_employee_id_fkey    FOREIGN KEY (employee_id)    REFERENCES employee   (id) ON DELETE SET NULL,
42
  CONSTRAINT record_templates_ar_ap_chart_id_fkey FOREIGN KEY (ar_ap_chart_id) REFERENCES chart      (id) ON DELETE SET NULL
43
);
44

  
45
CREATE TRIGGER mtime_record_templates BEFORE UPDATE ON record_templates FOR EACH ROW EXECUTE PROCEDURE set_mtime();
46

  
47
CREATE TABLE record_template_items (
48
  id                 SERIAL,
49
  record_template_id INTEGER         NOT NULL,
50

  
51
  chart_id           INTEGER         NOT NULL,
52
  tax_id             INTEGER         NOT NULL,
53
  project_id         INTEGER,
54
  amount1            NUMERIC (15, 5) NOT NULL,
55
  amount2            NUMERIC (15, 5),
56
  source             TEXT,
57
  memo               TEXT,
58

  
59
  PRIMARY KEY (id),
60
  CONSTRAINT record_template_items_record_template_id FOREIGN KEY (record_template_id) REFERENCES record_templates (id) ON DELETE CASCADE,
61
  CONSTRAINT record_template_items_chart_id           FOREIGN KEY (chart_id)           REFERENCES chart            (id) ON DELETE CASCADE,
62
  CONSTRAINT record_template_items_tax_id             FOREIGN KEY (tax_id)             REFERENCES tax              (id) ON DELETE CASCADE,
63
  CONSTRAINT record_template_items_project_id         FOREIGN KEY (project_id)         REFERENCES project          (id) ON DELETE SET NULL
64
);

Auch abrufbar als: Unified diff