-
-
-
-|;
-
- map { print "\n$column_header{$_}" } @column_index;
-
- print qq|
-
-|;
-
- my $ml = ($form->{category} eq 'A') ? -1 : 1;
- $form->{beginningbalance} *= $ml;
- my $balance = $form->{beginningbalance};
- my $clearedbalance = $balance;
- my $i = 0;
- my $id = 0;
-
- my %column_data;
- map { $column_data{$_} = " | " }
- qw(cleared transdate source name debit credit);
- $column_data{balance} =
- ""
- . $form->format_amount(\%myconfig, $balance, 2, 0) . " | ";
- my $j = 0;
- print qq|
-
-|;
-
- map { print "\n$column_data{$_}" } @column_index;
-
- print qq|
-
-|;
-
- my $cleared;
- my $totaldebits;
- my $totalcredits;
- my $fx_transaction;
- my $fx;
- foreach my $ref (@{ $form->{PR} }) {
-
- $balance += $ref->{amount} * $ml;
- $cleared += $ref->{amount} * $ml if $ref->{cleared};
-
- $column_data{name} = "$ref->{name} | ";
- $column_data{source} = qq|$ref->{source}
- | |;
- $column_data{transdate} = "$ref->{transdate} | ";
-
- $column_data{debit} = " | ";
- $column_data{credit} = " | ";
-
- if ($ref->{amount} < 0) {
- $totaldebits += $ref->{amount} * -1;
- $column_data{debit} =
- ""
- . $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")
- . " | ";
- } else {
- $totalcredits += $ref->{amount};
- $column_data{credit} =
- ""
- . $form->format_amount(\%myconfig, $ref->{amount}, 2, " ")
- . " | ";
- }
-
- $column_data{balance} =
- ""
- . $form->format_amount(\%myconfig, $balance, 2, 0) . " | ";
-
- if ($ref->{fx_transaction}) {
- $i++ unless $id == $ref->{id};
- $fx_transaction = 1;
- $fx += $ref->{amount} * $ml;
- $column_data{cleared} = qq|
- {oid}>
- | |;
- } else {
- $i++ unless ($fx_transaction && $id == $ref->{id});
- $fx_transaction = 0;
- $column_data{cleared} = qq|
- {cleared}>
- {oid}>
- | |;
- }
- $id = $ref->{id};
-
- $j++;
- $j %= 2;
- print qq|
-
-|;
-
- map { print "\n$column_data{$_}" } @column_index;
-
- print qq|
-
-|;
+ $::lxdebug->enter_sub;
+ $::auth->assert('cash');
+ my @options;
+ push @options, $::locale->text('From') . " " . $::locale->date(\%::myconfig, $::form->{fromdate}, 0) if $::form->{fromdate};
+ push @options, $::locale->text('Until') . " " . $::locale->date(\%::myconfig, $::form->{todate}, 0) if $::form->{todate};
+
+ my $ml = ($::form->{category} eq 'A') ? -1 : 1;
+ my $beginningbalance = $::form->{beginningbalance} * $ml;
+ my $clearedbalance =
+ my $balance = $beginningbalance;
+ my $i = 0;
+ my $last_id = 0;
+ my ($last_fx, @rows, $cleared, $totaldebits, $totalcredits, $fx);
+
+ for my $ref (@{ $::form->{PR} }) {
+ $balance += $ref->{amount} * $ml;
+ $cleared += $ref->{amount} * $ml if $ref->{cleared};
+ $totaldebits += $ref->{amount} * -1 if $ref->{amount} < 0;
+ $totalcredits += $ref->{amount} if $ref->{amount} >= 0;
+ $fx += $ref->{amount} * $ml if $ref->{fx_transaction};
+ $i++ if (!$ref->{fx_transaction} && !$last_fx) || $last_id != $ref->{id};
+ $last_fx = $ref->{fx_transaction};
+ $last_id = $ref->{id};
+
+ push @rows, { %$ref, balance => $balance, i => $i };
}
- # print totals
- map { $column_data{$_} = " | " } @column_index;
-
- $column_data{debit} =
- ""
- . $form->format_amount(\%myconfig, $totaldebits, 2, " ") . " | ";
- $column_data{credit} =
- ""
- . $form->format_amount(\%myconfig, $totalcredits, 2, " ") . " | ";
-
- print qq|
-
-|;
-
- map { print "\n$column_data{$_}" } @column_index;
-
- $form->{statementbalance} =
- $form->parse_amount(\%myconfig, $form->{statementbalance});
- my $difference =
- $form->format_amount(\%myconfig,
- $form->{statementbalance} - $clearedbalance - $cleared,
- 2, 0);
-
- $form->{statementbalance} =
- $form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
-
- $clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
-
- my $exchdiff;
- if ($fx) {
- $fx = $form->format_amount(\%myconfig, $fx, 2, 0);
- $exchdiff = qq|
- | | . $locale->text('Exchangerate Difference') . qq| |
- |
- $fx |
-|;
- }
+ my $statementbalance = $::form->parse_amount(\%::myconfig, $::form->{statementbalance});
+ my $difference = $statementbalance - $clearedbalance - $cleared;
- print qq|
-
-
- |
-
-