#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 vars qw(@ISA @EXPORT);
use MIME::Base64;
use List::MoreUtils qw/uniq/;
-use strict;
-use warnings;
+use Modern::Perl;
use utf8;
-use C4::Branch qw(GetBranchDetail GetBranchName);
-
use Koha::Number::Price;
+use Koha::DateUtils;
+use Koha::Libraries;
BEGIN {
use Exporter ();
- our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
- # set the version for version checking
- $VERSION = 1.00;
+ our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
@ISA = qw(Exporter);
@EXPORT = qw(printpdf);
}
#be careful, all the sizes (height, width, etc...) are in mm, not PostScript points (the default measurment of PDF::API2).
-#The constants exported tranform that into PostScript points (/mm for milimeter, /in for inch, pt is postscript point, and as so is there only to show what is happening.
+#The constants exported transform that into PostScript points (/mm for milimeter, /in for inch, pt is postscript point, and as so is there only to show what is happening.
use constant mm => 25.4 / 72;
use constant in => 1 / 72;
use constant pt => 1;
my $number = 3;
for my $basket (@$baskets){
my $page = $pdf->page();
-
+ my $billing_library = Koha::Libraries->find( $basket->{billingplace} );
+ my $delivery_library = Koha::Libraries->find( $basket->{deliveryplace} );
+
# print basket header (box)
my $box = $page->gfx;
$box->rectxy(($width - 10)/mm, ($height - 5)/mm, 10/mm, ($height - 25)/mm);
$text->text("Order no. ".$basketgroup->{'id'}.". Basket no. ".$basket->{basketno}.". ".$basket->{booksellernote});
$text->translate(20/mm, ($height-20)/mm);
$text->font( $pdf->corefont("Times", -encoding => "utf8"), 4/mm );
- $text->text( ( $basket->{billingplace} ? "Billing at " . C4::Branch::GetBranchName( $basket->{billingplace} ) : "" )
- . ( $basket->{billingplace} and $basket->{deliveryplace} ? " and " : "" )
- . ( $basket->{deliveryplace} ? "delivery at " . C4::Branch::GetBranchName( $basket->{deliveryplace}) : "" )
+ $text->text( ( $billing_library ? "Billing at " . $billing_library->branchname : "" )
+ . ( $billing_library and $delivery_library ? " and " : "" )
+ . ( $delivery_library ? "delivery at " . $delivery_library->branchname : "" )
);
my $pdftable = new PDF::Table();
push( @$arrbasket,
$titleinfo. ($line->{order_vendornote} ? "\n----------------\nNote for vendor : " . $line->{order_vendornote} : '' ),
$line->{quantity},
- Koha::Number::Price->new( $line->{rrpgste} )->format,
- Koha::Number::Price->new( $line->{rrpgsti} )->format,
+ Koha::Number::Price->new( $line->{rrp_tax_excluded} )->format,
+ Koha::Number::Price->new( $line->{rrp_tax_included} )->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,
+ Koha::Number::Price->new( $line->{rrp_tax_excluded} - $line->{ecost_tax_excluded})->format,
+ Koha::Number::Price->new( $line->{tax_rate} * 100 )->format . '%',
+ Koha::Number::Price->new( $line->{total_tax_excluded} )->format,
+ Koha::Number::Price->new( $line->{total_tax_included} )->format,
);
push(@$abaskets, $arrbasket);
}
for my $bkey (@keys) {
push(@$arrbasket, $bkey);
}
- my ($grandtotalrrpgsti, $grandtotalrrpgste, $grandtotalgsti, $grandtotalgste, $grandtotalgstvalue, $grandtotaldiscount);
+ my ($grandtotal_rrp_tax_included, $grandtotal_rrp_tax_excluded, $grandtotal_tax_included, $grandtotal_tax_excluded, $grandtotaltax_value, $grandtotaldiscount);
# calculate each basket total
push(@$abaskets, $arrbasket);
for my $basket (@$hbaskets) {
my @gst;
$arrbasket = undef;
- my ($totalrrpgste, $totalrrpgsti, $totalgste, $totalgsti, $totalgstvalue, $totaldiscount);
+ my ($total_rrp_tax_excluded, $total_rrp_tax_included, $total_tax_excluded, $total_tax_included, $totaltax_value, $totaldiscount);
my $ords = $orders->{$basket->{basketno}};
my $ordlength = @$ords;
foreach my $ord (@$ords) {
- $totalgste += $ord->{totalgste};
- $totalgsti += $ord->{totalgsti};
- $totalgstvalue += $ord->{gstvalue};
- $totaldiscount += ($ord->{rrpgste} - $ord->{ecostgste} ) * $ord->{quantity};
- $totalrrpgste += $ord->{rrpgste} * $ord->{quantity};
- $totalrrpgsti += $ord->{rrpgsti} * $ord->{quantity};
- push @gst, $ord->{gstrate};
+ $total_tax_excluded += $ord->{total_tax_excluded};
+ $total_tax_included += $ord->{total_tax_included};
+ $totaltax_value += $ord->{tax_value};
+ $totaldiscount += ($ord->{rrp_tax_excluded} - $ord->{ecost_tax_excluded} ) * $ord->{quantity};
+ $total_rrp_tax_excluded += $ord->{rrp_tax_excluded} * $ord->{quantity};
+ $total_rrp_tax_included += $ord->{rrp_tax_included} * $ord->{quantity};
+ push @gst, $ord->{tax_rate};
}
@gst = uniq map { $_ * 100 } @gst;
- $grandtotalrrpgste += $totalrrpgste;
- $grandtotalrrpgsti += $totalrrpgsti;
- $grandtotalgsti += $totalgsti;
- $grandtotalgste += $totalgste;
- $grandtotalgstvalue += $totalgstvalue;
+ $grandtotal_rrp_tax_excluded += $total_rrp_tax_excluded;
+ $grandtotal_rrp_tax_included += $total_rrp_tax_included;
+ $grandtotal_tax_included += $total_tax_included;
+ $grandtotal_tax_excluded += $total_tax_excluded;
+ $grandtotaltax_value += $totaltax_value;
$grandtotaldiscount += $totaldiscount;
my @gst_string =
map { Koha::Number::Price->new($_)->format . '%' } @gst;
push(@$arrbasket,
$basket->{contractname},
$basket->{basketname} . ' (No. ' . $basket->{basketno} . ')',
- Koha::Number::Price->new( $totalrrpgste )->format,
- Koha::Number::Price->new( $totalrrpgsti )->format,
+ Koha::Number::Price->new( $total_rrp_tax_excluded )->format,
+ Koha::Number::Price->new( $total_rrp_tax_included )->format,
"@gst_string",
- Koha::Number::Price->new( $totalgstvalue )->format,
+ Koha::Number::Price->new( $totaltax_value )->format,
Koha::Number::Price->new( $totaldiscount )->format,
- Koha::Number::Price->new( $totalgste )->format,
- Koha::Number::Price->new( $totalgsti )->format,
+ Koha::Number::Price->new( $total_tax_excluded )->format,
+ Koha::Number::Price->new( $total_tax_included )->format,
);
push(@$abaskets, $arrbasket);
}
push @$arrbasket,
'',
'Total',
- Koha::Number::Price->new( $grandtotalrrpgste )->format,
- Koha::Number::Price->new( $grandtotalrrpgsti )->format,
+ Koha::Number::Price->new( $grandtotal_rrp_tax_excluded )->format,
+ Koha::Number::Price->new( $grandtotal_rrp_tax_included )->format,
'',
- Koha::Number::Price->new( $grandtotalgstvalue )->format,
+ Koha::Number::Price->new( $grandtotaltax_value )->format,
Koha::Number::Price->new( $grandtotaldiscount )->format,
- Koha::Number::Price->new( $grandtotalgste )->format,
- Koha::Number::Price->new( $grandtotalgsti )->format;
+ Koha::Number::Price->new( $grandtotal_tax_excluded )->format,
+ Koha::Number::Price->new( $grandtotal_tax_included )->format;
push @$abaskets,$arrbasket;
# height is width and width is height in this function, as the pdf is in landscape mode for the Tables.
# get library name
my $libraryname = C4::Context->preference("LibraryName");
- # get branch details
- my $billingdetails = GetBranchDetail( $basketgroup->{billingplace} );
- my $deliverydetails = GetBranchDetail( $basketgroup->{deliveryplace} );
+ my $billing_library = Koha::Libraries->find( $basketgroup->{billingplace} );
+ my $delivery_library = Koha::Libraries->find( $basketgroup->{deliveryplace} );
my $freedeliveryplace = $basketgroup->{freedeliveryplace};
# get the subject
my $subject;
$text->text($basketgroup->{'id'});
# print the date
- my $today = C4::Dates->today();
+ my $today = output_pref({ dt => dt_from_string, dateonly => 1 });
$text->translate(130/mm, ($height-5-48)/mm);
$text->text($today);
$text->translate(100/mm, ($height-86)/mm);
$text->text($libraryname);
$text->translate(100/mm, ($height-97)/mm);
- $text->text($billingdetails->{branchname});
+ $text->text($billing_library->branchname);
$text->translate(100/mm, ($height-108.5)/mm);
- $text->text($billingdetails->{branchphone});
+ $text->text($billing_library->branchphone);
$text->translate(100/mm, ($height-115.5)/mm);
- $text->text($billingdetails->{branchfax});
+ $text->text($billing_library->branchfax);
$text->translate(100/mm, ($height-122.5)/mm);
- $text->text($billingdetails->{branchaddress1});
+ $text->text($billing_library->branchaddress1);
$text->translate(100/mm, ($height-127.5)/mm);
- $text->text($billingdetails->{branchaddress2});
+ $text->text($billing_library->branchaddress2);
$text->translate(100/mm, ($height-132.5)/mm);
- $text->text($billingdetails->{branchaddress3});
+ $text->text($billing_library->branchaddress3);
$text->translate(100/mm, ($height-137.5)/mm);
- $text->text(join(' ', $billingdetails->{branchzip}, $billingdetails->{branchcity}, $billingdetails->{branchcountry}));
+ $text->text(join(' ', $billing_library->branchzip, $billing_library->branchcity, $billing_library->branchcountry));
$text->translate(100/mm, ($height-147.5)/mm);
- $text->text($billingdetails->{branchemail});
+ $text->text($billing_library->branchemail);
# print subject
$text->translate(100/mm, ($height-145.5)/mm);
# print bookseller infos
$text->translate(100/mm, ($height-180)/mm);
- $text->text($bookseller->{name});
+ $text->text($bookseller->name);
$text->translate(100/mm, ($height-185)/mm);
- $text->text($bookseller->{postal});
+ $text->text($bookseller->postal);
$text->translate(100/mm, ($height-190)/mm);
- $text->text($bookseller->{address1});
+ $text->text($bookseller->address1);
$text->translate(100/mm, ($height-195)/mm);
- $text->text($bookseller->{address2});
+ $text->text($bookseller->address2);
$text->translate(100/mm, ($height-200)/mm);
- $text->text($bookseller->{address3});
+ $text->text($bookseller->address3);
$text->translate(100/mm, ($height-205)/mm);
- $text->text($bookseller->{accountnumber});
+ $text->text($bookseller->accountnumber);
# print delivery infos
$text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm );
$start += 5;
}
} else {
- $text->text($deliverydetails->{branchaddress1});
+ $text->text($delivery_library->branchaddress1);
$text->translate(50/mm, ($height-242)/mm);
- $text->text($deliverydetails->{branchaddress2});
+ $text->text($delivery_library->branchaddress2);
$text->translate(50/mm, ($height-247)/mm);
- $text->text($deliverydetails->{branchaddress3});
+ $text->text($delivery_library->branchaddress3);
$text->translate(50/mm, ($height-252)/mm);
- $text->text(join(' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry}));
+ $text->text(join(' ', $delivery_library->branchzip, $delivery_library->branchcity, $delivery_library->branchcountry));
}
$text->translate(50/mm, ($height-262)/mm);
$text->text($basketgroup->{deliverycomment});