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     my $chart = SL::DB::Chart->new( id => $chart_id );
 
  28     if ( $chart->load(speculative => 1) ) {
 
  29       my $linked_bank = SL::DB::Manager::BankAccount->find_by( chart_id => $chart_id );
 
  31         if ( not $self->{id} or ( $self->{id} && $linked_bank->id != $self->{id} )) {
 
  32           push @errors, $::locale->text('The account #1 is already being used by bank account #2.', $chart->displayable_name, $linked_bank->{name});
 
  36       push @errors, $::locale->text('The chart is not valid.');
 
  40   push @errors, $::locale->text('The IBAN is missing.') unless $self->{iban};