From e1476578f20b1c1f84f2edf241dbb0d1eea565fe Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 1 Jun 2017 10:12:48 -0300 Subject: [PATCH] Bug 12598: Update code to use new modules Signed-off-by: Colin Campbell Signed-off-by: Jonathan Druart --- Koha/Patrons/Import.pm | 12 +++++++----- .../prog/en/modules/tools/import_borrowers.tt | 14 ++++---------- t/db_dependent/Koha/Patrons/Import.t | 6 ++++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm index 6b53c4bebc..9155c36b3c 100644 --- a/Koha/Patrons/Import.pm +++ b/Koha/Patrons/Import.pm @@ -23,10 +23,12 @@ use Carp; use Text::CSV; use C4::Members; -use C4::Branch; use C4::Members::Attributes qw(:all); use C4::Members::AttributeTypes; +use Koha::Libraries; +use Koha::Patrons; +use Koha::Patron::Categories; use Koha::DateUtils; =head1 NAME @@ -401,7 +403,7 @@ Returns an array of borrowers' table columns. sub set_column_keys { my ($self, $extended) = @_; - my @columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } C4::Members::columns(); + my @columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } Koha::Patrons->columns(); push( @columnkeys, 'patron_attributes' ) if $extended; return @columnkeys; @@ -450,8 +452,8 @@ sub check_branch_code { } # look for branch code - my $branch_name = GetBranchName( $branchcode ); - unless( $branch_name ) { + my $library = Koha::Libraries->find( $branchcode ); + unless( $library ) { push (@$missing_criticals, { key => 'branchcode', line => $line_number, lineraw => $borrowerline, value => $branchcode, branch_map => 1, }); } @@ -475,7 +477,7 @@ sub check_borrower_category { } # Looking for borrower category - my $category = GetBorrowercategory( $categorycode ); + my $category = Koha::Patron::Categories->find($categorycode); unless( $category ) { push (@$missing_criticals, { key => 'categorycode', line => $line_number, lineraw => $borrowerline, value => $categorycode, category_map => 1, }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt index 7c53da864b..99894145e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt @@ -233,7 +233,10 @@ [% END %] -
+
+ + +
[% END %] @@ -274,15 +277,6 @@ you can supply dates in ISO format (e.g., '2010-10-28'). - - [% END %] -
- - -
- -[% END %] - diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t index 3c46ce2bf7..4e4bde49f5 100644 --- a/t/db_dependent/Koha/Patrons/Import.t +++ b/t/db_dependent/Koha/Patrons/Import.t @@ -392,17 +392,19 @@ subtest 'test_set_column_keys' => sub { subtest 'test_set_column_keys' => sub { plan tests => 2; + my @columns = Koha::Patrons->columns; # Given ... nothing at all # When ... Then ... my @columnkeys_0 = $patrons_import->set_column_keys(undef); - is(scalar @columnkeys_0, 66, 'Got the expected array size from set column keys with undef extended'); + # -1 because we do not want the borrowernumber column + is(scalar @columnkeys_0, @columns - 1, 'Got the expected array size from set column keys with undef extended'); # Given ... extended. my $extended = 1; # When ... Then ... my @columnkeys_1 = $patrons_import->set_column_keys($extended); - is(scalar @columnkeys_1, 67, 'Got the expected array size from set column keys with extended'); + is(scalar @columnkeys_1, @columns - 1 + $extended, 'Got the expected array size from set column keys with extended'); }; subtest 'test_set_patron_attributes' => sub { -- 2.39.5