Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3da2dca2

Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt

  • ID 3da2dca2e601b311b6e464ffff02bfe98a7024d1
  • Vorgänger 1663bada
  • Nachfolger 48582558

Saldenbilanz und Projektbuchungen auf die Verwendung von ReportGenerator umgestellt.

Unterschiede anzeigen:

bin/mozilla/rp.pl
1256 1256
  $form->{title}   = $locale->text('Project Transactions');
1257 1257
  RP->trial_balance(\%myconfig, \%$form);
1258 1258

  
1259
  &list_accounts;
1259
  list_accounts('generate_projects');
1260 1260

  
1261 1261
  $lxdebug->leave_sub();
1262 1262
}
......
1275 1275

  
1276 1276
  $form->{nextsub} = "generate_trial_balance";
1277 1277
  $form->{title}   = $locale->text('Trial Balance');
1278
  &list_accounts;
1278
  list_accounts('generate_trial_balance');
1279 1279

  
1280 1280
  $lxdebug->leave_sub();
1281 1281
}
1282 1282

  
1283
sub create_list_accounts_subtotal_row {
1284
  $lxdebug->enter_sub();
1285

  
1286
  my ($subtotals, $columns, $fields, $class) = @_;
1287

  
1288
  my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => 'right' } } @{ $columns } };
1289

  
1290
  map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $subtotals->{$_}, 2) } @{ $fields };
1291

  
1292
  $lxdebug->leave_sub();
1293

  
1294
  return $row;
1295
}
1296

  
1283 1297
sub list_accounts {
1284 1298
  $lxdebug->enter_sub();
1285 1299

  
1286
  $title = $form->escape($form->{title});
1300
  my ($action) = @_;
1287 1301

  
1302
  my @options;
1288 1303
  if ($form->{department}) {
1289
    ($department) = split /--/, $form->{department};
1290
    $options    = $locale->text('Department') . " : $department<br>";
1291
    $department = $form->escape($form->{department});
1304
    my ($department) = split /--/, $form->{department};
1305
    push @options, $locale->text('Department') . " : $department";
1292 1306
  }
1293 1307
  if ($form->{projectnumber}) {
1294
    $options .=
1295
      $locale->text('Project Number') . " : $form->{projectnumber}<br>";
1296
    $projectnumber = $form->escape($form->{projectnumber});
1308
    push @options, $locale->text('Project Number') . " : $form->{projectnumber}";
1297 1309
  }
1298 1310

  
1299 1311
  # if there are any dates
1300 1312
  if ($form->{fromdate} || $form->{todate}) {
1313
    my ($fromdate, $todate);
1314

  
1301 1315
    if ($form->{fromdate}) {
1302 1316
      $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1);
1303 1317
    }
......
1305 1319
      $todate = $locale->date(\%myconfig, $form->{todate}, 1);
1306 1320
    }
1307 1321

  
1308
    $form->{period} = "$fromdate - $todate";
1309
  } else {
1310
    $form->{period} =
1311
      $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1322
    push @options, "$fromdate - $todate";
1312 1323

  
1324
  } else {
1325
    push @options, $locale->date(\%myconfig, $form->current_date(\%myconfig), 1);
1313 1326
  }
1314
  $options .= $form->{period};
1315 1327

  
1316
  @column_index = qw(accno description begbalance debit credit endbalance);
1328
  my @columns     = qw(accno description begbalance debit credit endbalance);
1329
  my %column_defs = (
1330
    'accno'       => { 'text' => $locale->text('Account'), },
1331
    'description' => { 'text' => $locale->text('Description'), },
1332
    'debit'       => { 'text' => $locale->text('Debit'), },
1333
    'credit'      => { 'text' => $locale->text('Credit'), },
1334
    'begbalance'  => { 'text' => $locale->text('Balance'), },
1335
    'endbalance'  => { 'text' => $locale->text('Balance'), },
1336
  );
1337
  my %column_alignment = map { $_ => 'right' } qw(debit credit begbalance endbalance);
1317 1338

  
1318
  $column_header{accno} =
1319
    qq|<th class=listheading>| . $locale->text('Account') . qq|</th>|;
1320
  $column_header{description} =
1321
    qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
1322
  $column_header{debit} =
1323
    qq|<th class=listheading>| . $locale->text('Debit') . qq|</th>|;
1324
  $column_header{credit} =
1325
    qq|<th class=listheading>| . $locale->text('Credit') . qq|</th>|;
1326
  $column_header{begbalance} =
1327
    qq|<th class=listheading>| . $locale->text('Balance') . qq|</th>|;
1328
  $column_header{endbalance} =
1329
    qq|<th class=listheading>| . $locale->text('Balance') . qq|</th>|;
1339
  my @hidden_variables = qw(fromdate todate department l_heading l_subtotal all_accounts sort accounttype eur projectnumber project_id title nextsub);
1330 1340

  
1331
  $form->header;
1341
  $form->{callback} = build_std_url("action=$action", grep { $form->{$_} } @hidden_variables);
1332 1342

  
1333
  print qq|
1334
<body>
1343
  my $report = SL::ReportGenerator->new(\%myconfig, $form);
1335 1344

  
1336
<table width=100%>
1337
  <tr>
1338
    <th class=listtop>$form->{title}</th>
1339
  </tr>
1340
  <tr height="5"></tr>
1341
  <tr>
1342
    <td>$options</td>
1343
  </tr>
1344
  <tr>
1345
    <td>
1346
      <table width=100%>
1347
	<tr>|;
1345
  $report->set_options('top_info_text'         => join("\n", @options),
1346
                       'output_format'         => 'HTML',
1347
                       'title'                 => $form->{title},
1348
                       'attachment_basename'   => $locale->text('list_of_transactions') . strftime('_%Y%m%d', localtime time),
1349
                       'std_column_visibility' => 1,
1350
    );
1351
  $report->set_options_from_form();
1348 1352

  
1349
  map { print "$column_header{$_}\n" } @column_index;
1353
  $report->set_columns(%column_defs);
1354
  $report->set_column_order(@columns);
1350 1355

  
1351
  print qq|
1352
        </tr>
1353
|;
1356
  $report->set_export_options($action, @hidden_variables);
1354 1357

  
1355
  # sort the whole thing by account numbers and display
1356
  foreach $ref (sort { $a->{accno} cmp $b->{accno} } @{ $form->{TB} }) {
1357

  
1358
    $description = $form->escape($ref->{description});
1359

  
1360
    $href =
1361
      qq|ca.pl?action=list_transactions&accounttype=$form->{accounttype}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&sort=transdate&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&eur=$form->{eur}&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title&nextsub=$form->{nextsub}&accno=$ref->{accno}&description=$description|;
1362

  
1363
    $ml = ($ref->{category} =~ /(A|C|E)/) ? -1 : 1;
1364

  
1365
    $debit  = ($ref->{debit} != 0) ? $form->format_amount(\%myconfig, $ref->{debit},  2, "&nbsp;") : "&nbsp;";
1366
    $credit = ($ref->{credit} != 0) ? $form->format_amount(\%myconfig, $ref->{credit}, 2, "&nbsp;") : "&nbsp;";
1367
    $begbalance =
1368
      $form->format_amount(\%myconfig, $ref->{balance} * $ml, 2, "&nbsp;");
1369
    $endbalance =
1370
      $form->format_amount(\%myconfig,
1371
                           ($ref->{balance} + $ref->{amount}) * $ml,
1372
                           2, "&nbsp;");
1373

  
1374
    #    next if ($ref->{debit} == 0 && $ref->{credit} == 0);
1375

  
1376
    if ($ref->{charttype} eq "H" && $subtotal && $form->{l_subtotal}) {
1377
      map { $column_data{$_} = "<th>&nbsp;</th>" }
1378
        qw(accno begbalance endbalance);
1379

  
1380
      $subtotalbegbalance =
1381
        $form->format_amount(\%myconfig, $subtotalbegbalance, 2, "&nbsp;");
1382
      $subtotalendbalance =
1383
        $form->format_amount(\%myconfig, $subtotalendbalance, 2, "&nbsp;");
1384
      $subtotaldebit =
1385
        $form->format_amount(\%myconfig, $subtotaldebit, 2, "&nbsp;");
1386
      $subtotalcredit =
1387
        $form->format_amount(\%myconfig, $subtotalcredit, 2, "&nbsp;");
1388

  
1389
      $column_data{description} = "<th>$subtotaldescription</th>";
1390
      $column_data{begbalance}  = "<th align=right>$subtotalbegbalance</th>";
1391
      $column_data{endbalance}  = "<th align=right>$subtotalendbalance</th>";
1392
      $column_data{debit}       = "<th align=right>$subtotaldebit</th>";
1393
      $column_data{credit}      = "<th align=right>$subtotalcredit</th>";
1394

  
1395
      print qq|
1396
	<tr class=listsubtotal>
1397
|;
1398
      map { print "$column_data{$_}\n" } @column_index;
1358
  $report->set_sort_indicator('accno', 1);
1399 1359

  
1400
      print qq|
1401
        </tr>
1402
|;
1403
    }
1360
  my @totals_columns = qw(credit debit begbalance endbalance);
1361
  my %subtotals      = map { $_ => 0 } @totals_columns;
1362
  my %totals         = map { $_ => 0 } @totals_columns;
1363
  my $found_heading  = 0;
1364
  my @tb             = sort { $a->{accno} cmp $b->{accno} } @{ $form->{TB} };
1404 1365

  
1405
    if ($ref->{charttype} eq "H") {
1406
      $subtotal            = 1;
1407
      $subtotaldescription = $ref->{description};
1408
      $subtotaldebit       = $ref->{debit};
1409
      $subtotalcredit      = $ref->{credit};
1410
      $subtotalbegbalance  = 0;
1411
      $subtotalendbalance  = 0;
1366
  # sort the whole thing by account numbers and display
1367
  foreach my $idx (0 .. scalar(@tb) - 1) {
1368
    my $ref  = $tb[$idx];
1369
    my $href = build_std_url('script=ca.pl', 'action=list_transactions', 'accno=' . E($ref->{accno}), 'description=' . E($ref->{description}), @hidden_variables);
1412 1370

  
1413
      next unless $form->{l_heading};
1371
    my $ml   = ($ref->{category} =~ /(A|C|E)/) ? -1 : 1;
1414 1372

  
1415
      map { $column_data{$_} = "<th>&nbsp;</th>" }
1416
        qw(accno debit credit begbalance endbalance);
1417
      $column_data{description} =
1418
        "<th class=listheading>$ref->{description}</th>";
1419
    }
1373
    my $row  = { map { $_ => { 'align' => $column_alignment{$_} } } @columns };
1420 1374

  
1421
    if ($ref->{charttype} eq "A") {
1422
      $column_data{accno}       = "<td><a href=$href>$ref->{accno}</a></td>";
1423
      $column_data{description} = "<td>$ref->{description}</td>";
1424
      $column_data{debit}       = "<td align=right>$debit</td>";
1425
      $column_data{credit}      = "<td align=right>$credit</td>";
1426
      $column_data{begbalance}  = "<td align=right>$begbalance</td>";
1427
      $column_data{endbalance}  = "<td align=right>$endbalance</td>";
1375
    if ($ref->{charttype} eq 'H') {
1376
      next unless ($form->{l_heading});
1428 1377

  
1429
      $totaldebit  += $ref->{debit};
1430
      $totalcredit += $ref->{credit};
1378
      %subtotals                   = map { $_ => 0 } @totals_columns;
1379
      $found_heading               = 1;
1380
      $row->{description}->{class} = 'listheading';
1381
      $row->{description}->{data}  = $ref->{description};
1431 1382

  
1432
      $subtotalbegbalance += $ref->{balance} * $ml;
1433
      $subtotalendbalance += ($ref->{balance} + $ref->{amount}) * $ml;
1383
      $report->add_data($row);
1434 1384

  
1385
      next;
1435 1386
    }
1436 1387

  
1437
    if ($ref->{charttype} eq "H") {
1438
      print qq|
1439
      <tr class=listheading>
1440
|;
1441
    }
1442
    if ($ref->{charttype} eq "A") {
1443
      $i++;
1444
      $i %= 2;
1445
      print qq|
1446
      <tr class=listrow$i>
1447
|;
1388
    foreach (qw(debit credit)) {
1389
      $subtotals{$_} += $ref->{$_};
1390
      $totals{$_}    += $ref->{$_};
1448 1391
    }
1449 1392

  
1450
    map { print "$column_data{$_}\n" } @column_index;
1393
    $subtotals{begbalance} += $ref->{balance} * $ml;
1394
    $subtotals{endbalance} += ($ref->{balance} + $ref->{amount}) * $ml;
1451 1395

  
1452
    print qq|
1453
      </tr>
1454
|;
1455
  }
1396
    map { $row->{$_}->{data} = $ref->{$_} } qw(accno description);
1397
    map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $ref->{$_}, 2) if ($ref->{$_} != 0) } qw(credit debit);
1456 1398

  
1457
  # print last subtotal
1458
  if ($subtotal && $form->{l_subtotal}) {
1459
    map { $column_data{$_} = "<th>&nbsp;</th>" }
1460
      qw(accno begbalance endbalance);
1461
    $subtotalbegbalance =
1462
      $form->format_amount(\%myconfig, $subtotalbegbalance, 2, "&nbsp;");
1463
    $subtotalendbalance =
1464
      $form->format_amount(\%myconfig, $subtotalendbalance, 2, "&nbsp;");
1465
    $subtotaldebit =
1466
      $form->format_amount(\%myconfig, $subtotaldebit, 2, "&nbsp;");
1467
    $subtotalcredit =
1468
      $form->format_amount(\%myconfig, $subtotalcredit, 2, "&nbsp;");
1469
    $column_data{description} = "<th>$subdescription</th>";
1470
    $column_data{begbalance}  = "<th align=right>$subtotalbegbalance</th>";
1471
    $column_data{endbalance}  = "<th align=right>$subtotalendbalance</th>";
1472
    $column_data{debit}       = "<th align=right>$subtotaldebit</th>";
1473
    $column_data{credit}      = "<th align=right>$subtotalcredit</th>";
1399
    $row->{begbalance}->{data} = $form->format_amount(\%myconfig, $ref->{balance} * $ml, 2);
1400
    $row->{endbalance}->{data} = $form->format_amount(\%myconfig, ($ref->{balance} + $ref->{amount}) * $ml, 2);
1474 1401

  
1475
    print qq|
1476
      <tr class=listsubtotal>
1477
|;
1478
    map { print "$column_data{$_}\n" } @column_index;
1402
    $report->add_data($row);
1479 1403

  
1480
    print qq|
1481
      </tr>
1482
|;
1404
    if ($form->{l_heading} && $found_heading &&
1405
        (($idx == scalar(@tb) - 1) || ('H' eq $tb[$idx + 1]->{charttype}))) {
1406
      $report->add_data(create_list_accounts_subtotal_row(\%subtotals, \@columns, \@totals_columns, 'listsubtotal'));
1407
    }
1483 1408
  }
1484 1409

  
1485
  $totaldebit  = $form->format_amount(\%myconfig, $totaldebit,  2, "&nbsp;");
1486
  $totalcredit = $form->format_amount(\%myconfig, $totalcredit, 2, "&nbsp;");
1487

  
1488
  map { $column_data{$_} = "<th>&nbsp;</th>" }
1489
    qw(accno description begbalance endbalance);
1490

  
1491
  $column_data{debit}  = qq|<th align=right class=listtotal>$totaldebit</th>|;
1492
  $column_data{credit} = qq|<th align=right class=listtotal>$totalcredit</th>|;
1493

  
1494
  print qq|
1495
        <tr class=listtotal>
1496
|;
1410
  $report->add_separator();
1497 1411

  
1498
  map { print "$column_data{$_}\n" } @column_index;
1412
  $report->add_data(create_list_accounts_subtotal_row(\%totals, \@columns, [ qw(debit credit) ], 'listtotal'));
1499 1413

  
1500
  print qq|
1501
	</tr>
1502
      </table>
1503
    </td>
1504
  </tr>
1505
  <tr>
1506
    <td><hr size=3 noshade></td>
1507
  </tr>
1508
</table>
1509

  
1510
</body>
1511
</html>
1512
|;
1414
  $report->generate_with_headers();
1513 1415

  
1514 1416
  $lxdebug->leave_sub();
1515 1417
}

Auch abrufbar als: Unified diff