epic-s6g
[kivitendo-erp.git] / Test / perl / test_action.pl
index 5611dac..069cc14 100755 (executable)
@@ -1,16 +1,12 @@
 #!/usr/bin/perl
 use strict;
 
-#use SL::Controller::Mebil;
-use SL::DB;
-use SL::Form;
+use lib "/opt/kivitendo-erp";
 use SL::LXDebug;
-use SL::DB::Manager::MebilMapping;
+use SL::mebil::Mapping;
+use Test::perl::ErrorChannel;
 
 $::lxdebug = new LXDebug;
-#$::form    = new Form;
-
-#my $dbh = $::form->get_standard_dbh;
 
 SL::DB->register_db(
   domain   => 'KIVITENDO',
@@ -26,13 +22,18 @@ my $db = SL::DB->new(domain   => 'KIVITENDO',
   type     => 'KIVITENDO',);
 my $dbh = $db->dbh;
 
-#$dbh->do("SELECT * FROM mebil_mapping");
-
-#$db->begin_work or die $db->error;
-#my $m = new SL::Controller::Mebil;
-#$m->action_calcmap;
-my $mappings = SL::DB::Manager::MebilMapping->get_objects(dbh => $dbh);
-
-foreach my $map (@$mappings) {
-        print ("$map\n");
+my $errch = new ErrorChannel;
+my $mapper = new SL::mebil::Mapping($errch, $dbh);
+
+my $command = $ARGV[0];
+if ($command eq "GetMapping") {
+       my $mapping = $mapper->get_mapping();
+       foreach (@$mapping) {
+               print $_->{fromacc}."\n";
+       }
+       die ("Kein Mapping vorhanden.") unless (scalar(@$mapping) > 0);
+} elsif ($command eq "CalcMapping") {
+       die ("NIY.");
+} else {
+       die "Invalid command: $command";
 }