Revision d05b351d
Von Udo Spallek vor fast 19 Jahren hinzugefügt
SL/GL.pm | ||
---|---|---|
362 | 362 |
} |
363 | 363 |
|
364 | 364 |
my $query = |
365 |
qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link,
|
|
365 |
qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, t.taxkey AS sorttax,
|
|
366 | 366 |
g.description, ac.transdate, ac.source, ac.trans_id, |
367 | 367 |
ac.amount, c.accno, c.gifi_accno, g.notes, t.chart_id, ac.oid |
368 | 368 |
FROM gl g, acc_trans ac, chart c LEFT JOIN tax t ON |
... | ... | |
371 | 371 |
AND ac.chart_id = c.id |
372 | 372 |
AND g.id = ac.trans_id |
373 | 373 |
UNION |
374 |
SELECT a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
|
|
374 |
SELECT a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, t.taxkey AS sorttax,
|
|
375 | 375 |
ct.name, ac.transdate, ac.source, ac.trans_id, |
376 | 376 |
ac.amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid |
377 | 377 |
FROM ar a, acc_trans ac, customer ct, chart c LEFT JOIN tax t ON |
... | ... | |
381 | 381 |
AND a.customer_id = ct.id |
382 | 382 |
AND a.id = ac.trans_id |
383 | 383 |
UNION |
384 |
SELECT a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
|
|
384 |
SELECT a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, t.taxkey AS sorttax,
|
|
385 | 385 |
ct.name, ac.transdate, ac.source, ac.trans_id, |
386 | 386 |
ac.amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid |
387 | 387 |
FROM ap a, acc_trans ac, vendor ct, chart c LEFT JOIN tax t ON |
... | ... | |
390 | 390 |
AND ac.chart_id = c.id |
391 | 391 |
AND a.vendor_id = ct.id |
392 | 392 |
AND a.id = ac.trans_id |
393 |
ORDER BY $sortorder transdate, trans_id, taxkey DESC, oid|; |
|
394 |
|
|
395 |
# Show all $query in Debuglevel LXDebug::QUERY |
|
396 |
$callingdetails = (caller (0))[3]; |
|
397 |
$main::lxdebug->message(LXDebug::QUERY, "$callingdetails \$query=\n $query"); |
|
398 |
|
|
393 |
ORDER BY $sortorder transdate, trans_id, taxkey DESC, sorttax DESC,oid|; |
|
399 | 394 |
my $sth = $dbh->prepare($query); |
400 | 395 |
$sth->execute || $form->dberror($query); |
401 | 396 |
my $trans_id = ""; |
402 | 397 |
my $trans_id2 = ""; |
403 |
|
|
404 | 398 |
while (my $ref0 = $sth->fetchrow_hashref(NAME_lc)) { |
405 |
|
|
406 | 399 |
$trans_id = $ref0->{id}; |
407 |
|
|
408 | 400 |
if ($trans_id != $trans_id2) { |
409 |
|
|
410 | 401 |
if ($trans_id2) { |
411 | 402 |
push @{ $form->{GL} }, $ref; |
412 | 403 |
$balance = 0; |
413 | 404 |
} |
414 |
|
|
415 | 405 |
$ref = $ref0; |
416 | 406 |
$trans_id2 = $ref->{id}; |
417 | 407 |
|
... | ... | |
437 | 427 |
$ref->{module} = "ar"; |
438 | 428 |
} |
439 | 429 |
} |
440 |
|
|
441 | 430 |
$balance = $ref->{amount}; |
442 |
|
|
443 | 431 |
$i = 0; |
444 | 432 |
$j = 0; |
445 | 433 |
$k = 0; |
446 | 434 |
$l = 0; |
447 |
|
|
448 | 435 |
if ($ref->{amount} < 0) { |
449 | 436 |
if ($ref->{chart_id} > 0) { |
450 | 437 |
$ref->{debit_tax}{$i} = $ref->{amount} * -1; |
... | ... | |
454 | 441 |
$ref->{debit_accno}{$k} = $ref->{accno}; |
455 | 442 |
$ref->{debit_taxkey}{$k} = $ref->{taxkey}; |
456 | 443 |
} |
457 |
|
|
458 | 444 |
} else { |
459 |
|
|
460 | 445 |
if ($ref->{chart_id} > 0) { |
461 | 446 |
$ref->{credit_tax}{$j} = $ref->{amount}; |
462 | 447 |
$ref->{credit_tax_accno}{$j} = $ref->{accno}; |
... | ... | |
465 | 450 |
$ref->{credit_accno}{$l} = $ref->{accno}; |
466 | 451 |
$ref->{credit_taxkey}{$l} = $ref->{taxkey}; |
467 | 452 |
} |
468 |
|
|
469 | 453 |
} |
470 |
|
|
471 | 454 |
} else { |
472 |
|
|
473 | 455 |
$ref2 = $ref0; |
474 |
$trans_old =$trans_id2; |
|
475 | 456 |
$trans_id2 = $ref2->{id}; |
476 |
|
|
457 |
|
|
458 |
# if ($form->{accno} eq ''){ # flo & udo: if general report, |
|
459 |
# then check balance |
|
460 |
# while (abs($balance) >= 0.015) { |
|
461 |
# my $ref2 = $sth->fetchrow_hashref(NAME_lc) |
|
462 |
# || $form->error("Unbalanced ledger!"); |
|
463 |
# |
|
477 | 464 |
$balance = |
478 | 465 |
(int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000; |
479 |
|
|
480 | 466 |
if ($ref2->{amount} < 0) { |
481 |
|
|
482 | 467 |
if ($ref2->{chart_id} > 0) { |
483 |
|
|
484 | 468 |
if ($ref->{debit_tax_accno}{$i} ne "") { |
485 | 469 |
$i++; |
486 | 470 |
} |
487 |
|
|
488 |
if ($ref2->{link} =~ /AR_tax/) { |
|
489 |
$ref->{credit_tax}{$j} = $ref2->{amount}; |
|
490 |
$ref->{credit_tax_accno}{$j} = $ref2->{accno}; |
|
491 |
} |
|
492 |
if ($ref2->{link} =~ /AP_tax/) { |
|
493 |
$ref->{debit_tax}{$j} = $ref2->{amount} * -1; |
|
494 |
$ref->{debit_tax_accno}{$j} = $ref2->{accno}; |
|
495 |
} |
|
496 |
|
|
471 |
$ref->{debit_tax}{$i} = $ref2->{amount} * -1; |
|
472 |
$ref->{debit_tax_accno}{$i} = $ref2->{accno}; |
|
497 | 473 |
} else { |
498 |
|
|
499 | 474 |
if ($ref->{debit_accno}{$k} ne "") { |
500 | 475 |
$k++; |
501 | 476 |
} |
... | ... | |
503 | 478 |
$ref->{debit_accno}{$k} = $ref2->{accno}; |
504 | 479 |
$ref->{debit_taxkey}{$k} = $ref2->{taxkey}; |
505 | 480 |
} |
506 |
|
|
507 | 481 |
} else { |
508 |
|
|
509 | 482 |
if ($ref2->{chart_id} > 0) { |
510 |
|
|
511 | 483 |
if ($ref->{credit_tax_accno}{$j} ne "") { |
512 | 484 |
$j++; |
513 | 485 |
} |
514 |
|
|
515 |
if ($ref2->{link} =~ /AR_tax/) { |
|
516 |
$ref->{credit_tax}{$j} = $ref2->{amount}; |
|
517 |
$ref->{credit_tax_accno}{$j} = $ref2->{accno}; |
|
518 |
} |
|
519 |
if ($ref2->{link} =~ /AP_tax/) { |
|
520 |
$ref->{debit_tax}{$j} = $ref2->{amount} * -1; |
|
521 |
$ref->{debit_tax_accno}{$j} = $ref2->{accno}; |
|
522 |
} |
|
523 |
|
|
486 |
$ref->{credit_tax}{$j} = $ref2->{amount}; |
|
487 |
$ref->{credit_tax_accno}{$j} = $ref2->{accno}; |
|
524 | 488 |
} else { |
525 |
|
|
526 | 489 |
if ($ref->{credit_accno}{$l} ne "") { |
527 | 490 |
$l++; |
528 | 491 |
} |
... | ... | |
531 | 494 |
$ref->{credit_taxkey}{$l} = $ref2->{taxkey}; |
532 | 495 |
} |
533 | 496 |
} |
497 |
|
|
498 |
# } |
|
499 |
# } else { |
|
500 |
# # if account-report, then calculate the Balance?! |
|
501 |
# # ToDo: Calculate the Balance |
|
502 |
# 1; |
|
503 |
# } |
|
534 | 504 |
} |
505 |
|
|
535 | 506 |
} |
536 | 507 |
push @{ $form->{GL} }, $ref; |
537 | 508 |
$sth->finish; |
Auch abrufbar als: Unified diff
Reopend Bug 246: Buchungsjournal stellt Stornobuchungen verwirrend dar.
Reverse commits 1005, 1007, 1008 back to 1004.
Reason, Doesn't work proper.