Revision 91bd08d8
Von Moritz Bunkus vor fast 12 Jahren hinzugefügt
SL/DB/Invoice.pm | ||
---|---|---|
28 | 28 |
with_objects => [ 'part' ] |
29 | 29 |
} |
30 | 30 |
}, |
31 |
payment_term => { |
|
32 |
type => 'one to one', |
|
33 |
class => 'SL::DB::PaymentTerm', |
|
34 |
column_map => { payment_id => 'id' }, |
|
35 |
}, |
|
36 |
contact => { |
|
37 |
type => 'one to one', |
|
38 |
class => 'SL::DB::Contact', |
|
39 |
column_map => { cp_id => 'cp_id' }, |
|
40 |
}, |
|
41 |
shipto => { |
|
42 |
type => 'one to one', |
|
43 |
class => 'SL::DB::Shipto', |
|
44 |
column_map => { shipto_id => 'shipto_id' }, |
|
45 |
}, |
|
46 |
department => { |
|
47 |
type => 'one to one', |
|
48 |
class => 'SL::DB::Department', |
|
49 |
column_map => { department_id => 'id' }, |
|
50 |
}, |
|
51 |
language => { |
|
52 |
type => 'one to one', |
|
53 |
class => 'SL::DB::Language', |
|
54 |
column_map => { language_id => 'id' }, |
|
55 |
}, |
|
56 |
employee => { |
|
57 |
type => 'one to one', |
|
58 |
class => 'SL::DB::Employee', |
|
59 |
column_map => { employee_id => 'id' }, |
|
60 |
}, |
|
61 | 31 |
); |
62 | 32 |
|
63 | 33 |
__PACKAGE__->meta->initialize; |
64 | 34 |
|
65 | 35 |
# methods |
66 | 36 |
|
67 |
sub items { goto &invoiceitems; } |
|
37 |
sub items { goto &invoiceitems; } |
|
38 |
sub payment_term { goto &payment; } |
|
68 | 39 |
|
69 | 40 |
# it is assumed, that ordnumbers are unique here. |
70 | 41 |
sub first_order_by_ordnumber { |
SL/DB/MetaSetup/Invoice.pm | ||
---|---|---|
32 | 32 |
quonumber => { type => 'text' }, |
33 | 33 |
cusordnumber => { type => 'text' }, |
34 | 34 |
intnotes => { type => 'text' }, |
35 |
department_id => { type => 'integer', default => '0' },
|
|
35 |
department_id => { type => 'integer' }, |
|
36 | 36 |
shipvia => { type => 'text' }, |
37 | 37 |
itime => { type => 'timestamp', default => 'now()' }, |
38 | 38 |
mtime => { type => 'timestamp' }, |
... | ... | |
64 | 64 |
allow_inline_column_values => 1, |
65 | 65 |
|
66 | 66 |
foreign_keys => [ |
67 |
contact => { |
|
68 |
class => 'SL::DB::Contact', |
|
69 |
key_columns => { cp_id => 'cp_id' }, |
|
70 |
}, |
|
71 |
|
|
67 | 72 |
customer => { |
68 | 73 |
class => 'SL::DB::Customer', |
69 | 74 |
key_columns => { customer_id => 'id' }, |
70 | 75 |
}, |
71 | 76 |
|
77 |
department => { |
|
78 |
class => 'SL::DB::Department', |
|
79 |
key_columns => { department_id => 'id' }, |
|
80 |
}, |
|
81 |
|
|
72 | 82 |
dunning_config => { |
73 | 83 |
class => 'SL::DB::DunningConfig', |
74 | 84 |
key_columns => { dunning_config_id => 'id' }, |
75 | 85 |
}, |
76 | 86 |
|
87 |
employee => { |
|
88 |
class => 'SL::DB::Employee', |
|
89 |
key_columns => { employee_id => 'id' }, |
|
90 |
}, |
|
91 |
|
|
77 | 92 |
globalproject => { |
78 | 93 |
class => 'SL::DB::Project', |
79 | 94 |
key_columns => { globalproject_id => 'id' }, |
80 | 95 |
}, |
81 | 96 |
|
97 |
language => { |
|
98 |
class => 'SL::DB::Language', |
|
99 |
key_columns => { language_id => 'id' }, |
|
100 |
}, |
|
101 |
|
|
102 |
payment => { |
|
103 |
class => 'SL::DB::PaymentTerm', |
|
104 |
key_columns => { payment_id => 'id' }, |
|
105 |
}, |
|
106 |
|
|
82 | 107 |
salesman => { |
83 | 108 |
class => 'SL::DB::Employee', |
84 | 109 |
key_columns => { salesman_id => 'id' }, |
85 | 110 |
}, |
86 | 111 |
|
112 |
shipto => { |
|
113 |
class => 'SL::DB::Shipto', |
|
114 |
key_columns => { shipto_id => 'shipto_id' }, |
|
115 |
}, |
|
116 |
|
|
87 | 117 |
storno_obj => { |
88 | 118 |
class => 'SL::DB::Invoice', |
89 | 119 |
key_columns => { storno_id => 'id' }, |
SL/DB/MetaSetup/PurchaseInvoice.pm | ||
---|---|---|
28 | 28 |
employee_id => { type => 'integer' }, |
29 | 29 |
quonumber => { type => 'text' }, |
30 | 30 |
intnotes => { type => 'text' }, |
31 |
department_id => { type => 'integer', default => '0' },
|
|
31 |
department_id => { type => 'integer' }, |
|
32 | 32 |
itime => { type => 'timestamp', default => 'now()' }, |
33 | 33 |
mtime => { type => 'timestamp' }, |
34 | 34 |
shipvia => { type => 'text' }, |
... | ... | |
50 | 50 |
allow_inline_column_values => 1, |
51 | 51 |
|
52 | 52 |
foreign_keys => [ |
53 |
contact => { |
|
54 |
class => 'SL::DB::Contact', |
|
55 |
key_columns => { cp_id => 'cp_id' }, |
|
56 |
}, |
|
57 |
|
|
58 |
department => { |
|
59 |
class => 'SL::DB::Department', |
|
60 |
key_columns => { department_id => 'id' }, |
|
61 |
}, |
|
62 |
|
|
63 |
employee => { |
|
64 |
class => 'SL::DB::Employee', |
|
65 |
key_columns => { employee_id => 'id' }, |
|
66 |
}, |
|
67 |
|
|
53 | 68 |
globalproject => { |
54 | 69 |
class => 'SL::DB::Project', |
55 | 70 |
key_columns => { globalproject_id => 'id' }, |
56 | 71 |
}, |
57 | 72 |
|
73 |
language => { |
|
74 |
class => 'SL::DB::Language', |
|
75 |
key_columns => { language_id => 'id' }, |
|
76 |
}, |
|
77 |
|
|
78 |
payment => { |
|
79 |
class => 'SL::DB::PaymentTerm', |
|
80 |
key_columns => { payment_id => 'id' }, |
|
81 |
}, |
|
82 |
|
|
58 | 83 |
storno_obj => { |
59 | 84 |
class => 'SL::DB::PurchaseInvoice', |
60 | 85 |
key_columns => { storno_id => 'id' }, |
SL/DB/PurchaseInvoice.pm | ||
---|---|---|
17 | 17 |
|
18 | 18 |
__PACKAGE__->meta->initialize; |
19 | 19 |
|
20 |
sub items { goto &invoiceitems; } |
|
20 |
sub items { goto &invoiceitems; } |
|
21 |
sub payment_term { goto &payment; } |
|
21 | 22 |
|
22 | 23 |
1; |
sql/Pg-upgrade2/ar_ap_foreign_keys.sql | ||
---|---|---|
1 |
-- @tag: ar_ap_foreign_keys |
|
2 |
-- @description: Fremdschlüsselverweise für diverse Spalten in ar und ap |
|
3 |
-- @depends: release_3_0_0 |
|
4 |
-- @charset: utf-8 |
|
5 |
ALTER TABLE ar ALTER COLUMN department_id DROP DEFAULT; |
|
6 |
ALTER TABLE ap ALTER COLUMN department_id DROP DEFAULT; |
|
7 |
|
|
8 |
UPDATE ar SET cp_id = NULL WHERE (cp_id IS NOT NULL) AND (cp_id NOT IN (SELECT cp_id FROM contacts)); |
|
9 |
UPDATE ar SET department_id = NULL WHERE (department_id IS NOT NULL) AND (department_id NOT IN (SELECT id FROM department)); |
|
10 |
UPDATE ar SET employee_id = NULL WHERE (employee_id IS NOT NULL) AND (employee_id NOT IN (SELECT id FROM employee)); |
|
11 |
UPDATE ar SET language_id = NULL WHERE (language_id IS NOT NULL) AND (language_id NOT IN (SELECT id FROM language)); |
|
12 |
UPDATE ar SET payment_id = NULL WHERE (payment_id IS NOT NULL) AND (payment_id NOT IN (SELECT id FROM payment_terms)); |
|
13 |
UPDATE ar SET shipto_id = NULL WHERE (shipto_id IS NOT NULL) AND (shipto_id NOT IN (SELECT shipto_id FROM shipto)); |
|
14 |
|
|
15 |
UPDATE ap SET cp_id = NULL WHERE (cp_id IS NOT NULL) AND (cp_id NOT IN (SELECT cp_id FROM contacts)); |
|
16 |
UPDATE ap SET department_id = NULL WHERE (department_id IS NOT NULL) AND (department_id NOT IN (SELECT id FROM department)); |
|
17 |
UPDATE ap SET employee_id = NULL WHERE (employee_id IS NOT NULL) AND (employee_id NOT IN (SELECT id FROM employee)); |
|
18 |
UPDATE ap SET language_id = NULL WHERE (language_id IS NOT NULL) AND (language_id NOT IN (SELECT id FROM language)); |
|
19 |
UPDATE ap SET payment_id = NULL WHERE (payment_id IS NOT NULL) AND (payment_id NOT IN (SELECT id FROM payment_terms)); |
|
20 |
|
|
21 |
ALTER TABLE ar ADD FOREIGN KEY (cp_id) REFERENCES contacts (cp_id); |
|
22 |
ALTER TABLE ar ADD FOREIGN KEY (department_id) REFERENCES department (id); |
|
23 |
ALTER TABLE ar ADD FOREIGN KEY (employee_id) REFERENCES employee (id); |
|
24 |
ALTER TABLE ar ADD FOREIGN KEY (language_id) REFERENCES language (id); |
|
25 |
ALTER TABLE ar ADD FOREIGN KEY (payment_id) REFERENCES payment_terms (id); |
|
26 |
ALTER TABLE ar ADD FOREIGN KEY (shipto_id) REFERENCES shipto (shipto_id); |
|
27 |
|
|
28 |
ALTER TABLE ap ADD FOREIGN KEY (cp_id) REFERENCES contacts (cp_id); |
|
29 |
ALTER TABLE ap ADD FOREIGN KEY (employee_id) REFERENCES employee (id); |
|
30 |
ALTER TABLE ap ADD FOREIGN KEY (department_id) REFERENCES department (id); |
|
31 |
ALTER TABLE ap ADD FOREIGN KEY (language_id) REFERENCES language (id); |
|
32 |
ALTER TABLE ap ADD FOREIGN KEY (payment_id) REFERENCES payment_terms (id); |
Auch abrufbar als: Unified diff
Diverse Fremdschlüssel für Tabellen ar und ap