Lines 102-119
sub printorders {
Link Here
|
102 |
my $pdftable = new PDF::Table(); |
102 |
my $pdftable = new PDF::Table(); |
103 |
my $abaskets; |
103 |
my $abaskets; |
104 |
my $arrbasket; |
104 |
my $arrbasket; |
105 |
my @keys = ('Document','Qty','RRT GST Inc.','Discount','Discount price GST Exc.','GST', 'Total GST Inc.'); |
105 |
my @keys = ('Document', 'Qty', 'RRP tax exc.', 'RRP tax inc.', 'Discount', 'Discount price', 'GST rate', 'Total tax exc.', 'Total tax inc.'); |
106 |
for my $bkey (@keys) { |
106 |
for my $bkey (@keys) { |
107 |
push(@$arrbasket, $bkey); |
107 |
push(@$arrbasket, $bkey); |
108 |
} |
108 |
} |
109 |
push(@$abaskets, $arrbasket); |
109 |
push(@$abaskets, $arrbasket); |
110 |
# @{$orders->{$basket->{basketno}}}); |
|
|
111 |
foreach my $line (@{$orders->{$basket->{basketno}}}) { |
110 |
foreach my $line (@{$orders->{$basket->{basketno}}}) { |
112 |
$arrbasket = undef; |
111 |
$arrbasket = undef; |
113 |
push(@$arrbasket, @$line[3]." / ".@$line[2].(@$line[0]?" ISBN : ".@$line[0]:'').(@$line[10]?" EN : ".@$line[10]:'').", ".@$line[1].(@$line[4]?' published by '.@$line[4]:''), @$line[5],$num->format_price(@$line[6]),$num->format_price(@$line[8]).'%',$num->format_price(@$line[7]/(1+@$line[9]/100)),$num->format_price(@$line[9]).'%',$num->format_price($num->round(@$line[7])*@$line[5])); |
112 |
push( @$arrbasket, |
|
|
113 |
$line->{title} . " / " . $line->{author} . ( $line->{isbn} ? " ISBN : " . $line->{isbn} : '' ) . ( $line->{en} ? " EN : " . $line->{en} : '' ) . ", " . $line->{itemtype} . ( $line->{publishercode} ? ' published by '. $line->{publishercode} : ""), |
114 |
$line->{quantity}, |
115 |
$num->format_price($line->{rrpgste}), |
116 |
$num->format_price($line->{rrpgsti}), |
117 |
$num->format_price($line->{discount}).'%', |
118 |
$num->format_price($line->{rrpgste} - $line->{ecostgste}), |
119 |
$num->format_price($line->{gstrate} * 100).'%', |
120 |
$num->format_price($line->{totalgste}), |
121 |
$num->format_price($line->{totalgsti}), |
122 |
); |
114 |
push(@$abaskets, $arrbasket); |
123 |
push(@$abaskets, $arrbasket); |
115 |
} |
124 |
} |
116 |
|
125 |
|
117 |
$pdftable->table($pdf, $page, $abaskets, |
126 |
$pdftable->table($pdf, $page, $abaskets, |
118 |
x => 10/mm, |
127 |
x => 10/mm, |
119 |
w => ($width - 20)/mm, |
128 |
w => ($width - 20)/mm, |
Lines 128-140
sub printorders {
Link Here
|
128 |
font_size => 3/mm, |
137 |
font_size => 3/mm, |
129 |
header_props => { |
138 |
header_props => { |
130 |
font => $pdf->corefont("Times", -encoding => "utf8"), |
139 |
font => $pdf->corefont("Times", -encoding => "utf8"), |
131 |
font_size => 10, |
140 |
font_size => 9, |
132 |
bg_color => 'gray', |
141 |
bg_color => 'gray', |
133 |
repeat => 1, |
142 |
repeat => 1, |
134 |
}, |
143 |
}, |
135 |
column_props => [ |
144 |
column_props => [ |
136 |
{ |
145 |
{ |
137 |
min_w => 100/mm, # Minimum column width. |
146 |
min_w => 85/mm, # Minimum column width. |
|
|
147 |
}, |
148 |
{ |
149 |
justify => 'right', # One of left|right , |
150 |
}, |
151 |
{ |
152 |
justify => 'right', # One of left|right , |
138 |
}, |
153 |
}, |
139 |
{ |
154 |
{ |
140 |
justify => 'right', # One of left|right , |
155 |
justify => 'right', # One of left|right , |
Lines 203-236
sub printbaskets {
Link Here
|
203 |
my $abaskets; |
218 |
my $abaskets; |
204 |
my $arrbasket; |
219 |
my $arrbasket; |
205 |
# header of the table |
220 |
# header of the table |
206 |
my @keys = ('Lot', 'Basket (N°)', 'RRT GST Inc.', 'Discount', 'Discount price','GST rate', 'Total GST exc.','GST', 'Total GST Inc.'); |
221 |
my @keys = ('Lot', 'Basket (N°)','Total RRP tax exc.', 'Total RRP tax inc.', 'GST rate', 'GST', 'Total discount', 'Total tax exc.', 'Total tax inc.'); |
207 |
for my $bkey (@keys) { |
222 |
for my $bkey (@keys) { |
208 |
push(@$arrbasket, $bkey); |
223 |
push(@$arrbasket, $bkey); |
209 |
} |
224 |
} |
210 |
my $grandtotal=0; |
225 |
my ($grandtotalrrpgsti, $grandtotalrrpgste, $grandtotalgsti, $grandtotalgste, $grandtotalgstvalue, $grandtotaldiscount); |
211 |
my $grandgst=0; |
226 |
my @gst; |
212 |
# calculate each basket total |
227 |
# calculate each basket total |
213 |
push(@$abaskets, $arrbasket); |
228 |
push(@$abaskets, $arrbasket); |
214 |
for my $basket (@$hbaskets) { |
229 |
for my $basket (@$hbaskets) { |
215 |
$arrbasket = undef; |
230 |
$arrbasket = undef; |
216 |
my ($total, $gst, $totallist) = (0, 0, 0); |
231 |
my ($totalrrpgste, $totalrrpgsti, $totalgste, $totalgsti, $totalgstvalue, $totaldiscount); |
217 |
my $ords = $orders->{$basket->{basketno}}; |
232 |
my $ords = $orders->{$basket->{basketno}}; |
218 |
my $ordlength = @$ords; |
233 |
my $ordlength = @$ords; |
219 |
foreach my $ord (@$ords) { |
234 |
foreach my $ord (@$ords) { |
220 |
$total += @$ord[5] * @$ord[7]; |
235 |
$totalgste += $ord->{totalgste}; |
221 |
$gst += (@$ord[5] * @$ord[7]) * $GSTrate/(1+$GSTrate); |
236 |
$totalgsti += $ord->{totalgsti}; |
222 |
$totallist += @$ord[5]*@$ord[6]; |
237 |
$totalgstvalue += $ord->{gstvalue}; |
|
|
238 |
$totaldiscount += ($ord->{rrpgste} - $ord->{ecostgste} ) * $ord->{quantity}; |
239 |
$totalrrpgste += $ord->{rrpgste} * $ord->{quantity}; |
240 |
$totalrrpgsti += $ord->{rrpgsti} * $ord->{quantity}; |
241 |
push @gst, $ord->{gstrate} * 100 |
242 |
unless grep {$ord->{gstrate} * 100 == $_ ? $_ : ()} @gst; |
223 |
} |
243 |
} |
224 |
$total=$num->round($total); |
244 |
$totalgsti = $num->round($totalgsti); |
225 |
$gst=$num->round($gst); |
245 |
$totalgste = $num->round($totalgste); |
226 |
$grandtotal +=$total; |
246 |
$grandtotalrrpgste += $totalrrpgste; |
227 |
$grandgst +=$gst; |
247 |
$grandtotalrrpgsti += $totalrrpgsti; |
228 |
push(@$arrbasket, $basket->{contractname}, $basket->{basketname}.'(N°'.$basket->{basketno}.')',$num->format_price($totallist), $num->format_price($bookseller->{discount}).'%', $num->format_price($total), $num->format_price($GSTrate*100).'%', $num->format_price($total-$gst), $num->format_price($gst), $num->format_price($total)); |
248 |
$grandtotalgsti += $totalgsti; |
|
|
249 |
$grandtotalgste += $totalgste; |
250 |
$grandtotalgstvalue += $totalgstvalue; |
251 |
$grandtotaldiscount += $totaldiscount; |
252 |
my @gst_string = map{$num->format_price( $_ ) . '%'} @gst; |
253 |
push(@$arrbasket, |
254 |
$basket->{contractname}, |
255 |
$basket->{basketname} . ' (N°' . $basket->{basketno} . ')', |
256 |
$num->format_price($totalrrpgste), |
257 |
$num->format_price($totalrrpgsti), |
258 |
"@gst_string", |
259 |
$num->format_price($totalgstvalue), |
260 |
$num->format_price($totaldiscount), |
261 |
$num->format_price($totalgste), |
262 |
$num->format_price($totalgsti) |
263 |
); |
229 |
push(@$abaskets, $arrbasket); |
264 |
push(@$abaskets, $arrbasket); |
230 |
} |
265 |
} |
231 |
# now, push total |
266 |
# now, push total |
232 |
undef $arrbasket; |
267 |
undef $arrbasket; |
233 |
push @$arrbasket,'','','','Total',$num->format_price($grandtotal),'',$num->format_price($grandtotal-$grandgst), $num->format_price($grandgst),$num->format_price($grandtotal); |
268 |
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); |
234 |
push @$abaskets,$arrbasket; |
269 |
push @$abaskets,$arrbasket; |
235 |
# height is width and width is height in this function, as the pdf is in landscape mode for the Tables. |
270 |
# height is width and width is height in this function, as the pdf is in landscape mode for the Tables. |
236 |
|
271 |
|
Lines 270-281
sub printbaskets {
Link Here
|
270 |
{ |
305 |
{ |
271 |
justify => 'right', |
306 |
justify => 'right', |
272 |
}, |
307 |
}, |
273 |
{ |
|
|
274 |
justify => 'right', |
275 |
}, |
276 |
{ |
277 |
justify => 'right', |
278 |
}, |
279 |
], |
308 |
], |
280 |
); |
309 |
); |
281 |
$pdf->mediabox($height/mm, $width/mm); |
310 |
$pdf->mediabox($height/mm, $width/mm); |
282 |
- |
|
|