Datenbankupgradescript, Rose-Models für Wiederkehrende Rechnungen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 12 Jan 2011 11:25:21 +0000 (12:25 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Wed, 12 Jan 2011 15:06:45 +0000 (16:06 +0100)
SL/DB/Helper/ALL.pm
SL/DB/Helper/Mappings.pm
SL/DB/MetaSetup/PeriodicInvoice.pm [new file with mode: 0644]
SL/DB/MetaSetup/PeriodicInvoicesConfig.pm [new file with mode: 0644]
SL/DB/Order.pm
SL/DB/PeriodicInvoice.pm [new file with mode: 0644]
SL/DB/PeriodicInvoicesConfig.pm [new file with mode: 0644]
sql/Pg-upgrade2/periodic_invoices.sql [new file with mode: 0644]

index 3757404..ad369aa 100644 (file)
@@ -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;
index b300aa6..3ffd585 100644 (file)
@@ -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 (file)
index 0000000..2a7abc9
--- /dev/null
@@ -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 (file)
index 0000000..ab3a619
--- /dev/null
@@ -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;
+;
index 7395814..8d32166 100644 (file)
@@ -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 (file)
index 0000000..37084ef
--- /dev/null
@@ -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 (file)
index 0000000..3ed93bc
--- /dev/null
@@ -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 (file)
index 0000000..43c3b27
--- /dev/null
@@ -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)
+);