From 250fa402a8394de574f8ede1ce2345cef7f8b31b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 12 Jan 2011 12:25:21 +0100 Subject: [PATCH] =?utf8?q?Datenbankupgradescript,=20Rose-Models=20f=C3=BCr?= =?utf8?q?=20Wiederkehrende=20Rechnungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/Helper/ALL.pm | 2 + SL/DB/Helper/Mappings.pm | 2 + SL/DB/MetaSetup/PeriodicInvoice.pm | 38 +++++++++++++++++++ SL/DB/MetaSetup/PeriodicInvoicesConfig.pm | 45 +++++++++++++++++++++++ SL/DB/Order.pm | 12 +++++- SL/DB/PeriodicInvoice.pm | 20 ++++++++++ SL/DB/PeriodicInvoicesConfig.pm | 20 ++++++++++ sql/Pg-upgrade2/periodic_invoices.sql | 31 ++++++++++++++++ 8 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 SL/DB/MetaSetup/PeriodicInvoice.pm create mode 100644 SL/DB/MetaSetup/PeriodicInvoicesConfig.pm create mode 100644 SL/DB/PeriodicInvoice.pm create mode 100644 SL/DB/PeriodicInvoicesConfig.pm create mode 100644 sql/Pg-upgrade2/periodic_invoices.sql diff --git a/SL/DB/Helper/ALL.pm b/SL/DB/Helper/ALL.pm index 3757404dd..ad369aa5e 100644 --- a/SL/DB/Helper/ALL.pm +++ b/SL/DB/Helper/ALL.pm @@ -53,6 +53,8 @@ use SL::DB::Part; use SL::DB::PartsGroup; use SL::DB::PartsTax; use SL::DB::PaymentTerm; +use SL::DB::PeriodicInvoice; +use SL::DB::PeriodicInvoicesConfig; use SL::DB::PriceFactor; use SL::DB::Pricegroup; use SL::DB::Prices; diff --git a/SL/DB/Helper/Mappings.pm b/SL/DB/Helper/Mappings.pm index b300aa62c..3ffd58561 100644 --- a/SL/DB/Helper/Mappings.pm +++ b/SL/DB/Helper/Mappings.pm @@ -66,6 +66,8 @@ my %lxoffice_package_names = ( partsgroup => 'parts_group', partstax => 'parts_tax', payment_terms => 'payment_term', + periodic_invoices => 'periodic_invoice', + periodic_invoices_configs => 'periodic_invoices_config', prices => 'prices', price_factors => 'price_factor', pricegroup => 'pricegroup', diff --git a/SL/DB/MetaSetup/PeriodicInvoice.pm b/SL/DB/MetaSetup/PeriodicInvoice.pm new file mode 100644 index 000000000..2a7abc992 --- /dev/null +++ b/SL/DB/MetaSetup/PeriodicInvoice.pm @@ -0,0 +1,38 @@ +# This file has been auto-generated. Do not modify it; it will be overwritten +# by rose_auto_create_model.pl automatically. +package SL::DB::PeriodicInvoice; + +use strict; + +use base qw(SL::DB::Object); + +__PACKAGE__->meta->setup( + table => 'periodic_invoices', + + columns => [ + id => { type => 'integer', not_null => 1, sequence => 'id' }, + config_id => { type => 'integer', not_null => 1 }, + ar_id => { type => 'integer', not_null => 1 }, + period_start_date => { type => 'date', not_null => 1 }, + itime => { type => 'timestamp', default => 'now()' }, + ], + + primary_key_columns => [ 'id' ], + + allow_inline_column_values => 1, + + foreign_keys => [ + ar => { + class => 'SL::DB::Invoice', + key_columns => { ar_id => 'id' }, + }, + + config => { + class => 'SL::DB::PeriodicInvoicesConfig', + key_columns => { config_id => 'id' }, + }, + ], +); + +1; +; diff --git a/SL/DB/MetaSetup/PeriodicInvoicesConfig.pm b/SL/DB/MetaSetup/PeriodicInvoicesConfig.pm new file mode 100644 index 000000000..ab3a619ef --- /dev/null +++ b/SL/DB/MetaSetup/PeriodicInvoicesConfig.pm @@ -0,0 +1,45 @@ +# This file has been auto-generated. Do not modify it; it will be overwritten +# by rose_auto_create_model.pl automatically. +package SL::DB::PeriodicInvoicesConfig; + +use strict; + +use base qw(SL::DB::Object); + +__PACKAGE__->meta->setup( + table => 'periodic_invoices_configs', + + columns => [ + id => { type => 'integer', not_null => 1, sequence => 'id' }, + oe_id => { type => 'integer', not_null => 1 }, + periodicity => { type => 'varchar', length => 10, not_null => 1 }, + print => { type => 'boolean', default => 'false' }, + printer_id => { type => 'integer' }, + copies => { type => 'integer' }, + active => { type => 'boolean', default => 'true' }, + start_date => { type => 'date' }, + ar_chart_id => { type => 'integer', not_null => 1 }, + ], + + primary_key_columns => [ 'id' ], + + foreign_keys => [ + ar_chart => { + class => 'SL::DB::Chart', + key_columns => { ar_chart_id => 'id' }, + }, + + oe => { + class => 'SL::DB::Order', + key_columns => { oe_id => 'id' }, + }, + + printer => { + class => 'SL::DB::Printer', + key_columns => { printer_id => 'id' }, + }, + ], +); + +1; +; diff --git a/SL/DB/Order.pm b/SL/DB/Order.pm index 739581432..8d321661d 100644 --- a/SL/DB/Order.pm +++ b/SL/DB/Order.pm @@ -17,7 +17,17 @@ __PACKAGE__->meta->add_relationship( manager_args => { with_objects => [ 'part' ] } - } + }, + periodic_invoices_config => { + type => 'one to one', + class => 'SL::DB::PeriodicInvoicesConfig', + column_map => { id => 'oe_id' }, + }, + periodic_invoices => { + type => 'one to many', + class => 'SL::DB::PeriodicInvoice', + column_map => { id => 'oe_id' }, + }, ); __PACKAGE__->meta->initialize; diff --git a/SL/DB/PeriodicInvoice.pm b/SL/DB/PeriodicInvoice.pm new file mode 100644 index 000000000..37084ef32 --- /dev/null +++ b/SL/DB/PeriodicInvoice.pm @@ -0,0 +1,20 @@ +package SL::DB::PeriodicInvoice; + +use strict; + +use SL::DB::MetaSetup::PeriodicInvoice; + +__PACKAGE__->meta->add_relationships( + invoice => { + type => 'one to one', + class => 'SL::DB::Invoice', + column_map => { ar_id => 'id' }, + }, +); + +__PACKAGE__->meta->initialize; + +# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. +__PACKAGE__->meta->make_manager_class; + +1; diff --git a/SL/DB/PeriodicInvoicesConfig.pm b/SL/DB/PeriodicInvoicesConfig.pm new file mode 100644 index 000000000..3ed93bcf8 --- /dev/null +++ b/SL/DB/PeriodicInvoicesConfig.pm @@ -0,0 +1,20 @@ +package SL::DB::PeriodicInvoicesConfig; + +use strict; + +use SL::DB::MetaSetup::PeriodicInvoicesConfig; + +__PACKAGE__->meta->add_relationships( + order => { + type => 'one to one', + class => 'SL::DB::Order', + column_map => { oe_id => 'id' }, + }, +); + +__PACKAGE__->meta->initialize; + +# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. +__PACKAGE__->meta->make_manager_class; + +1; diff --git a/sql/Pg-upgrade2/periodic_invoices.sql b/sql/Pg-upgrade2/periodic_invoices.sql new file mode 100644 index 000000000..43c3b27cd --- /dev/null +++ b/sql/Pg-upgrade2/periodic_invoices.sql @@ -0,0 +1,31 @@ +-- @tag: periodic_invoices +-- @description: Neue Tabellen und Spalten für Wiederkehrende Rechnungen +-- @depends: release_2_6_1 +CREATE TABLE periodic_invoices_configs ( + id integer NOT NULL DEFAULT nextval('id'), + oe_id integer NOT NULL, + periodicity varchar(10) NOT NULL, + print boolean DEFAULT 'f', + printer_id integer, + copies integer, + active boolean DEFAULT 't', + start_date date, + ar_chart_id integer NOT NULL, + + PRIMARY KEY (id), + FOREIGN KEY (oe_id) REFERENCES oe (id), + FOREIGN KEY (printer_id) REFERENCES printers (id), + FOREIGN KEY (ar_chart_id) REFERENCES chart (id) +); + +CREATE TABLE periodic_invoices ( + id integer NOT NULL DEFAULT nextval('id'), + config_id integer NOT NULL, + ar_id integer NOT NULL, + period_start_date date NOT NULL, + itime timestamp DEFAULT now(), + + PRIMARY KEY (id), + FOREIGN KEY (config_id) REFERENCES periodic_invoices_configs (id), + FOREIGN KEY (ar_id) REFERENCES ar (id) +); -- 2.20.1