Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8c94b0ea

Von Philip Reetz vor mehr als 16 Jahren hinzugefügt

  • ID 8c94b0eaaf4e1b3717f36a755d71d848abcb21a5
  • Vorgänger a18cc3f5
  • Nachfolger cb8d5a5d

Ueberarbeiteter Kontenbericht

Unterschiede anzeigen:

SL/CA.pm
188 188
    ($form->{category}) = selectrow_query($form, $dbh, $query, $form->{accno});
189 189

  
190 190
    if ($form->{fromdate}) {
191
      # get beginning balance
191
      # get beginning balances
192 192
      $query =
193
        qq|SELECT SUM(ac.amount) | .
194
        qq|FROM acc_trans ac | .
195
        qq|JOIN chart c ON (ac.chart_id = c.id) | .
196
        $dpt_join .
197
        qq|WHERE c.accno = ? | .
198
        qq|AND ac.transdate < ? | .
199
        $dpt_where .
200
        $project;
201
      @values = ($form->{accno}, conv_date($form->{fromdate}),
202
                 @department_values, @project_values);
203

  
204
      if ($form->{project_id}) {
205
        $query .=
206
          qq|UNION | .
207

  
208
          qq|SELECT SUM(ac.qty * ac.sellprice) | .
209
          qq|FROM invoice ac | .
210
          qq|JOIN ar a ON (ac.trans_id = a.id) | .
211
          qq|JOIN parts p ON (ac.parts_id = p.id) | .
212
          qq|JOIN chart c ON (p.income_accno_id = c.id) | .
213
          $dpt_join .
214
          qq|WHERE c.accno = ? | .
215
          qq|  AND a.transdate < ? | .
216
          qq|  AND c.category = 'I' | .
217
          $dpt_where .
218
          $project .
219

  
220
          qq|UNION | .
221

  
222
          qq|SELECT SUM(ac.qty * ac.sellprice) | .
223
          qq|FROM invoice ac | .
224
          qq|JOIN ap a ON (ac.trans_id = a.id) | .
225
          qq|JOIN parts p ON (ac.parts_id = p.id) | .
226
          qq|JOIN chart c ON (p.expense_accno_id = c.id) | .
227
          $dpt_join .
228
          qq|WHERE c.accno = ? | .
229
          qq|  AND a.transdate < ? | .
230
          qq|  AND c.category = 'E' | .
231
          $dpt_where .
232
          $project;
233

  
234
        push(@values,
235
             $form->{accno}, conv_date($form->{transdate}),
236
             @department_values, @project_values,
237
             $form->{accno}, conv_date($form->{transdate}),
238
             @department_values, @project_values);
239
      }
193
        qq|SELECT SUM(ac.amount) AS amount
194
            FROM acc_trans ac
195
            JOIN chart c ON (ac.chart_id = c.id)
196
            $dpt_join
197
            WHERE ((select date_trunc('year', ac.transdate::date)) = (select date_trunc('year', ?::date))) AND ac.ob_transaction 
198
              $dpt_where
199
              $project
200
            AND c.accno = ?|;
201
    
202
      ($form->{beginning_balance}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno});
203

  
204
      # get last transaction date
205
      my $todate = ($form->{todate}) ? " AND ac.transdate <= '$form->{todate}' " : "";
206
      $query = qq|SELECT max(ac.transdate) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id)WHERE ((select date_trunc('year', ac.transdate::date)) = (select date_trunc('year', ?::date))) $todate AND c.accno = ?|;
207
      ($form->{last_transaction}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno});
208

  
209
      # get old saldo
210
      $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id)WHERE ((select date_trunc('year', ac.transdate::date)) = (select date_trunc('year', ?::date))) AND ac.transdate < ? AND c.accno = ?|;
211
      ($form->{saldo_old}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{fromdate}, $form->{accno});
212

  
213
      #get old balance
214
      $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id)WHERE ((select date_trunc('year', ac.transdate::date)) = (select date_trunc('year', ?::date))) AND ac.transdate < ? AND c.accno = ? AND ac.amount < 0 AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|;
215
      ($form->{old_balance_debit}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{fromdate}, $form->{accno});
240 216

  
241
      ($form->{balance}) = selectrow_query($form, $dbh, $query, @values);
217
      $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id)WHERE ((select date_trunc('year', ac.transdate::date)) = (select date_trunc('year', ?::date))) AND ac.transdate < ? AND c.accno = ? AND ac.amount > 0 AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|;
218
      ($form->{old_balance_credit}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{fromdate}, $form->{accno});
219

  
220
      # get current saldo
221
      my $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : "";
222
      $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id)WHERE ((select date_trunc('year', ac.transdate::date)) = (select date_trunc('year', ?::date))) $todate AND c.accno = ?|;
223
      ($form->{saldo_new}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno});
224

  
225
      #get current balance
226
      my $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : "";
227
      $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id)WHERE ((select date_trunc('year', ac.transdate::date)) = (select date_trunc('year', ?::date))) $todate AND c.accno = ? AND ac.amount < 0 AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|;
228
      ($form->{current_balance_debit}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno});
229

  
230
      my $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : "";
231
      $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id)WHERE ((select date_trunc('year', ac.transdate::date)) = (select date_trunc('year', ?::date))) $todate AND c.accno = ? AND ac.amount > 0 AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|;
232
      ($form->{current_balance_credit}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno});
242 233
    }
243 234
  }
244 235

  
......
258 249
    #  JOIN ... that also works.
259 250

  
260 251
    # get all transactions
261
    $query .=
262
      $union .
263
      qq|SELECT a.id, a.reference, a.description, ac.transdate, | .
264
      qq|  $false AS invoice, ac.amount, 'gl' as module | .
252
    $query =
253
      qq|SELECT a.id, a.reference, a.description, ac.transdate, ac.chart_id, | .
254
      qq|  $false AS invoice, ac.amount, 'gl' as module, | .
255
      qq?(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = (SELECT tax_id FROM taxkeys WHERE taxkey_id = ac.taxkey AND taxkeys.startdate <= ac.transdate ORDER BY taxkeys.startdate DESC LIMIT 1)) AS taxinfo ? .
265 256
      qq|FROM acc_trans ac, gl a | .
266 257
      $dpt_join .
267 258
      qq|WHERE | . $where . $dpt_where . $project .
268 259
      qq|  AND ac.chart_id = ? | .
269 260
      qq| AND ac.trans_id = a.id | .
261
      qq| AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL) | .
270 262

  
271 263
      qq|UNION ALL | .
272 264

  
273
      qq|SELECT a.id, a.invnumber, c.name, ac.transdate, | .
274
      qq|  a.invoice, ac.amount, 'ar' as module | .
265
      qq|SELECT a.id, a.invnumber, c.name, ac.transdate, ac.chart_id, | .
266
      qq|  a.invoice, ac.amount, 'ar' as module, | .
267
      qq?(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = (SELECT tax_id FROM taxkeys WHERE taxkey_id = ac.taxkey AND taxkeys.startdate <= ac.transdate ORDER BY taxkeys.startdate DESC LIMIT 1)) AS taxinfo ? . 
275 268
      qq|FROM acc_trans ac, customer c, ar a | .
276 269
      $dpt_join .
277 270
      qq|WHERE | . $where . $dpt_where . $project .
278 271
      qq| AND ac.chart_id = ? | .
279
      qq| AND NOT a.storno | .
280 272
      qq| AND ac.trans_id = a.id | .
281 273
      qq| AND a.customer_id = c.id | .
274
      qq| AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL) | .
282 275

  
283 276
      qq|UNION ALL | .
284 277

  
285
      qq|SELECT a.id, a.invnumber, v.name, ac.transdate, | .
286
      qq|  a.invoice, ac.amount, 'ap' as module | .
278
      qq|SELECT a.id, a.invnumber, v.name, ac.transdate, ac.chart_id, | .
279
      qq|  a.invoice, ac.amount, 'ap' as module, | .
280
      qq?(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = (SELECT tax_id FROM taxkeys WHERE taxkey_id = ac.taxkey AND taxkeys.startdate <= ac.transdate ORDER BY taxkeys.startdate DESC LIMIT 1)) AS taxinfo ? .
287 281
      qq|FROM acc_trans ac, vendor v, ap a | .
288 282
      $dpt_join .
289 283
      qq|WHERE | . $where . $dpt_where . $project .
290 284
      qq| AND ac.chart_id = ? | .
291 285
      qq| AND ac.trans_id = a.id | .
292
      qq| AND NOT a.storno | .
293 286
      qq| AND a.vendor_id = v.id |;
287
      qq| AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL) | .
294 288

  
295 289
    push(@values,
296 290
         @where_values, @department_values, @project_values, $id,
......
308 302
        qq|UNION ALL | .
309 303

  
310 304
        qq|SELECT a.id, a.invnumber, c.name, a.transdate, | .
311
        qq|  a.invoice, ac.qty * ac.sellprice AS sellprice, 'ar' as module | .
305
        qq|  a.invoice, ac.qty * ac.sellprice AS sellprice, 'ar' as module, | .
306
        qq?(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = (SELECT tax_id FROM taxkeys WHERE taxkey_id = ac.taxkey AND taxkeys.startdate <= ac.transdate ORDER BY taxkeys.startdate DESC LIMIT 1)) AS taxinfo ? .
312 307
        qq|FROM ar a | .
313 308
        qq|JOIN invoice ac ON (ac.trans_id = a.id) | .
314 309
        qq|JOIN parts p ON (ac.parts_id = p.id) | .
......
323 318
        qq|UNION ALL | .
324 319

  
325 320
        qq|SELECT a.id, a.invnumber, v.name, a.transdate, | .
326
        qq|  a.invoice, ac.qty * ac.sellprice AS sellprice, 'ap' as module | .
321
        qq|  a.invoice, ac.qty * ac.sellprice AS sellprice, 'ap' as module, | .
322
        qq?(SELECT accno||'--'||rate FROM tax LEFT JOIN chart ON (tax.chart_id=chart.id) WHERE tax.id = (SELECT tax_id FROM taxkeys WHERE taxkey_id = ac.taxkey AND taxkeys.startdate <= ac.transdate ORDER BY taxkeys.startdate DESC LIMIT 1)) AS taxinfo ? .
327 323
        qq|FROM ap a | .
328 324
        qq|JOIN invoice ac ON (ac.trans_id = a.id) | .
329 325
        qq|JOIN parts p ON (ac.parts_id = p.id) | .
......
352 348
  $query .= qq|ORDER BY $sort|;
353 349
  $sth = prepare_execute_query($form, $dbh, $query, @values);
354 350

  
351
  #get detail information for each transaction
352
  $trans_query =
353
        qq|SELECT accno, | .
354
        qq|amount, transdate FROM acc_trans LEFT JOIN chart ON (chart_id=chart.id) WHERE | .
355
        qq|trans_id = ? AND sign(amount) <> sign(?) AND chart_id <> ? AND transdate = ?|;
356
  my $trans_sth = $dbh->prepare($trans_query);
357

  
355 358
  $form->{CA} = [];
356 359
  while (my $ca = $sth->fetchrow_hashref(NAME_lc)) {
357 360
    # ap
......
372 375
      $ca->{debit}  = 0;
373 376
    }
374 377

  
375
    $ca->{index} = join "--", map { $ca->{$_} } qw(id reference description);
378
    ($ca->{ustkonto},$ca->{ustrate}) = split /--/, $ca->{taxinfo};
379

  
380
    #get detail information for this transaction
381
    $trans_sth->execute($ca->{id}, $ca->{amount}, $ca->{chart_id}, $ca->{transdate}) ||
382
    $form->dberror($trans_query . " (" . join(", ", $ca->{id}) . ")");
383
    while (my $trans = $trans_sth->fetchrow_hashref(NAME_lc)) {
384
      if (($ca->{transdate} eq $trans->{transdate}) && ($ca->{amount} * $trans->{amount} < 0)) {
385
        if ($trans->{amount} < 0) {
386
          $trans->{debit}  = $trans->{amount} * -1;
387
          $trans->{credit} = 0;
388
        } else {
389
          $trans->{credit} = $trans->{amount};
390
          $trans->{debit}  = 0;
391
        } 
392
        push(@{ $ca->{GEGENKONTO} }, $trans);
393
      } else {
394
        next;
395
      }
396
    }
397

  
398
    $ca->{index} = join "--", map { $ca->{$_} } qw(id reference description transdate);
376 399

  
377 400
    push(@{ $form->{CA} }, $ca);
378 401

  
bin/mozilla/ca.pl
142 142

  
143 143
  $form->{title} = $locale->text('List Transactions');
144 144
  $form->{title} .= " - " . $locale->text('Account') . " $form->{accno}";
145
  $year = (localtime)[5] + 1900;
145 146

  
146 147
  # get departments
147 148
  $form->all_departments(\%myconfig);
......
160 161
	  <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
161 162
	</tr>
162 163
| if $form->{selectdepartment};
164
  $accrual = ($eur) ? ""        : "checked";
165
  $cash    = ($eur) ? "checked" : "";
166
 
167
  $name_1    = "fromdate";
168
  $id_1      = "fromdate";
169
  $value_1   = "$form->{fromdate}";
170
  $trigger_1 = "trigger1";
171
  $name_2    = "todate";
172
  $id_2      = "todate";
173
  $value_2   = "";
174
  $trigger_2 = "trigger2";
175

  
176

  
177
  # with JavaScript Calendar
178
  if ($form->{jsscript}) {
179
    if ($name_1 eq "") {
180

  
181
      $button1 = qq|
182
         <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
183
      $button1_2 = qq|
184
        <input type=button name=$name_2 id="$trigger_2" value=|
185
        . $locale->text('button') . qq|>|;
186

  
187
      #write Trigger
188
      $jsscript =
189
        Form->write_trigger(\%myconfig, "1", "$name_2", "BR", "$trigger_2");
190
    } else {
191
      $button1 = qq|
192
         <input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\" value="$value_1">|;
193
      $button1_2 = qq|
194
        <input type=button name=$name_1 id="$trigger_1" value=|
195
        . $locale->text('button') . qq|>|;
196
      $button2 = qq|
197
         <input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
198
      $button2_2 = qq|
199
         <input type=button name=$name_2 id="$trigger_2" value=|
200
        . $locale->text('button') . qq|>
201
       |;
202

  
203
      #write Trigger
204
      $jsscript =
205
        Form->write_trigger(\%myconfig, "2", "$name_1", "BR", "$trigger_1",
206
                            "$name_2", "BL", "$trigger_2");
207
    }
208
  } else {
209

  
210
    # without JavaScript Calendar
211
    if ($name_1 eq "") {
212
      $button1 =
213
        qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
214
    } else {
215
      $button1 =
216
        qq|<input name=$name_1 id=$id_1 size=11 title="$myconfig{dateformat}" value="$value_1" onBlur=\"check_right_date_format(this)\">|;
217
      $button2 =
218
        qq|<input name=$name_2 id=$id_2 size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">|;
219
    }
220
  }
221
  $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
222
  $form->header;
223
  $onload = qq|focus()|;
224
  $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
225
  $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
226

  
163 227

  
164 228
  $form->header;
165 229

  
166 230
  $form->{description} =~ s/\"/&quot;/g;
167 231

  
168 232
  print qq|
169
<body>
233
<body onLoad="$onload">
170 234

  
171 235
<form method=post action=$form->{script}>
172 236

  
......
177 241
<input type=hidden name=accounttype value=$form->{accounttype}>
178 242

  
179 243
<table border=0 width=100%>
180
  <tr><th class=listtop>$form->{title}</th></tr>
181
  <tr height="5"></tr
182
  <tr valign=top>
183
    <td>
184
      <table>
185
        $department
244
  <tr>
245
    <th class=listtop>$form->{title}</th>
246
  </tr>
247

  
248
</table>
249
<table>
186 250
	<tr>
187
	  <th align=right>| . $locale->text('From') . qq|</th>
188
	  <td><input name=fromdate size=11 title="$myconfig{dateformat}"></td>
189
	  <th align=right>| . $locale->text('To') . qq|</th>
190
	  <td><input name=todate size=11 title="$myconfig{dateformat}"></td>
251
	  <th align=left><input name=reporttype class=radio type=radio value="custom" checked> |
252
      . $locale->text('Customized Report') . qq|</th>
191 253
	</tr>
192 254
	<tr>
193
	  <th align=right>| . $locale->text('Include in Report') . qq|</th>
194
	  <td colspan=3>
195
	  <input name=l_subtotal class=checkbox type=checkbox value=Y>&nbsp;|
196
    . $locale->text('Subtotal') . qq|</td>
255
	  <th colspan=1>| . $locale->text('Year') . qq|</th>
256
	  <td><input name=year size=11 title="|
257
      . $locale->text('YYYY') . qq|" value="$year"></td>
197 258
	</tr>
198
      </table>
199
    </td>
200
  </tr>
201
  <tr><td><hr size=3 noshade></td></tr>
259
|;
260

  
261
    print qq|
262
	<tr>
263
		<td align=right>
264
<b> | . $locale->text('Yearly') . qq|</b> </td>
265
		<th align=left>| . $locale->text('Quarterly') . qq|</th>
266
		<th align=left colspan=3>| . $locale->text('Monthly') . qq|</th>
267
	</tr>
268
	<tr>
269
		<td align=right>&nbsp; <input name=duetyp class=radio type=radio value="13"
270
$checked></td>
271
		<td><input name=duetyp class=radio type=radio value="A" $checked >&nbsp;1. |
272
      . $locale->text('Quarter') . qq|</td>
273
|;
274
    $checked = "checked";
275
    print qq|
276
		<td><input name=duetyp class=radio type=radio value="1" $checked >&nbsp;|
277
      . $locale->text('January') . qq|</td>
278
|;
279
    $checked = "";
280
    print qq|
281
		<td><input name=duetyp class=radio type=radio value="5" $checked >&nbsp;|
282
      . $locale->text('May') . qq|</td>
283
		<td><input name=duetyp class=radio type=radio value="9" $checked >&nbsp;|
284
      . $locale->text('September') . qq|</td>
285

  
286
	</tr>
287
	<tr>
288
		<td align= right>&nbsp;</td>
289
		<td><input name=duetyp class=radio type=radio value="B" $checked>&nbsp;2. |
290
      . $locale->text('Quarter') . qq|</td>
291
		<td><input name=duetyp class=radio type=radio value="2" $checked >&nbsp;|
292
      . $locale->text('February') . qq|</td>
293
		<td><input name=duetyp class=radio type=radio value="6" $checked >&nbsp;|
294
      . $locale->text('June') . qq|</td>
295
		<td><input name=duetyp class=radio type=radio value="10" $checked >&nbsp;|
296
      . $locale->text('October') . qq|</td>
297
	</tr>
298
	<tr>
299
		<td> &nbsp;</td>
300
		<td><input name=duetyp class=radio type=radio value="C" $checked>&nbsp;3. |
301
      . $locale->text('Quarter') . qq|</td>
302
		<td><input name=duetyp class=radio type=radio value="3" $checked >&nbsp;|
303
      . $locale->text('March') . qq|</td>
304
		<td><input name=duetyp class=radio type=radio value="7" $checked >&nbsp;|
305
      . $locale->text('July') . qq|</td>
306
		<td><input name=duetyp class=radio type=radio value="11" $checked >&nbsp;|
307
      . $locale->text('November') . qq|</td>
308

  
309
	</tr>
310
	<tr>
311
		<td> &nbsp;</td>
312
		<td><input name=duetyp class=radio type=radio value="D" $checked>&nbsp;4. |
313
      . $locale->text('Quarter') . qq|&nbsp;</td>
314
		<td><input name=duetyp class=radio type=radio value="4" $checked >&nbsp;|
315
      . $locale->text('April') . qq|</td>
316
		<td><input name=duetyp class=radio type=radio value="8" $checked >&nbsp;|
317
      . $locale->text('August') . qq|</td>
318
		<td><input name=duetyp class=radio type=radio value="12" $checked >&nbsp;|
319
      . $locale->text('December') . qq|</td>
320

  
321
	</tr>
322
	<tr>
323
   		<td colspan=5><hr size=3 noshade></td>
324
	</tr>
325
	<tr>
326
          <th align=left><input name=reporttype class=radio type=radio value="free" $checked> |
327
      . $locale->text('Free report period') . qq|</th>
328
	  <td align=left colspan=4>| . $locale->text('From') . qq|&nbsp;
329
	      $button1
330
              $button1_2&nbsp;
331
	      | . $locale->text('Bis') . qq|&nbsp;
332
	      $button2
333
              $button2_2
334
          </td>
335
        </tr>
336
	<tr>
337
   		<td colspan=5><hr size=3 noshade></td>
338
	</tr>
339
	<tr>
340
	  <th align=leftt>| . $locale->text('Method') . qq|</th>
341
	  <td colspan=3><input name=method class=radio type=radio value=accrual $accrual>|
342
      . $locale->text('Accrual') . qq|
343
	  &nbsp;<input name=method class=radio type=radio value=cash $cash>|
344
      . $locale->text('EUR') . qq|</td>
345
	</tr>
346
        <tr>
347
         <th align=right colspan=4>|
348
      . $locale->text('Decimalplaces')
349
      . qq|</th>
350
             <td><input name=decimalplaces size=3 value="2"></td>
351
         </tr>
352
                                    
353
$jsscript
354
  <tr><td colspan=5 ><hr size=3 noshade></td></tr>
202 355
</table>
203 356

  
204 357
<br><input class=submit type=submit name=action value="|
......
219 372

  
220 373
  $form->{title} = $locale->text('Account') . " $form->{accno} - $form->{description}";
221 374

  
375
  if ($form->{reporttype} eq "custom") {
376

  
377
    #forgotten the year --> thisyear
378
    if ($form->{year} !~ m/^\d\d\d\d$/) {
379
      $locale->date(\%myconfig, $form->current_date(\%myconfig), 0) =~
380
        /(\d\d\d\d)/;
381
      $form->{year} = $1;
382
    }
383

  
384
    #yearly report
385
    if ($form->{duetyp} eq "13") {
386
      $form->{fromdate} = "1.1.$form->{year}";
387
      $form->{todate}   = "31.12.$form->{year}";
388
    }
389

  
390
    #Quater reports
391
    if ($form->{duetyp} eq "A") {
392
      $form->{fromdate} = "1.1.$form->{year}";
393
      $form->{todate}   = "31.3.$form->{year}";
394
    }
395
    if ($form->{duetyp} eq "B") {
396
      $form->{fromdate} = "1.4.$form->{year}";
397
      $form->{todate}   = "30.6.$form->{year}";
398
    }
399
    if ($form->{duetyp} eq "C") {
400
      $form->{fromdate} = "1.7.$form->{year}";
401
      $form->{todate}   = "30.9.$form->{year}";
402
    }
403
    if ($form->{duetyp} eq "D") {
404
      $form->{fromdate} = "1.10.$form->{year}";
405
      $form->{todate}   = "31.12.$form->{year}";
406
    }
407

  
408
    #Monthly reports
409
  SWITCH: {
410
      $form->{duetyp} eq "1" && do {
411
        $form->{fromdate} = "1.1.$form->{year}";
412
        $form->{todate}   = "31.1.$form->{year}";
413
        last SWITCH;
414
      };
415
      $form->{duetyp} eq "2" && do {
416
        $form->{fromdate} = "1.2.$form->{year}";
417

  
418
        #this works from 1901 to 2099, 1900 and 2100 fail.
419
        $leap = ($form->{year} % 4 == 0) ? "29" : "28";
420
        $form->{todate} = "$leap.2.$form->{year}";
421
        last SWITCH;
422
      };
423
      $form->{duetyp} eq "3" && do {
424
        $form->{fromdate} = "1.3.$form->{year}";
425
        $form->{todate}   = "31.3.$form->{year}";
426
        last SWITCH;
427
      };
428
      $form->{duetyp} eq "4" && do {
429
        $form->{fromdate} = "1.4.$form->{year}";
430
        $form->{todate}   = "30.4.$form->{year}";
431
        last SWITCH;
432
      };
433
      $form->{duetyp} eq "5" && do {
434
        $form->{fromdate} = "1.5.$form->{year}";
435
        $form->{todate}   = "31.5.$form->{year}";
436
        last SWITCH;
437
      };
438
      $form->{duetyp} eq "6" && do {
439
        $form->{fromdate} = "1.6.$form->{year}";
440
        $form->{todate}   = "30.6.$form->{year}";
441
        last SWITCH;
442
      };
443
      $form->{duetyp} eq "7" && do {
444
        $form->{fromdate} = "1.7.$form->{year}";
445
        $form->{todate}   = "31.7.$form->{year}";
446
        last SWITCH;
447
      };
448
      $form->{duetyp} eq "8" && do {
449
        $form->{fromdate} = "1.8.$form->{year}";
450
        $form->{todate}   = "31.8.$form->{year}";
451
        last SWITCH;
452
      };
453
      $form->{duetyp} eq "9" && do {
454
        $form->{fromdate} = "1.9.$form->{year}";
455
        $form->{todate}   = "30.9.$form->{year}";
456
        last SWITCH;
457
      };
458
      $form->{duetyp} eq "10" && do {
459
        $form->{fromdate} = "1.10.$form->{year}";
460
        $form->{todate}   = "31.10.$form->{year}";
461
        last SWITCH;
462
      };
463
      $form->{duetyp} eq "11" && do {
464
        $form->{fromdate} = "1.11.$form->{year}";
465
        $form->{todate}   = "30.11.$form->{year}";
466
        last SWITCH;
467
      };
468
      $form->{duetyp} eq "12" && do {
469
        $form->{fromdate} = "1.12.$form->{year}";
470
        $form->{todate}   = "31.12.$form->{year}";
471
        last SWITCH;
472
      };
473
    }
474
  }
475

  
222 476
  CA->all_transactions(\%myconfig, \%$form);
223 477

  
478
  print(STDERR "EB: $form->{beginning_balance}\n");
479

  
480
  my $saldo_old = ($form->{saldo_old} > 0) ? $form->format_amount(\%myconfig, $form->{saldo_old}, 2) . " H" : $form->format_amount(\%myconfig, abs($form->{saldo_old}) , 2) . " S";
481

  
482
  my $eb_string = ($form->{beginning_balance} > 0) ? $form->format_amount(\%myconfig, $form->{beginning_balance}, 2) . " H" : $form->format_amount(\%myconfig, abs($form->{beginning_balance}), 2) . " S";
483
  print(STDERR "EB: $eb_string\n");
484

  
224 485
  my @options;
225 486
  if ($form->{department}) {
226 487
    my ($department) = split /--/, $form->{department};
......
249 510

  
250 511
  push @options, $period;
251 512

  
252
  my @columns     = qw(transdate reference description debit credit balance);
513
  my @columns     = qw(transdate reference description gegenkonto debit credit ustkonto ustrate);
253 514
  my %column_defs = (
254 515
    'transdate'   => { 'text' => $locale->text('Date'), },
255 516
    'reference'   => { 'text' => $locale->text('Reference'), },
256 517
    'description' => { 'text' => $locale->text('Description'), },
257 518
    'debit'       => { 'text' => $locale->text('Debit'), },
258 519
    'credit'      => { 'text' => $locale->text('Credit'), },
259
    'balance'     => { 'text' => $locale->text('Balance'), },
260
  );
261
  my %column_alignment = map { $_ => 'right' } qw(debit credit balance);
520
    'gegenkonto'     => { 'text' => $locale->text('Gegenkonto'), },
521
    'ustkonto'     => { 'text' => $locale->text('USt-Konto'), },
522
     'ustrate'     => { 'text' => $locale->text('Satz %'), },
523
 );
524
  my %column_alignment = map { $_ => 'right' } qw(debit credit);
525

  
526
  @custom_headers = ();
527
 # Zeile 1:
528
 push @custom_headers, [
529
   { 'text' => 'Letzte Buchung', },
530
   { 'text' => 'EB-Wert', },
531
   { 'text' => 'Saldo alt', 'colspan' => 2, },
532
   { 'text' => 'Jahresverkehrszahlen alt', 'colspan' => 2, },
533
   { 'text' => '', 'colspan' => 2, },
534
 ];
535
 push @custom_headers, [
536
   { 'text' => $form->{last_transaction}, },
537
   { 'text' => $eb_string, },
538
   { 'text' => $saldo_old, 'colspan' => 2, },
539
   { 'text' => $form->format_amount(\%myconfig, abs($form->{old_balance_debit}), 2) . " S", },
540
   { 'text' => $form->format_amount(\%myconfig, $form->{old_balance_credit}, 2) . " H", },
541
   { 'text' => '', 'colspan' => 2, },
542
 ];
543
 # Zeile 2:
544
 push @custom_headers, [
545
   { 'text' => $locale->text('Date'), },
546
   { 'text' => $locale->text('Reference'), },
547
   { 'text' => $locale->text('Description'), },
548
   { 'text' => $locale->text('Gegenkonto'), },
549
   { 'text' => $locale->text('Debit'), },
550
   { 'text' => $locale->text('Credit'), },
551
   { 'text' => $locale->text('USt-Konto'), },
552
   { 'text' => $locale->text('Satz %'), },
553
 ];
554

  
555

  
262 556

  
263 557
  my @hidden_variables = qw(accno fromdate todate description accounttype l_heading l_subtotal department projectnumber project_id sort);
264 558

  
......
268 562
  $form->{callback} = $link . '&sort=' . E($form->{sort});
269 563

  
270 564
  my $report = SL::ReportGenerator->new(\%myconfig, $form);
565
  $report->set_custom_headers(@custom_headers);
271 566

  
272 567
  $report->set_options('top_info_text'         => join("\n", @options),
273 568
                       'output_format'         => 'HTML',
......
288 583

  
289 584
  my $ml = ($form->{category} =~ /(A|E)/) ? -1 : 1;
290 585

  
291
  if ($form->{accno} && $form->{balance}) {
292
    my $row = {
293
      'balance' => {
294
        'data'  => $form->format_amount(\%myconfig, $form->{balance} * $ml, 2),
295
        'align' => 'right',
296
      },
297
    };
298

  
299
    $report->add_data($row);
300
  }
301 586

  
302 587
  my $idx       = 0;
303 588
  my %totals    = ( 'debit' => 0, 'credit' => 0 );
......
305 590
  my ($previous_index, $row_set);
306 591

  
307 592
  foreach my $ca (@{ $form->{CA} }) {
308
    $form->{balance} += $ca->{amount};
309 593

  
310 594
    foreach (qw(debit credit)) {
311 595
      $subtotals{$_} += $ca->{$_};
......
313 597
      $ca->{$_}       = $form->format_amount(\%myconfig, $ca->{$_}, 2) if ($ca->{$_} != 0);
314 598
    }
315 599

  
316
    $ca->{balance} = $form->format_amount(\%myconfig, $form->{balance} * $ml, 2);
317 600

  
318 601
    my $row = { };
319 602

  
603
    $ca->{ustrate} = $form->format_amount(\%myconfig, $ca->{ustrate} * 100, 2) if ($ca->{ustrate} != 0);
604

  
605
    
606

  
607
    foreach my $gegenkonto (@{ $ca->{GEGENKONTO} }) {
608
      if ($ca->{gegenkonto} eq "") {
609
        $ca->{gegenkonto} = $gegenkonto->{accno};
610
      } else {
611
        $ca->{gegenkonto} .= ", " . $gegenkonto->{accno};
612
      }
613
    }
614

  
320 615
    foreach (@columns) {
321 616
      $row->{$_} = {
322 617
        'data'  => $ca->{$_},
......
356 651
  $row->{balance}->{data} = $form->format_amount(\%myconfig, $form->{balance} * $ml, 2);
357 652
  $report->add_data($row);
358 653

  
654

  
655
  $report->add_separator();
656
  my $row = {
657
     'transdate' => {
658
       'data'    => "",
659
       'class' => 'listtotal',
660
     },
661
     'reference' => {
662
       'data'    => $locale->text('EB-Wert'),
663
       'class' => 'listtotal',
664
     },
665
     'description'      => {
666
       'data'    => $locale->text('Saldo neu'),
667
       'colspan' => 2,
668
       'class' => 'listtotal',
669
     },
670
     'debit'      => {
671
       'data'    => $locale->text('Jahresverkehrszahlen neu'),
672
       'colspan' => 2,
673
       'align' => 'left',
674
       'class' => 'listtotal',
675
    },
676
     'ustkonto'      => {
677
       'data'    => '',
678
       'colspan' => 2,
679
       'align' => 'left',
680
       'class' => 'listtotal',
681
    },
682
  };
683

  
684
  $report->add_data($row);
685
  my $saldo_new = ($form->{saldo_new} > 0) ? $form->format_amount(\%myconfig, $form->{saldo_new}, 2) . " H" : $form->format_amount(\%myconfig, abs($form->{saldo_new}) , 2) . " S";
686
  my $row = {
687
     'transdate' => {
688
       'data'    => "",
689
       'class' => 'listtotal',
690
     },
691
     'reference' => {
692
       'data'    => $eb_string,
693
       'class' => 'listtotal',
694
     },
695
     'description'      => {
696
       'data'    => $saldo_new,
697
       'colspan' => 2,
698
       'class' => 'listtotal',
699
     },
700
     'debit'      => {
701
       'data'    => $form->format_amount(\%myconfig, abs($form->{current_balance_debit}) , 2) . " S",
702
       'class' => 'listtotal',
703
     },
704
      'credit'      => {
705
       'data'    => $form->format_amount(\%myconfig, $form->{current_balance_credit}, 2) . " H",
706
       'class' => 'listtotal',
707
     },
708
      'ustkonto'      => {
709
       'data'    => "",
710
       'colspan' => 2,
711
       'class' => 'listtotal',
712
     },
713
  };
714

  
715
  $report->add_data($row);
716

  
359 717
  $report->generate_with_headers();
360 718

  
361 719
  $lxdebug->leave_sub();
locale/de/all
509 509
  'E-mail address missing!'     => 'E-Mail-Adresse fehlt!',
510 510
  'EAN'                         => 'EAN',
511 511
  'EAN-Code'                    => 'EAN-Code',
512
  'EB-Wert'                     => 'EB-Wert',
512 513
  'EK'                          => 'EK',
513 514
  'ELSE'                        => 'Zusatz',
514 515
  'ELSTER Export (Taxbird)'     => 'ELSTER-Export nach Taxbird',
......
659 660
  'Full Access'                 => 'Vollzugriff',
660 661
  'Full access to all functions' => 'Vollzugriff auf alle Funktionen',
661 662
  'GL Transaction'              => 'Dialogbuchung',
663
  'Gegenkonto'                  => 'Gegenkonto',
662 664
  'General Ledger'              => 'Finanzbuchhaltung',
663 665
  'General ledger and cash'     => 'Finanzbuchhaltung und Zahlungsverkehr',
664 666
  'Generic Tax Report'          => 'USTVA Bericht',
......
758 760
  'It may optionally be compressed with &quot;gzip&quot;.' => 'Sie darf optional mit &quot;gzip&quot; komprimiert sein.',
759 761
  'Item deleted!'               => 'Artikel gel?scht!',
760 762
  'Item not on file!'           => 'Dieser Artikel ist nicht in der Datenbank!',
763
  'Jahresverkehrszahlen neu'    => 'Jahresverkehrszahlen neu',
761 764
  'Jan'                         => 'Jan',
762 765
  'January'                     => 'Januar',
763 766
  'Journal'                     => 'Buchungsjournal',
......
1177 1180
  'SIC'                         => 'SIC',
1178 1181
  'Saldo Credit'                => 'Saldo Haben',
1179 1182
  'Saldo Debit'                 => 'Saldo Soll',
1183
  'Saldo neu'                   => 'Saldo neu',
1180 1184
  'Saldo per'                   => 'Saldo per',
1181 1185
  'Sales Invoice'               => 'Rechnung',
1182 1186
  'Sales Invoices'              => 'Kundenrechnung',
......
1189 1193
  'Same as the quote character' => 'Wie Anf&uuml;hrungszeichen',
1190 1194
  'Sat. Fax'                    => 'Sat. Fax',
1191 1195
  'Sat. Phone'                  => 'Sat. Tel.',
1196
  'Satz %'                      => 'Satz %',
1192 1197
  'Save'                        => 'Speichern',
1193 1198
  'Save account first to insert taxkeys' => 'Einstellungen sind nach
1194 1199
  dem Speichern des Kontos verf?gbar...',
......
1503 1508
  'USTVA-Hint: Method'          => 'Wenn Sie Ist-Versteuert sind, w?hlen Sie die Einnahmen-/?berschu?-Rechnung aus. Sind Sie Soll-Versteuert und bilanzverpflichtet, dann w?hlen Sie Bilanz aus.',
1504 1509
  'USTVA-Hint: Tax Authoritys'  => 'Bitte das Bundesland UND die Stadt bzw. den Einzugsbereich Ihres zust?ndigen Finanzamts ausw?hlen.',
1505 1510
  'USt-IdNr.'                   => 'USt-IdNr.',
1511
  'USt-Konto'                   => 'USt-Konto',
1506 1512
  'UStVA'                       => 'UStVA',
1507 1513
  'UStVA (PDF-Dokument)'        => 'UStVa als PDF-Dokument',
1508 1514
  'UStVa'                       => 'UStVa',
locale/de/ca
5 5
  'AP'                          => 'Einkauf',
6 6
  'AR'                          => 'Verkauf',
7 7
  'Account'                     => 'Konto',
8
  'Accrual'                     => 'Bilanzierung',
8 9
  'Advance turnover tax return' => 'Umsatzsteuervoranmeldung',
9 10
  'All reports'                 => 'Alle Berichte (Konten&uuml;bersicht, Summen- u. Saldenliste, GuV, BWA, Bilanz, Projektbuchungen)',
10 11
  'Apr'                         => 'Apr',
11 12
  'April'                       => 'April',
12 13
  'Aug'                         => 'Aug',
13 14
  'August'                      => 'August',
14
  'Balance'                     => 'Bilanz',
15 15
  'Bcc'                         => 'Bcc',
16 16
  'Bin List'                    => 'Lagerliste',
17 17
  'Binding to the LDAP server as "#1" failed. Please check config/authentication.pl.' => 'Die Anmeldung am LDAP-Server als "#1" schlug fehl. Bitte &uuml;berpr&uuml;fen Sie die Angaben in config/authentication.pl.',
18
  'Bis'                         => 'bis',
18 19
  'CANCELED'                    => 'Storniert',
19 20
  'CSV export -- options'       => 'CSV-Export -- Optionen',
20 21
  'Cc'                          => 'Cc',
......
36 37
  'Create and edit vendor invoices' => 'Eingangsrechnungen erfassen und bearbeiten',
37 38
  'Credit'                      => 'Haben',
38 39
  'Credit Note'                 => 'Gutschrift',
40
  'Customized Report'           => 'Vorgew?hlte Zeitr?ume',
39 41
  'DATEV Export'                => 'DATEV-Export',
40 42
  'DELETED'                     => 'Gel?scht',
41 43
  'DUNNING STARTED'             => 'Mahnprozess gestartet',
......
44 46
  'Debit'                       => 'Soll',
45 47
  'Dec'                         => 'Dez',
46 48
  'December'                    => 'Dezember',
49
  'Decimalplaces'               => 'Dezimalstellen',
47 50
  'Delivery Order'              => 'Lieferschein',
48 51
  'Department'                  => 'Abteilung',
49 52
  'Dependency loop detected:'   => 'Schleife in den Abh&auml;ngigkeiten entdeckt:',
50 53
  'Description'                 => 'Beschreibung',
51 54
  'Directory'                   => 'Verzeichnis',
55
  'EB-Wert'                     => 'EB-Wert',
52 56
  'ELSE'                        => 'Zusatz',
57
  'EUR'                         => 'E/?-Rechnung',
53 58
  'Error in database control file \'%s\': %s' => 'Fehler in Datenbankupgradekontrolldatei \'%s\': %s',
59
  'Falsches Datumsformat!'      => 'Falsches Datumsformat!',
54 60
  'Feb'                         => 'Feb',
55 61
  'February'                    => 'Februar',
56 62
  'File'                        => 'Datei',
63
  'Free report period'          => 'Freier Zeitraum',
57 64
  'From'                        => 'Von',
65
  'Gegenkonto'                  => 'Gegenkonto',
58 66
  'General ledger and cash'     => 'Finanzbuchhaltung und Zahlungsverkehr',
59
  'Include in Report'           => 'In Bericht aufnehmen',
60 67
  'Invoice'                     => 'Rechnung',
68
  'Jahresverkehrszahlen neu'    => 'Jahresverkehrszahlen neu',
61 69
  'Jan'                         => 'Jan',
62 70
  'January'                     => 'Januar',
63 71
  'Jul'                         => 'Jul',
......
74 82
  'May '                        => 'Mai',
75 83
  'May set the BCC field when sending emails' => 'Beim Verschicken von Emails das Feld \'BCC\' setzen',
76 84
  'Message'                     => 'Nachricht',
85
  'Method'                      => 'Verfahren',
77 86
  'Missing \'description\' field.' => 'Fehlendes Feld \'description\'.',
78 87
  'Missing \'tag\' field.'      => 'Fehlendes Feld \'tag\'.',
79 88
  'Missing parameter #1 in call to sub #2.' => 'Fehlernder Parameter \'#1\' in Funktionsaufruf \'#2\'.',
89
  'Monthly'                     => 'monatlich',
80 90
  'More than one control file with the tag \'%s\' exist.' => 'Es gibt mehr als eine Kontrolldatei mit dem Tag \'%s\'.',
81 91
  'No or an unknown authenticantion module specified in "config/authentication.pl".' => 'Es wurde kein oder ein unbekanntes Authentifizierungsmodul in "config/authentication.pl" angegeben.',
82 92
  'Nov'                         => 'Nov',
......
95 105
  'Proforma Invoice'            => 'Proformarechnung',
96 106
  'Project Number'              => 'Projektnummer',
97 107
  'Purchase Order'              => 'Lieferantenauftrag',
108
  'Quarter'                     => 'Quartal',
109
  'Quarterly'                   => 'quartalsweise',
98 110
  'Quotation'                   => 'Angebot',
99 111
  'RFQ'                         => 'Anfrage',
100 112
  'Receipt, payment, reconciliation' => 'Zahlungseingang, Zahlungsausgang, Kontenabgleich',
......
103 115
  'SAVED'                       => 'Gespeichert',
104 116
  'SAVED FOR DUNNING'           => 'Gespeichert',
105 117
  'SCREENED'                    => 'Angezeigt',
118
  'Saldo neu'                   => 'Saldo neu',
119
  'Satz %'                      => 'Satz %',
106 120
  'Sep'                         => 'Sep',
107 121
  'September'                   => 'September',
108 122
  'Storno Invoice'              => 'Stornorechnung',
109 123
  'Storno Packing List'         => 'Stornolieferschein',
110 124
  'Subject'                     => 'Betreff',
111
  'Subtotal'                    => 'Zwischensumme',
112 125
  'The \'tag\' field must only consist of alphanumeric characters or the carachters - _ ( )' => 'Das Feld \'tag\' darf nur aus alphanumerischen Zeichen und den Zeichen - _ ( ) bestehen.',
113 126
  'The LDAP server "#1:#2" is unreachable. Please check config/authentication.pl.' => 'Der LDAP-Server "#1:#2" ist nicht erreichbar. Bitte &uuml;berpr&uuml;fen Sie die Angaben in config/authentication.pl.',
114 127
  'The config file "config/authentication.pl" contained invalid Perl code:' => 'Die Konfigurationsdatei "config/authentication.pl" enthielt ung&uuml;tigen Perl-Code:',
......
118 131
  'The connection to the template database failed:' => 'Die Verbindung zur Vorlagendatenbank schlug fehl:',
119 132
  'The creation of the authentication database failed:' => 'Das Anlegen der Authentifizierungsdatenbank schlug fehl:',
120 133
  'The list has been printed.'  => 'Die Liste wurde ausgedruckt.',
121
  'To'                          => 'An',
122 134
  'To (email)'                  => 'An',
123 135
  'Transactions, AR transactions, AP transactions' => 'Dialogbuchen, Debitorenrechnungen, Kreditorenrechnungen',
136
  'USt-Konto'                   => 'USt-Konto',
124 137
  'Unknown dependency \'%s\'.'  => 'Unbekannte Abh&auml;ngigkeit \'%s\'.',
125 138
  'View warehouse content'      => 'Lagerbestand ansehen',
126 139
  'Warehouse management'        => 'Lagerverwaltung/Bestandsver?nderung',
140
  'YYYY'                        => 'JJJJ',
141
  'Year'                        => 'Jahr',
142
  'Yearly'                      => 'j?hrlich',
127 143
  'You do not have the permissions to access this function.' => 'Sie verf&uuml;gen nicht &uuml;ber die notwendigen Rechte, um auf diese Funktion zuzugreifen.',
128 144
  '[email]'                     => '[email]',
129 145
  'bin_list'                    => 'Lagerliste',
146
  'button'                      => '?',
130 147
  'chart_of_accounts'           => 'kontenuebersicht',
131 148
  'config/authentication.pl: Key "DB_config" is missing.' => 'config/authentication.pl: Das Schl&uuml;sselwort "DB_config" fehlt.',
132 149
  'config/authentication.pl: Key "LDAP_config" is missing.' => 'config/authentication.pl: Der Schl&uuml;ssel "LDAP_config" fehlt.',
......
143 160
  'request_quotation'           => 'Angebotsanforderung',
144 161
  'sales_order'                 => 'Kundenauftrag',
145 162
  'sales_quotation'             => 'Verkaufsangebot',
163
  'wrongformat'                 => 'Falsches Format',
146 164
};
147 165

  
148 166
$self->{subs} = {

Auch abrufbar als: Unified diff