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.
4 package SL::DB::BankAccount;
8 use SL::DB::MetaSetup::BankAccount;
9 use SL::DB::Manager::BankAccount;
10 use SL::DB::Helper::ActsAsList;
12 __PACKAGE__->meta->initialize;
19 if ( not $self->{chart_id} ) {
20 push @errors, $::locale->text('There is no connected chart.');
22 # check whether the assigned chart is valid or is already being used by
23 # another bank account (there is also a UNIQUE database constraint on
26 my $chart_id = $self->chart_id;
27 require SL::DB::Chart;
28 my $chart = SL::DB::Manager::Chart->find_by( id => $chart_id );
30 my $linked_bank = SL::DB::Manager::BankAccount->find_by( chart_id => $chart_id );
32 if ( not $self->{id} or ( $self->{id} && $linked_bank->id != $self->{id} )) {
33 push @errors, $::locale->text('The account #1 is already being used by bank account #2.', $chart->displayable_name, $linked_bank->{name});
37 push @errors, $::locale->text('The chart is not valid.');
41 push @errors, $::locale->text('The IBAN is missing.') unless $self->{iban};
46 sub displayable_name {
49 return join ' ', grep $_, $self->name, $self->bank, $self->iban;