Zahlen beim CSV-Export ohne Tausendertrennzeichen formatieren
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 27 Dec 2010 15:23:34 +0000 (16:23 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 27 Dec 2010 15:23:46 +0000 (16:23 +0100)
Fix für Bug 1393.

16 files changed:
SL/Locale.pm
bin/mozilla/ap.pl
bin/mozilla/ar.pl
bin/mozilla/bankaccounts.pl
bin/mozilla/ca.pl
bin/mozilla/ct.pl
bin/mozilla/do.pl
bin/mozilla/fu.pl
bin/mozilla/gl.pl
bin/mozilla/ic.pl
bin/mozilla/oe.pl
bin/mozilla/projects.pl
bin/mozilla/rp.pl
bin/mozilla/sepa.pl
bin/mozilla/vk.pl
bin/mozilla/wh.pl

index 4fde616..b1c8205 100644 (file)
@@ -480,4 +480,19 @@ sub with_raw_io {
   $self->{raw_io_active} = 0;
 }
 
+sub set_numberformat_wo_thousands_separator {
+  my $self     = shift;
+  my $myconfig = shift || \%::myconfig;
+
+  $self->{saved_numberformat} = $myconfig->{numberformat};
+  $myconfig->{numberformat}   =~ s/^1[,\.]/1/;
+}
+
+sub restore_numberformat {
+  my $self     = shift;
+  my $myconfig = shift || \%::myconfig;
+
+  $myconfig->{numberformat} = $self->{saved_numberformat} if $self->{saved_numberformat};
+}
+
 1;
index 8b32585..06541ef 100644 (file)
@@ -1342,6 +1342,7 @@ sub ap_transactions {
                        'attachment_basename'  => $locale->text('vendor_invoice_list') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort and escape callback, this one we use for the add sub
   $form->{callback} = $href .= "&sort=$form->{sort}";
index f0c3f4f..e2777bd 100644 (file)
@@ -1440,6 +1440,7 @@ sub ar_transactions {
                        'attachment_basename'  => $locale->text('invoice_list') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort and escape callback, this one we use for the add sub
   $form->{callback} = $href .= "&sort=$form->{sort}";
index 0815954..f8bbb3a 100644 (file)
@@ -1,5 +1,6 @@
 use strict;
 
+use List::MoreUtils qw(any);
 use POSIX qw(strftime);
 
 use SL::BankAccount;
@@ -125,6 +126,7 @@ sub bank_account_list {
                        'attachment_basename'   => $locale->text('bankaccounts') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
index a58ac1e..31c77da 100644 (file)
@@ -106,6 +106,7 @@ sub chart_of_accounts {
                        'std_column_visibility' => 1,
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
@@ -593,6 +594,7 @@ sub list_transactions {
                        'std_column_visibility' => 1,
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
index 4476411..63aa831 100644 (file)
@@ -208,6 +208,7 @@ sub list_names {
                        'attachment_basename'   => $attachment_basename . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
index 0d5941c..cde1c60 100644 (file)
@@ -551,6 +551,7 @@ sub orders {
                        'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort and escape callback, this one we use for the add sub
   $form->{callback} = $href .= "&sort=$form->{sort}";
index ac9e81f..ec32241 100644 (file)
@@ -300,6 +300,7 @@ sub report {
                        'attachment_basename'  => $locale->text('follow_up_list') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   my $idx      = 0;
   my $callback = build_std_url('action=report', grep { $form->{$_} } @report_params);
index f7810c7..e642f7e 100644 (file)
@@ -541,6 +541,7 @@ sub generate_report {
                        'attachment_basename'  => $locale->text('general_ledger_list') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort to callback
   $form->{callback} = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir});
index 5a012b7..d83d409 100644 (file)
@@ -1235,6 +1235,7 @@ sub generate_report {
                        'attachment_basename'   => $attachment_basenames{$form->{searchitems}} . strftime('_%Y%m%d', localtime time),
   );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
index 3867c1b..0a0ce98 100644 (file)
@@ -864,6 +864,7 @@ sub orders {
                        'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort and escape callback, this one we use for the add sub
   $form->{callback} = $href .= "&sort=$form->{sort}";
index f854a4a..8f5991e 100644 (file)
@@ -169,6 +169,7 @@ sub project_report {
                        'attachment_basename' => $locale->text('project_list') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   CVar->add_custom_variables_to_report('module'         => 'Projects',
                                        'trans_id_field' => 'id',
index e1b0773..b083102 100644 (file)
@@ -807,7 +807,7 @@ $jsscript
         </tr>
         <tr>
           <td>| . $locale->text('Review of Aging list') . qq|</td>
-          <td><select name="review_of_aging_list"> 
+          <td><select name="review_of_aging_list">
               <option></option>
               <option>0-30</option>
               <option>30-60</option>
@@ -1368,6 +1368,7 @@ sub generate_trial_balance {
                        'pdf_template'         => 'rp/html_report_susa',
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort and escape callback, this one we use for the add sub
   $form->{callback} = $href .= "&sort=$form->{sort}";
@@ -1519,6 +1520,7 @@ sub list_accounts {
                        'std_column_visibility' => 1,
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
@@ -1719,6 +1721,8 @@ sub aging {
                        'title'                => $form->{title},
                        'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
     );
+  $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   my $previous_ctid = 0;
   my $row_idx       = 0;
@@ -1775,8 +1779,6 @@ sub aging {
                          'raw_bottom_info_text' => $raw_bottom_info_text);
   }
 
-  $report->set_options_from_form();
-
   $report->generate_with_headers();
 
   $main::lxdebug->leave_sub();
@@ -2433,6 +2435,8 @@ sub list_payments {
     );
   $report->set_options_from_form();
 
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
+
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
 
index f6041fb..fd45f80 100755 (executable)
@@ -248,6 +248,7 @@ sub bank_transfer_list {
                        'attachment_basename'   => $locale->text('banktransfers') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%::myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
index 021761e..16fcc78 100644 (file)
@@ -87,7 +87,7 @@ sub invoice_transactions {
   my ($callback, $href, @columns);
 
   $form->{customer} = $form->unescape($form->{customer});
-  
+
   ($form->{customername}, $form->{customer_id}) = split(/--/, $form->{customer});
 
   # decimalplaces überprüfen oder auf Default 2 setzen
@@ -137,7 +137,7 @@ sub invoice_transactions {
     'marge_total'             => { 'text' => $locale->text('Sales margin'), },
     'marge_percent'           => { 'text' => $locale->text('Sales margin %'), },
   );
-  
+
   my %column_alignment = map { $_ => 'right' } qw(lastcost sellprice sellprice_total lastcost_total unit discount marge_total marge_percent qty);
 
   $form->{"l_type"} = "Y";
@@ -188,6 +188,7 @@ sub invoice_transactions {
                        'attachment_basename'  => $locale->text('Sales Report') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
@@ -222,7 +223,7 @@ sub invoice_transactions {
     $ar->{sellprice} = $ar->{sellprice} / $ar->{price_factor};
     $ar->{lastcost} = $ar->{lastcost} / $ar->{price_factor};
     $ar->{sellprice_total} = $ar->{qty} * $ar->{sellprice};
-    $ar->{lastcost_total}  = $ar->{qty} * $ar->{lastcost}; 
+    $ar->{lastcost_total}  = $ar->{qty} * $ar->{lastcost};
     # marge_percent wird neu berechnet, da Wert in invoice leer ist (Bug)
     $ar->{marge_percent} = $ar->{sellprice_total} ? (($ar->{sellprice_total}-$ar->{lastcost_total}) / $ar->{sellprice_total}) : 0;
     # marge_total neu berechnen
@@ -243,14 +244,14 @@ sub invoice_transactions {
       $report->add_data($headerrow_set);
 
       # add empty row after main header
-#      my $emptyheaderrow->{description}->{data} = ""; 
+#      my $emptyheaderrow->{description}->{data} = "";
 #      $emptyheaderrow->{description}->{class} = "listmainsortheader";
 #      my $emptyheaderrow_set = [ $emptyheaderrow ];
-#      $report->add_data($emptyheaderrow_set) if $form->{l_headers} eq "Y"; 
+#      $report->add_data($emptyheaderrow_set) if $form->{l_headers} eq "Y";
     };
 
     # subsort überschriften
-    if ( $idx == 0 
+    if ( $idx == 0
       or $ar->{ $form->{'subsort'} }  ne $form->{AR}->[$idx - 1]->{ $form->{'subsort'} }
       or $ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'mainsort'} }
     ) {
@@ -271,8 +272,8 @@ sub invoice_transactions {
     map { $subtotals1{$_} += $ar->{$_};
           $subtotals2{$_} += $ar->{$_};
         } @subtotal_columns;
-         
-    map { $totals{$_}    += $ar->{$_} } @total_columns;  
+
+    map { $totals{$_}    += $ar->{$_} } @total_columns;
 
     $subtotals2{sellprice} = $subtotals2{sellprice_total} / $subtotals2{qty} if $subtotals2{qty} != 0;
     $subtotals1{sellprice} = $subtotals1{sellprice_total} / $subtotals1{qty} if $subtotals1{qty} != 0;
@@ -298,7 +299,7 @@ sub invoice_transactions {
         'align' => $column_alignment{$column},
       };
     }
-  
+
    $row->{description}->{class} = 'listsortdescription';
 
     $row->{invnumber}->{link} = build_std_url("script=is.pl", 'action=edit')
@@ -317,14 +318,14 @@ sub invoice_transactions {
       } else {
         $name = 'name';
       };
-      
+
       if ($form->{l_subtotal} eq 'Y' ) {
         push @{ $row_set }, create_subtotal_row_invoice(\%subtotals2, \@columns, \%column_alignment, \@subtotal_columns, 'listsubsortsubtotal', $ar->{$name}) ;
         push @{ $row_set }, insert_empty_row();
       };
     }
 
-    # if mainsort has changed, add mainsort subtotal and empty row 
+    # if mainsort has changed, add mainsort subtotal and empty row
     if (($form->{l_subtotal} eq 'Y')
         && (($idx == (scalar @{ $form->{AR} } - 1))   # last element always has a subtotal
             || ($ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx + 1]->{ $form->{'mainsort'} })
@@ -340,7 +341,7 @@ sub invoice_transactions {
         push @{ $row_set }, insert_empty_row();
       };
     }
-  
+
     $report->add_data($row_set);
 
     $idx++;
@@ -373,7 +374,7 @@ sub create_subtotal_row_invoice {
   my %myconfig = %main::myconfig;
 
   my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
-  
+
   $row->{description}->{data} = "Summe " . $name;
 
   map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } qw(marge_total marge_percent);
index 30ee326..c990e63 100644 (file)
@@ -721,6 +721,7 @@ sub generate_journal {
                        'title'                => $form->{title},
                        'attachment_basename'  => strftime($locale->text('warehouse_journal_list') . '_%Y%m%d', localtime time));
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   my $all_units = AM->retrieve_units(\%myconfig, $form);
   my @contents  = WH->get_warehouse_journal(%filter);
@@ -869,6 +870,7 @@ sub generate_report {
                        'title'                => $form->{title},
                        'attachment_basename'  => strftime($locale->text('warehouse_report_list') . '_%Y%m%d', localtime time));
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   my $all_units = AM->retrieve_units(\%myconfig, $form);
   my @contents  = WH->get_warehouse_report(%filter);