Revision aea509f8
Von Moritz Bunkus vor etwa 16 Jahren hinzugefügt
SL/DATEV.pm | ||
---|---|---|
284 | 284 |
print("$counter "); |
285 | 285 |
} |
286 | 286 |
|
287 |
my $i = [ $ref ];
|
|
287 |
my $trans = [ $ref ];
|
|
288 | 288 |
|
289 | 289 |
my $count = $ref->{amount}; |
290 | 290 |
my $firstrun = 1; |
... | ... | |
293 | 293 |
my $ref2 = $sth->fetchrow_hashref(NAME_lc); |
294 | 294 |
last unless ($ref2); |
295 | 295 |
|
296 |
push @{$i}, $ref2;
|
|
296 |
push @{ $trans }, $ref2;
|
|
297 | 297 |
|
298 | 298 |
$count += $ref2->{amount}; |
299 | 299 |
$firstrun = 0; |
... | ... | |
301 | 301 |
|
302 | 302 |
my %taxid_taxkeys = (); |
303 | 303 |
my $absumsatz = 0; |
304 |
if (scalar(@{$i}) <= 2) {
|
|
305 |
push @{ $form->{DATEV} }, \@{$i};
|
|
304 |
if (scalar(@{$trans}) <= 2) {
|
|
305 |
push @{ $form->{DATEV} }, $trans;
|
|
306 | 306 |
next; |
307 | 307 |
} |
308 | 308 |
|
309 |
for my $j (0 .. (scalar(@{$i}) - 1)) {
|
|
310 |
if (abs($i->[$j]->{'amount'}) > abs($absumsatz)) {
|
|
311 |
$absumsatz = $i->[$j]->{'amount'};
|
|
309 |
for my $j (0 .. (scalar(@{$trans}) - 1)) {
|
|
310 |
if (abs($trans->[$j]->{'amount'}) > abs($absumsatz)) {
|
|
311 |
$absumsatz = $trans->[$j]->{'amount'};
|
|
312 | 312 |
$notsplitindex = $j; |
313 | 313 |
} |
314 |
if (($i->[$j]->{'taxtaxkey'}) && ($i->[$j]->{'taxid'})) {
|
|
315 |
$taxid_taxkeys{$i->[$j]->{'taxtaxkey'}} = $i->[$j]->{'taxid'};
|
|
314 |
if (($trans->[$j]->{'taxtaxkey'}) && ($trans->[$j]->{'taxid'})) {
|
|
315 |
$taxid_taxkeys{$trans->[$j]->{'taxtaxkey'}} = $trans->[$j]->{'taxid'};
|
|
316 | 316 |
} |
317 | 317 |
} |
318 |
$ml = ($i->[0]->{'umsatz'} > 0) ? 1 : -1;
|
|
319 |
for my $j (0 .. (scalar(@{$i}) - 1)) {
|
|
318 |
$ml = ($trans->[0]->{'umsatz'} > 0) ? 1 : -1;
|
|
319 |
for my $j (0 .. (scalar(@{$trans}) - 1)) {
|
|
320 | 320 |
if ( ($j != $notsplitindex) |
321 |
&& ($i->[$j]->{'chart_id'} eq "")
|
|
322 |
&& ( $i->[$j]->{'taxkey'} eq ""
|
|
323 |
|| $i->[$j]->{'taxkey'} eq "0"
|
|
324 |
|| $i->[$j]->{'taxkey'} eq "1"
|
|
325 |
|| $i->[$j]->{'taxkey'} eq "10"
|
|
326 |
|| $i->[$j]->{'taxkey'} eq "11")) {
|
|
321 |
&& ($trans->[$j]->{'chart_id'} eq "")
|
|
322 |
&& ( $trans->[$j]->{'taxkey'} eq ""
|
|
323 |
|| $trans->[$j]->{'taxkey'} eq "0"
|
|
324 |
|| $trans->[$j]->{'taxkey'} eq "1"
|
|
325 |
|| $trans->[$j]->{'taxkey'} eq "10"
|
|
326 |
|| $trans->[$j]->{'taxkey'} eq "11")) {
|
|
327 | 327 |
my %blubb = {}; |
328 |
map({ $blubb{$_} = $i->[$notsplitindex]->{$_}; } keys(%{ $i->[$notsplitindex] }));
|
|
328 |
map({ $blubb{$_} = $trans->[$notsplitindex]->{$_}; } keys(%{ $trans->[$notsplitindex] }));
|
|
329 | 329 |
|
330 |
$absumsatz += $i->[$j]->{'amount'};
|
|
331 |
$blubb{'amount'} = $i->[$j]->{'amount'} * (-1);
|
|
332 |
$blubb{'umsatz'} = abs($i->[$j]->{'amount'}) * $ml;
|
|
333 |
$i->[$j]->{'umsatz'} = abs($i->[$j]->{'amount'}) * $ml;
|
|
330 |
$absumsatz += $trans->[$j]->{'amount'};
|
|
331 |
$blubb{'amount'} = $trans->[$j]->{'amount'} * (-1);
|
|
332 |
$blubb{'umsatz'} = abs($trans->[$j]->{'amount'}) * $ml;
|
|
333 |
$trans->[$j]->{'umsatz'} = abs($trans->[$j]->{'amount'}) * $ml;
|
|
334 | 334 |
|
335 |
push @{ $splits[$g] }, \%blubb; #$i->[$notsplitindex];
|
|
336 |
push @{ $splits[$g] }, $i->[$j];
|
|
335 |
push @{ $splits[$g] }, \%blubb; #$trans->[$notsplitindex];
|
|
336 |
push @{ $splits[$g] }, $trans->[$j];
|
|
337 | 337 |
push @{ $form->{DATEV} }, \@{ $splits[$g] }; |
338 | 338 |
|
339 | 339 |
$g++; |
340 | 340 |
|
341 |
} elsif (($j != $notsplitindex) && ($i->[$j]->{'chart_id'} eq "")) {
|
|
342 |
$absumsatz += ($i->[$j]->{'amount'} * (1 + $taxes{ $taxid_taxkeys{$i->[$j]->{'taxkey'}} }));
|
|
341 |
} elsif (($j != $notsplitindex) && ($trans->[$j]->{'chart_id'} eq "")) {
|
|
342 |
$absumsatz += ($trans->[$j]->{'amount'} * (1 + $taxes{ $taxid_taxkeys{$trans->[$j]->{'taxkey'}} }));
|
|
343 | 343 |
|
344 | 344 |
my %blubb = {}; |
345 |
map({ $blubb{$_} = $i->[$notsplitindex]->{$_}; } keys(%{ $i->[$notsplitindex] }));
|
|
345 |
map({ $blubb{$_} = $trans->[$notsplitindex]->{$_}; } keys(%{ $trans->[$notsplitindex] }));
|
|
346 | 346 |
|
347 |
$test = 1 + $taxes{ $taxid_taxkeys{$i->[$j]->{'taxkey'}} };
|
|
348 |
$blubb{'amount'} = $form->round_amount(($i->[$j]->{'amount'} * $test * -1), 2);
|
|
349 |
$blubb{'umsatz'} = abs($form->round_amount(($i->[$j]->{'amount'} * $test), 2)) * $ml;
|
|
350 |
$i->[$j]->{'umsatz'} = abs($form->round_amount(($i->[$j]->{'amount'} * $test), 2)) * $ml;
|
|
347 |
$test = 1 + $taxes{ $taxid_taxkeys{$trans->[$j]->{'taxkey'}} };
|
|
348 |
$blubb{'amount'} = $form->round_amount(($trans->[$j]->{'amount'} * $test * -1), 2);
|
|
349 |
$blubb{'umsatz'} = abs($form->round_amount(($trans->[$j]->{'amount'} * $test), 2)) * $ml;
|
|
350 |
$trans->[$j]->{'umsatz'} = abs($form->round_amount(($trans->[$j]->{'amount'} * $test), 2)) * $ml;
|
|
351 | 351 |
|
352 | 352 |
push @{ $splits[$g] }, \%blubb; |
353 |
push @{ $splits[$g] }, $i->[$j];
|
|
353 |
push @{ $splits[$g] }, $trans->[$j];
|
|
354 | 354 |
push @{ $form->{DATEV} }, \@{ $splits[$g] }; |
355 | 355 |
$g++; |
356 | 356 |
} |
357 | 357 |
} |
358 | 358 |
|
359 | 359 |
if (abs($absumsatz) > 0.01) { |
360 |
$form->error("Datev-Export fehlgeschlagen! Bei Transaktion $i->[0]->{trans_id} $absumsatz\n");
|
|
360 |
$form->error("Datev-Export fehlgeschlagen! Bei Transaktion $trans->[0]->{trans_id} $absumsatz\n");
|
|
361 | 361 |
} |
362 | 362 |
} |
363 | 363 |
$sth->finish; |
Auch abrufbar als: Unified diff
Variable $i in $trans umbenannt.