Revision 4fef0591
Von Bernd Bleßmann vor fast 8 Jahren hinzugefügt
SL/Controller/BankImport.pm | ||
---|---|---|
7 | 7 |
use SL::DB::CsvImportProfile; |
8 | 8 |
use SL::Helper::MT940; |
9 | 9 |
|
10 |
use Rose::Object::MakeMethods::Generic |
|
11 |
( |
|
12 |
'scalar --get_set_init' => [ qw(profile) ], |
|
13 |
); |
|
14 |
|
|
10 | 15 |
__PACKAGE__->run_before('check_auth'); |
11 | 16 |
|
12 | 17 |
sub action_upload_mt940 { |
13 | 18 |
my ($self, %params) = @_; |
14 | 19 |
|
15 |
my $profile = SL::DB::Manager::CsvImportProfile->find_by(name => 'MT940', login => $::myconfig{login}); |
|
16 |
if ( ! $profile ) { |
|
17 |
$profile = SL::DB::Manager::CsvImportProfile->find_by(name => 'MT940', login => 'default'); |
|
18 |
} |
|
19 |
|
|
20 | 20 |
$self->setup_upload_mt940_action_bar; |
21 |
$self->render('bankimport/form', title => $::locale->text('MT940 import'), profile => $profile ? 1 : 0); |
|
21 |
$self->render('bankimport/form', title => $::locale->text('MT940 import'), profile => $self->profile ? 1 : 0);
|
|
22 | 22 |
} |
23 | 23 |
|
24 | 24 |
sub action_import_mt940 { |
... | ... | |
33 | 33 |
$file->fh->print($converted_data); |
34 | 34 |
$file->fh->close; |
35 | 35 |
|
36 |
my $profile = SL::DB::Manager::CsvImportProfile->find_by(name => 'MT940', login => $::myconfig{login}); |
|
37 |
if ( ! $profile ) { |
|
38 |
$profile = SL::DB::Manager::CsvImportProfile->find_by(name => 'MT940', login => 'default'); |
|
39 |
} |
|
40 |
die t8("The MT940 import needs an import profile called MT940") unless $profile; |
|
36 |
die t8("The MT940 import needs an import profile called MT940") unless $self->profile; |
|
41 | 37 |
|
42 |
$self->redirect_to(controller => 'controller.pl', action => 'CsvImport/test', 'profile.type' => 'bank_transactions', 'profile.id' => $profile->id, force_profile => 1); |
|
38 |
$self->redirect_to(controller => 'controller.pl', action => 'CsvImport/test', 'profile.type' => 'bank_transactions', 'profile.id' => $self->profile->id, force_profile => 1);
|
|
43 | 39 |
} |
44 | 40 |
|
45 | 41 |
sub check_auth { |
46 | 42 |
$::auth->assert('bank_transaction'); |
47 | 43 |
} |
48 | 44 |
|
45 |
sub init_profile { |
|
46 |
my $profile = SL::DB::Manager::CsvImportProfile->find_by(name => 'MT940', login => $::myconfig{login}); |
|
47 |
if ( ! $profile ) { |
|
48 |
$profile = SL::DB::Manager::CsvImportProfile->find_by(name => 'MT940', login => 'default'); |
|
49 |
} |
|
50 |
return $profile; |
|
51 |
} |
|
52 |
|
|
49 | 53 |
sub setup_upload_mt940_action_bar { |
50 | 54 |
my ($self) = @_; |
51 | 55 |
|
Auch abrufbar als: Unified diff
BankImport: Refactoring: Profil über init-Methode laden.