From: Kilian Saffran Date: Thu, 31 May 2018 06:46:08 +0000 (+0200) Subject: Checkservice optimisation X-Git-Tag: 3.19.7 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=e1926a126817f00319dc2e10cbb3067a5cb07ab6;p=creorga.git Checkservice optimisation --- diff --git a/Tools/pdfextract.pl b/Tools/pdfextract.pl index c04fbf7..5f5c775 100644 --- a/Tools/pdfextract.pl +++ b/Tools/pdfextract.pl @@ -7,6 +7,8 @@ use File::Basename; use File::Path qw/make_path/; use Data::Dumper; use File::Copy qw/copy/; +use XML::LibXML; +use JSON::PP; use lib('.'); use sqlite; use utf8; @@ -16,17 +18,17 @@ my $outputdir=""; my $toolsdir=""; my $delorig=0; my $totext =1; -my $template = ""; +my $xmlfile = ""; my $log =""; my $db = undef; my $cmonth = "none"; my $frmonth = {"Janvier" => '01',"Février"=> '02',"Mars" => '03',"Avril" => '04', "Mai" => '05',"Juin" => '06',"Juillet" => '07',"Août" => '08',"Septembre" => '09',"Octobre" => '10',"Novembre" => '11',"Décembre" => '12'}; -#-db "C:\\Users\\ksaff\\DKS\\projects\\Creorga\\Calimero\\20170302\\diff\\5531423c-b85a-4305-9372-c62a293d0c84.sqlite" -p "C:\\Users\\ksaff\\DKS\\projects\\Creorga\\Calimero\\facture\\factures201712 (1).pdf" -t "C:\\Users\\ksaff\\Workspace\\creorga\\Tools" -x inv -l "C:\\Users\\ksaff\\DKS\\projects\\Creorga\\pdfextract.log" -o "C:\\Users\\ksaff\\DKS\\projects\\Creorga\\Calimero\\20170302\\diff\\imports\\5531423c-b85a-4305-9372-c62a293d0c84" +# -db "C:\\Users\\ksaff\\DKS\\projects\\Creorga\\Calimero\\20170327\\basch\\9475a95d-e2ad-4586-8432-d44a604b3fd3.sqlite" -p "C:\\Users\\ksaff\\DKS\\projects\\Creorga\\Calimero\\2018.3.pdf" -o "C:\\Users\\ksaff\\DKS\\projects\\Creorga\\Calimero\\20170327\\basch\\imports\\9475a95d-e2ad-4586-8432-d44a604b3fd3" -t "C:\\Debug\\Creorga\\Tools" -l "C:\\Users\\ksaff\\AppData\\Roaming\\Creorga\\Profiles\\09coeoa7.default\\lastimport.json" GetOptions("dbfile|db=s" => \$dbfile, "pdf|p=s" => \$pdffile, "outdir|o=s" => \$outputdir, "toolsdir|t=s" => \$toolsdir, - "type|x=s" => \$template, #template => [inv|stmt] + "xml|x=s" => \$xmlfile, #template => [inv|stmt] "log|l=s" => \$log ); my $sep = '/'; @@ -35,18 +37,18 @@ print "DB:".$dbfile."\n"; print "PDF:".$pdffile."\n"; print "OUTPUTDIR:".$outputdir."\n"; print "TOOLSDIR:".$toolsdir."\n"; -print "TEMPLATE:".$template."\n"; +print "XML:".$xmlfile."\n"; print "LOG:".$log."\n"; -open(LOG,">>".$log); - -print LOG "DB:".$dbfile."\r\n"; -print LOG "PDF:".$pdffile."\r\n"; -print LOG "OUTPUTDIR:".$outputdir."\r\n"; -print LOG "TOOLSDIR:".$toolsdir."\r\n"; -print LOG "TEMPLATE:".$template."\r\n"; -print LOG "LOG:".$log."\r\n"; -close(LOG); +#open(LOG,">>".$log); +# +#print LOG "DB:".$dbfile."\r\n"; +#print LOG "PDF:".$pdffile."\r\n"; +#print LOG "OUTPUTDIR:".$outputdir."\r\n"; +#print LOG "TOOLSDIR:".$toolsdir."\r\n"; +#print LOG "TEMPLATE:".$xmlfile."\r\n"; +#print LOG "LOG:".$log."\r\n"; +#close(LOG); my $pdftotext = ""; if ($^O eq "MSWin32") { @@ -59,9 +61,8 @@ if ($^O eq "MSWin32") { #} -if (($log ne "") && (! -e $log)){ - open(LOG,">".$log); - close(LOG); +if (($log ne "") && (-e $log)){ + unlink($log); } #my $filename = "C:\\projects\\creorga\\calimero\\factures201512.pdf"; @@ -74,43 +75,43 @@ if (! -e $pdftotext) { if ((! -e $dbfile)) { - open(LOG,">>".$log); - print LOG localtime().":ERROR: no database incomplete input!\n"; - close(LOG); + #open(LOG,">>".$log); + print localtime().":ERROR: no database incomplete input!\n"; + #close(LOG); exit(1); } if ((! -e $pdffile)) { - open(LOG,">>".$log); - print LOG localtime().":ERROR: no pdf incomplete input!\n"; - close(LOG); + #open(LOG,">>".$log); + print localtime().":ERROR: no pdf incomplete input!\n"; + #close(LOG); exit(1); } if ((! -d $outputdir)) { - open(LOG,">>".$log); - print LOG localtime().":ERROR: no outputdir incomplete input!\n"; - close(LOG); + #open(LOG,">>".$log); + print localtime().":ERROR: no outputdir incomplete input!\n"; + #close(LOG); exit(1); } if ((! -d $toolsdir)) { - open(LOG,">>".$log); - print LOG localtime().":ERROR: no tools dir incomplete input!\n"; - close(LOG); + #open(LOG,">>".$log); + print localtime().":ERROR: no tools dir incomplete input!\n"; + #close(LOG); exit(1); } print "1: Split du PDF en pages!\r\n"; my $oldpdf = PDF::API2->open($pdffile); #1.split pdffile -$template = lc($template); +#$template = lc($template); my @nfiles = (); my $xx = $oldpdf->pages; for my $page_nb (1..$xx) { my $newpdf = PDF::API2->new; my $page = $newpdf->importpage($oldpdf, $page_nb); - my $npdfname = $outputdir.'/'.$template.substr(basename($pdffile),0,-4).".".$page_nb.".pdf"; + my $npdfname = $outputdir.'/'.'facture'.substr(basename($pdffile),0,-4).".".$page_nb.".pdf"; push @nfiles,$npdfname; if (-e $npdfname){ unlink($npdfname); @@ -122,12 +123,28 @@ if (-e $dbfile) { #$dbfile =~ s/\\\\/\\/g; $db = sqlite->new($dbfile); } +my $xmlres = (); +if ($xmlfile ne "" && -e $xmlfile){ + my $xmldata = XML::LibXML->load_xml(location => $xmlfile); + foreach my $data ($xmldata->findnodes('//factureExterne')) { + my $ref = $data->findvalue('./referenceExterne'); + $xmlres->{$ref}->{reference} = $ref; + $xmlres->{$ref}->{crechename} = $data->findvalue('./objetBasDeFacture'); + $xmlres->{$ref}->{datefacture} = $data->findvalue('./DateFacture'); + $xmlres->{$ref}->{totalamount} = $data->findvalue('./totalTtc'); + $xmlres->{$ref}->{totalamount} = s/\,/\./g; + $xmlres->{$ref}->{totalamount} = s/\s+//g; + my @cast = map {$_->to_literal();} $data->findnodes('./lignesFacture/ligneFacture/objetLigneFacture'); + my @numchks = split("\n",$cast[0]); + my $nx = $numchks[0]; + $xmlres->{$ref}->{checkservice} = $nx; + } +} +my $allchilddata = (); if ($totext == 1) { foreach my $n (@nfiles){ - if (-e $n.'.txt'){ - unlink($n.'.txt'); - } - unlink($n.'.txt'); + if (-e $n.'.txt'){ unlink($n.'.txt');} + #unlink($n.'.txt'); print "Lire des donnees de la page: ".basename($n)."\n"; my $cmd = '"'.$pdftotext.'" -q -table -eol unix "'.$n.'" "'.$n.'.txt"'; @@ -143,22 +160,62 @@ if ($totext == 1) { } } close(PDFDATA); - if (lc($template) eq "inv") { + # if (lc($template) eq "inv") { my $childdata = &parseinvoicedata(\@pdata); - print Dumper($childdata); + #print Dumper($childdata); print "Import des donnees Check-Service No.: ".$childdata->{checkservice}."\n"; + if (exists($xmlres->{$childdata->{reference}})){ + $childdata->{checkservice} = $xmlres->{$childdata->{reference}}->{checkservice}; + $childdata->{crechename} = $xmlres->{$childdata->{reference}}->{crechename}; + if (!defined($childdata->{totalamount})){ + $childdata->{totalamount} = $xmlres->{$childdata->{reference}}->{totalamount}; + } + + } print "\n----\n"; - &importinvoicedata($childdata,$n); - }elsif (lc($template eq "stmt")){ - my $stmtdata = &parsestatementdata(\@pdata); - print "Import des données Page: ".basename($n)."\n"; - &importstatementdata($stmtdata,$n); - } - unlink("$n.txt"); + my ($impfile,$sqlres) = &importinvoicedata($childdata,$n); + #} + $childdata->{newpdffile} = $impfile; + $childdata->{sqlresult} = $sqlres; +# elsif (lc($template eq "stmt")){ +# my $stmtdata = &parsestatementdata(\@pdata); +# print "Import des données Page: ".basename($n)."\n"; +# &importstatementdata($stmtdata,$n); +# } + #print Dumper($childdata); + #print "\n==================\n"; + #unlink("$n.txt"); + $allchilddata->{$childdata->{reference}} = $childdata; } } + +} +my $newpdf = PDF::API2->new(); +#foreach my $f (@files){ +# +# +#} +#$newpdf->saveas($inputdir.'/'.$searchstr.'.pdf'); +print "Create sorted PDF of month!\n"; +my $npdfname = ""; +foreach my $ac (sort {$a cmp $b} keys(%{$allchilddata})){ + if ($npdfname eq ""){ + $npdfname = substr($allchilddata->{$ac}->{reference},0,rindex($allchilddata->{$ac}->{reference},'.')).'.pdf'; + } + if (($allchilddata->{$ac}->{newpdffile} ne "" && -f $outputdir.'/'.$allchilddata->{$ac}->{newpdffile}) ){ + my $cpdf = PDF::API2->open($outputdir.'/'.$allchilddata->{$ac}->{newpdffile}); + $newpdf->import_page($cpdf,1); + } } +$newpdf->saveas($outputdir.'/'.$npdfname); +open(LOG,">".$log); +print LOG JSON::PP::encode_json($allchilddata); +close(LOG); + +print "Normal End!\n"; + + sub parseinvoicedata(){ my $tmpdata = shift; my @invoicedata = @{$tmpdata}; @@ -190,10 +247,14 @@ sub parseinvoicedata(){ my ($tmp) = $p =~ m/.+\s\((\d+)\).+$/; $pxdata->{checkservice} = $tmp; } - if (($p =~ /\s+\(\d+\)\s*$/)) { + if (($p =~ /\s+\(\d+\)\s*$/)&& (!defined($pxdata->{checkservice}))) { my ($tmp) = $p =~ m/\s+\((\d+)\s*\)$/; $pxdata->{checkservice} = $tmp; } + if (($p =~ /\s+\(\d+\).+$/)&& (!defined($pxdata->{checkservice}))) { + my ($tmp) = $p =~ m/\s+\((\d+).+\)$/; + $pxdata->{checkservice} = $tmp; + } if (($p =~ /^\s+\(\d+\)$/) && (!defined($pxdata->{checkservice}))) { my ($tmp) = $p =~ m/\s+\((\d+)\)$/; $pxdata->{checkservice} = $tmp; @@ -326,14 +387,14 @@ sub parseinvoicedata(){ $e1 =~ s/\ //; $pxdata->{benefitamount} = $e1; } - if (($p =~ /Montant\s.\sr.gler/)) { - my ($m1) = $p =~ m/.+Montant\s.\sr.gler\s+([\s|\d]+,\d{1,2}).+$/; + if (($p =~ /Montant\s.+\sr.+gler/)) { + my ($m1) = $p =~ m/.+Montant\s.+\sr.+gler\s+([\s|\d]+,\d{1,2}).+$/; $m1 =~ s/,/\./; $m1 =~ s/\ //; $pxdata->{totalamount} = $m1; } - if (($p =~ /Montante a pagar/)) { - my ($m1) = $p =~ m/.+Montante\sa\spagarr\s+([\s|\d]+,\d{1,2}).+$/; + if (($p =~ /Montante\sa\spagar/)) { + my ($m1) = $p =~ m/.+Montante\sa\spagar\s+([\s|\d]+,\d{1,2}).+$/; $m1 =~ s/,/\./; $m1 =~ s/\ //; $pxdata->{totalamount} = $m1; @@ -355,32 +416,34 @@ sub parseinvoicedata(){ return $pxdata; } -sub parsestatementdata(){ - my $tmpdata = shift; - my @xstmtdata = @{$tmpdata}; - my $sxdata = (); - - foreach my $p (@xstmtdata){ - if ($p =~ /P.riode/) { - my ($m1,$y1,$m2,$y2) = $p =~ m/.+\s(.+)\s+(\d+)\s+.\s+(.+)\s+(\d+)$/; - if (($m1 eq $m2) && ($y1 eq $y2)){ - $cmonth=$y1.'-'.$frmonth->{$m1}; - } - } - if ($p =~ /\d{13,}/) { - my ($csnum,$am) = $p =~ m/.+\s+(\d{13,})\s+([\d|\ |,]+)$/; - $am =~ s/\s+//; - $am =~ s/,/./; - $sxdata->{$cmonth}->{$csnum}=$am; - } - #print $p."\n"; - } - return $sxdata; -} +#sub parsestatementdata(){ +# my $tmpdata = shift; +# my @xstmtdata = @{$tmpdata}; +# my $sxdata = (); +# +# foreach my $p (@xstmtdata){ +# if ($p =~ /P.riode/) { +# my ($m1,$y1,$m2,$y2) = $p =~ m/.+\s(.+)\s+(\d+)\s+.\s+(.+)\s+(\d+)$/; +# if (($m1 eq $m2) && ($y1 eq $y2)){ +# $cmonth=$y1.'-'.$frmonth->{$m1}; +# } +# } +# if ($p =~ /\d{13,}/) { +# my ($csnum,$am) = $p =~ m/.+\s+(\d{13,})\s+([\d|\ |,]+)$/; +# $am =~ s/\s+//; +# $am =~ s/,/./; +# $sxdata->{$cmonth}->{$csnum}=$am; +# } +# #print $p."\n"; +# } +# return $sxdata; +#} sub importinvoicedata(){ my $impdata = shift; my $fname = shift; + my $insdbfile = ""; + my $sqlmsg = ""; if (defined($db)){ my $child = $db->dbquerysorted("select uuid from childs where replace(checkservicenumber,' ','') = '".$impdata->{checkservice}."';"); if (keys(%{$child}) == 1) { @@ -395,10 +458,10 @@ sub importinvoicedata(){ my @upd = (); if (exists($impdata->{reference})) { push @upd,"reference='".$impdata->{reference}."'"; - my $nfname = dirname($fname).$sep.$template.'_'.$impdata->{checkservice}.'_'.$impdata->{reference}.".pdf"; + my $nfname = dirname($fname).$sep.'facture'.'_'.$impdata->{checkservice}.'_'.$impdata->{reference}.".pdf"; print "Copy to new file: ".$nfname."\n"; copy ($fname,$nfname); - my $insdbfile = basename($nfname); + $insdbfile = basename($nfname); if (-e $nfname){ print "remove extracted file: ".$fname."\n"; unlink($fname); @@ -421,17 +484,11 @@ sub importinvoicedata(){ #print $sql."\n"; my $r = $db->dbexec($sql); #my $r = 1; - if (($log ne "") && (-e $log)){ - if (!defined($r)) { - open(LOG,">>".$log); - print LOG localtime().":ERROR:".$sql."\n"; - close(LOG); + if (!defined($r)) { + $sqlmsg = "Update ERROR"; } else { - open(LOG,">>".$log); - print LOG localtime().":SUCCESS:".$sql."\n"; - close(LOG); + $sqlmsg = "Update OK"; } - } }else { my @ins1 = (); my @ins2 = (); @@ -451,10 +508,10 @@ sub importinvoicedata(){ } if (exists($impdata->{reference})) { push(@ins1,"reference");push (@ins2,"'".$impdata->{reference}."'"); - my $nfname = dirname($fname).$sep.$template.'_'.$impdata->{checkservice}.'_'.$impdata->{reference}.".pdf"; + my $nfname = dirname($fname).$sep.'facture'.'_'.$impdata->{checkservice}.'_'.$impdata->{reference}.".pdf"; print "Copy to new file: ".$nfname."\n"; copy ($fname,$nfname); - my $insdbfile = basename($nfname); + $insdbfile = basename($nfname); if (-e $nfname){ print "remove extracted file: ".$fname."\n"; unlink($fname); @@ -471,93 +528,93 @@ sub importinvoicedata(){ #print $sql."\n"; my $r = $db->dbexec($sql); - if (($log ne "") && (-e $log)){ + #if (($log ne "") && (-e $log)){ if (!defined($r)) { - open(LOG,">>".$log); - print LOG localtime()." : ERROR : ".$sql."\n"; - close(LOG); + $sqlmsg = "insert ERROR"; } else { - open(LOG,">>".$log); - print LOG localtime()." : SUCCESS : ".$sql."\n"; - close(LOG); + $sqlmsg = "insert OK"; } - } + #} } } } + else { + $sqlmsg = "Enfant pas existant! No check-service :".$impdata->{checkservice}."!"; + } + return ($insdbfile,$sqlmsg); } -sub importstatementdata(){ - my $simpdata = shift; - my $fname = shift; - #print Dumper($simpdata); - my $n=0; - foreach my $m (keys(%{$simpdata})){ - $n++; - if (-e dirname($fname).$sep."prestation.".$m."-".$n.".pdf"){ - unlink(dirname($fname).$sep."prestation.".$m."-".$n.".pdf"); - } - rename($fname,dirname($fname).$sep."prestation.".$m."-".$n.".pdf"); - foreach my $csnum (keys(%{$simpdata->{$m}})){ - $simpdata->{$m}->{fnum} = $n; - } - } - foreach my $m (keys(%{$simpdata})){ - $n++; - if ($m =~ /\d{4,}-\d{2,}/) { - foreach my $csnum (keys(%{$simpdata->{$m}})){ - print "Import Check-Service no: " + $csnum + "\n"; - if (defined($db)){ - my $child = $db->dbquerysorted("select uuid from childs where replace(checkservicenumber,' ','') = '".$csnum."';"); - if (keys(%{$child}) == 1) { - my $accdata = $db->dbquerysorted("select accmonth,childuuid from accounting where childuuid='".$child->{0}->{uuid}."' and accmonth=date('".substr($m,0,4).'-'.substr($m,5,2)."-01');"); - if (keys(%{$accdata}) == 1) { - #make update - my @upd = (); - push @upd,"benefitamount='".$simpdata->{$m}->{$csnum}."'"; - push @upd,"benefitfile='prestation.".$m."-".$simpdata->{$m}->{fnum}.".pdf'"; - my $sql = "update accounting set ".join(',',@upd)." where childuuid='".$child->{0}->{uuid}."' and accmonth=date('".substr($m,0,4).'-'.substr($m,5,2)."-01');"; - #print $sql."\n"; - my $r = $db->dbexec($sql); - if (($log ne "") && (-e $log)){ - if (!defined($r)) { - open(LOG,">>".$log); - print LOG localtime().":ERROR:".$sql."\n"; - close(LOG); - } else { - open(LOG,">>".$log); - print LOG localtime().":SUCCESS:".$sql."\n"; - close(LOG); - } - } - }else { - my @ins1 = (); - my @ins2 = (); - push(@ins1,"accmonth");push (@ins2,"date('".substr($m,0,4).'-'.substr($m,5,2)."-01')"); - push(@ins1,"childuuid");push (@ins2,"'".$child->{0}->{uuid}."'"); - push(@ins1,"benefitamount");push (@ins2,"".$simpdata->{$m}->{$csnum}.""); - push(@ins1,"benefitfile");push (@ins2,"'prestation.".$m."-".$simpdata->{$m}->{fnum}.".pdf'"); - - #accmonth,childuuid,invoicedate,invoiceamount,reference - my $sql = "insert into accounting (".join(',',@ins1).") VALUES (".join(',',@ins2).");"; - #print $sql."\n"; - my $r = $db->dbexec($sql); - if (($log ne "") && (-e $log)){ - if (!defined($r)) { - open(LOG,">>".$log); - print LOG localtime().":ERROR:".$sql."\n"; - close(LOG); - } else { - open(LOG,">>".$log); - print LOG localtime().":SUCCESS:".$sql."\n"; - close(LOG); - } - } - } - } - } - } - } - } -} \ No newline at end of file +#sub importstatementdata(){ +# my $simpdata = shift; +# my $fname = shift; +# #print Dumper($simpdata); +# my $n=0; +# foreach my $m (keys(%{$simpdata})){ +# $n++; +# if (-e dirname($fname).$sep."prestation.".$m."-".$n.".pdf"){ +# unlink(dirname($fname).$sep."prestation.".$m."-".$n.".pdf"); +# } +# rename($fname,dirname($fname).$sep."prestation.".$m."-".$n.".pdf"); +# foreach my $csnum (keys(%{$simpdata->{$m}})){ +# $simpdata->{$m}->{fnum} = $n; +# } +# } +# foreach my $m (keys(%{$simpdata})){ +# $n++; +# if ($m =~ /\d{4,}-\d{2,}/) { +# foreach my $csnum (keys(%{$simpdata->{$m}})){ +# print "Import Check-Service no: " + $csnum + "\n"; +# if (defined($db)){ +# my $child = $db->dbquerysorted("select uuid from childs where replace(checkservicenumber,' ','') = '".$csnum."';"); +# if (keys(%{$child}) == 1) { +# my $accdata = $db->dbquerysorted("select accmonth,childuuid from accounting where childuuid='".$child->{0}->{uuid}."' and accmonth=date('".substr($m,0,4).'-'.substr($m,5,2)."-01');"); +# if (keys(%{$accdata}) == 1) { +# #make update +# my @upd = (); +# push @upd,"benefitamount='".$simpdata->{$m}->{$csnum}."'"; +# push @upd,"benefitfile='prestation.".$m."-".$simpdata->{$m}->{fnum}.".pdf'"; +# my $sql = "update accounting set ".join(',',@upd)." where childuuid='".$child->{0}->{uuid}."' and accmonth=date('".substr($m,0,4).'-'.substr($m,5,2)."-01');"; +# #print $sql."\n"; +# my $r = $db->dbexec($sql); +# if (($log ne "") && (-e $log)){ +# if (!defined($r)) { +# open(LOG,">>".$log); +# print LOG localtime().":ERROR:".$sql."\n"; +# close(LOG); +# } else { +# open(LOG,">>".$log); +# print LOG localtime().":SUCCESS:".$sql."\n"; +# close(LOG); +# } +# } +# }else { +# my @ins1 = (); +# my @ins2 = (); +# push(@ins1,"accmonth");push (@ins2,"date('".substr($m,0,4).'-'.substr($m,5,2)."-01')"); +# push(@ins1,"childuuid");push (@ins2,"'".$child->{0}->{uuid}."'"); +# push(@ins1,"benefitamount");push (@ins2,"".$simpdata->{$m}->{$csnum}.""); +# push(@ins1,"benefitfile");push (@ins2,"'prestation.".$m."-".$simpdata->{$m}->{fnum}.".pdf'"); +# +# #accmonth,childuuid,invoicedate,invoiceamount,reference +# my $sql = "insert into accounting (".join(',',@ins1).") VALUES (".join(',',@ins2).");"; +# #print $sql."\n"; +# my $r = $db->dbexec($sql); +# if (($log ne "") && (-e $log)){ +# if (!defined($r)) { +# open(LOG,">>".$log); +# print LOG localtime().":ERROR:".$sql."\n"; +# close(LOG); +# } else { +# open(LOG,">>".$log); +# print LOG localtime().":SUCCESS:".$sql."\n"; +# close(LOG); +# } +# } +# } +# } +# } +# } +# } +# } +#} \ No newline at end of file diff --git a/Tools/sqlite.pm b/Tools/sqlite.pm index 396b383..54cfffc 100644 --- a/Tools/sqlite.pm +++ b/Tools/sqlite.pm @@ -25,7 +25,7 @@ sub dbquery(){ my $key = shift; my $stat = shift; my $retdata =(); - my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,RaiseError=>1,AutoCommit=>1}) or die "dbquery Connection Error!".$!; + my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,RaiseError=>1,AutoCommit=>1}) or return "dbquery Connection Error!".$!; $stat = encode("utf8", $stat); #open FILE,">>/tmp/sql.log"; @@ -53,7 +53,7 @@ sub dbquerysorted(){ my $self = shift; my $stat = shift; my $retdata = (); - my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,RaiseError=>1,AutoCommit=>1}) or die "dbquery Connection Error!".$!; + my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,RaiseError=>1,AutoCommit=>1}) or return "dbquery Connection Error!".$!; $stat = encode("utf8", $stat); #open FILE,">>/tmp/sql.log"; #print "$stat\n"; @@ -79,14 +79,14 @@ sub dbquerysorted(){ sub dbexec(){ my $self = shift; my $stat = shift; - my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,AutoCommit=>1}) or die "dbexec Connection Error!".$!; + my $dbh = DBI->connect('DBI:SQLite:dbname='.$self->{dbfile},"","",{PrintError=>1,AutoCommit=>1}) or return "dbexec Connection Error!".$!; $stat = encode("utf8", $stat); #print $stat."\n"; #open FILE,">>/Users/kilian/sql.log"; #print FILE "$stat\n"; #close FILE; my $sth = $dbh->prepare($stat); - my $rv =$dbh->do($stat) or print "Failed dbexec:\n'".$stat. "'\n\n"; + my $rv =$dbh->do($stat) or return "SQL ERROR:".$dbh->errstr; $dbh->disconnect(); return $rv; } diff --git a/app_v3/chrome/content/modules/accounting/accounting.html b/app_v3/chrome/content/modules/accounting/accounting.html index 0e794e7..6c5b9f7 100644 --- a/app_v3/chrome/content/modules/accounting/accounting.html +++ b/app_v3/chrome/content/modules/accounting/accounting.html @@ -38,6 +38,7 @@ +