X-Git-Url: http://wagnertech.de/git?p=kivitendo-erp.git;a=blobdiff_plain;f=SL%2FDB%2FCustomer.pm;fp=SL%2FDB%2FCustomer.pm;h=d72d0c91ac9f4abf9fcd1b6c6a6b5b7a00dc678c;hp=71c762a5e96327d161eae2ba823336cbd8e7c01a;hb=b293ff8ad52fc76ba0c44783e3982418114d6b08;hpb=d4925a8b60f04674885e30d9316dc0263f8b9a84 diff --git a/SL/DB/Customer.pm b/SL/DB/Customer.pm index 71c762a5e..d72d0c91a 100644 --- a/SL/DB/Customer.pm +++ b/SL/DB/Customer.pm @@ -2,6 +2,7 @@ package SL::DB::Customer; use strict; +use List::Util qw(first); use Rose::DB::Object::Helpers qw(as_tree); use SL::Locale::String qw(t8); @@ -29,6 +30,12 @@ use SL::DB::Helper::DisplayableNamePreferences ( use SL::DB::VC; __PACKAGE__->meta->add_relationship( + additional_billing_addresses => { + type => 'one to many', + class => 'SL::DB::AdditionalBillingAddress', + column_map => { id => 'customer_id' }, + manager_args => { sort_by => 'lower(additional_billing_addresses.name)' }, + }, shipto => { type => 'one to many', class => 'SL::DB::Shipto', @@ -108,4 +115,11 @@ sub create_zugferd_invoices_for_this_customer { return $self->create_zugferd_invoices; } +sub default_billing_address { + my $self = shift; + + die 'not an accessor' if @_ > 1; + return first { $_->default_address } @{ $self->additional_billing_addresses }; +} + 1;