Revision 42fc1e70
Von Stephan Köhler vor etwa 19 Jahren hinzugefügt
SL/GL.pm | ||
---|---|---|
374 | 374 |
ORDER BY transdate, trans_id, taxkey DESC, sorttax DESC, oid|; |
375 | 375 |
my $sth = $dbh->prepare($query); |
376 | 376 |
$sth->execute || $form->dberror($query); |
377 |
|
|
378 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { |
|
379 |
print(STDERR $ref->{id}, " Transaction\n"); |
|
380 |
|
|
381 |
# gl |
|
382 |
if ($ref->{type} eq "gl") { |
|
383 |
$ref->{module} = "gl"; |
|
384 |
} |
|
385 |
|
|
386 |
# ap |
|
387 |
if ($ref->{type} eq "ap") { |
|
388 |
if ($ref->{invoice}) { |
|
389 |
$ref->{module} = "ir"; |
|
390 |
} else { |
|
391 |
$ref->{module} = "ap"; |
|
377 |
my $trans_id = ""; |
|
378 |
my $trans_id2 = ""; |
|
379 |
while (my $ref0 = $sth->fetchrow_hashref(NAME_lc)) { |
|
380 |
$trans_id = $ref0->{id}; |
|
381 |
if ($trans_id != $trans_id2) { |
|
382 |
if ($trans_id2) { |
|
383 |
push @{ $form->{GL} }, $ref; |
|
384 |
$balance = 0; |
|
392 | 385 |
} |
393 |
} |
|
394 |
|
|
395 |
# ar |
|
396 |
if ($ref->{type} eq "ar") { |
|
397 |
if ($ref->{invoice}) { |
|
398 |
$ref->{module} = "is"; |
|
399 |
} else { |
|
400 |
$ref->{module} = "ar"; |
|
386 |
$ref = $ref0; |
|
387 |
$trans_id2 = $ref->{id}; |
|
388 |
|
|
389 |
# gl |
|
390 |
if ($ref->{type} eq "gl") { |
|
391 |
$ref->{module} = "gl"; |
|
401 | 392 |
} |
402 |
} |
|
403 |
$balance = $ref->{amount}; |
|
404 |
$i = 0; |
|
405 |
$j = 0; |
|
406 |
$k = 0; |
|
407 |
$l = 0; |
|
408 |
if ($ref->{amount} < 0) { |
|
409 |
if ($ref->{chart_id} > 0) { |
|
410 |
$ref->{debit_tax}{$i} = $ref->{amount} * -1; |
|
411 |
$ref->{debit_tax_accno}{$i} = $ref->{accno}; |
|
412 |
} else { |
|
413 |
$ref->{debit}{$k} = $ref->{amount} * -1; |
|
414 |
$ref->{debit_accno}{$k} = $ref->{accno}; |
|
415 |
$ref->{debit_taxkey}{$k} = $ref->{taxkey}; |
|
393 |
# ap |
|
394 |
if ($ref->{type} eq "ap") { |
|
395 |
if ($ref->{invoice}) { |
|
396 |
$ref->{module} = "ir"; |
|
397 |
} else { |
|
398 |
$ref->{module} = "ap"; |
|
399 |
} |
|
416 | 400 |
} |
417 |
} else { |
|
418 |
if ($ref->{chart_id} > 0) { |
|
419 |
$ref->{credit_tax}{$j} = $ref->{amount}; |
|
420 |
$ref->{credit_tax_accno}{$j} = $ref->{accno}; |
|
401 |
|
|
402 |
# ar |
|
403 |
if ($ref->{type} eq "ar") { |
|
404 |
if ($ref->{invoice}) { |
|
405 |
$ref->{module} = "is"; |
|
406 |
} else { |
|
407 |
$ref->{module} = "ar"; |
|
408 |
} |
|
409 |
} |
|
410 |
$balance = $ref->{amount}; |
|
411 |
$i = 0; |
|
412 |
$j = 0; |
|
413 |
$k = 0; |
|
414 |
$l = 0; |
|
415 |
if ($ref->{amount} < 0) { |
|
416 |
if ($ref->{chart_id} > 0) { |
|
417 |
$ref->{debit_tax}{$i} = $ref->{amount} * -1; |
|
418 |
$ref->{debit_tax_accno}{$i} = $ref->{accno}; |
|
419 |
} else { |
|
420 |
$ref->{debit}{$k} = $ref->{amount} * -1; |
|
421 |
$ref->{debit_accno}{$k} = $ref->{accno}; |
|
422 |
$ref->{debit_taxkey}{$k} = $ref->{taxkey}; |
|
423 |
} |
|
421 | 424 |
} else { |
422 |
$ref->{credit}{$l} = $ref->{amount}; |
|
423 |
$ref->{credit_accno}{$l} = $ref->{accno}; |
|
424 |
$ref->{credit_taxkey}{$l} = $ref->{taxkey}; |
|
425 |
if ($ref->{chart_id} > 0) { |
|
426 |
$ref->{credit_tax}{$j} = $ref->{amount}; |
|
427 |
$ref->{credit_tax_accno}{$j} = $ref->{accno}; |
|
428 |
} else { |
|
429 |
$ref->{credit}{$l} = $ref->{amount}; |
|
430 |
$ref->{credit_accno}{$l} = $ref->{accno}; |
|
431 |
$ref->{credit_taxkey}{$l} = $ref->{taxkey}; |
|
432 |
} |
|
425 | 433 |
} |
434 |
} else { |
|
435 |
$ref2 = $ref0; |
|
436 |
$trans_id2 = $ref2->{id}; |
|
437 |
# if ($form->{accno} eq ''){ # flo & udo: if general report, |
|
438 |
# then check balance |
|
439 |
# while (abs($balance) >= 0.015) { |
|
440 |
# my $ref2 = $sth->fetchrow_hashref(NAME_lc) |
|
441 |
# || $form->error("Unbalanced ledger!"); |
|
442 |
# |
|
443 |
$balance = |
|
444 |
(int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000; |
|
445 |
if ($ref2->{amount} < 0) { |
|
446 |
if ($ref2->{chart_id} > 0) { |
|
447 |
if ($ref->{debit_tax_accno}{$i} ne "") { |
|
448 |
$i++; |
|
449 |
} |
|
450 |
$ref->{debit_tax}{$i} = $ref2->{amount} * -1; |
|
451 |
$ref->{debit_tax_accno}{$i} = $ref2->{accno}; |
|
452 |
} else { |
|
453 |
if ($ref->{debit_accno}{$k} ne "") { |
|
454 |
$k++; |
|
455 |
} |
|
456 |
$ref->{debit}{$k} = $ref2->{amount} * -1; |
|
457 |
$ref->{debit_accno}{$k} = $ref2->{accno}; |
|
458 |
$ref->{debit_taxkey}{$k} = $ref2->{taxkey}; |
|
459 |
} |
|
460 |
} else { |
|
461 |
if ($ref2->{chart_id} > 0) { |
|
462 |
if ($ref->{credit_tax_accno}{$j} ne "") { |
|
463 |
$j++; |
|
464 |
} |
|
465 |
$ref->{credit_tax}{$j} = $ref2->{amount}; |
|
466 |
$ref->{credit_tax_accno}{$j} = $ref2->{accno}; |
|
467 |
} else { |
|
468 |
if ($ref->{credit_accno}{$l} ne "") { |
|
469 |
$l++; |
|
470 |
} |
|
471 |
$ref->{credit}{$l} = $ref2->{amount}; |
|
472 |
$ref->{credit_accno}{$l} = $ref2->{accno}; |
|
473 |
$ref->{credit_taxkey}{$l} = $ref2->{taxkey}; |
|
474 |
} |
|
475 |
} |
|
476 |
# } |
|
477 |
# } else { |
|
478 |
# # if account-report, then calculate the Balance?! |
|
479 |
# # ToDo: Calculate the Balance |
|
480 |
# 1; |
|
481 |
# } |
|
426 | 482 |
} |
427 |
# if ($form->{accno} eq ''){ # flo & udo: if general report, |
|
428 |
# # then check balance |
|
429 |
# while (abs($balance) >= 0.015) { |
|
430 |
# my $ref2 = $sth->fetchrow_hashref(NAME_lc) |
|
431 |
# || $form->error("Unbalanced ledger!"); |
|
432 |
# |
|
433 |
# $balance = |
|
434 |
# (int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000; |
|
435 |
# print(STDERR $balance, " BAlance\n"); |
|
436 |
# print(STDERR $ref2->{amount}, " Ref2->amount\n"); |
|
437 |
# if ($ref2->{amount} < 0) { |
|
438 |
# if ($ref2->{chart_id} > 0) { |
|
439 |
# if ($ref->{debit_tax_accno}{$i} ne "") { |
|
440 |
# $i++; |
|
441 |
# } |
|
442 |
# $ref->{debit_tax}{$i} = $ref2->{amount} * -1; |
|
443 |
# $ref->{debit_tax_accno}{$i} = $ref2->{accno}; |
|
444 |
# } else { |
|
445 |
# if ($ref->{debit_accno}{$k} ne "") { |
|
446 |
# $k++; |
|
447 |
# } |
|
448 |
# $ref->{debit}{$k} = $ref2->{amount} * -1; |
|
449 |
# $ref->{debit_accno}{$k} = $ref2->{accno}; |
|
450 |
# $ref->{debit_taxkey}{$k} = $ref2->{taxkey}; |
|
451 |
# } |
|
452 |
# } else { |
|
453 |
# if ($ref2->{chart_id} > 0) { |
|
454 |
# if ($ref->{credit_tax_accno}{$j} ne "") { |
|
455 |
# $j++; |
|
456 |
# } |
|
457 |
# $ref->{credit_tax}{$j} = $ref2->{amount}; |
|
458 |
# $ref->{credit_tax_accno}{$j} = $ref2->{accno}; |
|
459 |
# } else { |
|
460 |
# if ($ref->{credit_accno}{$l} ne "") { |
|
461 |
# $l++; |
|
462 |
# } |
|
463 |
# $ref->{credit}{$l} = $ref2->{amount}; |
|
464 |
# $ref->{credit_accno}{$l} = $ref2->{accno}; |
|
465 |
# $ref->{credit_taxkey}{$l} = $ref2->{taxkey}; |
|
466 |
# } |
|
467 |
# } |
|
468 |
# } |
|
469 |
# } else { |
|
470 |
# # if account-report, then calculate the Balance?! |
|
471 |
# # ToDo: Calculate the Balance |
|
472 |
# 1; |
|
473 |
# } |
|
474 | 483 |
|
475 | 484 |
# print(STDERR Dumper($ref)); |
476 |
push @{ $form->{GL} }, $ref; |
|
477 |
$balance = 0; |
|
485 |
|
|
478 | 486 |
} |
487 |
push @{ $form->{GL} }, $ref; |
|
479 | 488 |
$sth->finish; |
480 | 489 |
|
481 | 490 |
if ($form->{accno}) { |
Auch abrufbar als: Unified diff
Merge von 613 aus unstable: UBL Bug
Buchungsjournal angepasst, Ueberpruefung auf UBL entfernt