$main::lxdebug->enter_sub();
my ($self, $myconfig, $form) = @_;
- my $rc;
+ my @rc;
if ($form->{exporttype} == 0) {
- $rc = &kne_buchungsexport($myconfig, $form);
+ @rc = &kne_buchungsexport($myconfig, $form);
} else {
- $rc = &kne_stammdatenexport($myconfig, $form);
+ @rc = &kne_stammdatenexport($myconfig, $form);
}
$main::lxdebug->leave_sub();
- return $rc;
+ return @rc;
}
sub obe_export {
$sth->execute || $form->dberror($query);
$i = 0;
$g = 0;
+ my $counter = 0;
@splits;
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
$count = 0;
$firstrun = 1;
+ $counter++;
+ if (($counter % 500) == 0) {
+ print("$counter ");
+ }
+
$count += $ref->{amount};
push @{$i}, $ref;
while (abs($count) > 0.01 || $firstrun) {
$blubb{'amount'} =
$form->round_amount(($i->[$j]->{'amount'} * $test * -1), 2);
- #print(STDERR $test, " Taxrate\n\n");
$blubb{'umsatz'} =
abs($form->round_amount(($i->[$j]->{'amount'} * $test), 2)) * $ml;
$i->[$j]->{'umsatz'} =
abs($form->round_amount(($i->[$j]->{'amount'} * $test), 2)) * $ml;
- #print(STDERR $i->[$j]->{'umsatz'}, " Steuer Umsatz\n");
- #print(STDERR $i->[$j]->{'amount'}, " Steuer Betrag\n");
- #print(STDERR $blubb{'umsatz'}, " Umsatz NOTSPLIT\n");
push @{ $splits[$g] }, \%blubb;
push @{ $splits[$g] }, $i->[$j];
push @{ $form->{DATEV} }, \@{ $splits[$g] };
}
}
if (abs($absumsatz) > 0.01) {
- print(STDERR $absumsatz, "ABSAUMSATZ\n");
- $form->error("Datev-Export fehlgeschlagen!");
+ $form->error("Datev-Export fehlgeschlagen! Bei Transaktion $i->[0]->{trans_id}\n");
}
} else {
push @{ $form->{DATEV} }, \@{$i};
$to =~ s/ //g;
if ($from ne "") {
- my ($fday, $fmonth, $fyear) = split /\./, $from;
+ my ($fday, $fmonth, $fyear) = split(/\./, $from);
if (length($fmonth) < 2) {
$fmonth = "0" . $fmonth;
}
$header .= $from;
if ($to ne "") {
- my ($tday, $tmonth, $tyear) = split /\./, $to;
+ my ($tday, $tmonth, $tyear) = split(/\./, $to);
if (length($tmonth) < 2) {
$tmonth = "0" . $tmonth;
}
my ($date, $six) = @_;
- ($day, $month, $year) = split /\./, $date;
+ ($day, $month, $year) = split(/\./, $date);
if ($day =~ /^0/) {
$day = substr($day, 1, 1);
my ($umsatz, $stellen) = @_;
$umsatz =~ s/-//;
- ($vorkomma, $nachkomma) = split /\./, $umsatz;
+ ($vorkomma, $nachkomma) = split(/\./, $umsatz);
$umsatz = "";
if ($stellen > 0) {
for ($i = $stellen; $i >= $stellen + 2 - length($vorkomma); $i--) {
my ($myconfig, $form) = @_;
- my $export_path = "datev/";
+ my @filenames;
+
+ my $export_path = $main::userspath . "/";
my $filename = "ED00000";
my $evfile = "EV01";
my @ed_versionsets;
my $fileno = 0;
+ $form->header;
+ print qq|
+ <html>
+ <body>Export in Bearbeitung<br>
+ Buchungssätze verarbeitet:
+|;
+
$fromto =
&get_dates($form->{zeitraum}, $form->{monat},
$form->{quartal}, $form->{transdatefrom},
$form->{transdateto});
&get_transactions($myconfig, $form, $fromto);
-
+ my $counter = 0;
+ print qq|<br>2. Durchlauf:|;
while (scalar(@{ $form->{DATEV} })) {
my $blockcount = 1;
my $remaining_bytes = 256;
my $buchungssatz = "";
$filename++;
my $ed_filename = $export_path . $filename;
+ push(@filenames, $filename);
open(ED, "> $ed_filename") or die "can't open outputfile: $!\n";
$header = &make_kne_data_header($myconfig, $form, $fromto);
$remaining_bytes -= length($header);
while (scalar(@{ $form->{DATEV} }) > 0) {
- $transaction = shift @{ $form->{DATEV} };
- $trans_lines = scalar(@{$transaction});
+ $transaction = shift @{ $form->{DATEV} };
+ $trans_lines = scalar(@{$transaction});
+ $counter++;
+ if (($counter % 500) == 0) {
+ print("$counter ");
+ }
+
$umsatz = 0;
$gegenkonto = "";
$konto = "";
'ß' => 'sz');
for (my $i = 0; $i < $trans_lines; $i++) {
- if (abs($transaction->[$i]->{'umsatz'}) > abs($umsatz)) {
- $umsatz = $transaction->[$i]->{'umsatz'};
+ if ($trans_lines == 2) {
+ if (abs($transaction->[$i]->{'amount'}) > abs($umsatz)) {
+ $umsatz = $transaction->[$i]->{'amount'};
+ }
+ } else {
+ if (abs($transaction->[$i]->{'umsatz'}) > abs($umsatz)) {
+ $umsatz = $transaction->[$i]->{'umsatz'};
+ }
}
if ($transaction->[$i]->{'datevautomatik'}) {
$datevautomatik = 1;
}
}
- $umsatzsumme += $umsatz;
+ $umsatzsumme += abs($umsatz);
# Umwandlung von Umlauten und Sonderzeichen in erlaubte Zeichen bei Textfeldern
foreach $umlaut (keys(%umlaute)) {
$blockcount++;
$total_bytes = ($blockcount) * 256;
}
+ $umsatz = abs($umsatz);
$vorzeichen = ($umsatz > 0) ? "+" : "-";
$buchungssatz .= $vorzeichen . &formatumsatz($umsatz, 0);
$remaining_bytes = $total_bytes - length($buchungssatz . $header);
#Make EV Verwaltungsdatei
$ev_header = &make_ev_header($form, $fileno);
$ev_filename = $export_path . $evfile;
+ push(@filenames, $evfile);
open(EV, "> $ev_filename") or die "can't open outputfile: EV01\n";
print(EV $ev_header);
print(EV $ed_versionset[$file]);
}
close(EV);
+ print qq|<br>Done. <br>
+|;
###
$main::lxdebug->leave_sub();
+
+ return @filenames;
}
sub kne_stammdatenexport {
my ($myconfig, $form) = @_;
$form->{abrechnungsnr} = "99";
- my $export_path = "datev/";
+ $form->header;
+ print qq|
+ <html>
+ <body>Export in Bearbeitung<br>
+|;
+
+ my @filenames;
+
+ my $export_path = $main::userspath . "/";
my $filename = "ED00000";
my $evfile = "EV01";
my @ed_versionsets;
my $buchungssatz = "";
$filename++;
my $ed_filename = $export_path . $filename;
+ push(@filenames, $filename);
open(ED, "> $ed_filename") or die "can't open outputfile: $!\n";
$header = &make_kne_data_header($myconfig, $form, "");
$remaining_bytes -= length($header);
qq|SELECT c.accno, c.description FROM chart c WHERE c.accno >=|
. $dbh->quote($form->{accnofrom}) . qq|
AND c.accno <= |
- . $dbh->quote($form->{accnoto})
- . qq| ORDER BY c.accno|;
+ . $dbh->quote($form->{accnoto}) . qq| ORDER BY c.accno|;
$sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
$ev_header = &make_ev_header($form, $fileno);
$ev_filename = $export_path . $evfile;
+ push(@filenames, $evfile);
open(EV, "> $ev_filename") or die "can't open outputfile: EV01\n";
print(EV $ev_header);
$dbh->disconnect;
###
+ print qq|<br>Done. <br>
+|;
+
$main::lxdebug->leave_sub();
+
+ return @filenames;
}
1;