Revision 7a4328be
Von Udo Spallek vor fast 19 Jahren hinzugefügt
- deleted old sub income_statement
- deleted already declared w. 'my' $sth and $query
SL/RP.pm | ||
---|---|---|
34 | 34 |
|
35 | 35 |
package RP; |
36 | 36 |
|
37 |
sub income_statement { |
|
38 |
$main::lxdebug->enter_sub(); |
|
39 |
|
|
40 |
my ($self, $myconfig, $form) = @_; |
|
41 |
|
|
42 |
# connect to database |
|
43 |
my $dbh = $form->dbconnect($myconfig); |
|
44 |
|
|
45 |
my $last_period = 0; |
|
46 |
my @categories = qw(I E); |
|
47 |
my $category; |
|
48 |
|
|
49 |
$form->{decimalplaces} *= 1; |
|
50 |
|
|
51 |
&get_accounts($dbh, $last_period, $form->{fromdate}, $form->{todate}, $form, |
|
52 |
\@categories); |
|
53 |
|
|
54 |
# if there are any compare dates |
|
55 |
if ($form->{comparefromdate} || $form->{comparetodate}) { |
|
56 |
$last_period = 1; |
|
57 |
|
|
58 |
&get_accounts($dbh, $last_period, |
|
59 |
$form->{comparefromdate}, |
|
60 |
$form->{comparetodate}, |
|
61 |
$form, \@categories); |
|
62 |
} |
|
63 |
|
|
64 |
# disconnect |
|
65 |
$dbh->disconnect; |
|
66 |
|
|
67 |
# now we got $form->{I}{accno}{ } |
|
68 |
# and $form->{E}{accno}{ } |
|
69 |
|
|
70 |
my %account = ( |
|
71 |
'I' => { 'label' => 'income', |
|
72 |
'labels' => 'income', |
|
73 |
'ml' => 1 |
|
74 |
}, |
|
75 |
'E' => { 'label' => 'expense', |
|
76 |
'labels' => 'expenses', |
|
77 |
'ml' => -1 |
|
78 |
}); |
|
79 |
|
|
80 |
my $str; |
|
81 |
|
|
82 |
foreach $category (@categories) { |
|
83 |
|
|
84 |
foreach $key (sort keys %{ $form->{$category} }) { |
|
85 |
|
|
86 |
# push description onto array |
|
87 |
|
|
88 |
$str = ($form->{l_heading}) ? $form->{padding} : ""; |
|
89 |
|
|
90 |
if ($form->{$category}{$key}{charttype} eq "A") { |
|
91 |
$str .= |
|
92 |
($form->{l_accno}) |
|
93 |
? "$form->{$category}{$key}{accno} - $form->{$category}{$key}{description}" |
|
94 |
: "$form->{$category}{$key}{description}"; |
|
95 |
} |
|
96 |
if ($form->{$category}{$key}{charttype} eq "H") { |
|
97 |
if ($account{$category}{subtotal} && $form->{l_subtotal}) { |
|
98 |
$dash = "- "; |
|
99 |
push(@{ $form->{"$account{$category}{label}_account"} }, |
|
100 |
"$str$form->{bold}$account{$category}{subdescription}$form->{endbold}" |
|
101 |
); |
|
102 |
push(@{ $form->{"$account{$category}{labels}_this_period"} }, |
|
103 |
$form->format_amount( |
|
104 |
$myconfig, |
|
105 |
$account{$category}{subthis} * $account{$category}{ml}, |
|
106 |
$form->{decimalplaces}, $dash |
|
107 |
)); |
|
108 |
|
|
109 |
if ($last_period) { |
|
110 |
push(@{ $form->{"$account{$category}{labels}_last_period"} }, |
|
111 |
$form->format_amount( |
|
112 |
$myconfig, |
|
113 |
$account{$category}{sublast} * $account{$category}{ml}, |
|
114 |
$form->{decimalplaces}, $dash |
|
115 |
)); |
|
116 |
} |
|
117 |
|
|
118 |
} |
|
119 |
|
|
120 |
$str = |
|
121 |
"$form->{br}$form->{bold}$form->{$category}{$key}{description}$form->{endbold}"; |
|
122 |
|
|
123 |
$account{$category}{subthis} = $form->{$category}{$key}{this}; |
|
124 |
$account{$category}{sublast} = $form->{$category}{$key}{last}; |
|
125 |
$account{$category}{subdescription} = |
|
126 |
$form->{$category}{$key}{description}; |
|
127 |
$account{$category}{subtotal} = 1; |
|
128 |
|
|
129 |
$form->{$category}{$key}{this} = 0; |
|
130 |
$form->{$category}{$key}{last} = 0; |
|
131 |
|
|
132 |
next unless $form->{l_heading}; |
|
133 |
|
|
134 |
$dash = " "; |
|
135 |
} |
|
136 |
|
|
137 |
push(@{ $form->{"$account{$category}{label}_account"} }, $str); |
|
138 |
|
|
139 |
if ($form->{$category}{$key}{charttype} eq 'A') { |
|
140 |
$form->{"total_$account{$category}{labels}_this_period"} += |
|
141 |
$form->{$category}{$key}{this} * $account{$category}{ml}; |
|
142 |
$dash = "- "; |
|
143 |
} |
|
144 |
|
|
145 |
push(@{ $form->{"$account{$category}{labels}_this_period"} }, |
|
146 |
$form->format_amount( |
|
147 |
$myconfig, |
|
148 |
$form->{$category}{$key}{this} * $account{$category}{ml}, |
|
149 |
$form->{decimalplaces}, $dash |
|
150 |
)); |
|
151 |
|
|
152 |
# add amount or - for last period |
|
153 |
if ($last_period) { |
|
154 |
$form->{"total_$account{$category}{labels}_last_period"} += |
|
155 |
$form->{$category}{$key}{last} * $account{$category}{ml}; |
|
156 |
|
|
157 |
push(@{ $form->{"$account{$category}{labels}_last_period"} }, |
|
158 |
$form->format_amount( |
|
159 |
$myconfig, |
|
160 |
$form->{$category}{$key}{last} * $account{$category}{ml}, |
|
161 |
$form->{decimalplaces}, $dash |
|
162 |
)); |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
$str = ($form->{l_heading}) ? $form->{padding} : ""; |
|
167 |
if ($account{$category}{subtotal} && $form->{l_subtotal}) { |
|
168 |
push(@{ $form->{"$account{$category}{label}_account"} }, |
|
169 |
"$str$form->{bold}$account{$category}{subdescription}$form->{endbold}" |
|
170 |
); |
|
171 |
push(@{ $form->{"$account{$category}{labels}_this_period"} }, |
|
172 |
$form->format_amount( |
|
173 |
$myconfig, |
|
174 |
$account{$category}{subthis} * $account{$category}{ml}, |
|
175 |
$form->{decimalplaces}, $dash |
|
176 |
)); |
|
177 |
|
|
178 |
if ($last_period) { |
|
179 |
push(@{ $form->{"$account{$category}{labels}_last_period"} }, |
|
180 |
$form->format_amount( |
|
181 |
$myconfig, |
|
182 |
$account{$category}{sublast} * $account{$category}{ml}, |
|
183 |
$form->{decimalplaces}, $dash |
|
184 |
)); |
|
185 |
} |
|
186 |
} |
|
187 |
|
|
188 |
} |
|
189 |
|
|
190 |
# totals for income and expenses |
|
191 |
$form->{total_income_this_period} = |
|
192 |
$form->round_amount($form->{total_income_this_period}, |
|
193 |
$form->{decimalplaces}); |
|
194 |
$form->{total_expenses_this_period} = |
|
195 |
$form->round_amount($form->{total_expenses_this_period}, |
|
196 |
$form->{decimalplaces}); |
|
197 |
|
|
198 |
# total for income/loss |
|
199 |
$form->{total_this_period} = |
|
200 |
$form->{total_income_this_period} - $form->{total_expenses_this_period}; |
|
201 |
|
|
202 |
if ($last_period) { |
|
203 |
|
|
204 |
# total for income/loss |
|
205 |
$form->{total_last_period} = |
|
206 |
$form->format_amount( |
|
207 |
$myconfig, |
|
208 |
$form->{total_income_last_period} - $form->{total_expenses_last_period}, |
|
209 |
$form->{decimalplaces}, |
|
210 |
"- "); |
|
211 |
|
|
212 |
# totals for income and expenses for last_period |
|
213 |
$form->{total_income_last_period} = |
|
214 |
$form->format_amount($myconfig, |
|
215 |
$form->{total_income_last_period}, |
|
216 |
$form->{decimalplaces}, "- "); |
|
217 |
$form->{total_expenses_last_period} = |
|
218 |
$form->format_amount($myconfig, |
|
219 |
$form->{total_expenses_last_period}, |
|
220 |
$form->{decimalplaces}, "- "); |
|
221 |
|
|
222 |
} |
|
223 |
|
|
224 |
$form->{total_income_this_period} = |
|
225 |
$form->format_amount($myconfig, |
|
226 |
$form->{total_income_this_period}, |
|
227 |
$form->{decimalplaces}, "- "); |
|
228 |
$form->{total_expenses_this_period} = |
|
229 |
$form->format_amount($myconfig, |
|
230 |
$form->{total_expenses_this_period}, |
|
231 |
$form->{decimalplaces}, "- "); |
|
232 |
$form->{total_this_period} = |
|
233 |
$form->format_amount($myconfig, |
|
234 |
$form->{total_this_period}, |
|
235 |
$form->{decimalplaces}, "- "); |
|
236 |
|
|
237 |
$main::lxdebug->leave_sub(); |
|
238 |
} |
|
239 | 37 |
|
240 | 38 |
sub balance_sheet { |
241 | 39 |
$main::lxdebug->enter_sub(); |
... | ... | |
1989 | 1787 |
$sth->finish; |
1990 | 1788 |
|
1991 | 1789 |
# get gifi tax accounts |
1992 |
my $query = qq|SELECT DISTINCT ON (g.accno) g.accno, g.description,
|
|
1790 |
$query = qq|SELECT DISTINCT ON (g.accno) g.accno, g.description, |
|
1993 | 1791 |
sum(t.rate) AS rate |
1994 | 1792 |
FROM gifi g, chart c, tax t |
1995 | 1793 |
WHERE g.accno = c.gifi_accno |
... | ... | |
1997 | 1795 |
AND c.link LIKE '%CT_tax%' |
1998 | 1796 |
GROUP BY g.accno, g.description |
1999 | 1797 |
ORDER BY accno|; |
2000 |
my $sth = $dbh->prepare($query);
|
|
1798 |
$sth = $dbh->prepare($query); |
|
2001 | 1799 |
$sth->execute || $form->dberror; |
2002 | 1800 |
|
2003 | 1801 |
while ($ref = $sth->fetchrow_hashref(NAME_lc)) { |
Auch abrufbar als: Unified diff