Business-Payment-SwissESR
view release on metacpan or search on metacpan
lib/Business/Payment/SwissESR/PaymentSlip.pm view on Meta::CPAN
With this property you can shift the payment slip right in milimeters.
=cut
has shiftRightMm => 0;
=head2 shiftDownMm
This is for shifting the payment slip down.
=cut
has shiftDownMm => 0;
=head2 scale
Some printers seem to not be able to accurately scale the output ... this lets you
scale the payment slip in the oposite direction.
=cut
has scale => 1;
=head2 senderAddressLaTeX
A default sender address for invoice and payment slip. This can be overridden in an individual basis
=cut
has senderAddressLaTeX => sub { 'no default' };
=head2 account
The default account to be printed on the payment slips.
=cut
has 'account';
=head2 preambleAddons
Additional lines for the latex preable
=cut
has preambleAddons => sub {
return '';
};
has tasks => sub {
[];
};
# where lualatex can run to create the pdfs
has tmpDir => sub {
my $tmpDir = '/tmp/SwissESR'.$$;
if (not -d $tmpDir){
mkdir $tmpDir or die "Failed to create $tmpDir";
chmod 0700, $tmpDir;
}
return $tmpDir;
};
# clean up the temp data
sub DESTROY {
my $self = shift;
unlink glob $self->tmpDir.'/*';
unlink glob $self->tmpDir.'/.??*';
rmdir $self->tmpDir;
}
# where to find our resource files
has moduleBase => sub {
my $path = $INC{'Business/Payment/SwissESR/PaymentSlip.pm'};
$path =~ s{/[^/]+$}{};
return $path;
};
=head1 METHODS
The SwissERS objects have the following methods.
=head2 add(key=>value, ...)
Adds an invoice. Specify the following properties for each invoice:
amount => 44.40,
account => '01-17546-3',
recipientAddressLaTeX => <<'LaTeX_End',
Peter Müller\newline
Haldenweg 12b\newline
4600 Olten
LaTeX_End
bodyLaTeX => 'complete body of the letter including all addrssing',
referenceNumber => 3423,
these two properties are optional
senderAddressLaTeX => 'Override',
watermark => 'small marker to be printed on the invoice',
You can call add multiple times to generate a buch of invoices in one pdf file.
=cut
sub add {
my $self = shift;
my $cfg = { @_ };
$cfg->{senderAddressLaTeX} //= $self->senderAddressLaTeX;
$cfg->{account} //= $self->account;
push @{$self->tasks}, $cfg;
}
# execute lualatex with the given source file and return the resulting pdf or die
( run in 1.682 second using v1.01-cache-2.11-cpan-6736b670a1e )