summaryrefslogtreecommitdiff
path: root/bin/moms-ifyllning.pl
blob: 8f8d46b49d732e7c47daecb905366d0e7303b24b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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;