31 |
31 |
#
|
32 |
32 |
#======================================================================
|
33 |
33 |
|
|
34 |
use POSIX qw(strftime);
|
|
35 |
|
34 |
36 |
use SL::GL;
|
35 |
37 |
use SL::IS;
|
36 |
38 |
use SL::PE;
|
|
39 |
use SL::ReportGenerator;
|
37 |
40 |
|
38 |
41 |
require "bin/mozilla/arap.pl";
|
39 |
42 |
require "bin/mozilla/common.pl";
|
|
43 |
require "bin/mozilla/report_generator.pl";
|
40 |
44 |
|
41 |
45 |
1;
|
42 |
46 |
|
... | ... | |
204 |
208 |
sub search {
|
205 |
209 |
$lxdebug->enter_sub();
|
206 |
210 |
|
207 |
|
$form->{title} = $locale->text('Buchungsjournal');
|
|
211 |
$form->{title} = $locale->text('Journal');
|
208 |
212 |
|
209 |
213 |
$form->all_departments(\%myconfig);
|
210 |
214 |
|
... | ... | |
392 |
396 |
$lxdebug->leave_sub();
|
393 |
397 |
}
|
394 |
398 |
|
395 |
|
sub generate_report {
|
|
399 |
sub create_subtotal_row {
|
396 |
400 |
$lxdebug->enter_sub();
|
397 |
401 |
|
398 |
|
$form->{sort} = "transdate" unless $form->{sort};
|
|
402 |
my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_;
|
399 |
403 |
|
400 |
|
GL->all_transactions(\%myconfig, \%$form);
|
|
404 |
my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
|
401 |
405 |
|
402 |
|
$callback =
|
403 |
|
"$form->{script}?action=generate_report&login=$form->{login}&password=$form->{password}";
|
|
406 |
map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } @{ $subtotal_columns };
|
404 |
407 |
|
405 |
|
$href = $callback;
|
|
408 |
map { $totals->{$_} = 0 } @{ $subtotal_columns };
|
406 |
409 |
|
407 |
|
%acctype = ('A' => $locale->text('Asset'),
|
408 |
|
'C' => $locale->text('Contra'),
|
409 |
|
'L' => $locale->text('Liability'),
|
410 |
|
'Q' => $locale->text('Equity'),
|
411 |
|
'I' => $locale->text('Revenue'),
|
412 |
|
'E' => $locale->text('Expense'),);
|
|
410 |
$lxdebug->leave_sub();
|
413 |
411 |
|
414 |
|
$form->{title} = $locale->text('General Ledger');
|
|
412 |
return $row;
|
|
413 |
}
|
415 |
414 |
|
416 |
|
$ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1;
|
|
415 |
sub generate_report {
|
|
416 |
$lxdebug->enter_sub();
|
417 |
417 |
|
418 |
|
unless ($form->{category} eq 'X') {
|
|
418 |
$form->{sort} ||= "transdate";
|
|
419 |
|
|
420 |
GL->all_transactions(\%myconfig, \%$form);
|
|
421 |
|
|
422 |
my %acctype = ('A' => $locale->text('Asset'),
|
|
423 |
'C' => $locale->text('Contra'),
|
|
424 |
'L' => $locale->text('Liability'),
|
|
425 |
'Q' => $locale->text('Equity'),
|
|
426 |
'I' => $locale->text('Revenue'),
|
|
427 |
'E' => $locale->text('Expense'),);
|
|
428 |
|
|
429 |
$form->{title} = $locale->text('Journal');
|
|
430 |
if ($form->{category} ne 'X') {
|
419 |
431 |
$form->{title} .= " : " . $locale->text($acctype{ $form->{category} });
|
420 |
432 |
}
|
|
433 |
|
|
434 |
$form->{landscape} = 1;
|
|
435 |
|
|
436 |
my $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1;
|
|
437 |
|
|
438 |
my @columns = qw(
|
|
439 |
transdate id reference description
|
|
440 |
notes source debit debit_accno
|
|
441 |
credit credit_accno debit_tax debit_tax_accno
|
|
442 |
credit_tax credit_tax_accno projectnumbers balance
|
|
443 |
);
|
|
444 |
|
|
445 |
my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto category l_subtotal);
|
|
446 |
push @hidden_variables, map { "l_${_}" } @columns;
|
|
447 |
|
|
448 |
my (@options, $date_option);
|
421 |
449 |
if ($form->{accno}) {
|
422 |
|
$href .= "&accno=" . $form->escape($form->{accno});
|
423 |
|
$callback .= "&accno=" . $form->escape($form->{accno}, 1);
|
424 |
|
$option =
|
425 |
|
$locale->text('Account')
|
426 |
|
. " : $form->{accno} $form->{account_description}";
|
|
450 |
push @options, $locale->text('Account') . " : $form->{accno} $form->{account_description}";
|
427 |
451 |
}
|
428 |
452 |
if ($form->{source}) {
|
429 |
|
$href .= "&source=" . $form->escape($form->{source});
|
430 |
|
$callback .= "&source=" . $form->escape($form->{source}, 1);
|
431 |
|
$option .= "\n<br>" if $option;
|
432 |
|
$option .= $locale->text('Source') . " : $form->{source}";
|
|
453 |
push @options, $locale->text('Source') . " : $form->{source}";
|
433 |
454 |
}
|
434 |
455 |
if ($form->{reference}) {
|
435 |
|
$href .= "&reference=" . $form->escape($form->{reference});
|
436 |
|
$callback .= "&reference=" . $form->escape($form->{reference}, 1);
|
437 |
|
$option .= "\n<br>" if $option;
|
438 |
|
$option .= $locale->text('Reference') . " : $form->{reference}";
|
|
456 |
push @options, $locale->text('Reference') . " : $form->{reference}";
|
439 |
457 |
}
|
440 |
458 |
if ($form->{department}) {
|
441 |
|
$href .= "&department=" . $form->escape($form->{department});
|
442 |
|
$callback .= "&department=" . $form->escape($form->{department}, 1);
|
443 |
|
($department) = split /--/, $form->{department};
|
444 |
|
$option .= "\n<br>" if $option;
|
445 |
|
$option .= $locale->text('Department') . " : $department";
|
|
459 |
my ($department) = split /--/, $form->{department};
|
|
460 |
push @options, $locale->text('Department') . " : $department";
|
446 |
461 |
}
|
447 |
|
|
448 |
462 |
if ($form->{description}) {
|
449 |
|
$href .= "&description=" . $form->escape($form->{description});
|
450 |
|
$callback .= "&description=" . $form->escape($form->{description}, 1);
|
451 |
|
$option .= "\n<br>" if $option;
|
452 |
|
$option .= $locale->text('Description') . " : $form->{description}";
|
|
463 |
push @options, $locale->text('Description') . " : $form->{description}";
|
453 |
464 |
}
|
454 |
465 |
if ($form->{notes}) {
|
455 |
|
$href .= "¬es=" . $form->escape($form->{notes});
|
456 |
|
$callback .= "¬es=" . $form->escape($form->{notes}, 1);
|
457 |
|
$option .= "\n<br>" if $option;
|
458 |
|
$option .= $locale->text('Notes') . " : $form->{notes}";
|
459 |
|
}
|
460 |
|
if ($form->{project_id}) {
|
461 |
|
$href .= "&project_id=" . $form->escape($form->{project_id});
|
462 |
|
$callback .= "&project_id=" . $form->escape($form->{project_id});
|
|
466 |
push @options, $locale->text('Notes') . " : $form->{notes}";
|
463 |
467 |
}
|
464 |
|
|
465 |
468 |
if ($form->{datefrom}) {
|
466 |
|
$href .= "&datefrom=$form->{datefrom}";
|
467 |
|
$callback .= "&datefrom=$form->{datefrom}";
|
468 |
|
$option .= "\n<br>" if $option;
|
469 |
|
$option .=
|
470 |
|
$locale->text('From') . " "
|
471 |
|
. $locale->date(\%myconfig, $form->{datefrom}, 1);
|
|
469 |
$date_option = $locale->text('From') . " " . $locale->date(\%myconfig, $form->{datefrom}, 1);
|
472 |
470 |
}
|
473 |
471 |
if ($form->{dateto}) {
|
474 |
|
$href .= "&dateto=$form->{dateto}";
|
475 |
|
$callback .= "&dateto=$form->{dateto}";
|
476 |
472 |
if ($form->{datefrom}) {
|
477 |
|
$option .= " ";
|
478 |
|
} else {
|
479 |
|
$option .= "\n<br>" if $option;
|
|
473 |
$date_option .= " ";
|
480 |
474 |
}
|
481 |
|
$option .=
|
482 |
|
$locale->text('Bis') . " "
|
483 |
|
. $locale->date(\%myconfig, $form->{dateto}, 1);
|
|
475 |
$date_option .= $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{dateto}, 1);
|
484 |
476 |
}
|
485 |
|
|
486 |
|
@columns = $form->sort_columns( qw(
|
487 |
|
transdate id reference description
|
488 |
|
notes source debit debit_accno
|
489 |
|
credit credit_accno debit_tax debit_tax_accno
|
490 |
|
credit_tax credit_tax_accno accno
|
491 |
|
projectnumbers
|
492 |
|
)
|
|
477 |
push @options, $date_option if $date_option;
|
|
478 |
|
|
479 |
my $callback = build_std_url('action=generate_report', @hidden_variables);
|
|
480 |
|
|
481 |
$form->{l_credit_accno} = 'Y';
|
|
482 |
$form->{l_debit_accno} = 'Y';
|
|
483 |
$form->{l_credit_tax} = 'Y';
|
|
484 |
$form->{l_debit_tax} = 'Y';
|
|
485 |
$form->{l_credit_tax_accno} = 'Y';
|
|
486 |
$form->{l_debit_tax_accno} = 'Y';
|
|
487 |
$form->{l_balance} = $form->{accno} ? 'Y' : '';
|
|
488 |
|
|
489 |
my %column_defs = (
|
|
490 |
'id' => { 'text' => $locale->text('ID'), },
|
|
491 |
'transdate' => { 'text' => $locale->text('Date'), },
|
|
492 |
'reference' => { 'text' => $locale->text('Reference'), },
|
|
493 |
'source' => { 'text' => $locale->text('Source'), },
|
|
494 |
'description' => { 'text' => $locale->text('Description'), },
|
|
495 |
'notes' => { 'text' => $locale->text('Notes'), },
|
|
496 |
'debit' => { 'text' => $locale->text('Debit'), },
|
|
497 |
'debit_accno' => { 'text' => $locale->text('Debit Account'), },
|
|
498 |
'credit' => { 'text' => $locale->text('Credit'), },
|
|
499 |
'credit_accno' => { 'text' => $locale->text('Credit Account'), },
|
|
500 |
'debit_tax' => { 'text' => $locale->text('Debit Tax'), },
|
|
501 |
'debit_tax_accno' => { 'text' => $locale->text('Debit Tax Account'), },
|
|
502 |
'credit_tax' => { 'text' => $locale->text('Credit Tax'), },
|
|
503 |
'credit_tax_accno' => { 'text' => $locale->text('Credit Tax Account'), },
|
|
504 |
'balance' => { 'text' => $locale->text('Balance'), },
|
|
505 |
'projectnumbers' => { 'text' => $locale->text('Project Numbers'), },
|
493 |
506 |
);
|
494 |
507 |
|
495 |
|
if ($form->{accno}) {
|
496 |
|
@columns = grep !/accno/, @columns;
|
497 |
|
push @columns, "balance";
|
498 |
|
$form->{l_balance} = "Y";
|
|
508 |
map { $column_defs{$_}->{link} = $callback . "&sort=${_}" } qw(id transdate reference source description);
|
|
509 |
map { $column_defs{$_}->{link} = $callback . "&sort=accno" } qw(debit_accno credit_accno debit_tax_accno credit_tax_accno debit_tax credit_tax);
|
|
510 |
map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
|
|
511 |
map { $column_defs{$_}->{visible} = 0 } qw(debit_accno credit_accno debit_tax_accno credit_tax_accno) if $form->{accno};
|
499 |
512 |
|
500 |
|
}
|
|
513 |
my %column_alignment;
|
|
514 |
map { $column_alignment{$_} = 'right' } qw(balance id debit credit debit_tax credit_tax);
|
|
515 |
map { $column_alignment{$_} = 'center' } qw(transdate reference description source notes debit_accno credit_accno debit_tax_accno credit_tax_accno);
|
501 |
516 |
|
502 |
|
$form->{l_credit_accno} = "Y";
|
503 |
|
$form->{l_debit_accno} = "Y";
|
504 |
|
$form->{l_credit_tax} = "Y";
|
505 |
|
$form->{l_debit_tax} = "Y";
|
506 |
|
$form->{l_credit_tax_accno} = "Y";
|
507 |
|
$form->{l_debit_tax_accno} = "Y";
|
508 |
|
$form->{l_accno} = "N";
|
509 |
|
foreach $item (@columns) {
|
510 |
|
if ($form->{"l_$item"} eq "Y") {
|
511 |
|
push @column_index, $item;
|
512 |
|
|
513 |
|
# add column to href and callback
|
514 |
|
$callback .= "&l_$item=Y";
|
515 |
|
$href .= "&l_$item=Y";
|
516 |
|
}
|
517 |
|
}
|
518 |
|
|
519 |
|
if ($form->{l_subtotal} eq 'Y') {
|
520 |
|
$callback .= "&l_subtotal=Y";
|
521 |
|
$href .= "&l_subtotal=Y";
|
522 |
|
}
|
523 |
|
|
524 |
|
$callback .= "&category=$form->{category}";
|
525 |
|
$href .= "&category=$form->{category}";
|
526 |
|
|
527 |
|
$column_header{id} =
|
528 |
|
"<th><a class=listheading href=$href&sort=id>"
|
529 |
|
. $locale->text('ID')
|
530 |
|
. "</a></th>";
|
531 |
|
$column_header{transdate} =
|
532 |
|
"<th><a class=listheading href=$href&sort=transdate>"
|
533 |
|
. $locale->text('Date')
|
534 |
|
. "</a></th>";
|
535 |
|
$column_header{reference} =
|
536 |
|
"<th><a class=listheading href=$href&sort=reference>"
|
537 |
|
. $locale->text('Reference')
|
538 |
|
. "</a></th>";
|
539 |
|
$column_header{source} =
|
540 |
|
"<th><a class=listheading href=$href&sort=source>"
|
541 |
|
. $locale->text('Source')
|
542 |
|
. "</a></th>";
|
543 |
|
$column_header{description} =
|
544 |
|
"<th><a class=listheading href=$href&sort=description>"
|
545 |
|
. $locale->text('Description')
|
546 |
|
. "</a></th>";
|
547 |
|
$column_header{notes} =
|
548 |
|
"<th class=listheading>" . $locale->text('Notes') . "</th>";
|
549 |
|
$column_header{debit} =
|
550 |
|
"<th class=listheading>" . $locale->text('Debit') . "</th>";
|
551 |
|
$column_header{debit_accno} =
|
552 |
|
"<th><a class=listheading href=$href&sort=accno>"
|
553 |
|
. $locale->text('Debit Account')
|
554 |
|
. "</a></th>";
|
555 |
|
$column_header{credit} =
|
556 |
|
"<th class=listheading>" . $locale->text('Credit') . "</th>";
|
557 |
|
$column_header{credit_accno} =
|
558 |
|
"<th><a class=listheading href=$href&sort=accno>"
|
559 |
|
. $locale->text('Credit Account')
|
560 |
|
. "</a></th>";
|
561 |
|
$column_header{debit_tax} =
|
562 |
|
"<th><a class=listheading href=$href&sort=accno>"
|
563 |
|
. $locale->text('Debit Tax')
|
564 |
|
. "</a></th>";
|
565 |
|
$column_header{debit_tax_accno} =
|
566 |
|
"<th><a class=listheading href=$href&sort=accno>"
|
567 |
|
. $locale->text('Debit Tax Account')
|
568 |
|
. "</a></th>";
|
569 |
|
$column_header{credit_tax} =
|
570 |
|
"<th><a class=listheading href=$href&sort=accno>"
|
571 |
|
. $locale->text('Credit Tax')
|
572 |
|
. "</a></th>";
|
573 |
|
$column_header{credit_tax_accno} =
|
574 |
|
"<th><a class=listheading href=$href&sort=accno>"
|
575 |
|
. $locale->text('Credit Tax Account')
|
576 |
|
. "</a></th>";
|
577 |
|
$column_header{balance} = "<th>" . $locale->text('Balance') . "</th>";
|
578 |
|
$column_header{projectnumbers} =
|
579 |
|
"<th class=listheading>" . $locale->text('Project Numbers') . "</th>";
|
580 |
|
|
581 |
|
$form->{landscape} = 1;
|
582 |
|
|
583 |
|
$form->header;
|
|
517 |
my $report = SL::ReportGenerator->new(\%myconfig, $form);
|
584 |
518 |
|
585 |
|
print qq|
|
586 |
|
<body>
|
|
519 |
$report->set_columns(%column_defs);
|
|
520 |
$report->set_column_order(@columns);
|
587 |
521 |
|
588 |
|
<table width=100%>
|
589 |
|
<tr>
|
590 |
|
<th class=listtop>$form->{title}</th>
|
591 |
|
</tr>
|
592 |
|
<tr height="5"></tr>
|
593 |
|
<tr>
|
594 |
|
<td>$option</td>
|
595 |
|
</tr>
|
596 |
|
<tr>
|
597 |
|
<td>
|
598 |
|
<table width=100%>
|
599 |
|
<thead>
|
600 |
|
<tr class=listheading>
|
601 |
|
|;
|
|
522 |
$report->set_export_options('generate_report', @hidden_variables);
|
602 |
523 |
|
603 |
|
map { print "$column_header{$_}\n" } @column_index;
|
|
524 |
$report->set_sort_indicator($form->{sort}, 1);
|
604 |
525 |
|
605 |
|
print "
|
606 |
|
</tr>
|
607 |
|
</thead>
|
608 |
|
</tfoot>
|
609 |
|
<tbody>
|
610 |
|
";
|
|
526 |
$report->set_options('top_info_text' => join("\n", @options),
|
|
527 |
'output_format' => 'HTML',
|
|
528 |
'title' => $form->{title},
|
|
529 |
'attachment_basename' => $locale->text('general_ledger_list') . strftime('_%Y%m%d', localtime time),
|
|
530 |
);
|
|
531 |
$report->set_options_from_form();
|
611 |
532 |
|
612 |
533 |
# add sort to callback
|
613 |
|
$form->{callback} = "$callback&sort=$form->{sort}";
|
614 |
|
$callback = $form->escape($form->{callback});
|
|
534 |
$form->{callback} = "$callback&sort=" . E($form->{sort});
|
615 |
535 |
|
616 |
|
# initial item for subtotals
|
617 |
|
if (@{ $form->{GL} }) {
|
618 |
|
$sameitem = $form->{GL}->[0]->{ $form->{sort} };
|
619 |
|
}
|
|
536 |
$form->{balance} *= $ml;
|
620 |
537 |
|
621 |
538 |
if ($form->{accno} && $form->{balance}) {
|
|
539 |
my $row = {
|
|
540 |
'balance' => {
|
|
541 |
'data' => $form->format_amount(\%myconfig, $form->{balance}, 2),
|
|
542 |
'align' => 'right',
|
|
543 |
},
|
|
544 |
};
|
|
545 |
|
|
546 |
$report->add_data($row);
|
|
547 |
}
|
622 |
548 |
|
623 |
|
map { $column_data{$_} = "<td> </td>" } @column_index;
|
624 |
|
$column_data{balance} =
|
625 |
|
"<td align=right>"
|
626 |
|
. $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
|
627 |
|
. "</td>";
|
628 |
|
|
629 |
|
$i++;
|
630 |
|
$i %= 2;
|
631 |
|
print qq|
|
632 |
|
<tr class=listrow$i>
|
633 |
|
|;
|
634 |
|
map { print "$column_data{$_}\n" } @column_index;
|
|
549 |
my @totals_columns = qw(debit credit debit_tax credit_tax);
|
|
550 |
my %subtotals = map { $_ => 0 } @totals_columns;
|
|
551 |
my %totals = map { $_ => 0 } @totals_columns;
|
|
552 |
my $idx = 0;
|
635 |
553 |
|
636 |
|
print qq|
|
637 |
|
</tr>
|
638 |
|
|;
|
639 |
|
}
|
640 |
|
$form->{balance} *= $ml;
|
641 |
554 |
foreach $ref (@{ $form->{GL} }) {
|
642 |
555 |
$form->{balance} *= $ml;
|
643 |
556 |
|
644 |
|
# if item ne sort print subtotal
|
645 |
|
if ($form->{l_subtotal} eq 'Y') {
|
646 |
|
if ($sameitem ne $ref->{ $form->{sort} }) {
|
647 |
|
&gl_subtotal;
|
648 |
|
}
|
649 |
|
}
|
650 |
|
|
651 |
|
#foreach $key (sort keys(%{ $ref->{amount} })) {
|
652 |
|
# $form->{balance} += $ref->{amount}{$key};
|
653 |
|
#}
|
|
557 |
my %rows;
|
654 |
558 |
|
655 |
|
$debit = "";
|
656 |
|
foreach $key (sort keys(%{ $ref->{debit} })) {
|
657 |
|
$subtotaldebit += $ref->{debit}{$key};
|
658 |
|
$totaldebit += $ref->{debit}{$key};
|
659 |
|
if ($key == 0) {
|
660 |
|
$debit = $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
|
661 |
|
} else {
|
662 |
|
$debit .=
|
663 |
|
"<br>" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
|
|
559 |
foreach my $key (qw(debit credit debit_tax credit_tax)) {
|
|
560 |
$rows{$key} = [];
|
|
561 |
foreach my $idx (sort keys(%{ $ref->{$key} })) {
|
|
562 |
my $value = $ref->{$key}->{$idx};
|
|
563 |
$subtotals{$key} += $value;
|
|
564 |
$totals{$key} += $value;
|
|
565 |
$form->{balance} = abs($form->{balance}) - abs($value);
|
|
566 |
push @{ $rows{$key} }, $form->format_amount(\%myconfig, $value, 2);
|
664 |
567 |
}
|
665 |
|
$form->{balance} = abs($form->{balance}) - abs($ref->{debit}{$key});
|
666 |
568 |
}
|
667 |
569 |
|
668 |
|
$credit = "";
|
669 |
|
foreach $key (sort keys(%{ $ref->{credit} })) {
|
670 |
|
$subtotalcredit += $ref->{credit}{$key};
|
671 |
|
$totalcredit += $ref->{credit}{$key};
|
672 |
|
if ($key == 0) {
|
673 |
|
$credit = $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
|
674 |
|
} else {
|
675 |
|
$credit .= "<br>"
|
676 |
|
. $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
|
677 |
|
}
|
678 |
|
$form->{balance} = abs($form->{balance}) - abs($ref->{credit}{$key});
|
|
570 |
foreach my $key (qw(debit_accno credit_accno debit_tax_accno credit_tax_accno ac_transdate)) {
|
|
571 |
my $col = $key eq 'ac_transdate' ? 'transdate' : $key;
|
|
572 |
$rows{$col} = [ map { $ref->{$key}->{$_} } sort keys(%{ $ref->{$key} }) ];
|
679 |
573 |
}
|
680 |
574 |
|
681 |
|
$debittax = "";
|
682 |
|
foreach $key (sort keys(%{ $ref->{debit_tax} })) {
|
683 |
|
$subtotaldebittax += $ref->{debit_tax}{$key};
|
684 |
|
$totaldebittax += $ref->{debit_tax}{$key};
|
685 |
|
if ($key == 0) {
|
686 |
|
$debittax =
|
687 |
|
$form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
|
688 |
|
} else {
|
689 |
|
$debittax .= "<br>"
|
690 |
|
. $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
|
691 |
|
}
|
692 |
|
$form->{balance} = abs($form->{balance}) - abs($ref->{debit_tax}{$key});
|
693 |
|
}
|
|
575 |
my $row = { };
|
|
576 |
map { $row->{$_} = { 'data' => '', 'align' => $column_alignment{$_} } } @columns;
|
694 |
577 |
|
695 |
|
$credittax = "";
|
696 |
|
foreach $key (sort keys(%{ $ref->{credit_tax} })) {
|
697 |
|
$subtotalcredittax += $ref->{credit_tax}{$key};
|
698 |
|
$totalcredittax += $ref->{credit_tax}{$key};
|
699 |
|
if ($key == 0) {
|
700 |
|
$credittax =
|
701 |
|
$form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
|
702 |
|
} else {
|
703 |
|
$credittax .= "<br>"
|
704 |
|
. $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
|
705 |
|
}
|
706 |
|
$form->{balance} = abs($form->{balance}) - abs($ref->{credit_tax}{$key});
|
707 |
|
}
|
|
578 |
$row->{balance}->{data} = $form->format_amount(\%myconfig, $form->{balance}, 2);
|
|
579 |
$row->{projectnumbers}->{data} = join ", ", sort { lc($a) cmp lc($b) } keys %{ $ref->{projectnumbers} };
|
708 |
580 |
|
709 |
|
$debitaccno = "";
|
710 |
|
$debittaxkey = "";
|
711 |
|
$taxaccno = "";
|
712 |
|
foreach $key (sort keys(%{ $ref->{debit_accno} })) {
|
713 |
|
if ($key == 0) {
|
714 |
|
$debitaccno =
|
715 |
|
"<a href=$href&accno=$ref->{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}</a>";
|
716 |
|
} else {
|
717 |
|
$debitaccno .=
|
718 |
|
"<br><a href=$href&accno=$ref->{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}</a>";
|
719 |
|
}
|
|
581 |
map { $row->{$_}->{data} = $ref->{$_} } qw(id reference description source notes);
|
720 |
582 |
|
721 |
|
# if ($ref->{debit_taxkey}{$key} eq $debittaxkey) {
|
722 |
|
# $ref->{debit_tax_accno}{$key} = $taxaccno;
|
723 |
|
# }
|
724 |
|
$taxaccno = $ref->{debit_tax_accno}{$key};
|
725 |
|
$debittaxkey = $ref->{debit_taxkey}{$key};
|
726 |
|
}
|
|
583 |
map { $row->{$_}->{data} = join "\n", @{ $rows{$_} }; } qw(transdate debit credit);
|
727 |
584 |
|
728 |
|
$creditaccno = "";
|
729 |
|
$credittaxkey = "";
|
730 |
|
$taxaccno = "";
|
731 |
|
foreach $key (sort keys(%{ $ref->{credit_accno} })) {
|
732 |
|
if ($key == 0) {
|
733 |
|
$creditaccno =
|
734 |
|
"<a href=$href&accno=$ref->{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}</a>";
|
735 |
|
} else {
|
736 |
|
$creditaccno .=
|
737 |
|
"<br><a href=$href&accno=$ref->{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}</a>";
|
738 |
|
}
|
739 |
|
|
740 |
|
# if ($ref->{credit_taxkey}{$key} eq $credittaxkey) {
|
741 |
|
# $ref->{credit_tax_accno}{$key} = $taxaccno;
|
742 |
|
# }
|
743 |
|
$taxaccno = $ref->{credit_tax_accno}{$key};
|
744 |
|
$credittaxkey = $ref->{credit_taxkey}{$key};
|
745 |
|
}
|
|
585 |
map { $row->{$_}->{data} = join "\n", @{ $rows{$_} } if ($ref->{"${_}_accno"} ne "") } qw(debit_tax credit_tax);
|
746 |
586 |
|
747 |
|
$debittaxaccno = "";
|
748 |
|
foreach $key (sort keys(%{ $ref->{debit_tax_accno} })) {
|
749 |
|
if ($key == 0) {
|
750 |
|
$debittaxaccno =
|
751 |
|
"<a href=$href&accno=$ref->{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
|
|
587 |
foreach my $col (qw(debit_accno credit_accno debit_tax_accno credit_tax_accno)) {
|
|
588 |
if (lc $report->{options}->{output_format} eq 'html') {
|
|
589 |
$row->{$col}->{raw_data} = join "<br>", map { "<a href=\"${callback}&accno=" . E($_) . "\">$_</a>" } @{ $rows{$col} };
|
752 |
590 |
} else {
|
753 |
|
$debittaxaccno .=
|
754 |
|
"<br><a href=$href&accno=$ref->{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
|
|
591 |
$row->{$col}->{data} = join "\n", @{ $rows{$col} };
|
755 |
592 |
}
|
756 |
593 |
}
|
757 |
594 |
|
758 |
|
$credittaxaccno = "";
|
759 |
|
foreach $key (sort keys(%{ $ref->{credit_tax_accno} })) {
|
760 |
|
if ($key == 0) {
|
761 |
|
$credittaxaccno =
|
762 |
|
"<a href=$href&accno=$ref->{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
|
763 |
|
} else {
|
764 |
|
$credittaxaccno .=
|
765 |
|
"<br><a href=$href&accno=$ref->{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
|
766 |
|
}
|
767 |
|
}
|
|
595 |
$row->{reference}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'id=' . E($ref->{id}), 'callback');
|
768 |
596 |
|
769 |
|
$transdate = "";
|
770 |
|
foreach $key (sort keys(%{ $ref->{ac_transdate} })) {
|
771 |
|
if ($key == 0) {
|
772 |
|
$transdate = "$ref->{ac_transdate}{$key}";
|
773 |
|
} else {
|
774 |
|
$transdate .= "<br>$ref->{ac_transdate}{$key}";
|
775 |
|
}
|
|
597 |
my $row_set = [ $row ];
|
|
598 |
|
|
599 |
if (($form->{l_subtotal} eq 'Y')
|
|
600 |
&& (($idx == (scalar @{ $form->{GL} } - 1))
|
|
601 |
|| ($ref->{ $form->{sort} } ne $form->{GL}->[$idx + 1]->{ $form->{sort} }))) {
|
|
602 |
push @{ $row_set }, create_subtotal_row(\%subtotals, \@columns, \%column_alignment, [ qw(debit credit) ], 'listsubtotal');
|
776 |
603 |
}
|
777 |
604 |
|
778 |
|
# $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, " ");
|
779 |
|
# $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " ");
|
780 |
|
|
781 |
|
$column_data{id} = "<td align=right> $ref->{id} </td>";
|
782 |
|
$column_data{transdate} = "<td align=center>$transdate</td>";
|
783 |
|
$column_data{reference} =
|
784 |
|
"<td align=center><a href=$ref->{module}.pl?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}</td>";
|
785 |
|
$column_data{description} = "<td align=center>$ref->{description} </td>";
|
786 |
|
$column_data{source} = "<td align=center>$ref->{source} </td>";
|
787 |
|
$column_data{notes} = "<td align=center>$ref->{notes} </td>";
|
788 |
|
$column_data{debit} = "<td align=right>$debit</td>";
|
789 |
|
$column_data{debit_accno} = "<td align=center>$debitaccno</td>";
|
790 |
|
$column_data{credit} = "<td align=right>$credit</td>";
|
791 |
|
$column_data{credit_accno} = "<td align=center>$creditaccno</td>";
|
792 |
|
$column_data{debit_tax} =
|
793 |
|
($ref->{debit_tax_accno} ne "")
|
794 |
|
? "<td align=right>$debittax</td>"
|
795 |
|
: "<td></td>";
|
796 |
|
$column_data{debit_tax_accno} = "<td align=center>$debittaxaccno</td>";
|
797 |
|
$column_data{credit_tax} =
|
798 |
|
($ref->{credit_tax_accno} ne "")
|
799 |
|
? "<td align=right>$credittax</td>"
|
800 |
|
: "<td></td>";
|
801 |
|
$column_data{credit_tax_accno} = "<td align=center>$credittaxaccno</td>";
|
802 |
|
$column_data{balance} =
|
803 |
|
"<td align=right>"
|
804 |
|
. $form->format_amount(\%myconfig, $form->{balance}, 2, 0) . "</td>";
|
805 |
|
$column_data{projectnumbers} =
|
806 |
|
"<td>" . join(", ", sort({ lc($a) cmp lc($b) } keys(%{ $ref->{projectnumbers} }))) . "</td>";
|
807 |
|
|
808 |
|
$i++;
|
809 |
|
$i %= 2;
|
810 |
|
print "
|
811 |
|
<tr class=listrow$i>";
|
812 |
|
map { print "$column_data{$_}\n" } @column_index;
|
813 |
|
print "</tr>";
|
|
605 |
$report->add_data($row_set);
|
814 |
606 |
|
|
607 |
$idx++;
|
815 |
608 |
}
|
816 |
609 |
|
817 |
|
&gl_subtotal if ($form->{l_subtotal} eq 'Y');
|
818 |
|
|
819 |
|
map { $column_data{$_} = "<td> </td>" } @column_index;
|
820 |
|
|
821 |
|
my $balanced_ledger = $totaldebit
|
822 |
|
+ $totaldebittax
|
823 |
|
- $totalcredit
|
824 |
|
- $totalcredittax;
|
825 |
|
# = 0 for balanced ledger
|
826 |
|
|
827 |
|
$column_data{debit} =
|
828 |
|
"<th align=right class=listtotal>"
|
829 |
|
. $form->format_amount(\%myconfig, $totaldebit, 2, " ") . "</th>";
|
830 |
|
$column_data{credit} =
|
831 |
|
"<th align=right class=listtotal>"
|
832 |
|
. $form->format_amount(\%myconfig, $totalcredit, 2, " ") . "</th>";
|
833 |
|
$column_data{debit_tax} =
|
834 |
|
"<th align=right class=listtotal>"
|
835 |
|
. $form->format_amount(\%myconfig, $totaldebittax, 2, " ") . "</th>";
|
836 |
|
$column_data{credit_tax} =
|
837 |
|
"<th align=right class=listtotal>"
|
838 |
|
. $form->format_amount(\%myconfig, $totalcredittax, 2, " ") . "</th>";
|
839 |
|
$column_data{balance} =
|
840 |
|
"<th align=right class=listtotal>"
|
841 |
|
. $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
|
842 |
|
|
843 |
|
print qq|
|
844 |
|
<tr class=listtotal>
|
845 |
|
|;
|
846 |
|
|
847 |
|
map { print "$column_data{$_}\n" } @column_index;
|
848 |
|
|
849 |
|
print qq|
|
850 |
|
</tr>
|
851 |
|
<tr>|;
|
852 |
|
|
|
610 |
$report->add_separator();
|
853 |
611 |
|
854 |
|
if ( abs($balanced_ledger) > 0.001 ) {
|
|
612 |
# = 0 for balanced ledger
|
|
613 |
my $balanced_ledger = $totals{debit} + $totals{debit_tax} - $totals{credit} - $totals{credit_tax};
|
855 |
614 |
|
856 |
|
print qq|<td colspan="4" style="background-color:#FFA0A0" >|
|
857 |
|
. $locale->text('Unbalanced Ledger')
|
858 |
|
. ": "
|
859 |
|
. $form->format_amount(\%myconfig, $balanced_ledger, 3, " ")
|
860 |
|
|
861 |
|
} elsif ( abs($balanced_ledger) <= 0.001 ) {
|
|
615 |
my $row = create_subtotal_row(\%totals, \@columns, \%column_alignment, [ qw(debit credit debit_tax credit_tax) ], 'listtotal');
|
|
616 |
$row->{balance} = {
|
|
617 |
'data' => $form->format_amount(\%myconfig, $form->{balance} * $ml, 2),
|
|
618 |
'align' => 'right',
|
|
619 |
'class' => 'listtotal',
|
|
620 |
};
|
|
621 |
$report->add_data($row);
|
862 |
622 |
|
863 |
|
print qq|<td colspan="3">|
|
864 |
|
. $locale->text('Balanced Ledger')
|
|
623 |
my $raw_bottom_info_text;
|
865 |
624 |
|
|
625 |
if (!$form->{accno} && (abs($balanced_ledger) > 0.001)) {
|
|
626 |
$raw_bottom_info_text .=
|
|
627 |
'<p><span class="unbalanced_ledger">'
|
|
628 |
. $locale->text('Unbalanced Ledger')
|
|
629 |
. ': '
|
|
630 |
. $form->format_amount(\%myconfig, $balanced_ledger, 3)
|
|
631 |
. '</span></p> ';
|
866 |
632 |
}
|
867 |
633 |
|
868 |
|
|
869 |
|
print qq|
|
870 |
|
</td>
|
871 |
|
</tr>
|
872 |
|
</tbody>
|
873 |
|
</table>
|
874 |
|
</td>
|
875 |
|
</tr>
|
876 |
|
<tr>
|
877 |
|
<td><hr size=3 noshade></td>
|
878 |
|
</tr>
|
879 |
|
</table>
|
|
634 |
$raw_bottom_info_text .= $form->parse_html_template('gl/generate_report_bottom');
|
880 |
635 |
|
881 |
|
<br>
|
882 |
|
|
883 |
|
<form method=post action=$form->{script}>
|
884 |
|
|
885 |
|
<input name=callback type=hidden value="$form->{callback}">
|
|
636 |
$report->set_options('raw_bottom_info_text' => $raw_bottom_info_text);
|
886 |
637 |
|
887 |
|
<input type=hidden name=login value=$form->{login}>
|
888 |
|
<input type=hidden name=password value=$form->{password}>
|
889 |
|
|
890 |
|
<input class=submit type=submit name=action value="|
|
891 |
|
. $locale->text('GL Transaction') . qq|">
|
892 |
|
<input class=submit type=submit name=action value="|
|
893 |
|
. $locale->text('AR Transaction') . qq|">
|
894 |
|
<input class=submit type=submit name=action value="|
|
895 |
|
. $locale->text('AP Transaction') . qq|">
|
896 |
|
<input class=submit type=submit name=action value="|
|
897 |
|
. $locale->text('Sales Invoice') . qq|">
|
898 |
|
<input class=submit type=submit name=action value="|
|
899 |
|
. $locale->text('Vendor Invoice') . qq|">
|
|
638 |
$report->generate_with_headers();
|
900 |
639 |
|
901 |
|
</form>
|
902 |
|
|
903 |
|
</body>
|
904 |
|
</html>
|
905 |
|
|;
|
906 |
|
$lxdebug->leave_sub();
|
907 |
|
|
908 |
|
}
|
909 |
|
|
910 |
|
sub gl_subtotal {
|
911 |
|
$lxdebug->enter_sub();
|
912 |
|
|
913 |
|
$subtotaldebit =
|
914 |
|
$form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
|
915 |
|
$subtotalcredit =
|
916 |
|
$form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
|
917 |
|
|
918 |
|
map { $column_data{$_} = "<td> </td>" }
|
919 |
|
qw(transdate id reference source description accno);
|
920 |
|
$column_data{debit} = "<th align=right>$subtotaldebit</td>";
|
921 |
|
$column_data{credit} = "<th align=right>$subtotalcredit</td>";
|
922 |
|
|
923 |
|
print "<tr class=listsubtotal>";
|
924 |
|
map { print "$column_data{$_}\n" } @column_index;
|
925 |
|
print "</tr>";
|
926 |
|
|
927 |
|
$subtotaldebit = 0;
|
928 |
|
$subtotalcredit = 0;
|
929 |
|
|
930 |
|
$sameitem = $ref->{ $form->{sort} };
|
931 |
640 |
$lxdebug->leave_sub();
|
932 |
|
|
933 |
641 |
}
|
934 |
642 |
|
935 |
643 |
sub update {
|
Das Buchungsjournal auf die Verwendung der ReportGenerator-Klasse umgestellt.