projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #34 from kivitendo/warengruppen_pflichtfeld
[kivitendo-erp.git]
/
SL
/
DB
/
Customer.pm
diff --git
a/SL/DB/Customer.pm
b/SL/DB/Customer.pm
index
71c762a
..
d72d0c9
100644
(file)
--- a/
SL/DB/Customer.pm
+++ b/
SL/DB/Customer.pm
@@
-2,6
+2,7
@@
package SL::DB::Customer;
use strict;
use strict;
+use List::Util qw(first);
use Rose::DB::Object::Helpers qw(as_tree);
use SL::Locale::String qw(t8);
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(
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',
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;
}
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;
1;