Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b1253e4f

Von Philip Reetz vor fast 19 Jahren hinzugefügt

  • ID b1253e4fa3f2a31c7452894439386d43951f5bc8
  • Vorgänger c7f9bb36
  • Nachfolger 0fdd4332

Perltidy Lauf der Aenderungen zu Splittbuchungen

Unterschiede anzeigen:

SL/GL.pm
40 40

  
41 41
sub delete_transaction {
42 42
  my ($self, $myconfig, $form) = @_;
43
  
43
  $lxdebug->enter_sub();
44

  
44 45
  # connect to database
45 46
  my $dbh = $form->dbconnect_noauto($myconfig);
46 47

  
......
53 54
  # commit and redirect
54 55
  my $rc = $dbh->commit;
55 56
  $dbh->disconnect;
56
  
57
  $lxdebug->leave_sub();
58

  
57 59
  $rc;
58
  
59
}
60 60

  
61
}
61 62

  
62 63
sub post_transaction {
63 64
  my ($self, $myconfig, $form) = @_;
64
  
65
  $lxdebug->enter_sub();
66

  
65 67
  my ($debit, $credit) = (0, 0);
66 68
  my $project_id;
67 69

  
68 70
  my $i;
71

  
69 72
  # check if debit and credit balances
70
  
73

  
71 74
  if ($form->{storno}) {
72
  	$debit = $debit * -1;
73
	$credit = $credit * -1;
74
	$tax = $tax * -1;
75
	$form->{reference} = "Storno-".$form->{reference};
76
	$form->{description} = "Storno-".$form->{description};
77
  }  
75
    $debit               = $debit * -1;
76
    $credit              = $credit * -1;
77
    $tax                 = $tax * -1;
78
    $form->{reference}   = "Storno-" . $form->{reference};
79
    $form->{description} = "Storno-" . $form->{description};
80
  }
78 81

  
79 82
  # connect to database, turn off AutoCommit
80 83
  my $dbh = $form->dbconnect_noauto($myconfig);
......
94 97
  if (!$form->{taxincluded}) {
95 98
    $form->{taxincluded} = 0;
96 99
  }
97
  
100

  
98 101
  my ($query, $sth);
99
  
102

  
100 103
  if ($form->{id}) {
104

  
101 105
    # delete individual transactions
102 106
    $query = qq|DELETE FROM acc_trans 
103 107
                WHERE trans_id = $form->{id}|;
104 108
    $dbh->do($query) || $form->dberror($query);
105
    
109

  
106 110
  } else {
107 111
    my $uid = time;
108 112
    $uid .= $form->{login};
......
111 115
                VALUES ('$uid', (SELECT e.id FROM employee e
112 116
		                 WHERE e.login = '$form->{login}'))|;
113 117
    $dbh->do($query) || $form->dberror($query);
114
    
118

  
115 119
    $query = qq|SELECT g.id FROM gl g
116 120
                WHERE g.reference = '$uid'|;
117 121
    $sth = $dbh->prepare($query);
......
121 125
    $sth->finish;
122 126

  
123 127
  }
124
  
128

  
125 129
  my ($null, $department_id) = split /--/, $form->{department};
126 130
  $department_id *= 1;
127
  
131

  
128 132
  $query = qq|UPDATE gl SET 
129 133
	      reference = '$form->{reference}',
130 134
	      description = '$form->{description}',
......
133 137
	      department_id = $department_id,
134 138
	      taxincluded = '$form->{taxincluded}'
135 139
	      WHERE id = $form->{id}|;
136
	   
140

  
137 141
  $dbh->do($query) || $form->dberror($query);
138 142
  ($taxkey, $rate) = split(/--/, $form->{taxkey});
139 143

  
140

  
141 144
  # insert acc_trans transactions
142 145
  for $i (1 .. $form->{rowcount}) {
146

  
143 147
    # extract accno
144 148
    my ($accno) = split(/--/, $form->{"accno_$i"});
145 149
    my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
146 150
    my $amount = 0;
147
    my $debit = $form->{"debit_$i"};
151
    my $debit  = $form->{"debit_$i"};
148 152
    my $credit = $form->{"credit_$i"};
149
    my $tax = $form->{"tax_$i"};
150
    
153
    my $tax    = $form->{"tax_$i"};
154

  
151 155
    if ($credit) {
152 156
      $amount = $credit;
153 157
      $posted = 0;
154 158
    }
155 159
    if ($debit) {
156 160
      $amount = $debit * -1;
157
      $tax = $tax * -1;
161
      $tax    = $tax * -1;
158 162
      $posted = 0;
159 163
    }
160 164

  
161

  
162 165
    # if there is an amount, add the record
163 166
    if ($amount != 0) {
164
      $project_id = ($form->{"project_id_$i"}) ? $form->{"project_id_$i"} : 'NULL'; 
167
      $project_id =
168
        ($form->{"project_id_$i"}) ? $form->{"project_id_$i"} : 'NULL';
165 169
      $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
166 170
                  source, memo, project_id, taxkey)
167 171
		  VALUES
168 172
		  ($form->{id}, (SELECT c.id
169 173
		                 FROM chart c
170 174
				 WHERE c.accno = '$accno'),
171
		   $amount, '$form->{transdate}', |.
172
		   $dbh->quote($form->{"source_$i"}) .qq|, |.
173
		  $dbh->quote($form->{"memo_$i"}).qq|,
175
		   $amount, '$form->{transdate}', |
176
        . $dbh->quote($form->{"source_$i"}) . qq|, |
177
        . $dbh->quote($form->{"memo_$i"}) . qq|,
174 178
		  $project_id, $taxkey)|;
175
    
179

  
176 180
      $dbh->do($query) || $form->dberror($query);
177 181
    }
178
  
179
    if ($tax !=0) {
180
          # add taxentry
181
          $amount = $tax;
182
          
183
          
184
          $project_id = ($form->{"project_id_$i"}) ? $form->{"project_id_$i"} : 'NULL'; 
185
          $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
182

  
183
    if ($tax != 0) {
184

  
185
      # add taxentry
186
      $amount = $tax;
187

  
188
      $project_id =
189
        ($form->{"project_id_$i"}) ? $form->{"project_id_$i"} : 'NULL';
190
      $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
186 191
                  source, memo, project_id, taxkey)
187 192
                  VALUES
188 193
                  ($form->{id}, (SELECT t.chart_id
189 194
                  FROM tax t
190 195
                  WHERE t.taxkey = $taxkey),
191
                  $amount, '$form->{transdate}', |.
192
		   $dbh->quote($form->{"source_$i"}) .qq|, |.
193
		  $dbh->quote($form->{"memo_$i"}).qq|,
196
                  $amount, '$form->{transdate}', |
197
        . $dbh->quote($form->{"source_$i"}) . qq|, |
198
        . $dbh->quote($form->{"memo_$i"}) . qq|,
194 199
                          $project_id, $taxkey)|;
195
          
196
          $dbh->do($query) || $form->dberror($query);
200

  
201
      $dbh->do($query) || $form->dberror($query);
197 202
    }
198 203
  }
199 204

  
200
  my %audittrail = ( tablename  => 'gl',
201
                     reference  => $form->{reference},
202
		     formname   => 'transaction',
203
		     action     => 'posted',
204
		     id         => $form->{id} );
205
 
205
  my %audittrail = (tablename => 'gl',
206
                    reference => $form->{reference},
207
                    formname  => 'transaction',
208
                    action    => 'posted',
209
                    id        => $form->{id});
210

  
206 211
  # $form->audittrail($dbh, "", \%audittrail);
207 212

  
208 213
  # commit and redirect
209 214
  my $rc = $dbh->commit;
210 215
  $dbh->disconnect;
216
  $lxdebug->leave_sub();
211 217

  
212 218
  $rc;
213 219

  
214 220
}
215 221

  
216

  
217

  
218 222
sub all_transactions {
219 223
  my ($self, $myconfig, $form) = @_;
224
  $lxdebug->enter_sub();
220 225

  
221 226
  # connect to database
222 227
  my $dbh = $form->dbconnect($myconfig);
223 228
  my ($query, $sth, $source, $null);
224 229

  
225 230
  my ($glwhere, $arwhere, $apwhere) = ("1 = 1", "1 = 1", "1 = 1");
226
  
231

  
227 232
  if ($form->{reference}) {
228 233
    $source = $form->like(lc $form->{reference});
229 234
    $glwhere .= " AND lower(g.reference) LIKE '$source'";
......
282 287
  }
283 288

  
284 289
  if ($form->{accno}) {
290

  
285 291
    # get category for account
286 292
    $query = qq|SELECT c.category
287 293
                FROM chart c
288 294
		WHERE c.accno = '$form->{accno}'|;
289
    $sth = $dbh->prepare($query); 
295
    $sth = $dbh->prepare($query);
296

  
297
    $sth->execute || $form->dberror($query);
298
    ($form->{ml}) = $sth->fetchrow_array;
299
    $sth->finish;
290 300

  
291
    $sth->execute || $form->dberror($query); 
292
    ($form->{ml}) = $sth->fetchrow_array; 
293
    $sth->finish; 
294
    
295 301
    if ($form->{datefrom}) {
296 302
      $query = qq|SELECT SUM(ac.amount)
297 303
		  FROM acc_trans ac, chart c
......
306 312
      $sth->finish;
307 313
    }
308 314
  }
309
  
315

  
310 316
  if ($form->{gifi_accno}) {
317

  
311 318
    # get category for account
312 319
    $query = qq|SELECT c.category
313 320
                FROM chart c
314 321
		WHERE c.gifi_accno = '$form->{gifi_accno}'|;
315
    $sth = $dbh->prepare($query); 
322
    $sth = $dbh->prepare($query);
323

  
324
    $sth->execute || $form->dberror($query);
325
    ($form->{ml}) = $sth->fetchrow_array;
326
    $sth->finish;
316 327

  
317
    $sth->execute || $form->dberror($query); 
318
    ($form->{ml}) = $sth->fetchrow_array; 
319
    $sth->finish; 
320
   
321 328
    if ($form->{datefrom}) {
322 329
      $query = qq|SELECT SUM(ac.amount)
323 330
		  FROM acc_trans ac, chart c
......
333 340
    }
334 341
  }
335 342

  
336
  my $false = ($myconfig->{dbdriver} eq 'Pg') ? FALSE : q|'0'|;
343
  my $false = ($myconfig->{dbdriver} eq 'Pg') ? FALSE: q|'0'|;
337 344

  
338
  
339
  my $query = qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, t.taxkey AS sorttax,
345
  my $query =
346
    qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, t.taxkey AS sorttax,
340 347
                 g.description, ac.transdate, ac.source, ac.trans_id,
341 348
		 ac.amount, c.accno, c.gifi_accno, g.notes, t.chart_id, ac.oid
342 349
                 FROM gl g, acc_trans ac, chart c LEFT JOIN tax t ON
......
367 374
	         ORDER BY transdate, trans_id, taxkey DESC, sorttax DESC, oid|;
368 375
  my $sth = $dbh->prepare($query);
369 376
  $sth->execute || $form->dberror($query);
370
  
377

  
371 378
  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
372 379
    print(STDERR $ref->{id}, " Transaction\n");
380

  
373 381
    # gl
374 382
    if ($ref->{type} eq "gl") {
375 383
      $ref->{module} = "gl";
......
392 400
        $ref->{module} = "ar";
393 401
      }
394 402
    }
395
    $balance=$ref->{amount};
396
    $i = 0;
397
    $j = 0;
398
    $k = 0;
399
    $l = 0;
403
    $balance = $ref->{amount};
404
    $i       = 0;
405
    $j       = 0;
406
    $k       = 0;
407
    $l       = 0;
400 408
    if ($ref->{amount} < 0) {
401
      if ($ref->{chart_id} >0) {
402
        $ref->{debit_tax}{$i} = $ref->{amount} * -1;
409
      if ($ref->{chart_id} > 0) {
410
        $ref->{debit_tax}{$i}       = $ref->{amount} * -1;
403 411
        $ref->{debit_tax_accno}{$i} = $ref->{accno};
404
        }
405
      else {
406
        $ref->{debit}{$k} = $ref->{amount} * -1;
407
        $ref->{debit_accno}{$k} = $ref->{accno};
412
      } else {
413
        $ref->{debit}{$k}        = $ref->{amount} * -1;
414
        $ref->{debit_accno}{$k}  = $ref->{accno};
408 415
        $ref->{debit_taxkey}{$k} = $ref->{taxkey};
409
        }
416
      }
410 417
    } else {
411
      if ($ref->{chart_id} >0) {
412
        $ref->{credit_tax}{$j} = $ref->{amount};
418
      if ($ref->{chart_id} > 0) {
419
        $ref->{credit_tax}{$j}       = $ref->{amount};
413 420
        $ref->{credit_tax_accno}{$j} = $ref->{accno};
414
        }
415
      else {
416
        $ref->{credit}{$l} = $ref->{amount};
417
        $ref->{credit_accno}{$l} = $ref->{accno};
421
      } else {
422
        $ref->{credit}{$l}        = $ref->{amount};
423
        $ref->{credit_accno}{$l}  = $ref->{accno};
418 424
        $ref->{credit_taxkey}{$l} = $ref->{taxkey};
419
        }
425
      }
420 426
    }
421 427

  
422
    while (abs($balance)>=0.015) {
423
      my $ref2 = $sth->fetchrow_hashref(NAME_lc) || $form->error("Unbalanced ledger!");
428
    while (abs($balance) >= 0.015) {
429
      my $ref2 = $sth->fetchrow_hashref(NAME_lc)
430
        || $form->error("Unbalanced ledger!");
424 431

  
425
      $balance = (int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000;
426
      print(STDERR $balance," BAlance\n");
432
      $balance =
433
        (int($balance * 100000) + int(100000 * $ref2->{amount})) / 100000;
434
      print(STDERR $balance, " BAlance\n");
427 435
      if ($ref2->{amount} < 0) {
428
        if ($ref2->{chart_id} >0) {
436
        if ($ref2->{chart_id} > 0) {
429 437
          if ($ref->{debit_tax_accno}{$i} ne "") {
430 438
            $i++;
431 439
          }
432
          $ref->{debit_tax}{$i} = $ref2->{amount} * -1;
440
          $ref->{debit_tax}{$i}       = $ref2->{amount} * -1;
433 441
          $ref->{debit_tax_accno}{$i} = $ref2->{accno};
434
          }
435
        else {
442
        } else {
436 443
          if ($ref->{debit_accno}{$k} ne "") {
437 444
            $k++;
438 445
          }
439
          $ref->{debit}{$k} = $ref2->{amount} * -1;
440
          $ref->{debit_accno}{$k} = $ref2->{accno};
446
          $ref->{debit}{$k}        = $ref2->{amount} * -1;
447
          $ref->{debit_accno}{$k}  = $ref2->{accno};
441 448
          $ref->{debit_taxkey}{$k} = $ref2->{taxkey};
442
          }
449
        }
443 450
      } else {
444
        if ($ref2->{chart_id} >0) {
451
        if ($ref2->{chart_id} > 0) {
445 452
          if ($ref->{credit_tax_accno}{$j} ne "") {
446 453
            $j++;
447 454
          }
448
          $ref->{credit_tax}{$j} = $ref2->{amount};
455
          $ref->{credit_tax}{$j}       = $ref2->{amount};
449 456
          $ref->{credit_tax_accno}{$j} = $ref2->{accno};
450
          }
451
        else {
457
        } else {
452 458
          if ($ref->{credit_accno}{$l} ne "") {
453 459
            $l++;
454 460
          }
455
          $ref->{credit}{$l} = $ref2->{amount};
456
          $ref->{credit_accno}{$l} = $ref2->{accno};
461
          $ref->{credit}{$l}        = $ref2->{amount};
462
          $ref->{credit_accno}{$l}  = $ref2->{accno};
457 463
          $ref->{credit_taxkey}{$l} = $ref2->{taxkey};
458
          }
464
        }
459 465
      }
460 466
    }
461
#    print(STDERR Dumper($ref));       
467

  
468
    #    print(STDERR Dumper($ref));
462 469
    push @{ $form->{GL} }, $ref;
463
    $balance=0;
470
    $balance = 0;
464 471
  }
465 472
  $sth->finish;
466 473

  
467 474
  if ($form->{accno}) {
468
    $query = qq|SELECT c.description FROM chart c WHERE c.accno = '$form->{accno}'|;
475
    $query =
476
      qq|SELECT c.description FROM chart c WHERE c.accno = '$form->{accno}'|;
469 477
    $sth = $dbh->prepare($query);
470 478
    $sth->execute || $form->dberror($query);
471 479

  
......
473 481
    $sth->finish;
474 482
  }
475 483
  if ($form->{gifi_accno}) {
476
    $query = qq|SELECT g.description FROM gifi g WHERE g.accno = '$form->{gifi_accno}'|;
484
    $query =
485
      qq|SELECT g.description FROM gifi g WHERE g.accno = '$form->{gifi_accno}'|;
477 486
    $sth = $dbh->prepare($query);
478 487
    $sth->execute || $form->dberror($query);
479 488

  
480 489
    ($form->{gifi_account_description}) = $sth->fetchrow_array;
481 490
    $sth->finish;
482 491
  }
483
 
492
  $lxdebug->leave_sub();
493

  
484 494
  $dbh->disconnect;
485 495

  
486 496
}
487 497

  
488

  
489 498
sub transaction {
490 499
  my ($self, $myconfig, $form) = @_;
491
  
500
  $lxdebug->enter_sub();
501

  
492 502
  my ($query, $sth, $ref);
493
  
503

  
494 504
  # connect to database
495 505
  my $dbh = $form->dbconnect($myconfig);
496 506

  
......
514 524
    $ref = $sth->fetchrow_hashref(NAME_lc);
515 525
    map { $form->{$_} = $ref->{$_} } keys %$ref;
516 526
    $sth->finish;
517
  
527

  
518 528
    # retrieve individual rows
519 529
    $query = "SELECT c.accno, a.amount, project_id,
520 530
                (SELECT p.projectnumber FROM project p
......
525 535
	      ORDER BY a.oid";
526 536
    $sth = $dbh->prepare($query);
527 537
    $sth->execute || $form->dberror($query);
528
    
538

  
529 539
    while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
530 540
      push @{ $form->{GL} }, $ref;
531 541
    }
532 542

  
533
      # get tax description
543
    # get tax description
534 544
    $query = qq| SELECT * FROM tax t|;
535
    $sth = $dbh->prepare($query);
536
    $sth->execute || $form->dberror($query);  
545
    $sth   = $dbh->prepare($query);
546
    $sth->execute || $form->dberror($query);
537 547
    $form->{TAX} = ();
538 548
    while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
539 549
      push @{ $form->{TAX} }, $ref;
540 550
    }
541
  
551

  
542 552
    $sth->finish;
543 553
  } else {
544 554
    $query = "SELECT current_date AS transdate, closedto, revtrans
......
546 556
    $sth = $dbh->prepare($query);
547 557
    $sth->execute || $form->dberror($query);
548 558

  
549
    ($form->{transdate}, $form->{closedto}, $form->{revtrans}) = $sth->fetchrow_array;
550
    
551
      # get tax description
559
    ($form->{transdate}, $form->{closedto}, $form->{revtrans}) =
560
      $sth->fetchrow_array;
561

  
562
    # get tax description
552 563
    $query = qq| SELECT * FROM tax t order by t.taxkey|;
553
    $sth = $dbh->prepare($query);
554
    $sth->execute || $form->dberror($query);  
564
    $sth   = $dbh->prepare($query);
565
    $sth->execute || $form->dberror($query);
555 566
    $form->{TAX} = ();
556 567
    while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
557 568
      push @{ $form->{TAX} }, $ref;
......
572 583
    push @{ $form->{chart} }, $ref;
573 584
  }
574 585
  $sth->finish;
575
  
576 586

  
577
  
578 587
  $sth->finish;
579
  
588
  $lxdebug->leave_sub();
589

  
580 590
  $dbh->disconnect;
581 591

  
582 592
}
583 593

  
584

  
585 594
1;
586 595

  
bin/mozilla/gl.pl
31 31
#
32 32
#======================================================================
33 33

  
34

  
35 34
use SL::GL;
36 35
use SL::PE;
37 36

  
38 37
require "$form->{path}/arap.pl";
39 38

  
40 39
1;
41
# end of main
42 40

  
41
# end of main
43 42

  
44 43
# this is for our long dates
45 44
# $locale->text('January')
......
69 68
# $locale->text('Nov')
70 69
# $locale->text('Dec')
71 70

  
72

  
73 71
sub add {
72
  $lxdebug->enter_sub();
74 73

  
75 74
  $form->{title} = "Add";
76
  
77
  $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback};
75

  
76
  $form->{callback} =
77
    "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
78
    unless $form->{callback};
78 79

  
79 80
  # we use this only to set a default date
80 81
  GL->transaction(\%myconfig, \%$form);
81 82

  
82
  map { $chart .= "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}</option>" } @{ $form->{chart} };
83
  map { $tax .= qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription}  |.($_->{rate} * 100).qq| %|} @{ $form->{TAX} };
84
  
85
  $form->{chart} = $chart;
83
  map {
84
    $chart .=
85
      "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}</option>"
86
  } @{ $form->{chart} };
87
  map {
88
    $tax .=
89
      qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription}  |
90
      . ($_->{rate} * 100) . qq| %|
91
  } @{ $form->{TAX} };
92

  
93
  $form->{chart}     = $chart;
86 94
  $form->{chartinit} = $chart;
87
  $form->{rowcount} = 2;
95
  $form->{rowcount}  = 2;
88 96

  
89
  $form->{debitchart} = $chart;
97
  $form->{debitchart}  = $chart;
90 98
  $form->{creditchart} = $chart;
91
  $form->{taxchart} = $tax;
92
  
93
  $form->{debit} = 0;
99
  $form->{taxchart}    = $tax;
100

  
101
  $form->{debit}  = 0;
94 102
  $form->{credit} = 0;
95
  $form->{tax} = 0;
96
  
103
  $form->{tax}    = 0;
97 104

  
98 105
  # departments
99 106
  $form->all_departments(\%myconfig);
100 107
  if (@{ $form->{all_departments} }) {
101 108
    $form->{selectdepartment} = "<option>\n";
102 109

  
103
    map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
110
    map {
111
      $form->{selectdepartment} .=
112
        "<option>$_->{description}--$_->{id}\n"
113
    } (@{ $form->{all_departments} });
104 114
  }
105
 
115

  
106 116
  &display_form(1);
107
  
108
}
117
  $lxdebug->leave_sub();
109 118

  
119
}
110 120

  
111 121
sub edit {
122
  $lxdebug->enter_sub();
112 123

  
113 124
  GL->transaction(\%myconfig, \%$form);
114 125

  
115
  map { if ($form->{debitaccno} eq $_->{accno}) {$form->{debitchart} .= "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}"} } @{ $form->{chart} };
116
  map { if ($form->{creditaccno} eq $_->{accno}) {$form->{creditchart} .= "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}"} } @{ $form->{chart} };
117
  map { $tax .= qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription}  |.($_->{rate} * 100).qq| %|} @{ $form->{TAX} };
118
  
126
  map {
127
    if ($form->{debitaccno} eq $_->{accno}) {
128
      $form->{debitchart} .=
129
        "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}";
130
    }
131
  } @{ $form->{chart} };
132
  map {
133
    if ($form->{creditaccno} eq $_->{accno}) {
134
      $form->{creditchart} .=
135
        "<option value=\"$_->{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}";
136
    }
137
  } @{ $form->{chart} };
138
  map {
139
    $tax .=
140
      qq|<option value="$_->{taxkey}--$_->{rate}">$_->{taxdescription}  |
141
      . ($_->{rate} * 100) . qq| %|
142
  } @{ $form->{TAX} };
143

  
119 144
  $form->{chart} = $chart;
120 145

  
121 146
  $form->{taxchart} = $tax;
122
  
147

  
123 148
  if ($form->{tax} < 0) {
124 149
    $form->{tax} = $form->{tax} * (-1);
125 150
  }
126
  
127
  $form->{amount}=$form->format_amount(\%myconfig, $form->{amount}, 2);
128
  
151

  
152
  $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2);
153

  
129 154
  # departments
130 155
  $form->all_departments(\%myconfig);
131 156
  if (@{ $form->{all_departments} }) {
132 157
    $form->{selectdepartment} = "<option>\n";
133 158

  
134
    map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
159
    map {
160
      $form->{selectdepartment} .=
161
        "<option>$_->{description}--$_->{id}\n"
162
    } (@{ $form->{all_departments} });
135 163
  }
136 164

  
137
   $i = 1;
165
  $i = 1;
138 166
  foreach $ref (@{ $form->{GL} }) {
139 167
    $form->{"accno_$i"} = "$ref->{accno}--$ref->{description}";
140 168

  
141 169
    $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}";
142 170
    for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} }
143
    
171

  
144 172
    if ($ref->{amount} < 0) {
145 173
      $form->{totaldebit} -= $ref->{amount};
146 174
      $form->{"debit_$i"} = $ref->{amount} * -1;
......
153 181
  }
154 182

  
155 183
  $form->{rowcount} = $i;
156
  $form->{locked} = ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig));
184
  $form->{locked}   =
185
    ($form->datetonum($form->{transdate}, \%myconfig) <=
186
     $form->datetonum($form->{closedto}, \%myconfig));
157 187

  
158 188
  $form->{title} = "Edit";
159
  
189

  
160 190
  &form_header;
161 191
  &display_rows;
162 192
  &form_footer;
163
  
164
}
165

  
193
  $lxdebug->leave_sub();
166 194

  
195
}
167 196

  
168 197
sub search {
198
  $lxdebug->enter_sub();
169 199

  
170 200
  $form->{title} = $locale->text('Buchungsjournal');
171
  
201

  
172 202
  $form->all_departments(\%myconfig);
203

  
173 204
  # departments
174 205
  if (@{ $form->{all_departments} }) {
175 206
    $form->{selectdepartment} = "<option>\n";
176 207

  
177
    map { $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} });
208
    map {
209
      $form->{selectdepartment} .=
210
        "<option>$_->{description}--$_->{id}\n"
211
    } (@{ $form->{all_departments} });
178 212
  }
179
 
213

  
180 214
  $department = qq|
181 215
  	<tr>
182
	  <th align=right nowrap>|.$locale->text('Department').qq|</th>
216
	  <th align=right nowrap>| . $locale->text('Department') . qq|</th>
183 217
	  <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
184 218
	</tr>
185 219
| if $form->{selectdepartment};
186
  
220

  
187 221
  # use JavaScript Calendar or not
188 222
  $form->{jsscript} = $jscalendar;
189 223
  $jsscript = "";
190
  if ($form->{jsscript}) 
191
  {
224
  if ($form->{jsscript}) {
225

  
192 226
    # with JavaScript Calendar
193 227
    $button1 = qq|
194 228
       <td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}">
195
       <input type=button name=datefrom id="trigger1" value=|.$locale->text('button').qq|></td>  
229
       <input type=button name=datefrom id="trigger1" value=|
230
      . $locale->text('button')
231
      . qq|></td>  
196 232
       |;
197
     $button2 = qq|
233
    $button2 = qq|
198 234
       <td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}">
199
       <input type=button name=dateto id="trigger2" value=|.$locale->text('button').qq|></td>
235
       <input type=button name=dateto id="trigger2" value=|
236
      . $locale->text('button')
237
      . qq|></td>
200 238
     |;
201
     #write Trigger
202
     $jsscript = Form->write_trigger(\%myconfig,"2","datefrom","BR","trigger1","dateto","BL","trigger2");
203
   }
204
   else
205
   {
206
      # without JavaScript Calendar
207
      $button1 = qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}"></td>|;
208
      $button2 = qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}"></td>|;
209
    }
239

  
240
    #write Trigger
241
    $jsscript =
242
      Form->write_trigger(\%myconfig, "2", "datefrom", "BR", "trigger1",
243
                          "dateto", "BL", "trigger2");
244
  } else {
245

  
246
    # without JavaScript Calendar
247
    $button1 =
248
      qq|<td><input name=datefrom id=datefrom size=11 title="$myconfig{dateformat}"></td>|;
249
    $button2 =
250
      qq|<td><input name=dateto id=dateto size=11 title="$myconfig{dateformat}"></td>|;
251
  }
210 252

  
211 253
  $form->header;
212 254

  
......
226 268
    <td>
227 269
      <table>
228 270
	<tr>
229
	  <th align=right>|.$locale->text('Reference').qq|</th>
271
	  <th align=right>| . $locale->text('Reference') . qq|</th>
230 272
	  <td><input name=reference size=20></td>
231
	  <th align=right>|.$locale->text('Source').qq|</th>
273
	  <th align=right>| . $locale->text('Source') . qq|</th>
232 274
	  <td><input name=source size=20></td>
233 275
	</tr>
234 276
	$department
235 277
	<tr>
236
	  <th align=right>|.$locale->text('Description').qq|</th>
278
	  <th align=right>| . $locale->text('Description') . qq|</th>
237 279
	  <td colspan=3><input name=description size=40></td>
238 280
	</tr>
239 281
	<tr>
240
	  <th align=right>|.$locale->text('Notes').qq|</th>
282
	  <th align=right>| . $locale->text('Notes') . qq|</th>
241 283
	  <td colspan=3><input name=notes size=40></td>
242 284
	</tr>
243 285
	<tr>
244
	  <th align=right>|.$locale->text('From').qq|</th>
286
	  <th align=right>| . $locale->text('From') . qq|</th>
245 287
          $button1
246 288
          $button2
247 289
	</tr>
248 290
	<tr>
249
	  <th align=right>|.$locale->text('Include in Report').qq|</th>
291
	  <th align=right>| . $locale->text('Include in Report') . qq|</th>
250 292
	  <td colspan=3>
251 293
	    <table>
252 294
	      <tr>
253 295
		<td>
254
		  <input name="category" class=radio type=radio value=X checked>&nbsp;|.$locale->text('All').qq|
255
		  <input name="category" class=radio type=radio value=A>&nbsp;|.$locale->text('Asset').qq|
256
		  <input name="category" class=radio type=radio value=C>&nbsp;|.$locale->text('Contra').qq|
257
		  <input name="category" class=radio type=radio value=L>&nbsp;|.$locale->text('Liability').qq|
258
		  <input name="category" class=radio type=radio value=Q>&nbsp;|.$locale->text('Equity').qq|
259
		  <input name="category" class=radio type=radio value=I>&nbsp;|.$locale->text('Revenue').qq|
260
		  <input name="category" class=radio type=radio value=E>&nbsp;|.$locale->text('Expense').qq|
296
		  <input name="category" class=radio type=radio value=X checked>&nbsp;|
297
    . $locale->text('All') . qq|
298
		  <input name="category" class=radio type=radio value=A>&nbsp;|
299
    . $locale->text('Asset') . qq|
300
		  <input name="category" class=radio type=radio value=C>&nbsp;|
301
    . $locale->text('Contra') . qq|
302
		  <input name="category" class=radio type=radio value=L>&nbsp;|
303
    . $locale->text('Liability') . qq|
304
		  <input name="category" class=radio type=radio value=Q>&nbsp;|
305
    . $locale->text('Equity') . qq|
306
		  <input name="category" class=radio type=radio value=I>&nbsp;|
307
    . $locale->text('Revenue') . qq|
308
		  <input name="category" class=radio type=radio value=E>&nbsp;|
309
    . $locale->text('Expense') . qq|
261 310
		</td>
262 311
	      </tr>
263 312
	      <tr>
264 313
		<table>
265 314
		  <tr>
266 315
		    <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
267
		    <td>|.$locale->text('ID').qq|</td>
316
		    <td>| . $locale->text('ID') . qq|</td>
268 317
		    <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
269
		    <td>|.$locale->text('Date').qq|</td>
318
		    <td>| . $locale->text('Date') . qq|</td>
270 319
		    <td align=right><input name="l_reference" class=checkbox type=checkbox value=Y checked></td>
271
		    <td>|.$locale->text('Reference').qq|</td>
320
		    <td>| . $locale->text('Reference') . qq|</td>
272 321
		    <td align=right><input name="l_description" class=checkbox type=checkbox value=Y checked></td>
273
		    <td>|.$locale->text('Description').qq|</td>
322
		    <td>| . $locale->text('Description') . qq|</td>
274 323
		    <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
275
		    <td>|.$locale->text('Notes').qq|</td>
324
		    <td>| . $locale->text('Notes') . qq|</td>
276 325
		  </tr>
277 326
		  <tr>
278 327
		    <td align=right><input name="l_debit" class=checkbox type=checkbox value=Y checked></td>
279
		    <td>|.$locale->text('Debit').qq|</td>
328
		    <td>| . $locale->text('Debit') . qq|</td>
280 329
		    <td align=right><input name="l_credit" class=checkbox type=checkbox value=Y checked></td>
281
		    <td>|.$locale->text('Credit').qq|</td>
330
		    <td>| . $locale->text('Credit') . qq|</td>
282 331
		    <td align=right><input name="l_source" class=checkbox type=checkbox value=Y checked></td>
283
		    <td>|.$locale->text('Source').qq|</td>
332
		    <td>| . $locale->text('Source') . qq|</td>
284 333
		    <td align=right><input name="l_accno" class=checkbox type=checkbox value=Y checked></td>
285
		    <td>|.$locale->text('Account').qq|</td>
334
		    <td>| . $locale->text('Account') . qq|</td>
286 335
		    <td align=right><input name="l_gifi_accno" class=checkbox type=checkbox value=Y></td>
287
		    <td>|.$locale->text('GIFI').qq|</td>
336
		    <td>| . $locale->text('GIFI') . qq|</td>
288 337
		  </tr>
289 338
		  <tr>
290 339
		    <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
291
		    <td>|.$locale->text('Subtotal').qq|</td>
340
		    <td>| . $locale->text('Subtotal') . qq|</td>
292 341
		  </tr>
293 342
		</table>
294 343
	      </tr>
......
311 360
<input type=hidden name=password value=$form->{password}>
312 361

  
313 362
<br>
314
<input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
363
<input class=submit type=submit name=action value="|
364
    . $locale->text('Continue') . qq|">
315 365
</form>
316 366

  
317 367
</body>
318 368
</html>
319 369
|;
370
  $lxdebug->leave_sub();
320 371
}
321 372

  
322

  
323 373
sub generate_report {
374
  $lxdebug->enter_sub();
324 375

  
325 376
  $form->{sort} = "transdate" unless $form->{sort};
326 377

  
327 378
  GL->all_transactions(\%myconfig, \%$form);
328
  
329
  $callback = "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
379

  
380
  $callback =
381
    "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}";
330 382

  
331 383
  $href = $callback;
332
  
333
  %acctype = ( 'A' => $locale->text('Asset'),
334
               'C' => $locale->text('Contra'),
335
               'L' => $locale->text('Liability'),
336
	       'Q' => $locale->text('Equity'),
337
	       'I' => $locale->text('Revenue'),
338
	       'E' => $locale->text('Expense'),
339
	     );
340
  
384

  
385
  %acctype = ('A' => $locale->text('Asset'),
386
              'C' => $locale->text('Contra'),
387
              'L' => $locale->text('Liability'),
388
              'Q' => $locale->text('Equity'),
389
              'I' => $locale->text('Revenue'),
390
              'E' => $locale->text('Expense'),);
391

  
341 392
  $form->{title} = $locale->text('General Ledger');
342
  
393

  
343 394
  $ml = ($form->{ml} =~ /(A|E)/) ? -1 : 1;
344 395

  
345 396
  unless ($form->{category} eq 'X') {
346
    $form->{title} .= " : ".$locale->text($acctype{$form->{category}});
397
    $form->{title} .= " : " . $locale->text($acctype{ $form->{category} });
347 398
  }
348 399
  if ($form->{accno}) {
349
    $href .= "&accno=".$form->escape($form->{accno});
350
    $callback .= "&accno=".$form->escape($form->{accno},1);
351
    $option = $locale->text('Account')." : $form->{accno} $form->{account_description}";
400
    $href .= "&accno=" . $form->escape($form->{accno});
401
    $callback .= "&accno=" . $form->escape($form->{accno}, 1);
402
    $option =
403
      $locale->text('Account')
404
      . " : $form->{accno} $form->{account_description}";
352 405
  }
353 406
  if ($form->{gifi_accno}) {
354
    $href .= "&gifi_accno=".$form->escape($form->{gifi_accno});
355
    $callback .= "&gifi_accno=".$form->escape($form->{gifi_accno},1);
356
    $option .= "\n<br>" if $option;
357
    $option .= $locale->text('GIFI')." : $form->{gifi_accno} $form->{gifi_account_description}";
407
    $href     .= "&gifi_accno=" . $form->escape($form->{gifi_accno});
408
    $callback .= "&gifi_accno=" . $form->escape($form->{gifi_accno}, 1);
409
    $option   .= "\n<br>" if $option;
410
    $option   .=
411
      $locale->text('GIFI')
412
      . " : $form->{gifi_accno} $form->{gifi_account_description}";
358 413
  }
359 414
  if ($form->{source}) {
360
    $href .= "&source=".$form->escape($form->{source});
361
    $callback .= "&source=".$form->escape($form->{source},1);
362
    $option .= "\n<br>" if $option;
363
    $option .= $locale->text('Source')." : $form->{source}";
415
    $href     .= "&source=" . $form->escape($form->{source});
416
    $callback .= "&source=" . $form->escape($form->{source}, 1);
417
    $option   .= "\n<br>" if $option;
418
    $option   .= $locale->text('Source') . " : $form->{source}";
364 419
  }
365 420
  if ($form->{reference}) {
366
    $href .= "&reference=".$form->escape($form->{reference});
367
    $callback .= "&reference=".$form->escape($form->{reference},1);
368
    $option .= "\n<br>" if $option;
369
    $option .= $locale->text('Reference')." : $form->{reference}";
421
    $href     .= "&reference=" . $form->escape($form->{reference});
422
    $callback .= "&reference=" . $form->escape($form->{reference}, 1);
423
    $option   .= "\n<br>" if $option;
424
    $option   .= $locale->text('Reference') . " : $form->{reference}";
370 425
  }
371 426
  if ($form->{department}) {
372
    $href .= "&department=".$form->escape($form->{department});
373
    $callback .= "&department=".$form->escape($form->{department},1);
427
    $href .= "&department=" . $form->escape($form->{department});
428
    $callback .= "&department=" . $form->escape($form->{department}, 1);
374 429
    ($department) = split /--/, $form->{department};
375 430
    $option .= "\n<br>" if $option;
376
    $option .= $locale->text('Department')." : $department";
431
    $option .= $locale->text('Department') . " : $department";
377 432
  }
378 433

  
379 434
  if ($form->{description}) {
380
    $href .= "&description=".$form->escape($form->{description});
381
    $callback .= "&description=".$form->escape($form->{description},1);
382
    $option .= "\n<br>" if $option;
383
    $option .= $locale->text('Description')." : $form->{description}";
435
    $href     .= "&description=" . $form->escape($form->{description});
436
    $callback .= "&description=" . $form->escape($form->{description}, 1);
437
    $option   .= "\n<br>" if $option;
438
    $option   .= $locale->text('Description') . " : $form->{description}";
384 439
  }
385 440
  if ($form->{notes}) {
386
    $href .= "&notes=".$form->escape($form->{notes});
387
    $callback .= "&notes=".$form->escape($form->{notes},1);
388
    $option .= "\n<br>" if $option;
389
    $option .= $locale->text('Notes')." : $form->{notes}";
441
    $href     .= "&notes=" . $form->escape($form->{notes});
442
    $callback .= "&notes=" . $form->escape($form->{notes}, 1);
443
    $option   .= "\n<br>" if $option;
444
    $option   .= $locale->text('Notes') . " : $form->{notes}";
390 445
  }
391
   
446

  
392 447
  if ($form->{datefrom}) {
393
    $href .= "&datefrom=$form->{datefrom}";
448
    $href     .= "&datefrom=$form->{datefrom}";
394 449
    $callback .= "&datefrom=$form->{datefrom}";
395
    $option .= "\n<br>" if $option;
396
    $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{datefrom}, 1);
450
    $option   .= "\n<br>" if $option;
451
    $option   .=
452
        $locale->text('From') . " "
453
      . $locale->date(\%myconfig, $form->{datefrom}, 1);
397 454
  }
398 455
  if ($form->{dateto}) {
399
    $href .= "&dateto=$form->{dateto}";
456
    $href     .= "&dateto=$form->{dateto}";
400 457
    $callback .= "&dateto=$form->{dateto}";
401 458
    if ($form->{datefrom}) {
402 459
      $option .= " ";
403 460
    } else {
404 461
      $option .= "\n<br>" if $option;
405 462
    }
406
    $option .= $locale->text('Bis')." ".$locale->date(\%myconfig, $form->{dateto}, 1);
463
    $option .=
464
        $locale->text('Bis') . " "
465
      . $locale->date(\%myconfig, $form->{dateto}, 1);
407 466
  }
408 467

  
409

  
410
  @columns = $form->sort_columns(qw(transdate id reference description notes source debit debit_accno credit credit_accno debit_tax debit_tax_accno credit_tax credit_tax_accno accno gifi_accno));
468
  @columns =
469
    $form->sort_columns(
470
    qw(transdate id reference description notes source debit debit_accno credit credit_accno debit_tax debit_tax_accno credit_tax credit_tax_accno accno gifi_accno)
471
    );
411 472

  
412 473
  if ($form->{accno} || $form->{gifi_accno}) {
413 474
    @columns = grep !/(accno|gifi_accno)/, @columns;
414 475
    push @columns, "balance";
415 476
    $form->{l_balance} = "Y";
416
 
417
 }
418
  
419
  $form->{l_credit_accno} = "Y";
420
  $form->{l_debit_accno} = "Y";
421
  $form->{l_credit_tax} = "Y";
422
  $form->{l_debit_tax} = "Y";
477

  
478
  }
479

  
480
  $form->{l_credit_accno}     = "Y";
481
  $form->{l_debit_accno}      = "Y";
482
  $form->{l_credit_tax}       = "Y";
483
  $form->{l_debit_tax}        = "Y";
423 484
  $form->{l_credit_tax_accno} = "Y";
424
  $form->{l_debit_tax_accno} = "Y";
425
  $form->{l_accno} = "N";
485
  $form->{l_debit_tax_accno}  = "Y";
486
  $form->{l_accno}            = "N";
426 487
  foreach $item (@columns) {
427 488
    if ($form->{"l_$item"} eq "Y") {
428 489
      push @column_index, $item;
429 490

  
430 491
      # add column to href and callback
431 492
      $callback .= "&l_$item=Y";
432
      $href .= "&l_$item=Y";
493
      $href     .= "&l_$item=Y";
433 494
    }
434 495
  }
435 496

  
436 497
  if ($form->{l_subtotal} eq 'Y') {
437 498
    $callback .= "&l_subtotal=Y";
438
    $href .= "&l_subtotal=Y";
499
    $href     .= "&l_subtotal=Y";
439 500
  }
440 501

  
441 502
  $callback .= "&category=$form->{category}";
442
  $href .= "&category=$form->{category}";
443

  
444
  $column_header{id} = "<th><a class=listheading href=$href&sort=id>".$locale->text('ID')."</a></th>";
445
  $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
446
  $column_header{reference} = "<th><a class=listheading href=$href&sort=reference>".$locale->text('Reference')."</a></th>";
447
  $column_header{source} = "<th><a class=listheading href=$href&sort=source>".$locale->text('Source')."</a></th>";
448
  $column_header{description} = "<th><a class=listheading href=$href&sort=description>".$locale->text('Description')."</a></th>";
449
  $column_header{notes} = "<th class=listheading>".$locale->text('Notes')."</th>";
450
  $column_header{debit} = "<th class=listheading>".$locale->text('Debit')."</th>";
451
  $column_header{debit_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Debit Account')."</a></th>";
452
  $column_header{credit} = "<th class=listheading>".$locale->text('Credit')."</th>";
453
  $column_header{credit_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Credit Account')."</a></th>";
454
  $column_header{debit_tax} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Debit Tax')."</a></th>";
455
  $column_header{debit_tax_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Debit Tax Account')."</a></th>";
456
  $column_header{credit_tax} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Credit Tax')."</a></th>";
457
  $column_header{credit_tax_accno} = "<th><a class=listheading href=$href&sort=accno>".$locale->text('Credit Tax Account')."</a></th>";
458
  $column_header{gifi_accno} = "<th><a class=listheading href=$href&sort=gifi_accno>".$locale->text('GIFI')."</a></th>";
459
  $column_header{balance} = "<th>".$locale->text('Balance')."</th>";
460
  
503
  $href     .= "&category=$form->{category}";
504

  
505
  $column_header{id} =
506
      "<th><a class=listheading href=$href&sort=id>"
507
    . $locale->text('ID')
508
    . "</a></th>";
509
  $column_header{transdate} =
510
      "<th><a class=listheading href=$href&sort=transdate>"
511
    . $locale->text('Date')
512
    . "</a></th>";
513
  $column_header{reference} =
514
      "<th><a class=listheading href=$href&sort=reference>"
515
    . $locale->text('Reference')
516
    . "</a></th>";
517
  $column_header{source} =
518
      "<th><a class=listheading href=$href&sort=source>"
519
    . $locale->text('Source')
520
    . "</a></th>";
521
  $column_header{description} =
522
      "<th><a class=listheading href=$href&sort=description>"
523
    . $locale->text('Description')
524
    . "</a></th>";
525
  $column_header{notes} =
526
    "<th class=listheading>" . $locale->text('Notes') . "</th>";
527
  $column_header{debit} =
528
    "<th class=listheading>" . $locale->text('Debit') . "</th>";
529
  $column_header{debit_accno} =
530
      "<th><a class=listheading href=$href&sort=accno>"
531
    . $locale->text('Debit Account')
532
    . "</a></th>";
533
  $column_header{credit} =
534
    "<th class=listheading>" . $locale->text('Credit') . "</th>";
535
  $column_header{credit_accno} =
536
      "<th><a class=listheading href=$href&sort=accno>"
537
    . $locale->text('Credit Account')
538
    . "</a></th>";
539
  $column_header{debit_tax} =
540
      "<th><a class=listheading href=$href&sort=accno>"
541
    . $locale->text('Debit Tax')
542
    . "</a></th>";
543
  $column_header{debit_tax_accno} =
544
      "<th><a class=listheading href=$href&sort=accno>"
545
    . $locale->text('Debit Tax Account')
546
    . "</a></th>";
547
  $column_header{credit_tax} =
548
      "<th><a class=listheading href=$href&sort=accno>"
549
    . $locale->text('Credit Tax')
550
    . "</a></th>";
551
  $column_header{credit_tax_accno} =
552
      "<th><a class=listheading href=$href&sort=accno>"
553
    . $locale->text('Credit Tax Account')
554
    . "</a></th>";
555
  $column_header{gifi_accno} =
556
      "<th><a class=listheading href=$href&sort=gifi_accno>"
557
    . $locale->text('GIFI')
558
    . "</a></th>";
559
  $column_header{balance} = "<th>" . $locale->text('Balance') . "</th>";
560

  
461 561
  $form->{landscape} = 1;
462
  
562

  
463 563
  $form->header;
464 564

  
465 565
  print qq|
......
480 580
	<tr class=listheading>
481 581
|;
482 582

  
483
map { print "$column_header{$_}\n" } @column_index;
583
  map { print "$column_header{$_}\n" } @column_index;
484 584

  
485
print "
585
  print "
486 586
        </tr>
487 587
        </thead>
488 588
        </tfoot>
489 589
        <tbody>
490 590
";
491
  
591

  
492 592
  # add sort to callback
493 593
  $form->{callback} = "$callback&sort=$form->{sort}";
494 594
  $callback = $form->escape($form->{callback});
495
  
595

  
496 596
  # initial item for subtotals
497 597
  if (@{ $form->{GL} }) {
498
    $sameitem = $form->{GL}->[0]->{$form->{sort}};
598
    $sameitem = $form->{GL}->[0]->{ $form->{sort} };
499 599
  }
500
  
600

  
501 601
  if (($form->{accno} || $form->{gifi_accno}) && $form->{balance}) {
502 602

  
503 603
    map { $column_data{$_} = "<td>&nbsp;</td>" } @column_index;
504
    $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</td>";
505
    
506
    $i++; $i %= 2;
604
    $column_data{balance} =
605
        "<td align=right>"
606
      . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
607
      . "</td>";
608

  
609
    $i++;
610
    $i %= 2;
507 611
    print qq|
508 612
        <tr class=listrow$i>
509 613
|;
510 614
    map { print "$column_data{$_}\n" } @column_index;
511
    
615

  
512 616
    print qq|
513 617
        </tr>
514 618
|;
515 619
  }
516
    
620

  
517 621
  foreach $ref (@{ $form->{GL} }) {
518 622

  
519 623
    # if item ne sort print subtotal
520 624
    if ($form->{l_subtotal} eq 'Y') {
521
      if ($sameitem ne $ref->{$form->{sort}}) {
522
	&gl_subtotal;
625
      if ($sameitem ne $ref->{ $form->{sort} }) {
626
        &gl_subtotal;
523 627
      }
524 628
    }
525
    foreach $key (sort keys (%{$ref->{amount}})) {
629
    foreach $key (sort keys(%{ $ref->{amount} })) {
526 630
      $form->{balance} += $ref->{amount}{$key};
527 631
    }
528
    
632

  
529 633
    $debit = "";
530
    foreach $key (sort keys (%{$ref->{debit}})) {
634
    foreach $key (sort keys(%{ $ref->{debit} })) {
531 635
      $subtotaldebit += $ref->{debit}{$key};
532
      $totaldebit += $ref->{debit}{$key};
636
      $totaldebit    += $ref->{debit}{$key};
533 637
      if ($key == 0) {
534
        $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key} , 2, 0);
638
        $debit = $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
535 639
      } else {
536
        $debit .= "<br>".$form->format_amount(\%myconfig, $ref->{debit}{$key} , 2, 0);
640
        $debit .=
641
          "<br>" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0);
537 642
      }
538 643
    }
539
    
644

  
540 645
    $credit = "";
541
    foreach $key (sort keys (%{$ref->{credit}})) {
646
    foreach $key (sort keys(%{ $ref->{credit} })) {
542 647
      $subtotalcredit += $ref->{credit}{$key};
543
      $totalcredit += $ref->{credit}{$key};
648
      $totalcredit    += $ref->{credit}{$key};
544 649
      if ($key == 0) {
545
        $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key} , 2, 0);
650
        $credit = $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
546 651
      } else {
547
        $credit .= "<br>".$form->format_amount(\%myconfig, $ref->{credit}{$key} , 2, 0);
548
      }      
652
        $credit .= "<br>"
653
          . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0);
654
      }
549 655
    }
550
    
656

  
551 657
    $debittax = "";
552
    foreach $key (sort keys (%{$ref->{debit_tax}})) {
658
    foreach $key (sort keys(%{ $ref->{debit_tax} })) {
553 659
      $subtotaldebittax += $ref->{debit_tax}{$key};
554
      $totaldebittax += $ref->{debit_tax}{$key};
660
      $totaldebittax    += $ref->{debit_tax}{$key};
555 661
      if ($key == 0) {
556
        $debittax = $form->format_amount(\%myconfig, $ref->{debit_tax}{$key} , 2, 0);
662
        $debittax =
663
          $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
557 664
      } else {
558
        $debittax .= "<br>".$form->format_amount(\%myconfig, $ref->{debit_tax}{$key} , 2, 0);
665
        $debittax .= "<br>"
666
          . $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0);
559 667
      }
560 668
    }
561
    
669

  
562 670
    $credittax = "";
563
    foreach $key (sort keys (%{$ref->{credit_tax}})) {
671
    foreach $key (sort keys(%{ $ref->{credit_tax} })) {
564 672
      $subtotalcredittax += $ref->{credit_tax}{$key};
565
      $totalcredittax += $ref->{credit_tax}{$key};
673
      $totalcredittax    += $ref->{credit_tax}{$key};
566 674
      if ($key == 0) {
567
        $credittax = $form->format_amount(\%myconfig, $ref->{credit_tax}{$key} , 2, 0);
675
        $credittax =
676
          $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
568 677
      } else {
569
        $credittax .= "<br>".$form->format_amount(\%myconfig, $ref->{credit_tax}{$key} , 2, 0);
678
        $credittax .= "<br>"
679
          . $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0);
570 680
      }
571 681
    }
572
    
573
    $debitaccno = "";
682

  
683
    $debitaccno  = "";
574 684
    $debittaxkey = "";
575
    $taxaccno = "";
576
    foreach $key (sort keys (%{$ref->{debit_accno}})) {
685
    $taxaccno    = "";
686
    foreach $key (sort keys(%{ $ref->{debit_accno} })) {
577 687
      if ($key == 0) {
578
        $debitaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_accno}{$key}</a>";
688
        $debitaccno =
689
          "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_accno}{$key}</a>";
579 690
      } else {
580
        $debitaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_accno}{$key}</a>";
691
        $debitaccno .=
692
          "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_accno}{$key}</a>";
581 693
      }
582 694
      if ($ref->{debit_taxkey}{$key} eq $debittaxkey) {
583 695
        $ref->{debit_tax_accno}{$key} = $taxaccno;
584
      }      
585
      $taxaccno = $ref->{debit_tax_accno}{$key};
696
      }
697
      $taxaccno    = $ref->{debit_tax_accno}{$key};
586 698
      $debittaxkey = $ref->{debit_taxkey}{$key};
587 699
    }
588
    
589
    $creditaccno = "";
700

  
701
    $creditaccno  = "";
590 702
    $credittaxkey = "";
591
    $taxaccno = "";
592
    foreach $key (sort keys (%{$ref->{credit_accno}})) {
703
    $taxaccno     = "";
704
    foreach $key (sort keys(%{ $ref->{credit_accno} })) {
593 705
      if ($key == 0) {
594
        $creditaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_accno}{$key}</a>";
706
        $creditaccno =
707
          "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_accno}{$key}</a>";
595 708
      } else {
596
        $creditaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_accno}{$key}</a>";
709
        $creditaccno .=
710
          "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_accno}{$key}</a>";
597 711
      }
598 712
      if ($ref->{credit_taxkey}{$key} eq $credittaxkey) {
599 713
        $ref->{credit_tax_accno}{$key} = $taxaccno;
600 714
      }
601
      $taxaccno = $ref->{credit_tax_accno}{$key};
715
      $taxaccno     = $ref->{credit_tax_accno}{$key};
602 716
      $credittaxkey = $ref->{credit_taxkey}{$key};
603
    }    
604
    
717
    }
718

  
605 719
    $debittaxaccno = "";
606
    foreach $key (sort keys (%{$ref->{debit_tax_accno}})) {
720
    foreach $key (sort keys(%{ $ref->{debit_tax_accno} })) {
607 721
      if ($key == 0) {
608
        $debittaxaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
722
        $debittaxaccno =
723
          "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
609 724
      } else {
610
        $debittaxaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
725
        $debittaxaccno .=
726
          "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}</a>";
611 727
      }
612 728
    }
613
    
729

  
614 730
    $credittaxaccno = "";
615
    foreach $key (sort keys (%{$ref->{credit_tax_accno}})) {
731
    foreach $key (sort keys(%{ $ref->{credit_tax_accno} })) {
616 732
      if ($key == 0) {
617
        $credittaxaccno = "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
733
        $credittaxaccno =
734
          "<a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
618 735
      } else {
619
        $credittaxaccno .= "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
736
        $credittaxaccno .=
737
          "<br><a href=$href&accno=$ref->{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}</a>";
620 738
      }
621
    }    
622
#    $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, "&nbsp;");
623
#    $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, "&nbsp;");
624
    
625
    $column_data{id} = "<td align=right>&nbsp;$ref->{id}&nbsp;</td>";
626
    $column_data{transdate} = "<td align=center>&nbsp;$ref->{transdate}&nbsp;</td>";
627
    $column_data{reference} = "<td align=center><a href=$ref->{module}.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}</td>";
628
    $column_data{description} = "<td align=center>$ref->{description}&nbsp;</td>";
629
    $column_data{source} = "<td align=center>$ref->{source}&nbsp;</td>";
630
    $column_data{notes} = "<td align=center>$ref->{notes}&nbsp;</td>";
631
    $column_data{debit} = "<td align=right>$debit</td>";
632
    $column_data{debit_accno} = "<td align=center>$debitaccno</td>";
633
    $column_data{credit} = "<td align=right>$credit</td>";
739
    }
740

  
741
    #    $ref->{debit} = $form->format_amount(\%myconfig, $ref->{debit}, 2, "&nbsp;");
742
    #    $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, "&nbsp;");
743

  
744
    $column_data{id}        = "<td align=right>&nbsp;$ref->{id}&nbsp;</td>";
745
    $column_data{transdate} =
746
      "<td align=center>&nbsp;$ref->{transdate}&nbsp;</td>";
747
    $column_data{reference} =
748
      "<td align=center><a href=$ref->{module}.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}</td>";
749
    $column_data{description} =
750
      "<td align=center>$ref->{description}&nbsp;</td>";
751
    $column_data{source}       = "<td align=center>$ref->{source}&nbsp;</td>";
752
    $column_data{notes}        = "<td align=center>$ref->{notes}&nbsp;</td>";
753
    $column_data{debit}        = "<td align=right>$debit</td>";
754
    $column_data{debit_accno}  = "<td align=center>$debitaccno</td>";
755
    $column_data{credit}       = "<td align=right>$credit</td>";
634 756
    $column_data{credit_accno} = "<td align=center>$creditaccno</td>";
635
    $column_data{debit_tax} = ($ref->{debit_tax_accno} ne "") ? "<td align=right>$debittax</td>" : "<td></td>";
757
    $column_data{debit_tax}    =
758
      ($ref->{debit_tax_accno} ne "")
759
      ? "<td align=right>$debittax</td>"
760
      : "<td></td>";
636 761
    $column_data{debit_tax_accno} = "<td align=center>$debittaxaccno</td>";
637
    $column_data{gifi_accno} = "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a>&nbsp;</td>";
638
    $column_data{credit_tax} = ($ref->{credit_tax_accno} ne "") ? "<td align=right>$credittax</td>" : "<td></td>";
762
    $column_data{gifi_accno}      =
763
      "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a>&nbsp;</td>";
764
    $column_data{credit_tax} =
765
      ($ref->{credit_tax_accno} ne "")
766
      ? "<td align=right>$credittax</td>"
767
      : "<td></td>";
639 768
    $column_data{credit_tax_accno} = "<td align=center>$credittaxaccno</td>";
640
    $column_data{gifi_accno} = "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a>&nbsp;</td>";
641
    $column_data{balance} = "<td align=right>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</td>";
769
    $column_data{gifi_accno}       =
770
      "<td><a href=$href&gifi_accno=$ref->{gifi_accno}&callback=$callback>$ref->{gifi_accno}</a>&nbsp;</td>";
771
    $column_data{balance} =
772
        "<td align=right>"
773
      . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)
774
      . "</td>";
642 775

  
643
    $i++; $i %= 2;
776
    $i++;
777
    $i %= 2;
644 778
    print "
645 779
        <tr class=listrow$i>";
646 780
    map { print "$column_data{$_}\n" } @column_index;
647 781
    print "</tr>";
648
    
649
  }
650 782

  
783
  }
651 784

  
652 785
  &gl_subtotal if ($form->{l_subtotal} eq 'Y');
653 786

  
654

  
655 787
  map { $column_data{$_} = "<td>&nbsp;</td>" } @column_index;
656
  
657
  $column_data{debit} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totaldebit, 2, "&nbsp;")."</th>";
658
  $column_data{credit} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totalcredit, 2, "&nbsp;")."</th>";
659
  $column_data{debit_tax} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totaldebittax, 2, "&nbsp;")."</th>";
660
  $column_data{credit_tax} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $totalcredittax, 2, "&nbsp;")."</th>";
661
  $column_data{balance} = "<th align=right class=listtotal>".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."</th>";
662
  
788

  
789
  $column_data{debit} =
790
    "<th align=right class=listtotal>"
791
    . $form->format_amount(\%myconfig, $totaldebit, 2, "&nbsp;") . "</th>";
792
  $column_data{credit} =
793
    "<th align=right class=listtotal>"
794
    . $form->format_amount(\%myconfig, $totalcredit, 2, "&nbsp;") . "</th>";
795
  $column_data{debit_tax} =
796
    "<th align=right class=listtotal>"
797
    . $form->format_amount(\%myconfig, $totaldebittax, 2, "&nbsp;") . "</th>";
798
  $column_data{credit_tax} =
799
    "<th align=right class=listtotal>"
800
    . $form->format_amount(\%myconfig, $totalcredittax, 2, "&nbsp;") . "</th>";
801
  $column_data{balance} =
802
    "<th align=right class=listtotal>"
803
    . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . "</th>";
804

  
663 805
  print qq|
664 806
	<tr class=listtotal>
665 807
|;
......
687 829
<input type=hidden name=login value=$form->{login}>
... Dieser Diff wurde abgeschnitten, weil er die maximale Anzahl anzuzeigender Zeilen überschreitet.

Auch abrufbar als: Unified diff