Revision 81cafff7
Von Moritz Bunkus vor etwa 3 Jahren hinzugefügt
SL/DB/AdditionalBillingAddress.pm | ||
---|---|---|
1 |
package SL::DB::AdditionalBillingAddress; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::MetaSetup::AdditionalBillingAddress; |
|
6 |
use SL::DB::Manager::AdditionalBillingAddress; |
|
7 |
|
|
8 |
__PACKAGE__->meta->initialize; |
|
9 |
|
|
10 |
sub displayable_id { |
|
11 |
my $self = shift; |
|
12 |
my $text = join('; ', grep { $_ } (map({ $self->$_ } qw(name street)), |
|
13 |
join(' ', grep { $_ } |
|
14 |
map { $self->$_ } |
|
15 |
qw(zipcode city)))); |
|
16 |
|
|
17 |
return $text; |
|
18 |
} |
|
19 |
|
|
20 |
sub used { |
|
21 |
my ($self) = @_; |
|
22 |
|
|
23 |
return unless $self->id; |
|
24 |
|
|
25 |
require SL::DB::Order; |
|
26 |
require SL::DB::Invoice; |
|
27 |
require SL::DB::DeliveryOrder; |
|
28 |
|
|
29 |
my %args = (query => [ billing_address_id => $self->id ]); |
|
30 |
|
|
31 |
return SL::DB::Manager::Invoice->get_all_count(%args) |
|
32 |
|| SL::DB::Manager::Order->get_all_count(%args) |
|
33 |
|| SL::DB::Manager::DeliveryOrder->get_all_count(%args); |
|
34 |
} |
|
35 |
|
|
36 |
sub detach { |
|
37 |
$_[0]->customer_id(undef); |
|
38 |
return $_[0]; |
|
39 |
} |
|
40 |
|
|
41 |
1; |
SL/DB/Customer.pm | ||
---|---|---|
29 | 29 |
use SL::DB::VC; |
30 | 30 |
|
31 | 31 |
__PACKAGE__->meta->add_relationship( |
32 |
additional_billing_addresses => { |
|
33 |
type => 'one to many', |
|
34 |
class => 'SL::DB::AdditionalBillingAddress', |
|
35 |
column_map => { id => 'customer_id' }, |
|
36 |
manager_args => { sort_by => 'lower(additional_billing_addresses.name)' }, |
|
37 |
}, |
|
32 | 38 |
shipto => { |
33 | 39 |
type => 'one to many', |
34 | 40 |
class => 'SL::DB::Shipto', |
SL/DB/Helper/ALL.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
|
5 | 5 |
use SL::DB::AccTransaction; |
6 |
use SL::DB::AdditionalBillingAddress; |
|
6 | 7 |
use SL::DB::Assembly; |
7 | 8 |
use SL::DB::AssortmentItem; |
8 | 9 |
use SL::DB::AuthClient; |
SL/DB/Helper/Mappings.pm | ||
---|---|---|
84 | 84 |
my %kivitendo_package_names = ( |
85 | 85 |
# TABLE # MODEL (given in C style) |
86 | 86 |
acc_trans => 'acc_transaction', |
87 |
additional_billing_addresses => 'additional_billing_address', |
|
87 | 88 |
'auth.clients' => 'auth_client', |
88 | 89 |
'auth.clients_users' => 'auth_client_user', |
89 | 90 |
'auth.clients_groups' => 'auth_client_group', |
SL/DB/Manager/AdditionalBillingAddress.pm | ||
---|---|---|
1 |
# This file has been auto-generated only because it didn't exist. |
|
2 |
# Feel free to modify it at will; it will not be overwritten automatically. |
|
3 |
|
|
4 |
package SL::DB::Manager::AdditionalBillingAddress; |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
use parent qw(SL::DB::Helper::Manager); |
|
9 |
|
|
10 |
sub object_class { 'SL::DB::AdditionalBillingAddress' } |
|
11 |
|
|
12 |
__PACKAGE__->make_manager_methods; |
|
13 |
|
|
14 |
1; |
SL/DB/MetaSetup/AdditionalBillingAddress.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::AdditionalBillingAddress; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use parent qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->table('additional_billing_addresses'); |
|
10 |
|
|
11 |
__PACKAGE__->meta->columns( |
|
12 |
city => { type => 'text' }, |
|
13 |
contact => { type => 'text' }, |
|
14 |
country => { type => 'text' }, |
|
15 |
customer_id => { type => 'integer' }, |
|
16 |
default_address => { type => 'boolean', default => 'false', not_null => 1 }, |
|
17 |
department_1 => { type => 'text' }, |
|
18 |
department_2 => { type => 'text' }, |
|
19 |
email => { type => 'text' }, |
|
20 |
fax => { type => 'text' }, |
|
21 |
gln => { type => 'text' }, |
|
22 |
id => { type => 'serial', not_null => 1 }, |
|
23 |
itime => { type => 'timestamp', default => 'now()', not_null => 1 }, |
|
24 |
mtime => { type => 'timestamp', default => 'now()', not_null => 1 }, |
|
25 |
name => { type => 'text' }, |
|
26 |
phone => { type => 'text' }, |
|
27 |
street => { type => 'text' }, |
|
28 |
zipcode => { type => 'text' }, |
|
29 |
); |
|
30 |
|
|
31 |
__PACKAGE__->meta->primary_key_columns([ 'id' ]); |
|
32 |
|
|
33 |
__PACKAGE__->meta->allow_inline_column_values(1); |
|
34 |
|
|
35 |
__PACKAGE__->meta->foreign_keys( |
|
36 |
customer => { |
|
37 |
class => 'SL::DB::Customer', |
|
38 |
key_columns => { customer_id => 'id' }, |
|
39 |
}, |
|
40 |
); |
|
41 |
|
|
42 |
1; |
|
43 |
; |
SL/DB/MetaSetup/DeliveryOrder.pm | ||
---|---|---|
9 | 9 |
__PACKAGE__->meta->table('delivery_orders'); |
10 | 10 |
|
11 | 11 |
__PACKAGE__->meta->columns( |
12 |
billing_address_id => { type => 'integer' }, |
|
12 | 13 |
closed => { type => 'boolean', default => 'false' }, |
13 | 14 |
cp_id => { type => 'integer' }, |
14 | 15 |
currency_id => { type => 'integer', not_null => 1 }, |
... | ... | |
48 | 49 |
__PACKAGE__->meta->allow_inline_column_values(1); |
49 | 50 |
|
50 | 51 |
__PACKAGE__->meta->foreign_keys( |
52 |
billing_address => { |
|
53 |
class => 'SL::DB::AdditionalBillingAddress', |
|
54 |
key_columns => { billing_address_id => 'id' }, |
|
55 |
}, |
|
56 |
|
|
51 | 57 |
contact => { |
52 | 58 |
class => 'SL::DB::Contact', |
53 | 59 |
key_columns => { cp_id => 'cp_id' }, |
SL/DB/MetaSetup/Invoice.pm | ||
---|---|---|
10 | 10 |
|
11 | 11 |
__PACKAGE__->meta->columns( |
12 | 12 |
amount => { type => 'numeric', default => '0', not_null => 1, precision => 15, scale => 5 }, |
13 |
billing_address_id => { type => 'integer' }, |
|
13 | 14 |
cp_id => { type => 'integer' }, |
14 | 15 |
currency_id => { type => 'integer', not_null => 1 }, |
15 | 16 |
cusordnumber => { type => 'text' }, |
... | ... | |
64 | 65 |
__PACKAGE__->meta->allow_inline_column_values(1); |
65 | 66 |
|
66 | 67 |
__PACKAGE__->meta->foreign_keys( |
68 |
billing_address => { |
|
69 |
class => 'SL::DB::AdditionalBillingAddress', |
|
70 |
key_columns => { billing_address_id => 'id' }, |
|
71 |
}, |
|
72 |
|
|
67 | 73 |
contact => { |
68 | 74 |
class => 'SL::DB::Contact', |
69 | 75 |
key_columns => { cp_id => 'cp_id' }, |
SL/DB/MetaSetup/Order.pm | ||
---|---|---|
10 | 10 |
|
11 | 11 |
__PACKAGE__->meta->columns( |
12 | 12 |
amount => { type => 'numeric', precision => 15, scale => 5 }, |
13 |
billing_address_id => { type => 'integer' }, |
|
13 | 14 |
closed => { type => 'boolean', default => 'false' }, |
14 | 15 |
cp_id => { type => 'integer' }, |
15 | 16 |
currency_id => { type => 'integer', not_null => 1 }, |
... | ... | |
57 | 58 |
__PACKAGE__->meta->allow_inline_column_values(1); |
58 | 59 |
|
59 | 60 |
__PACKAGE__->meta->foreign_keys( |
61 |
billing_address => { |
|
62 |
class => 'SL::DB::AdditionalBillingAddress', |
|
63 |
key_columns => { billing_address_id => 'id' }, |
|
64 |
}, |
|
65 |
|
|
60 | 66 |
contact => { |
61 | 67 |
class => 'SL::DB::Contact', |
62 | 68 |
key_columns => { cp_id => 'cp_id' }, |
sql/Pg-upgrade2/customer_additional_billing_addresses.sql | ||
---|---|---|
1 |
-- @tag: customer_additional_billing_addresses |
|
2 |
-- @description: Kundenstammdaten: zusätzliche Rechnungsadressen |
|
3 |
-- @depends: release_3_5_8 |
|
4 |
CREATE TABLE additional_billing_addresses ( |
|
5 |
id SERIAL, |
|
6 |
customer_id INTEGER, |
|
7 |
name TEXT, |
|
8 |
department_1 TEXT, |
|
9 |
department_2 TEXT, |
|
10 |
contact TEXT, |
|
11 |
street TEXT, |
|
12 |
zipcode TEXT, |
|
13 |
city TEXT, |
|
14 |
country TEXT, |
|
15 |
gln TEXT, |
|
16 |
email TEXT, |
|
17 |
phone TEXT, |
|
18 |
fax TEXT, |
|
19 |
default_address BOOLEAN NOT NULL DEFAULT FALSE, |
|
20 |
|
|
21 |
itime TIMESTAMP NOT NULL DEFAULT now(), |
|
22 |
mtime TIMESTAMP NOT NULL DEFAULT now(), |
|
23 |
|
|
24 |
PRIMARY KEY (id), |
|
25 |
FOREIGN KEY (customer_id) REFERENCES customer (id) |
|
26 |
); |
|
27 |
|
|
28 |
CREATE TRIGGER mtime_additional_billing_addresses |
|
29 |
BEFORE UPDATE ON additional_billing_addresses |
|
30 |
FOR EACH ROW EXECUTE PROCEDURE set_mtime(); |
|
31 |
|
|
32 |
ALTER TABLE oe |
|
33 |
ADD COLUMN billing_address_id INTEGER, |
|
34 |
ADD FOREIGN KEY (billing_address_id) |
|
35 |
REFERENCES additional_billing_addresses (id); |
|
36 |
|
|
37 |
ALTER TABLE delivery_orders |
|
38 |
ADD COLUMN billing_address_id INTEGER, |
|
39 |
ADD FOREIGN KEY (billing_address_id) |
|
40 |
REFERENCES additional_billing_addresses (id); |
|
41 |
|
|
42 |
ALTER TABLE ar |
|
43 |
ADD COLUMN billing_address_id INTEGER, |
|
44 |
ADD FOREIGN KEY (billing_address_id) |
|
45 |
REFERENCES additional_billing_addresses (id); |
Auch abrufbar als: Unified diff
Zusätzliche Rechnungsadressen: Datenbankupgrade, MetaSetup, Rose-Models