This file is indexed.

/usr/share/perl5/EB/Report.pm is in eekboek 2.00.03-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#! perl

package main;

our $dbh;

# Report.pm -- Report tools
# RCS Info        : $Id: Report.pm,v 1.8 2009/10/09 15:33:08 jv Exp $
# Author          : Johan Vromans
# Created On      : Mon Nov 14 21:46:04 2005
# Last Modified By: Johan Vromans
# Last Modified On: Wed Oct  7 11:32:02 2009
# Update Count    : 43
# Status          : Unknown, Use with caution!

package EB::Report;

use strict;
use warnings;

our $VERSION = sprintf "%d.%03d", q$Revision: 1.8 $ =~ /(\d+)/g;

use EB;
use EB::Format qw(numfmt);
use EB::Report::GenBase;

my $trace = 0;

sub GetTAccountsBal {
    shift;
    my ($end, $inc) = @_;

    # balans(r, t) = balans(r, t0) + sum(journaal, r, t0..t) + sum(boekjaarbalans, r, t' < t)

    # balans(r, t0)
    $dbh->sql_exec("DELETE FROM TAccounts");
    $dbh->sql_exec("INSERT INTO TAccounts".
		   " (acc_id,acc_desc,acc_balres,acc_debcrd,acc_dcfixed,".
		   "acc_ibalance,acc_balance,acc_struct)".
		   " SELECT acc_id,acc_desc,acc_balres,acc_debcrd,acc_dcfixed,".
		   "acc_ibalance,acc_ibalance AS acc_balance,acc_struct".
		   " FROM Accounts")->finish;

    return "TAccounts" unless defined $end;

    # sum(journaal, r, t0..t)
    my $sth = $dbh->sql_exec("SELECT jnl_acc_id,acc_balance,SUM(jnl_amount)".
			     " FROM Journal,TAccounts".
			     " WHERE acc_id = jnl_acc_id".
			     " AND jnl_date ".($inc ? "<" : "<=")." ?".
			     " GROUP BY jnl_acc_id,acc_balance,acc_ibalance",
			     $end);

    while ( my $rr = $sth->fetchrow_arrayref ) {
	my ($acc_id, $acc_balance, $sum) = @$rr;
	next unless $sum;
	$sum += $acc_balance;
	warn("!".__x("Balansrekening {acct}, saldo aangepast naar {exp}",
		     acct => $acc_id, exp => numfmt($sum)) . "\n") if $trace;
	$dbh->sql_exec("UPDATE TAccounts".
		       " SET acc_balance = ?".
		       " WHERE acc_id = ?",
		       $sum, $acc_id)->finish;
    }

    # sum(boekjaarbalans, r, t' < t)
    $sth = $dbh->sql_exec("SELECT bkb_acc_id, bkb_balance".
			  " FROM Boekjaarbalans".
			  " WHERE bkb_end ".($inc ? "<=" : "<")." ?", $end);
    while ( my $rr = $sth->fetchrow_arrayref ) {
	my ($acc_id, $acc_balance) = @$rr;
	warn("!".__x("Balansrekening {acct}, saldo aangepast met {exp}",
		     acct => $acc_id, exp => numfmt(-$acc_balance)) . "\n") if $trace;
	$dbh->sql_exec("UPDATE TAccounts".
		       " SET acc_balance = acc_balance - ?".
		       " WHERE acc_id = ?",
		       $acc_balance, $acc_id)->finish;
    }

    # Return temp table.
    "TAccounts";
}

sub GetTAccountsAll {
    push(@_, 1);
    goto &GetTAccountsRes;
}

sub GetTAccountsRes {
    shift;
    my ($begin, $end, $all) = @_;

    # beginsaldo(r, t1, t2) = sum(journaal, r, t0..t1) + sum(boekjaarbalans, r, t' < t1)
    # eindsaldo(r, t1, t2) = beginsaldo(r, t1, t2) + sum(journaal, r, t1..t2)

    # init
    $dbh->sql_exec("DELETE FROM TAccounts");
    if ( $all ) {
	$dbh->sql_exec("INSERT INTO TAccounts SELECT * FROM Accounts")->finish;
    }
    else {
	$dbh->sql_exec("INSERT INTO TAccounts".
		       " (acc_id,acc_desc,acc_balres,acc_debcrd,".
		       "acc_ibalance,acc_balance,acc_struct)".
		       " SELECT acc_id,acc_desc,acc_balres,acc_debcrd,0,0,acc_struct".
		       " FROM Accounts".
		       " WHERE NOT acc_balres")->finish;
    }

    # beginsaldo(r, t1, t2) = sum(journaal, r, t0..t1) ...
    my $sth = $dbh->sql_exec("SELECT jnl_acc_id,SUM(jnl_amount)".
			     " FROM Journal,TAccounts".
			     " WHERE acc_id = jnl_acc_id".
			     " AND jnl_date < ?".
			     " GROUP BY jnl_acc_id",
			     $begin);

    while ( my $rr = $sth->fetchrow_arrayref ) {
	my ($acc_id, $sum) = @$rr;
	next unless $sum;
	warn("!".__x("Resultaatrekening {acct}, beginsaldo is {exp}",
		     acct => $acc_id, exp => numfmt($sum)) . "\n") if $trace;
	$dbh->sql_exec("UPDATE TAccounts".
		       " SET acc_ibalance = acc_ibalance + ?".
		       " WHERE acc_id = ?",
		       $sum, $acc_id)->finish;
    }

    # ... + sum(boekjaarbalans, r, t' < t1)
    $sth = $dbh->sql_exec("SELECT bkb_acc_id, bkb_balance".
			  " FROM Boekjaarbalans".
			  " WHERE bkb_end < ?", $begin);
    while ( my $rr = $sth->fetchrow_arrayref ) {
	my ($acc_id, $acc_balance) = @$rr;
	warn("!".__x("Resultaatrekening {acct}, saldo aangepast met {exp}",
		     acct => $acc_id, exp => numfmt(-$acc_balance)) . "\n") if $trace;
	$dbh->sql_exec("UPDATE TAccounts".
		       " SET acc_ibalance = acc_ibalance - ?".
		       " WHERE acc_id = ?",
		       $acc_balance, $acc_id)->finish;
    }

    # eindsaldo(r, t2) = beginsaldo(r, t1) + sum(journaal, r, t1..t2)
    $sth = $dbh->sql_exec("SELECT jnl_acc_id,SUM(jnl_amount)".
			     " FROM Journal,TAccounts".
			     " WHERE acc_id = jnl_acc_id".
			     " AND jnl_date >= ?".
			     " AND jnl_date <= ?".
			     " GROUP BY jnl_acc_id",
			     $begin,
			     $end);

    while ( my $rr = $sth->fetchrow_arrayref ) {
	my ($acc_id, $sum) = @$rr;
	next unless $sum;
	warn("!".__x("Resultaatrekening {acct}, mutaties is {exp}",
		     acct => $acc_id, exp => numfmt($sum)) . "\n") if $trace;
	$dbh->sql_exec("UPDATE TAccounts".
		       " SET acc_balance = acc_ibalance + ?".
		       " WHERE acc_id = ?",
		       $sum, $acc_id)->finish;
    }

    "TAccounts";
}

sub GetTAccountsCopy {
    shift;
    $dbh->sql_exec("DELETE FROM TAccounts");
    $dbh->sql_exec("INSERT INTO TAccounts SELECT * FROM Accounts")->finish;
    "TAccounts";
}

1;