75 |
75 |
}
|
76 |
76 |
|
77 |
77 |
sub display_form {
|
78 |
|
$main::lxdebug->enter_sub();
|
79 |
|
|
80 |
|
my $form = $main::form;
|
81 |
|
my %myconfig = %main::myconfig;
|
82 |
|
my $locale = $main::locale;
|
83 |
|
|
84 |
|
$main::auth->assert('cash');
|
85 |
|
|
86 |
|
my @column_index = qw(cleared transdate source name credit debit balance);
|
87 |
|
my %column_header;
|
88 |
|
$column_header{cleared} = "<th> </th>";
|
89 |
|
$column_header{source} =
|
90 |
|
"<th class=listheading>" . $locale->text('Source') . "</a></th>";
|
91 |
|
$column_header{name} =
|
92 |
|
"<th class=listheading>" . $locale->text('Description') . "</a></th>";
|
93 |
|
$column_header{transdate} =
|
94 |
|
"<th class=listheading>" . $locale->text('Date') . "</a></th>";
|
95 |
|
|
96 |
|
if ($form->{category} eq 'A') {
|
97 |
|
$column_header{debit} =
|
98 |
|
"<th class=listheading>" . $locale->text('Deposit') . "</a></th>";
|
99 |
|
$column_header{credit} =
|
100 |
|
"<th class=listheading>" . $locale->text('Payment') . "</a></th>";
|
101 |
|
} else {
|
102 |
|
$column_header{debit} =
|
103 |
|
"<th class=listheading>" . $locale->text('Decrease') . "</a></th>";
|
104 |
|
$column_header{credit} =
|
105 |
|
"<th class=listheading>" . $locale->text('Increase') . "</a></th>";
|
106 |
|
}
|
107 |
|
|
108 |
|
$column_header{balance} =
|
109 |
|
"<th class=listheading>" . $locale->text('Balance') . "</a></th>";
|
110 |
|
|
111 |
|
my $option;
|
112 |
|
if ($form->{fromdate}) {
|
113 |
|
$option .= "\n<br>" if ($option);
|
114 |
|
$option .=
|
115 |
|
$locale->text('From') . " "
|
116 |
|
. $locale->date(\%myconfig, $form->{fromdate}, 0);
|
117 |
|
}
|
118 |
|
if ($form->{todate}) {
|
119 |
|
$option .= "\n<br>" if ($option);
|
120 |
|
$option .=
|
121 |
|
$locale->text('Until') . " "
|
122 |
|
. $locale->date(\%myconfig, $form->{todate}, 0);
|
123 |
|
}
|
124 |
|
|
125 |
|
$form->{title} = "$form->{accno}--$form->{account}";
|
126 |
|
|
127 |
|
$form->header;
|
128 |
|
|
129 |
|
print qq|
|
130 |
|
<body>
|
131 |
|
|
132 |
|
<form method=post action=$form->{script}>
|
133 |
|
|
134 |
|
<table width=100%>
|
135 |
|
<tr>
|
136 |
|
<th class=listtop>$form->{title}</th>
|
137 |
|
</tr>
|
138 |
|
<tr height="5"></tr>
|
139 |
|
<tr>
|
140 |
|
<td>$option</td>
|
141 |
|
</tr>
|
142 |
|
<tr>
|
143 |
|
<td>
|
144 |
|
<table width=100%>
|
145 |
|
<tr class=listheading>
|
146 |
|
|;
|
147 |
|
|
148 |
|
map { print "\n$column_header{$_}" } @column_index;
|
149 |
|
|
150 |
|
print qq|
|
151 |
|
</tr>
|
152 |
|
|;
|
153 |
|
|
154 |
|
my $ml = ($form->{category} eq 'A') ? -1 : 1;
|
155 |
|
$form->{beginningbalance} *= $ml;
|
156 |
|
my $balance = $form->{beginningbalance};
|
157 |
|
my $clearedbalance = $balance;
|
158 |
|
my $i = 0;
|
159 |
|
my $id = 0;
|
160 |
|
|
161 |
|
my %column_data;
|
162 |
|
map { $column_data{$_} = "<td> </td>" }
|
163 |
|
qw(cleared transdate source name debit credit);
|
164 |
|
$column_data{balance} =
|
165 |
|
"<td align=right>"
|
166 |
|
. $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
|
167 |
|
my $j = 0;
|
168 |
|
print qq|
|
169 |
|
<tr class=listrow$j>
|
170 |
|
|;
|
171 |
|
|
172 |
|
map { print "\n$column_data{$_}" } @column_index;
|
173 |
|
|
174 |
|
print qq|
|
175 |
|
</tr>
|
176 |
|
|;
|
177 |
|
|
178 |
|
my $cleared;
|
179 |
|
my $totaldebits;
|
180 |
|
my $totalcredits;
|
181 |
|
my $fx_transaction;
|
182 |
|
my $fx;
|
183 |
|
foreach my $ref (@{ $form->{PR} }) {
|
184 |
|
|
185 |
|
$balance += $ref->{amount} * $ml;
|
186 |
|
$cleared += $ref->{amount} * $ml if $ref->{cleared};
|
187 |
|
|
188 |
|
$column_data{name} = "<td>$ref->{name} </td>";
|
189 |
|
$column_data{source} = qq|<td>$ref->{source} </a>
|
190 |
|
</td>|;
|
191 |
|
$column_data{transdate} = "<td>$ref->{transdate} </td>";
|
192 |
|
|
193 |
|
$column_data{debit} = "<td> </td>";
|
194 |
|
$column_data{credit} = "<td> </td>";
|
195 |
|
|
196 |
|
if ($ref->{amount} < 0) {
|
197 |
|
$totaldebits += $ref->{amount} * -1;
|
198 |
|
$column_data{debit} =
|
199 |
|
"<td align=right>"
|
200 |
|
. $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, " ")
|
201 |
|
. "</td>";
|
202 |
|
} else {
|
203 |
|
$totalcredits += $ref->{amount};
|
204 |
|
$column_data{credit} =
|
205 |
|
"<td align=right>"
|
206 |
|
. $form->format_amount(\%myconfig, $ref->{amount}, 2, " ")
|
207 |
|
. "</td>";
|
208 |
|
}
|
209 |
|
|
210 |
|
$column_data{balance} =
|
211 |
|
"<td align=right>"
|
212 |
|
. $form->format_amount(\%myconfig, $balance, 2, 0) . "</td>";
|
213 |
|
|
214 |
|
if ($ref->{fx_transaction}) {
|
215 |
|
$i++ unless $id == $ref->{id};
|
216 |
|
$fx_transaction = 1;
|
217 |
|
$fx += $ref->{amount} * $ml;
|
218 |
|
$column_data{cleared} = qq|<td align=center>
|
219 |
|
<input type=hidden name="fxoid_$i" value=$ref->{oid}>
|
220 |
|
</td>|;
|
221 |
|
} else {
|
222 |
|
$i++ unless ($fx_transaction && $id == $ref->{id});
|
223 |
|
$fx_transaction = 0;
|
224 |
|
$column_data{cleared} = qq|<td>
|
225 |
|
<input name="cleared_$i" type=checkbox class=checkbox value=1 $ref->{cleared}>
|
226 |
|
<input type=hidden name="oid_$i" value=$ref->{oid}>
|
227 |
|
</td>|;
|
228 |
|
}
|
229 |
|
$id = $ref->{id};
|
230 |
|
|
231 |
|
$j++;
|
232 |
|
$j %= 2;
|
233 |
|
print qq|
|
234 |
|
<tr class=listrow$j>
|
235 |
|
|;
|
236 |
|
|
237 |
|
map { print "\n$column_data{$_}" } @column_index;
|
238 |
|
|
239 |
|
print qq|
|
240 |
|
</tr>
|
241 |
|
|;
|
|
78 |
$::lxdebug->enter_sub;
|
|
79 |
$::auth->assert('cash');
|
242 |
80 |
|
|
81 |
my @options;
|
|
82 |
push @options, $::locale->text('From') . " " . $::locale->date(\%::myconfig, $::form->{fromdate}, 0) if $::form->{fromdate};
|
|
83 |
push @options, $::locale->text('Until') . " " . $::locale->date(\%::myconfig, $::form->{todate}, 0) if $::form->{todate};
|
|
84 |
|
|
85 |
my $ml = ($::form->{category} eq 'A') ? -1 : 1;
|
|
86 |
my $beginningbalance = $::form->{beginningbalance} * $ml;
|
|
87 |
my $clearedbalance =
|
|
88 |
my $balance = $beginningbalance;
|
|
89 |
my $i = 0;
|
|
90 |
my $last_id = 0;
|
|
91 |
my ($last_fx, @rows, $cleared, $totaldebits, $totalcredits, $fx);
|
|
92 |
|
|
93 |
for my $ref (@{ $::form->{PR} }) {
|
|
94 |
$balance += $ref->{amount} * $ml;
|
|
95 |
$cleared += $ref->{amount} * $ml if $ref->{cleared};
|
|
96 |
$totaldebits += $ref->{amount} * -1 if $ref->{amount} < 0;
|
|
97 |
$totalcredits += $ref->{amount} if $ref->{amount} >= 0;
|
|
98 |
$fx += $ref->{amount} * $ml if $ref->{fx_transaction};
|
|
99 |
$i++ if (!$ref->{fx_transaction} && !$last_fx) || $last_id != $ref->{id};
|
|
100 |
$last_fx = $ref->{fx_transaction};
|
|
101 |
$last_id = $ref->{id};
|
|
102 |
|
|
103 |
push @rows, { %$ref, balance => $balance, i => $i };
|
243 |
104 |
}
|
244 |
105 |
|
245 |
|
# print totals
|
246 |
|
map { $column_data{$_} = "<td> </td>" } @column_index;
|
247 |
|
|
248 |
|
$column_data{debit} =
|
249 |
|
"<th class=listtotal align=right>"
|
250 |
|
. $form->format_amount(\%myconfig, $totaldebits, 2, " ") . "</th>";
|
251 |
|
$column_data{credit} =
|
252 |
|
"<th class=listtotal align=right>"
|
253 |
|
. $form->format_amount(\%myconfig, $totalcredits, 2, " ") . "</th>";
|
254 |
|
|
255 |
|
print qq|
|
256 |
|
<tr class=listtotal>
|
257 |
|
|;
|
258 |
|
|
259 |
|
map { print "\n$column_data{$_}" } @column_index;
|
260 |
|
|
261 |
|
$form->{statementbalance} =
|
262 |
|
$form->parse_amount(\%myconfig, $form->{statementbalance});
|
263 |
|
my $difference =
|
264 |
|
$form->format_amount(\%myconfig,
|
265 |
|
$form->{statementbalance} - $clearedbalance - $cleared,
|
266 |
|
2, 0);
|
267 |
|
|
268 |
|
$form->{statementbalance} =
|
269 |
|
$form->format_amount(\%myconfig, $form->{statementbalance}, 2, 0);
|
270 |
|
|
271 |
|
$clearedbalance = $form->format_amount(\%myconfig, $clearedbalance, 2, 0);
|
272 |
|
|
273 |
|
my $exchdiff;
|
274 |
|
if ($fx) {
|
275 |
|
$fx = $form->format_amount(\%myconfig, $fx, 2, 0);
|
276 |
|
$exchdiff = qq|
|
277 |
|
<th align=right nowrap>| . $locale->text('Exchangerate Difference') . qq|</th>
|
278 |
|
<td width=10%></td>
|
279 |
|
<td align=right>$fx</td>
|
280 |
|
|;
|
281 |
|
}
|
|
106 |
my $statementbalance = $::form->parse_amount(\%::myconfig, $::form->{statementbalance});
|
|
107 |
my $difference = $statementbalance - $clearedbalance - $cleared;
|
282 |
108 |
|
283 |
|
print qq|
|
284 |
|
</tr>
|
285 |
|
</table>
|
286 |
|
</td>
|
287 |
|
</tr>
|
288 |
|
<tr>
|
289 |
|
<td>
|
290 |
|
<table width=100%>
|
291 |
|
<tr valign=top>
|
292 |
|
<td>
|
293 |
|
<table>
|
294 |
|
<tr>
|
295 |
|
<th align=right nowrap>| . $locale->text('Cleared Balance') . qq|</th>
|
296 |
|
<td width=10%></td>
|
297 |
|
<td align=right>$clearedbalance</td>
|
298 |
|
</tr>
|
299 |
|
<tr>
|
300 |
|
$exchdiff
|
301 |
|
</tr>
|
302 |
|
</table>
|
303 |
|
</td>
|
304 |
|
<td align=right>
|
305 |
|
<table>
|
306 |
|
<tr>
|
307 |
|
<th align=right nowrap>| . $locale->text('Statement Balance') . qq|</th>
|
308 |
|
<td width=10%></td>
|
309 |
|
<td align=right><input name=statementbalance size=11 value=$form->{statementbalance}></td>
|
310 |
|
</tr>
|
311 |
|
<tr>
|
312 |
|
<th align=right nowrap>| . $locale->text('Difference') . qq|</th>
|
313 |
|
<td width=10%></td>
|
314 |
|
<td align=right><input name=null size=11 value=$difference></td>
|
315 |
|
<input type=hidden name=difference value=$difference>
|
316 |
|
</tr>
|
317 |
|
</table>
|
318 |
|
</td>
|
319 |
|
</tr>
|
320 |
|
</table>
|
321 |
|
</td>
|
322 |
|
</tr>
|
323 |
|
<tr>
|
324 |
|
<td><hr size=3 noshade></td>
|
325 |
|
</tr>
|
326 |
|
</table>
|
327 |
|
|
328 |
|
<input type=hidden name=rowcount value=$i>
|
329 |
|
<input type=hidden name=accno value=$form->{accno}>
|
330 |
|
<input type=hidden name=account value="$form->{account}">
|
331 |
|
|
332 |
|
<input type=hidden name=fromdate value=$form->{fromdate}>
|
333 |
|
<input type=hidden name=todate value=$form->{todate}>
|
334 |
|
|
335 |
|
<br>
|
336 |
|
<input type=submit class=submit name=action value="|
|
337 |
|
. $locale->text('Update') . qq|">
|
338 |
|
<input type=submit class=submit name=action value="|
|
339 |
|
. $locale->text('Select all') . qq|">
|
340 |
|
<input type=submit class=submit name=action value="|
|
341 |
|
. $locale->text('Done') . qq|">
|
342 |
|
|
343 |
|
</form>
|
344 |
|
|
345 |
|
</body>
|
346 |
|
</html>
|
347 |
|
|;
|
|
109 |
$::form->header;
|
|
110 |
print $::form->parse_html_template('rc/step2', {
|
|
111 |
is_asset => $::form->{category} eq 'A',
|
|
112 |
option => \@options,
|
|
113 |
DATA => \@rows,
|
|
114 |
total => {
|
|
115 |
credit => $totalcredits,
|
|
116 |
debit => $totaldebits,
|
|
117 |
},
|
|
118 |
balance => {
|
|
119 |
beginning => $beginningbalance,
|
|
120 |
cleared => $clearedbalance,
|
|
121 |
statement => $statementbalance,
|
|
122 |
},
|
|
123 |
difference => $difference,
|
|
124 |
rowcount => $i,
|
|
125 |
fx => $fx,
|
|
126 |
});
|
348 |
127 |
|
349 |
|
$main::lxdebug->leave_sub();
|
|
128 |
$::lxdebug->leave_sub;
|
350 |
129 |
}
|
351 |
130 |
|
352 |
131 |
sub update {
|
rc.pl display_form in template ausgelagert.
Warnung: Muss nochmal gut durchgetestet werden.