
| Current Path : /var/www/web-klick.de/dsh/50_dev2017/1300__perllib/Application/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/web-klick.de/dsh/50_dev2017/1300__perllib/Application/SQLFiBu.pm |
#print Dumper (Application::IfTFiBu->new()->shell(@ARGV));
package Application::FiBu;
use strict;
use Digest::SHA1;
use Data::Dumper;
use Cwd;
use Application::IfTRules;
use DBI;
use DBD::SQLite;
# our $slash = "/";
#*****************************************************************
sub new {
my $class = shift;
my $self = {};
bless($self,$class);
return($self);
}
#*****************************************************************
sub make_ukto {
my $self = shift;
my $buch = shift; # File, welches die Buchhaltung enthaelt
my $kto = shift; # Unterkonto
my $format = shift; # gewuenschtes Format
my $file = "./" . $buch; # Name des Exportfiles
$file =~ s/^(.*)[\\\/](.*\_)([a-z0-9][a-z0-9][a-z0-9][a-z0-9])\.(.*)$/$1\/$kto\/$2\_9999\.$format/;
mkdir("$1/$2");
my $dbh;
if (!(-f $buch)) {
$dbh = DBI->connect("dbi:SQLite:$buch");
$dbh->do("create table buchung (datum,betrag,kto1,kto2,remark)");
$dbh->do("create table konto (kto,bezeichnung)");
$dbh->do("create index buchung_datum on buchung (datum)");
$dbh->do("create index buchung_kto1 on buchung (kto1)");
$dbh->do("create index buchung_kto2 on buchung (kto2)");
$dbh->do("create index konto_bezeichnung on konto (bezeichnung)");
DBI->disconnect();
}
if ($format eq "sql") {
system("cp $buch $buch.$$.tmp");
$dbh = DBI->connect("dbi:SQLite:$buch.tmp");
} else {
$dbh = DBI->connect("dbi:SQLite:$buch");
}
my $kto_formatter_class = "Application::Format_$kto";
eval("use $kto_formatter_class");
if ($@) { return("ERROR: $@"); }
my $kto_formatter_singleton = $kto_formatter_class->new($dbh);
my $difflist = $kto_formatter_singleton->export($kto);
if ($difflist =~ /^ERROR/) { return($difflist); }
foreach $o (@$difflist) { # Einspielen der Aenderungen, wenn welche zurueckgegeben wurden
$dbh->do($o);
}
}
#*************************************************************************************
1;