From aa0b8cb96ae60037dcde6fd48ead0e14cc4205de Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 17 Mar 2020 17:36:05 +0100 Subject: [PATCH] Bug 24151: Add items.homebranch to the list Signed-off-by: Signed-off-by: Sonia Bouis Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- Koha/PseudonymizedTransaction.pm | 4 ++++ installer/data/mysql/atomicupdate/bug_24151.perl | 3 ++- installer/data/mysql/kohastructure.sql | 1 + .../prog/en/modules/admin/preferences/patrons.pref | 1 + t/db_dependent/Koha/Pseudonymization.t | 5 +++-- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Koha/PseudonymizedTransaction.pm b/Koha/PseudonymizedTransaction.pm index c5b0e8836f..c7802dc839 100644 --- a/Koha/PseudonymizedTransaction.pm +++ b/Koha/PseudonymizedTransaction.pm @@ -53,6 +53,9 @@ sub new_from_statistic { if ( grep { $_ eq 'holdingbranch' } @t_fields_to_copy ) { $values->{holdingbranch} = $statistic->item->holdingbranch; } + if ( grep { $_ eq 'homebranch' } @t_fields_to_copy ) { + $values->{homebranch} = $statistic->item->homebranch; + } if ( grep { $_ eq 'transaction_type' } @t_fields_to_copy ) { $values->{transaction_type} = $statistic->type; } @@ -64,6 +67,7 @@ sub new_from_statistic { @t_fields_to_copy = grep { $_ ne 'transaction_branchcode' && $_ ne 'holdingbranch' + && $_ ne 'homebranch' && $_ ne 'transaction_type' && $_ ne 'itemcallnumber' } @t_fields_to_copy; diff --git a/installer/data/mysql/atomicupdate/bug_24151.perl b/installer/data/mysql/atomicupdate/bug_24151.perl index 62fd64db9e..f5a83d2d29 100644 --- a/installer/data/mysql/atomicupdate/bug_24151.perl +++ b/installer/data/mysql/atomicupdate/bug_24151.perl @@ -23,6 +23,7 @@ if( CheckVersion( $DBversion ) ) { `itemnumber` int(11) default NULL, `itemtype` varchar(10) default NULL, `holdingbranch` varchar(10) default null, + `homebranch` varchar(10) default null, `location` varchar(80) default NULL, `itemcallnumber` varchar(255) default NULL, `ccode` varchar(80) default NULL, @@ -44,7 +45,7 @@ if( CheckVersion( $DBversion ) ) { |); $dbh->do(q| INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) - VALUES ('PseudonymizationTransactionFields','','datetime,transaction_branchcode,transaction_type,itemnumber,itemtype,holdingbranch,location,itemcallnumber,ccode','Transaction fields to copy to the pseudonymized_transactions table','multiple') + VALUES ('PseudonymizationTransactionFields','','datetime,transaction_branchcode,transaction_type,itemnumber,itemtype,holdingbranch,homebranch,location,itemcallnumber,ccode','Transaction fields to copy to the pseudonymized_transactions table','multiple') |); unless( TableExists( 'pseudonymized_borrower_attributes' ) ) { diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 04bd714648..ba718985b1 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1907,6 +1907,7 @@ CREATE TABLE `pseudonymized_transactions` ( `itemnumber` int(11) default NULL, `itemtype` varchar(10) default NULL, `holdingbranch` varchar(10) default null, + `homebranch` varchar(10) default null, `location` varchar(80) default NULL, `itemcallnumber` varchar(255) default NULL, `ccode` varchar(80) default NULL, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 1f15cf2cf7..0aba117e8d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -351,6 +351,7 @@ Patrons: itemnumber: "Itemnumber" itemtype: "Item type" holdingbranch: "Holding branch" + homebranch: "Home branch" location: "Location" itemcallnumber: "Item's callnumber" ccode: "Collection code" diff --git a/t/db_dependent/Koha/Pseudonymization.t b/t/db_dependent/Koha/Pseudonymization.t index 4e29dcbd47..0124e08475 100644 --- a/t/db_dependent/Koha/Pseudonymization.t +++ b/t/db_dependent/Koha/Pseudonymization.t @@ -73,7 +73,7 @@ subtest 'Config does not exist' => sub { subtest 'Koha::Anonymized::Transactions tests' => sub { - plan tests => 11; + plan tests => 12; $schema->storage->txn_begin; @@ -92,7 +92,7 @@ subtest 'Koha::Anonymized::Transactions tests' => sub { 'No pseudonymized transaction if Pseudonymization is off' ); t::lib::Mocks::mock_preference( 'Pseudonymization', 1 ); - t::lib::Mocks::mock_preference( 'PseudonymizationTransactionFields', 'datetime,transaction_branchcode,transaction_type,itemnumber,itemtype,holdingbranch,location,itemcallnumber,ccode' + t::lib::Mocks::mock_preference( 'PseudonymizationTransactionFields', 'datetime,transaction_branchcode,transaction_type,itemnumber,itemtype,holdingbranch,homebranch,location,itemcallnumber,ccode' ); $item = $builder->build_sample_item; t::lib::Mocks::mock_userenv({ branchcode => $item->homebranch }); @@ -108,6 +108,7 @@ subtest 'Koha::Anonymized::Transactions tests' => sub { is( $pseudonymized->itemnumber, $item->itemnumber ); is( $pseudonymized->itemtype, $item->effective_itemtype ); is( $pseudonymized->holdingbranch, $item->holdingbranch ); + is( $pseudonymized->homebranch, $item->homebranch ); is( $pseudonymized->location, $item->location ); is( $pseudonymized->itemcallnumber, $item->itemcallnumber ); is( $pseudonymized->ccode, $item->ccode ); -- 2.39.5