epic-s6g
[kivitendo-erp.git] / Test / perl / test_action.pl
1 #!/usr/bin/perl
2 use strict;
3
4 use lib "/opt/kivitendo-erp";
5 use lib "perl";
6 use SL::LXDebug;
7 use SL::mebil::Mapping;
8 use ErrorChannel;
9
10 $::lxdebug = new LXDebug;
11
12 SL::DB->register_db(
13   domain   => 'KIVITENDO',
14   type     => 'KIVITENDO',
15   driver   => 'Pg',
16   database => 'firma',
17   host     => 'localhost',
18   username => 'kivitendo',
19   password => 'kivitendo',
20 );
21
22 my $db = SL::DB->new(domain   => 'KIVITENDO',
23   type     => 'KIVITENDO',);
24 my $dbh = $db->dbh;
25
26 my $errch = new ErrorChannel;
27 my $mapper = new SL::mebil::Mapping($errch, $dbh);
28
29 my $command = $ARGV[0];
30 if ($command eq "ShowMapping") {
31         my $mapping = $mapper->get_mapping();
32         foreach (@$mapping) {
33                 print $_->{fromacc}."\n";
34         }
35         die ("Kein Mapping vorhanden.") unless (scalar(@$mapping) > 0);
36 } elsif ($command eq "CalcMapping") {
37         (my $fromacc, my $toacc) = $mapper->calc_mapping(2022);
38 } else {
39         die "Invalid command: $command";
40 }