Lines 23-29
Link Here
|
23 |
#you can use any PDF::API2 module, all you need to do is return the stringifyed pdf object from the printpdf sub. |
23 |
#you can use any PDF::API2 module, all you need to do is return the stringifyed pdf object from the printpdf sub. |
24 |
package pdfformat::layout3pages; |
24 |
package pdfformat::layout3pages; |
25 |
use vars qw($VERSION @ISA @EXPORT); |
25 |
use vars qw($VERSION @ISA @EXPORT); |
26 |
use Number::Format qw(format_price); |
|
|
27 |
use MIME::Base64; |
26 |
use MIME::Base64; |
28 |
use List::MoreUtils qw/uniq/; |
27 |
use List::MoreUtils qw/uniq/; |
29 |
use strict; |
28 |
use strict; |
Lines 32-37
use utf8;
Link Here
|
32 |
|
31 |
|
33 |
use C4::Branch qw(GetBranchDetail GetBranchName); |
32 |
use C4::Branch qw(GetBranchDetail GetBranchName); |
34 |
|
33 |
|
|
|
34 |
use Koha::Number::Price; |
35 |
|
35 |
BEGIN { |
36 |
BEGIN { |
36 |
use Exporter (); |
37 |
use Exporter (); |
37 |
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); |
38 |
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); |
Lines 57-80
sub printorders {
Link Here
|
57 |
my ($pdf, $basketgroup, $baskets, $orders) = @_; |
58 |
my ($pdf, $basketgroup, $baskets, $orders) = @_; |
58 |
|
59 |
|
59 |
my $cur_format = C4::Context->preference("CurrencyFormat"); |
60 |
my $cur_format = C4::Context->preference("CurrencyFormat"); |
60 |
my $num; |
|
|
61 |
|
62 |
if ( $cur_format eq 'FR' ) { |
63 |
$num = new Number::Format( |
64 |
'decimal_fill' => '2', |
65 |
'decimal_point' => ',', |
66 |
'int_curr_symbol' => '', |
67 |
'mon_thousands_sep' => ' ', |
68 |
'thousands_sep' => ' ', |
69 |
'mon_decimal_point' => ',' |
70 |
); |
71 |
} else { # US by default.. |
72 |
$num = new Number::Format( |
73 |
'int_curr_symbol' => '', |
74 |
'mon_thousands_sep' => ',', |
75 |
'mon_decimal_point' => '.' |
76 |
); |
77 |
} |
78 |
|
61 |
|
79 |
$pdf->mediabox($height/mm, $width/mm); |
62 |
$pdf->mediabox($height/mm, $width/mm); |
80 |
my $number = 3; |
63 |
my $number = 3; |
Lines 134-146
sub printorders {
Link Here
|
134 |
push( @$arrbasket, |
117 |
push( @$arrbasket, |
135 |
$titleinfo. ($line->{order_vendornote} ? "\n----------------\nNote for vendor : " . $line->{order_vendornote} : '' ), |
118 |
$titleinfo. ($line->{order_vendornote} ? "\n----------------\nNote for vendor : " . $line->{order_vendornote} : '' ), |
136 |
$line->{quantity}, |
119 |
$line->{quantity}, |
137 |
$num->format_price($line->{rrpgste}), |
120 |
Koha::Number::Price->new( $line->{rrpgste} )->format, |
138 |
$num->format_price($line->{rrpgsti}), |
121 |
Koha::Number::Price->new( $line->{rrpgsti} )->format, |
139 |
$num->format_price($line->{discount}).'%', |
122 |
Koha::Number::Price->new( $line->{discount} )->format . '%', |
140 |
$num->format_price($line->{rrpgste} - $line->{ecostgste}), |
123 |
Koha::Number::Price->new( $line->{rrpgste} - $line->{ecostgste})->format, |
141 |
$num->format_price($line->{gstrate} * 100).'%', |
124 |
Koha::Number::Price->new( $line->{gstrate} * 100 )->format . '%', |
142 |
$num->format_price($line->{totalgste}), |
125 |
Koha::Number::Price->new( $line->{totalgste} )->format, |
143 |
$num->format_price($line->{totalgsti}), |
126 |
Koha::Number::Price->new( $line->{totalgsti} )->format, |
144 |
); |
127 |
); |
145 |
push(@$abaskets, $arrbasket); |
128 |
push(@$abaskets, $arrbasket); |
146 |
} |
129 |
} |
Lines 204-228
sub printbaskets {
Link Here
|
204 |
my $libraryname = C4::Context->preference("LibraryName"); |
187 |
my $libraryname = C4::Context->preference("LibraryName"); |
205 |
|
188 |
|
206 |
my $cur_format = C4::Context->preference("CurrencyFormat"); |
189 |
my $cur_format = C4::Context->preference("CurrencyFormat"); |
207 |
my $num; |
190 |
|
208 |
|
|
|
209 |
if ( $cur_format eq 'FR' ) { |
210 |
$num = new Number::Format( |
211 |
'decimal_fill' => '2', |
212 |
'decimal_point' => ',', |
213 |
'int_curr_symbol' => '', |
214 |
'mon_thousands_sep' => ' ', |
215 |
'thousands_sep' => ' ', |
216 |
'mon_decimal_point' => ',' |
217 |
); |
218 |
} else { # US by default.. |
219 |
$num = new Number::Format( |
220 |
'int_curr_symbol' => '', |
221 |
'mon_thousands_sep' => ',', |
222 |
'mon_decimal_point' => '.' |
223 |
); |
224 |
} |
225 |
|
226 |
$pdf->mediabox($width/mm, $height/mm); |
191 |
$pdf->mediabox($width/mm, $height/mm); |
227 |
my $page = $pdf->openpage(2); |
192 |
my $page = $pdf->openpage(2); |
228 |
# create a text |
193 |
# create a text |
Lines 263-293
sub printbaskets {
Link Here
|
263 |
push @gst, $ord->{gstrate}; |
228 |
push @gst, $ord->{gstrate}; |
264 |
} |
229 |
} |
265 |
@gst = uniq map { $_ * 100 } @gst; |
230 |
@gst = uniq map { $_ * 100 } @gst; |
266 |
$totalgsti = $num->round($totalgsti); |
|
|
267 |
$totalgste = $num->round($totalgste); |
268 |
$grandtotalrrpgste += $totalrrpgste; |
231 |
$grandtotalrrpgste += $totalrrpgste; |
269 |
$grandtotalrrpgsti += $totalrrpgsti; |
232 |
$grandtotalrrpgsti += $totalrrpgsti; |
270 |
$grandtotalgsti += $totalgsti; |
233 |
$grandtotalgsti += $totalgsti; |
271 |
$grandtotalgste += $totalgste; |
234 |
$grandtotalgste += $totalgste; |
272 |
$grandtotalgstvalue += $totalgstvalue; |
235 |
$grandtotalgstvalue += $totalgstvalue; |
273 |
$grandtotaldiscount += $totaldiscount; |
236 |
$grandtotaldiscount += $totaldiscount; |
274 |
my @gst_string = map{$num->format_price( $_ ) . '%'} @gst; |
237 |
my @gst_string = |
|
|
238 |
map { Koha::Number::Price->new($_)->format . '%' } @gst; |
275 |
push(@$arrbasket, |
239 |
push(@$arrbasket, |
276 |
$basket->{contractname}, |
240 |
$basket->{contractname}, |
277 |
$basket->{basketname} . ' (No. ' . $basket->{basketno} . ')', |
241 |
$basket->{basketname} . ' (No. ' . $basket->{basketno} . ')', |
278 |
$num->format_price($totalrrpgste), |
242 |
Koha::Number::Price->new( $totalrrpgste )->format, |
279 |
$num->format_price($totalrrpgsti), |
243 |
Koha::Number::Price->new( $totalrrpgsti )->format, |
280 |
"@gst_string", |
244 |
"@gst_string", |
281 |
$num->format_price($totalgstvalue), |
245 |
Koha::Number::Price->new( $totalgstvalue )->format, |
282 |
$num->format_price($totaldiscount), |
246 |
Koha::Number::Price->new( $totaldiscount )->format, |
283 |
$num->format_price($totalgste), |
247 |
Koha::Number::Price->new( $totalgste )->format, |
284 |
$num->format_price($totalgsti) |
248 |
Koha::Number::Price->new( $totalgsti )->format, |
285 |
); |
249 |
); |
286 |
push(@$abaskets, $arrbasket); |
250 |
push(@$abaskets, $arrbasket); |
287 |
} |
251 |
} |
288 |
# now, push total |
252 |
# now, push total |
289 |
undef $arrbasket; |
253 |
undef $arrbasket; |
290 |
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); |
254 |
push @$arrbasket, |
|
|
255 |
'', |
256 |
'Total', |
257 |
Koha::Number::Price->new( $grandtotalrrpgste )->format, |
258 |
Koha::Number::Price->new( $grandtotalrrpgsti )->format, |
259 |
'', |
260 |
Koha::Number::Price->new( $grandtotalgstvalue )->format, |
261 |
Koha::Number::Price->new( $grandtotaldiscount )->format, |
262 |
Koha::Number::Price->new( $grandtotalgste )->format, |
263 |
Koha::Number::Price->new( $grandtotalgsti )->format; |
291 |
push @$abaskets,$arrbasket; |
264 |
push @$abaskets,$arrbasket; |
292 |
# height is width and width is height in this function, as the pdf is in landscape mode for the Tables. |
265 |
# height is width and width is height in this function, as the pdf is in landscape mode for the Tables. |
293 |
|
266 |
|