From dc3382e8276f279de81f8bdc53f4af0adb4e8657 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Mon, 4 Dec 2017 10:42:37 +0100 Subject: [PATCH] =?utf8?q?Inventur:=20neue=20Tabelle=20f=C3=BCr=20gez?= =?utf8?q?=C3=A4hlte=20Artikel.=20DB-Upgrade=20und=20Rose?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/Helper/ALL.pm | 1 + SL/DB/Helper/Mappings.pm | 1 + SL/DB/Manager/Stocktaking.pm | 14 ++++++++ SL/DB/MetaSetup/Stocktaking.pm | 59 ++++++++++++++++++++++++++++++++ SL/DB/Stocktaking.pm | 13 +++++++ sql/Pg-upgrade2/stocktakings.sql | 24 +++++++++++++ 6 files changed, 112 insertions(+) create mode 100644 SL/DB/Manager/Stocktaking.pm create mode 100644 SL/DB/MetaSetup/Stocktaking.pm create mode 100644 SL/DB/Stocktaking.pm create mode 100644 sql/Pg-upgrade2/stocktakings.sql diff --git a/SL/DB/Helper/ALL.pm b/SL/DB/Helper/ALL.pm index 7d71121e3..4429f8f8b 100644 --- a/SL/DB/Helper/ALL.pm +++ b/SL/DB/Helper/ALL.pm @@ -123,6 +123,7 @@ use SL::DB::ShopOrder; use SL::DB::ShopOrderItem; use SL::DB::ShopPart; use SL::DB::Status; +use SL::DB::Stocktaking; use SL::DB::Tax; use SL::DB::TaxKey; use SL::DB::TaxZone; diff --git a/SL/DB/Helper/Mappings.pm b/SL/DB/Helper/Mappings.pm index 4199bae9b..f9d474593 100644 --- a/SL/DB/Helper/Mappings.pm +++ b/SL/DB/Helper/Mappings.pm @@ -203,6 +203,7 @@ my %kivitendo_package_names = ( shop_order_items => 'shop_order_item', shop_parts => 'shop_part', status => 'status', + stocktakings => 'stocktaking', tax => 'tax', taxkeys => 'tax_key', tax_zones => 'tax_zone', diff --git a/SL/DB/Manager/Stocktaking.pm b/SL/DB/Manager/Stocktaking.pm new file mode 100644 index 000000000..6e6714c87 --- /dev/null +++ b/SL/DB/Manager/Stocktaking.pm @@ -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::Stocktaking; + +use strict; + +use parent qw(SL::DB::Helper::Manager); + +sub object_class { 'SL::DB::Stocktaking' } + +__PACKAGE__->make_manager_methods; + +1; diff --git a/SL/DB/MetaSetup/Stocktaking.pm b/SL/DB/MetaSetup/Stocktaking.pm new file mode 100644 index 000000000..b00b7d2db --- /dev/null +++ b/SL/DB/MetaSetup/Stocktaking.pm @@ -0,0 +1,59 @@ +# This file has been auto-generated. Do not modify it; it will be overwritten +# by rose_auto_create_model.pl automatically. +package SL::DB::Stocktaking; + +use strict; + +use parent qw(SL::DB::Object); + +__PACKAGE__->meta->table('stocktakings'); + +__PACKAGE__->meta->columns( + bestbefore => { type => 'date' }, + bin_id => { type => 'integer', not_null => 1 }, + chargenumber => { type => 'text', default => '', not_null => 1 }, + comment => { type => 'text' }, + cutoff_date => { type => 'date', not_null => 1 }, + employee_id => { type => 'integer', not_null => 1 }, + id => { type => 'integer', not_null => 1, sequence => 'id' }, + inventory_id => { type => 'integer' }, + itime => { type => 'timestamp', default => 'now()' }, + mtime => { type => 'timestamp' }, + parts_id => { type => 'integer', not_null => 1 }, + qty => { type => 'numeric', not_null => 1, precision => 25, scale => 5 }, + warehouse_id => { type => 'integer', not_null => 1 }, +); + +__PACKAGE__->meta->primary_key_columns([ 'id' ]); + +__PACKAGE__->meta->allow_inline_column_values(1); + +__PACKAGE__->meta->foreign_keys( + bin => { + class => 'SL::DB::Bin', + key_columns => { bin_id => 'id' }, + }, + + employee => { + class => 'SL::DB::Employee', + key_columns => { employee_id => 'id' }, + }, + + inventory => { + class => 'SL::DB::Inventory', + key_columns => { inventory_id => 'id' }, + }, + + parts => { + class => 'SL::DB::Part', + key_columns => { parts_id => 'id' }, + }, + + warehouse => { + class => 'SL::DB::Warehouse', + key_columns => { warehouse_id => 'id' }, + }, +); + +1; +; diff --git a/SL/DB/Stocktaking.pm b/SL/DB/Stocktaking.pm new file mode 100644 index 000000000..ee7926b39 --- /dev/null +++ b/SL/DB/Stocktaking.pm @@ -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::Stocktaking; + +use strict; + +use SL::DB::MetaSetup::Stocktaking; +use SL::DB::Manager::Stocktaking; + +__PACKAGE__->meta->initialize; + +1; diff --git a/sql/Pg-upgrade2/stocktakings.sql b/sql/Pg-upgrade2/stocktakings.sql new file mode 100644 index 000000000..49591edfe --- /dev/null +++ b/sql/Pg-upgrade2/stocktakings.sql @@ -0,0 +1,24 @@ +-- @tag: stocktakings +-- @description: Tabelle für in einer Inventur gezählte Artikel +-- @depends: warehouse + + +CREATE TABLE stocktakings ( + id INTEGER NOT NULL DEFAULT nextval('id'), + inventory_id INTEGER REFERENCES inventory(id), + warehouse_id INTEGER NOT NULL REFERENCES warehouse(id), + bin_id INTEGER NOT NULL REFERENCES bin(id), + parts_id INTEGER NOT NULL REFERENCES parts(id), + employee_id INTEGER NOT NULL REFERENCES employee(id), + qty NUMERIC(25,5) NOT NULL , + comment TEXT, + chargenumber TEXT NOT NULL DEFAULT '', + bestbefore DATE, + cutoff_date DATE NOT NULL, + itime TIMESTAMP DEFAULT now(), + mtime TIMESTAMP, + + PRIMARY KEY (id) +); + +CREATE TRIGGER mtime_stocktakings BEFORE UPDATE ON stocktakings FOR EACH ROW EXECUTE PROCEDURE set_mtime(); -- 2.20.1