@@ -, +, @@ defined at one place --- acqui/acqui-home.pl | 1 - acqui/addorderiso2709.pl | 1 - acqui/pdfformat/layout2pages.pm | 31 ++++----------- acqui/pdfformat/layout2pagesde.pm | 31 ++++----------- acqui/pdfformat/layout3pages.pm | 83 +++++++++++++-------------------------- acqui/pdfformat/layout3pagesfr.pm | 81 +++++++++++++------------------------- admin/aqbudgetperiods.pl | 14 +++---- admin/aqbudgets.pl | 1 - admin/aqplan.pl | 1 - 9 files changed, 74 insertions(+), 170 deletions(-) --- a/acqui/acqui-home.pl +++ a/acqui/acqui-home.pl @@ -28,7 +28,6 @@ this script is the main page for acqui use strict; use warnings; -use Number::Format; use CGI; use C4::Auth; --- a/acqui/addorderiso2709.pl +++ a/acqui/addorderiso2709.pl @@ -24,7 +24,6 @@ use Modern::Perl; use CGI; use Carp; -use Number::Format qw(:all); use YAML qw/Load/; use C4::Context; --- a/acqui/pdfformat/layout2pages.pm +++ a/acqui/pdfformat/layout2pages.pm @@ -23,7 +23,6 @@ #you can use any PDF::API2 module, all you need to do is return the stringifyed pdf object from the printpdf sub. package pdfformat::layout2pages; use vars qw($VERSION @ISA @EXPORT); -use Number::Format qw(format_price); use MIME::Base64; use strict; use warnings; @@ -31,6 +30,8 @@ use utf8; use C4::Branch qw(GetBranchDetail); +use Koha::Number::Price; + BEGIN { use Exporter (); our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); @@ -56,24 +57,6 @@ sub printorders { my ($pdf, $basketgroup, $baskets, $orders) = @_; my $cur_format = C4::Context->preference("CurrencyFormat"); - my $num; - - if ( $cur_format eq 'FR' ) { - $num = new Number::Format( - 'decimal_fill' => '2', - 'decimal_point' => ',', - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ' ', - 'thousands_sep' => ' ', - 'mon_decimal_point' => ',' - ); - } else { # US by default.. - $num = new Number::Format( - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ',', - 'mon_decimal_point' => '.' - ); - } $pdf->mediabox($height/mm, $width/mm); my $page = $pdf->page(); @@ -115,11 +98,11 @@ sub printorders { $basket->{basketno}, $titleinfo. ($line->{order_vendornote} ? "\n----------------\nNote for vendor : " . $line->{order_vendornote} : '' ), $line->{quantity}, - $num->format_price($line->{rrpgsti}), - $num->format_price($line->{discount}).'%', - $num->format_price($line->{gstrate} * 100).'%', - $num->format_price($line->{totalgste}), - $num->format_price($line->{totalgsti}), + Koha::Number::Price->new( $line->{rrpgsti} )->format, + Koha::Number::Price->new( $line->{discount} )->format . '%', + Koha::Number::Price->new( $line->{gstrate} * 100 )->format . '%', + Koha::Number::Price->new( $line->{totalgste} )->format, + Koha::Number::Price->new( $line->{totalgsti} )->format, ); push(@$abaskets, $arrbasket); } --- a/acqui/pdfformat/layout2pagesde.pm +++ a/acqui/pdfformat/layout2pagesde.pm @@ -23,7 +23,6 @@ #you can use any PDF::API2 module, all you need to do is return the stringifyed pdf object from the printpdf sub. package pdfformat::layout2pagesde; use vars qw($VERSION @ISA @EXPORT); -use Number::Format qw(format_price); use MIME::Base64; use strict; use warnings; @@ -31,6 +30,8 @@ use utf8; use C4::Branch qw(GetBranchDetail); +use Koha::Number::Price; + BEGIN { use Exporter (); our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); @@ -56,24 +57,6 @@ sub printorders { my ($pdf, $basketgroup, $baskets, $orders) = @_; my $cur_format = C4::Context->preference("CurrencyFormat"); - my $num; - - if ( $cur_format eq 'FR' ) { - $num = new Number::Format( - 'decimal_fill' => '2', - 'decimal_point' => ',', - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ' ', - 'thousands_sep' => ' ', - 'mon_decimal_point' => ',' - ); - } else { # US by default.. - $num = new Number::Format( - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ',', - 'mon_decimal_point' => '.' - ); - } $pdf->mediabox($height/mm, $width/mm); my $page = $pdf->page(); @@ -115,11 +98,11 @@ sub printorders { $basket->{basketno}, $titleinfo. ($line->{order_vendornote} ? "\n----------------\nLieferantennotiz : ". $line->{order_vendornote} : '' ), $line->{quantity}, $line->{quantity}, - $num->format_price($line->{rrpgsti}), - $num->format_price($line->{discount}).'%', - $num->format_price($line->{gstrate} * 100).'%', - $num->format_price($line->{totalgste}), - $num->format_price($line->{totalgsti}), + Koha::Number::Price->new( $line->{rrpgsti} )->format, + Koha::Number::Price->new( $line->{discount} )->format . '%', + Koha::Number::Price->new( $line->{gstrate} * 100 )->format . '%', + Koha::Number::Price->new( $line->{totalgste} )->format, + Koha::Number::Price->new( $line->{totalgsti} )->format, ); push(@$abaskets, $arrbasket); } --- a/acqui/pdfformat/layout3pages.pm +++ a/acqui/pdfformat/layout3pages.pm @@ -23,7 +23,6 @@ #you can use any PDF::API2 module, all you need to do is return the stringifyed pdf object from the printpdf sub. package pdfformat::layout3pages; use vars qw($VERSION @ISA @EXPORT); -use Number::Format qw(format_price); use MIME::Base64; use List::MoreUtils qw/uniq/; use strict; @@ -32,6 +31,8 @@ use utf8; use C4::Branch qw(GetBranchDetail GetBranchName); +use Koha::Number::Price; + BEGIN { use Exporter (); our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); @@ -57,24 +58,6 @@ sub printorders { my ($pdf, $basketgroup, $baskets, $orders) = @_; my $cur_format = C4::Context->preference("CurrencyFormat"); - my $num; - - if ( $cur_format eq 'FR' ) { - $num = new Number::Format( - 'decimal_fill' => '2', - 'decimal_point' => ',', - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ' ', - 'thousands_sep' => ' ', - 'mon_decimal_point' => ',' - ); - } else { # US by default.. - $num = new Number::Format( - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ',', - 'mon_decimal_point' => '.' - ); - } $pdf->mediabox($height/mm, $width/mm); my $number = 3; @@ -134,13 +117,13 @@ sub printorders { push( @$arrbasket, $titleinfo. ($line->{order_vendornote} ? "\n----------------\nNote for vendor : " . $line->{order_vendornote} : '' ), $line->{quantity}, - $num->format_price($line->{rrpgste}), - $num->format_price($line->{rrpgsti}), - $num->format_price($line->{discount}).'%', - $num->format_price($line->{rrpgste} - $line->{ecostgste}), - $num->format_price($line->{gstrate} * 100).'%', - $num->format_price($line->{totalgste}), - $num->format_price($line->{totalgsti}), + Koha::Number::Price->new( $line->{rrpgste} )->format, + Koha::Number::Price->new( $line->{rrpgsti} )->format, + Koha::Number::Price->new( $line->{discount} )->format . '%', + Koha::Number::Price->new( $line->{rrpgste} - $line->{ecostgste})->format, + Koha::Number::Price->new( $line->{gstrate} * 100 )->format . '%', + Koha::Number::Price->new( $line->{totalgste} )->format, + Koha::Number::Price->new( $line->{totalgsti} )->format, ); push(@$abaskets, $arrbasket); } @@ -204,25 +187,7 @@ sub printbaskets { my $libraryname = C4::Context->preference("LibraryName"); my $cur_format = C4::Context->preference("CurrencyFormat"); - my $num; - - if ( $cur_format eq 'FR' ) { - $num = new Number::Format( - 'decimal_fill' => '2', - 'decimal_point' => ',', - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ' ', - 'thousands_sep' => ' ', - 'mon_decimal_point' => ',' - ); - } else { # US by default.. - $num = new Number::Format( - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ',', - 'mon_decimal_point' => '.' - ); - } - + $pdf->mediabox($width/mm, $height/mm); my $page = $pdf->openpage(2); # create a text @@ -263,31 +228,39 @@ sub printbaskets { push @gst, $ord->{gstrate}; } @gst = uniq map { $_ * 100 } @gst; - $totalgsti = $num->round($totalgsti); - $totalgste = $num->round($totalgste); $grandtotalrrpgste += $totalrrpgste; $grandtotalrrpgsti += $totalrrpgsti; $grandtotalgsti += $totalgsti; $grandtotalgste += $totalgste; $grandtotalgstvalue += $totalgstvalue; $grandtotaldiscount += $totaldiscount; - my @gst_string = map{$num->format_price( $_ ) . '%'} @gst; + my @gst_string = + map { Koha::Number::Price->new($_)->format . '%' } @gst; push(@$arrbasket, $basket->{contractname}, $basket->{basketname} . ' (No. ' . $basket->{basketno} . ')', - $num->format_price($totalrrpgste), - $num->format_price($totalrrpgsti), + Koha::Number::Price->new( $totalrrpgste )->format, + Koha::Number::Price->new( $totalrrpgsti )->format, "@gst_string", - $num->format_price($totalgstvalue), - $num->format_price($totaldiscount), - $num->format_price($totalgste), - $num->format_price($totalgsti) + Koha::Number::Price->new( $totalgstvalue )->format, + Koha::Number::Price->new( $totaldiscount )->format, + Koha::Number::Price->new( $totalgste )->format, + Koha::Number::Price->new( $totalgsti )->format, ); push(@$abaskets, $arrbasket); } # now, push total undef $arrbasket; - push @$arrbasket,'','Total', $num->format_price($grandtotalrrpgste), $num->format_price($grandtotalrrpgsti), '', $num->format_price($grandtotalgstvalue), $num->format_price($grandtotaldiscount), $num->format_price($grandtotalgste), $num->format_price($grandtotalgsti); + push @$arrbasket, + '', + 'Total', + Koha::Number::Price->new( $grandtotalrrpgste )->format, + Koha::Number::Price->new( $grandtotalrrpgsti )->format, + '', + Koha::Number::Price->new( $grandtotalgstvalue )->format, + Koha::Number::Price->new( $grandtotaldiscount )->format, + Koha::Number::Price->new( $grandtotalgste )->format, + Koha::Number::Price->new( $grandtotalgsti )->format; push @$abaskets,$arrbasket; # height is width and width is height in this function, as the pdf is in landscape mode for the Tables. --- a/acqui/pdfformat/layout3pagesfr.pm +++ a/acqui/pdfformat/layout3pagesfr.pm @@ -22,7 +22,6 @@ #you can use any PDF::API2 module, all you need to do is return the stringifyed pdf object from the printpdf sub. package pdfformat::layout3pagesfr; use vars qw($VERSION @ISA @EXPORT); -use Number::Format qw(format_price); use MIME::Base64; use List::MoreUtils qw/uniq/; use strict; @@ -31,6 +30,8 @@ use utf8; use C4::Branch qw(GetBranchDetail GetBranchName); +use Koha::Number::Price; + BEGIN { use Exporter (); our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); @@ -56,24 +57,6 @@ sub printorders { my ($pdf, $basketgroup, $baskets, $orders) = @_; my $cur_format = C4::Context->preference("CurrencyFormat"); - my $num; - - if ( $cur_format eq 'FR' ) { - $num = new Number::Format( - 'decimal_fill' => '2', - 'decimal_point' => ',', - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ' ', - 'thousands_sep' => ' ', - 'mon_decimal_point' => ',' - ); - } else { # US by default.. - $num = new Number::Format( - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ',', - 'mon_decimal_point' => '.' - ); - } $pdf->mediabox($height/mm, $width/mm); my $number = 3; @@ -134,13 +117,13 @@ sub printorders { push( @$arrbasket, $titleinfo. ($line->{order_vendornote} ? "\n----------------\nNote pour le fournisseur : ". $line->{order_vendornote} : '' ), $line->{quantity}, - $num->format_price($line->{rrpgste}), - $num->format_price($line->{rrpgsti}), - $num->format_price($line->{discount}).'%', - $num->format_price($line->{rrpgste} - $line->{ecostgste}), - $num->format_price($line->{gstrate} * 100).'%', - $num->format_price($line->{totalgste}), - $num->format_price($line->{totalgsti}), + Koha::Number::Price->new( $line->{rrpgste}), + Koha::Number::Price->new( $line->{rrpgsti}), + Koha::Number::Price->new( $line->{discount}).'%', + Koha::Number::Price->new( $line->{rrpgste} - $line->{ecostgste}), + Koha::Number::Price->new( $line->{gstrate} * 100).'%', + Koha::Number::Price->new( $line->{totalgste}), + Koha::Number::Price->new( $line->{totalgsti}), ); push(@$abaskets, $arrbasket); } @@ -204,24 +187,6 @@ sub printbaskets { my $libraryname = C4::Context->preference("LibraryName"); my $cur_format = C4::Context->preference("CurrencyFormat"); - my $num; - - if ( $cur_format eq 'FR' ) { - $num = new Number::Format( - 'decimal_fill' => '2', - 'decimal_point' => ',', - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ' ', - 'thousands_sep' => ' ', - 'mon_decimal_point' => ',' - ); - } else { # US by default.. - $num = new Number::Format( - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ',', - 'mon_decimal_point' => '.' - ); - } $pdf->mediabox($width/mm, $height/mm); my $page = $pdf->openpage(2); @@ -263,31 +228,39 @@ sub printbaskets { push @gst, $ord->{gstrate}; } @gst = uniq map { $_ * 100 } @gst; - $totalgsti = $num->round($totalgsti); - $totalgste = $num->round($totalgste); $grandtotalrrpgste += $totalrrpgste; $grandtotalrrpgsti += $totalrrpgsti; $grandtotalgsti += $totalgsti; $grandtotalgste += $totalgste; $grandtotalgstvalue += $totalgstvalue; $grandtotaldiscount += $totaldiscount; - my @gst_string = map{$num->format_price( $_ ) . '%'} @gst; + my @gst_string = + map { Koha::Number::Price->new($_)->format . '%' } @gst; push(@$arrbasket, $basket->{contractname}, $basket->{basketname} . ' (No. ' . $basket->{basketno} . ')', - $num->format_price($totalrrpgste), - $num->format_price($totalrrpgsti), + Koha::Number::Price->new( $totalrrpgste )->format, + Koha::Number::Price->new( $totalrrpgsti )->format, "@gst_string", - $num->format_price($totalgstvalue), - $num->format_price($totaldiscount), - $num->format_price($totalgste), - $num->format_price($totalgsti) + Koha::Number::Price->new( $totalgstvalue )->format, + Koha::Number::Price->new( $totaldiscount )->format, + Koha::Number::Price->new( $totalgste )->format, + Koha::Number::Price->new( $totalgsti )->format, ); push(@$abaskets, $arrbasket); } # now, push total undef $arrbasket; - push @$arrbasket,'','Total', $num->format_price($grandtotalrrpgste), $num->format_price($grandtotalrrpgsti), '', $num->format_price($grandtotalgstvalue), $num->format_price($grandtotaldiscount), $num->format_price($grandtotalgste), $num->format_price($grandtotalgsti); + push @$arrbasket, + '', + 'Total', + Koha::Number::Price->new( $grandtotalrrpgste )->format, + Koha::Number::Price->new( $grandtotalrrpgsti )->format, + '', + Koha::Number::Price->new( $grandtotalgstvalue )->format, + Koha::Number::Price->new( $grandtotaldiscount )->format, + Koha::Number::Price->new( $grandtotalgste )->format, + Koha::Number::Price->new( $grandtotalgsti )->format; push @$abaskets,$arrbasket; # height is width and width is height in this function, as the pdf is in landscape mode for the Tables. --- a/admin/aqbudgetperiods.pl +++ a/admin/aqbudgetperiods.pl @@ -46,7 +46,6 @@ script to administer the budget periods table use Modern::Perl; -use Number::Format qw(format_price); use CGI; use List::Util qw/min/; use Koha::DateUtils; @@ -59,6 +58,8 @@ use C4::Acquisition; use C4::Budgets; use C4::Debug; +use Koha::Number::Price; + my $dbh = C4::Context->dbh; my $input = new CGI; @@ -106,14 +107,9 @@ if ( $op eq 'add_form' ) { my $budgetperiod_hash=GetBudgetPeriod($budget_period_id); # get dropboxes - my $editnum = new Number::Format( - 'int_curr_symbol' => '', - 'thousands_sep' => '', - 'mon_thousands_sep' => '', - 'mon_decimal_point' => '.' - ); - - $$budgetperiod_hash{budget_period_total}= $editnum->format_price($$budgetperiod_hash{'budget_period_total'}); + $budgetperiod_hash->{budget_period_total} = + Koha::Number::Price->new( $budgetperiod_hash->{budget_period_total} ) + ->format; $template->param( %$budgetperiod_hash ); --- a/admin/aqbudgets.pl +++ a/admin/aqbudgets.pl @@ -23,7 +23,6 @@ use Modern::Perl; use CGI; use List::Util qw/min/; -use Number::Format qw(format_price); use Koha::Database; use C4::Auth qw/get_user_subpermissions/; --- a/admin/aqplan.pl +++ a/admin/aqplan.pl @@ -27,7 +27,6 @@ use List::Util qw/min/; use Date::Calc qw/Delta_YMD Easter_Sunday Today Decode_Date_EU/; use Date::Manip qw/ ParseDate UnixDate DateCalc/; use C4::Dates qw/format_date format_date_in_iso/; -use Number::Format qw(format_price); use Text::CSV_XS; use C4::Acquisition; --