Zeiterfassung: Tabellen und Rose
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 17 Nov 2020 12:41:54 +0000 (13:41 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 5 May 2021 15:25:02 +0000 (17:25 +0200)
SL/DB/Helper/ALL.pm
SL/DB/Helper/Mappings.pm
SL/DB/Manager/TimeRecording.pm [new file with mode: 0644]
SL/DB/Manager/TimeRecordingType.pm [new file with mode: 0644]
SL/DB/MetaSetup/TimeRecording.pm [new file with mode: 0644]
SL/DB/MetaSetup/TimeRecordingType.pm [new file with mode: 0644]
SL/DB/TimeRecording.pm [new file with mode: 0644]
SL/DB/TimeRecordingType.pm [new file with mode: 0644]
sql/Pg-upgrade2/time_recordings.sql [new file with mode: 0644]

index 006a389..30ae802 100644 (file)
@@ -134,6 +134,8 @@ use SL::DB::Tax;
 use SL::DB::TaxKey;
 use SL::DB::TaxZone;
 use SL::DB::TaxzoneChart;
+use SL::DB::TimeRecording;
+use SL::DB::TimeRecordingType;
 use SL::DB::TodoUserConfig;
 use SL::DB::TransferType;
 use SL::DB::Translation;
index da931f9..4abed60 100644 (file)
@@ -214,6 +214,8 @@ my %kivitendo_package_names = (
   taxkeys                        => 'tax_key',
   tax_zones                      => 'tax_zone',
   taxzone_charts                 => 'taxzone_chart',
+  time_recording_types           => 'time_recording_type',
+  time_recordings                => 'time_recording',
   todo_user_config               => 'todo_user_config',
   transfer_type                  => 'transfer_type',
   translation                    => 'translation',
diff --git a/SL/DB/Manager/TimeRecording.pm b/SL/DB/Manager/TimeRecording.pm
new file mode 100644 (file)
index 0000000..f0c7f42
--- /dev/null
@@ -0,0 +1,14 @@
+# This file has been auto-generated only because it didn't exist.
+# Feel free to modify it at will; it will not be overwritten automatically.
+
+package SL::DB::Manager::TimeRecording;
+
+use strict;
+
+use parent qw(SL::DB::Helper::Manager);
+
+sub object_class { 'SL::DB::TimeRecording' }
+
+__PACKAGE__->make_manager_methods;
+
+1;
diff --git a/SL/DB/Manager/TimeRecordingType.pm b/SL/DB/Manager/TimeRecordingType.pm
new file mode 100644 (file)
index 0000000..9d7593e
--- /dev/null
@@ -0,0 +1,14 @@
+# This file has been auto-generated only because it didn't exist.
+# Feel free to modify it at will; it will not be overwritten automatically.
+
+package SL::DB::Manager::TimeRecordingType;
+
+use strict;
+
+use parent qw(SL::DB::Helper::Manager);
+
+sub object_class { 'SL::DB::TimeRecordingType' }
+
+__PACKAGE__->make_manager_methods;
+
+1;
diff --git a/SL/DB/MetaSetup/TimeRecording.pm b/SL/DB/MetaSetup/TimeRecording.pm
new file mode 100644 (file)
index 0000000..518a037
--- /dev/null
@@ -0,0 +1,57 @@
+# This file has been auto-generated. Do not modify it; it will be overwritten
+# by rose_auto_create_model.pl automatically.
+package SL::DB::TimeRecording;
+
+use strict;
+
+use parent qw(SL::DB::Object);
+
+__PACKAGE__->meta->table('time_recordings');
+
+__PACKAGE__->meta->columns(
+  customer_id     => { type => 'integer', not_null => 1 },
+  description     => { type => 'text', not_null => 1 },
+  employee_id     => { type => 'integer', not_null => 1 },
+  end_time        => { type => 'timestamp' },
+  id              => { type => 'serial', not_null => 1 },
+  itime           => { type => 'timestamp', default => 'now()', not_null => 1 },
+  mtime           => { type => 'timestamp', default => 'now()', not_null => 1 },
+  project_id      => { type => 'integer' },
+  staff_member_id => { type => 'integer', not_null => 1 },
+  start_time      => { type => 'timestamp', not_null => 1 },
+  type_id         => { type => 'integer' },
+);
+
+__PACKAGE__->meta->primary_key_columns([ 'id' ]);
+
+__PACKAGE__->meta->allow_inline_column_values(1);
+
+__PACKAGE__->meta->foreign_keys(
+  customer => {
+    class       => 'SL::DB::Customer',
+    key_columns => { customer_id => 'id' },
+  },
+
+  employee => {
+    class       => 'SL::DB::Employee',
+    key_columns => { employee_id => 'id' },
+  },
+
+  project => {
+    class       => 'SL::DB::Project',
+    key_columns => { project_id => 'id' },
+  },
+
+  staff_member => {
+    class       => 'SL::DB::Employee',
+    key_columns => { staff_member_id => 'id' },
+  },
+
+  type => {
+    class       => 'SL::DB::TimeRecordingType',
+    key_columns => { type_id => 'id' },
+  },
+);
+
+1;
+;
diff --git a/SL/DB/MetaSetup/TimeRecordingType.pm b/SL/DB/MetaSetup/TimeRecordingType.pm
new file mode 100644 (file)
index 0000000..2852d46
--- /dev/null
@@ -0,0 +1,22 @@
+# This file has been auto-generated. Do not modify it; it will be overwritten
+# by rose_auto_create_model.pl automatically.
+package SL::DB::TimeRecordingType;
+
+use strict;
+
+use parent qw(SL::DB::Object);
+
+__PACKAGE__->meta->table('time_recording_types');
+
+__PACKAGE__->meta->columns(
+  abbreviation => { type => 'text', not_null => 1 },
+  description  => { type => 'text' },
+  id           => { type => 'serial', not_null => 1 },
+  obsolete     => { type => 'boolean', default => 'false', not_null => 1 },
+  position     => { type => 'integer', not_null => 1 },
+);
+
+__PACKAGE__->meta->primary_key_columns([ 'id' ]);
+
+1;
+;
diff --git a/SL/DB/TimeRecording.pm b/SL/DB/TimeRecording.pm
new file mode 100644 (file)
index 0000000..341e572
--- /dev/null
@@ -0,0 +1,13 @@
+# This file has been auto-generated only because it didn't exist.
+# Feel free to modify it at will; it will not be overwritten automatically.
+
+package SL::DB::TimeRecording;
+
+use strict;
+
+use SL::DB::MetaSetup::TimeRecording;
+use SL::DB::Manager::TimeRecording;
+
+__PACKAGE__->meta->initialize;
+
+1;
diff --git a/SL/DB/TimeRecordingType.pm b/SL/DB/TimeRecordingType.pm
new file mode 100644 (file)
index 0000000..bc9d2c0
--- /dev/null
@@ -0,0 +1,13 @@
+# This file has been auto-generated only because it didn't exist.
+# Feel free to modify it at will; it will not be overwritten automatically.
+
+package SL::DB::TimeRecordingType;
+
+use strict;
+
+use SL::DB::MetaSetup::TimeRecordingType;
+use SL::DB::Manager::TimeRecordingType;
+
+__PACKAGE__->meta->initialize;
+
+1;
diff --git a/sql/Pg-upgrade2/time_recordings.sql b/sql/Pg-upgrade2/time_recordings.sql
new file mode 100644 (file)
index 0000000..ccbf329
--- /dev/null
@@ -0,0 +1,35 @@
+-- @tag: time_recordings
+-- @description: Tabellen zur Zeiterfassung
+-- @depends: release_3_5_6_1
+
+CREATE TABLE time_recording_types (
+  id                 SERIAL,
+  abbreviation       TEXT     NOT NULL,
+  description        TEXT,
+  position           INTEGER  NOT NULL,
+  obsolete           BOOLEAN  NOT NULL DEFAULT false,
+  PRIMARY KEY (id)
+);
+
+CREATE TABLE time_recordings (
+  id                SERIAL,
+  customer_id       INTEGER   NOT NULL,
+  project_id        INTEGER,
+  start_time        TIMESTAMP NOT NULL,
+  end_time          TIMESTAMP,
+  type_id           INTEGER,
+  description       TEXT      NOT NULL,
+  staff_member_id   INTEGER   NOT NULL,
+  employee_id       INTEGER   NOT NULL,
+  itime             TIMESTAMP NOT NULL DEFAULT now(),
+  mtime             TIMESTAMP NOT NULL DEFAULT now(),
+
+  PRIMARY KEY (id),
+  FOREIGN KEY (customer_id)     REFERENCES customer (id),
+  FOREIGN KEY (staff_member_id) REFERENCES employee (id),
+  FOREIGN KEY (employee_id)     REFERENCES employee (id),
+  FOREIGN KEY (project_id)      REFERENCES project (id),
+  FOREIGN KEY (type_id)         REFERENCES time_recording_types (id)
+);
+
+CREATE TRIGGER mtime_time_recordings BEFORE UPDATE ON time_recordings FOR EACH ROW EXECUTE PROCEDURE set_mtime();