Bug 27045: Fix other exports using CSV profiles
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 20 Nov 2020 14:33:14 +0000 (15:33 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Wed, 20 Jul 2022 14:50:40 +0000 (11:50 -0300)
This patch corrects the export of the 2 other reports
using CSV profiles:

* Late issues (serials)
* Basket (acquisitions)

To test:
1) Late issues
* Update the late issues sample report to use tab as separator
* Create a subscription
* Go to serial collection and 'generate next' to get some late issues
* Go to Claims
* Export the late issues and verify format is correct
* Verify exported file has tabs

2) Basket summary
* Create an order with several order lines
* Create an SQL type CSV profile for basket export using tab as separator
  Example: aqorders.quantity|aqordres.listprice|Title=biblio.title
* Export the basket using your configured CSV profile
* Verify exported file has tabs

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
C4/Acquisition.pm
serials/lateissues-export.pl

index 76b6e64..830436b 100644 (file)
@@ -276,7 +276,9 @@ sub GetBasketAsCSV {
         my $csv_profile = Koha::CsvProfiles->find( $csv_profile_id );
         Koha::Exceptions::ObjectNotFound->throw( 'There is no valid csv profile given') unless $csv_profile;
 
-        my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$csv_profile->csv_separator,'binary'=>1});
+        my $delimiter = $csv_profile->csv_separator;
+        $delimiter = "\t" if $delimiter eq "\\t";
+        my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$delimiter,'binary'=>1});
         my $csv_profile_content = $csv_profile->content;
         my ( @headers, @fields );
         while ( $csv_profile_content =~ /
index f20cdbe..de09d4c 100755 (executable)
@@ -35,10 +35,13 @@ my $csv_profile_id = $query->param('csv_profile');
 my $csv_profile = Koha::CsvProfiles->find( $csv_profile_id );
 die "There is no valid csv profile given" unless $csv_profile;
 
+my $delimiter = $csv_profile->csv_separator;
+$delimiter = "\t" if $delimiter eq "\\t";
+
 my $csv = Text::CSV_XS->new({
     'quote_char'  => '"',
     'escape_char' => '"',
-    'sep_char'    => $csv_profile->csv_separator,
+    'sep_char'    => $delimiter,
     'binary'      => 1
 });