Bug 24151: Add items.homebranch to the list
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 17 Mar 2020 16:36:05 +0000 (17:36 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 20 Jul 2020 13:17:42 +0000 (15:17 +0200)
Signed-off-by: Signed-off-by: Sonia Bouis <sonia.bouis@univ-lyon3.fr>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Koha/PseudonymizedTransaction.pm
installer/data/mysql/atomicupdate/bug_24151.perl
installer/data/mysql/kohastructure.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
t/db_dependent/Koha/Pseudonymization.t

index c5b0e88..c7802dc 100644 (file)
@@ -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;
index 62fd64d..f5a83d2 100644 (file)
@@ -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' ) ) {
index 04bd714..ba71898 100644 (file)
@@ -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,
index 1f15cf2..0aba117 100644 (file)
@@ -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"
index 4e29dcb..0124e08 100644 (file)
@@ -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 );