Auftrags-Controller: Menge vor Preisquellenermittlung auf 1, wenn ungesetzt
[kivitendo-erp.git] / SL / DB / MetaSetup / Assembly.pm
index 408eea7..4e8fe0e 100644 (file)
@@ -4,26 +4,35 @@ package SL::DB::Assembly;
 
 use strict;
 
-use base qw(SL::DB::Object);
-
-__PACKAGE__->meta->setup(
-  table   => 'assembly',
-
-  columns => [
-    id          => { type => 'integer' },
-    parts_id    => { type => 'integer' },
-    qty         => { type => 'float', precision => 4 },
-    bom         => { type => 'boolean' },
-    itime       => { type => 'timestamp', default => 'now()' },
-    mtime       => { type => 'timestamp' },
-    variable    => { type => 'boolean', default => 'false', not_null => 1, remarks => 'true if this part of the assembly is variable, and can be modified' },
-    item_id     => { type => 'integer', remarks => 'used to group parts in an assembly for exclusive options' },
-    assembly_id => { type => 'serial', not_null => 1 },
-  ],
-
-  primary_key_columns => [ 'assembly_id' ],
-
-  allow_inline_column_values => 1,
+use parent qw(SL::DB::Object);
+
+__PACKAGE__->meta->table('assembly');
+
+__PACKAGE__->meta->columns(
+  assembly_id => { type => 'serial', not_null => 1 },
+  bom         => { type => 'boolean' },
+  id          => { type => 'integer', not_null => 1 },
+  itime       => { type => 'timestamp', default => 'now()' },
+  mtime       => { type => 'timestamp' },
+  parts_id    => { type => 'integer', not_null => 1 },
+  position    => { type => 'integer' },
+  qty         => { type => 'float', precision => 4, scale => 4 },
+);
+
+__PACKAGE__->meta->primary_key_columns([ 'assembly_id' ]);
+
+__PACKAGE__->meta->allow_inline_column_values(1);
+
+__PACKAGE__->meta->foreign_keys(
+  assembly_part => {
+    class       => 'SL::DB::Part',
+    key_columns => { id => 'id' },
+  },
+
+  part => {
+    class       => 'SL::DB::Part',
+    key_columns => { parts_id => 'id' },
+  },
 );
 
 1;