diff options
Diffstat (limited to 'bin/moms-ifyllning.pl')
-rwxr-xr-x | bin/moms-ifyllning.pl | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/bin/moms-ifyllning.pl b/bin/moms-ifyllning.pl new file mode 100755 index 0000000..8f8d46b --- /dev/null +++ b/bin/moms-ifyllning.pl @@ -0,0 +1,55 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use GD::SVG; +use User::pwent; + +my ($full_name) = (User::pwent::getpwnam(getlogin)->gecos)[0] =~ /([^,]*),+$/; + +open FILE, $ARGV[0] or die $!; +my %values; +my ($key, $value); +while (my $line = <FILE>) { + chomp($line); + ($key, $value) = $line =~ /^(.*): *(.*)/g; + $values{$key} = $value; +} +close FILE; + +if (int($values{'A05'}*0.25+0.5) ne $values{'B10'}) { + print STDERR "Utgående moms stämmer icke! (A05, B10)\n"; + exit 1; +} + +if ($values{'B10'}-$values{'F48'} ne $values{'G49'}) { + print STDERR "Momsberäkning balanserar icke! (B10-F48 != G49)\n"; + print STDERR "B10 - F48 = $values{'B10'} - $values{'F48'} == " + .($values{'B10'}-$values{'F48'})."\n"; + print STDERR "G49 = $values{'G49'} == ".($values{'G49'})."\n"; + exit 1; +} + +my $moms = GD::SVG::Image->new(792, 1122); + +my $moms_white = $moms->colorAllocate(255,255,255); +my $moms_black = $moms->colorAllocate(0,0,0); +my $font = gdLargeFont; + +$moms->startGroup('ne-1'); +$moms->rectangle(0,0,792,1122, $moms_white); + +$moms->string($font, 219, 297, $values{'A05'}, $moms_black); +$moms->string($font, 563, 297, $values{'B10'}, $moms_black); +$moms->string($font, 563, 786, $values{'F48'}, $moms_black); +$moms->string($font, 563, 851, $values{'G49'}, $moms_black); + +$moms->string($font, 427, 945, $full_name, $moms_black); +$moms->string($font, 427, 977, $full_name, $moms_black); +$moms->string($font, 427, 1008, $values{'phone'}, $moms_black); + +$moms->endGroup; + +open(SVGFILE, ">moms-overlay.svg"); +print SVGFILE $moms->svg; |